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_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
877 str
= "Cannot have local-as same as BGP AS number";
879 case BGP_ERR_TCPSIG_FAILED
:
880 str
= "Error while applying TCP-Sig to session(s)";
882 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
883 str
= "ebgp-multihop and ttl-security cannot be configured together";
885 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
886 str
= "ttl-security only allowed for EBGP peers";
888 case BGP_ERR_AS_OVERRIDE
:
889 str
= "as-override cannot be configured for IBGP peers";
891 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
892 str
= "Invalid limit for number of dynamic neighbors";
894 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
895 str
= "Dynamic neighbor listen range already exists";
897 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
898 str
= "Operation not allowed on a dynamic neighbor";
900 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
901 str
= "Operation not allowed on a directly connected neighbor";
903 case BGP_ERR_PEER_SAFI_CONFLICT
:
904 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
906 case BGP_ERR_GR_INVALID_CMD
:
907 str
= "The Graceful Restart command used is not valid at this moment.";
909 case BGP_ERR_GR_OPERATION_FAILED
:
910 str
= "The Graceful Restart Operation failed due to an err.";
912 case BGP_ERR_PEER_GROUP_MEMBER
:
913 str
= "Peer-group member cannot override remote-as of peer-group.";
915 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
916 str
= "Peer-group members must be all internal or all external.";
918 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
919 str
= "Range specified cannot be deleted because it is not part of current config.";
921 case BGP_ERR_INSTANCE_MISMATCH
:
922 str
= "Instance specified does not match the current instance.";
924 case BGP_ERR_NO_INTERFACE_CONFIG
:
925 str
= "Interface specified is not being used for interface based peer.";
927 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
928 str
= "No configuration already specified for soft reconfiguration.";
930 case BGP_ERR_AS_MISMATCH
:
931 str
= "BGP is already running.";
933 case BGP_ERR_AF_UNCONFIGURED
:
934 str
= "AFI/SAFI specified is not currently configured.";
936 case BGP_ERR_INVALID_AS
:
937 str
= "Confederation AS specified is the same AS as our AS.";
939 case BGP_ERR_INVALID_ROLE_NAME
:
940 str
= "Invalid role name";
942 case BGP_ERR_INVALID_INTERNAL_ROLE
:
943 str
= "External roles can be set only on eBGP session";
947 vty_out(vty
, "%% %s\n", str
);
948 return CMD_WARNING_CONFIG_FAILED
;
953 /* BGP clear sort. */
962 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
963 safi_t safi
, int error
)
966 case BGP_ERR_AF_UNCONFIGURED
:
969 "%% BGP: Enable %s address family for the neighbor %s\n",
970 get_afi_safi_str(afi
, safi
, false), peer
->host
);
973 "%% BGP: Enable %s address family for the neighbor %s",
974 get_afi_safi_str(afi
, safi
, false), peer
->host
);
976 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
979 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
983 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
991 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
992 struct listnode
**nnode
, enum bgp_clear_type stype
)
997 /* if afi/.safi not specified, spin thru all of them */
998 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1001 enum bgp_af_index index
;
1003 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1004 paf
= peer
->peer_af_array
[index
];
1008 if (paf
&& paf
->subgroup
)
1009 SET_FLAG(paf
->subgroup
->sflags
,
1010 SUBGRP_STATUS_FORCE_UPDATES
);
1013 tmp_safi
= paf
->safi
;
1014 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1017 if (stype
== BGP_CLEAR_SOFT_NONE
)
1018 ret
= peer_clear(peer
, nnode
);
1020 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1023 /* if afi specified and safi not, spin thru safis on this afi */
1024 } else if (safi
== SAFI_UNSPEC
) {
1027 for (tmp_safi
= SAFI_UNICAST
;
1028 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1029 if (!peer
->afc
[afi
][tmp_safi
])
1032 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1033 if (paf
&& paf
->subgroup
)
1034 SET_FLAG(paf
->subgroup
->sflags
,
1035 SUBGRP_STATUS_FORCE_UPDATES
);
1037 if (stype
== BGP_CLEAR_SOFT_NONE
)
1038 ret
= peer_clear(peer
, nnode
);
1040 ret
= peer_clear_soft(peer
, afi
,
1043 /* both afi/safi specified, let the caller know if not defined */
1045 if (!peer
->afc
[afi
][safi
])
1048 paf
= peer_af_find(peer
, afi
, safi
);
1049 if (paf
&& paf
->subgroup
)
1050 SET_FLAG(paf
->subgroup
->sflags
,
1051 SUBGRP_STATUS_FORCE_UPDATES
);
1053 if (stype
== BGP_CLEAR_SOFT_NONE
)
1054 ret
= peer_clear(peer
, nnode
);
1056 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1062 /* `clear ip bgp' functions. */
1063 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1064 enum clear_sort sort
, enum bgp_clear_type stype
,
1071 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1073 /* Clear all neighbors. */
1075 * Pass along pointer to next node to peer_clear() when walking all
1076 * nodes on the BGP instance as that may get freed if it is a
1079 if (sort
== clear_all
) {
1080 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1082 bgp_peer_gr_flags_update(peer
);
1084 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1085 gr_router_detected
= true;
1087 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1091 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1094 if (gr_router_detected
1095 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1096 bgp_zebra_send_capabilities(bgp
, false);
1097 } else if (!gr_router_detected
1098 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1099 bgp_zebra_send_capabilities(bgp
, true);
1102 /* This is to apply read-only mode on this clear. */
1103 if (stype
== BGP_CLEAR_SOFT_NONE
)
1104 bgp
->update_delay_over
= 0;
1109 /* Clear specified neighbor. */
1110 if (sort
== clear_peer
) {
1113 /* Make sockunion for lookup. */
1114 ret
= str2sockunion(arg
, &su
);
1116 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1118 peer
= peer_lookup_by_hostname(bgp
, arg
);
1121 "Malformed address or name: %s\n",
1127 peer
= peer_lookup(bgp
, &su
);
1130 "%% BGP: Unknown neighbor - \"%s\"\n",
1136 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1137 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1139 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1141 /* if afi/safi not defined for this peer, let caller know */
1143 ret
= BGP_ERR_AF_UNCONFIGURED
;
1146 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1151 /* Clear all neighbors belonging to a specific peer-group. */
1152 if (sort
== clear_group
) {
1153 struct peer_group
*group
;
1155 group
= peer_group_lookup(bgp
, arg
);
1157 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1161 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1162 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1165 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1172 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1173 get_afi_safi_str(afi
, safi
, false), arg
);
1178 /* Clear all external (eBGP) neighbors. */
1179 if (sort
== clear_external
) {
1180 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1181 if (peer
->sort
== BGP_PEER_IBGP
)
1184 bgp_peer_gr_flags_update(peer
);
1186 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1187 gr_router_detected
= true;
1189 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1192 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1197 if (gr_router_detected
1198 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1199 bgp_zebra_send_capabilities(bgp
, false);
1200 } else if (!gr_router_detected
1201 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1202 bgp_zebra_send_capabilities(bgp
, true);
1207 "%% BGP: No external %s peer is configured\n",
1208 get_afi_safi_str(afi
, safi
, false));
1213 /* Clear all neighbors belonging to a specific AS. */
1214 if (sort
== clear_as
) {
1215 as_t as
= strtoul(arg
, NULL
, 10);
1217 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1221 bgp_peer_gr_flags_update(peer
);
1223 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1224 gr_router_detected
= true;
1226 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1229 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1234 if (gr_router_detected
1235 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1236 bgp_zebra_send_capabilities(bgp
, false);
1237 } else if (!gr_router_detected
1238 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1239 bgp_zebra_send_capabilities(bgp
, true);
1244 "%% BGP: No %s peer is configured with AS %s\n",
1245 get_afi_safi_str(afi
, safi
, false), arg
);
1253 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1254 safi_t safi
, enum clear_sort sort
,
1255 enum bgp_clear_type stype
, const char *arg
)
1259 /* BGP structure lookup. */
1261 bgp
= bgp_lookup_by_name(name
);
1263 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1267 bgp
= bgp_get_default();
1269 vty_out(vty
, "No BGP process is configured\n");
1274 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1277 /* clear soft inbound */
1278 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1283 FOREACH_AFI_SAFI (afi
, safi
)
1284 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1285 BGP_CLEAR_SOFT_IN
, NULL
);
1288 /* clear soft outbound */
1289 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1294 FOREACH_AFI_SAFI (afi
, safi
)
1295 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1296 BGP_CLEAR_SOFT_OUT
, NULL
);
1300 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1302 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1305 #ifndef VTYSH_EXTRACT_PL
1306 #include "bgpd/bgp_vty_clippy.c"
1309 DEFUN_HIDDEN (bgp_local_mac
,
1311 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1313 "Local MAC config\n"
1314 "VxLAN Network Identifier\n"
1318 "mac-mobility sequence\n"
1328 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1329 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1330 vty_out(vty
, "%% Malformed MAC address\n");
1333 memset(&ip
, 0, sizeof(ip
));
1334 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1336 bgp
= bgp_get_default();
1338 vty_out(vty
, "Default BGP instance is not there\n");
1342 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1345 vty_out(vty
, "Internal error\n");
1352 DEFUN_HIDDEN (no_bgp_local_mac
,
1353 no_bgp_local_mac_cmd
,
1354 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1357 "Local MAC config\n"
1358 "VxLAN Network Identifier\n"
1369 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1370 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1371 vty_out(vty
, "%% Malformed MAC address\n");
1374 memset(&ip
, 0, sizeof(ip
));
1376 bgp
= bgp_get_default();
1378 vty_out(vty
, "Default BGP instance is not there\n");
1382 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1384 vty_out(vty
, "Internal error\n");
1391 DEFUN (no_synchronization
,
1392 no_synchronization_cmd
,
1393 "no synchronization",
1395 "Perform IGP synchronization\n")
1400 DEFUN (no_auto_summary
,
1401 no_auto_summary_cmd
,
1404 "Enable automatic network number summarization\n")
1409 /* "router bgp" commands. */
1410 DEFUN_NOSH (router_bgp
,
1412 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1416 BGP_INSTANCE_HELP_STR
)
1419 int idx_view_vrf
= 3;
1425 const char *name
= NULL
;
1426 enum bgp_instance_type inst_type
;
1428 // "router bgp" without an ASN
1430 // Pending: Make VRF option available for ASN less config
1431 bgp
= bgp_get_default();
1434 vty_out(vty
, "%% No BGP process is configured\n");
1435 return CMD_WARNING_CONFIG_FAILED
;
1438 if (listcount(bm
->bgp
) > 1) {
1439 vty_out(vty
, "%% Please specify ASN and VRF\n");
1440 return CMD_WARNING_CONFIG_FAILED
;
1446 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1448 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1449 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1450 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1452 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1454 name
= argv
[idx_vrf
]->arg
;
1456 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1457 if (strmatch(name
, VRF_DEFAULT_NAME
))
1460 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1461 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1462 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1465 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1466 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1468 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1470 case BGP_ERR_AS_MISMATCH
:
1471 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1472 return CMD_WARNING_CONFIG_FAILED
;
1473 case BGP_ERR_INSTANCE_MISMATCH
:
1475 "BGP instance name and AS number mismatch\n");
1477 "BGP instance is already running; AS is %u\n",
1479 return CMD_WARNING_CONFIG_FAILED
;
1483 * If we just instantiated the default instance, complete
1484 * any pending VRF-VPN leaking that was configured via
1485 * earlier "router bgp X vrf FOO" blocks.
1487 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1488 vpn_leak_postchange_all();
1490 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1491 bgp_vpn_leak_export(bgp
);
1492 /* Pending: handle when user tries to change a view to vrf n vv.
1496 /* unset the auto created flag as the user config is now present */
1497 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1498 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1503 /* "no router bgp" commands. */
1504 DEFUN (no_router_bgp
,
1506 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1511 BGP_INSTANCE_HELP_STR
)
1517 const char *name
= NULL
;
1519 // "no router bgp" without an ASN
1521 // Pending: Make VRF option available for ASN less config
1522 bgp
= bgp_get_default();
1525 vty_out(vty
, "%% No BGP process is configured\n");
1526 return CMD_WARNING_CONFIG_FAILED
;
1529 if (listcount(bm
->bgp
) > 1) {
1530 vty_out(vty
, "%% Please specify ASN and VRF\n");
1531 return CMD_WARNING_CONFIG_FAILED
;
1535 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1537 return CMD_WARNING_CONFIG_FAILED
;
1540 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1543 name
= argv
[idx_vrf
]->arg
;
1544 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1545 && strmatch(name
, VRF_DEFAULT_NAME
))
1549 /* Lookup bgp structure. */
1550 bgp
= bgp_lookup(as
, name
);
1552 vty_out(vty
, "%% Can't find BGP instance\n");
1553 return CMD_WARNING_CONFIG_FAILED
;
1557 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1559 return CMD_WARNING_CONFIG_FAILED
;
1562 /* Cannot delete default instance if vrf instances exist */
1563 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1564 struct listnode
*node
;
1565 struct bgp
*tmp_bgp
;
1567 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1568 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1570 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1571 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1572 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1573 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1574 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1575 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1576 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1577 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1578 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1579 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1581 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1582 (bgp
== bgp_get_evpn() &&
1583 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1584 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1585 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1586 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1587 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1588 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1589 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1590 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1591 (hashcount(tmp_bgp
->vnihash
))) {
1593 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1594 return CMD_WARNING_CONFIG_FAILED
;
1605 /* bgp session-dscp */
1607 DEFPY (bgp_session_dscp
,
1608 bgp_session_dscp_cmd
,
1609 "bgp session-dscp (0-63)$dscp",
1611 "Override default (C6) bgp TCP session DSCP value\n"
1612 "Manually configured dscp parameter\n")
1614 bm
->tcp_dscp
= dscp
<< 2;
1619 DEFPY (no_bgp_session_dscp
,
1620 no_bgp_session_dscp_cmd
,
1621 "no bgp session-dscp [(0-63)]",
1624 "Override default (C6) bgp TCP session DSCP value\n"
1625 "Manually configured dscp parameter\n")
1627 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1632 /* BGP router-id. */
1634 DEFPY (bgp_router_id
,
1636 "bgp router-id A.B.C.D",
1638 "Override configured router identifier\n"
1639 "Manually configured router identifier\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1642 bgp_router_id_static_set(bgp
, router_id
);
1646 DEFPY (no_bgp_router_id
,
1647 no_bgp_router_id_cmd
,
1648 "no bgp router-id [A.B.C.D]",
1651 "Override configured router identifier\n"
1652 "Manually configured router identifier\n")
1654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1656 if (router_id_str
) {
1657 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1658 vty_out(vty
, "%% BGP router-id doesn't match\n");
1659 return CMD_WARNING_CONFIG_FAILED
;
1663 router_id
.s_addr
= 0;
1664 bgp_router_id_static_set(bgp
, router_id
);
1669 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1670 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1672 "Add community specific parameters\n"
1673 "Create an alias for a community\n"
1674 "Community (AA:BB or AA:BB:CC)\n"
1677 struct community_alias ca
= {};
1678 struct community_alias
*lookup_community
;
1679 struct community_alias
*lookup_alias
;
1680 struct community
*comm
;
1681 struct lcommunity
*lcomm
;
1682 uint8_t invalid
= 0;
1684 comm
= community_str2com(community
);
1687 community_free(&comm
);
1689 lcomm
= lcommunity_str2com(community
);
1692 lcommunity_free(&lcomm
);
1695 vty_out(vty
, "Invalid community format\n");
1699 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1700 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1702 lookup_community
= bgp_ca_community_lookup(&ca
);
1703 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1706 bgp_ca_alias_delete(&ca
);
1707 bgp_ca_community_delete(&ca
);
1710 /* Lookup if community hash table has an item
1711 * with the same alias name.
1713 strlcpy(ca
.community
, lookup_alias
->community
,
1714 sizeof(ca
.community
));
1715 if (bgp_ca_community_lookup(&ca
)) {
1717 "community (%s) already has this alias (%s)\n",
1718 lookup_alias
->community
,
1719 lookup_alias
->alias
);
1722 bgp_ca_alias_delete(&ca
);
1725 if (lookup_community
) {
1726 /* Lookup if alias hash table has an item
1727 * with the same community.
1729 strlcpy(ca
.alias
, lookup_community
->alias
,
1731 if (bgp_ca_alias_lookup(&ca
)) {
1733 "alias (%s) already has this community (%s)\n",
1734 lookup_community
->alias
,
1735 lookup_community
->community
);
1738 bgp_ca_community_delete(&ca
);
1741 bgp_ca_alias_insert(&ca
);
1742 bgp_ca_community_insert(&ca
);
1748 DEFPY (bgp_global_suppress_fib_pending
,
1749 bgp_global_suppress_fib_pending_cmd
,
1750 "[no] bgp suppress-fib-pending",
1753 "Advertise only routes that are programmed in kernel to peers globally\n")
1755 bm_wait_for_fib_set(!no
);
1760 DEFPY (bgp_suppress_fib_pending
,
1761 bgp_suppress_fib_pending_cmd
,
1762 "[no] bgp suppress-fib-pending",
1765 "Advertise only routes that are programmed in kernel to peers\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1769 bgp_suppress_fib_pending_set(bgp
, !no
);
1774 /* BGP Cluster ID. */
1775 DEFUN (bgp_cluster_id
,
1777 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1779 "Configure Route-Reflector Cluster-id\n"
1780 "Route-Reflector Cluster-id in IP address format\n"
1781 "Route-Reflector Cluster-id as 32 bit quantity\n")
1783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1786 struct in_addr cluster
;
1788 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1790 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1791 return CMD_WARNING_CONFIG_FAILED
;
1794 bgp_cluster_id_set(bgp
, &cluster
);
1795 bgp_clear_star_soft_out(vty
, bgp
->name
);
1800 DEFUN (no_bgp_cluster_id
,
1801 no_bgp_cluster_id_cmd
,
1802 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1805 "Configure Route-Reflector Cluster-id\n"
1806 "Route-Reflector Cluster-id in IP address format\n"
1807 "Route-Reflector Cluster-id as 32 bit quantity\n")
1809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1810 bgp_cluster_id_unset(bgp
);
1811 bgp_clear_star_soft_out(vty
, bgp
->name
);
1820 "Disable BGP route installation to RIB (Zebra)\n")
1822 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1824 "%% No-RIB option is already set, nothing to do here.\n");
1828 bgp_option_norib_set_runtime();
1833 DEFPY (no_bgp_norib
,
1838 "Disable BGP route installation to RIB (Zebra)\n")
1840 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1842 "%% No-RIB option is not set, nothing to do here.\n");
1846 bgp_option_norib_unset_runtime();
1851 DEFPY (no_bgp_send_extra_data
,
1852 no_bgp_send_extra_data_cmd
,
1853 "[no] bgp send-extra-data zebra",
1856 "Extra data to Zebra for display/use\n"
1860 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1862 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1867 DEFUN (bgp_confederation_identifier
,
1868 bgp_confederation_identifier_cmd
,
1869 "bgp confederation identifier (1-4294967295)",
1871 "AS confederation parameters\n"
1873 "Set routing domain confederation AS\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1879 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1881 bgp_confederation_id_set(bgp
, as
);
1886 DEFUN (no_bgp_confederation_identifier
,
1887 no_bgp_confederation_identifier_cmd
,
1888 "no bgp confederation identifier [(1-4294967295)]",
1891 "AS confederation parameters\n"
1893 "Set routing domain confederation AS\n")
1895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1896 bgp_confederation_id_unset(bgp
);
1901 DEFUN (bgp_confederation_peers
,
1902 bgp_confederation_peers_cmd
,
1903 "bgp confederation peers (1-4294967295)...",
1905 "AS confederation parameters\n"
1906 "Peer ASs in BGP confederation\n"
1909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1914 for (i
= idx_asn
; i
< argc
; i
++) {
1915 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1917 if (bgp
->as
== as
) {
1919 "%% Local member-AS not allowed in confed peer list\n");
1923 bgp_confederation_peers_add(bgp
, as
);
1928 DEFUN (no_bgp_confederation_peers
,
1929 no_bgp_confederation_peers_cmd
,
1930 "no bgp confederation peers (1-4294967295)...",
1933 "AS confederation parameters\n"
1934 "Peer ASs in BGP confederation\n"
1937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1942 for (i
= idx_asn
; i
< argc
; i
++) {
1943 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1945 bgp_confederation_peers_remove(bgp
, as
);
1951 * Central routine for maximum-paths configuration.
1952 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1953 * @set: 1 for setting values, 0 for removing the max-paths config.
1955 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1956 const char *mpaths
, uint16_t options
,
1959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1960 uint16_t maxpaths
= 0;
1965 afi
= bgp_node_afi(vty
);
1966 safi
= bgp_node_safi(vty
);
1969 maxpaths
= strtol(mpaths
, NULL
, 10);
1970 if (maxpaths
> multipath_num
) {
1972 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1973 maxpaths
, multipath_num
);
1974 return CMD_WARNING_CONFIG_FAILED
;
1976 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1979 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1983 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1984 (set
== 1) ? "" : "un",
1985 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1986 maxpaths
, afi
, safi
);
1987 return CMD_WARNING_CONFIG_FAILED
;
1990 bgp_recalculate_all_bestpaths(bgp
);
1995 DEFUN (bgp_maxmed_admin
,
1996 bgp_maxmed_admin_cmd
,
1997 "bgp max-med administrative ",
1999 "Advertise routes with max-med\n"
2000 "Administratively applied, for an indefinite period\n")
2002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp
->v_maxmed_admin
= 1;
2005 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2007 bgp_maxmed_update(bgp
);
2012 DEFUN (bgp_maxmed_admin_medv
,
2013 bgp_maxmed_admin_medv_cmd
,
2014 "bgp max-med administrative (0-4294967295)",
2016 "Advertise routes with max-med\n"
2017 "Administratively applied, for an indefinite period\n"
2018 "Max MED value to be used\n")
2020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2023 bgp
->v_maxmed_admin
= 1;
2024 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2026 bgp_maxmed_update(bgp
);
2031 DEFUN (no_bgp_maxmed_admin
,
2032 no_bgp_maxmed_admin_cmd
,
2033 "no bgp max-med administrative [(0-4294967295)]",
2036 "Advertise routes with max-med\n"
2037 "Administratively applied, for an indefinite period\n"
2038 "Max MED value to be used\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2041 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2042 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2043 bgp_maxmed_update(bgp
);
2048 DEFUN (bgp_maxmed_onstartup
,
2049 bgp_maxmed_onstartup_cmd
,
2050 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2052 "Advertise routes with max-med\n"
2053 "Effective on a startup\n"
2054 "Time (seconds) period for max-med\n"
2055 "Max MED value to be used\n")
2057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2061 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2062 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2063 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2065 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2067 bgp_maxmed_update(bgp
);
2072 DEFUN (no_bgp_maxmed_onstartup
,
2073 no_bgp_maxmed_onstartup_cmd
,
2074 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2077 "Advertise routes with max-med\n"
2078 "Effective on a startup\n"
2079 "Time (seconds) period for max-med\n"
2080 "Max MED value to be used\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2084 /* Cancel max-med onstartup if its on */
2085 if (bgp
->t_maxmed_onstartup
) {
2086 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2087 bgp
->maxmed_onstartup_over
= 1;
2090 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2091 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2093 bgp_maxmed_update(bgp
);
2098 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2099 uint16_t update_delay
,
2100 uint16_t establish_wait
)
2102 struct listnode
*node
, *nnode
;
2104 bool vrf_cfg
= false;
2107 * See if update-delay is set per-vrf and warn user to delete it
2108 * Note that we only need to check this if this is the first time
2109 * setting the global config.
2111 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2112 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2113 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2115 "%% update-delay configuration found in vrf %s\n",
2116 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2126 "%%Failed: global update-delay config not permitted\n");
2130 if (!establish_wait
) { /* update-delay <delay> */
2131 bm
->v_update_delay
= update_delay
;
2132 bm
->v_establish_wait
= bm
->v_update_delay
;
2134 /* update-delay <delay> <establish-wait> */
2135 if (update_delay
< establish_wait
) {
2137 "%%Failed: update-delay less than the establish-wait!\n");
2138 return CMD_WARNING_CONFIG_FAILED
;
2141 bm
->v_update_delay
= update_delay
;
2142 bm
->v_establish_wait
= establish_wait
;
2145 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2146 bgp
->v_update_delay
= bm
->v_update_delay
;
2147 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2153 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2155 struct listnode
*node
, *nnode
;
2158 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2159 bm
->v_establish_wait
= bm
->v_update_delay
;
2161 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2162 bgp
->v_update_delay
= bm
->v_update_delay
;
2163 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2169 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2170 uint16_t establish_wait
)
2172 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2174 /* if configured globally, per-instance config is not allowed */
2175 if (bm
->v_update_delay
) {
2177 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2178 return CMD_WARNING_CONFIG_FAILED
;
2182 if (!establish_wait
) /* update-delay <delay> */
2184 bgp
->v_update_delay
= update_delay
;
2185 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2189 /* update-delay <delay> <establish-wait> */
2190 if (update_delay
< establish_wait
) {
2192 "%%Failed: update-delay less than the establish-wait!\n");
2193 return CMD_WARNING_CONFIG_FAILED
;
2196 bgp
->v_update_delay
= update_delay
;
2197 bgp
->v_establish_wait
= establish_wait
;
2202 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2206 /* If configured globally, cannot remove from one bgp instance */
2207 if (bm
->v_update_delay
) {
2209 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2210 return CMD_WARNING_CONFIG_FAILED
;
2212 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2213 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2218 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2220 /* If configured globally, no need to display per-instance value */
2221 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2222 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2223 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2224 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2229 /* Global update-delay configuration */
2230 DEFPY (bgp_global_update_delay
,
2231 bgp_global_update_delay_cmd
,
2232 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2234 "Force initial delay for best-path and updates for all bgp instances\n"
2235 "Max delay in seconds\n"
2236 "Establish wait in seconds\n")
2238 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2241 /* Global update-delay deconfiguration */
2242 DEFPY (no_bgp_global_update_delay
,
2243 no_bgp_global_update_delay_cmd
,
2244 "no bgp update-delay [(0-3600) [(1-3600)]]",
2247 "Force initial delay for best-path and updates\n"
2248 "Max delay in seconds\n"
2249 "Establish wait in seconds\n")
2251 return bgp_global_update_delay_deconfig_vty(vty
);
2254 /* Update-delay configuration */
2256 DEFPY (bgp_update_delay
,
2257 bgp_update_delay_cmd
,
2258 "update-delay (0-3600)$delay [(1-3600)$wait]",
2259 "Force initial delay for best-path and updates\n"
2260 "Max delay in seconds\n"
2261 "Establish wait in seconds\n")
2263 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2266 /* Update-delay deconfiguration */
2267 DEFPY (no_bgp_update_delay
,
2268 no_bgp_update_delay_cmd
,
2269 "no update-delay [(0-3600) [(1-3600)]]",
2271 "Force initial delay for best-path and updates\n"
2272 "Max delay in seconds\n"
2273 "Establish wait in seconds\n")
2275 return bgp_update_delay_deconfig_vty(vty
);
2279 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2284 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2285 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2290 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2295 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2296 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2301 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2304 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2305 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2306 vty_out(vty
, " write-quanta %d\n", quanta
);
2309 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2312 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2313 if (quanta
!= BGP_READ_PACKET_MAX
)
2314 vty_out(vty
, " read-quanta %d\n", quanta
);
2317 /* Packet quanta configuration
2319 * XXX: The value set here controls the size of a stack buffer in the IO
2320 * thread. When changing these limits be careful to prevent stack overflow.
2322 * Furthermore, the maximums used here should correspond to
2323 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2325 DEFPY (bgp_wpkt_quanta
,
2326 bgp_wpkt_quanta_cmd
,
2327 "[no] write-quanta (1-64)$quanta",
2329 "How many packets to write to peer socket per run\n"
2330 "Number of packets\n")
2332 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2335 DEFPY (bgp_rpkt_quanta
,
2336 bgp_rpkt_quanta_cmd
,
2337 "[no] read-quanta (1-10)$quanta",
2339 "How many packets to read from peer socket per I/O cycle\n"
2340 "Number of packets\n")
2342 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2345 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2347 if (!bgp
->heuristic_coalesce
)
2348 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2351 /* BGP TCP keepalive */
2352 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2354 if (bgp
->tcp_keepalive_idle
) {
2355 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2356 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2357 bgp
->tcp_keepalive_probes
);
2361 DEFUN (bgp_coalesce_time
,
2362 bgp_coalesce_time_cmd
,
2363 "coalesce-time (0-4294967295)",
2364 "Subgroup coalesce timer\n"
2365 "Subgroup coalesce timer value (in ms)\n")
2367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2371 bgp
->heuristic_coalesce
= false;
2373 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2374 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2379 DEFUN (no_bgp_coalesce_time
,
2380 no_bgp_coalesce_time_cmd
,
2381 "no coalesce-time (0-4294967295)",
2383 "Subgroup coalesce timer\n"
2384 "Subgroup coalesce timer value (in ms)\n")
2386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2388 bgp
->heuristic_coalesce
= true;
2389 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2393 /* Maximum-paths configuration */
2394 DEFUN (bgp_maxpaths
,
2396 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2397 "Forward packets over multiple paths\n"
2398 "Number of paths\n")
2401 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2402 argv
[idx_number
]->arg
, 0, 1);
2405 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2406 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2407 "Forward packets over multiple paths\n"
2408 "Number of paths\n")
2410 DEFUN (bgp_maxpaths_ibgp
,
2411 bgp_maxpaths_ibgp_cmd
,
2412 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2413 "Forward packets over multiple paths\n"
2415 "Number of paths\n")
2418 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2419 argv
[idx_number
]->arg
, 0, 1);
2422 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2423 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2424 "Forward packets over multiple paths\n"
2426 "Number of paths\n")
2428 DEFUN (bgp_maxpaths_ibgp_cluster
,
2429 bgp_maxpaths_ibgp_cluster_cmd
,
2430 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2431 "Forward packets over multiple paths\n"
2434 "Match the cluster length\n")
2437 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2438 argv
[idx_number
]->arg
, true, 1);
2441 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2442 "maximum-paths ibgp " CMD_RANGE_STR(
2443 1, MULTIPATH_NUM
) " equal-cluster-length",
2444 "Forward packets over multiple paths\n"
2447 "Match the cluster length\n")
2449 DEFUN (no_bgp_maxpaths
,
2450 no_bgp_maxpaths_cmd
,
2451 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2453 "Forward packets over multiple paths\n"
2454 "Number of paths\n")
2456 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2459 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2460 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2461 "Forward packets over multiple paths\n"
2462 "Number of paths\n")
2464 DEFUN (no_bgp_maxpaths_ibgp
,
2465 no_bgp_maxpaths_ibgp_cmd
,
2466 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2468 "Forward packets over multiple paths\n"
2471 "Match the cluster length\n")
2473 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2476 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2477 "no maximum-paths ibgp [" CMD_RANGE_STR(
2478 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2480 "Forward packets over multiple paths\n"
2483 "Match the cluster length\n")
2485 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2486 afi_t afi
, safi_t safi
)
2488 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2489 vty_out(vty
, " maximum-paths %d\n",
2490 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2493 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2494 vty_out(vty
, " maximum-paths ibgp %d",
2495 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2496 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2497 vty_out(vty
, " equal-cluster-length");
2506 "timers bgp (0-65535) (0-65535)",
2507 "Adjust routing timers\n"
2509 "Keepalive interval\n"
2512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2514 int idx_number_2
= 3;
2515 unsigned long keepalive
= 0;
2516 unsigned long holdtime
= 0;
2518 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2519 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2521 /* Holdtime value check. */
2522 if (holdtime
< 3 && holdtime
!= 0) {
2524 "%% hold time value must be either 0 or greater than 3\n");
2525 return CMD_WARNING_CONFIG_FAILED
;
2528 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2529 BGP_DEFAULT_DELAYOPEN
);
2534 DEFUN (no_bgp_timers
,
2536 "no timers bgp [(0-65535) (0-65535)]",
2538 "Adjust routing timers\n"
2540 "Keepalive interval\n"
2543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2544 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2545 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2550 /* BGP minimum holdtime. */
2552 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2553 "bgp minimum-holdtime (1-65535)",
2554 "BGP specific commands\n"
2555 "BGP minimum holdtime\n"
2558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2560 unsigned long min_holdtime
;
2562 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2564 bgp
->default_min_holdtime
= min_holdtime
;
2569 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2570 "no bgp minimum-holdtime [(1-65535)]",
2572 "BGP specific commands\n"
2573 "BGP minimum holdtime\n"
2576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2578 bgp
->default_min_holdtime
= 0;
2583 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2584 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2586 "TCP keepalive parameters\n"
2587 "TCP keepalive idle time (seconds)\n"
2588 "TCP keepalive interval (seconds)\n"
2589 "TCP keepalive maximum probes\n")
2591 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2593 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2599 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2600 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2603 "TCP keepalive parameters\n"
2604 "TCP keepalive idle time (seconds)\n"
2605 "TCP keepalive interval (seconds)\n"
2606 "TCP keepalive maximum probes\n")
2608 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2610 bgp_tcp_keepalive_unset(bgp
);
2615 DEFUN (bgp_client_to_client_reflection
,
2616 bgp_client_to_client_reflection_cmd
,
2617 "bgp client-to-client reflection",
2619 "Configure client to client route reflection\n"
2620 "reflection of routes allowed\n")
2622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2623 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2624 bgp_clear_star_soft_out(vty
, bgp
->name
);
2629 DEFUN (no_bgp_client_to_client_reflection
,
2630 no_bgp_client_to_client_reflection_cmd
,
2631 "no bgp client-to-client reflection",
2634 "Configure client to client route reflection\n"
2635 "reflection of routes allowed\n")
2637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2638 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2639 bgp_clear_star_soft_out(vty
, bgp
->name
);
2644 /* "bgp always-compare-med" configuration. */
2645 DEFUN (bgp_always_compare_med
,
2646 bgp_always_compare_med_cmd
,
2647 "bgp always-compare-med",
2649 "Allow comparing MED from different neighbors\n")
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2653 bgp_recalculate_all_bestpaths(bgp
);
2658 DEFUN (no_bgp_always_compare_med
,
2659 no_bgp_always_compare_med_cmd
,
2660 "no bgp always-compare-med",
2663 "Allow comparing MED from different neighbors\n")
2665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2666 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2667 bgp_recalculate_all_bestpaths(bgp
);
2673 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2674 "bgp ebgp-requires-policy",
2676 "Require in and out policy for eBGP peers (RFC8212)\n")
2678 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2679 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2683 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2684 "no bgp ebgp-requires-policy",
2687 "Require in and out policy for eBGP peers (RFC8212)\n")
2689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2690 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2694 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2695 "bgp suppress-duplicates",
2697 "Suppress duplicate updates if the route actually not changed\n")
2699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2700 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2704 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2705 "no bgp suppress-duplicates",
2708 "Suppress duplicate updates if the route actually not changed\n")
2710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2711 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2715 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2716 "bgp reject-as-sets",
2718 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 struct listnode
*node
, *nnode
;
2724 bgp
->reject_as_sets
= true;
2726 /* Reset existing BGP sessions to reject routes
2727 * with aspath containing AS_SET or AS_CONFED_SET.
2729 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2730 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2731 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2732 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2733 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2740 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2741 "no bgp reject-as-sets",
2744 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2747 struct listnode
*node
, *nnode
;
2750 bgp
->reject_as_sets
= false;
2752 /* Reset existing BGP sessions to reject routes
2753 * with aspath containing AS_SET or AS_CONFED_SET.
2755 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2756 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2757 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2758 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2759 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2766 /* "bgp deterministic-med" configuration. */
2767 DEFUN (bgp_deterministic_med
,
2768 bgp_deterministic_med_cmd
,
2769 "bgp deterministic-med",
2771 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2775 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2776 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2777 bgp_recalculate_all_bestpaths(bgp
);
2783 DEFUN (no_bgp_deterministic_med
,
2784 no_bgp_deterministic_med_cmd
,
2785 "no bgp deterministic-med",
2788 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2791 int bestpath_per_as_used
;
2795 struct listnode
*node
, *nnode
;
2797 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2798 bestpath_per_as_used
= 0;
2800 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2801 FOREACH_AFI_SAFI (afi
, safi
)
2802 if (bgp_addpath_dmed_required(
2803 peer
->addpath_type
[afi
][safi
])) {
2804 bestpath_per_as_used
= 1;
2808 if (bestpath_per_as_used
)
2812 if (bestpath_per_as_used
) {
2814 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2815 return CMD_WARNING_CONFIG_FAILED
;
2817 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2818 bgp_recalculate_all_bestpaths(bgp
);
2825 /* "bgp graceful-restart mode" configuration. */
2826 DEFUN (bgp_graceful_restart
,
2827 bgp_graceful_restart_cmd
,
2828 "bgp graceful-restart",
2833 int ret
= BGP_GR_FAILURE
;
2835 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2836 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2842 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2845 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2846 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2848 "Graceful restart configuration changed, reset all peers to take effect\n");
2849 return bgp_vty_return(vty
, ret
);
2852 DEFUN (no_bgp_graceful_restart
,
2853 no_bgp_graceful_restart_cmd
,
2854 "no bgp graceful-restart",
2860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2862 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2863 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2865 int ret
= BGP_GR_FAILURE
;
2867 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2869 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2872 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2873 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2875 "Graceful restart configuration changed, reset all peers to take effect\n");
2877 return bgp_vty_return(vty
, ret
);
2880 DEFUN (bgp_graceful_restart_stalepath_time
,
2881 bgp_graceful_restart_stalepath_time_cmd
,
2882 "bgp graceful-restart stalepath-time (1-4095)",
2884 "Graceful restart capability parameters\n"
2885 "Set the max time to hold onto restarting peer's stale paths\n"
2886 "Delay value (seconds)\n")
2888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2892 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2893 bgp
->stalepath_time
= stalepath
;
2897 DEFUN (bgp_graceful_restart_restart_time
,
2898 bgp_graceful_restart_restart_time_cmd
,
2899 "bgp graceful-restart restart-time (0-4095)",
2901 "Graceful restart capability parameters\n"
2902 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2903 "Delay value (seconds)\n")
2905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2909 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2910 bgp
->restart_time
= restart
;
2914 DEFUN (bgp_graceful_restart_select_defer_time
,
2915 bgp_graceful_restart_select_defer_time_cmd
,
2916 "bgp graceful-restart select-defer-time (0-3600)",
2918 "Graceful restart capability parameters\n"
2919 "Set the time to defer the BGP route selection after restart\n"
2920 "Delay value (seconds, 0 - disable)\n")
2922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2924 uint32_t defer_time
;
2926 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2927 bgp
->select_defer_time
= defer_time
;
2928 if (defer_time
== 0)
2929 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2931 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2936 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2937 no_bgp_graceful_restart_stalepath_time_cmd
,
2938 "no bgp graceful-restart stalepath-time [(1-4095)]",
2941 "Graceful restart capability parameters\n"
2942 "Set the max time to hold onto restarting peer's stale paths\n"
2943 "Delay value (seconds)\n")
2945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2947 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2951 DEFUN (no_bgp_graceful_restart_restart_time
,
2952 no_bgp_graceful_restart_restart_time_cmd
,
2953 "no bgp graceful-restart restart-time [(0-4095)]",
2956 "Graceful restart capability parameters\n"
2957 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2958 "Delay value (seconds)\n")
2960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2962 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2966 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2967 no_bgp_graceful_restart_select_defer_time_cmd
,
2968 "no bgp graceful-restart select-defer-time [(0-3600)]",
2971 "Graceful restart capability parameters\n"
2972 "Set the time to defer the BGP route selection after restart\n"
2973 "Delay value (seconds)\n")
2975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2977 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2978 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2983 DEFUN (bgp_graceful_restart_preserve_fw
,
2984 bgp_graceful_restart_preserve_fw_cmd
,
2985 "bgp graceful-restart preserve-fw-state",
2987 "Graceful restart capability parameters\n"
2988 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2990 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2991 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2995 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2996 no_bgp_graceful_restart_preserve_fw_cmd
,
2997 "no bgp graceful-restart preserve-fw-state",
3000 "Graceful restart capability parameters\n"
3001 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3003 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3004 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3008 DEFPY (bgp_graceful_restart_notification
,
3009 bgp_graceful_restart_notification_cmd
,
3010 "[no$no] bgp graceful-restart notification",
3013 "Graceful restart capability parameters\n"
3014 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3019 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3021 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3026 DEFPY (bgp_administrative_reset
,
3027 bgp_administrative_reset_cmd
,
3028 "[no$no] bgp hard-administrative-reset",
3031 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3036 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3038 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3043 DEFUN (bgp_graceful_restart_disable
,
3044 bgp_graceful_restart_disable_cmd
,
3045 "bgp graceful-restart-disable",
3049 int ret
= BGP_GR_FAILURE
;
3051 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3053 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3057 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3059 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3062 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3064 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3066 "Graceful restart configuration changed, reset all peers to take effect\n");
3068 return bgp_vty_return(vty
, ret
);
3071 DEFUN (no_bgp_graceful_restart_disable
,
3072 no_bgp_graceful_restart_disable_cmd
,
3073 "no bgp graceful-restart-disable",
3079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3081 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3083 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3085 int ret
= BGP_GR_FAILURE
;
3087 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3089 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3092 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3094 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3096 "Graceful restart configuration changed, reset all peers to take effect\n");
3098 return bgp_vty_return(vty
, ret
);
3101 DEFUN (bgp_neighbor_graceful_restart_set
,
3102 bgp_neighbor_graceful_restart_set_cmd
,
3103 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3111 int ret
= BGP_GR_FAILURE
;
3113 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3115 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3117 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3119 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3121 return CMD_WARNING_CONFIG_FAILED
;
3123 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3125 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3126 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3128 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3130 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3132 "Graceful restart configuration changed, reset this peer to take effect\n");
3134 return bgp_vty_return(vty
, ret
);
3137 DEFUN (no_bgp_neighbor_graceful_restart
,
3138 no_bgp_neighbor_graceful_restart_set_cmd
,
3139 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3147 int ret
= BGP_GR_FAILURE
;
3150 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3152 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3154 return CMD_WARNING_CONFIG_FAILED
;
3156 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3158 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3160 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3162 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3163 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3165 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3167 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3169 "Graceful restart configuration changed, reset this peer to take effect\n");
3171 return bgp_vty_return(vty
, ret
);
3174 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3175 bgp_neighbor_graceful_restart_helper_set_cmd
,
3176 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3179 GR_NEIGHBOR_HELPER_CMD
3184 int ret
= BGP_GR_FAILURE
;
3186 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3188 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3190 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3192 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3195 return CMD_WARNING_CONFIG_FAILED
;
3198 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3200 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3201 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3203 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3205 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3207 "Graceful restart configuration changed, reset this peer to take effect\n");
3209 return bgp_vty_return(vty
, ret
);
3212 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3213 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3214 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3218 NO_GR_NEIGHBOR_HELPER_CMD
3222 int ret
= BGP_GR_FAILURE
;
3225 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3227 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3229 return CMD_WARNING_CONFIG_FAILED
;
3231 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3233 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3235 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3237 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3238 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3240 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3242 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3244 "Graceful restart configuration changed, reset this peer to take effect\n");
3246 return bgp_vty_return(vty
, ret
);
3249 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3250 bgp_neighbor_graceful_restart_disable_set_cmd
,
3251 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3254 GR_NEIGHBOR_DISABLE_CMD
3259 int ret
= BGP_GR_FAILURE
;
3261 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3263 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3265 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3267 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3269 return CMD_WARNING_CONFIG_FAILED
;
3271 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3273 if (peer
->bgp
->t_startup
)
3274 bgp_peer_gr_flags_update(peer
);
3276 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3277 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3279 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3281 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3283 "Graceful restart configuration changed, reset this peer to take effect\n");
3285 return bgp_vty_return(vty
, ret
);
3288 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3289 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3290 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3294 NO_GR_NEIGHBOR_DISABLE_CMD
3298 int ret
= BGP_GR_FAILURE
;
3301 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3303 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3305 return CMD_WARNING_CONFIG_FAILED
;
3307 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3309 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3311 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3313 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3314 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3316 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3318 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3320 "Graceful restart configuration changed, reset this peer to take effect\n");
3322 return bgp_vty_return(vty
, ret
);
3325 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3326 bgp_graceful_restart_disable_eor_cmd
,
3327 "bgp graceful-restart disable-eor",
3329 "Graceful restart configuration parameters\n"
3330 "Disable EOR Check\n")
3332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3333 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3338 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3339 no_bgp_graceful_restart_disable_eor_cmd
,
3340 "no bgp graceful-restart disable-eor",
3343 "Graceful restart configuration parameters\n"
3344 "Disable EOR Check\n")
3346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3347 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3352 DEFUN (bgp_graceful_restart_rib_stale_time
,
3353 bgp_graceful_restart_rib_stale_time_cmd
,
3354 "bgp graceful-restart rib-stale-time (1-3600)",
3356 "Graceful restart configuration parameters\n"
3357 "Specify the stale route removal timer in rib\n"
3358 "Delay value (seconds)\n")
3360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3362 uint32_t stale_time
;
3364 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3365 bgp
->rib_stale_time
= stale_time
;
3366 /* Send the stale timer update message to RIB */
3367 if (bgp_zebra_stale_timer_update(bgp
))
3373 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3374 no_bgp_graceful_restart_rib_stale_time_cmd
,
3375 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3378 "Graceful restart configuration parameters\n"
3379 "Specify the stale route removal timer in rib\n"
3380 "Delay value (seconds)\n")
3382 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3384 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3385 /* Send the stale timer update message to RIB */
3386 if (bgp_zebra_stale_timer_update(bgp
))
3392 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3393 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3395 "Enable Long-lived Graceful Restart\n"
3396 "Specifies maximum time to wait before purging long-lived stale routes\n"
3397 "Stale time value (seconds)\n")
3399 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3401 uint32_t llgr_stale_time
;
3403 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3404 bgp
->llgr_stale_time
= llgr_stale_time
;
3409 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3410 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3412 "Enable Long-lived Graceful Restart\n"
3413 "Specifies maximum time to wait before purging long-lived stale routes\n"
3414 "Stale time value (seconds)\n")
3416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3418 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3423 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3426 bgp_static_redo_import_check(bgp
);
3427 bgp_redistribute_redo(bgp
);
3428 bgp_clear_star_soft_out(vty
, bgp
->name
);
3429 bgp_clear_star_soft_in(vty
, bgp
->name
);
3432 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3434 struct listnode
*node
, *nnode
;
3436 bool vrf_cfg
= false;
3438 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3441 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3442 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3443 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3445 "%% graceful-shutdown configuration found in vrf %s\n",
3446 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3447 VRF_DEFAULT_NAME
: bgp
->name
);
3454 "%%Failed: global graceful-shutdown not permitted\n");
3458 /* Set flag globally */
3459 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3461 /* Initiate processing for all BGP instances. */
3462 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3463 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3468 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3470 struct listnode
*node
, *nnode
;
3473 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3476 /* Unset flag globally */
3477 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3479 /* Initiate processing for all BGP instances. */
3480 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3481 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3486 /* "bgp graceful-shutdown" configuration */
3487 DEFUN (bgp_graceful_shutdown
,
3488 bgp_graceful_shutdown_cmd
,
3489 "bgp graceful-shutdown",
3491 "Graceful shutdown parameters\n")
3493 if (vty
->node
== CONFIG_NODE
)
3494 return bgp_global_graceful_shutdown_config_vty(vty
);
3496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3498 /* if configured globally, per-instance config is not allowed */
3499 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3501 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3502 return CMD_WARNING_CONFIG_FAILED
;
3505 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3506 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3507 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3513 DEFUN (no_bgp_graceful_shutdown
,
3514 no_bgp_graceful_shutdown_cmd
,
3515 "no bgp graceful-shutdown",
3518 "Graceful shutdown parameters\n")
3520 if (vty
->node
== CONFIG_NODE
)
3521 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3525 /* If configured globally, cannot remove from one bgp instance */
3526 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3528 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3533 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3534 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3540 /* "bgp fast-external-failover" configuration. */
3541 DEFUN (bgp_fast_external_failover
,
3542 bgp_fast_external_failover_cmd
,
3543 "bgp fast-external-failover",
3545 "Immediately reset session if a link to a directly connected external peer goes down\n")
3547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3548 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3552 DEFUN (no_bgp_fast_external_failover
,
3553 no_bgp_fast_external_failover_cmd
,
3554 "no bgp fast-external-failover",
3557 "Immediately reset session if a link to a directly connected external peer goes down\n")
3559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3560 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3564 /* "bgp bestpath compare-routerid" configuration. */
3565 DEFUN (bgp_bestpath_compare_router_id
,
3566 bgp_bestpath_compare_router_id_cmd
,
3567 "bgp bestpath compare-routerid",
3569 "Change the default bestpath selection\n"
3570 "Compare router-id for identical EBGP paths\n")
3572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3573 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3574 bgp_recalculate_all_bestpaths(bgp
);
3579 DEFUN (no_bgp_bestpath_compare_router_id
,
3580 no_bgp_bestpath_compare_router_id_cmd
,
3581 "no bgp bestpath compare-routerid",
3584 "Change the default bestpath selection\n"
3585 "Compare router-id for identical EBGP paths\n")
3587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3588 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3589 bgp_recalculate_all_bestpaths(bgp
);
3594 /* "bgp bestpath as-path ignore" configuration. */
3595 DEFUN (bgp_bestpath_aspath_ignore
,
3596 bgp_bestpath_aspath_ignore_cmd
,
3597 "bgp bestpath as-path ignore",
3599 "Change the default bestpath selection\n"
3600 "AS-path attribute\n"
3601 "Ignore as-path length in selecting a route\n")
3603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3604 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3605 bgp_recalculate_all_bestpaths(bgp
);
3610 DEFUN (no_bgp_bestpath_aspath_ignore
,
3611 no_bgp_bestpath_aspath_ignore_cmd
,
3612 "no bgp bestpath as-path ignore",
3615 "Change the default bestpath selection\n"
3616 "AS-path attribute\n"
3617 "Ignore as-path length in selecting a route\n")
3619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3620 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3621 bgp_recalculate_all_bestpaths(bgp
);
3626 /* "bgp bestpath as-path confed" configuration. */
3627 DEFUN (bgp_bestpath_aspath_confed
,
3628 bgp_bestpath_aspath_confed_cmd
,
3629 "bgp bestpath as-path confed",
3631 "Change the default bestpath selection\n"
3632 "AS-path attribute\n"
3633 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3636 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3637 bgp_recalculate_all_bestpaths(bgp
);
3642 DEFUN (no_bgp_bestpath_aspath_confed
,
3643 no_bgp_bestpath_aspath_confed_cmd
,
3644 "no bgp bestpath as-path confed",
3647 "Change the default bestpath selection\n"
3648 "AS-path attribute\n"
3649 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3652 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3653 bgp_recalculate_all_bestpaths(bgp
);
3658 /* "bgp bestpath as-path multipath-relax" configuration. */
3659 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3660 bgp_bestpath_aspath_multipath_relax_cmd
,
3661 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3663 "Change the default bestpath selection\n"
3664 "AS-path attribute\n"
3665 "Allow load sharing across routes that have different AS paths (but same length)\n"
3666 "Generate an AS_SET\n"
3667 "Do not generate an AS_SET\n")
3669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3671 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3673 /* no-as-set is now the default behavior so we can silently
3675 if (argv_find(argv
, argc
, "as-set", &idx
))
3676 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3678 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3680 bgp_recalculate_all_bestpaths(bgp
);
3685 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3686 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3687 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3690 "Change the default bestpath selection\n"
3691 "AS-path attribute\n"
3692 "Allow load sharing across routes that have different AS paths (but same length)\n"
3693 "Generate an AS_SET\n"
3694 "Do not generate an AS_SET\n")
3696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3697 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3698 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3699 bgp_recalculate_all_bestpaths(bgp
);
3704 /* "bgp bestpath peer-type multipath-relax" configuration. */
3705 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3706 bgp_bestpath_peer_type_multipath_relax_cmd
,
3707 "bgp bestpath peer-type multipath-relax",
3709 "Change the default bestpath selection\n"
3711 "Allow load sharing across routes learned from different peer types\n")
3713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3714 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3715 bgp_recalculate_all_bestpaths(bgp
);
3720 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3721 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3722 "no bgp bestpath peer-type multipath-relax",
3724 "Change the default bestpath selection\n"
3726 "Allow load sharing across routes learned from different peer types\n")
3728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3729 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3730 bgp_recalculate_all_bestpaths(bgp
);
3735 /* "bgp log-neighbor-changes" configuration. */
3736 DEFUN (bgp_log_neighbor_changes
,
3737 bgp_log_neighbor_changes_cmd
,
3738 "bgp log-neighbor-changes",
3740 "Log neighbor up/down and reset reason\n")
3742 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3743 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3747 DEFUN (no_bgp_log_neighbor_changes
,
3748 no_bgp_log_neighbor_changes_cmd
,
3749 "no bgp log-neighbor-changes",
3752 "Log neighbor up/down and reset reason\n")
3754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3755 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3759 /* "bgp bestpath med" configuration. */
3760 DEFUN (bgp_bestpath_med
,
3761 bgp_bestpath_med_cmd
,
3762 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3764 "Change the default bestpath selection\n"
3766 "Compare MED among confederation paths\n"
3767 "Treat missing MED as the least preferred one\n"
3768 "Treat missing MED as the least preferred one\n"
3769 "Compare MED among confederation paths\n")
3771 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3774 if (argv_find(argv
, argc
, "confed", &idx
))
3775 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3777 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3778 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3780 bgp_recalculate_all_bestpaths(bgp
);
3785 DEFUN (no_bgp_bestpath_med
,
3786 no_bgp_bestpath_med_cmd
,
3787 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3790 "Change the default bestpath selection\n"
3792 "Compare MED among confederation paths\n"
3793 "Treat missing MED as the least preferred one\n"
3794 "Treat missing MED as the least preferred one\n"
3795 "Compare MED among confederation paths\n")
3797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3800 if (argv_find(argv
, argc
, "confed", &idx
))
3801 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3803 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3804 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3806 bgp_recalculate_all_bestpaths(bgp
);
3811 /* "bgp bestpath bandwidth" configuration. */
3812 DEFPY (bgp_bestpath_bw
,
3813 bgp_bestpath_bw_cmd
,
3814 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3816 "Change the default bestpath selection\n"
3817 "Link Bandwidth attribute\n"
3818 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3819 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3820 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3827 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3828 return CMD_ERR_INCOMPLETE
;
3830 if (!strcmp(bw_cfg
, "ignore"))
3831 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3832 else if (!strcmp(bw_cfg
, "skip-missing"))
3833 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3834 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3835 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3837 return CMD_ERR_NO_MATCH
;
3839 /* This config is used in route install, so redo that. */
3840 FOREACH_AFI_SAFI (afi
, safi
) {
3841 if (!bgp_fibupd_safi(safi
))
3843 bgp_zebra_announce_table(bgp
, afi
, safi
);
3849 DEFPY (no_bgp_bestpath_bw
,
3850 no_bgp_bestpath_bw_cmd
,
3851 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3854 "Change the default bestpath selection\n"
3855 "Link Bandwidth attribute\n"
3856 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3857 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3858 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3864 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3866 /* This config is used in route install, so redo that. */
3867 FOREACH_AFI_SAFI (afi
, safi
) {
3868 if (!bgp_fibupd_safi(safi
))
3870 bgp_zebra_announce_table(bgp
, afi
, safi
);
3875 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3876 "[no] bgp default <ipv4-unicast|"
3879 "ipv4-labeled-unicast|"
3884 "ipv6-labeled-unicast|"
3886 "l2vpn-evpn>$afi_safi",
3889 "Configure BGP defaults\n"
3890 "Activate ipv4-unicast for a peer by default\n"
3891 "Activate ipv4-multicast for a peer by default\n"
3892 "Activate ipv4-vpn for a peer by default\n"
3893 "Activate ipv4-labeled-unicast for a peer by default\n"
3894 "Activate ipv4-flowspec for a peer by default\n"
3895 "Activate ipv6-unicast for a peer by default\n"
3896 "Activate ipv6-multicast for a peer by default\n"
3897 "Activate ipv6-vpn for a peer by default\n"
3898 "Activate ipv6-labeled-unicast for a peer by default\n"
3899 "Activate ipv6-flowspec for a peer by default\n"
3900 "Activate l2vpn-evpn for a peer by default\n")
3902 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3903 char afi_safi_str
[strlen(afi_safi
) + 1];
3904 char *afi_safi_str_tok
;
3906 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3907 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3908 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3909 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3913 * Impossible situation but making coverity happy
3915 assert(afi
!= AFI_MAX
);
3917 if (strmatch(safi_str
, "labeled"))
3918 safi
= bgp_vty_safi_from_str("labeled-unicast");
3920 safi
= bgp_vty_safi_from_str(safi_str
);
3922 assert(safi
!= SAFI_MAX
);
3924 bgp
->default_af
[afi
][safi
] = false;
3926 if ((safi
== SAFI_LABELED_UNICAST
3927 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3928 || (safi
== SAFI_UNICAST
3929 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3930 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3932 bgp
->default_af
[afi
][safi
] = true;
3938 /* Display hostname in certain command outputs */
3939 DEFUN (bgp_default_show_hostname
,
3940 bgp_default_show_hostname_cmd
,
3941 "bgp default show-hostname",
3943 "Configure BGP defaults\n"
3944 "Show hostname in certain command outputs\n")
3946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3947 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3951 DEFUN (no_bgp_default_show_hostname
,
3952 no_bgp_default_show_hostname_cmd
,
3953 "no bgp default show-hostname",
3956 "Configure BGP defaults\n"
3957 "Show hostname in certain command outputs\n")
3959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3960 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3964 /* Display hostname in certain command outputs */
3965 DEFUN (bgp_default_show_nexthop_hostname
,
3966 bgp_default_show_nexthop_hostname_cmd
,
3967 "bgp default show-nexthop-hostname",
3969 "Configure BGP defaults\n"
3970 "Show hostname for nexthop in certain command outputs\n")
3972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3973 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3977 DEFUN (no_bgp_default_show_nexthop_hostname
,
3978 no_bgp_default_show_nexthop_hostname_cmd
,
3979 "no bgp default show-nexthop-hostname",
3982 "Configure BGP defaults\n"
3983 "Show hostname for nexthop in certain command outputs\n")
3985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3986 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3990 /* "bgp network import-check" configuration. */
3991 DEFUN (bgp_network_import_check
,
3992 bgp_network_import_check_cmd
,
3993 "bgp network import-check",
3995 "BGP network command\n"
3996 "Check BGP network route exists in IGP\n")
3998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3999 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4000 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4001 bgp_static_redo_import_check(bgp
);
4007 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4008 "bgp network import-check exact",
4010 "BGP network command\n"
4011 "Check BGP network route exists in IGP\n"
4012 "Match route precisely\n")
4014 DEFUN (no_bgp_network_import_check
,
4015 no_bgp_network_import_check_cmd
,
4016 "no bgp network import-check",
4019 "BGP network command\n"
4020 "Check BGP network route exists in IGP\n")
4022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4023 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4024 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4025 bgp_static_redo_import_check(bgp
);
4031 DEFUN (bgp_default_local_preference
,
4032 bgp_default_local_preference_cmd
,
4033 "bgp default local-preference (0-4294967295)",
4035 "Configure BGP defaults\n"
4036 "local preference (higher=more preferred)\n"
4037 "Configure default local preference value\n")
4039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4041 uint32_t local_pref
;
4043 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4045 bgp_default_local_preference_set(bgp
, local_pref
);
4046 bgp_clear_star_soft_in(vty
, bgp
->name
);
4051 DEFUN (no_bgp_default_local_preference
,
4052 no_bgp_default_local_preference_cmd
,
4053 "no bgp default local-preference [(0-4294967295)]",
4056 "Configure BGP defaults\n"
4057 "local preference (higher=more preferred)\n"
4058 "Configure default local preference value\n")
4060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4061 bgp_default_local_preference_unset(bgp
);
4062 bgp_clear_star_soft_in(vty
, bgp
->name
);
4068 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4069 bgp_default_subgroup_pkt_queue_max_cmd
,
4070 "bgp default subgroup-pkt-queue-max (20-100)",
4072 "Configure BGP defaults\n"
4073 "subgroup-pkt-queue-max\n"
4074 "Configure subgroup packet queue max\n")
4076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4080 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4082 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4087 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4088 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4089 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4092 "Configure BGP defaults\n"
4093 "subgroup-pkt-queue-max\n"
4094 "Configure subgroup packet queue max\n")
4096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4097 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4102 DEFUN (bgp_rr_allow_outbound_policy
,
4103 bgp_rr_allow_outbound_policy_cmd
,
4104 "bgp route-reflector allow-outbound-policy",
4106 "Allow modifications made by out route-map\n"
4107 "on ibgp neighbors\n")
4109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4111 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4112 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4113 update_group_announce_rrclients(bgp
);
4114 bgp_clear_star_soft_out(vty
, bgp
->name
);
4120 DEFUN (no_bgp_rr_allow_outbound_policy
,
4121 no_bgp_rr_allow_outbound_policy_cmd
,
4122 "no bgp route-reflector allow-outbound-policy",
4125 "Allow modifications made by out route-map\n"
4126 "on ibgp neighbors\n")
4128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4130 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4131 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4132 update_group_announce_rrclients(bgp
);
4133 bgp_clear_star_soft_out(vty
, bgp
->name
);
4139 DEFUN (bgp_listen_limit
,
4140 bgp_listen_limit_cmd
,
4141 "bgp listen limit (1-65535)",
4143 "BGP Dynamic Neighbors listen commands\n"
4144 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4145 "Configure Dynamic Neighbors listen limit value\n")
4147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4151 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4153 bgp_listen_limit_set(bgp
, listen_limit
);
4158 DEFUN (no_bgp_listen_limit
,
4159 no_bgp_listen_limit_cmd
,
4160 "no bgp listen limit [(1-65535)]",
4163 "BGP Dynamic Neighbors listen commands\n"
4164 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4165 "Configure Dynamic Neighbors listen limit value\n")
4167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4168 bgp_listen_limit_unset(bgp
);
4174 * Check if this listen range is already configured. Check for exact
4175 * match or overlap based on input.
4177 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4178 struct prefix
*range
, int exact
)
4180 struct listnode
*node
, *nnode
;
4181 struct listnode
*node1
, *nnode1
;
4182 struct peer_group
*group
;
4187 afi
= family2afi(range
->family
);
4188 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4189 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4192 match
= prefix_same(range
, lr
);
4194 match
= (prefix_match(range
, lr
)
4195 || prefix_match(lr
, range
));
4204 DEFUN (bgp_listen_range
,
4205 bgp_listen_range_cmd
,
4206 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4208 "Configure BGP dynamic neighbors listen range\n"
4209 "Configure BGP dynamic neighbors listen range\n"
4211 "Member of the peer-group\n"
4212 "Peer-group name\n")
4214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4215 struct prefix range
;
4216 struct peer_group
*group
, *existing_group
;
4221 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4222 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4223 char *prefix
= argv
[idx
]->arg
;
4224 argv_find(argv
, argc
, "PGNAME", &idx
);
4225 char *peergroup
= argv
[idx
]->arg
;
4227 /* Convert IP prefix string to struct prefix. */
4228 ret
= str2prefix(prefix
, &range
);
4230 vty_out(vty
, "%% Malformed listen range\n");
4231 return CMD_WARNING_CONFIG_FAILED
;
4234 afi
= family2afi(range
.family
);
4236 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4238 "%% Malformed listen range (link-local address)\n");
4239 return CMD_WARNING_CONFIG_FAILED
;
4244 /* Check if same listen range is already configured. */
4245 existing_group
= listen_range_exists(bgp
, &range
, 1);
4246 if (existing_group
) {
4247 if (strcmp(existing_group
->name
, peergroup
) == 0)
4251 "%% Same listen range is attached to peer-group %s\n",
4252 existing_group
->name
);
4253 return CMD_WARNING_CONFIG_FAILED
;
4257 /* Check if an overlapping listen range exists. */
4258 if (listen_range_exists(bgp
, &range
, 0)) {
4260 "%% Listen range overlaps with existing listen range\n");
4261 return CMD_WARNING_CONFIG_FAILED
;
4264 group
= peer_group_lookup(bgp
, peergroup
);
4266 vty_out(vty
, "%% Configure the peer-group first\n");
4267 return CMD_WARNING_CONFIG_FAILED
;
4270 ret
= peer_group_listen_range_add(group
, &range
);
4271 return bgp_vty_return(vty
, ret
);
4274 DEFUN (no_bgp_listen_range
,
4275 no_bgp_listen_range_cmd
,
4276 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4279 "Unconfigure BGP dynamic neighbors listen range\n"
4280 "Unconfigure BGP dynamic neighbors listen range\n"
4282 "Member of the peer-group\n"
4283 "Peer-group name\n")
4285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4286 struct prefix range
;
4287 struct peer_group
*group
;
4292 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4293 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4294 char *prefix
= argv
[idx
]->arg
;
4295 argv_find(argv
, argc
, "PGNAME", &idx
);
4296 char *peergroup
= argv
[idx
]->arg
;
4298 /* Convert IP prefix string to struct prefix. */
4299 ret
= str2prefix(prefix
, &range
);
4301 vty_out(vty
, "%% Malformed listen range\n");
4302 return CMD_WARNING_CONFIG_FAILED
;
4305 afi
= family2afi(range
.family
);
4307 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4309 "%% Malformed listen range (link-local address)\n");
4310 return CMD_WARNING_CONFIG_FAILED
;
4315 group
= peer_group_lookup(bgp
, peergroup
);
4317 vty_out(vty
, "%% Peer-group does not exist\n");
4318 return CMD_WARNING_CONFIG_FAILED
;
4321 ret
= peer_group_listen_range_del(group
, &range
);
4322 return bgp_vty_return(vty
, ret
);
4325 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4327 struct peer_group
*group
;
4328 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4329 struct prefix
*range
;
4332 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4333 vty_out(vty
, " bgp listen limit %d\n",
4334 bgp
->dynamic_neighbors_limit
);
4336 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4337 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4338 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4341 " bgp listen range %pFX peer-group %s\n",
4342 range
, group
->name
);
4349 DEFUN (bgp_disable_connected_route_check
,
4350 bgp_disable_connected_route_check_cmd
,
4351 "bgp disable-ebgp-connected-route-check",
4353 "Disable checking if nexthop is connected on ebgp sessions\n")
4355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4356 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4357 bgp_clear_star_soft_in(vty
, bgp
->name
);
4362 DEFUN (no_bgp_disable_connected_route_check
,
4363 no_bgp_disable_connected_route_check_cmd
,
4364 "no bgp disable-ebgp-connected-route-check",
4367 "Disable checking if nexthop is connected on ebgp sessions\n")
4369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4370 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4371 bgp_clear_star_soft_in(vty
, bgp
->name
);
4377 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4383 int as_type
= AS_SPECIFIED
;
4386 if (as_str
[0] == 'i') {
4388 as_type
= AS_INTERNAL
;
4389 } else if (as_str
[0] == 'e') {
4391 as_type
= AS_EXTERNAL
;
4393 /* Get AS number. */
4394 as
= strtoul(as_str
, NULL
, 10);
4397 /* If peer is peer group or interface peer, call proper function. */
4398 ret
= str2sockunion(peer_str
, &su
);
4402 /* Check if existing interface peer */
4403 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4405 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4407 /* if not interface peer, check peer-group settings */
4408 if (ret
< 0 && !peer
) {
4409 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4412 "%% Create the peer-group or interface first\n");
4413 return CMD_WARNING_CONFIG_FAILED
;
4418 if (peer_address_self_check(bgp
, &su
)) {
4420 "%% Can not configure the local system as neighbor\n");
4421 return CMD_WARNING_CONFIG_FAILED
;
4423 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4426 return bgp_vty_return(vty
, ret
);
4429 DEFUN (bgp_default_shutdown
,
4430 bgp_default_shutdown_cmd
,
4431 "[no] bgp default shutdown",
4434 "Configure BGP defaults\n"
4435 "Apply administrative shutdown to newly configured peers\n")
4437 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4438 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4442 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4444 "Administrative shutdown of the BGP instance\n"
4445 "Add a shutdown message (RFC 8203)\n"
4446 "Shutdown message\n")
4448 char *msgstr
= NULL
;
4450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4453 msgstr
= argv_concat(argv
, argc
, 3);
4455 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4456 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4457 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4458 return CMD_WARNING_CONFIG_FAILED
;
4461 bgp_shutdown_enable(bgp
, msgstr
);
4462 XFREE(MTYPE_TMP
, msgstr
);
4467 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4468 BGP_STR
"Administrative shutdown of the BGP instance\n")
4470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4472 bgp_shutdown_enable(bgp
, NULL
);
4477 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4478 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4482 bgp_shutdown_disable(bgp
);
4487 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4488 "no bgp shutdown message MSG...", NO_STR BGP_STR
4489 "Administrative shutdown of the BGP instance\n"
4490 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4492 DEFUN (neighbor_remote_as
,
4493 neighbor_remote_as_cmd
,
4494 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4497 "Specify a BGP neighbor\n"
4499 "Internal BGP peer\n"
4500 "External BGP peer\n")
4503 int idx_remote_as
= 3;
4504 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4505 argv
[idx_remote_as
]->arg
);
4508 DEFPY (bgp_allow_martian
,
4509 bgp_allow_martian_cmd
,
4510 "[no]$no bgp allow-martian-nexthop",
4513 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4518 bgp
->allow_martian
= false;
4520 bgp
->allow_martian
= true;
4525 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4526 * sessions do not wait for hold timer expiry to bring down the sessions
4527 * when nexthop becomes unreachable
4529 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4530 BGP_STR
"Fast convergence for bgp sessions\n")
4532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4533 bgp
->fast_convergence
= true;
4538 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4539 "no bgp fast-convergence",
4540 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4543 bgp
->fast_convergence
= false;
4548 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4550 const char *peer_group_name
,
4553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4555 int as_type
= AS_UNSPECIFIED
;
4557 struct peer_group
*group
;
4560 group
= peer_group_lookup(bgp
, conf_if
);
4563 vty_out(vty
, "%% Name conflict with peer-group \n");
4564 return CMD_WARNING_CONFIG_FAILED
;
4568 if (as_str
[0] == 'i') {
4569 as_type
= AS_INTERNAL
;
4570 } else if (as_str
[0] == 'e') {
4571 as_type
= AS_EXTERNAL
;
4573 /* Get AS number. */
4574 as
= strtoul(as_str
, NULL
, 10);
4575 as_type
= AS_SPECIFIED
;
4579 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4582 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4584 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4588 vty_out(vty
, "%% BGP failed to create peer\n");
4589 return CMD_WARNING_CONFIG_FAILED
;
4593 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4595 /* Request zebra to initiate IPv6 RAs on this interface. We do
4597 * any unnumbered peer in order to not worry about run-time
4599 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4601 * gets deleted later etc.)
4604 bgp_zebra_initiate_radv(bgp
, peer
);
4607 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4608 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4610 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4612 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4614 /* v6only flag changed. Reset bgp seesion */
4615 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4616 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4617 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4618 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4620 bgp_session_reset(peer
);
4623 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4624 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4625 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4626 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4629 if (peer_group_name
) {
4630 group
= peer_group_lookup(bgp
, peer_group_name
);
4632 vty_out(vty
, "%% Configure the peer-group first\n");
4633 return CMD_WARNING_CONFIG_FAILED
;
4636 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4639 return bgp_vty_return(vty
, ret
);
4642 DEFUN (neighbor_interface_config
,
4643 neighbor_interface_config_cmd
,
4644 "neighbor WORD interface [peer-group PGNAME]",
4646 "Interface name or neighbor tag\n"
4647 "Enable BGP on interface\n"
4648 "Member of the peer-group\n"
4649 "Peer-group name\n")
4652 int idx_peer_group_word
= 4;
4654 if (argc
> idx_peer_group_word
)
4655 return peer_conf_interface_get(
4656 vty
, argv
[idx_word
]->arg
, 0,
4657 argv
[idx_peer_group_word
]->arg
, NULL
);
4659 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4663 DEFUN (neighbor_interface_config_v6only
,
4664 neighbor_interface_config_v6only_cmd
,
4665 "neighbor WORD interface v6only [peer-group PGNAME]",
4667 "Interface name or neighbor tag\n"
4668 "Enable BGP on interface\n"
4669 "Enable BGP with v6 link-local only\n"
4670 "Member of the peer-group\n"
4671 "Peer-group name\n")
4674 int idx_peer_group_word
= 5;
4676 if (argc
> idx_peer_group_word
)
4677 return peer_conf_interface_get(
4678 vty
, argv
[idx_word
]->arg
, 1,
4679 argv
[idx_peer_group_word
]->arg
, NULL
);
4681 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4685 DEFUN (neighbor_interface_config_remote_as
,
4686 neighbor_interface_config_remote_as_cmd
,
4687 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4689 "Interface name or neighbor tag\n"
4690 "Enable BGP on interface\n"
4691 "Specify a BGP neighbor\n"
4693 "Internal BGP peer\n"
4694 "External BGP peer\n")
4697 int idx_remote_as
= 4;
4698 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4699 argv
[idx_remote_as
]->arg
);
4702 DEFUN (neighbor_interface_v6only_config_remote_as
,
4703 neighbor_interface_v6only_config_remote_as_cmd
,
4704 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4706 "Interface name or neighbor tag\n"
4707 "Enable BGP with v6 link-local only\n"
4708 "Enable BGP on interface\n"
4709 "Specify a BGP neighbor\n"
4711 "Internal BGP peer\n"
4712 "External BGP peer\n")
4715 int idx_remote_as
= 5;
4716 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4717 argv
[idx_remote_as
]->arg
);
4720 DEFUN (neighbor_peer_group
,
4721 neighbor_peer_group_cmd
,
4722 "neighbor WORD peer-group",
4724 "Interface name or neighbor tag\n"
4725 "Configure peer-group\n")
4727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4730 struct peer_group
*group
;
4732 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4734 vty_out(vty
, "%% Name conflict with interface: \n");
4735 return CMD_WARNING_CONFIG_FAILED
;
4738 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4740 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4741 return CMD_WARNING_CONFIG_FAILED
;
4749 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4753 "Specify a BGP neighbor\n"
4755 "Internal BGP peer\n"
4756 "External BGP peer\n")
4758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4762 struct peer_group
*group
;
4766 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4768 /* look up for neighbor by interface name config. */
4769 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4771 /* Request zebra to terminate IPv6 RAs on this
4774 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4775 peer_notify_unconfig(peer
);
4780 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4782 peer_group_notify_unconfig(group
);
4783 peer_group_delete(group
);
4785 vty_out(vty
, "%% Create the peer-group first\n");
4786 return CMD_WARNING_CONFIG_FAILED
;
4789 peer
= peer_lookup(bgp
, &su
);
4791 if (peer_dynamic_neighbor(peer
)) {
4793 "%% Operation not allowed on a dynamic neighbor\n");
4794 return CMD_WARNING_CONFIG_FAILED
;
4797 other
= peer
->doppelganger
;
4799 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4800 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4802 peer_notify_unconfig(peer
);
4804 if (other
&& other
->status
!= Deleted
) {
4805 peer_notify_unconfig(other
);
4814 DEFUN (no_neighbor_interface_config
,
4815 no_neighbor_interface_config_cmd
,
4816 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4820 "Configure BGP on interface\n"
4821 "Enable BGP with v6 link-local only\n"
4822 "Member of the peer-group\n"
4824 "Specify a BGP neighbor\n"
4826 "Internal BGP peer\n"
4827 "External BGP peer\n")
4829 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4833 /* look up for neighbor by interface name config. */
4834 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4836 /* Request zebra to terminate IPv6 RAs on this interface. */
4838 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4839 peer_notify_unconfig(peer
);
4842 vty_out(vty
, "%% Create the bgp interface first\n");
4843 return CMD_WARNING_CONFIG_FAILED
;
4848 DEFUN (no_neighbor_peer_group
,
4849 no_neighbor_peer_group_cmd
,
4850 "no neighbor WORD peer-group",
4854 "Configure peer-group\n")
4856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4858 struct peer_group
*group
;
4860 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4862 peer_group_notify_unconfig(group
);
4863 peer_group_delete(group
);
4865 vty_out(vty
, "%% Create the peer-group first\n");
4866 return CMD_WARNING_CONFIG_FAILED
;
4871 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4872 no_neighbor_interface_peer_group_remote_as_cmd
,
4873 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4876 "Interface name or neighbor tag\n"
4877 "Specify a BGP neighbor\n"
4879 "Internal BGP peer\n"
4880 "External BGP peer\n")
4882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4884 struct peer_group
*group
;
4887 /* look up for neighbor by interface name config. */
4888 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4890 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4894 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4896 peer_group_remote_as_delete(group
);
4898 vty_out(vty
, "%% Create the peer-group or interface first\n");
4899 return CMD_WARNING_CONFIG_FAILED
;
4904 DEFUN (neighbor_local_as
,
4905 neighbor_local_as_cmd
,
4906 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4909 "Specify a local-as number\n"
4910 "AS number used as local AS\n")
4918 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4920 return CMD_WARNING_CONFIG_FAILED
;
4922 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4923 ret
= peer_local_as_set(peer
, as
, 0, 0);
4924 return bgp_vty_return(vty
, ret
);
4927 DEFUN (neighbor_local_as_no_prepend
,
4928 neighbor_local_as_no_prepend_cmd
,
4929 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4932 "Specify a local-as number\n"
4933 "AS number used as local AS\n"
4934 "Do not prepend local-as to updates from ebgp peers\n")
4942 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4944 return CMD_WARNING_CONFIG_FAILED
;
4946 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4947 ret
= peer_local_as_set(peer
, as
, 1, 0);
4948 return bgp_vty_return(vty
, ret
);
4951 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4952 neighbor_local_as_no_prepend_replace_as_cmd
,
4953 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4956 "Specify a local-as number\n"
4957 "AS number used as local AS\n"
4958 "Do not prepend local-as to updates from ebgp peers\n"
4959 "Do not prepend local-as to updates from ibgp peers\n")
4967 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4969 return CMD_WARNING_CONFIG_FAILED
;
4971 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4972 ret
= peer_local_as_set(peer
, as
, 1, 1);
4973 return bgp_vty_return(vty
, ret
);
4976 DEFUN (no_neighbor_local_as
,
4977 no_neighbor_local_as_cmd
,
4978 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4982 "Specify a local-as number\n"
4983 "AS number used as local AS\n"
4984 "Do not prepend local-as to updates from ebgp peers\n"
4985 "Do not prepend local-as to updates from ibgp peers\n")
4991 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4993 return CMD_WARNING_CONFIG_FAILED
;
4995 ret
= peer_local_as_unset(peer
);
4996 return bgp_vty_return(vty
, ret
);
5000 DEFUN (neighbor_solo
,
5002 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5005 "Solo peer - part of its own update group\n")
5011 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5013 return CMD_WARNING_CONFIG_FAILED
;
5015 ret
= update_group_adjust_soloness(peer
, 1);
5016 return bgp_vty_return(vty
, ret
);
5019 DEFUN (no_neighbor_solo
,
5020 no_neighbor_solo_cmd
,
5021 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5025 "Solo peer - part of its own update group\n")
5031 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5033 return CMD_WARNING_CONFIG_FAILED
;
5035 ret
= update_group_adjust_soloness(peer
, 0);
5036 return bgp_vty_return(vty
, ret
);
5039 DEFUN (neighbor_password
,
5040 neighbor_password_cmd
,
5041 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5052 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5054 return CMD_WARNING_CONFIG_FAILED
;
5056 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5057 return bgp_vty_return(vty
, ret
);
5060 DEFUN (no_neighbor_password
,
5061 no_neighbor_password_cmd
,
5062 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5073 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5075 return CMD_WARNING_CONFIG_FAILED
;
5077 ret
= peer_password_unset(peer
);
5078 return bgp_vty_return(vty
, ret
);
5081 DEFUN (neighbor_activate
,
5082 neighbor_activate_cmd
,
5083 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5086 "Enable the Address Family for this Neighbor\n")
5092 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5094 return CMD_WARNING_CONFIG_FAILED
;
5096 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5097 return bgp_vty_return(vty
, ret
);
5100 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5101 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5102 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5103 "Enable the Address Family for this Neighbor\n")
5105 DEFUN (no_neighbor_activate
,
5106 no_neighbor_activate_cmd
,
5107 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5111 "Enable the Address Family for this Neighbor\n")
5118 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5120 return CMD_WARNING_CONFIG_FAILED
;
5122 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5123 return bgp_vty_return(vty
, ret
);
5126 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5127 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5128 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5129 "Enable the Address Family for this Neighbor\n")
5131 DEFUN (neighbor_set_peer_group
,
5132 neighbor_set_peer_group_cmd
,
5133 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5136 "Member of the peer-group\n"
5137 "Peer-group name\n")
5139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5146 struct peer_group
*group
;
5148 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5150 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5152 vty_out(vty
, "%% Malformed address or name: %s\n",
5153 argv
[idx_peer
]->arg
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5157 if (peer_address_self_check(bgp
, &su
)) {
5159 "%% Can not configure the local system as neighbor\n");
5160 return CMD_WARNING_CONFIG_FAILED
;
5163 /* Disallow for dynamic neighbor. */
5164 peer
= peer_lookup(bgp
, &su
);
5165 if (peer
&& peer_dynamic_neighbor(peer
)) {
5167 "%% Operation not allowed on a dynamic neighbor\n");
5168 return CMD_WARNING_CONFIG_FAILED
;
5172 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5174 vty_out(vty
, "%% Configure the peer-group first\n");
5175 return CMD_WARNING_CONFIG_FAILED
;
5178 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5180 return bgp_vty_return(vty
, ret
);
5183 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5184 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5185 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5186 "Member of the peer-group\n"
5187 "Peer-group name\n")
5189 DEFUN (no_neighbor_set_peer_group
,
5190 no_neighbor_set_peer_group_cmd
,
5191 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5195 "Member of the peer-group\n"
5196 "Peer-group name\n")
5198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5203 struct peer_group
*group
;
5205 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5207 return CMD_WARNING_CONFIG_FAILED
;
5209 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5211 vty_out(vty
, "%% Configure the peer-group first\n");
5212 return CMD_WARNING_CONFIG_FAILED
;
5215 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5216 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5218 peer_notify_unconfig(peer
);
5219 ret
= peer_delete(peer
);
5221 return bgp_vty_return(vty
, ret
);
5224 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5225 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5227 "Member of the peer-group\n"
5228 "Peer-group name\n")
5230 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5231 uint64_t flag
, int set
)
5236 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5238 return CMD_WARNING_CONFIG_FAILED
;
5241 * If 'neighbor <interface>', then this is for directly connected peers,
5242 * we should not accept disable-connected-check.
5244 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5246 "%s is directly connected peer, cannot accept disable-connected-check\n",
5248 return CMD_WARNING_CONFIG_FAILED
;
5251 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5252 peer_tx_shutdown_message_unset(peer
);
5255 ret
= peer_flag_set(peer
, flag
);
5257 ret
= peer_flag_unset(peer
, flag
);
5259 return bgp_vty_return(vty
, ret
);
5262 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5264 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5267 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5270 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5273 /* neighbor passive. */
5274 DEFUN (neighbor_passive
,
5275 neighbor_passive_cmd
,
5276 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5279 "Don't send open messages to this neighbor\n")
5282 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5285 DEFUN (no_neighbor_passive
,
5286 no_neighbor_passive_cmd
,
5287 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5291 "Don't send open messages to this neighbor\n")
5294 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5297 /* neighbor shutdown. */
5298 DEFUN (neighbor_shutdown_msg
,
5299 neighbor_shutdown_msg_cmd
,
5300 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5303 "Administratively shut down this neighbor\n"
5304 "Add a shutdown message (RFC 8203)\n"
5305 "Shutdown message\n")
5311 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5315 return CMD_WARNING_CONFIG_FAILED
;
5316 message
= argv_concat(argv
, argc
, 4);
5317 peer_tx_shutdown_message_set(peer
, message
);
5318 XFREE(MTYPE_TMP
, message
);
5321 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5324 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5325 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5327 "Administratively shut down this neighbor\n")
5329 DEFUN (no_neighbor_shutdown_msg
,
5330 no_neighbor_shutdown_msg_cmd
,
5331 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5335 "Administratively shut down this neighbor\n"
5336 "Remove a shutdown message (RFC 8203)\n"
5337 "Shutdown message\n")
5341 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5342 PEER_FLAG_SHUTDOWN
);
5345 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5346 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5347 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5348 "Administratively shut down this neighbor\n")
5350 DEFUN(neighbor_shutdown_rtt
,
5351 neighbor_shutdown_rtt_cmd
,
5352 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5355 "Administratively shut down this neighbor\n"
5356 "Shutdown if round-trip-time is higher than expected\n"
5357 "Round-trip-time in milliseconds\n"
5358 "Specify the number of keepalives before shutdown\n"
5359 "The number of keepalives with higher RTT to shutdown\n")
5366 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5369 return CMD_WARNING_CONFIG_FAILED
;
5371 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5373 if (argv_find(argv
, argc
, "count", &idx_count
))
5374 peer
->rtt_keepalive_conf
=
5375 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5377 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5378 PEER_FLAG_RTT_SHUTDOWN
);
5381 DEFUN(no_neighbor_shutdown_rtt
,
5382 no_neighbor_shutdown_rtt_cmd
,
5383 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5387 "Administratively shut down this neighbor\n"
5388 "Shutdown if round-trip-time is higher than expected\n"
5389 "Round-trip-time in milliseconds\n"
5390 "Specify the number of keepalives before shutdown\n"
5391 "The number of keepalives with higher RTT to shutdown\n")
5396 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5399 return CMD_WARNING_CONFIG_FAILED
;
5401 peer
->rtt_expected
= 0;
5402 peer
->rtt_keepalive_conf
= 1;
5404 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5405 PEER_FLAG_RTT_SHUTDOWN
);
5408 /* neighbor capability dynamic. */
5409 DEFUN (neighbor_capability_dynamic
,
5410 neighbor_capability_dynamic_cmd
,
5411 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5414 "Advertise capability to the peer\n"
5415 "Advertise dynamic capability to this neighbor\n")
5418 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5419 PEER_FLAG_DYNAMIC_CAPABILITY
);
5422 DEFUN (no_neighbor_capability_dynamic
,
5423 no_neighbor_capability_dynamic_cmd
,
5424 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5428 "Advertise capability to the peer\n"
5429 "Advertise dynamic capability to this neighbor\n")
5432 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5433 PEER_FLAG_DYNAMIC_CAPABILITY
);
5436 /* neighbor dont-capability-negotiate */
5437 DEFUN (neighbor_dont_capability_negotiate
,
5438 neighbor_dont_capability_negotiate_cmd
,
5439 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5442 "Do not perform capability negotiation\n")
5445 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5446 PEER_FLAG_DONT_CAPABILITY
);
5449 DEFUN (no_neighbor_dont_capability_negotiate
,
5450 no_neighbor_dont_capability_negotiate_cmd
,
5451 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5455 "Do not perform capability negotiation\n")
5458 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5459 PEER_FLAG_DONT_CAPABILITY
);
5462 /* neighbor capability extended next hop encoding */
5463 DEFUN (neighbor_capability_enhe
,
5464 neighbor_capability_enhe_cmd
,
5465 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5468 "Advertise capability to the peer\n"
5469 "Advertise extended next-hop capability to the peer\n")
5474 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5475 if (peer
&& peer
->conf_if
)
5478 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5479 PEER_FLAG_CAPABILITY_ENHE
);
5482 DEFUN (no_neighbor_capability_enhe
,
5483 no_neighbor_capability_enhe_cmd
,
5484 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5488 "Advertise capability to the peer\n"
5489 "Advertise extended next-hop capability to the peer\n")
5494 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5495 if (peer
&& peer
->conf_if
) {
5497 "Peer %s cannot have capability extended-nexthop turned off\n",
5498 argv
[idx_peer
]->arg
);
5499 return CMD_WARNING_CONFIG_FAILED
;
5502 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5503 PEER_FLAG_CAPABILITY_ENHE
);
5506 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5507 afi_t afi
, safi_t safi
, uint32_t flag
,
5513 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5515 return CMD_WARNING_CONFIG_FAILED
;
5518 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5520 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5522 return bgp_vty_return(vty
, ret
);
5525 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5526 afi_t afi
, safi_t safi
, uint32_t flag
)
5528 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5531 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5532 afi_t afi
, safi_t safi
, uint32_t flag
)
5534 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5537 /* neighbor capability orf prefix-list. */
5538 DEFUN (neighbor_capability_orf_prefix
,
5539 neighbor_capability_orf_prefix_cmd
,
5540 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5543 "Advertise capability to the peer\n"
5544 "Advertise ORF capability to the peer\n"
5545 "Advertise prefixlist ORF capability to this neighbor\n"
5546 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5547 "Capability to RECEIVE the ORF from this neighbor\n"
5548 "Capability to SEND the ORF to this neighbor\n")
5550 int idx_send_recv
= 5;
5551 char *peer_str
= argv
[1]->arg
;
5553 afi_t afi
= bgp_node_afi(vty
);
5554 safi_t safi
= bgp_node_safi(vty
);
5556 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5561 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5562 PEER_FLAG_ORF_PREFIX_SM
);
5564 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5565 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5566 PEER_FLAG_ORF_PREFIX_RM
);
5568 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5569 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5570 PEER_FLAG_ORF_PREFIX_SM
)
5571 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5572 PEER_FLAG_ORF_PREFIX_RM
);
5574 return CMD_WARNING_CONFIG_FAILED
;
5578 neighbor_capability_orf_prefix
,
5579 neighbor_capability_orf_prefix_hidden_cmd
,
5580 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5582 "Advertise capability to the peer\n"
5583 "Advertise ORF capability to the peer\n"
5584 "Advertise prefixlist ORF capability to this neighbor\n"
5585 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5586 "Capability to RECEIVE the ORF from this neighbor\n"
5587 "Capability to SEND the ORF to this neighbor\n")
5589 DEFUN (no_neighbor_capability_orf_prefix
,
5590 no_neighbor_capability_orf_prefix_cmd
,
5591 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5595 "Advertise capability to the peer\n"
5596 "Advertise ORF capability to the peer\n"
5597 "Advertise prefixlist ORF capability to this neighbor\n"
5598 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5599 "Capability to RECEIVE the ORF from this neighbor\n"
5600 "Capability to SEND the ORF to this neighbor\n")
5602 int idx_send_recv
= 6;
5603 char *peer_str
= argv
[2]->arg
;
5605 afi_t afi
= bgp_node_afi(vty
);
5606 safi_t safi
= bgp_node_safi(vty
);
5608 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5610 return CMD_WARNING_CONFIG_FAILED
;
5612 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5613 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5614 PEER_FLAG_ORF_PREFIX_SM
);
5616 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5617 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5618 PEER_FLAG_ORF_PREFIX_RM
);
5620 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5621 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5622 PEER_FLAG_ORF_PREFIX_SM
)
5623 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5624 PEER_FLAG_ORF_PREFIX_RM
);
5626 return CMD_WARNING_CONFIG_FAILED
;
5630 no_neighbor_capability_orf_prefix
,
5631 no_neighbor_capability_orf_prefix_hidden_cmd
,
5632 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5633 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5634 "Advertise capability to the peer\n"
5635 "Advertise ORF capability to the peer\n"
5636 "Advertise prefixlist ORF capability to this neighbor\n"
5637 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5638 "Capability to RECEIVE the ORF from this neighbor\n"
5639 "Capability to SEND the ORF to this neighbor\n")
5641 /* neighbor next-hop-self. */
5642 DEFUN (neighbor_nexthop_self
,
5643 neighbor_nexthop_self_cmd
,
5644 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5647 "Disable the next hop calculation for this neighbor\n")
5650 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5651 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5654 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5655 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5656 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5657 "Disable the next hop calculation for this neighbor\n")
5659 /* neighbor next-hop-self. */
5660 DEFUN (neighbor_nexthop_self_force
,
5661 neighbor_nexthop_self_force_cmd
,
5662 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5665 "Disable the next hop calculation for this neighbor\n"
5666 "Set the next hop to self for reflected routes\n")
5669 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5671 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5674 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5675 neighbor_nexthop_self_force_hidden_cmd
,
5676 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5677 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5678 "Disable the next hop calculation for this neighbor\n"
5679 "Set the next hop to self for reflected routes\n")
5681 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5682 neighbor_nexthop_self_all_hidden_cmd
,
5683 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5684 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5685 "Disable the next hop calculation for this neighbor\n"
5686 "Set the next hop to self for reflected routes\n")
5688 DEFUN (no_neighbor_nexthop_self
,
5689 no_neighbor_nexthop_self_cmd
,
5690 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5694 "Disable the next hop calculation for this neighbor\n")
5697 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5698 bgp_node_afi(vty
), bgp_node_safi(vty
),
5699 PEER_FLAG_NEXTHOP_SELF
);
5702 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5703 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5704 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5705 "Disable the next hop calculation for this neighbor\n")
5707 DEFUN (no_neighbor_nexthop_self_force
,
5708 no_neighbor_nexthop_self_force_cmd
,
5709 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5713 "Disable the next hop calculation for this neighbor\n"
5714 "Set the next hop to self for reflected routes\n")
5717 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5718 bgp_node_afi(vty
), bgp_node_safi(vty
),
5719 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5722 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5723 no_neighbor_nexthop_self_force_hidden_cmd
,
5724 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5725 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5726 "Disable the next hop calculation for this neighbor\n"
5727 "Set the next hop to self for reflected routes\n")
5729 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5730 no_neighbor_nexthop_self_all_hidden_cmd
,
5731 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5732 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5733 "Disable the next hop calculation for this neighbor\n"
5734 "Set the next hop to self for reflected routes\n")
5736 /* neighbor as-override */
5737 DEFUN (neighbor_as_override
,
5738 neighbor_as_override_cmd
,
5739 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5742 "Override ASNs in outbound updates if aspath equals remote-as\n")
5745 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5746 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5749 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5750 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5751 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5752 "Override ASNs in outbound updates if aspath equals remote-as\n")
5754 DEFUN (no_neighbor_as_override
,
5755 no_neighbor_as_override_cmd
,
5756 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5760 "Override ASNs in outbound updates if aspath equals remote-as\n")
5763 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5764 bgp_node_afi(vty
), bgp_node_safi(vty
),
5765 PEER_FLAG_AS_OVERRIDE
);
5768 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5769 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5770 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5771 "Override ASNs in outbound updates if aspath equals remote-as\n")
5773 /* neighbor remove-private-AS. */
5774 DEFUN (neighbor_remove_private_as
,
5775 neighbor_remove_private_as_cmd
,
5776 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5779 "Remove private ASNs in outbound updates\n")
5782 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5784 PEER_FLAG_REMOVE_PRIVATE_AS
);
5787 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5788 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5789 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5790 "Remove private ASNs in outbound updates\n")
5792 DEFUN (neighbor_remove_private_as_all
,
5793 neighbor_remove_private_as_all_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5797 "Remove private ASNs in outbound updates\n"
5798 "Apply to all AS numbers\n")
5801 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5803 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5806 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5807 neighbor_remove_private_as_all_hidden_cmd
,
5808 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5809 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5810 "Remove private ASNs in outbound updates\n"
5811 "Apply to all AS numbers")
5813 DEFUN (neighbor_remove_private_as_replace_as
,
5814 neighbor_remove_private_as_replace_as_cmd
,
5815 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5818 "Remove private ASNs in outbound updates\n"
5819 "Replace private ASNs with our ASN in outbound updates\n")
5822 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5824 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5827 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5828 neighbor_remove_private_as_replace_as_hidden_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5830 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5831 "Remove private ASNs in outbound updates\n"
5832 "Replace private ASNs with our ASN in outbound updates\n")
5834 DEFUN (neighbor_remove_private_as_all_replace_as
,
5835 neighbor_remove_private_as_all_replace_as_cmd
,
5836 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5839 "Remove private ASNs in outbound updates\n"
5840 "Apply to all AS numbers\n"
5841 "Replace private ASNs with our ASN in outbound updates\n")
5844 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5846 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5850 neighbor_remove_private_as_all_replace_as
,
5851 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5852 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5853 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5854 "Remove private ASNs in outbound updates\n"
5855 "Apply to all AS numbers\n"
5856 "Replace private ASNs with our ASN in outbound updates\n")
5858 DEFUN (no_neighbor_remove_private_as
,
5859 no_neighbor_remove_private_as_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5864 "Remove private ASNs in outbound updates\n")
5867 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5868 bgp_node_afi(vty
), bgp_node_safi(vty
),
5869 PEER_FLAG_REMOVE_PRIVATE_AS
);
5872 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5873 no_neighbor_remove_private_as_hidden_cmd
,
5874 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5875 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5876 "Remove private ASNs in outbound updates\n")
5878 DEFUN (no_neighbor_remove_private_as_all
,
5879 no_neighbor_remove_private_as_all_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5884 "Remove private ASNs in outbound updates\n"
5885 "Apply to all AS numbers\n")
5888 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5889 bgp_node_afi(vty
), bgp_node_safi(vty
),
5890 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5893 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5894 no_neighbor_remove_private_as_all_hidden_cmd
,
5895 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5896 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5897 "Remove private ASNs in outbound updates\n"
5898 "Apply to all AS numbers\n")
5900 DEFUN (no_neighbor_remove_private_as_replace_as
,
5901 no_neighbor_remove_private_as_replace_as_cmd
,
5902 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5906 "Remove private ASNs in outbound updates\n"
5907 "Replace private ASNs with our ASN in outbound updates\n")
5910 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5911 bgp_node_afi(vty
), bgp_node_safi(vty
),
5912 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5915 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5916 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5917 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5918 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5919 "Remove private ASNs in outbound updates\n"
5920 "Replace private ASNs with our ASN in outbound updates\n")
5922 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5923 no_neighbor_remove_private_as_all_replace_as_cmd
,
5924 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5928 "Remove private ASNs in outbound updates\n"
5929 "Apply to all AS numbers\n"
5930 "Replace private ASNs with our ASN in outbound updates\n")
5933 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5934 bgp_node_afi(vty
), bgp_node_safi(vty
),
5935 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5939 no_neighbor_remove_private_as_all_replace_as
,
5940 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5941 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5942 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5943 "Remove private ASNs in outbound updates\n"
5944 "Apply to all AS numbers\n"
5945 "Replace private ASNs with our ASN in outbound updates\n")
5948 /* neighbor send-community. */
5949 DEFUN (neighbor_send_community
,
5950 neighbor_send_community_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5954 "Send Community attribute to this neighbor\n")
5958 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5960 PEER_FLAG_SEND_COMMUNITY
);
5963 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5964 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5966 "Send Community attribute to this neighbor\n")
5968 DEFUN (no_neighbor_send_community
,
5969 no_neighbor_send_community_cmd
,
5970 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5974 "Send Community attribute to this neighbor\n")
5978 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5979 bgp_node_afi(vty
), bgp_node_safi(vty
),
5980 PEER_FLAG_SEND_COMMUNITY
);
5983 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5984 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5985 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5986 "Send Community attribute to this neighbor\n")
5988 /* neighbor send-community extended. */
5989 DEFUN (neighbor_send_community_type
,
5990 neighbor_send_community_type_cmd
,
5991 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5994 "Send Community attribute to this neighbor\n"
5995 "Send Standard and Extended Community attributes\n"
5996 "Send Standard, Large and Extended Community attributes\n"
5997 "Send Extended Community attributes\n"
5998 "Send Standard Community attributes\n"
5999 "Send Large Community attributes\n")
6001 const char *type
= argv
[argc
- 1]->text
;
6002 char *peer_str
= argv
[1]->arg
;
6004 afi_t afi
= bgp_node_afi(vty
);
6005 safi_t safi
= bgp_node_safi(vty
);
6007 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6009 return CMD_WARNING_CONFIG_FAILED
;
6011 if (strmatch(type
, "standard"))
6012 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6013 PEER_FLAG_SEND_COMMUNITY
);
6015 if (strmatch(type
, "extended"))
6016 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6017 PEER_FLAG_SEND_EXT_COMMUNITY
);
6019 if (strmatch(type
, "large"))
6020 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6021 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6023 if (strmatch(type
, "both")) {
6024 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6025 PEER_FLAG_SEND_COMMUNITY
)
6026 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6027 PEER_FLAG_SEND_EXT_COMMUNITY
);
6029 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6030 PEER_FLAG_SEND_COMMUNITY
)
6031 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6032 PEER_FLAG_SEND_EXT_COMMUNITY
)
6033 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6034 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6038 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6039 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6040 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6041 "Send Community attribute to this neighbor\n"
6042 "Send Standard and Extended Community attributes\n"
6043 "Send Standard, Large and Extended Community attributes\n"
6044 "Send Extended Community attributes\n"
6045 "Send Standard Community attributes\n"
6046 "Send Large Community attributes\n")
6048 DEFUN (no_neighbor_send_community_type
,
6049 no_neighbor_send_community_type_cmd
,
6050 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6054 "Send Community attribute to this neighbor\n"
6055 "Send Standard and Extended Community attributes\n"
6056 "Send Standard, Large and Extended Community attributes\n"
6057 "Send Extended Community attributes\n"
6058 "Send Standard Community attributes\n"
6059 "Send Large Community attributes\n")
6061 const char *type
= argv
[argc
- 1]->text
;
6062 char *peer_str
= argv
[2]->arg
;
6064 afi_t afi
= bgp_node_afi(vty
);
6065 safi_t safi
= bgp_node_safi(vty
);
6067 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6069 return CMD_WARNING_CONFIG_FAILED
;
6071 if (strmatch(type
, "standard"))
6072 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6073 PEER_FLAG_SEND_COMMUNITY
);
6075 if (strmatch(type
, "extended"))
6076 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6077 PEER_FLAG_SEND_EXT_COMMUNITY
);
6079 if (strmatch(type
, "large"))
6080 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6081 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6083 if (strmatch(type
, "both")) {
6085 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6086 PEER_FLAG_SEND_COMMUNITY
)
6087 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6088 PEER_FLAG_SEND_EXT_COMMUNITY
);
6091 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6092 PEER_FLAG_SEND_COMMUNITY
)
6093 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6094 PEER_FLAG_SEND_EXT_COMMUNITY
)
6095 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6096 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6100 no_neighbor_send_community_type
,
6101 no_neighbor_send_community_type_hidden_cmd
,
6102 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6103 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Send Community attribute to this neighbor\n"
6105 "Send Standard and Extended Community attributes\n"
6106 "Send Standard, Large and Extended Community attributes\n"
6107 "Send Extended Community attributes\n"
6108 "Send Standard Community attributes\n"
6109 "Send Large Community attributes\n")
6111 /* neighbor soft-reconfig. */
6112 DEFUN (neighbor_soft_reconfiguration
,
6113 neighbor_soft_reconfiguration_cmd
,
6114 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6117 "Per neighbor soft reconfiguration\n"
6118 "Allow inbound soft reconfiguration for this neighbor\n")
6121 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6123 PEER_FLAG_SOFT_RECONFIG
);
6126 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6127 neighbor_soft_reconfiguration_hidden_cmd
,
6128 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6130 "Per neighbor soft reconfiguration\n"
6131 "Allow inbound soft reconfiguration for this neighbor\n")
6133 DEFUN (no_neighbor_soft_reconfiguration
,
6134 no_neighbor_soft_reconfiguration_cmd
,
6135 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6139 "Per neighbor soft reconfiguration\n"
6140 "Allow inbound soft reconfiguration for this neighbor\n")
6143 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6144 bgp_node_afi(vty
), bgp_node_safi(vty
),
6145 PEER_FLAG_SOFT_RECONFIG
);
6148 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6149 no_neighbor_soft_reconfiguration_hidden_cmd
,
6150 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6152 "Per neighbor soft reconfiguration\n"
6153 "Allow inbound soft reconfiguration for this neighbor\n")
6155 DEFUN (neighbor_route_reflector_client
,
6156 neighbor_route_reflector_client_cmd
,
6157 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6160 "Configure a neighbor as Route Reflector client\n")
6166 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6168 return CMD_WARNING_CONFIG_FAILED
;
6170 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6172 PEER_FLAG_REFLECTOR_CLIENT
);
6175 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6176 neighbor_route_reflector_client_hidden_cmd
,
6177 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6178 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6179 "Configure a neighbor as Route Reflector client\n")
6181 DEFUN (no_neighbor_route_reflector_client
,
6182 no_neighbor_route_reflector_client_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6187 "Configure a neighbor as Route Reflector client\n")
6190 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6191 bgp_node_afi(vty
), bgp_node_safi(vty
),
6192 PEER_FLAG_REFLECTOR_CLIENT
);
6195 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6196 no_neighbor_route_reflector_client_hidden_cmd
,
6197 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6198 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6199 "Configure a neighbor as Route Reflector client\n")
6201 /* neighbor route-server-client. */
6202 DEFUN (neighbor_route_server_client
,
6203 neighbor_route_server_client_cmd
,
6204 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6207 "Configure a neighbor as Route Server client\n")
6212 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6214 return CMD_WARNING_CONFIG_FAILED
;
6215 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6217 PEER_FLAG_RSERVER_CLIENT
);
6220 ALIAS_HIDDEN(neighbor_route_server_client
,
6221 neighbor_route_server_client_hidden_cmd
,
6222 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6223 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6224 "Configure a neighbor as Route Server client\n")
6226 DEFUN (no_neighbor_route_server_client
,
6227 no_neighbor_route_server_client_cmd
,
6228 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6232 "Configure a neighbor as Route Server client\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_RSERVER_CLIENT
);
6240 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6241 no_neighbor_route_server_client_hidden_cmd
,
6242 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6243 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6244 "Configure a neighbor as Route Server client\n")
6246 DEFUN (neighbor_nexthop_local_unchanged
,
6247 neighbor_nexthop_local_unchanged_cmd
,
6248 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6251 "Configure treatment of outgoing link-local nexthop attribute\n"
6252 "Leave link-local nexthop unchanged for this peer\n")
6255 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6257 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6260 DEFUN (no_neighbor_nexthop_local_unchanged
,
6261 no_neighbor_nexthop_local_unchanged_cmd
,
6262 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6266 "Configure treatment of outgoing link-local-nexthop attribute\n"
6267 "Leave link-local nexthop unchanged for this peer\n")
6270 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6271 bgp_node_afi(vty
), bgp_node_safi(vty
),
6272 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6275 DEFUN (neighbor_attr_unchanged
,
6276 neighbor_attr_unchanged_cmd
,
6277 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6280 "BGP attribute is propagated unchanged to this neighbor\n"
6281 "As-path attribute\n"
6282 "Nexthop attribute\n"
6286 char *peer_str
= argv
[1]->arg
;
6288 bool aspath
= false;
6289 bool nexthop
= false;
6291 afi_t afi
= bgp_node_afi(vty
);
6292 safi_t safi
= bgp_node_safi(vty
);
6295 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6297 return CMD_WARNING_CONFIG_FAILED
;
6299 if (argv_find(argv
, argc
, "as-path", &idx
))
6303 if (argv_find(argv
, argc
, "next-hop", &idx
))
6307 if (argv_find(argv
, argc
, "med", &idx
))
6310 /* no flags means all of them! */
6311 if (!aspath
&& !nexthop
&& !med
) {
6312 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6313 PEER_FLAG_AS_PATH_UNCHANGED
);
6314 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6315 PEER_FLAG_NEXTHOP_UNCHANGED
);
6316 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6317 PEER_FLAG_MED_UNCHANGED
);
6320 if (peer_af_flag_check(peer
, afi
, safi
,
6321 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6322 ret
|= peer_af_flag_unset_vty(
6323 vty
, peer_str
, afi
, safi
,
6324 PEER_FLAG_AS_PATH_UNCHANGED
);
6327 ret
|= peer_af_flag_set_vty(
6328 vty
, peer_str
, afi
, safi
,
6329 PEER_FLAG_AS_PATH_UNCHANGED
);
6332 if (peer_af_flag_check(peer
, afi
, safi
,
6333 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6334 ret
|= peer_af_flag_unset_vty(
6335 vty
, peer_str
, afi
, safi
,
6336 PEER_FLAG_NEXTHOP_UNCHANGED
);
6339 ret
|= peer_af_flag_set_vty(
6340 vty
, peer_str
, afi
, safi
,
6341 PEER_FLAG_NEXTHOP_UNCHANGED
);
6344 if (peer_af_flag_check(peer
, afi
, safi
,
6345 PEER_FLAG_MED_UNCHANGED
)) {
6346 ret
|= peer_af_flag_unset_vty(
6347 vty
, peer_str
, afi
, safi
,
6348 PEER_FLAG_MED_UNCHANGED
);
6351 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6352 PEER_FLAG_MED_UNCHANGED
);
6359 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6360 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6361 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6362 "BGP attribute is propagated unchanged to this neighbor\n"
6363 "As-path attribute\n"
6364 "Nexthop attribute\n"
6367 DEFUN (no_neighbor_attr_unchanged
,
6368 no_neighbor_attr_unchanged_cmd
,
6369 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6373 "BGP attribute is propagated unchanged to this neighbor\n"
6374 "As-path attribute\n"
6375 "Nexthop attribute\n"
6379 char *peer_str
= argv
[2]->arg
;
6381 bool aspath
= false;
6382 bool nexthop
= false;
6384 afi_t afi
= bgp_node_afi(vty
);
6385 safi_t safi
= bgp_node_safi(vty
);
6388 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6390 return CMD_WARNING_CONFIG_FAILED
;
6392 if (argv_find(argv
, argc
, "as-path", &idx
))
6396 if (argv_find(argv
, argc
, "next-hop", &idx
))
6400 if (argv_find(argv
, argc
, "med", &idx
))
6403 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6404 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6405 PEER_FLAG_AS_PATH_UNCHANGED
)
6406 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6407 PEER_FLAG_NEXTHOP_UNCHANGED
)
6408 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6409 PEER_FLAG_MED_UNCHANGED
);
6412 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6413 PEER_FLAG_AS_PATH_UNCHANGED
);
6416 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6417 PEER_FLAG_NEXTHOP_UNCHANGED
);
6420 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6421 PEER_FLAG_MED_UNCHANGED
);
6427 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6428 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6429 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6430 "BGP attribute is propagated unchanged to this neighbor\n"
6431 "As-path attribute\n"
6432 "Nexthop attribute\n"
6435 /* EBGP multihop configuration. */
6436 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6437 const char *ttl_str
)
6442 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6444 return CMD_WARNING_CONFIG_FAILED
;
6447 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6452 ttl
= strtoul(ttl_str
, NULL
, 10);
6454 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6457 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6461 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6463 return CMD_WARNING_CONFIG_FAILED
;
6465 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6468 /* neighbor ebgp-multihop. */
6469 DEFUN (neighbor_ebgp_multihop
,
6470 neighbor_ebgp_multihop_cmd
,
6471 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6474 "Allow EBGP neighbors not on directly connected networks\n")
6477 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6480 DEFUN (neighbor_ebgp_multihop_ttl
,
6481 neighbor_ebgp_multihop_ttl_cmd
,
6482 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6485 "Allow EBGP neighbors not on directly connected networks\n"
6486 "maximum hop count\n")
6490 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6491 argv
[idx_number
]->arg
);
6494 DEFUN (no_neighbor_ebgp_multihop
,
6495 no_neighbor_ebgp_multihop_cmd
,
6496 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6500 "Allow EBGP neighbors not on directly connected networks\n"
6501 "maximum hop count\n")
6504 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6507 static uint8_t get_role_by_name(const char *role_str
)
6509 if (strncmp(role_str
, "peer", 2) == 0)
6511 if (strncmp(role_str
, "provider", 2) == 0)
6512 return ROLE_PROVIDER
;
6513 if (strncmp(role_str
, "customer", 2) == 0)
6514 return ROLE_CUSTOMER
;
6515 if (strncmp(role_str
, "rs-server", 4) == 0)
6516 return ROLE_RS_SERVER
;
6517 if (strncmp(role_str
, "rs-client", 4) == 0)
6518 return ROLE_RS_CLIENT
;
6519 return ROLE_UNDEFINED
;
6522 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6523 const char *role_str
, bool strict_mode
)
6527 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6529 return CMD_WARNING_CONFIG_FAILED
;
6530 uint8_t role
= get_role_by_name(role_str
);
6532 if (role
== ROLE_UNDEFINED
)
6533 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6534 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6537 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6541 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6543 return CMD_WARNING_CONFIG_FAILED
;
6544 return bgp_vty_return(vty
, peer_role_unset(peer
));
6547 DEFPY(neighbor_role
,
6549 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6552 "Set session role\n"
6558 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6562 DEFPY(neighbor_role_strict
,
6563 neighbor_role_strict_cmd
,
6564 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6567 "Set session role\n"
6569 "Use additional restriction on peer\n")
6574 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6578 DEFPY(no_neighbor_role
,
6579 no_neighbor_role_cmd
,
6580 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6584 "Set session role\n"
6586 "Use additional restriction on peer\n")
6590 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6593 /* disable-connected-check */
6594 DEFUN (neighbor_disable_connected_check
,
6595 neighbor_disable_connected_check_cmd
,
6596 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6599 "one-hop away EBGP peer using loopback address\n"
6600 "Enforce EBGP neighbors perform multihop\n")
6603 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6604 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6607 DEFUN (no_neighbor_disable_connected_check
,
6608 no_neighbor_disable_connected_check_cmd
,
6609 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6613 "one-hop away EBGP peer using loopback address\n"
6614 "Enforce EBGP neighbors perform multihop\n")
6617 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6618 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6621 /* disable-link-bw-encoding-ieee */
6622 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6623 neighbor_disable_link_bw_encoding_ieee_cmd
,
6624 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6625 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6626 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6630 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6631 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6634 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6635 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6636 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6637 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6638 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6642 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6643 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6646 /* extended-optional-parameters */
6647 DEFUN(neighbor_extended_optional_parameters
,
6648 neighbor_extended_optional_parameters_cmd
,
6649 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6650 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6651 "Force the extended optional parameters format for OPEN messages\n")
6655 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6656 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6659 DEFUN(no_neighbor_extended_optional_parameters
,
6660 no_neighbor_extended_optional_parameters_cmd
,
6661 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6662 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6663 "Force the extended optional parameters format for OPEN messages\n")
6667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6668 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6671 /* enforce-first-as */
6672 DEFUN (neighbor_enforce_first_as
,
6673 neighbor_enforce_first_as_cmd
,
6674 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6677 "Enforce the first AS for EBGP routes\n")
6681 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6682 PEER_FLAG_ENFORCE_FIRST_AS
);
6685 DEFUN (no_neighbor_enforce_first_as
,
6686 no_neighbor_enforce_first_as_cmd
,
6687 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6691 "Enforce the first AS for EBGP routes\n")
6695 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6696 PEER_FLAG_ENFORCE_FIRST_AS
);
6700 DEFUN (neighbor_description
,
6701 neighbor_description_cmd
,
6702 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6705 "Neighbor specific description\n"
6706 "Up to 80 characters describing this neighbor\n")
6713 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6715 return CMD_WARNING_CONFIG_FAILED
;
6717 str
= argv_concat(argv
, argc
, idx_line
);
6719 peer_description_set(peer
, str
);
6721 XFREE(MTYPE_TMP
, str
);
6726 DEFUN (no_neighbor_description
,
6727 no_neighbor_description_cmd
,
6728 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6732 "Neighbor specific description\n")
6737 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6739 return CMD_WARNING_CONFIG_FAILED
;
6741 peer_description_unset(peer
);
6746 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6747 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6748 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6749 "Neighbor specific description\n"
6750 "Up to 80 characters describing this neighbor\n")
6752 /* Neighbor update-source. */
6753 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6754 const char *source_str
)
6760 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6762 return CMD_WARNING_CONFIG_FAILED
;
6768 if (str2sockunion(source_str
, &su
) == 0)
6769 peer_update_source_addr_set(peer
, &su
);
6771 if (str2prefix(source_str
, &p
)) {
6773 "%% Invalid update-source, remove prefix length \n");
6774 return CMD_WARNING_CONFIG_FAILED
;
6776 peer_update_source_if_set(peer
, source_str
);
6779 peer_update_source_unset(peer
);
6784 #define BGP_UPDATE_SOURCE_HELP_STR \
6787 "Interface name (requires zebra to be running)\n"
6789 DEFUN (neighbor_update_source
,
6790 neighbor_update_source_cmd
,
6791 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6794 "Source of routing updates\n"
6795 BGP_UPDATE_SOURCE_HELP_STR
)
6799 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6800 argv
[idx_peer_2
]->arg
);
6803 DEFUN (no_neighbor_update_source
,
6804 no_neighbor_update_source_cmd
,
6805 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6809 "Source of routing updates\n"
6810 BGP_UPDATE_SOURCE_HELP_STR
)
6813 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6816 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6817 afi_t afi
, safi_t safi
,
6818 const char *rmap
, int set
)
6822 struct route_map
*route_map
= NULL
;
6824 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6826 return CMD_WARNING_CONFIG_FAILED
;
6830 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6831 ret
= peer_default_originate_set(peer
, afi
, safi
,
6834 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6836 return bgp_vty_return(vty
, ret
);
6839 /* neighbor default-originate. */
6840 DEFUN (neighbor_default_originate
,
6841 neighbor_default_originate_cmd
,
6842 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6845 "Originate default route to this neighbor\n")
6848 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6850 bgp_node_safi(vty
), NULL
, 1);
6853 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6854 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6855 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6856 "Originate default route to this neighbor\n")
6858 DEFUN (neighbor_default_originate_rmap
,
6859 neighbor_default_originate_rmap_cmd
,
6860 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6863 "Originate default route to this neighbor\n"
6864 "Route-map to specify criteria to originate default\n"
6869 return peer_default_originate_set_vty(
6870 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6871 argv
[idx_word
]->arg
, 1);
6875 neighbor_default_originate_rmap
,
6876 neighbor_default_originate_rmap_hidden_cmd
,
6877 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6878 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6879 "Originate default route to this neighbor\n"
6880 "Route-map to specify criteria to originate default\n"
6883 DEFUN (no_neighbor_default_originate
,
6884 no_neighbor_default_originate_cmd
,
6885 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6889 "Originate default route to this neighbor\n"
6890 "Route-map to specify criteria to originate default\n"
6894 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6896 bgp_node_safi(vty
), NULL
, 0);
6900 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6901 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6902 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6903 "Originate default route to this neighbor\n"
6904 "Route-map to specify criteria to originate default\n"
6908 /* Set neighbor's BGP port. */
6909 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6910 const char *port_str
)
6916 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6918 return CMD_WARNING_CONFIG_FAILED
;
6921 sp
= getservbyname("bgp", "tcp");
6922 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6924 port
= strtoul(port_str
, NULL
, 10);
6927 peer_port_set(peer
, port
);
6932 /* Set specified peer's BGP port. */
6933 DEFUN (neighbor_port
,
6935 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6938 "Neighbor's BGP port\n"
6939 "TCP port number\n")
6943 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6944 argv
[idx_number
]->arg
);
6947 DEFUN (no_neighbor_port
,
6948 no_neighbor_port_cmd
,
6949 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6953 "Neighbor's BGP port\n"
6954 "TCP port number\n")
6957 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6961 /* neighbor weight. */
6962 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6963 safi_t safi
, const char *weight_str
)
6967 unsigned long weight
;
6969 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6971 return CMD_WARNING_CONFIG_FAILED
;
6973 weight
= strtoul(weight_str
, NULL
, 10);
6975 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6976 return bgp_vty_return(vty
, ret
);
6979 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6985 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6987 return CMD_WARNING_CONFIG_FAILED
;
6989 ret
= peer_weight_unset(peer
, afi
, safi
);
6990 return bgp_vty_return(vty
, ret
);
6993 DEFUN (neighbor_weight
,
6994 neighbor_weight_cmd
,
6995 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6998 "Set default weight for routes from this neighbor\n"
7003 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7004 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7007 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7008 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7009 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7010 "Set default weight for routes from this neighbor\n"
7013 DEFUN (no_neighbor_weight
,
7014 no_neighbor_weight_cmd
,
7015 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7019 "Set default weight for routes from this neighbor\n"
7023 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7024 bgp_node_afi(vty
), bgp_node_safi(vty
));
7027 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7028 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7029 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7030 "Set default weight for routes from this neighbor\n"
7034 /* Override capability negotiation. */
7035 DEFUN (neighbor_override_capability
,
7036 neighbor_override_capability_cmd
,
7037 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7040 "Override capability negotiation result\n")
7043 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7044 PEER_FLAG_OVERRIDE_CAPABILITY
);
7047 DEFUN (no_neighbor_override_capability
,
7048 no_neighbor_override_capability_cmd
,
7049 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7053 "Override capability negotiation result\n")
7056 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7057 PEER_FLAG_OVERRIDE_CAPABILITY
);
7060 DEFUN (neighbor_strict_capability
,
7061 neighbor_strict_capability_cmd
,
7062 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7065 "Strict capability negotiation match\n")
7069 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7070 PEER_FLAG_STRICT_CAP_MATCH
);
7073 DEFUN (no_neighbor_strict_capability
,
7074 no_neighbor_strict_capability_cmd
,
7075 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7079 "Strict capability negotiation match\n")
7083 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7084 PEER_FLAG_STRICT_CAP_MATCH
);
7087 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7088 const char *keep_str
, const char *hold_str
)
7095 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7097 return CMD_WARNING_CONFIG_FAILED
;
7099 keepalive
= strtoul(keep_str
, NULL
, 10);
7100 holdtime
= strtoul(hold_str
, NULL
, 10);
7102 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7104 return bgp_vty_return(vty
, ret
);
7107 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7112 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7114 return CMD_WARNING_CONFIG_FAILED
;
7116 ret
= peer_timers_unset(peer
);
7118 return bgp_vty_return(vty
, ret
);
7121 DEFUN (neighbor_timers
,
7122 neighbor_timers_cmd
,
7123 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7126 "BGP per neighbor timers\n"
7127 "Keepalive interval\n"
7132 int idx_number_2
= 4;
7133 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7134 argv
[idx_number
]->arg
,
7135 argv
[idx_number_2
]->arg
);
7138 DEFUN (no_neighbor_timers
,
7139 no_neighbor_timers_cmd
,
7140 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7144 "BGP per neighbor timers\n"
7145 "Keepalive interval\n"
7149 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7153 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7154 const char *time_str
)
7160 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7162 return CMD_WARNING_CONFIG_FAILED
;
7164 connect
= strtoul(time_str
, NULL
, 10);
7166 ret
= peer_timers_connect_set(peer
, connect
);
7168 return bgp_vty_return(vty
, ret
);
7171 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7176 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7178 return CMD_WARNING_CONFIG_FAILED
;
7180 ret
= peer_timers_connect_unset(peer
);
7182 return bgp_vty_return(vty
, ret
);
7185 DEFUN (neighbor_timers_connect
,
7186 neighbor_timers_connect_cmd
,
7187 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7190 "BGP per neighbor timers\n"
7191 "BGP connect timer\n"
7196 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7197 argv
[idx_number
]->arg
);
7200 DEFUN (no_neighbor_timers_connect
,
7201 no_neighbor_timers_connect_cmd
,
7202 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7206 "BGP per neighbor timers\n"
7207 "BGP connect timer\n"
7211 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7214 DEFPY (neighbor_timers_delayopen
,
7215 neighbor_timers_delayopen_cmd
,
7216 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7219 "BGP per neighbor timers\n"
7220 "RFC 4271 DelayOpenTimer\n"
7221 "DelayOpenTime timer interval\n")
7225 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7227 return CMD_WARNING_CONFIG_FAILED
;
7230 if (peer_timers_delayopen_unset(peer
))
7231 return CMD_WARNING_CONFIG_FAILED
;
7233 if (peer_timers_delayopen_set(peer
, interval
))
7234 return CMD_WARNING_CONFIG_FAILED
;
7240 DEFPY (no_neighbor_timers_delayopen
,
7241 no_neighbor_timers_delayopen_cmd
,
7242 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7246 "BGP per neighbor timers\n"
7247 "RFC 4271 DelayOpenTimer\n"
7248 "DelayOpenTime timer interval\n")
7252 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7254 return CMD_WARNING_CONFIG_FAILED
;
7256 if (peer_timers_delayopen_unset(peer
))
7257 return CMD_WARNING_CONFIG_FAILED
;
7262 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7263 const char *time_str
, int set
)
7267 uint32_t routeadv
= 0;
7269 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7271 return CMD_WARNING_CONFIG_FAILED
;
7274 routeadv
= strtoul(time_str
, NULL
, 10);
7277 ret
= peer_advertise_interval_set(peer
, routeadv
);
7279 ret
= peer_advertise_interval_unset(peer
);
7281 return bgp_vty_return(vty
, ret
);
7284 DEFUN (neighbor_advertise_interval
,
7285 neighbor_advertise_interval_cmd
,
7286 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7289 "Minimum interval between sending BGP routing updates\n"
7290 "time in seconds\n")
7294 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7295 argv
[idx_number
]->arg
, 1);
7298 DEFUN (no_neighbor_advertise_interval
,
7299 no_neighbor_advertise_interval_cmd
,
7300 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7304 "Minimum interval between sending BGP routing updates\n"
7305 "time in seconds\n")
7308 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7312 /* Time to wait before processing route-map updates */
7313 DEFUN (bgp_set_route_map_delay_timer
,
7314 bgp_set_route_map_delay_timer_cmd
,
7315 "bgp route-map delay-timer (0-600)",
7317 "BGP route-map delay timer\n"
7318 "Time in secs to wait before processing route-map changes\n"
7319 "0 disables the timer, no route updates happen when route-maps change\n")
7322 uint32_t rmap_delay_timer
;
7324 if (argv
[idx_number
]->arg
) {
7325 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7326 bm
->rmap_update_timer
= rmap_delay_timer
;
7328 /* if the dynamic update handling is being disabled, and a timer
7330 * running, stop the timer and act as if the timer has already
7333 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7334 THREAD_OFF(bm
->t_rmap_update
);
7335 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7340 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7341 return CMD_WARNING_CONFIG_FAILED
;
7345 DEFUN (no_bgp_set_route_map_delay_timer
,
7346 no_bgp_set_route_map_delay_timer_cmd
,
7347 "no bgp route-map delay-timer [(0-600)]",
7350 "Default BGP route-map delay timer\n"
7351 "Reset to default time to wait for processing route-map changes\n"
7352 "0 disables the timer, no route updates happen when route-maps change\n")
7355 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7360 /* neighbor interface */
7361 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7366 peer
= peer_lookup_vty(vty
, ip_str
);
7367 if (!peer
|| peer
->conf_if
) {
7368 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7369 return CMD_WARNING_CONFIG_FAILED
;
7373 peer_interface_set(peer
, str
);
7375 peer_interface_unset(peer
);
7380 DEFUN (neighbor_interface
,
7381 neighbor_interface_cmd
,
7382 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7391 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7394 DEFUN (no_neighbor_interface
,
7395 no_neighbor_interface_cmd
,
7396 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7405 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7408 DEFUN (neighbor_distribute_list
,
7409 neighbor_distribute_list_cmd
,
7410 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7413 "Filter updates to/from this neighbor\n"
7414 "IP Access-list name\n"
7415 "Filter incoming updates\n"
7416 "Filter outgoing updates\n")
7423 const char *pstr
= argv
[idx_peer
]->arg
;
7424 const char *acl
= argv
[idx_acl
]->arg
;
7425 const char *inout
= argv
[argc
- 1]->text
;
7427 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7429 return CMD_WARNING_CONFIG_FAILED
;
7431 /* Check filter direction. */
7432 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7433 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7436 return bgp_vty_return(vty
, ret
);
7440 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7441 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7442 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7443 "Filter updates to/from this neighbor\n"
7444 "IP Access-list name\n"
7445 "Filter incoming updates\n"
7446 "Filter outgoing updates\n")
7448 DEFUN (no_neighbor_distribute_list
,
7449 no_neighbor_distribute_list_cmd
,
7450 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7454 "Filter updates to/from this neighbor\n"
7455 "IP Access-list name\n"
7456 "Filter incoming updates\n"
7457 "Filter outgoing updates\n")
7463 const char *pstr
= argv
[idx_peer
]->arg
;
7464 const char *inout
= argv
[argc
- 1]->text
;
7466 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7468 return CMD_WARNING_CONFIG_FAILED
;
7470 /* Check filter direction. */
7471 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7472 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7475 return bgp_vty_return(vty
, ret
);
7479 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7480 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7482 "Filter updates to/from this neighbor\n"
7483 "IP Access-list name\n"
7484 "Filter incoming updates\n"
7485 "Filter outgoing updates\n")
7487 /* Set prefix list to the peer. */
7488 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7489 afi_t afi
, safi_t safi
,
7490 const char *name_str
,
7491 const char *direct_str
)
7494 int direct
= FILTER_IN
;
7497 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7499 return CMD_WARNING_CONFIG_FAILED
;
7501 /* Check filter direction. */
7502 if (strncmp(direct_str
, "i", 1) == 0)
7504 else if (strncmp(direct_str
, "o", 1) == 0)
7505 direct
= FILTER_OUT
;
7507 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7509 return bgp_vty_return(vty
, ret
);
7512 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7513 afi_t afi
, safi_t safi
,
7514 const char *direct_str
)
7518 int direct
= FILTER_IN
;
7520 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7522 return CMD_WARNING_CONFIG_FAILED
;
7524 /* Check filter direction. */
7525 if (strncmp(direct_str
, "i", 1) == 0)
7527 else if (strncmp(direct_str
, "o", 1) == 0)
7528 direct
= FILTER_OUT
;
7530 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7532 return bgp_vty_return(vty
, ret
);
7535 DEFUN (neighbor_prefix_list
,
7536 neighbor_prefix_list_cmd
,
7537 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7540 "Filter updates to/from this neighbor\n"
7541 "Name of a prefix list\n"
7542 "Filter incoming updates\n"
7543 "Filter outgoing updates\n")
7548 return peer_prefix_list_set_vty(
7549 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7550 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7553 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7554 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7555 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7556 "Filter updates to/from this neighbor\n"
7557 "Name of a prefix list\n"
7558 "Filter incoming updates\n"
7559 "Filter outgoing updates\n")
7561 DEFUN (no_neighbor_prefix_list
,
7562 no_neighbor_prefix_list_cmd
,
7563 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7567 "Filter updates to/from this neighbor\n"
7568 "Name of a prefix list\n"
7569 "Filter incoming updates\n"
7570 "Filter outgoing updates\n")
7574 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7575 bgp_node_afi(vty
), bgp_node_safi(vty
),
7576 argv
[idx_in_out
]->arg
);
7579 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7580 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7581 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7582 "Filter updates to/from this neighbor\n"
7583 "Name of a prefix list\n"
7584 "Filter incoming updates\n"
7585 "Filter outgoing updates\n")
7587 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7588 safi_t safi
, const char *name_str
,
7589 const char *direct_str
)
7593 int direct
= FILTER_IN
;
7595 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7597 return CMD_WARNING_CONFIG_FAILED
;
7599 /* Check filter direction. */
7600 if (strncmp(direct_str
, "i", 1) == 0)
7602 else if (strncmp(direct_str
, "o", 1) == 0)
7603 direct
= FILTER_OUT
;
7605 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7607 return bgp_vty_return(vty
, ret
);
7610 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7611 safi_t safi
, const char *direct_str
)
7615 int direct
= FILTER_IN
;
7617 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7619 return CMD_WARNING_CONFIG_FAILED
;
7621 /* Check filter direction. */
7622 if (strncmp(direct_str
, "i", 1) == 0)
7624 else if (strncmp(direct_str
, "o", 1) == 0)
7625 direct
= FILTER_OUT
;
7627 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7629 return bgp_vty_return(vty
, ret
);
7632 DEFUN (neighbor_filter_list
,
7633 neighbor_filter_list_cmd
,
7634 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7637 "Establish BGP filters\n"
7638 "AS path access-list name\n"
7639 "Filter incoming routes\n"
7640 "Filter outgoing routes\n")
7645 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7646 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7647 argv
[idx_in_out
]->arg
);
7650 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7651 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7652 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7653 "Establish BGP filters\n"
7654 "AS path access-list name\n"
7655 "Filter incoming routes\n"
7656 "Filter outgoing routes\n")
7658 DEFUN (no_neighbor_filter_list
,
7659 no_neighbor_filter_list_cmd
,
7660 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7664 "Establish BGP filters\n"
7665 "AS path access-list name\n"
7666 "Filter incoming routes\n"
7667 "Filter outgoing routes\n")
7671 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7672 bgp_node_afi(vty
), bgp_node_safi(vty
),
7673 argv
[idx_in_out
]->arg
);
7676 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7677 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7678 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7679 "Establish BGP filters\n"
7680 "AS path access-list name\n"
7681 "Filter incoming routes\n"
7682 "Filter outgoing routes\n")
7684 /* Set advertise-map to the peer. */
7685 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7686 afi_t afi
, safi_t safi
,
7687 const char *advertise_str
,
7688 const char *condition_str
, bool condition
,
7691 int ret
= CMD_WARNING_CONFIG_FAILED
;
7693 struct route_map
*advertise_map
;
7694 struct route_map
*condition_map
;
7696 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7700 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7701 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7704 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7705 advertise_map
, condition_str
,
7706 condition_map
, condition
);
7708 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7709 advertise_map
, condition_str
,
7710 condition_map
, condition
);
7712 return bgp_vty_return(vty
, ret
);
7715 DEFPY (bgp_condadv_period
,
7716 bgp_condadv_period_cmd
,
7717 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7720 "Conditional advertisement settings\n"
7721 "Set period to rescan BGP table to check if condition is met\n"
7722 "Period between BGP table scans, in seconds; default 60\n")
7724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7726 bgp
->condition_check_period
=
7727 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7732 DEFPY (neighbor_advertise_map
,
7733 neighbor_advertise_map_cmd
,
7734 "[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",
7738 "Route-map to conditionally advertise routes\n"
7739 "Name of advertise map\n"
7740 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7741 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7742 "Name of the exist or non exist map\n")
7744 bool condition
= CONDITION_EXIST
;
7746 if (!strcmp(exist
, "non-exist-map"))
7747 condition
= CONDITION_NON_EXIST
;
7749 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7750 bgp_node_safi(vty
), advertise_str
,
7751 condition_str
, condition
, !no
);
7754 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7755 "[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",
7756 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7757 "Route-map to conditionally advertise routes\n"
7758 "Name of advertise map\n"
7759 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7760 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7761 "Name of the exist or non exist map\n")
7763 /* Set route-map to the peer. */
7764 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7765 afi_t afi
, safi_t safi
, const char *name_str
,
7766 const char *direct_str
)
7770 int direct
= RMAP_IN
;
7771 struct route_map
*route_map
;
7773 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7775 return CMD_WARNING_CONFIG_FAILED
;
7777 /* Check filter direction. */
7778 if (strncmp(direct_str
, "in", 2) == 0)
7780 else if (strncmp(direct_str
, "o", 1) == 0)
7783 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7784 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7786 return bgp_vty_return(vty
, ret
);
7789 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7790 afi_t afi
, safi_t safi
,
7791 const char *direct_str
)
7795 int direct
= RMAP_IN
;
7797 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7799 return CMD_WARNING_CONFIG_FAILED
;
7801 /* Check filter direction. */
7802 if (strncmp(direct_str
, "in", 2) == 0)
7804 else if (strncmp(direct_str
, "o", 1) == 0)
7807 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7809 return bgp_vty_return(vty
, ret
);
7812 DEFUN (neighbor_route_map
,
7813 neighbor_route_map_cmd
,
7814 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7817 "Apply route map to neighbor\n"
7818 "Name of route map\n"
7819 "Apply map to incoming routes\n"
7820 "Apply map to outbound routes\n")
7825 return peer_route_map_set_vty(
7826 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7827 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7830 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7831 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7832 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7833 "Apply route map to neighbor\n"
7834 "Name of route map\n"
7835 "Apply map to incoming routes\n"
7836 "Apply map to outbound routes\n")
7838 DEFUN (no_neighbor_route_map
,
7839 no_neighbor_route_map_cmd
,
7840 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7844 "Apply route map to neighbor\n"
7845 "Name of route map\n"
7846 "Apply map to incoming routes\n"
7847 "Apply map to outbound routes\n")
7851 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7852 bgp_node_afi(vty
), bgp_node_safi(vty
),
7853 argv
[idx_in_out
]->arg
);
7856 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7857 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7858 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7859 "Apply route map to neighbor\n"
7860 "Name of route map\n"
7861 "Apply map to incoming routes\n"
7862 "Apply map to outbound routes\n")
7864 /* Set unsuppress-map to the peer. */
7865 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7866 afi_t afi
, safi_t safi
,
7867 const char *name_str
)
7871 struct route_map
*route_map
;
7873 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7875 return CMD_WARNING_CONFIG_FAILED
;
7877 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7878 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7880 return bgp_vty_return(vty
, ret
);
7883 /* Unset route-map from the peer. */
7884 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7885 afi_t afi
, safi_t safi
)
7890 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7892 return CMD_WARNING_CONFIG_FAILED
;
7894 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7896 return bgp_vty_return(vty
, ret
);
7899 DEFUN (neighbor_unsuppress_map
,
7900 neighbor_unsuppress_map_cmd
,
7901 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7904 "Route-map to selectively unsuppress suppressed routes\n"
7905 "Name of route map\n")
7909 return peer_unsuppress_map_set_vty(
7910 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7911 argv
[idx_word
]->arg
);
7914 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7915 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7917 "Route-map to selectively unsuppress suppressed routes\n"
7918 "Name of route map\n")
7920 DEFUN (no_neighbor_unsuppress_map
,
7921 no_neighbor_unsuppress_map_cmd
,
7922 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7926 "Route-map to selectively unsuppress suppressed routes\n"
7927 "Name of route map\n")
7930 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7932 bgp_node_safi(vty
));
7935 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7936 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7937 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7938 "Route-map to selectively unsuppress suppressed routes\n"
7939 "Name of route map\n")
7941 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7942 afi_t afi
, safi_t safi
,
7943 const char *num_str
,
7944 const char *threshold_str
, int warning
,
7945 const char *restart_str
,
7946 const char *force_str
)
7954 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7956 return CMD_WARNING_CONFIG_FAILED
;
7958 max
= strtoul(num_str
, NULL
, 10);
7960 threshold
= atoi(threshold_str
);
7962 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7965 restart
= atoi(restart_str
);
7969 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7970 restart
, force_str
? true : false);
7972 return bgp_vty_return(vty
, ret
);
7975 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7976 afi_t afi
, safi_t safi
)
7981 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7983 return CMD_WARNING_CONFIG_FAILED
;
7985 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7987 return bgp_vty_return(vty
, ret
);
7990 /* Maximum number of prefix to be sent to the neighbor. */
7991 DEFUN(neighbor_maximum_prefix_out
,
7992 neighbor_maximum_prefix_out_cmd
,
7993 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7996 "Maximum number of prefixes to be sent to this peer\n"
7997 "Maximum no. of prefix limit\n")
8004 afi_t afi
= bgp_node_afi(vty
);
8005 safi_t safi
= bgp_node_safi(vty
);
8007 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8009 return CMD_WARNING_CONFIG_FAILED
;
8011 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8013 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8015 return bgp_vty_return(vty
, ret
);
8018 DEFUN(no_neighbor_maximum_prefix_out
,
8019 no_neighbor_maximum_prefix_out_cmd
,
8020 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8024 "Maximum number of prefixes to be sent to this peer\n"
8025 "Maximum no. of prefix limit\n")
8030 afi_t afi
= bgp_node_afi(vty
);
8031 safi_t safi
= bgp_node_safi(vty
);
8033 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8035 return CMD_WARNING_CONFIG_FAILED
;
8037 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8039 return bgp_vty_return(vty
, ret
);
8042 /* Maximum number of prefix configuration. Prefix count is different
8043 for each peer configuration. So this configuration can be set for
8044 each peer configuration. */
8045 DEFUN (neighbor_maximum_prefix
,
8046 neighbor_maximum_prefix_cmd
,
8047 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8050 "Maximum number of prefix accept from this peer\n"
8051 "maximum no. of prefix limit\n"
8052 "Force checking all received routes not only accepted\n")
8059 if (argv_find(argv
, argc
, "force", &idx_force
))
8060 force
= argv
[idx_force
]->arg
;
8062 return peer_maximum_prefix_set_vty(
8063 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8064 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8067 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8070 "Maximum number of prefix accept from this peer\n"
8071 "maximum no. of prefix limit\n"
8072 "Force checking all received routes not only accepted\n")
8074 DEFUN (neighbor_maximum_prefix_threshold
,
8075 neighbor_maximum_prefix_threshold_cmd
,
8076 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8079 "Maximum number of prefix accept from this peer\n"
8080 "maximum no. of prefix limit\n"
8081 "Threshold value (%) at which to generate a warning msg\n"
8082 "Force checking all received routes not only accepted\n")
8086 int idx_number_2
= 4;
8090 if (argv_find(argv
, argc
, "force", &idx_force
))
8091 force
= argv
[idx_force
]->arg
;
8093 return peer_maximum_prefix_set_vty(
8094 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8095 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8099 neighbor_maximum_prefix_threshold
,
8100 neighbor_maximum_prefix_threshold_hidden_cmd
,
8101 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8102 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8103 "Maximum number of prefix accept from this peer\n"
8104 "maximum no. of prefix limit\n"
8105 "Threshold value (%) at which to generate a warning msg\n"
8106 "Force checking all received routes not only accepted\n")
8108 DEFUN (neighbor_maximum_prefix_warning
,
8109 neighbor_maximum_prefix_warning_cmd
,
8110 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8113 "Maximum number of prefix accept from this peer\n"
8114 "maximum no. of prefix limit\n"
8115 "Only give warning message when limit is exceeded\n"
8116 "Force checking all received routes not only accepted\n")
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
, NULL
, 1, NULL
, force
);
8132 neighbor_maximum_prefix_warning
,
8133 neighbor_maximum_prefix_warning_hidden_cmd
,
8134 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) 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 "Only give warning message when limit is exceeded\n"
8139 "Force checking all received routes not only accepted\n")
8141 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8142 neighbor_maximum_prefix_threshold_warning_cmd
,
8143 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8146 "Maximum number of prefix accept from this peer\n"
8147 "maximum no. of prefix limit\n"
8148 "Threshold value (%) at which to generate a warning msg\n"
8149 "Only give warning message when limit is exceeded\n"
8150 "Force checking all received routes not only accepted\n")
8154 int idx_number_2
= 4;
8158 if (argv_find(argv
, argc
, "force", &idx_force
))
8159 force
= argv
[idx_force
]->arg
;
8161 return peer_maximum_prefix_set_vty(
8162 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8163 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8167 neighbor_maximum_prefix_threshold_warning
,
8168 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8169 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8170 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8171 "Maximum number of prefix accept from this peer\n"
8172 "maximum no. of prefix limit\n"
8173 "Threshold value (%) at which to generate a warning msg\n"
8174 "Only give warning message when limit is exceeded\n"
8175 "Force checking all received routes not only accepted\n")
8177 DEFUN (neighbor_maximum_prefix_restart
,
8178 neighbor_maximum_prefix_restart_cmd
,
8179 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8182 "Maximum number of prefix accept from this peer\n"
8183 "maximum no. of prefix limit\n"
8184 "Restart bgp connection after limit is exceeded\n"
8185 "Restart interval in minutes\n"
8186 "Force checking all received routes not only accepted\n")
8190 int idx_number_2
= 5;
8194 if (argv_find(argv
, argc
, "force", &idx_force
))
8195 force
= argv
[idx_force
]->arg
;
8197 return peer_maximum_prefix_set_vty(
8198 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8199 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8203 neighbor_maximum_prefix_restart
,
8204 neighbor_maximum_prefix_restart_hidden_cmd
,
8205 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8206 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8207 "Maximum number of prefix accept from this peer\n"
8208 "maximum no. of prefix limit\n"
8209 "Restart bgp connection after limit is exceeded\n"
8210 "Restart interval in minutes\n"
8211 "Force checking all received routes not only accepted\n")
8213 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8214 neighbor_maximum_prefix_threshold_restart_cmd
,
8215 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8218 "Maximum number of prefixes to accept from this peer\n"
8219 "maximum no. of prefix limit\n"
8220 "Threshold value (%) at which to generate a warning msg\n"
8221 "Restart bgp connection after limit is exceeded\n"
8222 "Restart interval in minutes\n"
8223 "Force checking all received routes not only accepted\n")
8227 int idx_number_2
= 4;
8228 int idx_number_3
= 6;
8232 if (argv_find(argv
, argc
, "force", &idx_force
))
8233 force
= argv
[idx_force
]->arg
;
8235 return peer_maximum_prefix_set_vty(
8236 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8237 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8238 argv
[idx_number_3
]->arg
, force
);
8242 neighbor_maximum_prefix_threshold_restart
,
8243 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8244 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8245 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8246 "Maximum number of prefixes to accept from this peer\n"
8247 "maximum no. of prefix limit\n"
8248 "Threshold value (%) at which to generate a warning msg\n"
8249 "Restart bgp connection after limit is exceeded\n"
8250 "Restart interval in minutes\n"
8251 "Force checking all received routes not only accepted\n")
8253 DEFUN (no_neighbor_maximum_prefix
,
8254 no_neighbor_maximum_prefix_cmd
,
8255 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8259 "Maximum number of prefixes to accept from this peer\n"
8260 "maximum no. of prefix limit\n"
8261 "Threshold value (%) at which to generate a warning msg\n"
8262 "Restart bgp connection after limit is exceeded\n"
8263 "Restart interval in minutes\n"
8264 "Only give warning message when limit is exceeded\n"
8265 "Force checking all received routes not only accepted\n")
8268 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8270 bgp_node_safi(vty
));
8274 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8275 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8276 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8277 "Maximum number of prefixes to accept from this peer\n"
8278 "maximum no. of prefix limit\n"
8279 "Threshold value (%) at which to generate a warning msg\n"
8280 "Restart bgp connection after limit is exceeded\n"
8281 "Restart interval in minutes\n"
8282 "Only give warning message when limit is exceeded\n"
8283 "Force checking all received routes not only accepted\n")
8285 /* "neighbor soo" */
8286 DEFPY (neighbor_soo
,
8288 "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
);
8297 struct ecommunity
*ecomm_soo
;
8299 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8301 return CMD_WARNING_CONFIG_FAILED
;
8303 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8305 vty_out(vty
, "%% Malformed SoO extended community\n");
8308 ecommunity_str(ecomm_soo
);
8310 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8311 ecommunity_free(&peer
->soo
[afi
][safi
]);
8312 peer
->soo
[afi
][safi
] = ecomm_soo
;
8313 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8316 return bgp_vty_return(vty
,
8317 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8320 DEFPY (no_neighbor_soo
,
8321 no_neighbor_soo_cmd
,
8322 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8326 "Set the Site-of-Origin (SoO) extended community\n"
8327 "VPN extended community\n")
8330 afi_t afi
= bgp_node_afi(vty
);
8331 safi_t safi
= bgp_node_safi(vty
);
8333 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8335 return CMD_WARNING_CONFIG_FAILED
;
8337 ecommunity_free(&peer
->soo
[afi
][safi
]);
8339 return bgp_vty_return(
8340 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8343 /* "neighbor allowas-in" */
8344 DEFUN (neighbor_allowas_in
,
8345 neighbor_allowas_in_cmd
,
8346 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8349 "Accept as-path with my AS present in it\n"
8350 "Number of occurrences of AS number\n"
8351 "Only accept my AS in the as-path if the route was originated in my AS\n")
8354 int idx_number_origin
= 3;
8360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8362 return CMD_WARNING_CONFIG_FAILED
;
8364 if (argc
<= idx_number_origin
)
8367 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8370 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8373 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8376 return bgp_vty_return(vty
, ret
);
8380 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8381 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8382 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8383 "Accept as-path with my AS present in it\n"
8384 "Number of occurrences of AS number\n"
8385 "Only accept my AS in the as-path if the route was originated in my AS\n")
8387 DEFUN (no_neighbor_allowas_in
,
8388 no_neighbor_allowas_in_cmd
,
8389 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8393 "allow local ASN appears in aspath attribute\n"
8394 "Number of occurrences of AS number\n"
8395 "Only accept my AS in the as-path if the route was originated in my AS\n")
8401 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8403 return CMD_WARNING_CONFIG_FAILED
;
8405 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8406 bgp_node_safi(vty
));
8408 return bgp_vty_return(vty
, ret
);
8412 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8413 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8414 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8415 "allow local ASN appears in aspath attribute\n"
8416 "Number of occurrences of AS number\n"
8417 "Only accept my AS in the as-path if the route was originated in my AS\n")
8419 DEFUN (neighbor_ttl_security
,
8420 neighbor_ttl_security_cmd
,
8421 "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")
8433 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8435 return CMD_WARNING_CONFIG_FAILED
;
8437 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8440 * If 'neighbor swpX', then this is for directly connected peers,
8441 * we should not accept a ttl-security hops value greater than 1.
8443 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8445 "%s is directly connected peer, hops cannot exceed 1\n",
8446 argv
[idx_peer
]->arg
);
8447 return CMD_WARNING_CONFIG_FAILED
;
8450 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8453 DEFUN (no_neighbor_ttl_security
,
8454 no_neighbor_ttl_security_cmd
,
8455 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8459 "BGP ttl-security parameters\n"
8460 "Specify the maximum number of hops to the BGP peer\n"
8461 "Number of hops to BGP peer\n")
8466 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8468 return CMD_WARNING_CONFIG_FAILED
;
8470 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8473 /* disable-addpath-rx */
8474 DEFUN(neighbor_disable_addpath_rx
,
8475 neighbor_disable_addpath_rx_cmd
,
8476 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8479 "Do not accept additional paths\n")
8481 char *peer_str
= argv
[1]->arg
;
8483 afi_t afi
= bgp_node_afi(vty
);
8484 safi_t safi
= bgp_node_safi(vty
);
8486 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8488 return CMD_WARNING_CONFIG_FAILED
;
8490 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8491 PEER_FLAG_DISABLE_ADDPATH_RX
);
8494 DEFUN(no_neighbor_disable_addpath_rx
,
8495 no_neighbor_disable_addpath_rx_cmd
,
8496 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8500 "Do not accept additional paths\n")
8502 char *peer_str
= argv
[2]->arg
;
8504 afi_t afi
= bgp_node_afi(vty
);
8505 safi_t safi
= bgp_node_safi(vty
);
8507 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8509 return CMD_WARNING_CONFIG_FAILED
;
8511 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8512 PEER_FLAG_DISABLE_ADDPATH_RX
);
8515 DEFUN (neighbor_addpath_tx_all_paths
,
8516 neighbor_addpath_tx_all_paths_cmd
,
8517 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8520 "Use addpath to advertise all paths to a neighbor\n")
8525 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8527 return CMD_WARNING_CONFIG_FAILED
;
8529 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8534 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8535 neighbor_addpath_tx_all_paths_hidden_cmd
,
8536 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8537 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8538 "Use addpath to advertise all paths to a neighbor\n")
8540 DEFUN (no_neighbor_addpath_tx_all_paths
,
8541 no_neighbor_addpath_tx_all_paths_cmd
,
8542 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8546 "Use addpath to advertise all paths to a neighbor\n")
8551 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8553 return CMD_WARNING_CONFIG_FAILED
;
8555 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8556 != BGP_ADDPATH_ALL
) {
8558 "%% Peer not currently configured to transmit all paths.");
8559 return CMD_WARNING_CONFIG_FAILED
;
8562 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8568 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8569 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8570 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8571 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8572 "Use addpath to advertise all paths to a neighbor\n")
8574 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8575 neighbor_addpath_tx_bestpath_per_as_cmd
,
8576 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8579 "Use addpath to advertise the bestpath per each neighboring AS\n")
8584 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8586 return CMD_WARNING_CONFIG_FAILED
;
8588 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8589 BGP_ADDPATH_BEST_PER_AS
);
8594 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8595 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8596 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8597 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8598 "Use addpath to advertise the bestpath per each neighboring AS\n")
8600 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8601 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8602 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8606 "Use addpath to advertise the bestpath per each neighboring AS\n")
8611 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8613 return CMD_WARNING_CONFIG_FAILED
;
8615 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8616 != BGP_ADDPATH_BEST_PER_AS
) {
8618 "%% Peer not currently configured to transmit all best path per as.");
8619 return CMD_WARNING_CONFIG_FAILED
;
8622 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8628 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8629 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8630 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8631 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8632 "Use addpath to advertise the bestpath per each neighboring AS\n")
8635 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8636 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8639 "Detect AS loops before sending to neighbor\n")
8643 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8645 return CMD_WARNING_CONFIG_FAILED
;
8647 peer
->as_path_loop_detection
= true;
8653 no_neighbor_aspath_loop_detection
,
8654 no_neighbor_aspath_loop_detection_cmd
,
8655 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8659 "Detect AS loops before sending to neighbor\n")
8663 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8665 return CMD_WARNING_CONFIG_FAILED
;
8667 peer
->as_path_loop_detection
= false;
8672 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8673 struct ecommunity
**list
, bool is_rt6
)
8675 struct ecommunity
*ecom
= NULL
;
8676 struct ecommunity
*ecomadd
;
8678 for (; argc
; --argc
, ++argv
) {
8680 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8681 ECOMMUNITY_ROUTE_TARGET
,
8684 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8685 ECOMMUNITY_ROUTE_TARGET
,
8688 vty_out(vty
, "Malformed community-list value\n");
8690 ecommunity_free(&ecom
);
8691 return CMD_WARNING_CONFIG_FAILED
;
8695 ecommunity_merge(ecom
, ecomadd
);
8696 ecommunity_free(&ecomadd
);
8703 ecommunity_free(&*list
);
8711 * v2vimport is true if we are handling a `import vrf ...` command
8713 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8717 switch (vty
->node
) {
8726 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8731 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8732 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8733 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8734 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8736 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8740 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8741 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8742 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8743 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8745 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8752 DEFPY (af_rd_vpn_export
,
8753 af_rd_vpn_export_cmd
,
8754 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8756 "Specify route distinguisher\n"
8757 "Between current address-family and vpn\n"
8758 "For routes leaked from current address-family to vpn\n"
8759 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8762 struct prefix_rd prd
;
8768 if (argv_find(argv
, argc
, "no", &idx
))
8772 ret
= str2prefix_rd(rd_str
, &prd
);
8774 vty_out(vty
, "%% Malformed rd\n");
8775 return CMD_WARNING_CONFIG_FAILED
;
8779 afi
= vpn_policy_getafi(vty
, bgp
, false);
8781 return CMD_WARNING_CONFIG_FAILED
;
8784 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8786 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8787 bgp_get_default(), bgp
);
8790 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8791 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8792 BGP_VPN_POLICY_TOVPN_RD_SET
);
8794 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8795 BGP_VPN_POLICY_TOVPN_RD_SET
);
8798 /* post-change: re-export vpn routes */
8799 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8800 bgp_get_default(), bgp
);
8805 ALIAS (af_rd_vpn_export
,
8806 af_no_rd_vpn_export_cmd
,
8809 "Specify route distinguisher\n"
8810 "Between current address-family and vpn\n"
8811 "For routes leaked from current address-family to vpn\n")
8813 DEFPY (af_label_vpn_export
,
8814 af_label_vpn_export_cmd
,
8815 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8817 "label value for VRF\n"
8818 "Between current address-family and vpn\n"
8819 "For routes leaked from current address-family to vpn\n"
8820 "Label Value <0-1048575>\n"
8821 "Automatically assign a label\n")
8823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8824 mpls_label_t label
= MPLS_LABEL_NONE
;
8829 if (argv_find(argv
, argc
, "no", &idx
))
8832 /* If "no ...", squash trailing parameter */
8838 label
= label_val
; /* parser should force unsigned */
8841 afi
= vpn_policy_getafi(vty
, bgp
, false);
8843 return CMD_WARNING_CONFIG_FAILED
;
8846 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8847 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8852 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8854 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8855 bgp_get_default(), bgp
);
8857 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8858 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8860 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8863 * label has previously been automatically
8864 * assigned by labelpool: release it
8866 * NB if tovpn_label == MPLS_LABEL_NONE it
8867 * means the automatic assignment is in flight
8868 * and therefore the labelpool callback must
8869 * detect that the auto label is not needed.
8872 bgp_lp_release(LP_TYPE_VRF
,
8873 &bgp
->vpn_policy
[afi
],
8874 bgp
->vpn_policy
[afi
].tovpn_label
);
8876 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8877 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8880 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8882 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8883 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8884 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8885 vpn_leak_label_callback
);
8888 /* post-change: re-export vpn routes */
8889 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8890 bgp_get_default(), bgp
);
8892 hook_call(bgp_snmp_update_last_changed
, bgp
);
8896 DEFPY (af_sid_vpn_export
,
8897 af_sid_vpn_export_cmd
,
8898 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8900 "sid value for VRF\n"
8901 "Between current address-family and vpn\n"
8902 "For routes leaked from current address-family to vpn\n"
8903 "Sid allocation index\n"
8904 "Automatically assign a label\n")
8906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8912 if (argv_find(argv
, argc
, "no", &idx
))
8914 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8915 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8917 afi
= vpn_policy_getafi(vty
, bgp
, false);
8919 return CMD_WARNING_CONFIG_FAILED
;
8923 vty_out(vty
, "It's not implemented\n");
8924 return CMD_WARNING_CONFIG_FAILED
;
8927 /* skip when it's already configured */
8928 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8929 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8930 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8934 * mode change between sid_idx and sid_auto isn't supported.
8935 * user must negate sid vpn export when they want to change the mode
8937 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8938 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8939 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8940 vty_out(vty
, "it's already configured as %s.\n",
8941 sid_auto
? "auto-mode" : "idx-mode");
8942 return CMD_WARNING_CONFIG_FAILED
;
8946 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8947 bgp_get_default(), bgp
);
8950 /* SID allocation auto-mode */
8952 zlog_debug("%s: auto sid alloc.", __func__
);
8953 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8954 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8956 /* SID allocation index-mode */
8958 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8959 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8963 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8964 bgp_get_default(), bgp
);
8968 ALIAS (af_label_vpn_export
,
8969 af_no_label_vpn_export_cmd
,
8970 "no label vpn export",
8972 "label value for VRF\n"
8973 "Between current address-family and vpn\n"
8974 "For routes leaked from current address-family to vpn\n")
8976 DEFPY (af_nexthop_vpn_export
,
8977 af_nexthop_vpn_export_cmd
,
8978 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8980 "Specify next hop to use for VRF advertised prefixes\n"
8981 "Between current address-family and vpn\n"
8982 "For routes leaked from current address-family to vpn\n"
8986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8992 vty_out(vty
, "%% Nexthop required\n");
8993 return CMD_WARNING_CONFIG_FAILED
;
8995 if (!sockunion2hostprefix(nexthop_su
, &p
))
8996 return CMD_WARNING_CONFIG_FAILED
;
8999 afi
= vpn_policy_getafi(vty
, bgp
, false);
9001 return CMD_WARNING_CONFIG_FAILED
;
9004 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9006 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9007 bgp_get_default(), bgp
);
9010 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9011 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9012 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9014 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9015 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9018 /* post-change: re-export vpn routes */
9019 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9020 bgp_get_default(), bgp
);
9025 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9027 if (!strcmp(dstr
, "import")) {
9028 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9029 } else if (!strcmp(dstr
, "export")) {
9030 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9031 } else if (!strcmp(dstr
, "both")) {
9032 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9033 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9035 vty_out(vty
, "%% direction parse error\n");
9036 return CMD_WARNING_CONFIG_FAILED
;
9041 DEFPY (af_rt_vpn_imexport
,
9042 af_rt_vpn_imexport_cmd
,
9043 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9045 "Specify route target list\n"
9046 "Specify route target list\n"
9047 "Between current address-family and vpn\n"
9048 "For routes leaked from vpn to current address-family: match any\n"
9049 "For routes leaked from current address-family to vpn: set\n"
9050 "both import: match any and export: set\n"
9051 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9055 struct ecommunity
*ecom
= NULL
;
9056 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9057 enum vpn_policy_direction dir
;
9062 if (argv_find(argv
, argc
, "no", &idx
))
9065 afi
= vpn_policy_getafi(vty
, bgp
, false);
9067 return CMD_WARNING_CONFIG_FAILED
;
9069 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9070 if (ret
!= CMD_SUCCESS
)
9074 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9075 vty_out(vty
, "%% Missing RTLIST\n");
9076 return CMD_WARNING_CONFIG_FAILED
;
9078 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9079 if (ret
!= CMD_SUCCESS
) {
9084 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9088 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9091 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9093 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9094 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9095 ecommunity_dup(ecom
);
9097 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9099 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9100 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9103 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9107 ecommunity_free(&ecom
);
9112 ALIAS (af_rt_vpn_imexport
,
9113 af_no_rt_vpn_imexport_cmd
,
9114 "no <rt|route-target> vpn <import|export|both>$direction_str",
9116 "Specify route target list\n"
9117 "Specify route target list\n"
9118 "Between current address-family and vpn\n"
9119 "For routes leaked from vpn to current address-family\n"
9120 "For routes leaked from current address-family to vpn\n"
9121 "both import and export\n")
9123 DEFPY (af_route_map_vpn_imexport
,
9124 af_route_map_vpn_imexport_cmd
,
9125 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9126 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9128 "Specify route map\n"
9129 "Between current address-family and vpn\n"
9130 "For routes leaked from vpn to current address-family\n"
9131 "For routes leaked from current address-family to vpn\n"
9132 "name of route-map\n")
9134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9136 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9137 enum vpn_policy_direction dir
;
9142 if (argv_find(argv
, argc
, "no", &idx
))
9145 afi
= vpn_policy_getafi(vty
, bgp
, false);
9147 return CMD_WARNING_CONFIG_FAILED
;
9149 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9150 if (ret
!= CMD_SUCCESS
)
9153 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9157 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9160 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9161 XFREE(MTYPE_ROUTE_MAP_NAME
,
9162 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9163 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9164 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9165 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9166 route_map_lookup_warn_noexist(vty
, rmap_str
);
9167 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9170 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9171 XFREE(MTYPE_ROUTE_MAP_NAME
,
9172 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9173 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9174 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9177 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9183 ALIAS (af_route_map_vpn_imexport
,
9184 af_no_route_map_vpn_imexport_cmd
,
9185 "no route-map vpn <import|export>$direction_str",
9187 "Specify route map\n"
9188 "Between current address-family and vpn\n"
9189 "For routes leaked from vpn to current address-family\n"
9190 "For routes leaked from current address-family to vpn\n")
9192 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9193 "import vrf route-map RMAP$rmap_str",
9194 "Import routes from another VRF\n"
9195 "Vrf routes being filtered\n"
9196 "Specify route map\n"
9197 "name of route-map\n")
9199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9200 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9202 struct bgp
*bgp_default
;
9204 afi
= vpn_policy_getafi(vty
, bgp
, true);
9206 return CMD_WARNING_CONFIG_FAILED
;
9208 bgp_default
= bgp_get_default();
9213 /* Auto-create assuming the same AS */
9214 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9215 BGP_INSTANCE_TYPE_DEFAULT
);
9219 "VRF default is not configured as a bgp instance\n");
9224 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9226 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9227 XFREE(MTYPE_ROUTE_MAP_NAME
,
9228 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9229 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9230 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9231 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9232 route_map_lookup_warn_noexist(vty
, rmap_str
);
9233 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9236 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9237 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9239 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9244 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9245 "no import vrf route-map [RMAP$rmap_str]",
9247 "Import routes from another VRF\n"
9248 "Vrf routes being filtered\n"
9249 "Specify route map\n"
9250 "name of route-map\n")
9252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9253 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9256 afi
= vpn_policy_getafi(vty
, bgp
, true);
9258 return CMD_WARNING_CONFIG_FAILED
;
9260 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9262 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9263 XFREE(MTYPE_ROUTE_MAP_NAME
,
9264 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9265 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9266 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9268 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9269 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9270 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9272 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9277 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9278 "[no] import vrf VIEWVRFNAME$import_name",
9280 "Import routes from another VRF\n"
9281 "VRF to import from\n"
9282 "The name of the VRF\n")
9284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9285 struct listnode
*node
;
9286 struct bgp
*vrf_bgp
, *bgp_default
;
9289 bool remove
= false;
9292 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9296 if (import_name
== NULL
) {
9297 vty_out(vty
, "%% Missing import name\n");
9301 if (strcmp(import_name
, "route-map") == 0) {
9302 vty_out(vty
, "%% Must include route-map name\n");
9306 if (argv_find(argv
, argc
, "no", &idx
))
9309 afi
= vpn_policy_getafi(vty
, bgp
, true);
9311 return CMD_WARNING_CONFIG_FAILED
;
9313 safi
= bgp_node_safi(vty
);
9315 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9316 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9317 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9318 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9319 remove
? "unimport" : "import", import_name
);
9323 bgp_default
= bgp_get_default();
9325 /* Auto-create assuming the same AS */
9326 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9327 BGP_INSTANCE_TYPE_DEFAULT
);
9331 "VRF default is not configured as a bgp instance\n");
9336 vrf_bgp
= bgp_lookup_by_name(import_name
);
9338 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9339 vrf_bgp
= bgp_default
;
9341 /* Auto-create assuming the same AS */
9342 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9346 "VRF %s is not configured as a bgp instance\n",
9353 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9355 /* Already importing from "import_vrf"? */
9356 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9358 if (strcmp(vname
, import_name
) == 0)
9362 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9368 /* This command is valid only in a bgp vrf instance or the default instance */
9369 DEFPY (bgp_imexport_vpn
,
9370 bgp_imexport_vpn_cmd
,
9371 "[no] <import|export>$direction_str vpn",
9373 "Import routes to this address-family\n"
9374 "Export routes from this address-family\n"
9375 "to/from default instance VPN RIB\n")
9377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9384 enum vpn_policy_direction dir
;
9386 if (argv_find(argv
, argc
, "no", &idx
))
9389 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9390 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9392 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9393 return CMD_WARNING_CONFIG_FAILED
;
9396 afi
= bgp_node_afi(vty
);
9397 safi
= bgp_node_safi(vty
);
9398 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9399 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9400 return CMD_WARNING_CONFIG_FAILED
;
9403 if (!strcmp(direction_str
, "import")) {
9404 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9405 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9406 } else if (!strcmp(direction_str
, "export")) {
9407 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9408 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9410 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9411 return CMD_WARNING_CONFIG_FAILED
;
9414 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9417 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9418 if (!previous_state
) {
9419 /* trigger export current vrf */
9420 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9423 if (previous_state
) {
9424 /* trigger un-export current vrf */
9425 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9427 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9430 hook_call(bgp_snmp_init_stats
, bgp
);
9435 DEFPY (af_routetarget_import
,
9436 af_routetarget_import_cmd
,
9437 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9439 "Specify route target list\n"
9440 "Specify route target list\n"
9441 "Specify route target list\n"
9442 "Specify route target list\n"
9443 "Flow-spec redirect type route target\n"
9444 "Import routes to this address-family\n"
9445 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9449 struct ecommunity
*ecom
= NULL
;
9451 int idx
= 0, idx_unused
= 0;
9455 if (argv_find(argv
, argc
, "no", &idx
))
9458 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9459 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9462 afi
= vpn_policy_getafi(vty
, bgp
, false);
9464 return CMD_WARNING_CONFIG_FAILED
;
9466 if (rt6
&& afi
!= AFI_IP6
)
9467 return CMD_WARNING_CONFIG_FAILED
;
9470 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9471 vty_out(vty
, "%% Missing RTLIST\n");
9472 return CMD_WARNING_CONFIG_FAILED
;
9474 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9475 if (ret
!= CMD_SUCCESS
)
9480 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9481 ecommunity_free(&bgp
->vpn_policy
[afi
]
9482 .import_redirect_rtlist
);
9483 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9484 ecommunity_dup(ecom
);
9486 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9487 ecommunity_free(&bgp
->vpn_policy
[afi
]
9488 .import_redirect_rtlist
);
9489 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9493 ecommunity_free(&ecom
);
9498 DEFUN_NOSH (address_family_ipv4_safi
,
9499 address_family_ipv4_safi_cmd
,
9500 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9501 "Enter Address Family command mode\n"
9503 BGP_SAFI_WITH_LABEL_HELP_STR
)
9507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9508 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9509 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9510 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9511 && safi
!= SAFI_EVPN
) {
9513 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9514 return CMD_WARNING_CONFIG_FAILED
;
9516 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9518 vty
->node
= BGP_IPV4_NODE
;
9523 DEFUN_NOSH (address_family_ipv6_safi
,
9524 address_family_ipv6_safi_cmd
,
9525 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9526 "Enter Address Family command mode\n"
9528 BGP_SAFI_WITH_LABEL_HELP_STR
)
9531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9532 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9533 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9534 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9535 && safi
!= SAFI_EVPN
) {
9537 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9538 return CMD_WARNING_CONFIG_FAILED
;
9540 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9542 vty
->node
= BGP_IPV6_NODE
;
9547 #ifdef KEEP_OLD_VPN_COMMANDS
9548 DEFUN_NOSH (address_family_vpnv4
,
9549 address_family_vpnv4_cmd
,
9550 "address-family vpnv4 [unicast]",
9551 "Enter Address Family command mode\n"
9553 BGP_AF_MODIFIER_STR
)
9555 vty
->node
= BGP_VPNV4_NODE
;
9559 DEFUN_NOSH (address_family_vpnv6
,
9560 address_family_vpnv6_cmd
,
9561 "address-family vpnv6 [unicast]",
9562 "Enter Address Family command mode\n"
9564 BGP_AF_MODIFIER_STR
)
9566 vty
->node
= BGP_VPNV6_NODE
;
9569 #endif /* KEEP_OLD_VPN_COMMANDS */
9571 DEFUN_NOSH (address_family_evpn
,
9572 address_family_evpn_cmd
,
9573 "address-family l2vpn evpn",
9574 "Enter Address Family command mode\n"
9576 BGP_AF_MODIFIER_STR
)
9578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9579 vty
->node
= BGP_EVPN_NODE
;
9583 DEFUN_NOSH (bgp_segment_routing_srv6
,
9584 bgp_segment_routing_srv6_cmd
,
9585 "segment-routing srv6",
9586 "Segment-Routing configuration\n"
9587 "Segment-Routing SRv6 configuration\n")
9589 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9590 bgp
->srv6_enabled
= true;
9591 vty
->node
= BGP_SRV6_NODE
;
9595 DEFUN (no_bgp_segment_routing_srv6
,
9596 no_bgp_segment_routing_srv6_cmd
,
9597 "no segment-routing srv6",
9599 "Segment-Routing configuration\n"
9600 "Segment-Routing SRv6 configuration\n")
9602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9604 if (strlen(bgp
->srv6_locator_name
) > 0)
9605 if (bgp_srv6_locator_unset(bgp
) < 0)
9606 return CMD_WARNING_CONFIG_FAILED
;
9608 bgp
->srv6_enabled
= false;
9612 DEFPY (bgp_srv6_locator
,
9613 bgp_srv6_locator_cmd
,
9614 "locator NAME$name",
9615 "Specify SRv6 locator\n"
9616 "Specify SRv6 locator\n")
9618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9621 if (strlen(bgp
->srv6_locator_name
) > 0
9622 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9623 vty_out(vty
, "srv6 locator is already configured\n");
9624 return CMD_WARNING_CONFIG_FAILED
;
9627 snprintf(bgp
->srv6_locator_name
,
9628 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9630 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9632 return CMD_WARNING_CONFIG_FAILED
;
9637 DEFPY (no_bgp_srv6_locator
,
9638 no_bgp_srv6_locator_cmd
,
9639 "no locator NAME$name",
9641 "Specify SRv6 locator\n"
9642 "Specify SRv6 locator\n")
9644 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9646 /* when locator isn't configured, do nothing */
9647 if (strlen(bgp
->srv6_locator_name
) < 1)
9650 /* name validation */
9651 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9652 vty_out(vty
, "%% No srv6 locator is configured\n");
9653 return CMD_WARNING_CONFIG_FAILED
;
9657 if (bgp_srv6_locator_unset(bgp
) < 0)
9658 return CMD_WARNING_CONFIG_FAILED
;
9663 DEFPY (show_bgp_srv6
,
9665 "show bgp segment-routing srv6",
9668 "BGP Segment Routing\n"
9669 "BGP Segment Routing SRv6\n")
9672 struct listnode
*node
;
9673 struct srv6_locator_chunk
*chunk
;
9674 struct bgp_srv6_function
*func
;
9677 bgp
= bgp_get_default();
9681 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9682 vty_out(vty
, "locator_chunks:\n");
9683 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9684 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9686 vty_out(vty
, "functions:\n");
9687 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9688 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9689 vty_out(vty
, "- sid: %s\n", buf
);
9690 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9693 vty_out(vty
, "bgps:\n");
9694 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9695 vty_out(vty
, "- name: %s\n",
9696 bgp
->name
? bgp
->name
: "default");
9698 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9699 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9700 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9701 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9707 DEFUN_NOSH (exit_address_family
,
9708 exit_address_family_cmd
,
9709 "exit-address-family",
9710 "Exit from Address Family configuration mode\n")
9712 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9713 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9714 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9715 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9716 || vty
->node
== BGP_EVPN_NODE
9717 || vty
->node
== BGP_FLOWSPECV4_NODE
9718 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9719 vty
->node
= BGP_NODE
;
9723 /* Recalculate bestpath and re-advertise a prefix */
9724 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9725 const char *ip_str
, afi_t afi
, safi_t safi
,
9726 struct prefix_rd
*prd
)
9729 struct prefix match
;
9730 struct bgp_dest
*dest
;
9731 struct bgp_dest
*rm
;
9733 struct bgp_table
*table
;
9734 struct bgp_table
*rib
;
9736 /* BGP structure lookup. */
9738 bgp
= bgp_lookup_by_name(view_name
);
9740 vty_out(vty
, "%% Can't find BGP instance %s\n",
9745 bgp
= bgp_get_default();
9747 vty_out(vty
, "%% No BGP process is configured\n");
9752 /* Check IP address argument. */
9753 ret
= str2prefix(ip_str
, &match
);
9755 vty_out(vty
, "%% address is malformed\n");
9759 match
.family
= afi2family(afi
);
9760 rib
= bgp
->rib
[afi
][safi
];
9762 if (safi
== SAFI_MPLS_VPN
) {
9763 for (dest
= bgp_table_top(rib
); dest
;
9764 dest
= bgp_route_next(dest
)) {
9765 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9767 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9770 table
= bgp_dest_get_bgp_table_info(dest
);
9774 rm
= bgp_node_match(table
, &match
);
9776 const struct prefix
*rm_p
=
9777 bgp_dest_get_prefix(rm
);
9779 if (rm_p
->prefixlen
== match
.prefixlen
) {
9781 BGP_NODE_USER_CLEAR
);
9782 bgp_process(bgp
, rm
, afi
, safi
);
9784 bgp_dest_unlock_node(rm
);
9788 dest
= bgp_node_match(rib
, &match
);
9790 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9792 if (dest_p
->prefixlen
== match
.prefixlen
) {
9793 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9794 bgp_process(bgp
, dest
, afi
, safi
);
9796 bgp_dest_unlock_node(dest
);
9803 /* one clear bgp command to rule them all */
9804 DEFUN (clear_ip_bgp_all
,
9805 clear_ip_bgp_all_cmd
,
9806 "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>]",
9810 BGP_INSTANCE_HELP_STR
9813 BGP_SAFI_WITH_LABEL_HELP_STR
9816 "BGP IPv4 neighbor to clear\n"
9817 "BGP IPv6 neighbor to clear\n"
9818 "BGP neighbor on interface to clear\n"
9819 "Clear peers with the AS number\n"
9820 "Clear all external peers\n"
9821 "Clear all members of peer-group\n"
9822 "BGP peer-group name\n"
9827 "Push out prefix-list ORF and do inbound soft reconfig\n"
9829 "Reset message statistics\n")
9833 afi_t afi
= AFI_UNSPEC
;
9834 safi_t safi
= SAFI_UNSPEC
;
9835 enum clear_sort clr_sort
= clear_peer
;
9836 enum bgp_clear_type clr_type
;
9837 char *clr_arg
= NULL
;
9841 /* clear [ip] bgp */
9842 if (argv_find(argv
, argc
, "ip", &idx
))
9845 /* [<vrf> VIEWVRFNAME] */
9846 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9847 vrf
= argv
[idx
+ 1]->arg
;
9849 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9851 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9852 /* [<view> VIEWVRFNAME] */
9853 vrf
= argv
[idx
+ 1]->arg
;
9856 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9857 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9858 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9860 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9861 if (argv_find(argv
, argc
, "*", &idx
)) {
9862 clr_sort
= clear_all
;
9863 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9864 clr_sort
= clear_peer
;
9865 clr_arg
= argv
[idx
]->arg
;
9866 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9867 clr_sort
= clear_peer
;
9868 clr_arg
= argv
[idx
]->arg
;
9869 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9870 clr_sort
= clear_group
;
9872 clr_arg
= argv
[idx
]->arg
;
9873 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9874 clr_sort
= clear_peer
;
9875 clr_arg
= argv
[idx
]->arg
;
9876 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9877 clr_sort
= clear_peer
;
9878 clr_arg
= argv
[idx
]->arg
;
9879 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9880 clr_sort
= clear_as
;
9881 clr_arg
= argv
[idx
]->arg
;
9882 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9883 clr_sort
= clear_external
;
9886 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9887 if (argv_find(argv
, argc
, "soft", &idx
)) {
9888 if (argv_find(argv
, argc
, "in", &idx
)
9889 || argv_find(argv
, argc
, "out", &idx
))
9890 clr_type
= strmatch(argv
[idx
]->text
, "in")
9892 : BGP_CLEAR_SOFT_OUT
;
9894 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9895 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9896 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9897 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9898 : BGP_CLEAR_SOFT_IN
;
9899 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9900 clr_type
= BGP_CLEAR_SOFT_OUT
;
9901 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9902 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9904 clr_type
= BGP_CLEAR_SOFT_NONE
;
9906 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9909 DEFUN (clear_ip_bgp_prefix
,
9910 clear_ip_bgp_prefix_cmd
,
9911 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9915 BGP_INSTANCE_HELP_STR
9916 "Clear bestpath and re-advertise\n"
9920 char *prefix
= NULL
;
9924 /* [<view|vrf> VIEWVRFNAME] */
9925 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9926 vrf
= argv
[idx
+ 1]->arg
;
9928 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9930 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9931 /* [<view> VIEWVRFNAME] */
9932 vrf
= argv
[idx
+ 1]->arg
;
9936 prefix
= argv
[argc
- 1]->arg
;
9938 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9941 DEFUN (clear_bgp_ipv6_safi_prefix
,
9942 clear_bgp_ipv6_safi_prefix_cmd
,
9943 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9949 "Clear bestpath and re-advertise\n"
9953 int idx_ipv6_prefix
= 0;
9954 safi_t safi
= SAFI_UNICAST
;
9955 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9956 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9958 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9959 return bgp_clear_prefix(
9960 vty
, NULL
, prefix
, AFI_IP6
,
9964 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9965 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9966 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9970 BGP_INSTANCE_HELP_STR
9973 "Clear bestpath and re-advertise\n"
9977 int idx_vrfview
= 0;
9978 int idx_ipv6_prefix
= 0;
9979 safi_t safi
= SAFI_UNICAST
;
9980 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9981 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9982 char *vrfview
= NULL
;
9984 /* [<view|vrf> VIEWVRFNAME] */
9985 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9986 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9987 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9989 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9990 /* [<view> VIEWVRFNAME] */
9991 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9993 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9995 return bgp_clear_prefix(
9996 vty
, vrfview
, prefix
,
9997 AFI_IP6
, safi
, NULL
);
10000 DEFUN (show_bgp_views
,
10001 show_bgp_views_cmd
,
10002 "show [ip] bgp views",
10006 "Show the defined BGP views\n")
10008 struct list
*inst
= bm
->bgp
;
10009 struct listnode
*node
;
10012 vty_out(vty
, "Defined BGP views:\n");
10013 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10015 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10017 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10021 return CMD_SUCCESS
;
10024 DEFUN (show_bgp_vrfs
,
10026 "show [ip] bgp vrfs [json]",
10033 char buf
[ETHER_ADDR_STRLEN
];
10034 struct list
*inst
= bm
->bgp
;
10035 struct listnode
*node
;
10037 bool uj
= use_json(argc
, argv
);
10038 json_object
*json
= NULL
;
10039 json_object
*json_vrfs
= NULL
;
10043 json
= json_object_new_object();
10044 json_vrfs
= json_object_new_object();
10047 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10048 const char *name
, *type
;
10050 struct listnode
*node2
, *nnode2
;
10051 int peers_cfg
, peers_estb
;
10052 json_object
*json_vrf
= NULL
;
10055 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10059 if (!uj
&& count
== 1) {
10061 "%4s %-5s %-16s %9s %10s %-37s\n",
10062 "Type", "Id", "routerId", "#PeersCfg",
10063 "#PeersEstb", "Name");
10064 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10065 "L3-VNI", "RouterMAC", "Interface");
10068 peers_cfg
= peers_estb
= 0;
10070 json_vrf
= json_object_new_object();
10073 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10074 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10077 if (peer_established(peer
))
10081 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10082 name
= VRF_DEFAULT_NAME
;
10091 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10093 : (int64_t)bgp
->vrf_id
;
10094 char buf
[BUFSIZ
] = {0};
10096 json_object_string_add(json_vrf
, "type", type
);
10097 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10098 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10100 json_object_int_add(json_vrf
, "numConfiguredPeers",
10102 json_object_int_add(json_vrf
, "numEstablishedPeers",
10105 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10106 json_object_string_add(
10108 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10109 json_object_string_add(json_vrf
, "interface",
10110 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10112 json_object_object_add(json_vrfs
, name
, json_vrf
);
10114 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10116 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10117 : (int)bgp
->vrf_id
,
10118 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10119 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10121 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10122 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10128 json_object_object_add(json
, "vrfs", json_vrfs
);
10130 json_object_int_add(json
, "totalVrfs", count
);
10132 vty_json(vty
, json
);
10136 "\nTotal number of VRFs (including default): %d\n",
10140 return CMD_SUCCESS
;
10143 DEFUN (show_bgp_mac_hash
,
10144 show_bgp_mac_hash_cmd
,
10145 "show bgp mac hash",
10149 "Mac Address database\n")
10151 bgp_mac_dump_table(vty
);
10153 return CMD_SUCCESS
;
10156 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10158 struct vty
*vty
= (struct vty
*)args
;
10159 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10161 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10164 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10166 vty_out(vty
, "self nexthop database:\n");
10167 bgp_nexthop_show_address_hash(vty
, bgp
);
10169 vty_out(vty
, "Tunnel-ip database:\n");
10170 hash_iterate(bgp
->tip_hash
,
10171 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10175 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10176 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10177 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10178 "martian next-hops\n"
10179 "martian next-hop database\n")
10181 struct bgp
*bgp
= NULL
;
10185 /* [<vrf> VIEWVRFNAME] */
10186 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10187 name
= argv
[idx
+ 1]->arg
;
10188 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10190 } else if (argv_find(argv
, argc
, "view", &idx
))
10191 /* [<view> VIEWVRFNAME] */
10192 name
= argv
[idx
+ 1]->arg
;
10194 bgp
= bgp_lookup_by_name(name
);
10196 bgp
= bgp_get_default();
10199 vty_out(vty
, "%% No BGP process is configured\n");
10200 return CMD_WARNING
;
10202 bgp_show_martian_nexthops(vty
, bgp
);
10204 return CMD_SUCCESS
;
10207 DEFUN (show_bgp_memory
,
10208 show_bgp_memory_cmd
,
10209 "show [ip] bgp memory",
10213 "Global BGP memory statistics\n")
10215 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10216 unsigned long count
;
10218 /* RIB related usage stats */
10219 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10220 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10221 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10222 count
* sizeof(struct bgp_dest
)));
10224 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10225 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10226 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10227 count
* sizeof(struct bgp_path_info
)));
10228 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10229 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10232 memstrbuf
, sizeof(memstrbuf
),
10233 count
* sizeof(struct bgp_path_info_extra
)));
10235 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10236 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10237 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10238 count
* sizeof(struct bgp_static
)));
10240 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10241 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10242 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10243 count
* sizeof(struct bpacket
)));
10246 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10247 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10248 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10249 count
* sizeof(struct bgp_adj_in
)));
10250 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10251 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10252 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10253 count
* sizeof(struct bgp_adj_out
)));
10255 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10256 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10258 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10259 count
* sizeof(struct bgp_nexthop_cache
)));
10261 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10262 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10264 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10265 count
* sizeof(struct bgp_damp_info
)));
10268 count
= attr_count();
10269 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10270 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10271 count
* sizeof(struct attr
)));
10273 if ((count
= attr_unknown_count()))
10274 vty_out(vty
, "%ld unknown attributes\n", count
);
10276 /* AS_PATH attributes */
10277 count
= aspath_count();
10278 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10279 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10280 count
* sizeof(struct aspath
)));
10282 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10283 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10284 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10285 count
* sizeof(struct assegment
)));
10287 /* Other attributes */
10288 if ((count
= community_count()))
10289 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10290 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10291 count
* sizeof(struct community
)));
10292 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10294 "%ld BGP ext-community entries, using %s of memory\n",
10296 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10297 count
* sizeof(struct ecommunity
)));
10298 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10300 "%ld BGP large-community entries, using %s of memory\n",
10301 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10302 count
* sizeof(struct lcommunity
)));
10304 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10305 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10306 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10307 count
* sizeof(struct cluster_list
)));
10309 /* Peer related usage */
10310 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10311 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10312 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10313 count
* sizeof(struct peer
)));
10315 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10316 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10317 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10318 count
* sizeof(struct peer_group
)));
10321 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10322 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10323 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10324 count
* sizeof(regex_t
)));
10325 return CMD_SUCCESS
;
10328 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10330 json_object
*bestpath
= json_object_new_object();
10332 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10333 json_object_string_add(bestpath
, "asPath", "ignore");
10335 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10336 json_object_string_add(bestpath
, "asPath", "confed");
10338 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10339 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10340 json_object_string_add(bestpath
, "multiPathRelax",
10343 json_object_string_add(bestpath
, "multiPathRelax",
10346 json_object_string_add(bestpath
, "multiPathRelax", "false");
10348 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10349 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10351 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10352 json_object_string_add(bestpath
, "compareRouterId", "true");
10353 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10354 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10355 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10356 json_object_string_add(bestpath
, "med", "confed");
10357 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10358 json_object_string_add(bestpath
, "med",
10359 "missing-as-worst");
10361 json_object_string_add(bestpath
, "med", "true");
10364 json_object_object_add(json
, "bestPath", bestpath
);
10367 /* Print the error code/subcode for why the peer is down */
10368 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10369 json_object
*json_peer
, bool use_json
)
10371 const char *code_str
;
10372 const char *subcode_str
;
10375 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10376 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10377 char errorcodesubcode_hexstr
[5];
10378 char errorcodesubcode_str
[256];
10380 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10381 subcode_str
= bgp_notify_subcode_str(
10383 peer
->notify
.subcode
);
10385 snprintf(errorcodesubcode_hexstr
,
10386 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10387 peer
->notify
.code
, peer
->notify
.subcode
);
10388 json_object_string_add(json_peer
,
10389 "lastErrorCodeSubcode",
10390 errorcodesubcode_hexstr
);
10391 snprintf(errorcodesubcode_str
, 255, "%s%s",
10392 code_str
, subcode_str
);
10393 json_object_string_add(json_peer
,
10394 "lastNotificationReason",
10395 errorcodesubcode_str
);
10396 json_object_boolean_add(json_peer
,
10397 "lastNotificationHardReset",
10398 peer
->notify
.hard_reset
);
10399 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10400 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10401 && (peer
->notify
.subcode
10402 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10403 || peer
->notify
.subcode
10404 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10405 && peer
->notify
.length
) {
10407 const char *msg_str
;
10409 msg_str
= bgp_notify_admin_message(
10410 msgbuf
, sizeof(msgbuf
),
10411 (uint8_t *)peer
->notify
.data
,
10412 peer
->notify
.length
);
10414 json_object_string_add(
10416 "lastShutdownDescription",
10421 json_object_string_add(json_peer
, "lastResetDueTo",
10422 peer_down_str
[(int)peer
->last_reset
]);
10423 json_object_int_add(json_peer
, "lastResetCode",
10426 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10427 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10428 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10430 bgp_notify_subcode_str(peer
->notify
.code
,
10431 peer
->notify
.subcode
);
10432 vty_out(vty
, " Notification %s (%s%s%s)\n",
10433 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10436 code_str
, subcode_str
,
10437 peer
->notify
.hard_reset
10438 ? bgp_notify_subcode_str(
10440 BGP_NOTIFY_CEASE_HARD_RESET
)
10443 vty_out(vty
, " %s\n",
10444 peer_down_str
[(int)peer
->last_reset
]);
10449 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10452 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10455 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10456 struct peer
*peer
, json_object
*json_peer
,
10457 int max_neighbor_width
, bool use_json
)
10459 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10463 if (peer_dynamic_neighbor(peer
))
10464 json_object_boolean_true_add(json_peer
,
10466 if (peer
->hostname
)
10467 json_object_string_add(json_peer
, "hostname",
10470 if (peer
->domainname
)
10471 json_object_string_add(json_peer
, "domainname",
10473 json_object_int_add(json_peer
, "connectionsEstablished",
10474 peer
->established
);
10475 json_object_int_add(json_peer
, "connectionsDropped",
10477 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10478 use_json
, json_peer
);
10479 if (peer_established(peer
))
10480 json_object_string_add(json_peer
, "lastResetDueTo",
10481 "AFI/SAFI Not Negotiated");
10483 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10486 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10488 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10489 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10490 peer
->hostname
, peer
->host
);
10492 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10494 /* pad the neighbor column with spaces */
10495 if (len
< max_neighbor_width
)
10496 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10498 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10500 peer_uptime(peer
->uptime
, timebuf
,
10501 BGP_UPTIME_LEN
, 0, NULL
));
10502 if (peer_established(peer
))
10503 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10505 bgp_show_peer_reset(vty
, peer
, NULL
,
10510 /* Strip peer's description to the given size. */
10511 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10513 static char stripped
[BUFSIZ
];
10515 uint32_t last_space
= 0;
10518 if (*(desc
+ i
) == 0) {
10519 stripped
[i
] = '\0';
10522 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10524 stripped
[i
] = *(desc
+ i
);
10528 if (last_space
> size
)
10529 stripped
[size
+ 1] = '\0';
10531 stripped
[last_space
] = '\0';
10536 /* Determine whether var peer should be filtered out of the summary. */
10537 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10538 struct peer
*fpeer
, int as_type
,
10542 /* filter neighbor XXXX */
10543 if (fpeer
&& fpeer
!= peer
)
10546 /* filter remote-as (internal|external) */
10547 if (as_type
!= AS_UNSPECIFIED
) {
10548 if (peer
->as_type
== AS_SPECIFIED
) {
10549 if (as_type
== AS_INTERNAL
) {
10550 if (peer
->as
!= peer
->local_as
)
10552 } else if (peer
->as
== peer
->local_as
)
10554 } else if (as_type
!= peer
->as_type
)
10556 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10562 /* Show BGP peer's summary information.
10564 * Peer's description is stripped according to if `wide` option is given
10567 * When adding new columns to `show bgp summary` output, please make
10568 * sure `Desc` is the lastest column to show because it can contain
10569 * whitespaces and the whole output will be tricky.
10571 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10572 struct peer
*fpeer
, int as_type
, as_t as
,
10573 uint16_t show_flags
)
10576 struct listnode
*node
, *nnode
;
10577 unsigned int count
= 0, dn_count
= 0;
10578 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10579 char neighbor_buf
[VTY_BUFSIZ
];
10580 int neighbor_col_default_width
= 16;
10581 int len
, failed_count
= 0;
10582 unsigned int filtered_count
= 0;
10583 int max_neighbor_width
= 0;
10585 json_object
*json
= NULL
;
10586 json_object
*json_peer
= NULL
;
10587 json_object
*json_peers
= NULL
;
10588 struct peer_af
*paf
;
10589 struct bgp_filter
*filter
;
10590 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10591 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10592 bool show_established
=
10593 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10594 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10595 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10597 /* labeled-unicast routes are installed in the unicast table so in order
10599 * display the correct PfxRcd value we must look at SAFI_UNICAST
10602 if (safi
== SAFI_LABELED_UNICAST
)
10603 pfx_rcd_safi
= SAFI_UNICAST
;
10605 pfx_rcd_safi
= safi
;
10608 json
= json_object_new_object();
10609 json_peers
= json_object_new_object();
10610 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10611 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10618 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10621 if (peer
->afc
[afi
][safi
]) {
10622 /* See if we have at least a single failed peer */
10623 if (bgp_has_peer_failed(peer
, afi
, safi
))
10627 if (peer_dynamic_neighbor(peer
))
10632 /* Loop over all neighbors that will be displayed to determine
10634 * characters are needed for the Neighbor column
10636 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10637 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10644 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10647 if (peer
->afc
[afi
][safi
]) {
10648 memset(dn_flag
, '\0', sizeof(dn_flag
));
10649 if (peer_dynamic_neighbor(peer
))
10653 && CHECK_FLAG(bgp
->flags
,
10654 BGP_FLAG_SHOW_HOSTNAME
))
10655 snprintf(neighbor_buf
,
10656 sizeof(neighbor_buf
),
10657 "%s%s(%s) ", dn_flag
,
10658 peer
->hostname
, peer
->host
);
10660 snprintf(neighbor_buf
,
10661 sizeof(neighbor_buf
), "%s%s ",
10662 dn_flag
, peer
->host
);
10664 len
= strlen(neighbor_buf
);
10666 if (len
> max_neighbor_width
)
10667 max_neighbor_width
= len
;
10669 /* See if we have at least a single failed peer */
10670 if (bgp_has_peer_failed(peer
, afi
, safi
))
10676 /* Originally we displayed the Neighbor column as 16
10677 * characters wide so make that the default
10679 if (max_neighbor_width
< neighbor_col_default_width
)
10680 max_neighbor_width
= neighbor_col_default_width
;
10683 if (show_failed
&& !failed_count
) {
10685 json_object_int_add(json
, "failedPeersCount", 0);
10686 json_object_int_add(json
, "dynamicPeers", dn_count
);
10687 json_object_int_add(json
, "totalPeers", count
);
10689 vty_json(vty
, json
);
10691 vty_out(vty
, "%% No failed BGP neighbors found\n");
10693 return CMD_SUCCESS
;
10696 count
= 0; /* Reset the value as its used again */
10697 filtered_count
= 0;
10699 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10700 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10703 if (!peer
->afc
[afi
][safi
])
10707 unsigned long ents
;
10708 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10711 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10713 : (int64_t)bgp
->vrf_id
;
10715 /* Usage summary and header */
10717 json_object_string_addf(json
, "routerId",
10720 json_object_int_add(json
, "as", bgp
->as
);
10721 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10722 json_object_string_add(
10725 == BGP_INSTANCE_TYPE_DEFAULT
)
10730 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10731 &bgp
->router_id
, bgp
->as
,
10732 bgp
->vrf_id
== VRF_UNKNOWN
10734 : (int)bgp
->vrf_id
);
10735 vty_out(vty
, "\n");
10738 if (bgp_update_delay_configured(bgp
)) {
10740 json_object_int_add(
10741 json
, "updateDelayLimit",
10742 bgp
->v_update_delay
);
10744 if (bgp
->v_update_delay
10745 != bgp
->v_establish_wait
)
10746 json_object_int_add(
10748 "updateDelayEstablishWait",
10749 bgp
->v_establish_wait
);
10751 if (bgp_update_delay_active(bgp
)) {
10752 json_object_string_add(
10754 "updateDelayFirstNeighbor",
10755 bgp
->update_delay_begin_time
);
10756 json_object_boolean_true_add(
10758 "updateDelayInProgress");
10760 if (bgp
->update_delay_over
) {
10761 json_object_string_add(
10763 "updateDelayFirstNeighbor",
10764 bgp
->update_delay_begin_time
);
10765 json_object_string_add(
10767 "updateDelayBestpathResumed",
10768 bgp
->update_delay_end_time
);
10769 json_object_string_add(
10771 "updateDelayZebraUpdateResume",
10772 bgp
->update_delay_zebra_resume_time
);
10773 json_object_string_add(
10775 "updateDelayPeerUpdateResume",
10776 bgp
->update_delay_peers_resume_time
);
10781 "Read-only mode update-delay limit: %d seconds\n",
10782 bgp
->v_update_delay
);
10783 if (bgp
->v_update_delay
10784 != bgp
->v_establish_wait
)
10786 " Establish wait: %d seconds\n",
10787 bgp
->v_establish_wait
);
10789 if (bgp_update_delay_active(bgp
)) {
10791 " First neighbor established: %s\n",
10792 bgp
->update_delay_begin_time
);
10794 " Delay in progress\n");
10796 if (bgp
->update_delay_over
) {
10798 " First neighbor established: %s\n",
10799 bgp
->update_delay_begin_time
);
10801 " Best-paths resumed: %s\n",
10802 bgp
->update_delay_end_time
);
10804 " zebra update resumed: %s\n",
10805 bgp
->update_delay_zebra_resume_time
);
10807 " peers update resumed: %s\n",
10808 bgp
->update_delay_peers_resume_time
);
10815 if (bgp_maxmed_onstartup_configured(bgp
)
10816 && bgp
->maxmed_active
)
10817 json_object_boolean_true_add(
10818 json
, "maxMedOnStartup");
10819 if (bgp
->v_maxmed_admin
)
10820 json_object_boolean_true_add(
10821 json
, "maxMedAdministrative");
10823 json_object_int_add(
10824 json
, "tableVersion",
10825 bgp_table_version(bgp
->rib
[afi
][safi
]));
10827 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10828 json_object_int_add(json
, "ribCount", ents
);
10829 json_object_int_add(
10831 ents
* sizeof(struct bgp_dest
));
10833 ents
= bgp
->af_peer_count
[afi
][safi
];
10834 json_object_int_add(json
, "peerCount", ents
);
10835 json_object_int_add(json
, "peerMemory",
10836 ents
* sizeof(struct peer
));
10838 if ((ents
= listcount(bgp
->group
))) {
10839 json_object_int_add(
10840 json
, "peerGroupCount", ents
);
10841 json_object_int_add(
10842 json
, "peerGroupMemory",
10843 ents
* sizeof(struct
10847 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10848 BGP_CONFIG_DAMPENING
))
10849 json_object_boolean_true_add(
10850 json
, "dampeningEnabled");
10853 if (bgp_maxmed_onstartup_configured(bgp
)
10854 && bgp
->maxmed_active
)
10856 "Max-med on-startup active\n");
10857 if (bgp
->v_maxmed_admin
)
10859 "Max-med administrative active\n");
10862 "BGP table version %" PRIu64
10865 bgp
->rib
[afi
][safi
]));
10867 ents
= bgp_table_count(
10868 bgp
->rib
[afi
][safi
]);
10870 "RIB entries %ld, using %s of memory\n",
10880 /* Peer related usage */
10881 ents
= bgp
->af_peer_count
[afi
][safi
];
10883 "Peers %ld, using %s of memory\n",
10893 if ((ents
= listcount(bgp
->group
)))
10895 "Peer groups %ld, using %s of memory\n",
10905 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10906 BGP_CONFIG_DAMPENING
))
10908 "Dampening enabled.\n");
10911 vty_out(vty
, "\n");
10913 /* Subtract 8 here because 'Neighbor' is
10915 vty_out(vty
, "Neighbor");
10916 vty_out(vty
, "%*s",
10917 max_neighbor_width
- 8, " ");
10919 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10924 paf
= peer_af_find(peer
, afi
, safi
);
10925 filter
= &peer
->filter
[afi
][safi
];
10928 /* Works for both failed & successful cases */
10929 if (peer_dynamic_neighbor(peer
))
10934 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10940 bgp_has_peer_failed(peer
, afi
, safi
)) {
10941 json_peer
= json_object_new_object();
10942 bgp_show_failed_summary(vty
, bgp
, peer
,
10943 json_peer
, 0, use_json
);
10944 } else if (!show_failed
) {
10945 if (show_established
10946 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10951 json_peer
= json_object_new_object();
10952 if (peer_dynamic_neighbor(peer
)) {
10953 json_object_boolean_true_add(json_peer
,
10957 if (peer
->hostname
)
10958 json_object_string_add(json_peer
, "hostname",
10961 if (peer
->domainname
)
10962 json_object_string_add(json_peer
, "domainname",
10965 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10966 json_object_int_add(
10967 json_peer
, "localAs",
10968 peer
->change_local_as
10969 ? peer
->change_local_as
10971 json_object_int_add(json_peer
, "version", 4);
10972 json_object_int_add(json_peer
, "msgRcvd",
10973 PEER_TOTAL_RX(peer
));
10974 json_object_int_add(json_peer
, "msgSent",
10975 PEER_TOTAL_TX(peer
));
10977 atomic_size_t outq_count
, inq_count
;
10978 outq_count
= atomic_load_explicit(
10979 &peer
->obuf
->count
,
10980 memory_order_relaxed
);
10981 inq_count
= atomic_load_explicit(
10982 &peer
->ibuf
->count
,
10983 memory_order_relaxed
);
10985 json_object_int_add(json_peer
, "tableVersion",
10986 peer
->version
[afi
][safi
]);
10987 json_object_int_add(json_peer
, "outq",
10989 json_object_int_add(json_peer
, "inq",
10991 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10992 use_json
, json_peer
);
10994 json_object_int_add(json_peer
, "pfxRcd",
10995 peer
->pcount
[afi
][pfx_rcd_safi
]);
10997 if (paf
&& PAF_SUBGRP(paf
))
10998 json_object_int_add(
10999 json_peer
, "pfxSnt",
11000 (PAF_SUBGRP(paf
))->scount
);
11002 json_object_int_add(json_peer
, "pfxSnt",
11005 /* BGP FSM state */
11006 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11007 || CHECK_FLAG(peer
->bgp
->flags
,
11008 BGP_FLAG_SHUTDOWN
))
11009 json_object_string_add(json_peer
,
11012 else if (peer
->afc_recv
[afi
][safi
])
11013 json_object_string_add(
11014 json_peer
, "state",
11015 lookup_msg(bgp_status_msg
,
11016 peer
->status
, NULL
));
11017 else if (CHECK_FLAG(
11019 PEER_STATUS_PREFIX_OVERFLOW
))
11020 json_object_string_add(json_peer
,
11024 json_object_string_add(
11025 json_peer
, "state",
11026 lookup_msg(bgp_status_msg
,
11027 peer
->status
, NULL
));
11029 /* BGP peer state */
11030 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11031 || CHECK_FLAG(peer
->bgp
->flags
,
11032 BGP_FLAG_SHUTDOWN
))
11033 json_object_string_add(json_peer
,
11036 else if (CHECK_FLAG(
11038 PEER_STATUS_PREFIX_OVERFLOW
))
11039 json_object_string_add(json_peer
,
11042 else if (CHECK_FLAG(peer
->flags
,
11043 PEER_FLAG_PASSIVE
))
11044 json_object_string_add(json_peer
,
11047 else if (CHECK_FLAG(peer
->sflags
,
11048 PEER_STATUS_NSF_WAIT
))
11049 json_object_string_add(json_peer
,
11052 else if (CHECK_FLAG(
11054 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11055 && (!bgp_inbound_policy_exists(peer
,
11057 || !bgp_outbound_policy_exists(
11059 json_object_string_add(json_peer
,
11063 json_object_string_add(
11064 json_peer
, "peerState", "OK");
11066 json_object_int_add(json_peer
, "connectionsEstablished",
11067 peer
->established
);
11068 json_object_int_add(json_peer
, "connectionsDropped",
11071 json_object_string_add(
11072 json_peer
, "desc", peer
->desc
);
11074 /* Avoid creating empty peer dicts in JSON */
11075 if (json_peer
== NULL
)
11079 json_object_string_add(json_peer
, "idType",
11081 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11082 json_object_string_add(json_peer
, "idType",
11084 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11085 json_object_string_add(json_peer
, "idType",
11087 json_object_object_add(json_peers
, peer
->host
,
11090 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11096 bgp_has_peer_failed(peer
, afi
, safi
)) {
11097 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11098 max_neighbor_width
,
11100 } else if (!show_failed
) {
11101 if (show_established
11102 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11107 if ((count
- filtered_count
) == 1) {
11108 /* display headline before the first
11110 vty_out(vty
, "\n");
11112 /* Subtract 8 here because 'Neighbor' is
11114 vty_out(vty
, "Neighbor");
11115 vty_out(vty
, "%*s",
11116 max_neighbor_width
- 8, " ");
11119 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11120 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11123 memset(dn_flag
, '\0', sizeof(dn_flag
));
11124 if (peer_dynamic_neighbor(peer
)) {
11129 && CHECK_FLAG(bgp
->flags
,
11130 BGP_FLAG_SHOW_HOSTNAME
))
11131 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11135 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11137 /* pad the neighbor column with spaces */
11138 if (len
< max_neighbor_width
)
11139 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11142 atomic_size_t outq_count
, inq_count
;
11143 outq_count
= atomic_load_explicit(
11144 &peer
->obuf
->count
,
11145 memory_order_relaxed
);
11146 inq_count
= atomic_load_explicit(
11147 &peer
->ibuf
->count
,
11148 memory_order_relaxed
);
11152 "4 %10u %10u %9u %9u %8" PRIu64
11155 peer
->change_local_as
11156 ? peer
->change_local_as
11158 PEER_TOTAL_RX(peer
),
11159 PEER_TOTAL_TX(peer
),
11160 peer
->version
[afi
][safi
],
11161 inq_count
, outq_count
,
11162 peer_uptime(peer
->uptime
,
11167 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11169 peer
->as
, PEER_TOTAL_RX(peer
),
11170 PEER_TOTAL_TX(peer
),
11171 peer
->version
[afi
][safi
],
11172 inq_count
, outq_count
,
11173 peer_uptime(peer
->uptime
,
11178 if (peer_established(peer
)) {
11179 if (peer
->afc_recv
[afi
][safi
]) {
11182 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11183 && !bgp_inbound_policy_exists(
11185 vty_out(vty
, " %12s",
11194 vty_out(vty
, " NoNeg");
11197 if (paf
&& PAF_SUBGRP(paf
)) {
11200 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11201 && !bgp_outbound_policy_exists(
11203 vty_out(vty
, " %8s",
11212 vty_out(vty
, " NoNeg");
11215 if (CHECK_FLAG(peer
->flags
,
11216 PEER_FLAG_SHUTDOWN
)
11217 || CHECK_FLAG(peer
->bgp
->flags
,
11218 BGP_FLAG_SHUTDOWN
))
11219 vty_out(vty
, " Idle (Admin)");
11220 else if (CHECK_FLAG(
11222 PEER_STATUS_PREFIX_OVERFLOW
))
11223 vty_out(vty
, " Idle (PfxCt)");
11225 vty_out(vty
, " %12s",
11226 lookup_msg(bgp_status_msg
,
11227 peer
->status
, NULL
));
11229 vty_out(vty
, " %8u", 0);
11231 /* Make sure `Desc` column is the lastest in
11235 vty_out(vty
, " %s",
11236 bgp_peer_description_stripped(
11238 show_wide
? 64 : 20));
11240 vty_out(vty
, " N/A");
11241 vty_out(vty
, "\n");
11248 json_object_object_add(json
, "peers", json_peers
);
11249 json_object_int_add(json
, "failedPeers", failed_count
);
11250 json_object_int_add(json
, "displayedPeers",
11251 count
- filtered_count
);
11252 json_object_int_add(json
, "totalPeers", count
);
11253 json_object_int_add(json
, "dynamicPeers", dn_count
);
11256 bgp_show_bestpath_json(bgp
, json
);
11258 vty_json(vty
, json
);
11261 if (filtered_count
== count
)
11262 vty_out(vty
, "\n%% No matching neighbor\n");
11265 vty_out(vty
, "\nDisplayed neighbors %d",
11267 else if (as_type
!= AS_UNSPECIFIED
|| as
11268 || fpeer
|| show_established
)
11269 vty_out(vty
, "\nDisplayed neighbors %d",
11270 count
- filtered_count
);
11272 vty_out(vty
, "\nTotal number of neighbors %d\n",
11276 vty_out(vty
, "No %s neighbor is configured\n",
11277 get_afi_safi_str(afi
, safi
, false));
11281 vty_out(vty
, "* - dynamic neighbor\n");
11282 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11283 dn_count
, bgp
->dynamic_neighbors_limit
);
11287 return CMD_SUCCESS
;
11290 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11291 int safi
, struct peer
*fpeer
, int as_type
,
11292 as_t as
, uint16_t show_flags
)
11295 int afi_wildcard
= (afi
== AFI_MAX
);
11296 int safi_wildcard
= (safi
== SAFI_MAX
);
11297 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11298 bool nbr_output
= false;
11299 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11301 if (use_json
&& is_wildcard
)
11302 vty_out(vty
, "{\n");
11304 afi
= 1; /* AFI_IP */
11305 while (afi
< AFI_MAX
) {
11307 safi
= 1; /* SAFI_UNICAST */
11308 while (safi
< SAFI_MAX
) {
11309 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11314 * So limit output to those afi/safi
11316 * actualy have something interesting in
11321 vty_out(vty
, ",\n");
11325 vty_out(vty
, "\"%s\":",
11326 get_afi_safi_str(afi
,
11331 "\n%s Summary (%s):\n",
11332 get_afi_safi_str(afi
,
11338 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11339 as_type
, as
, show_flags
);
11342 if (!safi_wildcard
)
11350 if (use_json
&& is_wildcard
)
11351 vty_out(vty
, "}\n");
11352 else if (!nbr_output
) {
11354 vty_out(vty
, "{}\n");
11356 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11361 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11363 const char *neighbor
,
11364 int as_type
, as_t as
,
11365 uint16_t show_flags
)
11367 struct listnode
*node
, *nnode
;
11369 struct peer
*fpeer
= NULL
;
11371 bool nbr_output
= false;
11372 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11375 vty_out(vty
, "{\n");
11377 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11381 vty_out(vty
, ",\n");
11385 vty_out(vty
, "\"%s\":",
11386 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11391 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11396 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11401 vty_out(vty
, "}\n");
11402 else if (!nbr_output
)
11403 vty_out(vty
, "%% BGP instance not found\n");
11406 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11407 safi_t safi
, const char *neighbor
, int as_type
,
11408 as_t as
, uint16_t show_flags
)
11411 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11412 struct peer
*fpeer
= NULL
;
11415 if (strmatch(name
, "all")) {
11416 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11419 return CMD_SUCCESS
;
11421 bgp
= bgp_lookup_by_name(name
);
11425 vty_out(vty
, "{}\n");
11428 "%% BGP instance not found\n");
11429 return CMD_WARNING
;
11433 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11436 return CMD_WARNING
;
11438 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11439 as_type
, as
, show_flags
);
11440 return CMD_SUCCESS
;
11444 bgp
= bgp_get_default();
11448 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11451 return CMD_WARNING
;
11453 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11457 vty_out(vty
, "{}\n");
11459 vty_out(vty
, "%% BGP instance not found\n");
11460 return CMD_WARNING
;
11463 return CMD_SUCCESS
;
11466 /* `show [ip] bgp summary' commands. */
11467 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11468 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11469 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11470 "]] [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]",
11471 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11472 BGP_SAFI_WITH_LABEL_HELP_STR
11473 "Display the entries for all address families\n"
11474 "Summary of BGP neighbor status\n"
11475 "Show only sessions in Established state\n"
11476 "Show only sessions not in Established state\n"
11477 "Show only the specified neighbor session\n"
11478 "Neighbor to display information about\n"
11479 "Neighbor to display information about\n"
11480 "Neighbor on BGP configured interface\n"
11481 "Show only the specified remote AS sessions\n"
11483 "Internal (iBGP) AS sessions\n"
11484 "External (eBGP) AS sessions\n"
11485 "Shorten the information on BGP instances\n"
11486 "Increase table width for longer output\n" JSON_STR
)
11489 afi_t afi
= AFI_MAX
;
11490 safi_t safi
= SAFI_MAX
;
11491 as_t as
= 0; /* 0 means AS filter not set */
11492 int as_type
= AS_UNSPECIFIED
;
11493 uint16_t show_flags
= 0;
11497 /* show [ip] bgp */
11498 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11500 /* [<vrf> VIEWVRFNAME] */
11501 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11502 vrf
= argv
[idx
+ 1]->arg
;
11503 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11505 } else if (argv_find(argv
, argc
, "view", &idx
))
11506 /* [<view> VIEWVRFNAME] */
11507 vrf
= argv
[idx
+ 1]->arg
;
11508 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11509 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11510 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11513 if (argv_find(argv
, argc
, "failed", &idx
))
11514 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11516 if (argv_find(argv
, argc
, "established", &idx
))
11517 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11519 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11520 if (argv
[idx
+ 1]->arg
[0] == 'i')
11521 as_type
= AS_INTERNAL
;
11522 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11523 as_type
= AS_EXTERNAL
;
11525 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11528 if (argv_find(argv
, argc
, "terse", &idx
))
11529 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11531 if (argv_find(argv
, argc
, "wide", &idx
))
11532 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11534 if (argv_find(argv
, argc
, "json", &idx
))
11535 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11537 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11541 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11544 return get_afi_safi_json_str(afi
, safi
);
11546 return get_afi_safi_vty_str(afi
, safi
);
11550 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11551 afi_t afi
, safi_t safi
,
11552 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11553 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11554 bool use_json
, json_object
*json_pref
)
11557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11558 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11560 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11561 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11562 json_object_string_add(json_pref
, "sendMode",
11563 "advertisedAndReceived");
11564 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11565 json_object_string_add(json_pref
, "sendMode",
11567 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11568 json_object_string_add(json_pref
, "sendMode",
11571 vty_out(vty
, " Send-mode: ");
11572 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11573 vty_out(vty
, "advertised");
11574 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11575 vty_out(vty
, "%sreceived",
11576 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11580 vty_out(vty
, "\n");
11585 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11586 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11588 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11589 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11590 json_object_string_add(json_pref
, "recvMode",
11591 "advertisedAndReceived");
11592 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11593 json_object_string_add(json_pref
, "recvMode",
11595 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11596 json_object_string_add(json_pref
, "recvMode",
11599 vty_out(vty
, " Receive-mode: ");
11600 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11601 vty_out(vty
, "advertised");
11602 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11603 vty_out(vty
, "%sreceived",
11604 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11608 vty_out(vty
, "\n");
11613 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11621 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11622 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11623 && (peer_established(p
))) {
11624 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11625 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11629 json_object_boolean_add(json
, "rBit", rbit
);
11630 json_object_boolean_add(json
, "nBit", nbit
);
11632 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11633 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11637 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11642 const char *mode
= "NotApplicable";
11645 vty_out(vty
, "\n Remote GR Mode: ");
11647 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11648 && (peer_established(peer
))) {
11650 if ((peer
->nsf_af_count
== 0)
11651 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11655 } else if (peer
->nsf_af_count
== 0
11656 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11660 } else if (peer
->nsf_af_count
!= 0
11661 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11668 json_object_string_add(json
, "remoteGrMode", mode
);
11670 vty_out(vty
, mode
, "\n");
11673 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11678 const char *mode
= "Invalid";
11681 vty_out(vty
, " Local GR Mode: ");
11683 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11685 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11687 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11689 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11690 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11692 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11694 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11701 json_object_string_add(json
, "localGrMode", mode
);
11703 vty_out(vty
, mode
, "\n");
11707 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11708 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11712 json_object
*json_afi_safi
= NULL
;
11713 json_object
*json_timer
= NULL
;
11714 json_object
*json_endofrib_status
= NULL
;
11715 bool eor_flag
= false;
11717 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11718 if (!peer
->afc
[afi
][safi
])
11721 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11722 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11726 json_afi_safi
= json_object_new_object();
11727 json_endofrib_status
= json_object_new_object();
11728 json_timer
= json_object_new_object();
11731 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11737 vty_out(vty
, " %s:\n",
11738 get_afi_safi_str(afi
, safi
, false));
11740 vty_out(vty
, " F bit: ");
11743 if (peer
->nsf
[afi
][safi
] &&
11744 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11745 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11748 json_object_boolean_true_add(json_afi_safi
,
11751 vty_out(vty
, "True\n");
11754 json_object_boolean_false_add(json_afi_safi
,
11757 vty_out(vty
, "False\n");
11761 vty_out(vty
, " End-of-RIB sent: ");
11763 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11764 PEER_STATUS_EOR_SEND
)) {
11766 json_object_boolean_true_add(
11767 json_endofrib_status
, "endOfRibSend");
11769 PRINT_EOR_JSON(eor_flag
);
11771 vty_out(vty
, "Yes\n");
11773 " End-of-RIB sent after update: ");
11775 PRINT_EOR(eor_flag
);
11779 json_object_boolean_false_add(
11780 json_endofrib_status
, "endOfRibSend");
11781 json_object_boolean_false_add(
11782 json_endofrib_status
,
11783 "endOfRibSentAfterUpdate");
11785 vty_out(vty
, "No\n");
11787 " End-of-RIB sent after update: ");
11788 vty_out(vty
, "No\n");
11793 vty_out(vty
, " End-of-RIB received: ");
11795 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11796 PEER_STATUS_EOR_RECEIVED
)) {
11798 json_object_boolean_true_add(
11799 json_endofrib_status
, "endOfRibRecv");
11801 vty_out(vty
, "Yes\n");
11804 json_object_boolean_false_add(
11805 json_endofrib_status
, "endOfRibRecv");
11807 vty_out(vty
, "No\n");
11811 json_object_int_add(json_timer
, "stalePathTimer",
11812 peer
->bgp
->stalepath_time
);
11814 if (peer
->t_gr_stale
!= NULL
) {
11815 json_object_int_add(json_timer
,
11816 "stalePathTimerRemaining",
11817 thread_timer_remain_second(
11818 peer
->t_gr_stale
));
11821 /* Display Configured Selection
11822 * Deferral only when when
11823 * Gr mode is enabled.
11825 if (CHECK_FLAG(peer
->flags
,
11826 PEER_FLAG_GRACEFUL_RESTART
)) {
11827 json_object_int_add(json_timer
,
11828 "selectionDeferralTimer",
11829 peer
->bgp
->stalepath_time
);
11832 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11835 json_object_int_add(
11837 "selectionDeferralTimerRemaining",
11838 thread_timer_remain_second(
11839 peer
->bgp
->gr_info
[afi
][safi
]
11840 .t_select_deferral
));
11843 vty_out(vty
, " Timers:\n");
11845 " Configured Stale Path Time(sec): %u\n",
11846 peer
->bgp
->stalepath_time
);
11848 if (peer
->t_gr_stale
!= NULL
)
11850 " Stale Path Remaining(sec): %ld\n",
11851 thread_timer_remain_second(
11852 peer
->t_gr_stale
));
11853 /* Display Configured Selection
11854 * Deferral only when when
11855 * Gr mode is enabled.
11857 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11859 " Configured Selection Deferral Time(sec): %u\n",
11860 peer
->bgp
->select_defer_time
);
11862 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11865 " Selection Deferral Time Remaining(sec): %ld\n",
11866 thread_timer_remain_second(
11867 peer
->bgp
->gr_info
[afi
][safi
]
11868 .t_select_deferral
));
11871 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11872 json_endofrib_status
);
11873 json_object_object_add(json_afi_safi
, "timers",
11875 json_object_object_add(
11876 json
, get_afi_safi_str(afi
, safi
, true),
11882 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11888 json_object
*json_timer
= NULL
;
11890 json_timer
= json_object_new_object();
11892 json_object_int_add(json_timer
, "configuredRestartTimer",
11893 p
->bgp
->restart_time
);
11895 json_object_int_add(json_timer
, "receivedRestartTimer",
11898 if (p
->t_gr_restart
!= NULL
)
11899 json_object_int_add(
11900 json_timer
, "restartTimerRemaining",
11901 thread_timer_remain_second(p
->t_gr_restart
));
11903 json_object_object_add(json
, "timers", json_timer
);
11906 vty_out(vty
, " Timers:\n");
11907 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11908 p
->bgp
->restart_time
);
11910 vty_out(vty
, " Received Restart Time(sec): %u\n",
11912 if (p
->t_gr_restart
!= NULL
)
11913 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11914 thread_timer_remain_second(p
->t_gr_restart
));
11915 if (p
->t_gr_restart
!= NULL
) {
11916 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11917 thread_timer_remain_second(p
->t_gr_restart
));
11922 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11923 bool use_json
, json_object
*json
)
11925 char dn_flag
[2] = {0};
11926 /* '*' + v6 address of neighbor */
11927 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11929 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11934 json_object_string_addf(json
, "neighborAddr", "%pSU",
11937 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11940 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11944 json_object_string_add(json
, "neighborAddr",
11947 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11950 /* more gr info in new format */
11951 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11954 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11955 safi_t safi
, bool use_json
,
11956 json_object
*json_neigh
)
11958 struct bgp_filter
*filter
;
11959 struct peer_af
*paf
;
11960 char orf_pfx_name
[BUFSIZ
];
11962 json_object
*json_af
= NULL
;
11963 json_object
*json_prefA
= NULL
;
11964 json_object
*json_prefB
= NULL
;
11965 json_object
*json_addr
= NULL
;
11966 json_object
*json_advmap
= NULL
;
11969 json_addr
= json_object_new_object();
11970 json_af
= json_object_new_object();
11971 filter
= &p
->filter
[afi
][safi
];
11973 if (peer_group_active(p
))
11974 json_object_string_add(json_addr
, "peerGroupMember",
11977 paf
= peer_af_find(p
, afi
, safi
);
11978 if (paf
&& PAF_SUBGRP(paf
)) {
11979 json_object_int_add(json_addr
, "updateGroupId",
11980 PAF_UPDGRP(paf
)->id
);
11981 json_object_int_add(json_addr
, "subGroupId",
11982 PAF_SUBGRP(paf
)->id
);
11983 json_object_int_add(json_addr
, "packetQueueLength",
11984 bpacket_queue_virtual_length(paf
));
11987 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11988 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11989 PEER_CAP_ORF_PREFIX_SM_RCV
)
11990 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11991 PEER_CAP_ORF_PREFIX_RM_ADV
)
11992 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11993 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11994 json_object_int_add(json_af
, "orfType",
11996 json_prefA
= json_object_new_object();
11997 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11998 PEER_CAP_ORF_PREFIX_SM_ADV
,
11999 PEER_CAP_ORF_PREFIX_RM_ADV
,
12000 PEER_CAP_ORF_PREFIX_SM_RCV
,
12001 PEER_CAP_ORF_PREFIX_RM_RCV
,
12002 use_json
, json_prefA
);
12003 json_object_object_add(json_af
, "orfPrefixList",
12007 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
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_OLD_RCV
)) {
12014 json_object_int_add(json_af
, "orfOldType",
12015 ORF_TYPE_PREFIX_OLD
);
12016 json_prefB
= json_object_new_object();
12017 bgp_show_peer_afi_orf_cap(
12018 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12019 PEER_CAP_ORF_PREFIX_RM_ADV
,
12020 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12021 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12023 json_object_object_add(json_af
, "orfOldPrefixList",
12027 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12028 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12029 PEER_CAP_ORF_PREFIX_SM_RCV
)
12030 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12031 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12032 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12033 PEER_CAP_ORF_PREFIX_RM_ADV
)
12034 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12035 PEER_CAP_ORF_PREFIX_RM_RCV
)
12036 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12037 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12038 json_object_object_add(json_addr
, "afDependentCap",
12041 json_object_free(json_af
);
12043 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12044 p
->host
, afi
, safi
);
12045 orf_pfx_count
= prefix_bgp_show_prefix_list(
12046 NULL
, afi
, orf_pfx_name
, use_json
);
12048 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12049 PEER_STATUS_ORF_PREFIX_SEND
)
12050 || orf_pfx_count
) {
12051 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12052 PEER_STATUS_ORF_PREFIX_SEND
))
12053 json_object_boolean_true_add(json_neigh
,
12056 json_object_int_add(json_addr
, "orfRecvCounter",
12059 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12060 PEER_STATUS_ORF_WAIT_REFRESH
))
12061 json_object_string_add(
12062 json_addr
, "orfFirstUpdate",
12063 "deferredUntilORFOrRouteRefreshRecvd");
12065 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12066 PEER_FLAG_REFLECTOR_CLIENT
))
12067 json_object_boolean_true_add(json_addr
,
12068 "routeReflectorClient");
12069 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12070 PEER_FLAG_RSERVER_CLIENT
))
12071 json_object_boolean_true_add(json_addr
,
12072 "routeServerClient");
12073 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12074 json_object_boolean_true_add(json_addr
,
12075 "inboundSoftConfigPermit");
12077 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12078 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12079 json_object_boolean_true_add(
12081 "privateAsNumsAllReplacedInUpdatesToNbr");
12082 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12083 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12084 json_object_boolean_true_add(
12086 "privateAsNumsReplacedInUpdatesToNbr");
12087 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12088 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12089 json_object_boolean_true_add(
12091 "privateAsNumsAllRemovedInUpdatesToNbr");
12092 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12093 PEER_FLAG_REMOVE_PRIVATE_AS
))
12094 json_object_boolean_true_add(
12096 "privateAsNumsRemovedInUpdatesToNbr");
12098 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12099 json_object_boolean_true_add(
12101 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12104 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12105 json_object_string_add(json_addr
,
12106 "overrideASNsInOutboundUpdates",
12107 "ifAspathEqualRemoteAs");
12109 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12110 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12111 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12112 json_object_boolean_true_add(json_addr
,
12113 "routerAlwaysNextHop");
12114 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12115 PEER_FLAG_AS_PATH_UNCHANGED
))
12116 json_object_boolean_true_add(
12117 json_addr
, "unchangedAsPathPropogatedToNbr");
12118 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12119 PEER_FLAG_NEXTHOP_UNCHANGED
))
12120 json_object_boolean_true_add(
12121 json_addr
, "unchangedNextHopPropogatedToNbr");
12122 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12123 json_object_boolean_true_add(
12124 json_addr
, "unchangedMedPropogatedToNbr");
12125 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12126 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12127 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12128 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12129 PEER_FLAG_SEND_COMMUNITY
)
12130 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12131 PEER_FLAG_SEND_EXT_COMMUNITY
))
12132 json_object_string_add(json_addr
,
12133 "commAttriSentToNbr",
12134 "extendedAndStandard");
12135 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12136 PEER_FLAG_SEND_EXT_COMMUNITY
))
12137 json_object_string_add(json_addr
,
12138 "commAttriSentToNbr",
12141 json_object_string_add(json_addr
,
12142 "commAttriSentToNbr",
12145 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12146 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12147 if (p
->default_rmap
[afi
][safi
].name
)
12148 json_object_string_add(
12149 json_addr
, "defaultRouteMap",
12150 p
->default_rmap
[afi
][safi
].name
);
12152 if (paf
&& PAF_SUBGRP(paf
)
12153 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12154 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12155 json_object_boolean_true_add(json_addr
,
12158 json_object_boolean_true_add(json_addr
,
12162 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12163 if (is_evpn_enabled())
12164 json_object_boolean_true_add(
12165 json_addr
, "advertiseAllVnis");
12168 if (filter
->plist
[FILTER_IN
].name
12169 || filter
->dlist
[FILTER_IN
].name
12170 || filter
->aslist
[FILTER_IN
].name
12171 || filter
->map
[RMAP_IN
].name
)
12172 json_object_boolean_true_add(json_addr
,
12173 "inboundPathPolicyConfig");
12174 if (filter
->plist
[FILTER_OUT
].name
12175 || filter
->dlist
[FILTER_OUT
].name
12176 || filter
->aslist
[FILTER_OUT
].name
12177 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12178 json_object_boolean_true_add(
12179 json_addr
, "outboundPathPolicyConfig");
12182 if (filter
->plist
[FILTER_IN
].name
)
12183 json_object_string_add(json_addr
,
12184 "incomingUpdatePrefixFilterList",
12185 filter
->plist
[FILTER_IN
].name
);
12186 if (filter
->plist
[FILTER_OUT
].name
)
12187 json_object_string_add(json_addr
,
12188 "outgoingUpdatePrefixFilterList",
12189 filter
->plist
[FILTER_OUT
].name
);
12191 /* distribute-list */
12192 if (filter
->dlist
[FILTER_IN
].name
)
12193 json_object_string_add(
12194 json_addr
, "incomingUpdateNetworkFilterList",
12195 filter
->dlist
[FILTER_IN
].name
);
12196 if (filter
->dlist
[FILTER_OUT
].name
)
12197 json_object_string_add(
12198 json_addr
, "outgoingUpdateNetworkFilterList",
12199 filter
->dlist
[FILTER_OUT
].name
);
12202 if (filter
->aslist
[FILTER_IN
].name
)
12203 json_object_string_add(json_addr
,
12204 "incomingUpdateAsPathFilterList",
12205 filter
->aslist
[FILTER_IN
].name
);
12206 if (filter
->aslist
[FILTER_OUT
].name
)
12207 json_object_string_add(json_addr
,
12208 "outgoingUpdateAsPathFilterList",
12209 filter
->aslist
[FILTER_OUT
].name
);
12212 if (filter
->map
[RMAP_IN
].name
)
12213 json_object_string_add(
12214 json_addr
, "routeMapForIncomingAdvertisements",
12215 filter
->map
[RMAP_IN
].name
);
12216 if (filter
->map
[RMAP_OUT
].name
)
12217 json_object_string_add(
12218 json_addr
, "routeMapForOutgoingAdvertisements",
12219 filter
->map
[RMAP_OUT
].name
);
12221 /* ebgp-requires-policy (inbound) */
12222 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12223 && !bgp_inbound_policy_exists(p
, filter
))
12224 json_object_string_add(
12225 json_addr
, "inboundEbgpRequiresPolicy",
12226 "Inbound updates discarded due to missing policy");
12228 /* ebgp-requires-policy (outbound) */
12229 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12230 && (!bgp_outbound_policy_exists(p
, filter
)))
12231 json_object_string_add(
12232 json_addr
, "outboundEbgpRequiresPolicy",
12233 "Outbound updates discarded due to missing policy");
12235 /* unsuppress-map */
12236 if (filter
->usmap
.name
)
12237 json_object_string_add(json_addr
,
12238 "selectiveUnsuppressRouteMap",
12239 filter
->usmap
.name
);
12241 /* advertise-map */
12242 if (filter
->advmap
.aname
) {
12243 json_advmap
= json_object_new_object();
12244 json_object_string_add(json_advmap
, "condition",
12245 filter
->advmap
.condition
12248 json_object_string_add(json_advmap
, "conditionMap",
12249 filter
->advmap
.cname
);
12250 json_object_string_add(json_advmap
, "advertiseMap",
12251 filter
->advmap
.aname
);
12252 json_object_string_add(
12253 json_advmap
, "advertiseStatus",
12254 filter
->advmap
.update_type
==
12255 UPDATE_TYPE_ADVERTISE
12258 json_object_object_add(json_addr
, "advertiseMap",
12262 /* Receive prefix count */
12263 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12264 p
->pcount
[afi
][safi
]);
12265 if (paf
&& PAF_SUBGRP(paf
))
12266 json_object_int_add(json_addr
, "sentPrefixCounter",
12267 (PAF_SUBGRP(paf
))->scount
);
12269 /* Maximum prefix */
12270 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12271 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12272 p
->pmax_out
[afi
][safi
]);
12274 /* Maximum prefix */
12275 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12276 json_object_int_add(json_addr
, "prefixAllowedMax",
12277 p
->pmax
[afi
][safi
]);
12278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12279 PEER_FLAG_MAX_PREFIX_WARNING
))
12280 json_object_boolean_true_add(
12281 json_addr
, "prefixAllowedMaxWarning");
12282 json_object_int_add(json_addr
,
12283 "prefixAllowedWarningThresh",
12284 p
->pmax_threshold
[afi
][safi
]);
12285 if (p
->pmax_restart
[afi
][safi
])
12286 json_object_int_add(
12288 "prefixAllowedRestartIntervalMsecs",
12289 p
->pmax_restart
[afi
][safi
] * 60000);
12291 json_object_object_add(json_neigh
,
12292 get_afi_safi_str(afi
, safi
, true),
12296 filter
= &p
->filter
[afi
][safi
];
12298 vty_out(vty
, " For address family: %s\n",
12299 get_afi_safi_str(afi
, safi
, false));
12301 if (peer_group_active(p
))
12302 vty_out(vty
, " %s peer-group member\n",
12305 paf
= peer_af_find(p
, afi
, safi
);
12306 if (paf
&& PAF_SUBGRP(paf
)) {
12307 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12308 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12309 vty_out(vty
, " Packet Queue length %d\n",
12310 bpacket_queue_virtual_length(paf
));
12312 vty_out(vty
, " Not part of any update group\n");
12314 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12315 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12316 PEER_CAP_ORF_PREFIX_SM_RCV
)
12317 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12318 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12319 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12320 PEER_CAP_ORF_PREFIX_RM_ADV
)
12321 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12322 PEER_CAP_ORF_PREFIX_RM_RCV
)
12323 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12324 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12325 vty_out(vty
, " AF-dependant capabilities:\n");
12327 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12328 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12329 PEER_CAP_ORF_PREFIX_SM_RCV
)
12330 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12331 PEER_CAP_ORF_PREFIX_RM_ADV
)
12332 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12333 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12335 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12337 bgp_show_peer_afi_orf_cap(
12338 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12339 PEER_CAP_ORF_PREFIX_RM_ADV
,
12340 PEER_CAP_ORF_PREFIX_SM_RCV
,
12341 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12343 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12344 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12345 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12346 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12347 PEER_CAP_ORF_PREFIX_RM_ADV
)
12348 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12349 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12351 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12352 ORF_TYPE_PREFIX_OLD
);
12353 bgp_show_peer_afi_orf_cap(
12354 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12355 PEER_CAP_ORF_PREFIX_RM_ADV
,
12356 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12357 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12360 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12361 p
->host
, afi
, safi
);
12362 orf_pfx_count
= prefix_bgp_show_prefix_list(
12363 NULL
, afi
, orf_pfx_name
, use_json
);
12365 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12366 PEER_STATUS_ORF_PREFIX_SEND
)
12367 || orf_pfx_count
) {
12368 vty_out(vty
, " Outbound Route Filter (ORF):");
12369 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12370 PEER_STATUS_ORF_PREFIX_SEND
))
12371 vty_out(vty
, " sent;");
12373 vty_out(vty
, " received (%d entries)",
12375 vty_out(vty
, "\n");
12377 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12378 PEER_STATUS_ORF_WAIT_REFRESH
))
12380 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12382 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12383 PEER_FLAG_REFLECTOR_CLIENT
))
12384 vty_out(vty
, " Route-Reflector Client\n");
12385 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12386 PEER_FLAG_RSERVER_CLIENT
))
12387 vty_out(vty
, " Route-Server Client\n");
12388 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12390 " Inbound soft reconfiguration allowed\n");
12392 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12393 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12395 " Private AS numbers (all) replaced in updates to this neighbor\n");
12396 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12397 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12399 " Private AS numbers replaced in updates to this neighbor\n");
12400 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12401 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12403 " Private AS numbers (all) removed in updates to this neighbor\n");
12404 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12405 PEER_FLAG_REMOVE_PRIVATE_AS
))
12407 " Private AS numbers removed in updates to this neighbor\n");
12409 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12410 vty_out(vty
, " %s\n",
12411 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12412 ->human_description
);
12414 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12416 " Override ASNs in outbound updates if aspath equals remote-as\n");
12418 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12419 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12420 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12421 vty_out(vty
, " NEXT_HOP is always this router\n");
12422 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_AS_PATH_UNCHANGED
))
12425 " AS_PATH is propagated unchanged to this neighbor\n");
12426 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12427 PEER_FLAG_NEXTHOP_UNCHANGED
))
12429 " NEXT_HOP is propagated unchanged to this neighbor\n");
12430 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12432 " MED is propagated unchanged to this neighbor\n");
12433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12434 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12435 PEER_FLAG_SEND_EXT_COMMUNITY
)
12436 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12437 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12439 " Community attribute sent to this neighbor");
12440 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12441 PEER_FLAG_SEND_COMMUNITY
)
12442 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12443 PEER_FLAG_SEND_EXT_COMMUNITY
)
12444 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12445 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12446 vty_out(vty
, "(all)\n");
12447 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12448 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12449 vty_out(vty
, "(large)\n");
12450 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12451 PEER_FLAG_SEND_EXT_COMMUNITY
))
12452 vty_out(vty
, "(extended)\n");
12454 vty_out(vty
, "(standard)\n");
12456 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12457 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12458 vty_out(vty
, " Default information originate,");
12460 if (p
->default_rmap
[afi
][safi
].name
)
12461 vty_out(vty
, " default route-map %s%s,",
12462 p
->default_rmap
[afi
][safi
].map
? "*"
12464 p
->default_rmap
[afi
][safi
].name
);
12465 if (paf
&& PAF_SUBGRP(paf
)
12466 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12467 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12468 vty_out(vty
, " default sent\n");
12470 vty_out(vty
, " default not sent\n");
12473 /* advertise-vni-all */
12474 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12475 if (is_evpn_enabled())
12476 vty_out(vty
, " advertise-all-vni\n");
12479 if (filter
->plist
[FILTER_IN
].name
12480 || filter
->dlist
[FILTER_IN
].name
12481 || filter
->aslist
[FILTER_IN
].name
12482 || filter
->map
[RMAP_IN
].name
)
12483 vty_out(vty
, " Inbound path policy configured\n");
12484 if (filter
->plist
[FILTER_OUT
].name
12485 || filter
->dlist
[FILTER_OUT
].name
12486 || filter
->aslist
[FILTER_OUT
].name
12487 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12488 vty_out(vty
, " Outbound path policy configured\n");
12491 if (filter
->plist
[FILTER_IN
].name
)
12493 " Incoming update prefix filter list is %s%s\n",
12494 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12495 filter
->plist
[FILTER_IN
].name
);
12496 if (filter
->plist
[FILTER_OUT
].name
)
12498 " Outgoing update prefix filter list is %s%s\n",
12499 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12500 filter
->plist
[FILTER_OUT
].name
);
12502 /* distribute-list */
12503 if (filter
->dlist
[FILTER_IN
].name
)
12505 " Incoming update network filter list is %s%s\n",
12506 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12507 filter
->dlist
[FILTER_IN
].name
);
12508 if (filter
->dlist
[FILTER_OUT
].name
)
12510 " Outgoing update network filter list is %s%s\n",
12511 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12512 filter
->dlist
[FILTER_OUT
].name
);
12515 if (filter
->aslist
[FILTER_IN
].name
)
12517 " Incoming update AS path filter list is %s%s\n",
12518 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12519 filter
->aslist
[FILTER_IN
].name
);
12520 if (filter
->aslist
[FILTER_OUT
].name
)
12522 " Outgoing update AS path filter list is %s%s\n",
12523 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12524 filter
->aslist
[FILTER_OUT
].name
);
12527 if (filter
->map
[RMAP_IN
].name
)
12529 " Route map for incoming advertisements is %s%s\n",
12530 filter
->map
[RMAP_IN
].map
? "*" : "",
12531 filter
->map
[RMAP_IN
].name
);
12532 if (filter
->map
[RMAP_OUT
].name
)
12534 " Route map for outgoing advertisements is %s%s\n",
12535 filter
->map
[RMAP_OUT
].map
? "*" : "",
12536 filter
->map
[RMAP_OUT
].name
);
12538 /* ebgp-requires-policy (inbound) */
12539 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12540 && !bgp_inbound_policy_exists(p
, filter
))
12542 " Inbound updates discarded due to missing policy\n");
12544 /* ebgp-requires-policy (outbound) */
12545 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12546 && !bgp_outbound_policy_exists(p
, filter
))
12548 " Outbound updates discarded due to missing policy\n");
12550 /* unsuppress-map */
12551 if (filter
->usmap
.name
)
12553 " Route map for selective unsuppress is %s%s\n",
12554 filter
->usmap
.map
? "*" : "",
12555 filter
->usmap
.name
);
12557 /* advertise-map */
12558 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12560 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12561 filter
->advmap
.condition
? "EXIST"
12563 filter
->advmap
.cmap
? "*" : "",
12564 filter
->advmap
.cname
,
12565 filter
->advmap
.amap
? "*" : "",
12566 filter
->advmap
.aname
,
12567 filter
->advmap
.update_type
==
12568 UPDATE_TYPE_ADVERTISE
12572 /* Receive prefix count */
12573 vty_out(vty
, " %u accepted prefixes\n",
12574 p
->pcount
[afi
][safi
]);
12576 /* maximum-prefix-out */
12577 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12578 PEER_FLAG_MAX_PREFIX_OUT
))
12580 " Maximum allowed prefixes sent %u\n",
12581 p
->pmax_out
[afi
][safi
]);
12583 /* Maximum prefix */
12584 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12586 " Maximum prefixes allowed %u%s\n",
12587 p
->pmax
[afi
][safi
],
12588 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12589 PEER_FLAG_MAX_PREFIX_WARNING
)
12590 ? " (warning-only)"
12592 vty_out(vty
, " Threshold for warning message %d%%",
12593 p
->pmax_threshold
[afi
][safi
]);
12594 if (p
->pmax_restart
[afi
][safi
])
12595 vty_out(vty
, ", restart interval %d min",
12596 p
->pmax_restart
[afi
][safi
]);
12597 vty_out(vty
, "\n");
12600 vty_out(vty
, "\n");
12604 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12608 char buf1
[PREFIX2STR_BUFFER
];
12609 char timebuf
[BGP_UPTIME_LEN
];
12615 json_object
*json_neigh
= NULL
;
12617 uint32_t sync_tcp_mss
;
12622 json_neigh
= json_object_new_object();
12624 memset(dn_flag
, '\0', sizeof(dn_flag
));
12625 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12629 if (p
->conf_if
) /* Configured interface name. */
12630 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12632 else /* Configured IP address. */
12633 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12638 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12639 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12641 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12642 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12645 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12647 if (p
->change_local_as
)
12648 json_object_int_add(json_neigh
, "localAs",
12649 p
->change_local_as
);
12651 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12653 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12654 json_object_boolean_true_add(json_neigh
,
12655 "localAsNoPrepend");
12657 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12658 json_object_boolean_true_add(json_neigh
,
12659 "localAsReplaceAs");
12661 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12662 || (p
->as_type
== AS_INTERNAL
))
12663 vty_out(vty
, "remote AS %u, ", p
->as
);
12665 vty_out(vty
, "remote AS Unspecified, ");
12666 vty_out(vty
, "local AS %u%s%s, ",
12667 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12668 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12671 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12675 /* peer type internal or confed-internal */
12676 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12678 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12679 json_object_boolean_true_add(
12680 json_neigh
, "nbrConfedInternalLink");
12682 json_object_boolean_true_add(json_neigh
,
12683 "nbrInternalLink");
12685 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12686 vty_out(vty
, "confed-internal link\n");
12688 vty_out(vty
, "internal link\n");
12690 /* peer type external or confed-external */
12691 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12693 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12694 json_object_boolean_true_add(
12695 json_neigh
, "nbrConfedExternalLink");
12697 json_object_boolean_true_add(json_neigh
,
12698 "nbrExternalLink");
12700 if (bgp_confederation_peers_check(bgp
, p
->as
))
12701 vty_out(vty
, "confed-external link\n");
12703 vty_out(vty
, "external link\n");
12707 json_object_boolean_true_add(json_neigh
,
12708 "nbrUnspecifiedLink");
12710 vty_out(vty
, "unspecified link\n");
12715 json_object_string_add(json_neigh
, "localRole",
12716 bgp_get_name_by_role(p
->local_role
));
12717 json_object_string_add(json_neigh
, "remoteRole",
12718 bgp_get_name_by_role(p
->remote_role
));
12720 vty_out(vty
, " Local Role: %s\n",
12721 bgp_get_name_by_role(p
->local_role
));
12722 vty_out(vty
, " Remote Role: %s\n",
12723 bgp_get_name_by_role(p
->remote_role
));
12730 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12732 vty_out(vty
, " Description: %s\n", p
->desc
);
12738 json_object_string_add(json_neigh
, "hostname",
12742 json_object_string_add(json_neigh
, "domainname",
12745 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12746 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12749 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12756 json_object_string_add(json_neigh
, "peerGroup",
12760 struct prefix prefix
, *range
= NULL
;
12762 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12763 range
= peer_group_lookup_dynamic_neighbor_range(
12764 p
->group
, &prefix
);
12767 json_object_string_addf(
12769 "peerSubnetRangeGroup", "%pFX",
12775 " Member of peer-group %s for session parameters\n",
12779 struct prefix prefix
, *range
= NULL
;
12781 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12782 range
= peer_group_lookup_dynamic_neighbor_range(
12783 p
->group
, &prefix
);
12787 " Belongs to the subnet range group: %pFX\n",
12795 /* Administrative shutdown. */
12796 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12797 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12798 json_object_boolean_true_add(json_neigh
,
12802 json_object_int_add(json_neigh
, "bgpVersion", 4);
12803 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12805 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12808 /* Confederation */
12809 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12810 && bgp_confederation_peers_check(bgp
, p
->as
))
12811 json_object_boolean_true_add(json_neigh
,
12815 json_object_string_add(
12816 json_neigh
, "bgpState",
12817 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12819 if (peer_established(p
)) {
12822 uptime
= monotime(NULL
);
12823 uptime
-= p
->uptime
;
12824 epoch_tbuf
= time(NULL
) - uptime
;
12826 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12828 json_object_string_add(json_neigh
, "bgpTimerUpString",
12829 peer_uptime(p
->uptime
, timebuf
,
12832 json_object_int_add(json_neigh
,
12833 "bgpTimerUpEstablishedEpoch",
12837 else if (p
->status
== Active
) {
12838 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12839 json_object_string_add(json_neigh
, "bgpStateIs",
12841 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12842 json_object_string_add(json_neigh
, "bgpStateIs",
12850 uptime
= monotime(NULL
);
12851 uptime
-= p
->readtime
;
12852 gmtime_r(&uptime
, &tm
);
12854 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12855 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12856 + (tm
.tm_hour
* 3600000));
12858 uptime
= monotime(NULL
);
12859 uptime
-= p
->last_write
;
12860 gmtime_r(&uptime
, &tm
);
12862 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12863 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12864 + (tm
.tm_hour
* 3600000));
12866 uptime
= monotime(NULL
);
12867 uptime
-= p
->update_time
;
12868 gmtime_r(&uptime
, &tm
);
12870 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12871 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12872 + (tm
.tm_hour
* 3600000));
12874 /* Configured timer values. */
12875 json_object_int_add(json_neigh
,
12876 "bgpTimerConfiguredHoldTimeMsecs",
12877 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12878 ? p
->holdtime
* 1000
12879 : bgp
->default_holdtime
* 1000);
12880 json_object_int_add(json_neigh
,
12881 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12882 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12883 ? p
->keepalive
* 1000
12884 : bgp
->default_keepalive
* 1000);
12885 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12886 p
->v_holdtime
* 1000);
12887 json_object_int_add(json_neigh
,
12888 "bgpTimerKeepAliveIntervalMsecs",
12889 p
->v_keepalive
* 1000);
12890 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12891 json_object_int_add(json_neigh
,
12892 "bgpTimerDelayOpenTimeMsecs",
12893 p
->v_delayopen
* 1000);
12896 /* Configured and Synced tcp-mss value for peer */
12897 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12898 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12899 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12901 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12905 /* Extended Optional Parameters Length for BGP OPEN Message */
12906 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12907 json_object_boolean_true_add(
12908 json_neigh
, "extendedOptionalParametersLength");
12910 json_object_boolean_false_add(
12911 json_neigh
, "extendedOptionalParametersLength");
12913 /* Conditional advertisements */
12914 json_object_int_add(
12916 "bgpTimerConfiguredConditionalAdvertisementsSec",
12917 bgp
->condition_check_period
);
12918 if (thread_is_scheduled(bgp
->t_condition_check
))
12919 json_object_int_add(
12921 "bgpTimerUntilConditionalAdvertisementsSec",
12922 thread_timer_remain_second(
12923 bgp
->t_condition_check
));
12925 /* Administrative shutdown. */
12926 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12927 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12928 vty_out(vty
, " Administratively shut down\n");
12931 vty_out(vty
, " BGP version 4");
12932 vty_out(vty
, ", remote router ID %s",
12933 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12934 vty_out(vty
, ", local router ID %s\n",
12935 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12938 /* Confederation */
12939 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12940 && bgp_confederation_peers_check(bgp
, p
->as
))
12942 " Neighbor under common administration\n");
12945 vty_out(vty
, " BGP state = %s",
12946 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12948 if (peer_established(p
))
12949 vty_out(vty
, ", up for %8s",
12950 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12953 else if (p
->status
== Active
) {
12954 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12955 vty_out(vty
, " (passive)");
12956 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12957 vty_out(vty
, " (NSF passive)");
12959 vty_out(vty
, "\n");
12962 vty_out(vty
, " Last read %s",
12963 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12965 vty_out(vty
, ", Last write %s\n",
12966 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12969 /* Configured timer values. */
12971 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12972 p
->v_holdtime
, p
->v_keepalive
);
12973 vty_out(vty
, " Configured hold time is %d seconds",
12974 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12976 : bgp
->default_holdtime
);
12977 vty_out(vty
, ", keepalive interval is %d seconds\n",
12978 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12980 : bgp
->default_keepalive
);
12981 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12983 " Configured DelayOpenTime is %d seconds\n",
12986 /* Configured and synced tcp-mss value for peer */
12987 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12988 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12989 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12990 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12993 /* Extended Optional Parameters Length for BGP OPEN Message */
12994 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12996 " Extended Optional Parameters Length is enabled\n");
12998 /* Conditional advertisements */
13000 " Configured conditional advertisements interval is %d seconds\n",
13001 bgp
->condition_check_period
);
13002 if (thread_is_scheduled(bgp
->t_condition_check
))
13004 " Time until conditional advertisements begin is %lu seconds\n",
13005 thread_timer_remain_second(
13006 bgp
->t_condition_check
));
13009 if (peer_established(p
) &&
13010 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13012 json_object
*json_cap
= NULL
;
13014 json_cap
= json_object_new_object();
13017 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13018 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13019 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13020 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13021 json_object_string_add(
13022 json_cap
, "4byteAs",
13023 "advertisedAndReceived");
13024 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13025 json_object_string_add(json_cap
,
13028 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13029 json_object_string_add(json_cap
,
13034 /* Extended Message Support */
13035 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13036 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13037 json_object_string_add(json_cap
,
13039 "advertisedAndReceived");
13040 else if (CHECK_FLAG(p
->cap
,
13041 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13042 json_object_string_add(json_cap
,
13045 else if (CHECK_FLAG(p
->cap
,
13046 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13047 json_object_string_add(json_cap
,
13052 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13053 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13054 json_object
*json_add
= NULL
;
13055 const char *print_store
;
13057 json_add
= json_object_new_object();
13059 FOREACH_AFI_SAFI (afi
, safi
) {
13060 json_object
*json_sub
= NULL
;
13061 json_sub
= json_object_new_object();
13062 print_store
= get_afi_safi_str(
13066 p
->af_cap
[afi
][safi
],
13067 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13069 p
->af_cap
[afi
][safi
],
13070 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13074 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13078 PEER_CAP_ADDPATH_AF_TX_RCV
))
13079 json_object_boolean_true_add(
13081 "txAdvertisedAndReceived");
13086 PEER_CAP_ADDPATH_AF_TX_ADV
))
13087 json_object_boolean_true_add(
13094 PEER_CAP_ADDPATH_AF_TX_RCV
))
13095 json_object_boolean_true_add(
13101 p
->af_cap
[afi
][safi
],
13102 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13104 p
->af_cap
[afi
][safi
],
13105 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13109 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13113 PEER_CAP_ADDPATH_AF_RX_RCV
))
13114 json_object_boolean_true_add(
13116 "rxAdvertisedAndReceived");
13121 PEER_CAP_ADDPATH_AF_RX_ADV
))
13122 json_object_boolean_true_add(
13129 PEER_CAP_ADDPATH_AF_RX_RCV
))
13130 json_object_boolean_true_add(
13136 p
->af_cap
[afi
][safi
],
13137 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13139 p
->af_cap
[afi
][safi
],
13140 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13142 p
->af_cap
[afi
][safi
],
13143 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13145 p
->af_cap
[afi
][safi
],
13146 PEER_CAP_ADDPATH_AF_RX_RCV
))
13147 json_object_object_add(
13148 json_add
, print_store
,
13151 json_object_free(json_sub
);
13154 json_object_object_add(json_cap
, "addPath",
13159 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13160 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13161 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13162 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13163 json_object_string_add(
13164 json_cap
, "dynamic",
13165 "advertisedAndReceived");
13166 else if (CHECK_FLAG(p
->cap
,
13167 PEER_CAP_DYNAMIC_ADV
))
13168 json_object_string_add(json_cap
,
13171 else if (CHECK_FLAG(p
->cap
,
13172 PEER_CAP_DYNAMIC_RCV
))
13173 json_object_string_add(json_cap
,
13179 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13180 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13181 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13182 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13183 json_object_string_add(
13185 "advertisedAndReceived");
13186 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13187 json_object_string_add(json_cap
, "role",
13189 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13190 json_object_string_add(json_cap
, "role",
13194 /* Extended nexthop */
13195 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13196 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13197 json_object
*json_nxt
= NULL
;
13198 const char *print_store
;
13201 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13202 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13203 json_object_string_add(
13204 json_cap
, "extendedNexthop",
13205 "advertisedAndReceived");
13206 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13207 json_object_string_add(
13208 json_cap
, "extendedNexthop",
13210 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13211 json_object_string_add(
13212 json_cap
, "extendedNexthop",
13215 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13216 json_nxt
= json_object_new_object();
13218 for (safi
= SAFI_UNICAST
;
13219 safi
< SAFI_MAX
; safi
++) {
13223 PEER_CAP_ENHE_AF_RCV
)) {
13229 json_object_string_add(
13232 "recieved"); /* misspelled for compatibility */
13235 json_object_object_add(
13237 "extendedNexthopFamililesByPeer",
13242 /* Long-lived Graceful Restart */
13243 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13244 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13245 json_object
*json_llgr
= NULL
;
13246 const char *afi_safi_str
;
13248 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13249 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13250 json_object_string_add(
13252 "longLivedGracefulRestart",
13253 "advertisedAndReceived");
13254 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13255 json_object_string_add(
13257 "longLivedGracefulRestart",
13259 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13260 json_object_string_add(
13262 "longLivedGracefulRestart",
13265 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13266 json_llgr
= json_object_new_object();
13268 FOREACH_AFI_SAFI (afi
, safi
) {
13272 PEER_CAP_ENHE_AF_RCV
)) {
13278 json_object_string_add(
13284 json_object_object_add(
13286 "longLivedGracefulRestartByPeer",
13291 /* Route Refresh */
13292 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13293 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13294 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13295 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13296 (CHECK_FLAG(p
->cap
,
13297 PEER_CAP_REFRESH_NEW_RCV
) ||
13299 PEER_CAP_REFRESH_OLD_RCV
))) {
13302 PEER_CAP_REFRESH_OLD_RCV
) &&
13305 PEER_CAP_REFRESH_NEW_RCV
))
13306 json_object_string_add(
13309 "advertisedAndReceivedOldNew");
13313 PEER_CAP_REFRESH_OLD_RCV
))
13314 json_object_string_add(
13317 "advertisedAndReceivedOld");
13319 json_object_string_add(
13322 "advertisedAndReceivedNew");
13324 } else if (CHECK_FLAG(p
->cap
,
13325 PEER_CAP_REFRESH_ADV
))
13326 json_object_string_add(json_cap
,
13329 else if (CHECK_FLAG(p
->cap
,
13330 PEER_CAP_REFRESH_NEW_RCV
) ||
13332 PEER_CAP_REFRESH_OLD_RCV
))
13333 json_object_string_add(json_cap
,
13338 /* Enhanced Route Refresh */
13339 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13340 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13341 if (CHECK_FLAG(p
->cap
,
13342 PEER_CAP_ENHANCED_RR_ADV
) &&
13344 PEER_CAP_ENHANCED_RR_RCV
))
13345 json_object_string_add(
13347 "enhancedRouteRefresh",
13348 "advertisedAndReceived");
13349 else if (CHECK_FLAG(p
->cap
,
13350 PEER_CAP_ENHANCED_RR_ADV
))
13351 json_object_string_add(
13353 "enhancedRouteRefresh",
13355 else if (CHECK_FLAG(p
->cap
,
13356 PEER_CAP_ENHANCED_RR_RCV
))
13357 json_object_string_add(
13359 "enhancedRouteRefresh",
13363 /* Multiprotocol Extensions */
13364 json_object
*json_multi
= NULL
;
13366 json_multi
= json_object_new_object();
13368 FOREACH_AFI_SAFI (afi
, safi
) {
13369 if (p
->afc_adv
[afi
][safi
] ||
13370 p
->afc_recv
[afi
][safi
]) {
13371 json_object
*json_exten
= NULL
;
13372 json_exten
= json_object_new_object();
13374 if (p
->afc_adv
[afi
][safi
] &&
13375 p
->afc_recv
[afi
][safi
])
13376 json_object_boolean_true_add(
13378 "advertisedAndReceived");
13379 else if (p
->afc_adv
[afi
][safi
])
13380 json_object_boolean_true_add(
13383 else if (p
->afc_recv
[afi
][safi
])
13384 json_object_boolean_true_add(
13385 json_exten
, "received");
13387 json_object_object_add(
13389 get_afi_safi_str(afi
, safi
,
13394 json_object_object_add(json_cap
,
13395 "multiprotocolExtensions",
13398 /* Hostname capabilities */
13399 json_object
*json_hname
= NULL
;
13401 json_hname
= json_object_new_object();
13403 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13404 json_object_string_add(
13405 json_hname
, "advHostName",
13406 bgp
->peer_self
->hostname
13407 ? bgp
->peer_self
->hostname
13409 json_object_string_add(
13410 json_hname
, "advDomainName",
13411 bgp
->peer_self
->domainname
13412 ? bgp
->peer_self
->domainname
13417 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13418 json_object_string_add(
13419 json_hname
, "rcvHostName",
13420 p
->hostname
? p
->hostname
: "n/a");
13421 json_object_string_add(
13422 json_hname
, "rcvDomainName",
13423 p
->domainname
? p
->domainname
: "n/a");
13426 json_object_object_add(json_cap
, "hostName",
13429 /* Graceful Restart */
13430 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13431 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13432 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13433 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13434 json_object_string_add(
13435 json_cap
, "gracefulRestart",
13436 "advertisedAndReceived");
13437 else if (CHECK_FLAG(p
->cap
,
13438 PEER_CAP_RESTART_ADV
))
13439 json_object_string_add(
13441 "gracefulRestartCapability",
13443 else if (CHECK_FLAG(p
->cap
,
13444 PEER_CAP_RESTART_RCV
))
13445 json_object_string_add(
13447 "gracefulRestartCapability",
13450 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13451 int restart_af_count
= 0;
13452 json_object
*json_restart
= NULL
;
13453 json_restart
= json_object_new_object();
13455 json_object_int_add(
13457 "gracefulRestartRemoteTimerMsecs",
13458 p
->v_gr_restart
* 1000);
13460 FOREACH_AFI_SAFI (afi
, safi
) {
13464 PEER_CAP_RESTART_AF_RCV
)) {
13465 json_object
*json_sub
=
13468 json_object_new_object();
13474 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13475 json_object_boolean_true_add(
13478 restart_af_count
++;
13479 json_object_object_add(
13488 if (!restart_af_count
) {
13489 json_object_string_add(
13491 "addressFamiliesByPeer",
13493 json_object_free(json_restart
);
13495 json_object_object_add(
13497 "addressFamiliesByPeer",
13501 json_object_object_add(
13502 json_neigh
, "neighborCapabilities", json_cap
);
13504 vty_out(vty
, " Neighbor capabilities:\n");
13507 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13508 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13509 vty_out(vty
, " 4 Byte AS:");
13510 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13511 vty_out(vty
, " advertised");
13512 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13513 vty_out(vty
, " %sreceived",
13518 vty_out(vty
, "\n");
13521 /* Extended Message Support */
13522 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13523 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13524 vty_out(vty
, " Extended Message:");
13525 if (CHECK_FLAG(p
->cap
,
13526 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13527 vty_out(vty
, " advertised");
13528 if (CHECK_FLAG(p
->cap
,
13529 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13530 vty_out(vty
, " %sreceived",
13533 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13536 vty_out(vty
, "\n");
13540 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13541 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13542 vty_out(vty
, " AddPath:\n");
13544 FOREACH_AFI_SAFI (afi
, safi
) {
13546 p
->af_cap
[afi
][safi
],
13547 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13549 p
->af_cap
[afi
][safi
],
13550 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13551 vty_out(vty
, " %s: TX ",
13559 PEER_CAP_ADDPATH_AF_TX_ADV
))
13566 PEER_CAP_ADDPATH_AF_TX_RCV
))
13573 PEER_CAP_ADDPATH_AF_TX_ADV
)
13577 vty_out(vty
, "\n");
13581 p
->af_cap
[afi
][safi
],
13582 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13584 p
->af_cap
[afi
][safi
],
13585 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13586 vty_out(vty
, " %s: RX ",
13594 PEER_CAP_ADDPATH_AF_RX_ADV
))
13601 PEER_CAP_ADDPATH_AF_RX_RCV
))
13608 PEER_CAP_ADDPATH_AF_RX_ADV
)
13612 vty_out(vty
, "\n");
13618 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13619 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13620 vty_out(vty
, " Dynamic:");
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13622 vty_out(vty
, " advertised");
13623 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13624 vty_out(vty
, " %sreceived",
13626 PEER_CAP_DYNAMIC_ADV
)
13629 vty_out(vty
, "\n");
13633 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13634 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13635 vty_out(vty
, " Role:");
13636 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13637 vty_out(vty
, " advertised");
13638 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13639 vty_out(vty
, " %sreceived",
13644 vty_out(vty
, "\n");
13647 /* Extended nexthop */
13648 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13649 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13650 vty_out(vty
, " Extended nexthop:");
13651 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13652 vty_out(vty
, " advertised");
13653 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13654 vty_out(vty
, " %sreceived",
13659 vty_out(vty
, "\n");
13661 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13663 " Address families by peer:\n ");
13664 for (safi
= SAFI_UNICAST
;
13665 safi
< SAFI_MAX
; safi
++)
13669 PEER_CAP_ENHE_AF_RCV
))
13679 /* Long-lived Graceful Restart */
13680 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13681 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13683 " Long-lived Graceful Restart:");
13684 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13685 vty_out(vty
, " advertised");
13686 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13687 vty_out(vty
, " %sreceived",
13692 vty_out(vty
, "\n");
13694 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13696 " Address families by peer:\n");
13697 FOREACH_AFI_SAFI (afi
, safi
)
13701 PEER_CAP_LLGR_AF_RCV
))
13711 /* Route Refresh */
13712 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13713 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13714 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13715 vty_out(vty
, " Route refresh:");
13716 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13717 vty_out(vty
, " advertised");
13718 if (CHECK_FLAG(p
->cap
,
13719 PEER_CAP_REFRESH_NEW_RCV
) ||
13721 PEER_CAP_REFRESH_OLD_RCV
))
13722 vty_out(vty
, " %sreceived(%s)",
13724 PEER_CAP_REFRESH_ADV
)
13729 PEER_CAP_REFRESH_OLD_RCV
) &&
13732 PEER_CAP_REFRESH_NEW_RCV
))
13736 PEER_CAP_REFRESH_OLD_RCV
)
13740 vty_out(vty
, "\n");
13743 /* Enhanced Route Refresh */
13744 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13745 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13746 vty_out(vty
, " Enhanced Route Refresh:");
13747 if (CHECK_FLAG(p
->cap
,
13748 PEER_CAP_ENHANCED_RR_ADV
))
13749 vty_out(vty
, " advertised");
13750 if (CHECK_FLAG(p
->cap
,
13751 PEER_CAP_ENHANCED_RR_RCV
))
13752 vty_out(vty
, " %sreceived",
13754 PEER_CAP_REFRESH_ADV
)
13757 vty_out(vty
, "\n");
13760 /* Multiprotocol Extensions */
13761 FOREACH_AFI_SAFI (afi
, safi
)
13762 if (p
->afc_adv
[afi
][safi
] ||
13763 p
->afc_recv
[afi
][safi
]) {
13764 vty_out(vty
, " Address Family %s:",
13765 get_afi_safi_str(afi
, safi
,
13767 if (p
->afc_adv
[afi
][safi
])
13768 vty_out(vty
, " advertised");
13769 if (p
->afc_recv
[afi
][safi
])
13770 vty_out(vty
, " %sreceived",
13771 p
->afc_adv
[afi
][safi
]
13774 vty_out(vty
, "\n");
13777 /* Hostname capability */
13778 vty_out(vty
, " Hostname Capability:");
13780 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13782 " advertised (name: %s,domain name: %s)",
13783 bgp
->peer_self
->hostname
13784 ? bgp
->peer_self
->hostname
13786 bgp
->peer_self
->domainname
13787 ? bgp
->peer_self
->domainname
13790 vty_out(vty
, " not advertised");
13793 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13795 " received (name: %s,domain name: %s)",
13796 p
->hostname
? p
->hostname
: "n/a",
13797 p
->domainname
? p
->domainname
: "n/a");
13799 vty_out(vty
, " not received");
13802 vty_out(vty
, "\n");
13804 /* Graceful Restart */
13805 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13806 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13808 " Graceful Restart Capability:");
13809 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13810 vty_out(vty
, " advertised");
13811 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13812 vty_out(vty
, " %sreceived",
13814 PEER_CAP_RESTART_ADV
)
13817 vty_out(vty
, "\n");
13819 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13820 int restart_af_count
= 0;
13823 " Remote Restart timer is %d seconds\n",
13826 " Address families by peer:\n ");
13828 FOREACH_AFI_SAFI (afi
, safi
)
13832 PEER_CAP_RESTART_AF_RCV
)) {
13833 vty_out(vty
, "%s%s(%s)",
13845 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13847 : "not preserved");
13848 restart_af_count
++;
13850 if (!restart_af_count
)
13851 vty_out(vty
, "none");
13852 vty_out(vty
, "\n");
13854 } /* Graceful Restart */
13858 /* graceful restart information */
13859 json_object
*json_grace
= NULL
;
13860 json_object
*json_grace_send
= NULL
;
13861 json_object
*json_grace_recv
= NULL
;
13862 int eor_send_af_count
= 0;
13863 int eor_receive_af_count
= 0;
13866 json_grace
= json_object_new_object();
13867 json_grace_send
= json_object_new_object();
13868 json_grace_recv
= json_object_new_object();
13870 if ((peer_established(p
)) &&
13871 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13872 FOREACH_AFI_SAFI (afi
, safi
) {
13873 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13874 PEER_STATUS_EOR_SEND
)) {
13875 json_object_boolean_true_add(
13877 get_afi_safi_str(afi
, safi
,
13879 eor_send_af_count
++;
13882 FOREACH_AFI_SAFI (afi
, safi
) {
13883 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13884 PEER_STATUS_EOR_RECEIVED
)) {
13885 json_object_boolean_true_add(
13887 get_afi_safi_str(afi
, safi
,
13889 eor_receive_af_count
++;
13893 json_object_object_add(json_grace
, "endOfRibSend",
13895 json_object_object_add(json_grace
, "endOfRibRecv",
13899 if (p
->t_gr_restart
)
13900 json_object_int_add(
13901 json_grace
, "gracefulRestartTimerMsecs",
13902 thread_timer_remain_second(p
->t_gr_restart
) *
13906 json_object_int_add(
13907 json_grace
, "gracefulStalepathTimerMsecs",
13908 thread_timer_remain_second(p
->t_gr_stale
) *
13910 /* more gr info in new format */
13911 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13912 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13915 vty_out(vty
, " Graceful restart information:\n");
13916 if ((peer_established(p
)) &&
13917 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13919 vty_out(vty
, " End-of-RIB send: ");
13920 FOREACH_AFI_SAFI (afi
, safi
) {
13921 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13922 PEER_STATUS_EOR_SEND
)) {
13923 vty_out(vty
, "%s%s",
13924 eor_send_af_count
? ", " : "",
13925 get_afi_safi_str(afi
, safi
,
13927 eor_send_af_count
++;
13930 vty_out(vty
, "\n");
13931 vty_out(vty
, " End-of-RIB received: ");
13932 FOREACH_AFI_SAFI (afi
, safi
) {
13933 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13934 PEER_STATUS_EOR_RECEIVED
)) {
13935 vty_out(vty
, "%s%s",
13936 eor_receive_af_count
? ", "
13938 get_afi_safi_str(afi
, safi
,
13940 eor_receive_af_count
++;
13943 vty_out(vty
, "\n");
13946 if (p
->t_gr_restart
)
13948 " The remaining time of restart timer is %ld\n",
13949 thread_timer_remain_second(p
->t_gr_restart
));
13953 " The remaining time of stalepath timer is %ld\n",
13954 thread_timer_remain_second(p
->t_gr_stale
));
13956 /* more gr info in new format */
13957 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13961 json_object
*json_stat
= NULL
;
13962 json_stat
= json_object_new_object();
13963 /* Packet counts. */
13965 atomic_size_t outq_count
, inq_count
;
13966 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13967 memory_order_relaxed
);
13968 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13969 memory_order_relaxed
);
13971 json_object_int_add(json_stat
, "depthInq",
13972 (unsigned long)inq_count
);
13973 json_object_int_add(json_stat
, "depthOutq",
13974 (unsigned long)outq_count
);
13975 json_object_int_add(json_stat
, "opensSent",
13976 atomic_load_explicit(&p
->open_out
,
13977 memory_order_relaxed
));
13978 json_object_int_add(json_stat
, "opensRecv",
13979 atomic_load_explicit(&p
->open_in
,
13980 memory_order_relaxed
));
13981 json_object_int_add(json_stat
, "notificationsSent",
13982 atomic_load_explicit(&p
->notify_out
,
13983 memory_order_relaxed
));
13984 json_object_int_add(json_stat
, "notificationsRecv",
13985 atomic_load_explicit(&p
->notify_in
,
13986 memory_order_relaxed
));
13987 json_object_int_add(json_stat
, "updatesSent",
13988 atomic_load_explicit(&p
->update_out
,
13989 memory_order_relaxed
));
13990 json_object_int_add(json_stat
, "updatesRecv",
13991 atomic_load_explicit(&p
->update_in
,
13992 memory_order_relaxed
));
13993 json_object_int_add(json_stat
, "keepalivesSent",
13994 atomic_load_explicit(&p
->keepalive_out
,
13995 memory_order_relaxed
));
13996 json_object_int_add(json_stat
, "keepalivesRecv",
13997 atomic_load_explicit(&p
->keepalive_in
,
13998 memory_order_relaxed
));
13999 json_object_int_add(json_stat
, "routeRefreshSent",
14000 atomic_load_explicit(&p
->refresh_out
,
14001 memory_order_relaxed
));
14002 json_object_int_add(json_stat
, "routeRefreshRecv",
14003 atomic_load_explicit(&p
->refresh_in
,
14004 memory_order_relaxed
));
14005 json_object_int_add(json_stat
, "capabilitySent",
14006 atomic_load_explicit(&p
->dynamic_cap_out
,
14007 memory_order_relaxed
));
14008 json_object_int_add(json_stat
, "capabilityRecv",
14009 atomic_load_explicit(&p
->dynamic_cap_in
,
14010 memory_order_relaxed
));
14011 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14012 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14013 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14015 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14016 notify_out
, notify_in
, update_out
, update_in
,
14017 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14018 dynamic_cap_out
, dynamic_cap_in
;
14019 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14020 memory_order_relaxed
);
14021 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14022 memory_order_relaxed
);
14023 open_out
= atomic_load_explicit(&p
->open_out
,
14024 memory_order_relaxed
);
14026 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14027 notify_out
= atomic_load_explicit(&p
->notify_out
,
14028 memory_order_relaxed
);
14029 notify_in
= atomic_load_explicit(&p
->notify_in
,
14030 memory_order_relaxed
);
14031 update_out
= atomic_load_explicit(&p
->update_out
,
14032 memory_order_relaxed
);
14033 update_in
= atomic_load_explicit(&p
->update_in
,
14034 memory_order_relaxed
);
14035 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14036 memory_order_relaxed
);
14037 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14038 memory_order_relaxed
);
14039 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14040 memory_order_relaxed
);
14041 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14042 memory_order_relaxed
);
14043 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14044 memory_order_relaxed
);
14045 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14046 memory_order_relaxed
);
14048 /* Packet counts. */
14049 vty_out(vty
, " Message statistics:\n");
14050 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14051 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14052 vty_out(vty
, " Sent Rcvd\n");
14053 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14055 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14057 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14059 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14061 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14063 vty_out(vty
, " Capability: %10zu %10zu\n",
14064 dynamic_cap_out
, dynamic_cap_in
);
14065 vty_out(vty
, " Total: %10u %10u\n",
14066 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14070 /* advertisement-interval */
14071 json_object_int_add(json_neigh
,
14072 "minBtwnAdvertisementRunsTimerMsecs",
14073 p
->v_routeadv
* 1000);
14075 /* Update-source. */
14076 if (p
->update_if
|| p
->update_source
) {
14078 json_object_string_add(json_neigh
,
14081 else if (p
->update_source
)
14082 json_object_string_addf(json_neigh
,
14083 "updateSource", "%pSU",
14087 /* advertisement-interval */
14089 " Minimum time between advertisement runs is %d seconds\n",
14092 /* Update-source. */
14093 if (p
->update_if
|| p
->update_source
) {
14094 vty_out(vty
, " Update source is ");
14096 vty_out(vty
, "%s", p
->update_if
);
14097 else if (p
->update_source
)
14098 vty_out(vty
, "%pSU", p
->update_source
);
14099 vty_out(vty
, "\n");
14102 vty_out(vty
, "\n");
14105 /* Address Family Information */
14106 json_object
*json_hold
= NULL
;
14109 json_hold
= json_object_new_object();
14111 FOREACH_AFI_SAFI (afi
, safi
)
14112 if (p
->afc
[afi
][safi
])
14113 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14117 json_object_object_add(json_neigh
, "addressFamilyInfo",
14119 json_object_int_add(json_neigh
, "connectionsEstablished",
14121 json_object_int_add(json_neigh
, "connectionsDropped",
14124 vty_out(vty
, " Connections established %d; dropped %d\n",
14125 p
->established
, p
->dropped
);
14127 if (!p
->last_reset
) {
14129 json_object_string_add(json_neigh
, "lastReset",
14132 vty_out(vty
, " Last reset never\n");
14138 uptime
= monotime(NULL
);
14139 uptime
-= p
->resettime
;
14140 gmtime_r(&uptime
, &tm
);
14142 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14144 + (tm
.tm_min
* 60000)
14145 + (tm
.tm_hour
* 3600000));
14146 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14148 vty_out(vty
, " Last reset %s, ",
14149 peer_uptime(p
->resettime
, timebuf
,
14150 BGP_UPTIME_LEN
, 0, NULL
));
14152 bgp_show_peer_reset(vty
, p
, NULL
, false);
14153 if (p
->last_reset_cause_size
) {
14154 msg
= p
->last_reset_cause
;
14156 " Message received that caused BGP to send a NOTIFICATION:\n ");
14157 for (i
= 1; i
<= p
->last_reset_cause_size
;
14159 vty_out(vty
, "%02X", *msg
++);
14161 if (i
!= p
->last_reset_cause_size
) {
14163 vty_out(vty
, "\n ");
14164 } else if (i
% 4 == 0) {
14169 vty_out(vty
, "\n");
14174 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14176 json_object_boolean_true_add(json_neigh
,
14177 "prefixesConfigExceedMax");
14180 " Peer had exceeded the max. no. of prefixes configured.\n");
14182 if (p
->t_pmax_restart
) {
14184 json_object_boolean_true_add(
14185 json_neigh
, "reducePrefixNumFrom");
14186 json_object_int_add(json_neigh
,
14187 "restartInTimerMsec",
14188 thread_timer_remain_second(
14193 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14194 p
->host
, thread_timer_remain_second(
14195 p
->t_pmax_restart
));
14198 json_object_boolean_true_add(
14200 "reducePrefixNumAndClearIpBgp");
14203 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14208 /* EBGP Multihop and GTSM */
14209 if (p
->sort
!= BGP_PEER_IBGP
) {
14211 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14212 json_object_int_add(json_neigh
,
14213 "externalBgpNbrMaxHopsAway",
14216 json_object_int_add(json_neigh
,
14217 "externalBgpNbrMaxHopsAway",
14220 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14222 " External BGP neighbor may be up to %d hops away.\n",
14226 " External BGP neighbor may be up to %d hops away.\n",
14231 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14232 json_object_int_add(json_neigh
,
14233 "internalBgpNbrMaxHopsAway",
14236 json_object_int_add(json_neigh
,
14237 "internalBgpNbrMaxHopsAway",
14240 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14242 " Internal BGP neighbor may be up to %d hops away.\n",
14246 " Internal BGP neighbor may be up to %d hops away.\n",
14251 /* Local address. */
14254 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14256 json_object_int_add(json_neigh
, "portLocal",
14257 ntohs(p
->su_local
->sin
.sin_port
));
14259 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14260 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14263 json_object_string_add(json_neigh
, "hostLocal",
14265 json_object_int_add(json_neigh
, "portLocal", -1);
14269 /* Remote address. */
14270 if (p
->su_remote
) {
14272 json_object_string_addf(json_neigh
, "hostForeign",
14273 "%pSU", p
->su_remote
);
14274 json_object_int_add(json_neigh
, "portForeign",
14275 ntohs(p
->su_remote
->sin
.sin_port
));
14277 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14279 ntohs(p
->su_remote
->sin
.sin_port
));
14282 json_object_string_add(json_neigh
, "hostForeign",
14284 json_object_int_add(json_neigh
, "portForeign", -1);
14288 /* Nexthop display. */
14291 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14293 json_object_string_addf(json_neigh
, "nexthopGlobal",
14294 "%pI6", &p
->nexthop
.v6_global
);
14295 json_object_string_addf(json_neigh
, "nexthopLocal",
14296 "%pI6", &p
->nexthop
.v6_local
);
14297 if (p
->shared_network
)
14298 json_object_string_add(json_neigh
,
14302 json_object_string_add(json_neigh
,
14304 "nonSharedNetwork");
14306 vty_out(vty
, "Nexthop: %s\n",
14307 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14309 vty_out(vty
, "Nexthop global: %s\n",
14310 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14312 vty_out(vty
, "Nexthop local: %s\n",
14313 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14315 vty_out(vty
, "BGP connection: %s\n",
14316 p
->shared_network
? "shared network"
14317 : "non shared network");
14321 /* Timer information. */
14323 json_object_int_add(json_neigh
, "connectRetryTimer",
14325 if (peer_established(p
) && p
->rtt
)
14326 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14329 json_object_int_add(
14330 json_neigh
, "nextStartTimerDueInMsecs",
14331 thread_timer_remain_second(p
->t_start
) * 1000);
14333 json_object_int_add(
14334 json_neigh
, "nextConnectTimerDueInMsecs",
14335 thread_timer_remain_second(p
->t_connect
)
14337 if (p
->t_routeadv
) {
14338 json_object_int_add(json_neigh
, "mraiInterval",
14340 json_object_int_add(
14341 json_neigh
, "mraiTimerExpireInMsecs",
14342 thread_timer_remain_second(p
->t_routeadv
)
14346 json_object_int_add(json_neigh
, "authenticationEnabled",
14350 json_object_string_add(json_neigh
, "readThread", "on");
14352 json_object_string_add(json_neigh
, "readThread", "off");
14354 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14355 json_object_string_add(json_neigh
, "writeThread", "on");
14357 json_object_string_add(json_neigh
, "writeThread",
14360 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14362 if (peer_established(p
) && p
->rtt
)
14363 vty_out(vty
, "Estimated round trip time: %d ms\n",
14366 vty_out(vty
, "Next start timer due in %ld seconds\n",
14367 thread_timer_remain_second(p
->t_start
));
14369 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14370 thread_timer_remain_second(p
->t_connect
));
14373 "MRAI (interval %u) timer expires in %ld seconds\n",
14375 thread_timer_remain_second(p
->t_routeadv
));
14377 vty_out(vty
, "Peer Authentication Enabled\n");
14379 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14380 p
->t_read
? "on" : "off",
14381 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14386 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14387 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14388 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14391 vty_out(vty
, "\n");
14393 /* BFD information. */
14395 bgp_bfd_show_info(vty
, p
, json_neigh
);
14398 if (p
->conf_if
) /* Configured interface name. */
14399 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14400 else /* Configured IP address. */
14401 json_object_object_add(json
, p
->host
, json_neigh
);
14405 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14406 enum show_type type
,
14407 union sockunion
*su
,
14408 const char *conf_if
, afi_t afi
,
14411 struct listnode
*node
, *nnode
;
14414 safi_t safi
= SAFI_UNICAST
;
14415 json_object
*json
= NULL
;
14416 json_object
*json_neighbor
= NULL
;
14419 json
= json_object_new_object();
14420 json_neighbor
= json_object_new_object();
14423 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14425 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14428 if ((peer
->afc
[afi
][safi
]) == 0)
14431 if (type
== show_all
) {
14432 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14436 json_object_object_add(json
, peer
->host
,
14438 json_neighbor
= NULL
;
14441 } else if (type
== show_peer
) {
14444 && !strcmp(peer
->conf_if
, conf_if
))
14446 && !strcmp(peer
->hostname
, conf_if
))) {
14448 bgp_show_peer_gr_status(vty
, peer
,
14453 if (sockunion_same(&peer
->su
, su
)) {
14455 bgp_show_peer_gr_status(vty
, peer
,
14460 if (use_json
&& find
)
14461 json_object_object_add(json
, peer
->host
,
14466 json_neighbor
= NULL
;
14471 if (type
== show_peer
&& !find
) {
14473 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14475 vty_out(vty
, "%% No such neighbor\n");
14479 json_object_free(json_neighbor
);
14480 vty_json(vty
, json
);
14482 vty_out(vty
, "\n");
14485 return CMD_SUCCESS
;
14488 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14489 enum show_type type
, union sockunion
*su
,
14490 const char *conf_if
, bool use_json
,
14493 struct listnode
*node
, *nnode
;
14496 bool nbr_output
= false;
14497 afi_t afi
= AFI_MAX
;
14498 safi_t safi
= SAFI_MAX
;
14500 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14502 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14506 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14507 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14512 bgp_show_peer(vty
, peer
, use_json
, json
);
14518 && !strcmp(peer
->conf_if
, conf_if
))
14520 && !strcmp(peer
->hostname
, conf_if
))) {
14522 bgp_show_peer(vty
, peer
, use_json
,
14526 if (sockunion_same(&peer
->su
, su
)) {
14528 bgp_show_peer(vty
, peer
, use_json
,
14533 case show_ipv4_peer
:
14534 case show_ipv6_peer
:
14535 FOREACH_SAFI (safi
) {
14536 if (peer
->afc
[afi
][safi
]) {
14539 && !strcmp(peer
->conf_if
, conf_if
))
14541 && !strcmp(peer
->hostname
, conf_if
))) {
14543 bgp_show_peer(vty
, peer
, use_json
,
14548 if (sockunion_same(&peer
->su
, su
)) {
14550 bgp_show_peer(vty
, peer
, use_json
,
14558 case show_ipv4_all
:
14559 case show_ipv6_all
:
14560 FOREACH_SAFI (safi
) {
14561 if (peer
->afc
[afi
][safi
]) {
14562 bgp_show_peer(vty
, peer
, use_json
, json
);
14571 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14572 type
== show_ipv6_peer
) && !find
) {
14574 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14576 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14579 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14580 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14581 vty_out(vty
, "%% No BGP neighbors found\n");
14584 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14585 json
, JSON_C_TO_STRING_PRETTY
));
14587 vty_out(vty
, "\n");
14590 return CMD_SUCCESS
;
14593 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14594 enum show_type type
,
14595 const char *ip_str
,
14596 afi_t afi
, bool use_json
)
14601 union sockunion su
;
14603 bgp
= bgp_get_default();
14609 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14613 ret
= str2sockunion(ip_str
, &su
);
14615 bgp_show_neighbor_graceful_restart(
14616 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14618 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14619 NULL
, afi
, use_json
);
14621 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14625 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14626 enum show_type type
,
14627 const char *ip_str
,
14630 struct listnode
*node
, *nnode
;
14632 union sockunion su
;
14633 json_object
*json
= NULL
;
14634 int ret
, is_first
= 1;
14635 bool nbr_output
= false;
14638 vty_out(vty
, "{\n");
14640 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14643 if (!(json
= json_object_new_object())) {
14645 EC_BGP_JSON_MEM_ERROR
,
14646 "Unable to allocate memory for JSON object");
14648 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14652 json_object_int_add(json
, "vrfId",
14653 (bgp
->vrf_id
== VRF_UNKNOWN
)
14655 : (int64_t)bgp
->vrf_id
);
14656 json_object_string_add(
14658 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14663 vty_out(vty
, ",\n");
14667 vty_out(vty
, "\"%s\":",
14668 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14672 vty_out(vty
, "\nInstance %s:\n",
14673 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14678 if (type
== show_peer
|| type
== show_ipv4_peer
||
14679 type
== show_ipv6_peer
) {
14680 ret
= str2sockunion(ip_str
, &su
);
14682 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14685 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14688 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14691 json_object_free(json
);
14696 vty_out(vty
, "}\n");
14697 else if (!nbr_output
)
14698 vty_out(vty
, "%% BGP instance not found\n");
14701 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14702 enum show_type type
, const char *ip_str
,
14707 union sockunion su
;
14708 json_object
*json
= NULL
;
14711 if (strmatch(name
, "all")) {
14712 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14714 return CMD_SUCCESS
;
14716 bgp
= bgp_lookup_by_name(name
);
14719 json
= json_object_new_object();
14720 vty_json(vty
, json
);
14723 "%% BGP instance not found\n");
14725 return CMD_WARNING
;
14729 bgp
= bgp_get_default();
14733 json
= json_object_new_object();
14735 ret
= str2sockunion(ip_str
, &su
);
14737 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14740 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14743 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14746 json_object_free(json
);
14749 vty_out(vty
, "{}\n");
14751 vty_out(vty
, "%% BGP instance not found\n");
14754 return CMD_SUCCESS
;
14759 /* "show [ip] bgp neighbors graceful-restart" commands. */
14760 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14761 show_ip_bgp_neighbors_graceful_restart_cmd
,
14762 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14768 "Neighbor to display information about\n"
14769 "Neighbor to display information about\n"
14770 "Neighbor on BGP configured interface\n"
14774 char *sh_arg
= NULL
;
14775 enum show_type sh_type
;
14777 afi_t afi
= AFI_MAX
;
14778 bool uj
= use_json(argc
, argv
);
14780 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14785 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14786 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14787 || argv_find(argv
, argc
, "WORD", &idx
)) {
14788 sh_type
= show_peer
;
14789 sh_arg
= argv
[idx
]->arg
;
14791 sh_type
= show_all
;
14793 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14794 return CMD_SUCCESS
;
14797 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14801 /* "show [ip] bgp neighbors" commands. */
14802 DEFUN (show_ip_bgp_neighbors
,
14803 show_ip_bgp_neighbors_cmd
,
14804 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14808 BGP_INSTANCE_HELP_STR
14811 "Detailed information on TCP and BGP neighbor connections\n"
14812 "Neighbor to display information about\n"
14813 "Neighbor to display information about\n"
14814 "Neighbor on BGP configured interface\n"
14818 char *sh_arg
= NULL
;
14819 enum show_type sh_type
;
14820 afi_t afi
= AFI_MAX
;
14822 bool uj
= use_json(argc
, argv
);
14826 /* [<vrf> VIEWVRFNAME] */
14827 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14828 vrf
= argv
[idx
+ 1]->arg
;
14829 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14831 } else if (argv_find(argv
, argc
, "view", &idx
))
14832 /* [<view> VIEWVRFNAME] */
14833 vrf
= argv
[idx
+ 1]->arg
;
14837 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14838 sh_type
= show_ipv4_all
;
14840 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14841 sh_type
= show_ipv6_all
;
14844 sh_type
= show_all
;
14847 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14848 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14849 || argv_find(argv
, argc
, "WORD", &idx
)) {
14850 sh_type
= show_peer
;
14851 sh_arg
= argv
[idx
]->arg
;
14854 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14855 sh_type
= show_ipv4_peer
;
14856 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14857 sh_type
= show_ipv6_peer
;
14860 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14863 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14864 paths' and `show ip mbgp paths'. Those functions results are the
14866 DEFUN (show_ip_bgp_paths
,
14867 show_ip_bgp_paths_cmd
,
14868 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14873 "Path information\n")
14875 vty_out(vty
, "Address Refcnt Path\n");
14876 aspath_print_all_vty(vty
);
14877 return CMD_SUCCESS
;
14882 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14885 struct community
*com
;
14887 com
= (struct community
*)bucket
->data
;
14888 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14889 community_str(com
, false, false));
14892 /* Show BGP's community internal data. */
14893 DEFUN (show_ip_bgp_community_info
,
14894 show_ip_bgp_community_info_cmd
,
14895 "show [ip] bgp community-info",
14899 "List all bgp community information\n")
14901 vty_out(vty
, "Address Refcnt Community\n");
14903 hash_iterate(community_hash(),
14904 (void (*)(struct hash_bucket
*,
14905 void *))community_show_all_iterator
,
14908 return CMD_SUCCESS
;
14911 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14914 struct lcommunity
*lcom
;
14916 lcom
= (struct lcommunity
*)bucket
->data
;
14917 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14918 lcommunity_str(lcom
, false, false));
14921 /* Show BGP's community internal data. */
14922 DEFUN (show_ip_bgp_lcommunity_info
,
14923 show_ip_bgp_lcommunity_info_cmd
,
14924 "show ip bgp large-community-info",
14928 "List all bgp large-community information\n")
14930 vty_out(vty
, "Address Refcnt Large-community\n");
14932 hash_iterate(lcommunity_hash(),
14933 (void (*)(struct hash_bucket
*,
14934 void *))lcommunity_show_all_iterator
,
14937 return CMD_SUCCESS
;
14939 /* Graceful Restart */
14941 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14948 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14950 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14952 switch (bgp_global_gr_mode
) {
14954 case GLOBAL_HELPER
:
14955 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14959 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14962 case GLOBAL_DISABLE
:
14963 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14966 case GLOBAL_INVALID
:
14968 "Global BGP GR Mode Invalid\n");
14971 vty_out(vty
, "\n");
14974 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14975 enum show_type type
,
14976 const char *ip_str
,
14977 afi_t afi
, bool use_json
)
14979 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14982 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14984 bgp_show_neighbor_graceful_restart_vty(
14985 vty
, type
, ip_str
, afi
, use_json
);
14988 } else if (afi
!= AFI_MAX
) {
14989 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14992 return CMD_ERR_INCOMPLETE
;
14995 return CMD_SUCCESS
;
14997 /* Graceful Restart */
14999 DEFUN (show_ip_bgp_attr_info
,
15000 show_ip_bgp_attr_info_cmd
,
15001 "show [ip] bgp attribute-info",
15005 "List all bgp attribute information\n")
15007 attr_show_all(vty
);
15008 return CMD_SUCCESS
;
15011 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15012 afi_t afi
, safi_t safi
,
15013 bool use_json
, json_object
*json
)
15016 struct listnode
*node
;
15019 enum vpn_policy_direction dir
;
15022 json_object
*json_import_vrfs
= NULL
;
15023 json_object
*json_export_vrfs
= NULL
;
15025 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15028 vty_json(vty
, json
);
15030 return CMD_WARNING
;
15033 /* Provide context for the block */
15034 json_object_string_add(json
, "vrf", name
? name
: "default");
15035 json_object_string_add(json
, "afiSafi",
15036 get_afi_safi_str(afi
, safi
, true));
15038 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15039 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15040 json_object_string_add(json
, "importFromVrfs", "none");
15041 json_object_string_add(json
, "importRts", "none");
15043 json_import_vrfs
= json_object_new_array();
15045 for (ALL_LIST_ELEMENTS_RO(
15046 bgp
->vpn_policy
[afi
].import_vrf
,
15048 json_object_array_add(json_import_vrfs
,
15049 json_object_new_string(vname
));
15051 json_object_object_add(json
, "importFromVrfs",
15053 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15054 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15055 ecom_str
= ecommunity_ecom2str(
15056 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15057 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15058 json_object_string_add(json
, "importRts",
15060 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15062 json_object_string_add(json
, "importRts",
15066 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15067 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15068 json_object_string_add(json
, "exportToVrfs", "none");
15069 json_object_string_add(json
, "routeDistinguisher",
15071 json_object_string_add(json
, "exportRts", "none");
15073 json_export_vrfs
= json_object_new_array();
15075 for (ALL_LIST_ELEMENTS_RO(
15076 bgp
->vpn_policy
[afi
].export_vrf
,
15078 json_object_array_add(json_export_vrfs
,
15079 json_object_new_string(vname
));
15080 json_object_object_add(json
, "exportToVrfs",
15082 json_object_string_addf(json
, "routeDistinguisher",
15084 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15086 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15087 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15088 ecom_str
= ecommunity_ecom2str(
15089 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15090 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15091 json_object_string_add(json
, "exportRts",
15093 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15095 json_object_string_add(json
, "exportRts",
15100 vty_json(vty
, json
);
15103 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15106 vty_out(vty
, "%% No such BGP instance exist\n");
15107 return CMD_WARNING
;
15110 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15111 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15113 "This VRF is not importing %s routes from any other VRF\n",
15114 get_afi_safi_str(afi
, safi
, false));
15117 "This VRF is importing %s routes from the following VRFs:\n",
15118 get_afi_safi_str(afi
, safi
, false));
15120 for (ALL_LIST_ELEMENTS_RO(
15121 bgp
->vpn_policy
[afi
].import_vrf
,
15123 vty_out(vty
, " %s\n", vname
);
15125 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15127 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15128 ecom_str
= ecommunity_ecom2str(
15129 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15130 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15131 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15133 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15135 vty_out(vty
, "Import RT(s):\n");
15138 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15139 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15141 "This VRF is not exporting %s routes to any other VRF\n",
15142 get_afi_safi_str(afi
, safi
, false));
15145 "This VRF is exporting %s routes to the following VRFs:\n",
15146 get_afi_safi_str(afi
, safi
, false));
15148 for (ALL_LIST_ELEMENTS_RO(
15149 bgp
->vpn_policy
[afi
].export_vrf
,
15151 vty_out(vty
, " %s\n", vname
);
15153 vty_out(vty
, "RD: %pRD\n",
15154 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15156 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15157 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15158 ecom_str
= ecommunity_ecom2str(
15159 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15160 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15161 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15162 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15164 vty_out(vty
, "Import RT(s):\n");
15168 return CMD_SUCCESS
;
15171 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15172 safi_t safi
, bool use_json
)
15174 struct listnode
*node
, *nnode
;
15176 char *vrf_name
= NULL
;
15177 json_object
*json
= NULL
;
15178 json_object
*json_vrf
= NULL
;
15179 json_object
*json_vrfs
= NULL
;
15182 json
= json_object_new_object();
15183 json_vrfs
= json_object_new_object();
15186 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15188 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15189 vrf_name
= bgp
->name
;
15192 json_vrf
= json_object_new_object();
15194 vty_out(vty
, "\nInstance %s:\n",
15195 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15196 ? VRF_DEFAULT_NAME
: bgp
->name
);
15198 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15200 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15201 json_object_object_add(json_vrfs
,
15202 VRF_DEFAULT_NAME
, json_vrf
);
15204 json_object_object_add(json_vrfs
, vrf_name
,
15210 json_object_object_add(json
, "vrfs", json_vrfs
);
15211 vty_json(vty
, json
);
15214 return CMD_SUCCESS
;
15217 /* "show [ip] bgp route-leak" command. */
15218 DEFUN (show_ip_bgp_route_leak
,
15219 show_ip_bgp_route_leak_cmd
,
15220 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15224 BGP_INSTANCE_HELP_STR
15227 "Route leaking information\n"
15231 afi_t afi
= AFI_MAX
;
15232 safi_t safi
= SAFI_MAX
;
15234 bool uj
= use_json(argc
, argv
);
15236 json_object
*json
= NULL
;
15238 /* show [ip] bgp */
15239 if (argv_find(argv
, argc
, "ip", &idx
)) {
15241 safi
= SAFI_UNICAST
;
15243 /* [vrf VIEWVRFNAME] */
15244 if (argv_find(argv
, argc
, "view", &idx
)) {
15246 "%% This command is not applicable to BGP views\n");
15247 return CMD_WARNING
;
15250 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15251 vrf
= argv
[idx
+ 1]->arg
;
15252 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15255 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15256 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15257 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15259 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15261 "%% This command is applicable only for unicast ipv4|ipv6\n");
15262 return CMD_WARNING
;
15265 if (vrf
&& strmatch(vrf
, "all"))
15266 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15269 json
= json_object_new_object();
15271 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15274 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15277 struct listnode
*node
, *nnode
;
15280 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15281 vty_out(vty
, "\nInstance %s:\n",
15282 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15285 update_group_show(bgp
, afi
, safi
, vty
, 0);
15289 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15290 int safi
, uint64_t subgrp_id
)
15295 if (strmatch(name
, "all")) {
15296 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15297 return CMD_SUCCESS
;
15299 bgp
= bgp_lookup_by_name(name
);
15302 bgp
= bgp_get_default();
15306 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15307 return CMD_SUCCESS
;
15310 DEFUN (show_ip_bgp_updgrps
,
15311 show_ip_bgp_updgrps_cmd
,
15312 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15316 BGP_INSTANCE_HELP_STR
15318 BGP_SAFI_WITH_LABEL_HELP_STR
15319 "Detailed info about dynamic update groups\n"
15320 "Specific subgroup to display detailed info for\n")
15323 afi_t afi
= AFI_IP6
;
15324 safi_t safi
= SAFI_UNICAST
;
15325 uint64_t subgrp_id
= 0;
15329 /* show [ip] bgp */
15330 if (argv_find(argv
, argc
, "ip", &idx
))
15332 /* [<vrf> VIEWVRFNAME] */
15333 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15334 vrf
= argv
[idx
+ 1]->arg
;
15335 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15337 } else if (argv_find(argv
, argc
, "view", &idx
))
15338 /* [<view> VIEWVRFNAME] */
15339 vrf
= argv
[idx
+ 1]->arg
;
15340 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15341 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15342 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15345 /* get subgroup id, if provided */
15347 if (argv
[idx
]->type
== VARIABLE_TKN
)
15348 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15350 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15353 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15354 show_bgp_instance_all_ipv6_updgrps_cmd
,
15355 "show [ip] bgp <view|vrf> all update-groups",
15359 BGP_INSTANCE_ALL_HELP_STR
15360 "Detailed info about dynamic update groups\n")
15362 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15363 return CMD_SUCCESS
;
15366 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15367 show_bgp_l2vpn_evpn_updgrps_cmd
,
15368 "show [ip] bgp l2vpn evpn update-groups",
15372 "l2vpn address family\n"
15373 "evpn sub-address family\n"
15374 "Detailed info about dynamic update groups\n")
15377 uint64_t subgrp_id
= 0;
15379 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15380 return CMD_SUCCESS
;
15383 DEFUN (show_bgp_updgrps_stats
,
15384 show_bgp_updgrps_stats_cmd
,
15385 "show [ip] bgp update-groups statistics",
15389 "Detailed info about dynamic update groups\n"
15394 bgp
= bgp_get_default();
15396 update_group_show_stats(bgp
, vty
);
15398 return CMD_SUCCESS
;
15401 DEFUN (show_bgp_instance_updgrps_stats
,
15402 show_bgp_instance_updgrps_stats_cmd
,
15403 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15407 BGP_INSTANCE_HELP_STR
15408 "Detailed info about dynamic update groups\n"
15414 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15416 update_group_show_stats(bgp
, vty
);
15418 return CMD_SUCCESS
;
15421 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15422 afi_t afi
, safi_t safi
,
15423 const char *what
, uint64_t subgrp_id
)
15428 bgp
= bgp_lookup_by_name(name
);
15430 bgp
= bgp_get_default();
15433 if (!strcmp(what
, "advertise-queue"))
15434 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15436 else if (!strcmp(what
, "advertised-routes"))
15437 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15439 else if (!strcmp(what
, "packet-queue"))
15440 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15445 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15446 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15447 "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",
15448 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15450 "Detailed info about dynamic update groups\n"
15451 "Specific subgroup to display info for\n"
15452 "Advertisement queue\n"
15453 "Announced routes\n"
15456 uint64_t subgrp_id
= 0;
15460 subgrp_id
= strtoull(sgid
, NULL
, 10);
15465 afiz
= bgp_vty_afi_from_str(afi
);
15469 afiz
= bgp_vty_afi_from_str(afi
);
15470 if (afiz
!= AFI_IP
)
15472 "%% Cannot specify both 'ip' and 'ipv6'\n");
15473 return CMD_WARNING
;
15476 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15478 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15479 return CMD_SUCCESS
;
15482 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15485 struct listnode
*node
, *nnode
;
15486 struct prefix
*range
;
15491 const char *peer_status
;
15495 json_object
*json_peer_group
= NULL
;
15496 json_object
*json_peer_group_afc
= NULL
;
15497 json_object
*json_peer_group_members
= NULL
;
15498 json_object
*json_peer_group_dynamic
= NULL
;
15499 json_object
*json_peer_group_dynamic_af
= NULL
;
15500 json_object
*json_peer_group_ranges
= NULL
;
15502 conf
= group
->conf
;
15505 json_peer_group
= json_object_new_object();
15506 json_peer_group_afc
= json_object_new_array();
15509 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15511 json_object_int_add(json_peer_group
, "remoteAs",
15514 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15515 group
->name
, conf
->as
);
15516 } else if (conf
->as_type
== AS_INTERNAL
) {
15518 json_object_int_add(json_peer_group
, "remoteAs",
15521 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15522 group
->name
, group
->bgp
->as
);
15525 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15528 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15530 json_object_string_add(json_peer_group
, "type",
15533 vty_out(vty
, " Peer-group type is internal\n");
15536 json_object_string_add(json_peer_group
, "type",
15539 vty_out(vty
, " Peer-group type is external\n");
15542 /* Display AFs configured. */
15544 vty_out(vty
, " Configured address-families:");
15546 FOREACH_AFI_SAFI (afi
, safi
) {
15547 if (conf
->afc
[afi
][safi
]) {
15550 json_object_array_add(
15551 json_peer_group_afc
,
15552 json_object_new_string(get_afi_safi_str(
15553 afi
, safi
, false)));
15555 vty_out(vty
, " %s;",
15556 get_afi_safi_str(afi
, safi
, false));
15561 json_object_object_add(json_peer_group
,
15562 "addressFamiliesConfigured",
15563 json_peer_group_afc
);
15566 vty_out(vty
, " none\n");
15568 vty_out(vty
, "\n");
15571 /* Display listen ranges (for dynamic neighbors), if any */
15572 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15573 lr_count
= listcount(group
->listen_range
[afi
]);
15576 if (!json_peer_group_dynamic
)
15577 json_peer_group_dynamic
=
15578 json_object_new_object();
15580 json_peer_group_dynamic_af
=
15581 json_object_new_object();
15582 json_peer_group_ranges
=
15583 json_object_new_array();
15584 json_object_int_add(json_peer_group_dynamic_af
,
15585 "count", lr_count
);
15587 vty_out(vty
, " %d %s listen range(s)\n",
15588 lr_count
, afi2str(afi
));
15591 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15596 snprintfrr(buf
, sizeof(buf
), "%pFX",
15599 json_object_array_add(
15600 json_peer_group_ranges
,
15601 json_object_new_string(buf
));
15603 vty_out(vty
, " %pFX\n", range
);
15608 json_object_object_add(
15609 json_peer_group_dynamic_af
, "ranges",
15610 json_peer_group_ranges
);
15612 json_object_object_add(
15613 json_peer_group_dynamic
, afi2str(afi
),
15614 json_peer_group_dynamic_af
);
15619 if (json_peer_group_dynamic
)
15620 json_object_object_add(json_peer_group
, "dynamicRanges",
15621 json_peer_group_dynamic
);
15623 /* Display group members and their status */
15624 if (listcount(group
->peer
)) {
15626 json_peer_group_members
= json_object_new_object();
15628 vty_out(vty
, " Peer-group members:\n");
15629 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15630 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15631 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15632 peer_status
= "Idle (Admin)";
15633 else if (CHECK_FLAG(peer
->sflags
,
15634 PEER_STATUS_PREFIX_OVERFLOW
))
15635 peer_status
= "Idle (PfxCt)";
15637 peer_status
= lookup_msg(bgp_status_msg
,
15638 peer
->status
, NULL
);
15640 dynamic
= peer_dynamic_neighbor(peer
);
15643 json_object
*json_peer_group_member
=
15644 json_object_new_object();
15646 json_object_string_add(json_peer_group_member
,
15647 "status", peer_status
);
15650 json_object_boolean_true_add(
15651 json_peer_group_member
,
15654 json_object_object_add(json_peer_group_members
,
15656 json_peer_group_member
);
15658 vty_out(vty
, " %s %s %s \n", peer
->host
,
15659 dynamic
? "(dynamic)" : "",
15664 json_object_object_add(json_peer_group
, "members",
15665 json_peer_group_members
);
15669 json_object_object_add(json
, group
->name
, json_peer_group
);
15671 return CMD_SUCCESS
;
15674 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15675 const char *group_name
, bool uj
)
15678 struct listnode
*node
, *nnode
;
15679 struct peer_group
*group
;
15680 bool found
= false;
15681 json_object
*json
= NULL
;
15684 json
= json_object_new_object();
15686 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15690 vty_json(vty
, json
);
15692 vty_out(vty
, "%% BGP instance not found\n");
15694 return CMD_WARNING
;
15697 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15699 if (strmatch(group
->name
, group_name
)) {
15700 bgp_show_one_peer_group(vty
, group
, json
);
15705 bgp_show_one_peer_group(vty
, group
, json
);
15709 if (group_name
&& !found
&& !uj
)
15710 vty_out(vty
, "%% No such peer-group\n");
15713 vty_json(vty
, json
);
15715 return CMD_SUCCESS
;
15718 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15719 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15720 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15721 "Detailed information on BGP peer groups\n"
15722 "Peer group name\n" JSON_STR
)
15726 bool uj
= use_json(argc
, argv
);
15728 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15730 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15732 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15736 /* Redistribute VTY commands. */
15738 DEFUN (bgp_redistribute_ipv4
,
15739 bgp_redistribute_ipv4_cmd
,
15740 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15741 "Redistribute information from another routing protocol\n"
15742 FRR_IP_REDIST_HELP_STR_BGPD
)
15744 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15745 int idx_protocol
= 1;
15748 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15750 vty_out(vty
, "%% Invalid route type\n");
15751 return CMD_WARNING_CONFIG_FAILED
;
15754 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15755 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15759 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15760 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15761 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15763 DEFUN (bgp_redistribute_ipv4_rmap
,
15764 bgp_redistribute_ipv4_rmap_cmd
,
15765 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15766 "Redistribute information from another routing protocol\n"
15767 FRR_IP_REDIST_HELP_STR_BGPD
15768 "Route map reference\n"
15769 "Pointer to route-map entries\n")
15771 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15772 int idx_protocol
= 1;
15775 struct bgp_redist
*red
;
15777 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15778 vty
, argv
[idx_word
]->arg
);
15780 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15782 vty_out(vty
, "%% Invalid route type\n");
15783 return CMD_WARNING_CONFIG_FAILED
;
15786 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15788 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15789 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15793 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15794 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15795 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15796 "Route map reference\n"
15797 "Pointer to route-map entries\n")
15799 DEFUN (bgp_redistribute_ipv4_metric
,
15800 bgp_redistribute_ipv4_metric_cmd
,
15801 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15802 "Redistribute information from another routing protocol\n"
15803 FRR_IP_REDIST_HELP_STR_BGPD
15804 "Metric for redistributed routes\n"
15805 "Default metric\n")
15807 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15808 int idx_protocol
= 1;
15809 int idx_number
= 3;
15812 struct bgp_redist
*red
;
15815 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15817 vty_out(vty
, "%% Invalid route type\n");
15818 return CMD_WARNING_CONFIG_FAILED
;
15820 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15822 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15823 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15824 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15828 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15829 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15830 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15831 "Metric for redistributed routes\n"
15832 "Default metric\n")
15834 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15835 bgp_redistribute_ipv4_rmap_metric_cmd
,
15836 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15837 "Redistribute information from another routing protocol\n"
15838 FRR_IP_REDIST_HELP_STR_BGPD
15839 "Route map reference\n"
15840 "Pointer to route-map entries\n"
15841 "Metric for redistributed routes\n"
15842 "Default metric\n")
15844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15845 int idx_protocol
= 1;
15847 int idx_number
= 5;
15850 struct bgp_redist
*red
;
15852 struct route_map
*route_map
=
15853 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15855 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15857 vty_out(vty
, "%% Invalid route type\n");
15858 return CMD_WARNING_CONFIG_FAILED
;
15860 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15862 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15864 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15865 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15866 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15870 bgp_redistribute_ipv4_rmap_metric
,
15871 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15872 "redistribute " FRR_IP_REDIST_STR_BGPD
15873 " route-map RMAP_NAME metric (0-4294967295)",
15874 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15875 "Route map reference\n"
15876 "Pointer to route-map entries\n"
15877 "Metric for redistributed routes\n"
15878 "Default metric\n")
15880 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15881 bgp_redistribute_ipv4_metric_rmap_cmd
,
15882 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15883 "Redistribute information from another routing protocol\n"
15884 FRR_IP_REDIST_HELP_STR_BGPD
15885 "Metric for redistributed routes\n"
15887 "Route map reference\n"
15888 "Pointer to route-map entries\n")
15890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15891 int idx_protocol
= 1;
15892 int idx_number
= 3;
15896 struct bgp_redist
*red
;
15898 struct route_map
*route_map
=
15899 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15901 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15903 vty_out(vty
, "%% Invalid route type\n");
15904 return CMD_WARNING_CONFIG_FAILED
;
15906 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15908 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15909 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15911 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15912 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15916 bgp_redistribute_ipv4_metric_rmap
,
15917 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15918 "redistribute " FRR_IP_REDIST_STR_BGPD
15919 " metric (0-4294967295) route-map RMAP_NAME",
15920 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15921 "Metric for redistributed routes\n"
15923 "Route map reference\n"
15924 "Pointer to route-map entries\n")
15926 DEFUN (bgp_redistribute_ipv4_ospf
,
15927 bgp_redistribute_ipv4_ospf_cmd
,
15928 "redistribute <ospf|table> (1-65535)",
15929 "Redistribute information from another routing protocol\n"
15930 "Open Shortest Path First (OSPFv2)\n"
15931 "Non-main Kernel Routing Table\n"
15932 "Instance ID/Table ID\n")
15934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15935 int idx_ospf_table
= 1;
15936 int idx_number
= 2;
15937 unsigned short instance
;
15938 unsigned short protocol
;
15940 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15942 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15943 protocol
= ZEBRA_ROUTE_OSPF
;
15945 protocol
= ZEBRA_ROUTE_TABLE
;
15947 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15948 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15951 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15952 "redistribute <ospf|table> (1-65535)",
15953 "Redistribute information from another routing protocol\n"
15954 "Open Shortest Path First (OSPFv2)\n"
15955 "Non-main Kernel Routing Table\n"
15956 "Instance ID/Table ID\n")
15958 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15959 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15960 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15961 "Redistribute information from another routing protocol\n"
15962 "Open Shortest Path First (OSPFv2)\n"
15963 "Non-main Kernel Routing Table\n"
15964 "Instance ID/Table ID\n"
15965 "Route map reference\n"
15966 "Pointer to route-map entries\n")
15968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15969 int idx_ospf_table
= 1;
15970 int idx_number
= 2;
15972 struct bgp_redist
*red
;
15973 unsigned short instance
;
15976 struct route_map
*route_map
=
15977 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15979 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15980 protocol
= ZEBRA_ROUTE_OSPF
;
15982 protocol
= ZEBRA_ROUTE_TABLE
;
15984 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15985 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15987 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15988 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15991 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15992 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15993 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15994 "Redistribute information from another routing protocol\n"
15995 "Open Shortest Path First (OSPFv2)\n"
15996 "Non-main Kernel Routing Table\n"
15997 "Instance ID/Table ID\n"
15998 "Route map reference\n"
15999 "Pointer to route-map entries\n")
16001 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16002 bgp_redistribute_ipv4_ospf_metric_cmd
,
16003 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16004 "Redistribute information from another routing protocol\n"
16005 "Open Shortest Path First (OSPFv2)\n"
16006 "Non-main Kernel Routing Table\n"
16007 "Instance ID/Table ID\n"
16008 "Metric for redistributed routes\n"
16009 "Default metric\n")
16011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16012 int idx_ospf_table
= 1;
16013 int idx_number
= 2;
16014 int idx_number_2
= 4;
16016 struct bgp_redist
*red
;
16017 unsigned short instance
;
16021 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16022 protocol
= ZEBRA_ROUTE_OSPF
;
16024 protocol
= ZEBRA_ROUTE_TABLE
;
16026 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16027 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16029 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16030 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16032 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16035 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16036 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16037 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16038 "Redistribute information from another routing protocol\n"
16039 "Open Shortest Path First (OSPFv2)\n"
16040 "Non-main Kernel Routing Table\n"
16041 "Instance ID/Table ID\n"
16042 "Metric for redistributed routes\n"
16043 "Default metric\n")
16045 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16046 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16047 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16048 "Redistribute information from another routing protocol\n"
16049 "Open Shortest Path First (OSPFv2)\n"
16050 "Non-main Kernel Routing Table\n"
16051 "Instance ID/Table ID\n"
16052 "Route map reference\n"
16053 "Pointer to route-map entries\n"
16054 "Metric for redistributed routes\n"
16055 "Default metric\n")
16057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16058 int idx_ospf_table
= 1;
16059 int idx_number
= 2;
16061 int idx_number_2
= 6;
16063 struct bgp_redist
*red
;
16064 unsigned short instance
;
16067 struct route_map
*route_map
=
16068 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16070 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16071 protocol
= ZEBRA_ROUTE_OSPF
;
16073 protocol
= ZEBRA_ROUTE_TABLE
;
16075 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16076 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16078 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16080 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16081 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16083 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16087 bgp_redistribute_ipv4_ospf_rmap_metric
,
16088 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16089 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16090 "Redistribute information from another routing protocol\n"
16091 "Open Shortest Path First (OSPFv2)\n"
16092 "Non-main Kernel Routing Table\n"
16093 "Instance ID/Table ID\n"
16094 "Route map reference\n"
16095 "Pointer to route-map entries\n"
16096 "Metric for redistributed routes\n"
16097 "Default metric\n")
16099 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16100 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16101 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16102 "Redistribute information from another routing protocol\n"
16103 "Open Shortest Path First (OSPFv2)\n"
16104 "Non-main Kernel Routing Table\n"
16105 "Instance ID/Table ID\n"
16106 "Metric for redistributed routes\n"
16108 "Route map reference\n"
16109 "Pointer to route-map entries\n")
16111 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16112 int idx_ospf_table
= 1;
16113 int idx_number
= 2;
16114 int idx_number_2
= 4;
16117 struct bgp_redist
*red
;
16118 unsigned short instance
;
16121 struct route_map
*route_map
=
16122 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16124 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16125 protocol
= ZEBRA_ROUTE_OSPF
;
16127 protocol
= ZEBRA_ROUTE_TABLE
;
16129 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16130 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16132 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16133 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16136 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16137 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16141 bgp_redistribute_ipv4_ospf_metric_rmap
,
16142 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16143 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16144 "Redistribute information from another routing protocol\n"
16145 "Open Shortest Path First (OSPFv2)\n"
16146 "Non-main Kernel Routing Table\n"
16147 "Instance ID/Table ID\n"
16148 "Metric for redistributed routes\n"
16150 "Route map reference\n"
16151 "Pointer to route-map entries\n")
16153 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16154 no_bgp_redistribute_ipv4_ospf_cmd
,
16155 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16157 "Redistribute information from another routing protocol\n"
16158 "Open Shortest Path First (OSPFv2)\n"
16159 "Non-main Kernel Routing Table\n"
16160 "Instance ID/Table ID\n"
16161 "Metric for redistributed routes\n"
16163 "Route map reference\n"
16164 "Pointer to route-map entries\n")
16166 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16167 int idx_ospf_table
= 2;
16168 int idx_number
= 3;
16169 unsigned short instance
;
16172 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16173 protocol
= ZEBRA_ROUTE_OSPF
;
16175 protocol
= ZEBRA_ROUTE_TABLE
;
16177 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16178 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16182 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16183 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16185 "Redistribute information from another routing protocol\n"
16186 "Open Shortest Path First (OSPFv2)\n"
16187 "Non-main Kernel Routing Table\n"
16188 "Instance ID/Table ID\n"
16189 "Metric for redistributed routes\n"
16191 "Route map reference\n"
16192 "Pointer to route-map entries\n")
16194 DEFUN (no_bgp_redistribute_ipv4
,
16195 no_bgp_redistribute_ipv4_cmd
,
16196 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16198 "Redistribute information from another routing protocol\n"
16199 FRR_IP_REDIST_HELP_STR_BGPD
16200 "Metric for redistributed routes\n"
16202 "Route map reference\n"
16203 "Pointer to route-map entries\n")
16205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16206 int idx_protocol
= 2;
16209 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16211 vty_out(vty
, "%% Invalid route type\n");
16212 return CMD_WARNING_CONFIG_FAILED
;
16214 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16218 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16219 "no redistribute " FRR_IP_REDIST_STR_BGPD
16220 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16222 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16223 "Metric for redistributed routes\n"
16225 "Route map reference\n"
16226 "Pointer to route-map entries\n")
16228 DEFUN (bgp_redistribute_ipv6
,
16229 bgp_redistribute_ipv6_cmd
,
16230 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16231 "Redistribute information from another routing protocol\n"
16232 FRR_IP6_REDIST_HELP_STR_BGPD
)
16234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16235 int idx_protocol
= 1;
16238 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16240 vty_out(vty
, "%% Invalid route type\n");
16241 return CMD_WARNING_CONFIG_FAILED
;
16244 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16245 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16248 DEFUN (bgp_redistribute_ipv6_rmap
,
16249 bgp_redistribute_ipv6_rmap_cmd
,
16250 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16251 "Redistribute information from another routing protocol\n"
16252 FRR_IP6_REDIST_HELP_STR_BGPD
16253 "Route map reference\n"
16254 "Pointer to route-map entries\n")
16256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16257 int idx_protocol
= 1;
16260 struct bgp_redist
*red
;
16262 struct route_map
*route_map
=
16263 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16265 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16267 vty_out(vty
, "%% Invalid route type\n");
16268 return CMD_WARNING_CONFIG_FAILED
;
16271 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16273 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16274 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16277 DEFUN (bgp_redistribute_ipv6_metric
,
16278 bgp_redistribute_ipv6_metric_cmd
,
16279 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16280 "Redistribute information from another routing protocol\n"
16281 FRR_IP6_REDIST_HELP_STR_BGPD
16282 "Metric for redistributed routes\n"
16283 "Default metric\n")
16285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16286 int idx_protocol
= 1;
16287 int idx_number
= 3;
16290 struct bgp_redist
*red
;
16293 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16295 vty_out(vty
, "%% Invalid route type\n");
16296 return CMD_WARNING_CONFIG_FAILED
;
16298 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16300 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16301 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16302 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16305 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16306 bgp_redistribute_ipv6_rmap_metric_cmd
,
16307 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16308 "Redistribute information from another routing protocol\n"
16309 FRR_IP6_REDIST_HELP_STR_BGPD
16310 "Route map reference\n"
16311 "Pointer to route-map entries\n"
16312 "Metric for redistributed routes\n"
16313 "Default metric\n")
16315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16316 int idx_protocol
= 1;
16318 int idx_number
= 5;
16321 struct bgp_redist
*red
;
16323 struct route_map
*route_map
=
16324 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16326 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16328 vty_out(vty
, "%% Invalid route type\n");
16329 return CMD_WARNING_CONFIG_FAILED
;
16331 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16333 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16335 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16336 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16338 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16341 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16342 bgp_redistribute_ipv6_metric_rmap_cmd
,
16343 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16344 "Redistribute information from another routing protocol\n"
16345 FRR_IP6_REDIST_HELP_STR_BGPD
16346 "Metric for redistributed routes\n"
16348 "Route map reference\n"
16349 "Pointer to route-map entries\n")
16351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16352 int idx_protocol
= 1;
16353 int idx_number
= 3;
16357 struct bgp_redist
*red
;
16359 struct route_map
*route_map
=
16360 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16362 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16364 vty_out(vty
, "%% Invalid route type\n");
16365 return CMD_WARNING_CONFIG_FAILED
;
16367 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16369 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16370 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16373 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16374 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16377 DEFUN (no_bgp_redistribute_ipv6
,
16378 no_bgp_redistribute_ipv6_cmd
,
16379 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16381 "Redistribute information from another routing protocol\n"
16382 FRR_IP6_REDIST_HELP_STR_BGPD
16383 "Metric for redistributed routes\n"
16385 "Route map reference\n"
16386 "Pointer to route-map entries\n")
16388 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16389 int idx_protocol
= 2;
16392 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16394 vty_out(vty
, "%% Invalid route type\n");
16395 return CMD_WARNING_CONFIG_FAILED
;
16398 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16401 /* Neighbor update tcp-mss. */
16402 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16403 const char *tcp_mss_str
)
16406 uint32_t tcp_mss_val
= 0;
16408 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16410 return CMD_WARNING_CONFIG_FAILED
;
16413 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16414 peer_tcp_mss_set(peer
, tcp_mss_val
);
16416 peer_tcp_mss_unset(peer
);
16419 return CMD_SUCCESS
;
16422 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16423 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16424 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16425 "TCP max segment size\n"
16428 int peer_index
= 1;
16432 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16433 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16434 argv
[mss_index
]->arg
);
16437 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16438 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16439 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16440 "TCP max segment size\n"
16443 int peer_index
= 2;
16446 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16447 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16450 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16451 "[no$no] bgp retain route-target all",
16453 "Retain BGP updates\n"
16454 "Retain BGP updates based on route-target values\n"
16455 "Retain all BGP updates\n")
16458 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16460 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16461 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16462 if (check
!= !no
) {
16464 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16465 [bgp_node_safi(vty
)],
16466 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16468 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16469 [bgp_node_safi(vty
)],
16470 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16471 /* trigger a flush to re-sync with ADJ-RIB-in */
16472 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16473 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16475 return CMD_SUCCESS
;
16478 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16479 afi_t afi
, safi_t safi
)
16483 /* Unicast redistribution only. */
16484 if (safi
!= SAFI_UNICAST
)
16487 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16488 /* Redistribute BGP does not make sense. */
16489 if (i
!= ZEBRA_ROUTE_BGP
) {
16490 struct list
*red_list
;
16491 struct listnode
*node
;
16492 struct bgp_redist
*red
;
16494 red_list
= bgp
->redist
[afi
][i
];
16498 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16499 /* "redistribute" configuration. */
16500 vty_out(vty
, " redistribute %s",
16501 zebra_route_string(i
));
16503 vty_out(vty
, " %d", red
->instance
);
16504 if (red
->redist_metric_flag
)
16505 vty_out(vty
, " metric %u",
16506 red
->redist_metric
);
16507 if (red
->rmap
.name
)
16508 vty_out(vty
, " route-map %s",
16510 vty_out(vty
, "\n");
16516 /* peer-group helpers for config-write */
16518 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16520 if (!peer_group_active(peer
)) {
16521 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16522 return !CHECK_FLAG(peer
->flags
, flag
);
16524 return !!CHECK_FLAG(peer
->flags
, flag
);
16527 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16530 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16533 if (!peer_group_active(peer
)) {
16534 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16535 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16537 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16540 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16543 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16544 uint8_t type
, int direct
)
16546 struct bgp_filter
*filter
;
16548 if (peer_group_active(peer
))
16549 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16552 filter
= &peer
->filter
[afi
][safi
];
16554 case PEER_FT_DISTRIBUTE_LIST
:
16555 return !!(filter
->dlist
[direct
].name
);
16556 case PEER_FT_FILTER_LIST
:
16557 return !!(filter
->aslist
[direct
].name
);
16558 case PEER_FT_PREFIX_LIST
:
16559 return !!(filter
->plist
[direct
].name
);
16560 case PEER_FT_ROUTE_MAP
:
16561 return !!(filter
->map
[direct
].name
);
16562 case PEER_FT_UNSUPPRESS_MAP
:
16563 return !!(filter
->usmap
.name
);
16564 case PEER_FT_ADVERTISE_MAP
:
16565 return !!(filter
->advmap
.aname
16566 && ((filter
->advmap
.condition
== direct
)
16567 && filter
->advmap
.cname
));
16573 /* Return true if the addpath type is set for peer and different from
16576 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16579 enum bgp_addpath_strat type
, g_type
;
16581 type
= peer
->addpath_type
[afi
][safi
];
16583 if (type
!= BGP_ADDPATH_NONE
) {
16584 if (peer_group_active(peer
)) {
16585 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16587 if (type
!= g_type
)
16599 /* This is part of the address-family block (unicast only) */
16600 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16604 uint32_t tovpn_sid_index
= 0;
16606 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16607 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16608 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16609 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16610 bgp
->vpn_policy
[afi
]
16611 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16613 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16614 bgp
->vpn_policy
[afi
]
16615 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16617 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16618 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16619 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16620 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16623 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16624 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16626 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16629 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16630 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16631 bgp
->vpn_policy
[afi
].tovpn_label
);
16635 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16636 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16637 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16638 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16639 } else if (tovpn_sid_index
!= 0) {
16640 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16644 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16645 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16646 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16648 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16649 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16651 char buf
[PREFIX_STRLEN
];
16652 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16653 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16656 vty_out(vty
, "%*snexthop vpn export %s\n",
16660 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16661 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16663 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16664 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16666 char *b
= ecommunity_ecom2str(
16667 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16668 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16669 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16670 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16672 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16673 char *b
= ecommunity_ecom2str(
16674 bgp
->vpn_policy
[afi
]
16675 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16676 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16677 ECOMMUNITY_ROUTE_TARGET
);
16678 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16679 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16681 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16682 char *b
= ecommunity_ecom2str(
16683 bgp
->vpn_policy
[afi
]
16684 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16685 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16686 ECOMMUNITY_ROUTE_TARGET
);
16687 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16688 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16692 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16693 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16694 bgp
->vpn_policy
[afi
]
16695 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16697 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16698 char *b
= ecommunity_ecom2str(
16699 bgp
->vpn_policy
[afi
]
16700 .import_redirect_rtlist
,
16701 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16702 ECOMMUNITY_ROUTE_TARGET
);
16704 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16705 != ECOMMUNITY_SIZE
)
16706 vty_out(vty
, "%*srt6 redirect import %s\n",
16709 vty_out(vty
, "%*srt redirect import %s\n",
16711 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16715 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16716 afi_t afi
, safi_t safi
)
16718 struct bgp_filter
*filter
;
16722 filter
= &peer
->filter
[afi
][safi
];
16724 /* distribute-list. */
16725 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16727 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16728 filter
->dlist
[FILTER_IN
].name
);
16730 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16732 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16733 filter
->dlist
[FILTER_OUT
].name
);
16736 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16738 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16739 filter
->plist
[FILTER_IN
].name
);
16741 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16743 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16744 filter
->plist
[FILTER_OUT
].name
);
16747 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16748 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16749 filter
->map
[RMAP_IN
].name
);
16751 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16753 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16754 filter
->map
[RMAP_OUT
].name
);
16756 /* unsuppress-map */
16757 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16758 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16759 filter
->usmap
.name
);
16761 /* advertise-map : always applied in OUT direction*/
16762 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16763 CONDITION_NON_EXIST
))
16765 " neighbor %s advertise-map %s non-exist-map %s\n",
16766 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16768 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16770 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16771 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16774 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16776 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16777 filter
->aslist
[FILTER_IN
].name
);
16779 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16781 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16782 filter
->aslist
[FILTER_OUT
].name
);
16785 /* BGP peer configuration display function. */
16786 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16789 struct peer
*g_peer
= NULL
;
16791 int if_pg_printed
= false;
16792 int if_ras_printed
= false;
16794 /* Skip dynamic neighbors. */
16795 if (peer_dynamic_neighbor(peer
))
16799 addr
= peer
->conf_if
;
16803 /************************************
16804 ****** Global to the neighbor ******
16805 ************************************/
16806 if (peer
->conf_if
) {
16807 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16808 vty_out(vty
, " neighbor %s interface v6only", addr
);
16810 vty_out(vty
, " neighbor %s interface", addr
);
16812 if (peer_group_active(peer
)) {
16813 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16814 if_pg_printed
= true;
16815 } else if (peer
->as_type
== AS_SPECIFIED
) {
16816 vty_out(vty
, " remote-as %u", peer
->as
);
16817 if_ras_printed
= true;
16818 } else if (peer
->as_type
== AS_INTERNAL
) {
16819 vty_out(vty
, " remote-as internal");
16820 if_ras_printed
= true;
16821 } else if (peer
->as_type
== AS_EXTERNAL
) {
16822 vty_out(vty
, " remote-as external");
16823 if_ras_printed
= true;
16826 vty_out(vty
, "\n");
16829 /* remote-as and peer-group */
16830 /* peer is a member of a peer-group */
16831 if (peer_group_active(peer
)) {
16832 g_peer
= peer
->group
->conf
;
16834 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16835 if (peer
->as_type
== AS_SPECIFIED
) {
16836 vty_out(vty
, " neighbor %s remote-as %u\n",
16838 } else if (peer
->as_type
== AS_INTERNAL
) {
16840 " neighbor %s remote-as internal\n",
16842 } else if (peer
->as_type
== AS_EXTERNAL
) {
16844 " neighbor %s remote-as external\n",
16849 /* For swpX peers we displayed the peer-group
16850 * via 'neighbor swpX interface peer-group PGNAME' */
16851 if (!if_pg_printed
)
16852 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16853 peer
->group
->name
);
16856 /* peer is NOT a member of a peer-group */
16858 /* peer is a peer-group, declare the peer-group */
16859 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16860 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16863 if (!if_ras_printed
) {
16864 if (peer
->as_type
== AS_SPECIFIED
) {
16865 vty_out(vty
, " neighbor %s remote-as %u\n",
16867 } else if (peer
->as_type
== AS_INTERNAL
) {
16869 " neighbor %s remote-as internal\n",
16871 } else if (peer
->as_type
== AS_EXTERNAL
) {
16873 " neighbor %s remote-as external\n",
16880 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16881 vty_out(vty
, " neighbor %s local-as %u", addr
,
16882 peer
->change_local_as
);
16883 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16884 vty_out(vty
, " no-prepend");
16885 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16886 vty_out(vty
, " replace-as");
16887 vty_out(vty
, "\n");
16892 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16896 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16897 if (peer
->tx_shutdown_message
)
16898 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16899 peer
->tx_shutdown_message
);
16901 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16904 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16905 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16906 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16909 if (peer
->bfd_config
)
16910 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16913 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16914 vty_out(vty
, " neighbor %s password %s\n", addr
,
16917 /* neighbor solo */
16918 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16919 if (!peer_group_active(peer
)) {
16920 vty_out(vty
, " neighbor %s solo\n", addr
);
16925 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16926 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16929 /* Local interface name */
16930 if (peer
->ifname
) {
16931 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16934 /* TCP max segment size */
16935 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16936 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16939 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16940 vty_out(vty
, " neighbor %s passive\n", addr
);
16942 /* ebgp-multihop */
16943 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16944 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16945 && peer
->ttl
== MAXTTL
)) {
16946 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16947 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16953 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16954 peer
->local_role
!= ROLE_UNDEFINED
)
16955 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16956 bgp_get_name_by_role(peer
->local_role
),
16957 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16961 /* ttl-security hops */
16962 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16963 if (!peer_group_active(peer
)
16964 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16965 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16966 addr
, peer
->gtsm_hops
);
16970 /* disable-connected-check */
16971 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16972 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16974 /* link-bw-encoding-ieee */
16975 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16976 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16979 /* extended-optional-parameters */
16980 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16981 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16984 /* enforce-first-as */
16985 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16986 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16988 /* update-source */
16989 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16990 if (peer
->update_source
)
16991 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16992 peer
->update_source
);
16993 else if (peer
->update_if
)
16994 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16998 /* advertisement-interval */
16999 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17000 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17004 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17005 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17006 peer
->keepalive
, peer
->holdtime
);
17008 /* timers connect */
17009 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17010 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17012 /* need special-case handling for changed default values due to
17013 * config profile / version (because there is no "timers bgp connect"
17014 * command, we need to save this per-peer :/)
17016 else if (!peer_group_active(peer
) && !peer
->connect
&&
17017 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17018 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17019 peer
->bgp
->default_connect_retry
);
17021 /* timers delayopen */
17022 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17023 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17025 /* Save config even though flag is not set if default values have been
17028 else if (!peer_group_active(peer
) && !peer
->delayopen
17029 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17030 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17031 peer
->bgp
->default_delayopen
);
17033 /* capability dynamic */
17034 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17035 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17037 /* capability extended-nexthop */
17038 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17039 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17042 " no neighbor %s capability extended-nexthop\n",
17044 else if (!peer
->conf_if
)
17046 " neighbor %s capability extended-nexthop\n",
17050 /* dont-capability-negotiation */
17051 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17052 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17054 /* override-capability */
17055 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17056 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17058 /* strict-capability-match */
17059 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17060 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17062 /* Sender side AS path loop detection. */
17063 if (peer
->as_path_loop_detection
)
17064 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17067 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17068 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17070 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17071 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17073 " neighbor %s graceful-restart-helper\n", addr
);
17074 } else if (CHECK_FLAG(
17075 peer
->peer_gr_new_status_flag
,
17076 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17078 " neighbor %s graceful-restart\n", addr
);
17080 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17081 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17083 peer
->peer_gr_new_status_flag
,
17084 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17085 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17091 /* BGP peer configuration display function. */
17092 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17093 struct peer
*peer
, afi_t afi
, safi_t safi
)
17095 struct peer
*g_peer
= NULL
;
17097 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17099 /* Skip dynamic neighbors. */
17100 if (peer_dynamic_neighbor(peer
))
17104 addr
= peer
->conf_if
;
17108 /************************************
17109 ****** Per AF to the neighbor ******
17110 ************************************/
17111 if (peer_group_active(peer
)) {
17112 g_peer
= peer
->group
->conf
;
17114 /* If the peer-group is active but peer is not, print a 'no
17116 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17117 vty_out(vty
, " no neighbor %s activate\n", addr
);
17120 /* If the peer-group is not active but peer is, print an
17122 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17123 vty_out(vty
, " neighbor %s activate\n", addr
);
17126 if (peer
->afc
[afi
][safi
]) {
17127 if (safi
== SAFI_ENCAP
)
17128 vty_out(vty
, " neighbor %s activate\n", addr
);
17129 else if (!bgp
->default_af
[afi
][safi
])
17130 vty_out(vty
, " neighbor %s activate\n", addr
);
17132 if (bgp
->default_af
[afi
][safi
])
17133 vty_out(vty
, " no neighbor %s activate\n",
17138 /* addpath TX knobs */
17139 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17140 switch (peer
->addpath_type
[afi
][safi
]) {
17141 case BGP_ADDPATH_ALL
:
17142 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17145 case BGP_ADDPATH_BEST_PER_AS
:
17147 " neighbor %s addpath-tx-bestpath-per-AS\n",
17150 case BGP_ADDPATH_MAX
:
17151 case BGP_ADDPATH_NONE
:
17156 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17157 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17159 /* ORF capability. */
17160 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17161 || peergroup_af_flag_check(peer
, afi
, safi
,
17162 PEER_FLAG_ORF_PREFIX_RM
)) {
17163 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17165 if (peergroup_af_flag_check(peer
, afi
, safi
,
17166 PEER_FLAG_ORF_PREFIX_SM
)
17167 && peergroup_af_flag_check(peer
, afi
, safi
,
17168 PEER_FLAG_ORF_PREFIX_RM
))
17169 vty_out(vty
, " both");
17170 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17171 PEER_FLAG_ORF_PREFIX_SM
))
17172 vty_out(vty
, " send");
17174 vty_out(vty
, " receive");
17175 vty_out(vty
, "\n");
17178 /* Route reflector client. */
17179 if (peergroup_af_flag_check(peer
, afi
, safi
,
17180 PEER_FLAG_REFLECTOR_CLIENT
)) {
17181 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17184 /* next-hop-self force */
17185 if (peergroup_af_flag_check(peer
, afi
, safi
,
17186 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17187 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17190 /* next-hop-self */
17191 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17192 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17195 /* remove-private-AS */
17196 if (peergroup_af_flag_check(peer
, afi
, safi
,
17197 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17198 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17202 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17203 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17204 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17208 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17209 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17210 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17213 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17214 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17215 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17219 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17220 vty_out(vty
, " neighbor %s as-override\n", addr
);
17223 /* send-community print. */
17224 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17225 PEER_FLAG_SEND_COMMUNITY
);
17226 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17227 PEER_FLAG_SEND_EXT_COMMUNITY
);
17228 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17229 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17231 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17232 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17235 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17238 " no neighbor %s send-community extended\n",
17242 vty_out(vty
, " no neighbor %s send-community large\n",
17246 /* Default information */
17247 if (peergroup_af_flag_check(peer
, afi
, safi
,
17248 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17249 vty_out(vty
, " neighbor %s default-originate", addr
);
17251 if (peer
->default_rmap
[afi
][safi
].name
)
17252 vty_out(vty
, " route-map %s",
17253 peer
->default_rmap
[afi
][safi
].name
);
17255 vty_out(vty
, "\n");
17258 /* Soft reconfiguration inbound. */
17259 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17260 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17264 /* maximum-prefix. */
17265 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17266 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17267 peer
->pmax
[afi
][safi
]);
17269 if (peer
->pmax_threshold
[afi
][safi
]
17270 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17271 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17272 if (peer_af_flag_check(peer
, afi
, safi
,
17273 PEER_FLAG_MAX_PREFIX_WARNING
))
17274 vty_out(vty
, " warning-only");
17275 if (peer
->pmax_restart
[afi
][safi
])
17276 vty_out(vty
, " restart %u",
17277 peer
->pmax_restart
[afi
][safi
]);
17278 if (peer_af_flag_check(peer
, afi
, safi
,
17279 PEER_FLAG_MAX_PREFIX_FORCE
))
17280 vty_out(vty
, " force");
17282 vty_out(vty
, "\n");
17285 /* maximum-prefix-out */
17286 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17287 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17288 addr
, peer
->pmax_out
[afi
][safi
]);
17290 /* Route server client. */
17291 if (peergroup_af_flag_check(peer
, afi
, safi
,
17292 PEER_FLAG_RSERVER_CLIENT
)) {
17293 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17296 /* Nexthop-local unchanged. */
17297 if (peergroup_af_flag_check(peer
, afi
, safi
,
17298 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17299 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17302 /* allowas-in <1-10> */
17303 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17304 if (peer_af_flag_check(peer
, afi
, safi
,
17305 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17306 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17307 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17308 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17310 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17311 peer
->allowas_in
[afi
][safi
]);
17316 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17317 char *soo_str
= ecommunity_ecom2str(
17318 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17320 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17321 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17325 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17326 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17327 peer
->weight
[afi
][safi
]);
17330 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17332 /* atribute-unchanged. */
17333 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17334 || (safi
!= SAFI_EVPN
17335 && peer_af_flag_check(peer
, afi
, safi
,
17336 PEER_FLAG_NEXTHOP_UNCHANGED
))
17337 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17339 if (!peer_group_active(peer
)
17340 || peergroup_af_flag_check(peer
, afi
, safi
,
17341 PEER_FLAG_AS_PATH_UNCHANGED
)
17342 || peergroup_af_flag_check(peer
, afi
, safi
,
17343 PEER_FLAG_NEXTHOP_UNCHANGED
)
17344 || peergroup_af_flag_check(peer
, afi
, safi
,
17345 PEER_FLAG_MED_UNCHANGED
)) {
17348 " neighbor %s attribute-unchanged%s%s%s\n",
17350 peer_af_flag_check(peer
, afi
, safi
,
17351 PEER_FLAG_AS_PATH_UNCHANGED
)
17354 peer_af_flag_check(peer
, afi
, safi
,
17355 PEER_FLAG_NEXTHOP_UNCHANGED
)
17358 peer_af_flag_check(peer
, afi
, safi
,
17359 PEER_FLAG_MED_UNCHANGED
)
17366 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17369 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17370 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17371 vty_out(vty
, " no bgp retain route-target all\n");
17374 /* Address family based peer configuration display. */
17375 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17379 struct peer_group
*group
;
17380 struct listnode
*node
, *nnode
;
17383 vty_frame(vty
, " !\n address-family ");
17384 if (afi
== AFI_IP
) {
17385 if (safi
== SAFI_UNICAST
)
17386 vty_frame(vty
, "ipv4 unicast");
17387 else if (safi
== SAFI_LABELED_UNICAST
)
17388 vty_frame(vty
, "ipv4 labeled-unicast");
17389 else if (safi
== SAFI_MULTICAST
)
17390 vty_frame(vty
, "ipv4 multicast");
17391 else if (safi
== SAFI_MPLS_VPN
)
17392 vty_frame(vty
, "ipv4 vpn");
17393 else if (safi
== SAFI_ENCAP
)
17394 vty_frame(vty
, "ipv4 encap");
17395 else if (safi
== SAFI_FLOWSPEC
)
17396 vty_frame(vty
, "ipv4 flowspec");
17397 } else if (afi
== AFI_IP6
) {
17398 if (safi
== SAFI_UNICAST
)
17399 vty_frame(vty
, "ipv6 unicast");
17400 else if (safi
== SAFI_LABELED_UNICAST
)
17401 vty_frame(vty
, "ipv6 labeled-unicast");
17402 else if (safi
== SAFI_MULTICAST
)
17403 vty_frame(vty
, "ipv6 multicast");
17404 else if (safi
== SAFI_MPLS_VPN
)
17405 vty_frame(vty
, "ipv6 vpn");
17406 else if (safi
== SAFI_ENCAP
)
17407 vty_frame(vty
, "ipv6 encap");
17408 else if (safi
== SAFI_FLOWSPEC
)
17409 vty_frame(vty
, "ipv6 flowspec");
17410 } else if (afi
== AFI_L2VPN
) {
17411 if (safi
== SAFI_EVPN
)
17412 vty_frame(vty
, "l2vpn evpn");
17414 vty_frame(vty
, "\n");
17416 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17418 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17420 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17422 /* BGP flag dampening. */
17423 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17424 bgp_config_write_damp(vty
, afi
, safi
);
17426 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17427 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17429 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17430 /* Do not display doppelganger peers */
17431 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17432 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17435 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17436 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17438 if (safi
== SAFI_EVPN
)
17439 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17441 if (safi
== SAFI_FLOWSPEC
)
17442 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17444 if (safi
== SAFI_MPLS_VPN
)
17445 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17447 if (safi
== SAFI_UNICAST
) {
17448 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17449 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17450 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17452 vty_out(vty
, " export vpn\n");
17454 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17455 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17457 vty_out(vty
, " import vpn\n");
17459 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17460 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17463 for (ALL_LIST_ELEMENTS_RO(
17464 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17466 vty_out(vty
, " import vrf %s\n", name
);
17470 vty_endframe(vty
, " exit-address-family\n");
17473 int bgp_config_write(struct vty
*vty
)
17476 struct peer_group
*group
;
17478 struct listnode
*node
, *nnode
;
17479 struct listnode
*mnode
, *mnnode
;
17483 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17484 vty_out(vty
, "bgp route-map delay-timer %u\n",
17485 bm
->rmap_update_timer
);
17487 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17488 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17489 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17490 vty_out(vty
, " %d", bm
->v_establish_wait
);
17491 vty_out(vty
, "\n");
17494 if (bm
->wait_for_fib
)
17495 vty_out(vty
, "bgp suppress-fib-pending\n");
17497 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17498 vty_out(vty
, "bgp graceful-shutdown\n");
17500 /* No-RIB (Zebra) option flag configuration */
17501 if (bgp_option_check(BGP_OPT_NO_FIB
))
17502 vty_out(vty
, "bgp no-rib\n");
17504 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17505 vty_out(vty
, "bgp send-extra-data zebra\n");
17507 /* BGP session DSCP value */
17508 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17509 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17511 /* BGP configuration. */
17512 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17514 /* skip all auto created vrf as they dont have user config */
17515 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17518 /* Router bgp ASN */
17519 vty_out(vty
, "router bgp %u", bgp
->as
);
17522 vty_out(vty
, " %s %s",
17523 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17524 ? "view" : "vrf", bgp
->name
);
17525 vty_out(vty
, "\n");
17527 /* BGP fast-external-failover. */
17528 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17529 vty_out(vty
, " no bgp fast-external-failover\n");
17531 /* BGP router ID. */
17532 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17533 vty_out(vty
, " bgp router-id %pI4\n",
17534 &bgp
->router_id_static
);
17536 /* Suppress fib pending */
17537 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17538 vty_out(vty
, " bgp suppress-fib-pending\n");
17540 /* BGP log-neighbor-changes. */
17541 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17542 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17543 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17544 CHECK_FLAG(bgp
->flags
,
17545 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17549 /* BGP configuration. */
17550 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17551 vty_out(vty
, " bgp always-compare-med\n");
17553 /* RFC8212 default eBGP policy. */
17554 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17555 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17556 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17557 CHECK_FLAG(bgp
->flags
,
17558 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17562 /* draft-ietf-idr-deprecate-as-set-confed-set */
17563 if (bgp
->reject_as_sets
)
17564 vty_out(vty
, " bgp reject-as-sets\n");
17566 /* Suppress duplicate updates if the route actually not changed
17568 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17569 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17570 vty_out(vty
, " %sbgp suppress-duplicates\n",
17571 CHECK_FLAG(bgp
->flags
,
17572 BGP_FLAG_SUPPRESS_DUPLICATES
)
17576 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17578 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17579 SAVE_BGP_HARD_ADMIN_RESET
)
17580 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17581 CHECK_FLAG(bgp
->flags
,
17582 BGP_FLAG_HARD_ADMIN_RESET
)
17586 /* BGP default <afi>-<safi> */
17587 FOREACH_AFI_SAFI (afi
, safi
) {
17588 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17589 if (!bgp
->default_af
[afi
][safi
])
17590 vty_out(vty
, " no bgp default %s\n",
17591 get_bgp_default_af_flag(afi
,
17593 } else if (bgp
->default_af
[afi
][safi
])
17594 vty_out(vty
, " bgp default %s\n",
17595 get_bgp_default_af_flag(afi
, safi
));
17598 /* BGP default local-preference. */
17599 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17600 vty_out(vty
, " bgp default local-preference %u\n",
17601 bgp
->default_local_pref
);
17603 /* BGP default show-hostname */
17604 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17605 != SAVE_BGP_SHOW_HOSTNAME
)
17606 vty_out(vty
, " %sbgp default show-hostname\n",
17607 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17611 /* BGP default show-nexthop-hostname */
17612 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17613 != SAVE_BGP_SHOW_HOSTNAME
)
17614 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17615 CHECK_FLAG(bgp
->flags
,
17616 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17620 /* BGP default subgroup-pkt-queue-max. */
17621 if (bgp
->default_subgroup_pkt_queue_max
17622 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17623 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17624 bgp
->default_subgroup_pkt_queue_max
);
17626 /* BGP client-to-client reflection. */
17627 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17628 vty_out(vty
, " no bgp client-to-client reflection\n");
17630 /* BGP cluster ID. */
17631 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17632 vty_out(vty
, " bgp cluster-id %pI4\n",
17635 /* Disable ebgp connected nexthop check */
17636 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17638 " bgp disable-ebgp-connected-route-check\n");
17640 /* Confederation identifier*/
17641 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17642 vty_out(vty
, " bgp confederation identifier %u\n",
17645 /* Confederation peer */
17646 if (bgp
->confed_peers_cnt
> 0) {
17649 vty_out(vty
, " bgp confederation peers");
17651 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17652 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17654 vty_out(vty
, "\n");
17657 /* BGP deterministic-med. */
17658 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17659 != SAVE_BGP_DETERMINISTIC_MED
)
17660 vty_out(vty
, " %sbgp deterministic-med\n",
17661 CHECK_FLAG(bgp
->flags
,
17662 BGP_FLAG_DETERMINISTIC_MED
)
17666 /* BGP update-delay. */
17667 bgp_config_write_update_delay(vty
, bgp
);
17669 if (bgp
->v_maxmed_onstartup
17670 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17671 vty_out(vty
, " bgp max-med on-startup %u",
17672 bgp
->v_maxmed_onstartup
);
17673 if (bgp
->maxmed_onstartup_value
17674 != BGP_MAXMED_VALUE_DEFAULT
)
17675 vty_out(vty
, " %u",
17676 bgp
->maxmed_onstartup_value
);
17677 vty_out(vty
, "\n");
17679 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17680 vty_out(vty
, " bgp max-med administrative");
17681 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17682 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17683 vty_out(vty
, "\n");
17687 bgp_config_write_wpkt_quanta(vty
, bgp
);
17689 bgp_config_write_rpkt_quanta(vty
, bgp
);
17691 /* coalesce time */
17692 bgp_config_write_coalesce_time(vty
, bgp
);
17694 /* BGP per-instance graceful-shutdown */
17695 /* BGP-wide settings and per-instance settings are mutually
17698 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17699 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17700 vty_out(vty
, " bgp graceful-shutdown\n");
17702 /* Long-lived Graceful Restart */
17703 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17705 " bgp long-lived-graceful-restart stale-time %u\n",
17706 bgp
->llgr_stale_time
);
17708 /* BGP graceful-restart. */
17709 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17711 " bgp graceful-restart stalepath-time %u\n",
17712 bgp
->stalepath_time
);
17714 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17715 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17716 bgp
->restart_time
);
17718 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17719 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17720 vty_out(vty
, " %sbgp graceful-restart notification\n",
17721 CHECK_FLAG(bgp
->flags
,
17722 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17726 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17728 " bgp graceful-restart select-defer-time %u\n",
17729 bgp
->select_defer_time
);
17731 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17732 vty_out(vty
, " bgp graceful-restart\n");
17734 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17735 vty_out(vty
, " bgp graceful-restart-disable\n");
17737 /* BGP graceful-restart Preserve State F bit. */
17738 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17740 " bgp graceful-restart preserve-fw-state\n");
17742 /* BGP TCP keepalive */
17743 bgp_config_tcp_keepalive(vty
, bgp
);
17745 /* Stale timer for RIB */
17746 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17748 " bgp graceful-restart rib-stale-time %u\n",
17749 bgp
->rib_stale_time
);
17751 /* BGP bestpath method. */
17752 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17753 vty_out(vty
, " bgp bestpath as-path ignore\n");
17754 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17755 vty_out(vty
, " bgp bestpath as-path confed\n");
17757 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17758 if (CHECK_FLAG(bgp
->flags
,
17759 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17761 " bgp bestpath as-path multipath-relax as-set\n");
17764 " bgp bestpath as-path multipath-relax\n");
17768 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17770 " bgp route-reflector allow-outbound-policy\n");
17772 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17773 vty_out(vty
, " bgp bestpath compare-routerid\n");
17774 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17775 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17776 vty_out(vty
, " bgp bestpath med");
17777 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17778 vty_out(vty
, " confed");
17779 if (CHECK_FLAG(bgp
->flags
,
17780 BGP_FLAG_MED_MISSING_AS_WORST
))
17781 vty_out(vty
, " missing-as-worst");
17782 vty_out(vty
, "\n");
17785 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17787 " bgp bestpath peer-type multipath-relax\n");
17789 /* Link bandwidth handling. */
17790 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17791 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17792 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17793 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17794 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17795 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17797 /* BGP network import check. */
17798 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17799 != SAVE_BGP_IMPORT_CHECK
)
17800 vty_out(vty
, " %sbgp network import-check\n",
17801 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17805 /* BGP timers configuration. */
17806 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17807 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17808 vty_out(vty
, " timers bgp %u %u\n",
17809 bgp
->default_keepalive
, bgp
->default_holdtime
);
17811 /* BGP minimum holdtime configuration. */
17812 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17813 && bgp
->default_min_holdtime
!= 0)
17814 vty_out(vty
, " bgp minimum-holdtime %u\n",
17815 bgp
->default_min_holdtime
);
17817 /* Conditional advertisement timer configuration */
17818 if (bgp
->condition_check_period
17819 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17821 " bgp conditional-advertisement timer %u\n",
17822 bgp
->condition_check_period
);
17825 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17826 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17829 /* Normal neighbor configuration. */
17830 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17831 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17832 bgp_config_write_peer_global(vty
, bgp
, peer
);
17835 /* listen range and limit for dynamic BGP neighbors */
17836 bgp_config_write_listen(vty
, bgp
);
17839 * BGP default autoshutdown neighbors
17841 * This must be placed after any peer and peer-group
17842 * configuration, to avoid setting all peers to shutdown after
17843 * a daemon restart, which is undesired behavior. (see #2286)
17845 if (bgp
->autoshutdown
)
17846 vty_out(vty
, " bgp default shutdown\n");
17848 /* BGP instance administrative shutdown */
17849 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17850 vty_out(vty
, " bgp shutdown\n");
17852 if (bgp
->allow_martian
)
17853 vty_out(vty
, " bgp allow-martian-nexthop\n");
17855 if (bgp
->fast_convergence
)
17856 vty_out(vty
, " bgp fast-convergence\n");
17858 if (bgp
->srv6_enabled
) {
17859 vty_frame(vty
, " !\n segment-routing srv6\n");
17860 if (strlen(bgp
->srv6_locator_name
))
17861 vty_out(vty
, " locator %s\n",
17862 bgp
->srv6_locator_name
);
17863 vty_endframe(vty
, " exit\n");
17867 /* IPv4 unicast configuration. */
17868 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17870 /* IPv4 multicast configuration. */
17871 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17873 /* IPv4 labeled-unicast configuration. */
17874 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17876 /* IPv4 VPN configuration. */
17877 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17879 /* ENCAPv4 configuration. */
17880 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17882 /* FLOWSPEC v4 configuration. */
17883 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17885 /* IPv6 unicast configuration. */
17886 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17888 /* IPv6 multicast configuration. */
17889 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17891 /* IPv6 labeled-unicast configuration. */
17892 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17893 SAFI_LABELED_UNICAST
);
17895 /* IPv6 VPN configuration. */
17896 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17898 /* ENCAPv6 configuration. */
17899 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17901 /* FLOWSPEC v6 configuration. */
17902 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17904 /* EVPN configuration. */
17905 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17907 hook_call(bgp_inst_config_write
, bgp
, vty
);
17909 #ifdef ENABLE_BGP_VNC
17910 bgp_rfapi_cfg_write(vty
, bgp
);
17913 vty_out(vty
, "exit\n");
17914 vty_out(vty
, "!\n");
17920 /* BGP node structure. */
17921 static struct cmd_node bgp_node
= {
17924 .parent_node
= CONFIG_NODE
,
17925 .prompt
= "%s(config-router)# ",
17926 .config_write
= bgp_config_write
,
17929 static struct cmd_node bgp_ipv4_unicast_node
= {
17930 .name
= "bgp ipv4 unicast",
17931 .node
= BGP_IPV4_NODE
,
17932 .parent_node
= BGP_NODE
,
17933 .prompt
= "%s(config-router-af)# ",
17937 static struct cmd_node bgp_ipv4_multicast_node
= {
17938 .name
= "bgp ipv4 multicast",
17939 .node
= BGP_IPV4M_NODE
,
17940 .parent_node
= BGP_NODE
,
17941 .prompt
= "%s(config-router-af)# ",
17945 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17946 .name
= "bgp ipv4 labeled unicast",
17947 .node
= BGP_IPV4L_NODE
,
17948 .parent_node
= BGP_NODE
,
17949 .prompt
= "%s(config-router-af)# ",
17953 static struct cmd_node bgp_ipv6_unicast_node
= {
17954 .name
= "bgp ipv6 unicast",
17955 .node
= BGP_IPV6_NODE
,
17956 .parent_node
= BGP_NODE
,
17957 .prompt
= "%s(config-router-af)# ",
17961 static struct cmd_node bgp_ipv6_multicast_node
= {
17962 .name
= "bgp ipv6 multicast",
17963 .node
= BGP_IPV6M_NODE
,
17964 .parent_node
= BGP_NODE
,
17965 .prompt
= "%s(config-router-af)# ",
17969 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17970 .name
= "bgp ipv6 labeled unicast",
17971 .node
= BGP_IPV6L_NODE
,
17972 .parent_node
= BGP_NODE
,
17973 .prompt
= "%s(config-router-af)# ",
17977 static struct cmd_node bgp_vpnv4_node
= {
17978 .name
= "bgp vpnv4",
17979 .node
= BGP_VPNV4_NODE
,
17980 .parent_node
= BGP_NODE
,
17981 .prompt
= "%s(config-router-af)# ",
17985 static struct cmd_node bgp_vpnv6_node
= {
17986 .name
= "bgp vpnv6",
17987 .node
= BGP_VPNV6_NODE
,
17988 .parent_node
= BGP_NODE
,
17989 .prompt
= "%s(config-router-af-vpnv6)# ",
17993 static struct cmd_node bgp_evpn_node
= {
17994 .name
= "bgp evpn",
17995 .node
= BGP_EVPN_NODE
,
17996 .parent_node
= BGP_NODE
,
17997 .prompt
= "%s(config-router-evpn)# ",
18001 static struct cmd_node bgp_evpn_vni_node
= {
18002 .name
= "bgp evpn vni",
18003 .node
= BGP_EVPN_VNI_NODE
,
18004 .parent_node
= BGP_EVPN_NODE
,
18005 .prompt
= "%s(config-router-af-vni)# ",
18008 static struct cmd_node bgp_flowspecv4_node
= {
18009 .name
= "bgp ipv4 flowspec",
18010 .node
= BGP_FLOWSPECV4_NODE
,
18011 .parent_node
= BGP_NODE
,
18012 .prompt
= "%s(config-router-af)# ",
18016 static struct cmd_node bgp_flowspecv6_node
= {
18017 .name
= "bgp ipv6 flowspec",
18018 .node
= BGP_FLOWSPECV6_NODE
,
18019 .parent_node
= BGP_NODE
,
18020 .prompt
= "%s(config-router-af-vpnv6)# ",
18024 static struct cmd_node bgp_srv6_node
= {
18025 .name
= "bgp srv6",
18026 .node
= BGP_SRV6_NODE
,
18027 .parent_node
= BGP_NODE
,
18028 .prompt
= "%s(config-router-srv6)# ",
18031 static void community_list_vty(void);
18033 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18036 struct peer_group
*group
;
18037 struct listnode
*lnbgp
, *lnpeer
;
18039 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18040 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18042 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18046 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18050 struct listnode
*lnbgp
, *lnpeer
;
18052 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18053 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18054 /* only provide suggestions on the appropriate input
18056 * they'll otherwise show up multiple times */
18057 enum cmd_token_type match_type
;
18058 char *name
= peer
->host
;
18060 if (peer
->conf_if
) {
18061 match_type
= VARIABLE_TKN
;
18062 name
= peer
->conf_if
;
18063 } else if (strchr(peer
->host
, ':'))
18064 match_type
= IPV6_TKN
;
18066 match_type
= IPV4_TKN
;
18068 if (token
->type
!= match_type
)
18071 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18076 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18078 bgp_ac_peer(comps
, token
);
18080 if (token
->type
== VARIABLE_TKN
)
18081 bgp_ac_peergroup(comps
, token
);
18084 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18085 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18086 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18087 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18088 {.completions
= NULL
}};
18090 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18091 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18092 {.completions
= NULL
} };
18094 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18096 static struct thread
*t_bgp_cfg
;
18098 bool bgp_config_inprocess(void)
18100 return thread_is_scheduled(t_bgp_cfg
);
18103 static void bgp_config_finish(struct thread
*t
)
18105 struct listnode
*node
;
18108 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18109 hook_call(bgp_config_end
, bgp
);
18112 static void bgp_config_start(void)
18114 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18115 THREAD_OFF(t_bgp_cfg
);
18116 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18117 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18120 /* When we receive a hook the configuration is read,
18121 * we start a timer to make sure we postpone sending
18122 * EoR before route-maps are processed.
18123 * This is especially valid if using `bgp route-map delay-timer`.
18125 static void bgp_config_end(void)
18127 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18128 uint32_t bgp_post_config_delay
=
18129 thread_is_scheduled(bm
->t_rmap_update
)
18130 ? thread_timer_remain_second(bm
->t_rmap_update
)
18131 : BGP_POST_CONFIG_DELAY_SECONDS
;
18133 /* If BGP config processing thread isn't running, then
18134 * we can return and rely it's properly handled.
18136 if (!bgp_config_inprocess())
18139 THREAD_OFF(t_bgp_cfg
);
18141 /* Start a new timer to make sure we don't send EoR
18142 * before route-maps are processed.
18144 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18145 bgp_post_config_delay
, &t_bgp_cfg
);
18148 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18151 struct interface
*ifp
;
18152 struct bgp_interface
*iifp
;
18154 FOR_ALL_INTERFACES (vrf
, ifp
) {
18159 if_vty_config_start(vty
, ifp
);
18161 if (CHECK_FLAG(iifp
->flags
,
18162 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18163 vty_out(vty
, " mpls bgp forwarding\n");
18167 if_vty_config_end(vty
);
18173 /* Configuration write function for bgpd. */
18174 static int config_write_interface(struct vty
*vty
)
18177 struct vrf
*vrf
= NULL
;
18179 /* Display all VRF aware OSPF interface configuration */
18180 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18181 write
+= config_write_interface_one(vty
, vrf
);
18187 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18188 "[no$no] mpls bgp forwarding",
18189 NO_STR MPLS_STR BGP_STR
18190 "Enable MPLS forwarding for eBGP directly connected peers\n")
18193 struct bgp_interface
*iifp
;
18195 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18198 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18199 return CMD_WARNING_CONFIG_FAILED
;
18201 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18202 if (check
!= !no
) {
18204 UNSET_FLAG(iifp
->flags
,
18205 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18207 SET_FLAG(iifp
->flags
,
18208 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18209 /* trigger a nht update on eBGP sessions */
18210 if (if_is_operative(ifp
))
18211 bgp_nht_ifp_up(ifp
);
18213 return CMD_SUCCESS
;
18216 /* Initialization of BGP interface. */
18217 static void bgp_vty_if_init(void)
18219 /* Install interface node. */
18220 if_cmd_init(config_write_interface
);
18222 /* "mpls bgp forwarding" commands. */
18223 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18226 void bgp_vty_init(void)
18228 cmd_variable_handler_register(bgp_var_neighbor
);
18229 cmd_variable_handler_register(bgp_var_peergroup
);
18231 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18233 /* Install bgp top node. */
18234 install_node(&bgp_node
);
18235 install_node(&bgp_ipv4_unicast_node
);
18236 install_node(&bgp_ipv4_multicast_node
);
18237 install_node(&bgp_ipv4_labeled_unicast_node
);
18238 install_node(&bgp_ipv6_unicast_node
);
18239 install_node(&bgp_ipv6_multicast_node
);
18240 install_node(&bgp_ipv6_labeled_unicast_node
);
18241 install_node(&bgp_vpnv4_node
);
18242 install_node(&bgp_vpnv6_node
);
18243 install_node(&bgp_evpn_node
);
18244 install_node(&bgp_evpn_vni_node
);
18245 install_node(&bgp_flowspecv4_node
);
18246 install_node(&bgp_flowspecv6_node
);
18247 install_node(&bgp_srv6_node
);
18249 /* Install default VTY commands to new nodes. */
18250 install_default(BGP_NODE
);
18251 install_default(BGP_IPV4_NODE
);
18252 install_default(BGP_IPV4M_NODE
);
18253 install_default(BGP_IPV4L_NODE
);
18254 install_default(BGP_IPV6_NODE
);
18255 install_default(BGP_IPV6M_NODE
);
18256 install_default(BGP_IPV6L_NODE
);
18257 install_default(BGP_VPNV4_NODE
);
18258 install_default(BGP_VPNV6_NODE
);
18259 install_default(BGP_FLOWSPECV4_NODE
);
18260 install_default(BGP_FLOWSPECV6_NODE
);
18261 install_default(BGP_EVPN_NODE
);
18262 install_default(BGP_EVPN_VNI_NODE
);
18263 install_default(BGP_SRV6_NODE
);
18265 /* "bgp local-mac" hidden commands. */
18266 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18267 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18269 /* "bgp suppress-fib-pending" global */
18270 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18272 /* bgp route-map delay-timer commands. */
18273 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18274 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18276 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18278 /* bgp fast-convergence command */
18279 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18280 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18282 /* global bgp update-delay command */
18283 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18284 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18286 /* global bgp graceful-shutdown command */
18287 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18288 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18290 /* Dummy commands (Currently not supported) */
18291 install_element(BGP_NODE
, &no_synchronization_cmd
);
18292 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18294 /* "router bgp" commands. */
18295 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18297 /* "no router bgp" commands. */
18298 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18300 /* "bgp session-dscp command */
18301 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18302 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18304 /* "bgp router-id" commands. */
18305 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18306 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18308 /* "bgp suppress-fib-pending" command */
18309 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18311 /* "bgp cluster-id" commands. */
18312 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18313 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18315 /* "bgp no-rib" commands. */
18316 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18317 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18319 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18321 /* "bgp confederation" commands. */
18322 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18323 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18325 /* "bgp confederation peers" commands. */
18326 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18327 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18329 /* bgp max-med command */
18330 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18331 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18332 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18333 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18334 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18336 /* "neighbor role" commands. */
18337 install_element(BGP_NODE
, &neighbor_role_cmd
);
18338 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18339 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18341 /* bgp disable-ebgp-connected-nh-check */
18342 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18343 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18345 /* bgp update-delay command */
18346 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18347 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18349 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18350 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18352 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18353 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18355 /* "maximum-paths" commands. */
18356 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18357 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18358 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18359 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18360 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18361 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18362 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18363 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18364 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18365 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18366 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18367 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18368 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18369 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18370 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18372 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18373 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18374 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18375 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18376 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18377 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18378 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18379 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18380 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18381 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18383 /* "timers bgp" commands. */
18384 install_element(BGP_NODE
, &bgp_timers_cmd
);
18385 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18387 /* "minimum-holdtime" commands. */
18388 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18389 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18391 /* route-map delay-timer commands - per instance for backwards compat.
18393 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18394 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18396 /* "bgp client-to-client reflection" commands */
18397 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18398 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18400 /* "bgp always-compare-med" commands */
18401 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18402 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18404 /* bgp ebgp-requires-policy */
18405 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18406 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18408 /* bgp suppress-duplicates */
18409 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18410 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18412 /* bgp reject-as-sets */
18413 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18414 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18416 /* "bgp deterministic-med" commands */
18417 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18418 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18420 /* "bgp graceful-restart" command */
18421 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18422 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18424 /* "bgp graceful-restart-disable" command */
18425 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18426 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18428 /* "neighbor a:b:c:d graceful-restart" command */
18429 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18430 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18432 /* "neighbor a:b:c:d graceful-restart-disable" command */
18433 install_element(BGP_NODE
,
18434 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18435 install_element(BGP_NODE
,
18436 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18438 /* "neighbor a:b:c:d graceful-restart-helper" command */
18439 install_element(BGP_NODE
,
18440 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18441 install_element(BGP_NODE
,
18442 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18444 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18445 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18446 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18447 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18448 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18449 install_element(BGP_NODE
,
18450 &no_bgp_graceful_restart_select_defer_time_cmd
);
18451 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18452 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18453 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18455 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18456 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18457 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18458 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18460 /* "bgp graceful-shutdown" commands */
18461 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18462 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18464 /* "bgp hard-administrative-reset" commands */
18465 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18467 /* "bgp long-lived-graceful-restart" commands */
18468 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18469 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18471 /* "bgp fast-external-failover" commands */
18472 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18473 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18475 /* "bgp bestpath compare-routerid" commands */
18476 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18477 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18479 /* "bgp bestpath as-path ignore" commands */
18480 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18481 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18483 /* "bgp bestpath as-path confed" commands */
18484 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18485 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18487 /* "bgp bestpath as-path multipath-relax" commands */
18488 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18489 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18491 /* "bgp bestpath peer-type multipath-relax" commands */
18492 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18493 install_element(BGP_NODE
,
18494 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18496 /* "bgp log-neighbor-changes" commands */
18497 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18498 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18500 /* "bgp bestpath med" commands */
18501 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18502 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18504 /* "bgp bestpath bandwidth" commands */
18505 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18506 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18508 /* "no bgp default <afi>-<safi>" commands. */
18509 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18511 /* "bgp network import-check" commands. */
18512 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18513 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18514 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18516 /* "bgp default local-preference" commands. */
18517 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18518 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18520 /* bgp default show-hostname */
18521 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18522 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18524 /* bgp default show-nexthop-hostname */
18525 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18526 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18528 /* "bgp default subgroup-pkt-queue-max" commands. */
18529 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18530 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18532 /* bgp ibgp-allow-policy-mods command */
18533 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18534 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18536 /* "bgp listen limit" commands. */
18537 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18538 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18540 /* "bgp listen range" commands. */
18541 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18542 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18544 /* "bgp default shutdown" command */
18545 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18547 /* "bgp shutdown" commands */
18548 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18549 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18550 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18551 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18553 /* "neighbor remote-as" commands. */
18554 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18555 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18556 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18557 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18558 install_element(BGP_NODE
,
18559 &neighbor_interface_v6only_config_remote_as_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_cmd
);
18561 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18563 /* "neighbor peer-group" commands. */
18564 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18565 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18566 install_element(BGP_NODE
,
18567 &no_neighbor_interface_peer_group_remote_as_cmd
);
18569 /* "neighbor local-as" commands. */
18570 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18571 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18572 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18573 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18575 /* "neighbor solo" commands. */
18576 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18577 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18579 /* "neighbor password" commands. */
18580 install_element(BGP_NODE
, &neighbor_password_cmd
);
18581 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18583 /* "neighbor activate" commands. */
18584 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18585 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18586 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18587 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18588 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18589 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18590 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18591 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18592 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18593 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18594 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18595 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18597 /* "no neighbor activate" commands. */
18598 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18599 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18600 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18601 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18602 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18603 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18604 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18605 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18606 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18607 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18608 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18609 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18611 /* "neighbor peer-group" set commands. */
18612 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18613 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18614 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18615 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18616 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18617 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18618 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18619 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18620 install_element(BGP_FLOWSPECV4_NODE
,
18621 &neighbor_set_peer_group_hidden_cmd
);
18622 install_element(BGP_FLOWSPECV6_NODE
,
18623 &neighbor_set_peer_group_hidden_cmd
);
18625 /* "no neighbor peer-group unset" commands. */
18626 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18627 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18628 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18629 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18630 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18631 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18632 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18633 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18634 install_element(BGP_FLOWSPECV4_NODE
,
18635 &no_neighbor_set_peer_group_hidden_cmd
);
18636 install_element(BGP_FLOWSPECV6_NODE
,
18637 &no_neighbor_set_peer_group_hidden_cmd
);
18639 /* "neighbor softreconfiguration inbound" commands.*/
18640 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18641 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18642 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18643 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18644 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18645 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18646 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18647 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18648 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18649 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18650 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18651 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18652 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18653 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18654 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18655 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18656 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18657 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18658 install_element(BGP_FLOWSPECV4_NODE
,
18659 &neighbor_soft_reconfiguration_cmd
);
18660 install_element(BGP_FLOWSPECV4_NODE
,
18661 &no_neighbor_soft_reconfiguration_cmd
);
18662 install_element(BGP_FLOWSPECV6_NODE
,
18663 &neighbor_soft_reconfiguration_cmd
);
18664 install_element(BGP_FLOWSPECV6_NODE
,
18665 &no_neighbor_soft_reconfiguration_cmd
);
18666 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18667 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18669 /* "neighbor attribute-unchanged" commands. */
18670 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18671 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18672 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18673 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18674 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18675 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18676 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18677 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18678 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18679 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18680 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18681 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18682 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18683 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18684 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18685 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18686 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18687 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18689 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18690 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18692 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18693 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18694 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18695 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18697 /* "nexthop-local unchanged" commands */
18698 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18699 install_element(BGP_IPV6_NODE
,
18700 &no_neighbor_nexthop_local_unchanged_cmd
);
18702 /* "neighbor next-hop-self" commands. */
18703 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18704 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18705 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18706 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18707 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18708 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18709 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18710 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18711 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18712 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18713 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18714 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18715 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18716 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18717 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18718 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18719 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18720 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18721 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18722 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18724 /* "neighbor next-hop-self force" commands. */
18725 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18726 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18727 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18728 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18729 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18730 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18731 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18732 install_element(BGP_IPV4_NODE
,
18733 &no_neighbor_nexthop_self_all_hidden_cmd
);
18734 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18735 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18736 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18737 install_element(BGP_IPV4M_NODE
,
18738 &no_neighbor_nexthop_self_all_hidden_cmd
);
18739 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18740 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18741 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18742 install_element(BGP_IPV4L_NODE
,
18743 &no_neighbor_nexthop_self_all_hidden_cmd
);
18744 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18745 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18746 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18747 install_element(BGP_IPV6_NODE
,
18748 &no_neighbor_nexthop_self_all_hidden_cmd
);
18749 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18750 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18751 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18752 install_element(BGP_IPV6M_NODE
,
18753 &no_neighbor_nexthop_self_all_hidden_cmd
);
18754 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18755 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18756 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18757 install_element(BGP_IPV6L_NODE
,
18758 &no_neighbor_nexthop_self_all_hidden_cmd
);
18759 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18760 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18761 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18762 install_element(BGP_VPNV4_NODE
,
18763 &no_neighbor_nexthop_self_all_hidden_cmd
);
18764 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18765 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18766 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18767 install_element(BGP_VPNV6_NODE
,
18768 &no_neighbor_nexthop_self_all_hidden_cmd
);
18769 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18770 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18772 /* "neighbor as-override" commands. */
18773 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18774 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18775 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18776 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18777 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18778 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18779 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18780 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18781 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18782 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18783 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18784 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18785 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18786 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18787 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18788 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18789 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18790 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18792 /* "neighbor remove-private-AS" commands. */
18793 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18794 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18795 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18796 install_element(BGP_NODE
,
18797 &no_neighbor_remove_private_as_all_hidden_cmd
);
18798 install_element(BGP_NODE
,
18799 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18800 install_element(BGP_NODE
,
18801 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18802 install_element(BGP_NODE
,
18803 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18806 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18807 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18808 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18809 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18810 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18811 install_element(BGP_IPV4_NODE
,
18812 &neighbor_remove_private_as_replace_as_cmd
);
18813 install_element(BGP_IPV4_NODE
,
18814 &no_neighbor_remove_private_as_replace_as_cmd
);
18815 install_element(BGP_IPV4_NODE
,
18816 &neighbor_remove_private_as_all_replace_as_cmd
);
18817 install_element(BGP_IPV4_NODE
,
18818 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18819 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18820 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18821 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18822 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18823 install_element(BGP_IPV4M_NODE
,
18824 &neighbor_remove_private_as_replace_as_cmd
);
18825 install_element(BGP_IPV4M_NODE
,
18826 &no_neighbor_remove_private_as_replace_as_cmd
);
18827 install_element(BGP_IPV4M_NODE
,
18828 &neighbor_remove_private_as_all_replace_as_cmd
);
18829 install_element(BGP_IPV4M_NODE
,
18830 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18831 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18832 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18833 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18834 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18835 install_element(BGP_IPV4L_NODE
,
18836 &neighbor_remove_private_as_replace_as_cmd
);
18837 install_element(BGP_IPV4L_NODE
,
18838 &no_neighbor_remove_private_as_replace_as_cmd
);
18839 install_element(BGP_IPV4L_NODE
,
18840 &neighbor_remove_private_as_all_replace_as_cmd
);
18841 install_element(BGP_IPV4L_NODE
,
18842 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18843 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18844 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18845 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18846 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18847 install_element(BGP_IPV6_NODE
,
18848 &neighbor_remove_private_as_replace_as_cmd
);
18849 install_element(BGP_IPV6_NODE
,
18850 &no_neighbor_remove_private_as_replace_as_cmd
);
18851 install_element(BGP_IPV6_NODE
,
18852 &neighbor_remove_private_as_all_replace_as_cmd
);
18853 install_element(BGP_IPV6_NODE
,
18854 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18855 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18856 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18857 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18858 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18859 install_element(BGP_IPV6M_NODE
,
18860 &neighbor_remove_private_as_replace_as_cmd
);
18861 install_element(BGP_IPV6M_NODE
,
18862 &no_neighbor_remove_private_as_replace_as_cmd
);
18863 install_element(BGP_IPV6M_NODE
,
18864 &neighbor_remove_private_as_all_replace_as_cmd
);
18865 install_element(BGP_IPV6M_NODE
,
18866 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18867 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18868 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18869 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18870 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18871 install_element(BGP_IPV6L_NODE
,
18872 &neighbor_remove_private_as_replace_as_cmd
);
18873 install_element(BGP_IPV6L_NODE
,
18874 &no_neighbor_remove_private_as_replace_as_cmd
);
18875 install_element(BGP_IPV6L_NODE
,
18876 &neighbor_remove_private_as_all_replace_as_cmd
);
18877 install_element(BGP_IPV6L_NODE
,
18878 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18879 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18880 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18881 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18882 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18883 install_element(BGP_VPNV4_NODE
,
18884 &neighbor_remove_private_as_replace_as_cmd
);
18885 install_element(BGP_VPNV4_NODE
,
18886 &no_neighbor_remove_private_as_replace_as_cmd
);
18887 install_element(BGP_VPNV4_NODE
,
18888 &neighbor_remove_private_as_all_replace_as_cmd
);
18889 install_element(BGP_VPNV4_NODE
,
18890 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18891 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18892 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18893 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18894 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18895 install_element(BGP_VPNV6_NODE
,
18896 &neighbor_remove_private_as_replace_as_cmd
);
18897 install_element(BGP_VPNV6_NODE
,
18898 &no_neighbor_remove_private_as_replace_as_cmd
);
18899 install_element(BGP_VPNV6_NODE
,
18900 &neighbor_remove_private_as_all_replace_as_cmd
);
18901 install_element(BGP_VPNV6_NODE
,
18902 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18904 /* "neighbor send-community" commands.*/
18905 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18906 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18907 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18908 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18909 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18910 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18911 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18912 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18913 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18914 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18915 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18916 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18917 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18918 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18919 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18921 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18922 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18923 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18924 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18925 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18926 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18927 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18928 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18929 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18930 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18931 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18932 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18933 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18934 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18935 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18936 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18937 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18938 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18939 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18940 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18942 /* "neighbor route-reflector" commands.*/
18943 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18944 install_element(BGP_NODE
,
18945 &no_neighbor_route_reflector_client_hidden_cmd
);
18946 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18947 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18948 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18949 install_element(BGP_IPV4M_NODE
,
18950 &no_neighbor_route_reflector_client_cmd
);
18951 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18952 install_element(BGP_IPV4L_NODE
,
18953 &no_neighbor_route_reflector_client_cmd
);
18954 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18955 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18956 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18957 install_element(BGP_IPV6M_NODE
,
18958 &no_neighbor_route_reflector_client_cmd
);
18959 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18960 install_element(BGP_IPV6L_NODE
,
18961 &no_neighbor_route_reflector_client_cmd
);
18962 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18963 install_element(BGP_VPNV4_NODE
,
18964 &no_neighbor_route_reflector_client_cmd
);
18965 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18966 install_element(BGP_VPNV6_NODE
,
18967 &no_neighbor_route_reflector_client_cmd
);
18968 install_element(BGP_FLOWSPECV4_NODE
,
18969 &neighbor_route_reflector_client_cmd
);
18970 install_element(BGP_FLOWSPECV4_NODE
,
18971 &no_neighbor_route_reflector_client_cmd
);
18972 install_element(BGP_FLOWSPECV6_NODE
,
18973 &neighbor_route_reflector_client_cmd
);
18974 install_element(BGP_FLOWSPECV6_NODE
,
18975 &no_neighbor_route_reflector_client_cmd
);
18976 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18977 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18979 /* "neighbor route-server" commands.*/
18980 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18981 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18982 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18983 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18984 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18985 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18986 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18987 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18988 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18989 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18990 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18991 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18992 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18993 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18994 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18995 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18996 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18997 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18998 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18999 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19000 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19001 install_element(BGP_FLOWSPECV4_NODE
,
19002 &no_neighbor_route_server_client_cmd
);
19003 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19004 install_element(BGP_FLOWSPECV6_NODE
,
19005 &no_neighbor_route_server_client_cmd
);
19007 /* "neighbor disable-addpath-rx" commands. */
19008 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19009 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19010 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19011 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19012 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19013 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19014 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19015 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19016 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19017 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19018 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19019 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19020 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19021 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19022 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19023 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19025 /* "neighbor addpath-tx-all-paths" commands.*/
19026 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19027 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19028 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19029 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19030 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19031 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19032 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19033 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19034 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19035 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19036 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19037 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19038 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19039 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19040 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19041 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19042 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19043 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19045 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19046 install_element(BGP_NODE
,
19047 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19048 install_element(BGP_NODE
,
19049 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19050 install_element(BGP_IPV4_NODE
,
19051 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19052 install_element(BGP_IPV4_NODE
,
19053 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19054 install_element(BGP_IPV4M_NODE
,
19055 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19056 install_element(BGP_IPV4M_NODE
,
19057 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19058 install_element(BGP_IPV4L_NODE
,
19059 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19060 install_element(BGP_IPV4L_NODE
,
19061 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19062 install_element(BGP_IPV6_NODE
,
19063 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19064 install_element(BGP_IPV6_NODE
,
19065 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19066 install_element(BGP_IPV6M_NODE
,
19067 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19068 install_element(BGP_IPV6M_NODE
,
19069 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19070 install_element(BGP_IPV6L_NODE
,
19071 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19072 install_element(BGP_IPV6L_NODE
,
19073 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19074 install_element(BGP_VPNV4_NODE
,
19075 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19076 install_element(BGP_VPNV4_NODE
,
19077 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19078 install_element(BGP_VPNV6_NODE
,
19079 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19080 install_element(BGP_VPNV6_NODE
,
19081 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19083 /* "neighbor sender-as-path-loop-detection" commands. */
19084 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19085 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19087 /* "neighbor passive" commands. */
19088 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19089 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19092 /* "neighbor shutdown" commands. */
19093 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19094 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19095 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19096 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19097 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19098 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19100 /* "neighbor capability extended-nexthop" commands.*/
19101 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19102 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19104 /* "neighbor capability orf prefix-list" commands.*/
19105 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19106 install_element(BGP_NODE
,
19107 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19108 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19109 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19110 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19111 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19112 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19113 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19114 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19115 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19116 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19117 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19118 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19119 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19121 /* "neighbor capability dynamic" commands.*/
19122 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19123 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19125 /* "neighbor dont-capability-negotiate" commands. */
19126 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19127 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19129 /* "neighbor ebgp-multihop" commands. */
19130 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19131 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19132 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19134 /* "neighbor disable-connected-check" commands. */
19135 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19136 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19138 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19139 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19140 install_element(BGP_NODE
,
19141 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19143 /* "neighbor extended-optional-parameters" commands. */
19144 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19145 install_element(BGP_NODE
,
19146 &no_neighbor_extended_optional_parameters_cmd
);
19148 /* "neighbor enforce-first-as" commands. */
19149 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19150 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19152 /* "neighbor description" commands. */
19153 install_element(BGP_NODE
, &neighbor_description_cmd
);
19154 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19155 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19157 /* "neighbor update-source" commands. "*/
19158 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19159 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19161 /* "neighbor default-originate" commands. */
19162 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19163 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19164 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19165 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19166 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19167 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19168 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19169 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19170 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19171 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19172 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19173 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19174 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19175 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19176 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19177 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19178 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19179 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19180 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19181 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19182 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19184 /* "neighbor port" commands. */
19185 install_element(BGP_NODE
, &neighbor_port_cmd
);
19186 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19188 /* "neighbor weight" commands. */
19189 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19190 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19192 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19193 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19194 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19195 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19196 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19197 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19198 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19199 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19200 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19201 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19202 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19203 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19204 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19205 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19206 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19207 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19209 /* "neighbor override-capability" commands. */
19210 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19211 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19213 /* "neighbor strict-capability-match" commands. */
19214 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19215 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19217 /* "neighbor timers" commands. */
19218 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19219 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19221 /* "neighbor timers connect" commands. */
19222 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19223 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19225 /* "neighbor timers delayopen" commands. */
19226 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19227 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19229 /* "neighbor advertisement-interval" commands. */
19230 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19231 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19233 /* "neighbor interface" commands. */
19234 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19235 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19237 /* "neighbor distribute" commands. */
19238 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19239 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19240 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19241 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19242 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19243 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19244 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19245 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19246 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19247 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19248 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19249 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19250 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19251 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19252 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19253 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19254 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19255 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19257 /* "neighbor prefix-list" commands. */
19258 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19259 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19260 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19261 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19262 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19263 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19264 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19265 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19266 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19267 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19268 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19269 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19270 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19271 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19272 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19273 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19274 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19275 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19276 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19277 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19278 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19279 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19281 /* "neighbor filter-list" commands. */
19282 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19283 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19284 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19285 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19286 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19287 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19288 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19289 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19290 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19291 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19292 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19293 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19294 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19295 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19296 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19297 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19298 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19299 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19300 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19301 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19302 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19303 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19305 /* "neighbor route-map" commands. */
19306 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19307 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19308 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19309 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19310 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19311 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19312 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19313 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19314 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19315 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19316 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19317 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19318 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19319 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19320 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19321 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19322 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19323 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19324 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19325 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19326 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19327 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19328 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19329 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19331 /* "neighbor unsuppress-map" commands. */
19332 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19333 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19334 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19335 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19336 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19337 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19338 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19339 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19340 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19341 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19342 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19343 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19344 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19345 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19346 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19347 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19348 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19349 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19351 /* "neighbor advertise-map" commands. */
19352 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19353 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19354 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19355 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19356 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19357 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19358 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19359 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19360 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19361 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19363 /* neighbor maximum-prefix-out commands. */
19364 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19365 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19366 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19367 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19368 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19369 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19370 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19371 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19372 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19373 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19374 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19375 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19376 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19377 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19378 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19379 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19380 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19381 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19383 /* "neighbor maximum-prefix" commands. */
19384 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19385 install_element(BGP_NODE
,
19386 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19387 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19388 install_element(BGP_NODE
,
19389 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19390 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19391 install_element(BGP_NODE
,
19392 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19393 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19394 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19395 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19396 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19397 install_element(BGP_IPV4_NODE
,
19398 &neighbor_maximum_prefix_threshold_warning_cmd
);
19399 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19400 install_element(BGP_IPV4_NODE
,
19401 &neighbor_maximum_prefix_threshold_restart_cmd
);
19402 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19403 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19404 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19405 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19406 install_element(BGP_IPV4M_NODE
,
19407 &neighbor_maximum_prefix_threshold_warning_cmd
);
19408 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19409 install_element(BGP_IPV4M_NODE
,
19410 &neighbor_maximum_prefix_threshold_restart_cmd
);
19411 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19412 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19413 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19414 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19415 install_element(BGP_IPV4L_NODE
,
19416 &neighbor_maximum_prefix_threshold_warning_cmd
);
19417 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19418 install_element(BGP_IPV4L_NODE
,
19419 &neighbor_maximum_prefix_threshold_restart_cmd
);
19420 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19421 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19422 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19423 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19424 install_element(BGP_IPV6_NODE
,
19425 &neighbor_maximum_prefix_threshold_warning_cmd
);
19426 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19427 install_element(BGP_IPV6_NODE
,
19428 &neighbor_maximum_prefix_threshold_restart_cmd
);
19429 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19430 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19431 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19432 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19433 install_element(BGP_IPV6M_NODE
,
19434 &neighbor_maximum_prefix_threshold_warning_cmd
);
19435 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19436 install_element(BGP_IPV6M_NODE
,
19437 &neighbor_maximum_prefix_threshold_restart_cmd
);
19438 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19439 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19440 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19441 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19442 install_element(BGP_IPV6L_NODE
,
19443 &neighbor_maximum_prefix_threshold_warning_cmd
);
19444 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19445 install_element(BGP_IPV6L_NODE
,
19446 &neighbor_maximum_prefix_threshold_restart_cmd
);
19447 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19448 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19449 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19450 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19451 install_element(BGP_VPNV4_NODE
,
19452 &neighbor_maximum_prefix_threshold_warning_cmd
);
19453 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19454 install_element(BGP_VPNV4_NODE
,
19455 &neighbor_maximum_prefix_threshold_restart_cmd
);
19456 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19457 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19458 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19459 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19460 install_element(BGP_VPNV6_NODE
,
19461 &neighbor_maximum_prefix_threshold_warning_cmd
);
19462 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19463 install_element(BGP_VPNV6_NODE
,
19464 &neighbor_maximum_prefix_threshold_restart_cmd
);
19465 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19467 /* "neighbor allowas-in" */
19468 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19469 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19470 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19471 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19472 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19473 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19474 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19475 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19476 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19477 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19478 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19479 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19480 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19481 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19482 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19483 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19484 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19485 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19486 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19487 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19489 /* "neighbor soo" */
19490 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19491 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19492 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19493 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19494 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19495 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19496 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19497 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19498 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19499 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19500 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19501 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19502 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19503 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19504 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19505 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19506 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19507 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19509 /* address-family commands. */
19510 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19511 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19512 #ifdef KEEP_OLD_VPN_COMMANDS
19513 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19514 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19515 #endif /* KEEP_OLD_VPN_COMMANDS */
19517 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19519 /* "exit-address-family" command. */
19520 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19521 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19522 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19523 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19524 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19525 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19526 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19527 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19528 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19529 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19530 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19532 /* BGP retain all route-target */
19533 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19534 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19536 /* "clear ip bgp commands" */
19537 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19539 /* clear ip bgp prefix */
19540 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19541 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19542 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19544 /* "show [ip] bgp summary" commands. */
19545 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19546 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19547 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19548 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19549 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19550 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19551 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19553 /* "show [ip] bgp neighbors" commands. */
19554 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19556 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19558 /* "show [ip] bgp peer-group" commands. */
19559 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19561 /* "show [ip] bgp paths" commands. */
19562 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19564 /* "show [ip] bgp community" commands. */
19565 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19567 /* "show ip bgp large-community" commands. */
19568 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19569 /* "show [ip] bgp attribute-info" commands. */
19570 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19571 /* "show [ip] bgp route-leak" command */
19572 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19574 /* "redistribute" commands. */
19575 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19576 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19577 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19578 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19579 install_element(BGP_NODE
,
19580 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19581 install_element(BGP_NODE
,
19582 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19583 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19584 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19585 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19586 install_element(BGP_NODE
,
19587 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19588 install_element(BGP_NODE
,
19589 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19590 install_element(BGP_NODE
,
19591 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19592 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19593 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19594 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19595 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19596 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19597 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19598 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19599 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19600 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19601 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19602 install_element(BGP_IPV4_NODE
,
19603 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19604 install_element(BGP_IPV4_NODE
,
19605 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19606 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19607 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19608 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19609 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19610 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19611 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19613 /* import|export vpn [route-map RMAP_NAME] */
19614 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19615 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19617 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19618 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19620 /* ttl_security commands */
19621 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19622 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19624 /* "bgp tcp-keepalive" commands */
19625 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19626 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19628 /* "show [ip] bgp memory" commands. */
19629 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19631 /* "show bgp martian next-hop" */
19632 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19634 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19636 /* "show [ip] bgp views" commands. */
19637 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19639 /* "show [ip] bgp vrfs" commands. */
19640 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19642 /* Community-list. */
19643 community_list_vty();
19645 community_alias_vty();
19647 /* vpn-policy commands */
19648 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19649 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19650 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19651 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19652 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19653 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19654 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19655 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19656 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19657 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19658 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19659 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19661 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19662 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19664 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19665 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19666 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19667 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19668 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19669 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19670 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19671 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19672 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19673 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19675 /* tcp-mss command */
19676 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19677 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19679 /* srv6 commands */
19680 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19681 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19682 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19683 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19684 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19685 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19686 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19691 #include "memory.h"
19692 #include "bgp_regex.h"
19693 #include "bgp_clist.h"
19694 #include "bgp_ecommunity.h"
19696 /* VTY functions. */
19698 /* Direction value to string conversion. */
19699 static const char *community_direct_str(int direct
)
19702 case COMMUNITY_DENY
:
19704 case COMMUNITY_PERMIT
:
19711 /* Display error string. */
19712 static void community_list_perror(struct vty
*vty
, int ret
)
19715 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19716 vty_out(vty
, "%% Can't find community-list\n");
19718 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19719 vty_out(vty
, "%% Malformed community-list value\n");
19721 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19723 "%% Community name conflict, previously defined as standard community\n");
19725 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19727 "%% Community name conflict, previously defined as expanded community\n");
19732 /* "community-list" keyword help string. */
19733 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19735 /*community-list standard */
19736 DEFUN (community_list_standard
,
19737 bgp_community_list_standard_cmd
,
19738 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19741 "Community list number (standard)\n"
19742 "Add an standard community-list entry\n"
19743 "Community list name\n"
19744 "Sequence number of an entry\n"
19745 "Sequence number\n"
19746 "Specify community to reject\n"
19747 "Specify community to accept\n"
19750 char *cl_name_or_number
= NULL
;
19753 int style
= COMMUNITY_LIST_STANDARD
;
19756 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19757 seq
= argv
[idx
]->arg
;
19760 argv_find(argv
, argc
, "(1-99)", &idx
);
19761 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19762 cl_name_or_number
= argv
[idx
]->arg
;
19763 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19765 argv_find(argv
, argc
, "AA:NN", &idx
);
19766 char *str
= argv_concat(argv
, argc
, idx
);
19768 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19771 XFREE(MTYPE_TMP
, str
);
19774 /* Display error string. */
19775 community_list_perror(vty
, ret
);
19776 return CMD_WARNING_CONFIG_FAILED
;
19779 return CMD_SUCCESS
;
19782 DEFUN (no_community_list_standard_all
,
19783 no_bgp_community_list_standard_all_cmd
,
19784 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19788 "Community list number (standard)\n"
19789 "Add an standard community-list entry\n"
19790 "Community list name\n"
19791 "Sequence number of an entry\n"
19792 "Sequence number\n"
19793 "Specify community to reject\n"
19794 "Specify community to accept\n"
19797 char *cl_name_or_number
= NULL
;
19800 int style
= COMMUNITY_LIST_STANDARD
;
19804 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19805 seq
= argv
[idx
]->arg
;
19808 argv_find(argv
, argc
, "permit", &idx
);
19809 argv_find(argv
, argc
, "deny", &idx
);
19812 direct
= argv_find(argv
, argc
, "permit", &idx
)
19817 argv_find(argv
, argc
, "AA:NN", &idx
);
19818 str
= argv_concat(argv
, argc
, idx
);
19822 argv_find(argv
, argc
, "(1-99)", &idx
);
19823 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19824 cl_name_or_number
= argv
[idx
]->arg
;
19826 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19829 XFREE(MTYPE_TMP
, str
);
19832 community_list_perror(vty
, ret
);
19833 return CMD_WARNING_CONFIG_FAILED
;
19836 return CMD_SUCCESS
;
19839 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19840 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19841 NO_STR BGP_STR COMMUNITY_LIST_STR
19842 "Community list number (standard)\n"
19843 "Add an standard community-list entry\n"
19844 "Community list name\n")
19846 /*community-list expanded */
19847 DEFUN (community_list_expanded_all
,
19848 bgp_community_list_expanded_all_cmd
,
19849 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19852 "Community list number (expanded)\n"
19853 "Add an expanded community-list entry\n"
19854 "Community list name\n"
19855 "Sequence number of an entry\n"
19856 "Sequence number\n"
19857 "Specify community to reject\n"
19858 "Specify community to accept\n"
19861 char *cl_name_or_number
= NULL
;
19864 int style
= COMMUNITY_LIST_EXPANDED
;
19867 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19868 seq
= argv
[idx
]->arg
;
19872 argv_find(argv
, argc
, "(100-500)", &idx
);
19873 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19874 cl_name_or_number
= argv
[idx
]->arg
;
19875 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19877 argv_find(argv
, argc
, "AA:NN", &idx
);
19878 char *str
= argv_concat(argv
, argc
, idx
);
19880 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19883 XFREE(MTYPE_TMP
, str
);
19886 /* Display error string. */
19887 community_list_perror(vty
, ret
);
19888 return CMD_WARNING_CONFIG_FAILED
;
19891 return CMD_SUCCESS
;
19894 DEFUN (no_community_list_expanded_all
,
19895 no_bgp_community_list_expanded_all_cmd
,
19896 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19900 "Community list number (expanded)\n"
19901 "Add an expanded community-list entry\n"
19902 "Community list name\n"
19903 "Sequence number of an entry\n"
19904 "Sequence number\n"
19905 "Specify community to reject\n"
19906 "Specify community to accept\n"
19909 char *cl_name_or_number
= NULL
;
19913 int style
= COMMUNITY_LIST_EXPANDED
;
19916 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19917 seq
= argv
[idx
]->arg
;
19920 argv_find(argv
, argc
, "permit", &idx
);
19921 argv_find(argv
, argc
, "deny", &idx
);
19924 direct
= argv_find(argv
, argc
, "permit", &idx
)
19929 argv_find(argv
, argc
, "AA:NN", &idx
);
19930 str
= argv_concat(argv
, argc
, idx
);
19934 argv_find(argv
, argc
, "(100-500)", &idx
);
19935 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19936 cl_name_or_number
= argv
[idx
]->arg
;
19938 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19941 XFREE(MTYPE_TMP
, str
);
19944 community_list_perror(vty
, ret
);
19945 return CMD_WARNING_CONFIG_FAILED
;
19948 return CMD_SUCCESS
;
19951 ALIAS(no_community_list_expanded_all
,
19952 no_bgp_community_list_expanded_all_list_cmd
,
19953 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19954 NO_STR BGP_STR COMMUNITY_LIST_STR
19955 "Community list number (expanded)\n"
19956 "Add an expanded community-list entry\n"
19957 "Community list name\n")
19959 /* Return configuration string of community-list entry. */
19960 static const char *community_list_config_str(struct community_entry
*entry
)
19967 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19968 str
= community_str(entry
->u
.com
, false, false);
19969 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19970 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19972 str
= entry
->config
;
19977 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19979 struct community_entry
*entry
;
19981 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19982 if (entry
== list
->head
) {
19983 if (all_digit(list
->name
))
19984 vty_out(vty
, "Community %s list %s\n",
19985 entry
->style
== COMMUNITY_LIST_STANDARD
19987 : "(expanded) access",
19990 vty_out(vty
, "Named Community %s list %s\n",
19991 entry
->style
== COMMUNITY_LIST_STANDARD
19997 vty_out(vty
, " %s\n",
19998 community_direct_str(entry
->direct
));
20000 vty_out(vty
, " %s %s\n",
20001 community_direct_str(entry
->direct
),
20002 community_list_config_str(entry
));
20006 DEFUN (show_community_list
,
20007 show_bgp_community_list_cmd
,
20008 "show bgp community-list",
20011 "List community-list\n")
20013 struct community_list
*list
;
20014 struct community_list_master
*cm
;
20016 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20018 return CMD_SUCCESS
;
20020 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20021 community_list_show(vty
, list
);
20023 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20024 community_list_show(vty
, list
);
20026 return CMD_SUCCESS
;
20029 DEFUN (show_community_list_arg
,
20030 show_bgp_community_list_arg_cmd
,
20031 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20034 "List community-list\n"
20035 "Community-list number\n"
20036 "Community-list name\n"
20037 "Detailed information on community-list\n")
20039 int idx_comm_list
= 3;
20040 struct community_list
*list
;
20042 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20043 COMMUNITY_LIST_MASTER
);
20045 vty_out(vty
, "%% Can't find community-list\n");
20046 return CMD_WARNING
;
20049 community_list_show(vty
, list
);
20051 return CMD_SUCCESS
;
20055 * Large Community code.
20057 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20058 struct cmd_token
**argv
, int style
,
20059 int reject_all_digit_name
)
20068 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20069 seq
= argv
[idx
]->arg
;
20072 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20075 /* All digit name check. */
20077 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20078 argv_find(argv
, argc
, "(1-99)", &idx
);
20079 argv_find(argv
, argc
, "(100-500)", &idx
);
20080 cl_name
= argv
[idx
]->arg
;
20081 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20082 vty_out(vty
, "%% Community name cannot have all digits\n");
20083 return CMD_WARNING_CONFIG_FAILED
;
20087 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20088 argv_find(argv
, argc
, "LINE", &idx
);
20089 /* Concat community string argument. */
20091 str
= argv_concat(argv
, argc
, idx
);
20095 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20097 /* Free temporary community list string allocated by
20099 XFREE(MTYPE_TMP
, str
);
20102 community_list_perror(vty
, ret
);
20103 return CMD_WARNING_CONFIG_FAILED
;
20105 return CMD_SUCCESS
;
20108 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20109 struct cmd_token
**argv
, int style
)
20117 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20118 seq
= argv
[idx
]->arg
;
20121 argv_find(argv
, argc
, "permit", &idx
);
20122 argv_find(argv
, argc
, "deny", &idx
);
20125 /* Check the list direct. */
20126 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20127 direct
= COMMUNITY_PERMIT
;
20129 direct
= COMMUNITY_DENY
;
20132 argv_find(argv
, argc
, "LINE", &idx
);
20133 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20134 /* Concat community string argument. */
20135 str
= argv_concat(argv
, argc
, idx
);
20139 argv_find(argv
, argc
, "(1-99)", &idx
);
20140 argv_find(argv
, argc
, "(100-500)", &idx
);
20141 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20143 /* Unset community list. */
20144 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20147 /* Free temporary community list string allocated by
20149 XFREE(MTYPE_TMP
, str
);
20152 community_list_perror(vty
, ret
);
20153 return CMD_WARNING_CONFIG_FAILED
;
20156 return CMD_SUCCESS
;
20159 /* "large-community-list" keyword help string. */
20160 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20161 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20163 DEFUN (lcommunity_list_standard
,
20164 bgp_lcommunity_list_standard_cmd
,
20165 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20167 LCOMMUNITY_LIST_STR
20168 "Large Community list number (standard)\n"
20169 "Sequence number of an entry\n"
20170 "Sequence number\n"
20171 "Specify large community to reject\n"
20172 "Specify large community to accept\n"
20173 LCOMMUNITY_VAL_STR
)
20175 return lcommunity_list_set_vty(vty
, argc
, argv
,
20176 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20179 DEFUN (lcommunity_list_expanded
,
20180 bgp_lcommunity_list_expanded_cmd
,
20181 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20183 LCOMMUNITY_LIST_STR
20184 "Large Community list number (expanded)\n"
20185 "Sequence number of an entry\n"
20186 "Sequence number\n"
20187 "Specify large community to reject\n"
20188 "Specify large community to accept\n"
20189 "An ordered list as a regular-expression\n")
20191 return lcommunity_list_set_vty(vty
, argc
, argv
,
20192 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20195 DEFUN (lcommunity_list_name_standard
,
20196 bgp_lcommunity_list_name_standard_cmd
,
20197 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20199 LCOMMUNITY_LIST_STR
20200 "Specify standard large-community-list\n"
20201 "Large Community list name\n"
20202 "Sequence number of an entry\n"
20203 "Sequence number\n"
20204 "Specify large community to reject\n"
20205 "Specify large community to accept\n"
20206 LCOMMUNITY_VAL_STR
)
20208 return lcommunity_list_set_vty(vty
, argc
, argv
,
20209 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20212 DEFUN (lcommunity_list_name_expanded
,
20213 bgp_lcommunity_list_name_expanded_cmd
,
20214 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20216 LCOMMUNITY_LIST_STR
20217 "Specify expanded large-community-list\n"
20218 "Large Community list name\n"
20219 "Sequence number of an entry\n"
20220 "Sequence number\n"
20221 "Specify large community to reject\n"
20222 "Specify large community to accept\n"
20223 "An ordered list as a regular-expression\n")
20225 return lcommunity_list_set_vty(vty
, argc
, argv
,
20226 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20229 DEFUN (no_lcommunity_list_all
,
20230 no_bgp_lcommunity_list_all_cmd
,
20231 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20234 LCOMMUNITY_LIST_STR
20235 "Large Community list number (standard)\n"
20236 "Large Community list number (expanded)\n"
20237 "Large Community list name\n")
20239 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20240 LARGE_COMMUNITY_LIST_STANDARD
);
20243 DEFUN (no_lcommunity_list_name_standard_all
,
20244 no_bgp_lcommunity_list_name_standard_all_cmd
,
20245 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20248 LCOMMUNITY_LIST_STR
20249 "Specify standard large-community-list\n"
20250 "Large Community list name\n")
20252 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20253 LARGE_COMMUNITY_LIST_STANDARD
);
20256 DEFUN (no_lcommunity_list_name_expanded_all
,
20257 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20258 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20261 LCOMMUNITY_LIST_STR
20262 "Specify expanded large-community-list\n"
20263 "Large Community list name\n")
20265 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20266 LARGE_COMMUNITY_LIST_EXPANDED
);
20269 DEFUN (no_lcommunity_list_standard
,
20270 no_bgp_lcommunity_list_standard_cmd
,
20271 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20274 LCOMMUNITY_LIST_STR
20275 "Large Community list number (standard)\n"
20276 "Sequence number of an entry\n"
20277 "Sequence number\n"
20278 "Specify large community to reject\n"
20279 "Specify large community to accept\n"
20280 LCOMMUNITY_VAL_STR
)
20282 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20283 LARGE_COMMUNITY_LIST_STANDARD
);
20286 DEFUN (no_lcommunity_list_expanded
,
20287 no_bgp_lcommunity_list_expanded_cmd
,
20288 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20291 LCOMMUNITY_LIST_STR
20292 "Large Community list number (expanded)\n"
20293 "Sequence number of an entry\n"
20294 "Sequence number\n"
20295 "Specify large community to reject\n"
20296 "Specify large community to accept\n"
20297 "An ordered list as a regular-expression\n")
20299 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20300 LARGE_COMMUNITY_LIST_EXPANDED
);
20303 DEFUN (no_lcommunity_list_name_standard
,
20304 no_bgp_lcommunity_list_name_standard_cmd
,
20305 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20308 LCOMMUNITY_LIST_STR
20309 "Specify standard large-community-list\n"
20310 "Large Community list name\n"
20311 "Sequence number of an entry\n"
20312 "Sequence number\n"
20313 "Specify large community to reject\n"
20314 "Specify large community to accept\n"
20315 LCOMMUNITY_VAL_STR
)
20317 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20318 LARGE_COMMUNITY_LIST_STANDARD
);
20321 DEFUN (no_lcommunity_list_name_expanded
,
20322 no_bgp_lcommunity_list_name_expanded_cmd
,
20323 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20326 LCOMMUNITY_LIST_STR
20327 "Specify expanded large-community-list\n"
20328 "Large community list name\n"
20329 "Sequence number of an entry\n"
20330 "Sequence number\n"
20331 "Specify large community to reject\n"
20332 "Specify large community to accept\n"
20333 "An ordered list as a regular-expression\n")
20335 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20336 LARGE_COMMUNITY_LIST_EXPANDED
);
20339 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20341 struct community_entry
*entry
;
20343 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20344 if (entry
== list
->head
) {
20345 if (all_digit(list
->name
))
20346 vty_out(vty
, "Large community %s list %s\n",
20348 LARGE_COMMUNITY_LIST_STANDARD
20350 : "(expanded) access",
20354 "Named large community %s list %s\n",
20356 LARGE_COMMUNITY_LIST_STANDARD
20362 vty_out(vty
, " %s\n",
20363 community_direct_str(entry
->direct
));
20365 vty_out(vty
, " %s %s\n",
20366 community_direct_str(entry
->direct
),
20367 community_list_config_str(entry
));
20371 DEFUN (show_lcommunity_list
,
20372 show_bgp_lcommunity_list_cmd
,
20373 "show bgp large-community-list",
20376 "List large-community list\n")
20378 struct community_list
*list
;
20379 struct community_list_master
*cm
;
20381 cm
= community_list_master_lookup(bgp_clist
,
20382 LARGE_COMMUNITY_LIST_MASTER
);
20384 return CMD_SUCCESS
;
20386 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20387 lcommunity_list_show(vty
, list
);
20389 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20390 lcommunity_list_show(vty
, list
);
20392 return CMD_SUCCESS
;
20395 DEFUN (show_lcommunity_list_arg
,
20396 show_bgp_lcommunity_list_arg_cmd
,
20397 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20400 "List large-community list\n"
20401 "Large-community-list number\n"
20402 "Large-community-list name\n"
20403 "Detailed information on large-community-list\n")
20405 struct community_list
*list
;
20407 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20408 LARGE_COMMUNITY_LIST_MASTER
);
20410 vty_out(vty
, "%% Can't find large-community-list\n");
20411 return CMD_WARNING
;
20414 lcommunity_list_show(vty
, list
);
20416 return CMD_SUCCESS
;
20419 /* "extcommunity-list" keyword help string. */
20420 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20421 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20423 DEFUN (extcommunity_list_standard
,
20424 bgp_extcommunity_list_standard_cmd
,
20425 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20427 EXTCOMMUNITY_LIST_STR
20428 "Extended Community list number (standard)\n"
20429 "Specify standard extcommunity-list\n"
20430 "Community list name\n"
20431 "Sequence number of an entry\n"
20432 "Sequence number\n"
20433 "Specify community to reject\n"
20434 "Specify community to accept\n"
20435 EXTCOMMUNITY_VAL_STR
)
20437 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20439 char *cl_number_or_name
= NULL
;
20444 argv_find(argv
, argc
, "(1-99)", &idx
);
20445 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20446 cl_number_or_name
= argv
[idx
]->arg
;
20448 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20449 seq
= argv
[idx
]->arg
;
20451 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20453 argv_find(argv
, argc
, "AA:NN", &idx
);
20454 char *str
= argv_concat(argv
, argc
, idx
);
20456 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20459 XFREE(MTYPE_TMP
, str
);
20462 community_list_perror(vty
, ret
);
20463 return CMD_WARNING_CONFIG_FAILED
;
20466 return CMD_SUCCESS
;
20469 DEFUN (extcommunity_list_name_expanded
,
20470 bgp_extcommunity_list_name_expanded_cmd
,
20471 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20473 EXTCOMMUNITY_LIST_STR
20474 "Extended Community list number (expanded)\n"
20475 "Specify expanded extcommunity-list\n"
20476 "Extended Community list name\n"
20477 "Sequence number of an entry\n"
20478 "Sequence number\n"
20479 "Specify community to reject\n"
20480 "Specify community to accept\n"
20481 "An ordered list as a regular-expression\n")
20483 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20485 char *cl_number_or_name
= NULL
;
20489 argv_find(argv
, argc
, "(100-500)", &idx
);
20490 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20491 cl_number_or_name
= argv
[idx
]->arg
;
20493 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20494 seq
= argv
[idx
]->arg
;
20496 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20498 argv_find(argv
, argc
, "LINE", &idx
);
20499 char *str
= argv_concat(argv
, argc
, idx
);
20501 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20504 XFREE(MTYPE_TMP
, str
);
20507 community_list_perror(vty
, ret
);
20508 return CMD_WARNING_CONFIG_FAILED
;
20511 return CMD_SUCCESS
;
20514 DEFUN (no_extcommunity_list_standard_all
,
20515 no_bgp_extcommunity_list_standard_all_cmd
,
20516 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20519 EXTCOMMUNITY_LIST_STR
20520 "Extended Community list number (standard)\n"
20521 "Specify standard extcommunity-list\n"
20522 "Community list name\n"
20523 "Sequence number of an entry\n"
20524 "Sequence number\n"
20525 "Specify community to reject\n"
20526 "Specify community to accept\n"
20527 EXTCOMMUNITY_VAL_STR
)
20529 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20531 char *cl_number_or_name
= NULL
;
20536 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20537 seq
= argv
[idx
]->arg
;
20540 argv_find(argv
, argc
, "permit", &idx
);
20541 argv_find(argv
, argc
, "deny", &idx
);
20543 direct
= argv_find(argv
, argc
, "permit", &idx
)
20548 argv_find(argv
, argc
, "AA:NN", &idx
);
20549 str
= argv_concat(argv
, argc
, idx
);
20553 argv_find(argv
, argc
, "(1-99)", &idx
);
20554 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20555 cl_number_or_name
= argv
[idx
]->arg
;
20557 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20558 seq
, direct
, style
);
20560 XFREE(MTYPE_TMP
, str
);
20563 community_list_perror(vty
, ret
);
20564 return CMD_WARNING_CONFIG_FAILED
;
20567 return CMD_SUCCESS
;
20570 ALIAS(no_extcommunity_list_standard_all
,
20571 no_bgp_extcommunity_list_standard_all_list_cmd
,
20572 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20573 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20574 "Extended Community list number (standard)\n"
20575 "Specify standard extcommunity-list\n"
20576 "Community list name\n")
20578 DEFUN (no_extcommunity_list_expanded_all
,
20579 no_bgp_extcommunity_list_expanded_all_cmd
,
20580 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20583 EXTCOMMUNITY_LIST_STR
20584 "Extended Community list number (expanded)\n"
20585 "Specify expanded extcommunity-list\n"
20586 "Extended Community list name\n"
20587 "Sequence number of an entry\n"
20588 "Sequence number\n"
20589 "Specify community to reject\n"
20590 "Specify community to accept\n"
20591 "An ordered list as a regular-expression\n")
20593 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20595 char *cl_number_or_name
= NULL
;
20600 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20601 seq
= argv
[idx
]->arg
;
20604 argv_find(argv
, argc
, "permit", &idx
);
20605 argv_find(argv
, argc
, "deny", &idx
);
20608 direct
= argv_find(argv
, argc
, "permit", &idx
)
20613 argv_find(argv
, argc
, "LINE", &idx
);
20614 str
= argv_concat(argv
, argc
, idx
);
20618 argv_find(argv
, argc
, "(100-500)", &idx
);
20619 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20620 cl_number_or_name
= argv
[idx
]->arg
;
20622 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20623 seq
, direct
, style
);
20625 XFREE(MTYPE_TMP
, str
);
20628 community_list_perror(vty
, ret
);
20629 return CMD_WARNING_CONFIG_FAILED
;
20632 return CMD_SUCCESS
;
20635 ALIAS(no_extcommunity_list_expanded_all
,
20636 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20637 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20638 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20639 "Extended Community list number (expanded)\n"
20640 "Specify expanded extcommunity-list\n"
20641 "Extended Community list name\n")
20643 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20645 struct community_entry
*entry
;
20647 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20648 if (entry
== list
->head
) {
20649 if (all_digit(list
->name
))
20650 vty_out(vty
, "Extended community %s list %s\n",
20651 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20653 : "(expanded) access",
20657 "Named extended community %s list %s\n",
20658 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20664 vty_out(vty
, " %s\n",
20665 community_direct_str(entry
->direct
));
20667 vty_out(vty
, " %s %s\n",
20668 community_direct_str(entry
->direct
),
20669 community_list_config_str(entry
));
20673 DEFUN (show_extcommunity_list
,
20674 show_bgp_extcommunity_list_cmd
,
20675 "show bgp extcommunity-list",
20678 "List extended-community list\n")
20680 struct community_list
*list
;
20681 struct community_list_master
*cm
;
20683 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20685 return CMD_SUCCESS
;
20687 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20688 extcommunity_list_show(vty
, list
);
20690 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20691 extcommunity_list_show(vty
, list
);
20693 return CMD_SUCCESS
;
20696 DEFUN (show_extcommunity_list_arg
,
20697 show_bgp_extcommunity_list_arg_cmd
,
20698 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20701 "List extended-community list\n"
20702 "Extcommunity-list number\n"
20703 "Extcommunity-list name\n"
20704 "Detailed information on extcommunity-list\n")
20706 int idx_comm_list
= 3;
20707 struct community_list
*list
;
20709 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20710 EXTCOMMUNITY_LIST_MASTER
);
20712 vty_out(vty
, "%% Can't find extcommunity-list\n");
20713 return CMD_WARNING
;
20716 extcommunity_list_show(vty
, list
);
20718 return CMD_SUCCESS
;
20721 /* Display community-list and extcommunity-list configuration. */
20722 static int community_list_config_write(struct vty
*vty
)
20724 struct community_list
*list
;
20725 struct community_entry
*entry
;
20726 struct community_list_master
*cm
;
20729 /* Community-list. */
20730 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20732 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20733 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20735 "bgp community-list %s seq %" PRId64
" %s %s\n",
20736 list
->name
, entry
->seq
,
20737 community_direct_str(entry
->direct
),
20738 community_list_config_str(entry
));
20741 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20742 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20744 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20745 entry
->style
== COMMUNITY_LIST_STANDARD
20748 list
->name
, entry
->seq
,
20749 community_direct_str(entry
->direct
),
20750 community_list_config_str(entry
));
20754 /* Extcommunity-list. */
20755 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20757 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20758 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20760 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20761 list
->name
, entry
->seq
,
20762 community_direct_str(entry
->direct
),
20763 community_list_config_str(entry
));
20766 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20767 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20769 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20770 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20773 list
->name
, entry
->seq
,
20774 community_direct_str(entry
->direct
),
20775 community_list_config_str(entry
));
20780 /* lcommunity-list. */
20781 cm
= community_list_master_lookup(bgp_clist
,
20782 LARGE_COMMUNITY_LIST_MASTER
);
20784 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20785 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20787 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20788 list
->name
, entry
->seq
,
20789 community_direct_str(entry
->direct
),
20790 community_list_config_str(entry
));
20793 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20794 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20796 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20798 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20801 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20802 community_list_config_str(entry
));
20809 static int community_list_config_write(struct vty
*vty
);
20810 static struct cmd_node community_list_node
= {
20811 .name
= "community list",
20812 .node
= COMMUNITY_LIST_NODE
,
20814 .config_write
= community_list_config_write
,
20817 static void community_list_vty(void)
20819 install_node(&community_list_node
);
20821 /* Community-list. */
20822 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20823 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20824 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20825 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20826 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20827 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20828 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20829 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20831 /* Extcommunity-list. */
20832 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20833 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20834 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20835 install_element(CONFIG_NODE
,
20836 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20837 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20838 install_element(CONFIG_NODE
,
20839 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20840 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20841 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20843 /* Large Community List */
20844 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20845 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20846 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20847 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20848 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20849 install_element(CONFIG_NODE
,
20850 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20851 install_element(CONFIG_NODE
,
20852 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20853 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20854 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20855 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20856 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20857 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20858 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20860 bgp_community_list_command_completion_setup();
20863 static struct cmd_node community_alias_node
= {
20864 .name
= "community alias",
20865 .node
= COMMUNITY_ALIAS_NODE
,
20867 .config_write
= bgp_community_alias_write
,
20870 void community_alias_vty(void)
20872 install_node(&community_alias_node
);
20874 /* Community-list. */
20875 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20877 bgp_community_alias_command_completion_setup();