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"
81 #include "bgpd/bgp_orr.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
129 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
130 { .val_bool
= false, .match_version
= "< 8.3", },
131 { .val_bool
= true },
133 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
134 { .val_bool
= false, .match_version
= "< 8.3", },
135 { .val_bool
= true },
138 DEFINE_HOOK(bgp_inst_config_write
,
139 (struct bgp
*bgp
, struct vty
*vty
),
141 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
142 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 /* Show BGP peer's information. */
157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
158 struct prefix
*range
, int exact
);
160 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
165 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
168 afi_t afi
, bool use_json
);
170 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
176 return BGP_IPV4_NODE
;
178 return BGP_IPV4M_NODE
;
179 case SAFI_LABELED_UNICAST
:
180 return BGP_IPV4L_NODE
;
182 return BGP_VPNV4_NODE
;
184 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
192 return BGP_IPV6_NODE
;
194 return BGP_IPV6M_NODE
;
195 case SAFI_LABELED_UNICAST
:
196 return BGP_IPV6L_NODE
;
198 return BGP_VPNV6_NODE
;
200 return BGP_FLOWSPECV6_NODE
;
203 return BGP_IPV4_NODE
;
206 return BGP_EVPN_NODE
;
209 // We should never be here but to clarify the switch statement..
210 return BGP_IPV4_NODE
;
213 // Impossible to happen
214 return BGP_IPV4_NODE
;
217 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
220 if (safi
== SAFI_UNICAST
)
221 return "IPv4 Unicast";
222 if (safi
== SAFI_MULTICAST
)
223 return "IPv4 Multicast";
224 if (safi
== SAFI_LABELED_UNICAST
)
225 return "IPv4 Labeled Unicast";
226 if (safi
== SAFI_MPLS_VPN
)
228 if (safi
== SAFI_ENCAP
)
230 if (safi
== SAFI_FLOWSPEC
)
231 return "IPv4 Flowspec";
232 } else if (afi
== AFI_IP6
) {
233 if (safi
== SAFI_UNICAST
)
234 return "IPv6 Unicast";
235 if (safi
== SAFI_MULTICAST
)
236 return "IPv6 Multicast";
237 if (safi
== SAFI_LABELED_UNICAST
)
238 return "IPv6 Labeled Unicast";
239 if (safi
== SAFI_MPLS_VPN
)
241 if (safi
== SAFI_ENCAP
)
243 if (safi
== SAFI_FLOWSPEC
)
244 return "IPv6 Flowspec";
245 } else if (afi
== AFI_L2VPN
) {
246 if (safi
== SAFI_EVPN
)
254 * Please note that we have intentionally camelCased
255 * the return strings here. So if you want
256 * to use this function, please ensure you
257 * are doing this within json output
259 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
262 if (safi
== SAFI_UNICAST
)
263 return "ipv4Unicast";
264 if (safi
== SAFI_MULTICAST
)
265 return "ipv4Multicast";
266 if (safi
== SAFI_LABELED_UNICAST
)
267 return "ipv4LabeledUnicast";
268 if (safi
== SAFI_MPLS_VPN
)
270 if (safi
== SAFI_ENCAP
)
272 if (safi
== SAFI_FLOWSPEC
)
273 return "ipv4Flowspec";
274 } else if (afi
== AFI_IP6
) {
275 if (safi
== SAFI_UNICAST
)
276 return "ipv6Unicast";
277 if (safi
== SAFI_MULTICAST
)
278 return "ipv6Multicast";
279 if (safi
== SAFI_LABELED_UNICAST
)
280 return "ipv6LabeledUnicast";
281 if (safi
== SAFI_MPLS_VPN
)
283 if (safi
== SAFI_ENCAP
)
285 if (safi
== SAFI_FLOWSPEC
)
286 return "ipv6Flowspec";
287 } else if (afi
== AFI_L2VPN
) {
288 if (safi
== SAFI_EVPN
)
295 /* unset srv6 locator */
296 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
299 struct listnode
*node
, *nnode
;
300 struct srv6_locator_chunk
*chunk
, *tovpn_sid_locator
;
301 struct bgp_srv6_function
*func
;
304 /* release chunk notification via ZAPI */
305 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
306 bgp
->srv6_locator_name
);
311 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
312 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
313 srv6_locator_chunk_free(chunk
);
316 /* refresh functions */
317 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
318 listnode_delete(bgp
->srv6_functions
, func
);
319 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
322 /* refresh tovpn_sid */
323 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
324 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
327 /* refresh vpnv4 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
331 /* refresh vpnv6 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
335 /* refresh per-vrf tovpn_sid */
336 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->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 */
349 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
;
350 if (tovpn_sid_locator
) {
351 srv6_locator_chunk_free(tovpn_sid_locator
);
352 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
= NULL
;
355 /* refresh vpnv6 tovpn_sid_locator */
357 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
;
358 if (tovpn_sid_locator
) {
359 srv6_locator_chunk_free(tovpn_sid_locator
);
360 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
= NULL
;
363 /* refresh per-vrf tovpn_sid_locator */
364 srv6_locator_chunk_free(bgp_vrf
->tovpn_sid_locator
);
367 /* clear locator name */
368 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
373 /* Utility function to get address family from current node. */
374 afi_t
bgp_node_afi(struct vty
*vty
)
382 case BGP_FLOWSPECV6_NODE
:
395 /* Utility function to get subsequent address family from current
397 safi_t
bgp_node_safi(struct vty
*vty
)
403 safi
= SAFI_MPLS_VPN
;
407 safi
= SAFI_MULTICAST
;
414 safi
= SAFI_LABELED_UNICAST
;
416 case BGP_FLOWSPECV4_NODE
:
417 case BGP_FLOWSPECV6_NODE
:
418 safi
= SAFI_FLOWSPEC
;
428 * Converts an AFI in string form to afi_t
430 * @param afi string, one of
434 * @return the corresponding afi_t
436 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
438 afi_t afi
= AFI_MAX
; /* unknown */
439 if (strmatch(afi_str
, "ipv4"))
441 else if (strmatch(afi_str
, "ipv6"))
443 else if (strmatch(afi_str
, "l2vpn"))
448 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
452 if (argv_find(argv
, argc
, "ipv4", index
)) {
456 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
460 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
468 /* supports <unicast|multicast|vpn|labeled-unicast> */
469 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
471 safi_t safi
= SAFI_MAX
; /* unknown */
472 if (strmatch(safi_str
, "multicast"))
473 safi
= SAFI_MULTICAST
;
474 else if (strmatch(safi_str
, "unicast"))
476 else if (strmatch(safi_str
, "vpn"))
477 safi
= SAFI_MPLS_VPN
;
478 else if (strmatch(safi_str
, "evpn"))
480 else if (strmatch(safi_str
, "labeled-unicast"))
481 safi
= SAFI_LABELED_UNICAST
;
482 else if (strmatch(safi_str
, "flowspec"))
483 safi
= SAFI_FLOWSPEC
;
487 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
491 if (argv_find(argv
, argc
, "unicast", index
)) {
494 *safi
= SAFI_UNICAST
;
495 } else if (argv_find(argv
, argc
, "multicast", index
)) {
498 *safi
= SAFI_MULTICAST
;
499 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
502 *safi
= SAFI_LABELED_UNICAST
;
503 } else if (argv_find(argv
, argc
, "vpn", index
)) {
506 *safi
= SAFI_MPLS_VPN
;
507 } else if (argv_find(argv
, argc
, "evpn", index
)) {
511 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
514 *safi
= SAFI_FLOWSPEC
;
520 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
523 * address-family identifier
526 * subsequent address-family identifier
529 * default_af string corresponding to the supplied afi/safi pair.
530 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
533 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
539 return "ipv4-unicast";
541 return "ipv4-multicast";
546 case SAFI_LABELED_UNICAST
:
547 return "ipv4-labeled-unicast";
549 return "ipv4-flowspec";
551 return "unknown-afi/safi";
557 return "ipv6-unicast";
559 return "ipv6-multicast";
564 case SAFI_LABELED_UNICAST
:
565 return "ipv6-labeled-unicast";
567 return "ipv6-flowspec";
569 return "unknown-afi/safi";
577 return "unknown-afi/safi";
581 return "unknown-afi/safi";
583 /* all AFIs are accounted for above, so this shouldn't happen */
584 return "unknown-afi/safi";
587 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
588 enum bgp_instance_type inst_type
)
590 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
592 if (ret
== BGP_CREATED
) {
593 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
594 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
596 if (DFLT_BGP_IMPORT_CHECK
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
598 if (DFLT_BGP_SHOW_HOSTNAME
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
600 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
602 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
604 if (DFLT_BGP_DETERMINISTIC_MED
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
606 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
607 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
608 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
609 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
610 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
611 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
612 if (DFLT_BGP_HARD_ADMIN_RESET
)
613 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
621 * bgp_vty_find_and_parse_afi_safi_bgp
623 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
624 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
625 * to appropriate values for the calling function. This is to allow the
626 * calling function to make decisions appropriate for the show command
627 * that is being parsed.
629 * The show commands are generally of the form:
630 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
631 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
633 * Since we use argv_find if the show command in particular doesn't have:
635 * [<view|vrf> VIEWVRFNAME]
636 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
637 * The command parsing should still be ok.
639 * vty -> The vty for the command so we can output some useful data in
640 * the event of a parse error in the vrf.
641 * argv -> The command tokens
642 * argc -> How many command tokens we have
643 * idx -> The current place in the command, generally should be 0 for this
645 * afi -> The parsed afi if it was included in the show command, returned here
646 * safi -> The parsed safi if it was included in the show command, returned here
647 * bgp -> Pointer to the bgp data structure we need to fill in.
648 * use_json -> json is configured or not
650 * The function returns the correct location in the parse tree for the
653 * Returns 0 for failure to parse correctly, else the idx position of where
654 * it found the last token.
656 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
657 struct cmd_token
**argv
, int argc
,
658 int *idx
, afi_t
*afi
, safi_t
*safi
,
659 struct bgp
**bgp
, bool use_json
)
661 char *vrf_name
= NULL
;
667 if (argv_find(argv
, argc
, "ip", idx
))
670 if (argv_find(argv
, argc
, "view", idx
))
671 vrf_name
= argv
[*idx
+ 1]->arg
;
672 else if (argv_find(argv
, argc
, "vrf", idx
)) {
673 vrf_name
= argv
[*idx
+ 1]->arg
;
674 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
678 if (strmatch(vrf_name
, "all"))
681 *bgp
= bgp_lookup_by_name(vrf_name
);
684 json_object
*json
= NULL
;
685 json
= json_object_new_object();
686 json_object_string_add(
688 "View/Vrf is unknown");
692 vty_out(vty
, "View/Vrf %s is unknown\n",
699 *bgp
= bgp_get_default();
702 json_object
*json
= NULL
;
703 json
= json_object_new_object();
704 json_object_string_add(
706 "Default BGP instance not found");
711 "Default BGP instance not found\n");
717 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
718 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
724 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
726 struct interface
*ifp
= NULL
;
727 struct listnode
*node
;
728 struct bgp_listener
*listener
;
729 union sockunion all_su
;
731 if (su
->sa
.sa_family
== AF_INET
) {
732 (void)str2sockunion("0.0.0.0", &all_su
);
733 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
734 } else if (su
->sa
.sa_family
== AF_INET6
) {
735 (void)str2sockunion("::", &all_su
);
736 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
737 su
->sin6
.sin6_scope_id
,
742 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
743 if (sockunion_family(su
) !=
744 sockunion_family(&listener
->su
))
747 /* If 0.0.0.0/:: is a listener, then treat as self and
750 if (!sockunion_cmp(&listener
->su
, su
) ||
751 !sockunion_cmp(&listener
->su
, &all_su
))
759 /* Utility function for looking up peer from VTY. */
760 /* This is used only for configuration, so disallow if attempted on
761 * a dynamic neighbor.
763 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
765 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
774 ret
= str2sockunion(ip_str
, &su
);
776 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
778 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
781 "%% Malformed address or name: %s\n",
787 peer
= peer_lookup(bgp
, &su
);
790 "%% Specify remote-as or peer-group commands first\n");
793 if (peer_dynamic_neighbor(peer
)) {
795 "%% Operation not allowed on a dynamic neighbor\n");
802 /* Utility function for looking up peer or peer group. */
803 /* This is used only for configuration, so disallow if attempted on
804 * a dynamic neighbor.
806 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
808 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
811 struct peer
*peer
= NULL
;
812 struct peer_group
*group
= NULL
;
818 ret
= str2sockunion(peer_str
, &su
);
820 /* IP address, locate peer. */
821 peer
= peer_lookup(bgp
, &su
);
823 /* Not IP, could match either peer configured on interface or a
825 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
827 group
= peer_group_lookup(bgp
, peer_str
);
831 if (peer_dynamic_neighbor(peer
)) {
833 "%% Operation not allowed on a dynamic neighbor\n");
843 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
848 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
850 const char *str
= NULL
;
855 case BGP_GR_NO_OPERATION
:
857 case BGP_ERR_INVALID_VALUE
:
858 str
= "Invalid value";
860 case BGP_ERR_INVALID_FLAG
:
861 str
= "Invalid flag";
863 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
864 str
= "Peer-group has been shutdown. Activate the peer-group first";
866 case BGP_ERR_PEER_FLAG_CONFLICT
:
867 str
= "Can't set override-capability and strict-capability-match at the same time";
869 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
870 str
= "Specify remote-as or peer-group remote AS first";
872 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
873 str
= "Cannot change the peer-group. Deconfigure first";
875 case BGP_ERR_PEER_GROUP_MISMATCH
:
876 str
= "Peer is not a member of this peer-group";
878 case BGP_ERR_PEER_FILTER_CONFLICT
:
879 str
= "Prefix/distribute list can not co-exist";
881 case BGP_ERR_NOT_INTERNAL_PEER
:
882 str
= "Invalid command. Not an internal neighbor";
884 case BGP_ERR_REMOVE_PRIVATE_AS
:
885 str
= "remove-private-AS cannot be configured for IBGP peers";
887 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
888 str
= "Cannot have local-as same as BGP AS number";
890 case BGP_ERR_TCPSIG_FAILED
:
891 str
= "Error while applying TCP-Sig to session(s)";
893 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
894 str
= "ebgp-multihop and ttl-security cannot be configured together";
896 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
897 str
= "ttl-security only allowed for EBGP peers";
899 case BGP_ERR_AS_OVERRIDE
:
900 str
= "as-override cannot be configured for IBGP peers";
902 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
903 str
= "Invalid limit for number of dynamic neighbors";
905 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
906 str
= "Dynamic neighbor listen range already exists";
908 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
909 str
= "Operation not allowed on a dynamic neighbor";
911 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
912 str
= "Operation not allowed on a directly connected neighbor";
914 case BGP_ERR_PEER_SAFI_CONFLICT
:
915 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
917 case BGP_ERR_GR_INVALID_CMD
:
918 str
= "The Graceful Restart command used is not valid at this moment.";
920 case BGP_ERR_GR_OPERATION_FAILED
:
921 str
= "The Graceful Restart Operation failed due to an err.";
923 case BGP_ERR_PEER_GROUP_MEMBER
:
924 str
= "Peer-group member cannot override remote-as of peer-group.";
926 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
927 str
= "Peer-group members must be all internal or all external.";
929 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
930 str
= "Range specified cannot be deleted because it is not part of current config.";
932 case BGP_ERR_INSTANCE_MISMATCH
:
933 str
= "Instance specified does not match the current instance.";
935 case BGP_ERR_NO_INTERFACE_CONFIG
:
936 str
= "Interface specified is not being used for interface based peer.";
938 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
939 str
= "No configuration already specified for soft reconfiguration.";
941 case BGP_ERR_AS_MISMATCH
:
942 str
= "BGP is already running.";
944 case BGP_ERR_AF_UNCONFIGURED
:
945 str
= "AFI/SAFI specified is not currently configured.";
947 case BGP_ERR_INVALID_AS
:
948 str
= "Confederation AS specified is the same AS as our AS.";
950 case BGP_ERR_INVALID_ROLE_NAME
:
951 str
= "Invalid role name";
953 case BGP_ERR_INVALID_INTERNAL_ROLE
:
954 str
= "External roles can be set only on eBGP session";
956 case BGP_ERR_PEER_ORR_CONFIGURED
:
957 str
= "Deconfigure optimal-route-reflection on this peer first";
961 vty_out(vty
, "%% %s\n", str
);
962 return CMD_WARNING_CONFIG_FAILED
;
967 /* BGP clear sort. */
976 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
977 safi_t safi
, int error
)
980 case BGP_ERR_AF_UNCONFIGURED
:
983 "%% BGP: Enable %s address family for the neighbor %s\n",
984 get_afi_safi_str(afi
, safi
, false), peer
->host
);
987 "%% BGP: Enable %s address family for the neighbor %s",
988 get_afi_safi_str(afi
, safi
, false), peer
->host
);
990 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
993 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
997 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
1005 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1006 struct listnode
**nnode
, enum bgp_clear_type stype
)
1009 struct peer_af
*paf
;
1011 /* if afi/.safi not specified, spin thru all of them */
1012 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1015 enum bgp_af_index index
;
1017 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1018 paf
= peer
->peer_af_array
[index
];
1022 if (paf
&& paf
->subgroup
)
1023 SET_FLAG(paf
->subgroup
->sflags
,
1024 SUBGRP_STATUS_FORCE_UPDATES
);
1027 tmp_safi
= paf
->safi
;
1028 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1031 if (stype
== BGP_CLEAR_SOFT_NONE
)
1032 ret
= peer_clear(peer
, nnode
);
1034 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1037 /* if afi specified and safi not, spin thru safis on this afi */
1038 } else if (safi
== SAFI_UNSPEC
) {
1041 for (tmp_safi
= SAFI_UNICAST
;
1042 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1043 if (!peer
->afc
[afi
][tmp_safi
])
1046 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1047 if (paf
&& paf
->subgroup
)
1048 SET_FLAG(paf
->subgroup
->sflags
,
1049 SUBGRP_STATUS_FORCE_UPDATES
);
1051 if (stype
== BGP_CLEAR_SOFT_NONE
)
1052 ret
= peer_clear(peer
, nnode
);
1054 ret
= peer_clear_soft(peer
, afi
,
1057 /* both afi/safi specified, let the caller know if not defined */
1059 if (!peer
->afc
[afi
][safi
])
1062 paf
= peer_af_find(peer
, afi
, safi
);
1063 if (paf
&& paf
->subgroup
)
1064 SET_FLAG(paf
->subgroup
->sflags
,
1065 SUBGRP_STATUS_FORCE_UPDATES
);
1067 if (stype
== BGP_CLEAR_SOFT_NONE
)
1068 ret
= peer_clear(peer
, nnode
);
1070 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1076 /* `clear ip bgp' functions. */
1077 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1078 enum clear_sort sort
, enum bgp_clear_type stype
,
1085 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1087 /* Clear all neighbors. */
1089 * Pass along pointer to next node to peer_clear() when walking all
1090 * nodes on the BGP instance as that may get freed if it is a
1093 if (sort
== clear_all
) {
1094 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1096 bgp_peer_gr_flags_update(peer
);
1098 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1099 gr_router_detected
= true;
1101 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1105 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1108 if (gr_router_detected
1109 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1110 bgp_zebra_send_capabilities(bgp
, false);
1111 } else if (!gr_router_detected
1112 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1113 bgp_zebra_send_capabilities(bgp
, true);
1116 /* This is to apply read-only mode on this clear. */
1117 if (stype
== BGP_CLEAR_SOFT_NONE
)
1118 bgp
->update_delay_over
= 0;
1123 /* Clear specified neighbor. */
1124 if (sort
== clear_peer
) {
1127 /* Make sockunion for lookup. */
1128 ret
= str2sockunion(arg
, &su
);
1130 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1132 peer
= peer_lookup_by_hostname(bgp
, arg
);
1135 "Malformed address or name: %s\n",
1141 peer
= peer_lookup(bgp
, &su
);
1144 "%% BGP: Unknown neighbor - \"%s\"\n",
1150 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1151 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1153 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1155 /* if afi/safi not defined for this peer, let caller know */
1157 ret
= BGP_ERR_AF_UNCONFIGURED
;
1160 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1165 /* Clear all neighbors belonging to a specific peer-group. */
1166 if (sort
== clear_group
) {
1167 struct peer_group
*group
;
1169 group
= peer_group_lookup(bgp
, arg
);
1171 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1175 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1176 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1179 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1186 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1187 get_afi_safi_str(afi
, safi
, false), arg
);
1192 /* Clear all external (eBGP) neighbors. */
1193 if (sort
== clear_external
) {
1194 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1195 if (peer
->sort
== BGP_PEER_IBGP
)
1198 bgp_peer_gr_flags_update(peer
);
1200 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1201 gr_router_detected
= true;
1203 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1206 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1211 if (gr_router_detected
1212 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1213 bgp_zebra_send_capabilities(bgp
, false);
1214 } else if (!gr_router_detected
1215 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1216 bgp_zebra_send_capabilities(bgp
, true);
1221 "%% BGP: No external %s peer is configured\n",
1222 get_afi_safi_str(afi
, safi
, false));
1227 /* Clear all neighbors belonging to a specific AS. */
1228 if (sort
== clear_as
) {
1229 as_t as
= strtoul(arg
, NULL
, 10);
1231 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1235 bgp_peer_gr_flags_update(peer
);
1237 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1238 gr_router_detected
= true;
1240 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1243 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1248 if (gr_router_detected
1249 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1250 bgp_zebra_send_capabilities(bgp
, false);
1251 } else if (!gr_router_detected
1252 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1253 bgp_zebra_send_capabilities(bgp
, true);
1258 "%% BGP: No %s peer is configured with AS %s\n",
1259 get_afi_safi_str(afi
, safi
, false), arg
);
1267 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1268 safi_t safi
, enum clear_sort sort
,
1269 enum bgp_clear_type stype
, const char *arg
)
1273 /* BGP structure lookup. */
1275 bgp
= bgp_lookup_by_name(name
);
1277 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1281 bgp
= bgp_get_default();
1283 vty_out(vty
, "No BGP process is configured\n");
1288 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1291 /* clear soft inbound */
1292 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1297 FOREACH_AFI_SAFI (afi
, safi
)
1298 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1299 BGP_CLEAR_SOFT_IN
, NULL
);
1302 /* clear soft outbound */
1303 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1308 FOREACH_AFI_SAFI (afi
, safi
)
1309 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1310 BGP_CLEAR_SOFT_OUT
, NULL
);
1314 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1316 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1319 #ifndef VTYSH_EXTRACT_PL
1320 #include "bgpd/bgp_vty_clippy.c"
1323 DEFUN_HIDDEN (bgp_local_mac
,
1325 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1327 "Local MAC config\n"
1328 "VxLAN Network Identifier\n"
1332 "mac-mobility sequence\n"
1342 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1343 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1344 vty_out(vty
, "%% Malformed MAC address\n");
1347 memset(&ip
, 0, sizeof(ip
));
1348 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1350 bgp
= bgp_get_default();
1352 vty_out(vty
, "Default BGP instance is not there\n");
1356 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1359 vty_out(vty
, "Internal error\n");
1366 DEFUN_HIDDEN (no_bgp_local_mac
,
1367 no_bgp_local_mac_cmd
,
1368 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1371 "Local MAC config\n"
1372 "VxLAN Network Identifier\n"
1383 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1384 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1385 vty_out(vty
, "%% Malformed MAC address\n");
1388 memset(&ip
, 0, sizeof(ip
));
1390 bgp
= bgp_get_default();
1392 vty_out(vty
, "Default BGP instance is not there\n");
1396 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1398 vty_out(vty
, "Internal error\n");
1405 DEFUN (no_synchronization
,
1406 no_synchronization_cmd
,
1407 "no synchronization",
1409 "Perform IGP synchronization\n")
1414 DEFUN (no_auto_summary
,
1415 no_auto_summary_cmd
,
1418 "Enable automatic network number summarization\n")
1423 /* "router bgp" commands. */
1424 DEFUN_NOSH (router_bgp
,
1426 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1430 BGP_INSTANCE_HELP_STR
)
1433 int idx_view_vrf
= 3;
1439 const char *name
= NULL
;
1440 enum bgp_instance_type inst_type
;
1442 // "router bgp" without an ASN
1444 // Pending: Make VRF option available for ASN less config
1445 bgp
= bgp_get_default();
1448 vty_out(vty
, "%% No BGP process is configured\n");
1449 return CMD_WARNING_CONFIG_FAILED
;
1452 if (listcount(bm
->bgp
) > 1) {
1453 vty_out(vty
, "%% Please specify ASN and VRF\n");
1454 return CMD_WARNING_CONFIG_FAILED
;
1460 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1462 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1463 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1464 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1466 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1468 name
= argv
[idx_vrf
]->arg
;
1470 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1471 if (strmatch(name
, VRF_DEFAULT_NAME
))
1474 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1475 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1476 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1479 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1480 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1482 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1484 case BGP_ERR_AS_MISMATCH
:
1485 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1486 return CMD_WARNING_CONFIG_FAILED
;
1487 case BGP_ERR_INSTANCE_MISMATCH
:
1489 "BGP instance name and AS number mismatch\n");
1491 "BGP instance is already running; AS is %u\n",
1493 return CMD_WARNING_CONFIG_FAILED
;
1497 * If we just instantiated the default instance, complete
1498 * any pending VRF-VPN leaking that was configured via
1499 * earlier "router bgp X vrf FOO" blocks.
1501 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1502 vpn_leak_postchange_all();
1504 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1505 bgp_vpn_leak_export(bgp
);
1506 /* Pending: handle when user tries to change a view to vrf n vv.
1510 /* unset the auto created flag as the user config is now present */
1511 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1512 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1517 /* "no router bgp" commands. */
1518 DEFUN (no_router_bgp
,
1520 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1525 BGP_INSTANCE_HELP_STR
)
1531 const char *name
= NULL
;
1533 // "no router bgp" without an ASN
1535 // Pending: Make VRF option available for ASN less config
1536 bgp
= bgp_get_default();
1539 vty_out(vty
, "%% No BGP process is configured\n");
1540 return CMD_WARNING_CONFIG_FAILED
;
1543 if (listcount(bm
->bgp
) > 1) {
1544 vty_out(vty
, "%% Please specify ASN and VRF\n");
1545 return CMD_WARNING_CONFIG_FAILED
;
1549 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1551 return CMD_WARNING_CONFIG_FAILED
;
1554 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1557 name
= argv
[idx_vrf
]->arg
;
1558 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1559 && strmatch(name
, VRF_DEFAULT_NAME
))
1563 /* Lookup bgp structure. */
1564 bgp
= bgp_lookup(as
, name
);
1566 vty_out(vty
, "%% Can't find BGP instance\n");
1567 return CMD_WARNING_CONFIG_FAILED
;
1571 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1573 return CMD_WARNING_CONFIG_FAILED
;
1576 /* Cannot delete default instance if vrf instances exist */
1577 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1578 struct listnode
*node
;
1579 struct bgp
*tmp_bgp
;
1581 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1582 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1584 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1585 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1586 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1587 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1588 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1589 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1590 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1591 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1592 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1593 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1594 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1595 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1596 (bgp
== bgp_get_evpn() &&
1597 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1598 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1599 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1600 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1601 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1602 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1603 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1604 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1605 (hashcount(tmp_bgp
->vnihash
))) {
1607 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1608 return CMD_WARNING_CONFIG_FAILED
;
1619 /* bgp session-dscp */
1621 DEFPY (bgp_session_dscp
,
1622 bgp_session_dscp_cmd
,
1623 "bgp session-dscp (0-63)$dscp",
1625 "Override default (C6) bgp TCP session DSCP value\n"
1626 "Manually configured dscp parameter\n")
1628 bm
->tcp_dscp
= dscp
<< 2;
1633 DEFPY (no_bgp_session_dscp
,
1634 no_bgp_session_dscp_cmd
,
1635 "no bgp session-dscp [(0-63)]",
1638 "Override default (C6) bgp TCP session DSCP value\n"
1639 "Manually configured dscp parameter\n")
1641 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1646 /* BGP router-id. */
1648 DEFPY (bgp_router_id
,
1650 "bgp router-id A.B.C.D",
1652 "Override configured router identifier\n"
1653 "Manually configured router identifier\n")
1655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1656 bgp_router_id_static_set(bgp
, router_id
);
1660 DEFPY (no_bgp_router_id
,
1661 no_bgp_router_id_cmd
,
1662 "no bgp router-id [A.B.C.D]",
1665 "Override configured router identifier\n"
1666 "Manually configured router identifier\n")
1668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1670 if (router_id_str
) {
1671 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1672 vty_out(vty
, "%% BGP router-id doesn't match\n");
1673 return CMD_WARNING_CONFIG_FAILED
;
1677 router_id
.s_addr
= 0;
1678 bgp_router_id_static_set(bgp
, router_id
);
1683 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1684 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1686 "Add community specific parameters\n"
1687 "Create an alias for a community\n"
1688 "Community (AA:BB or AA:BB:CC)\n"
1691 struct community_alias ca
= {};
1692 struct community_alias
*lookup_community
;
1693 struct community_alias
*lookup_alias
;
1694 struct community
*comm
;
1695 struct lcommunity
*lcomm
;
1696 uint8_t invalid
= 0;
1698 comm
= community_str2com(community
);
1701 community_free(&comm
);
1703 lcomm
= lcommunity_str2com(community
);
1706 lcommunity_free(&lcomm
);
1709 vty_out(vty
, "Invalid community format\n");
1713 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1714 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1716 lookup_community
= bgp_ca_community_lookup(&ca
);
1717 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1720 bgp_ca_alias_delete(&ca
);
1721 bgp_ca_community_delete(&ca
);
1724 /* Lookup if community hash table has an item
1725 * with the same alias name.
1727 strlcpy(ca
.community
, lookup_alias
->community
,
1728 sizeof(ca
.community
));
1729 if (bgp_ca_community_lookup(&ca
)) {
1731 "community (%s) already has this alias (%s)\n",
1732 lookup_alias
->community
,
1733 lookup_alias
->alias
);
1736 bgp_ca_alias_delete(&ca
);
1739 if (lookup_community
) {
1740 /* Lookup if alias hash table has an item
1741 * with the same community.
1743 strlcpy(ca
.alias
, lookup_community
->alias
,
1745 if (bgp_ca_alias_lookup(&ca
)) {
1747 "alias (%s) already has this community (%s)\n",
1748 lookup_community
->alias
,
1749 lookup_community
->community
);
1752 bgp_ca_community_delete(&ca
);
1755 bgp_ca_alias_insert(&ca
);
1756 bgp_ca_community_insert(&ca
);
1762 DEFPY (bgp_global_suppress_fib_pending
,
1763 bgp_global_suppress_fib_pending_cmd
,
1764 "[no] bgp suppress-fib-pending",
1767 "Advertise only routes that are programmed in kernel to peers globally\n")
1769 bm_wait_for_fib_set(!no
);
1774 DEFPY (bgp_suppress_fib_pending
,
1775 bgp_suppress_fib_pending_cmd
,
1776 "[no] bgp suppress-fib-pending",
1779 "Advertise only routes that are programmed in kernel to peers\n")
1781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1783 bgp_suppress_fib_pending_set(bgp
, !no
);
1788 /* BGP Cluster ID. */
1789 DEFUN (bgp_cluster_id
,
1791 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1793 "Configure Route-Reflector Cluster-id\n"
1794 "Route-Reflector Cluster-id in IP address format\n"
1795 "Route-Reflector Cluster-id as 32 bit quantity\n")
1797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1800 struct in_addr cluster
;
1802 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1804 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1805 return CMD_WARNING_CONFIG_FAILED
;
1808 bgp_cluster_id_set(bgp
, &cluster
);
1809 bgp_clear_star_soft_out(vty
, bgp
->name
);
1814 DEFUN (no_bgp_cluster_id
,
1815 no_bgp_cluster_id_cmd
,
1816 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1819 "Configure Route-Reflector Cluster-id\n"
1820 "Route-Reflector Cluster-id in IP address format\n"
1821 "Route-Reflector Cluster-id as 32 bit quantity\n")
1823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1824 bgp_cluster_id_unset(bgp
);
1825 bgp_clear_star_soft_out(vty
, bgp
->name
);
1834 "Disable BGP route installation to RIB (Zebra)\n")
1836 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1838 "%% No-RIB option is already set, nothing to do here.\n");
1842 bgp_option_norib_set_runtime();
1847 DEFPY (no_bgp_norib
,
1852 "Disable BGP route installation to RIB (Zebra)\n")
1854 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1856 "%% No-RIB option is not set, nothing to do here.\n");
1860 bgp_option_norib_unset_runtime();
1865 DEFPY (no_bgp_send_extra_data
,
1866 no_bgp_send_extra_data_cmd
,
1867 "[no] bgp send-extra-data zebra",
1870 "Extra data to Zebra for display/use\n"
1874 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1876 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1881 DEFUN (bgp_confederation_identifier
,
1882 bgp_confederation_identifier_cmd
,
1883 "bgp confederation identifier (1-4294967295)",
1885 "AS confederation parameters\n"
1887 "Set routing domain confederation AS\n")
1889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1893 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1895 bgp_confederation_id_set(bgp
, as
);
1900 DEFUN (no_bgp_confederation_identifier
,
1901 no_bgp_confederation_identifier_cmd
,
1902 "no bgp confederation identifier [(1-4294967295)]",
1905 "AS confederation parameters\n"
1907 "Set routing domain confederation AS\n")
1909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1910 bgp_confederation_id_unset(bgp
);
1915 DEFUN (bgp_confederation_peers
,
1916 bgp_confederation_peers_cmd
,
1917 "bgp confederation peers (1-4294967295)...",
1919 "AS confederation parameters\n"
1920 "Peer ASs in BGP confederation\n"
1923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1928 for (i
= idx_asn
; i
< argc
; i
++) {
1929 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1931 if (bgp
->as
== as
) {
1933 "%% Local member-AS not allowed in confed peer list\n");
1937 bgp_confederation_peers_add(bgp
, as
);
1942 DEFUN (no_bgp_confederation_peers
,
1943 no_bgp_confederation_peers_cmd
,
1944 "no bgp confederation peers (1-4294967295)...",
1947 "AS confederation parameters\n"
1948 "Peer ASs in BGP confederation\n"
1951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1956 for (i
= idx_asn
; i
< argc
; i
++) {
1957 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1959 bgp_confederation_peers_remove(bgp
, as
);
1965 * Central routine for maximum-paths configuration.
1966 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1967 * @set: 1 for setting values, 0 for removing the max-paths config.
1969 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1970 const char *mpaths
, uint16_t options
,
1973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1974 uint16_t maxpaths
= 0;
1979 afi
= bgp_node_afi(vty
);
1980 safi
= bgp_node_safi(vty
);
1983 maxpaths
= strtol(mpaths
, NULL
, 10);
1984 if (maxpaths
> multipath_num
) {
1986 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1987 maxpaths
, multipath_num
);
1988 return CMD_WARNING_CONFIG_FAILED
;
1990 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1993 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1997 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1998 (set
== 1) ? "" : "un",
1999 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2000 maxpaths
, afi
, safi
);
2001 return CMD_WARNING_CONFIG_FAILED
;
2004 bgp_recalculate_all_bestpaths(bgp
);
2009 DEFUN (bgp_maxmed_admin
,
2010 bgp_maxmed_admin_cmd
,
2011 "bgp max-med administrative ",
2013 "Advertise routes with max-med\n"
2014 "Administratively applied, for an indefinite period\n")
2016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp
->v_maxmed_admin
= 1;
2019 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2021 bgp_maxmed_update(bgp
);
2026 DEFUN (bgp_maxmed_admin_medv
,
2027 bgp_maxmed_admin_medv_cmd
,
2028 "bgp max-med administrative (0-4294967295)",
2030 "Advertise routes with max-med\n"
2031 "Administratively applied, for an indefinite period\n"
2032 "Max MED value to be used\n")
2034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2037 bgp
->v_maxmed_admin
= 1;
2038 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2040 bgp_maxmed_update(bgp
);
2045 DEFUN (no_bgp_maxmed_admin
,
2046 no_bgp_maxmed_admin_cmd
,
2047 "no bgp max-med administrative [(0-4294967295)]",
2050 "Advertise routes with max-med\n"
2051 "Administratively applied, for an indefinite period\n"
2052 "Max MED value to be used\n")
2054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2055 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2056 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2057 bgp_maxmed_update(bgp
);
2062 DEFUN (bgp_maxmed_onstartup
,
2063 bgp_maxmed_onstartup_cmd
,
2064 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2066 "Advertise routes with max-med\n"
2067 "Effective on a startup\n"
2068 "Time (seconds) period for max-med\n"
2069 "Max MED value to be used\n")
2071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2074 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2075 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2076 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2077 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2079 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2081 bgp_maxmed_update(bgp
);
2086 DEFUN (no_bgp_maxmed_onstartup
,
2087 no_bgp_maxmed_onstartup_cmd
,
2088 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2091 "Advertise routes with max-med\n"
2092 "Effective on a startup\n"
2093 "Time (seconds) period for max-med\n"
2094 "Max MED value to be used\n")
2096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2098 /* Cancel max-med onstartup if its on */
2099 if (bgp
->t_maxmed_onstartup
) {
2100 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2101 bgp
->maxmed_onstartup_over
= 1;
2104 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2105 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2107 bgp_maxmed_update(bgp
);
2112 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2113 uint16_t update_delay
,
2114 uint16_t establish_wait
)
2116 struct listnode
*node
, *nnode
;
2118 bool vrf_cfg
= false;
2121 * See if update-delay is set per-vrf and warn user to delete it
2122 * Note that we only need to check this if this is the first time
2123 * setting the global config.
2125 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2126 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2127 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2129 "%% update-delay configuration found in vrf %s\n",
2130 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2140 "%%Failed: global update-delay config not permitted\n");
2144 if (!establish_wait
) { /* update-delay <delay> */
2145 bm
->v_update_delay
= update_delay
;
2146 bm
->v_establish_wait
= bm
->v_update_delay
;
2148 /* update-delay <delay> <establish-wait> */
2149 if (update_delay
< establish_wait
) {
2151 "%%Failed: update-delay less than the establish-wait!\n");
2152 return CMD_WARNING_CONFIG_FAILED
;
2155 bm
->v_update_delay
= update_delay
;
2156 bm
->v_establish_wait
= establish_wait
;
2159 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2160 bgp
->v_update_delay
= bm
->v_update_delay
;
2161 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2167 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2169 struct listnode
*node
, *nnode
;
2172 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2173 bm
->v_establish_wait
= bm
->v_update_delay
;
2175 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2176 bgp
->v_update_delay
= bm
->v_update_delay
;
2177 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2183 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2184 uint16_t establish_wait
)
2186 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2188 /* if configured globally, per-instance config is not allowed */
2189 if (bm
->v_update_delay
) {
2191 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2192 return CMD_WARNING_CONFIG_FAILED
;
2196 if (!establish_wait
) /* update-delay <delay> */
2198 bgp
->v_update_delay
= update_delay
;
2199 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2203 /* update-delay <delay> <establish-wait> */
2204 if (update_delay
< establish_wait
) {
2206 "%%Failed: update-delay less than the establish-wait!\n");
2207 return CMD_WARNING_CONFIG_FAILED
;
2210 bgp
->v_update_delay
= update_delay
;
2211 bgp
->v_establish_wait
= establish_wait
;
2216 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2220 /* If configured globally, cannot remove from one bgp instance */
2221 if (bm
->v_update_delay
) {
2223 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2224 return CMD_WARNING_CONFIG_FAILED
;
2226 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2227 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2232 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2234 /* If configured globally, no need to display per-instance value */
2235 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2236 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2237 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2238 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2243 /* Global update-delay configuration */
2244 DEFPY (bgp_global_update_delay
,
2245 bgp_global_update_delay_cmd
,
2246 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2248 "Force initial delay for best-path and updates for all bgp instances\n"
2249 "Max delay in seconds\n"
2250 "Establish wait in seconds\n")
2252 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2255 /* Global update-delay deconfiguration */
2256 DEFPY (no_bgp_global_update_delay
,
2257 no_bgp_global_update_delay_cmd
,
2258 "no bgp update-delay [(0-3600) [(1-3600)]]",
2261 "Force initial delay for best-path and updates\n"
2262 "Max delay in seconds\n"
2263 "Establish wait in seconds\n")
2265 return bgp_global_update_delay_deconfig_vty(vty
);
2268 /* Update-delay configuration */
2270 DEFPY (bgp_update_delay
,
2271 bgp_update_delay_cmd
,
2272 "update-delay (0-3600)$delay [(1-3600)$wait]",
2273 "Force initial delay for best-path and updates\n"
2274 "Max delay in seconds\n"
2275 "Establish wait in seconds\n")
2277 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2280 /* Update-delay deconfiguration */
2281 DEFPY (no_bgp_update_delay
,
2282 no_bgp_update_delay_cmd
,
2283 "no update-delay [(0-3600) [(1-3600)]]",
2285 "Force initial delay for best-path and updates\n"
2286 "Max delay in seconds\n"
2287 "Establish wait in seconds\n")
2289 return bgp_update_delay_deconfig_vty(vty
);
2293 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2298 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2299 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2304 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2309 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2310 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2315 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2318 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2319 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2320 vty_out(vty
, " write-quanta %d\n", quanta
);
2323 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2326 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2327 if (quanta
!= BGP_READ_PACKET_MAX
)
2328 vty_out(vty
, " read-quanta %d\n", quanta
);
2331 /* Packet quanta configuration
2333 * XXX: The value set here controls the size of a stack buffer in the IO
2334 * thread. When changing these limits be careful to prevent stack overflow.
2336 * Furthermore, the maximums used here should correspond to
2337 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2339 DEFPY (bgp_wpkt_quanta
,
2340 bgp_wpkt_quanta_cmd
,
2341 "[no] write-quanta (1-64)$quanta",
2343 "How many packets to write to peer socket per run\n"
2344 "Number of packets\n")
2346 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2349 DEFPY (bgp_rpkt_quanta
,
2350 bgp_rpkt_quanta_cmd
,
2351 "[no] read-quanta (1-10)$quanta",
2353 "How many packets to read from peer socket per I/O cycle\n"
2354 "Number of packets\n")
2356 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2359 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2361 if (!bgp
->heuristic_coalesce
)
2362 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2365 /* BGP TCP keepalive */
2366 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2368 if (bgp
->tcp_keepalive_idle
) {
2369 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2370 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2371 bgp
->tcp_keepalive_probes
);
2375 DEFUN (bgp_coalesce_time
,
2376 bgp_coalesce_time_cmd
,
2377 "coalesce-time (0-4294967295)",
2378 "Subgroup coalesce timer\n"
2379 "Subgroup coalesce timer value (in ms)\n")
2381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2385 bgp
->heuristic_coalesce
= false;
2387 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2388 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2393 DEFUN (no_bgp_coalesce_time
,
2394 no_bgp_coalesce_time_cmd
,
2395 "no coalesce-time (0-4294967295)",
2397 "Subgroup coalesce timer\n"
2398 "Subgroup coalesce timer value (in ms)\n")
2400 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2402 bgp
->heuristic_coalesce
= true;
2403 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2407 /* Maximum-paths configuration */
2408 DEFUN (bgp_maxpaths
,
2410 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2411 "Forward packets over multiple paths\n"
2412 "Number of paths\n")
2415 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2416 argv
[idx_number
]->arg
, 0, 1);
2419 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2420 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2421 "Forward packets over multiple paths\n"
2422 "Number of paths\n")
2424 DEFUN (bgp_maxpaths_ibgp
,
2425 bgp_maxpaths_ibgp_cmd
,
2426 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2427 "Forward packets over multiple paths\n"
2429 "Number of paths\n")
2432 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2433 argv
[idx_number
]->arg
, 0, 1);
2436 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2437 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2438 "Forward packets over multiple paths\n"
2440 "Number of paths\n")
2442 DEFUN (bgp_maxpaths_ibgp_cluster
,
2443 bgp_maxpaths_ibgp_cluster_cmd
,
2444 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2445 "Forward packets over multiple paths\n"
2448 "Match the cluster length\n")
2451 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2452 argv
[idx_number
]->arg
, true, 1);
2455 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2456 "maximum-paths ibgp " CMD_RANGE_STR(
2457 1, MULTIPATH_NUM
) " equal-cluster-length",
2458 "Forward packets over multiple paths\n"
2461 "Match the cluster length\n")
2463 DEFUN (no_bgp_maxpaths
,
2464 no_bgp_maxpaths_cmd
,
2465 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2467 "Forward packets over multiple paths\n"
2468 "Number of paths\n")
2470 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2473 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2474 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2475 "Forward packets over multiple paths\n"
2476 "Number of paths\n")
2478 DEFUN (no_bgp_maxpaths_ibgp
,
2479 no_bgp_maxpaths_ibgp_cmd
,
2480 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2482 "Forward packets over multiple paths\n"
2485 "Match the cluster length\n")
2487 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2490 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2491 "no maximum-paths ibgp [" CMD_RANGE_STR(
2492 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2494 "Forward packets over multiple paths\n"
2497 "Match the cluster length\n")
2499 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2500 afi_t afi
, safi_t safi
)
2502 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2503 vty_out(vty
, " maximum-paths %d\n",
2504 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2507 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2508 vty_out(vty
, " maximum-paths ibgp %d",
2509 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2510 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2511 vty_out(vty
, " equal-cluster-length");
2520 "timers bgp (0-65535) (0-65535)",
2521 "Adjust routing timers\n"
2523 "Keepalive interval\n"
2526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2528 int idx_number_2
= 3;
2529 unsigned long keepalive
= 0;
2530 unsigned long holdtime
= 0;
2532 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2533 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2535 /* Holdtime value check. */
2536 if (holdtime
< 3 && holdtime
!= 0) {
2538 "%% hold time value must be either 0 or greater than 3\n");
2539 return CMD_WARNING_CONFIG_FAILED
;
2542 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2543 BGP_DEFAULT_DELAYOPEN
);
2548 DEFUN (no_bgp_timers
,
2550 "no timers bgp [(0-65535) (0-65535)]",
2552 "Adjust routing timers\n"
2554 "Keepalive interval\n"
2557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2558 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2559 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2564 /* BGP minimum holdtime. */
2566 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2567 "bgp minimum-holdtime (1-65535)",
2568 "BGP specific commands\n"
2569 "BGP minimum holdtime\n"
2572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2574 unsigned long min_holdtime
;
2576 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2578 bgp
->default_min_holdtime
= min_holdtime
;
2583 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2584 "no bgp minimum-holdtime [(1-65535)]",
2586 "BGP specific commands\n"
2587 "BGP minimum holdtime\n"
2590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2592 bgp
->default_min_holdtime
= 0;
2597 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2598 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2600 "TCP keepalive parameters\n"
2601 "TCP keepalive idle time (seconds)\n"
2602 "TCP keepalive interval (seconds)\n"
2603 "TCP keepalive maximum probes\n")
2605 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2607 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2613 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2614 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2617 "TCP keepalive parameters\n"
2618 "TCP keepalive idle time (seconds)\n"
2619 "TCP keepalive interval (seconds)\n"
2620 "TCP keepalive maximum probes\n")
2622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2624 bgp_tcp_keepalive_unset(bgp
);
2629 DEFUN (bgp_client_to_client_reflection
,
2630 bgp_client_to_client_reflection_cmd
,
2631 "bgp client-to-client reflection",
2633 "Configure client to client route reflection\n"
2634 "reflection of routes allowed\n")
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2637 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2638 bgp_clear_star_soft_out(vty
, bgp
->name
);
2643 DEFUN (no_bgp_client_to_client_reflection
,
2644 no_bgp_client_to_client_reflection_cmd
,
2645 "no bgp client-to-client reflection",
2648 "Configure client to client route reflection\n"
2649 "reflection of routes allowed\n")
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2653 bgp_clear_star_soft_out(vty
, bgp
->name
);
2658 /* "bgp always-compare-med" configuration. */
2659 DEFUN (bgp_always_compare_med
,
2660 bgp_always_compare_med_cmd
,
2661 "bgp always-compare-med",
2663 "Allow comparing MED from different neighbors\n")
2665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2666 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2667 bgp_recalculate_all_bestpaths(bgp
);
2672 DEFUN (no_bgp_always_compare_med
,
2673 no_bgp_always_compare_med_cmd
,
2674 "no bgp always-compare-med",
2677 "Allow comparing MED from different neighbors\n")
2679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2680 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2681 bgp_recalculate_all_bestpaths(bgp
);
2687 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2688 "bgp ebgp-requires-policy",
2690 "Require in and out policy for eBGP peers (RFC8212)\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2697 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2698 "no bgp ebgp-requires-policy",
2701 "Require in and out policy for eBGP peers (RFC8212)\n")
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2708 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2709 "bgp suppress-duplicates",
2711 "Suppress duplicate updates if the route actually not changed\n")
2713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2714 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2718 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2719 "no bgp suppress-duplicates",
2722 "Suppress duplicate updates if the route actually not changed\n")
2724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2729 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2730 "bgp reject-as-sets",
2732 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2735 struct listnode
*node
, *nnode
;
2738 bgp
->reject_as_sets
= true;
2740 /* Reset existing BGP sessions to reject routes
2741 * with aspath containing AS_SET or AS_CONFED_SET.
2743 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2744 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2745 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2746 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2747 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2754 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2755 "no bgp reject-as-sets",
2758 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2761 struct listnode
*node
, *nnode
;
2764 bgp
->reject_as_sets
= false;
2766 /* Reset existing BGP sessions to reject routes
2767 * with aspath containing AS_SET or AS_CONFED_SET.
2769 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2770 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2771 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2772 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2773 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2780 /* "bgp deterministic-med" configuration. */
2781 DEFUN (bgp_deterministic_med
,
2782 bgp_deterministic_med_cmd
,
2783 "bgp deterministic-med",
2785 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2789 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2790 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2791 bgp_recalculate_all_bestpaths(bgp
);
2797 DEFUN (no_bgp_deterministic_med
,
2798 no_bgp_deterministic_med_cmd
,
2799 "no bgp deterministic-med",
2802 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2805 int bestpath_per_as_used
;
2809 struct listnode
*node
, *nnode
;
2811 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2812 bestpath_per_as_used
= 0;
2814 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2815 FOREACH_AFI_SAFI (afi
, safi
)
2816 if (bgp_addpath_dmed_required(
2817 peer
->addpath_type
[afi
][safi
])) {
2818 bestpath_per_as_used
= 1;
2822 if (bestpath_per_as_used
)
2826 if (bestpath_per_as_used
) {
2828 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2829 return CMD_WARNING_CONFIG_FAILED
;
2831 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2832 bgp_recalculate_all_bestpaths(bgp
);
2839 /* "bgp graceful-restart mode" configuration. */
2840 DEFUN (bgp_graceful_restart
,
2841 bgp_graceful_restart_cmd
,
2842 "bgp graceful-restart",
2847 int ret
= BGP_GR_FAILURE
;
2849 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2850 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2854 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2856 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2859 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2860 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2862 "Graceful restart configuration changed, reset all peers to take effect\n");
2863 return bgp_vty_return(vty
, ret
);
2866 DEFUN (no_bgp_graceful_restart
,
2867 no_bgp_graceful_restart_cmd
,
2868 "no bgp graceful-restart",
2874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2876 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2877 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2879 int ret
= BGP_GR_FAILURE
;
2881 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2883 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2886 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2887 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2889 "Graceful restart configuration changed, reset all peers to take effect\n");
2891 return bgp_vty_return(vty
, ret
);
2894 DEFUN (bgp_graceful_restart_stalepath_time
,
2895 bgp_graceful_restart_stalepath_time_cmd
,
2896 "bgp graceful-restart stalepath-time (1-4095)",
2898 "Graceful restart capability parameters\n"
2899 "Set the max time to hold onto restarting peer's stale paths\n"
2900 "Delay value (seconds)\n")
2902 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2907 bgp
->stalepath_time
= stalepath
;
2911 DEFUN (bgp_graceful_restart_restart_time
,
2912 bgp_graceful_restart_restart_time_cmd
,
2913 "bgp graceful-restart restart-time (0-4095)",
2915 "Graceful restart capability parameters\n"
2916 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2917 "Delay value (seconds)\n")
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2923 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2924 bgp
->restart_time
= restart
;
2928 DEFUN (bgp_graceful_restart_select_defer_time
,
2929 bgp_graceful_restart_select_defer_time_cmd
,
2930 "bgp graceful-restart select-defer-time (0-3600)",
2932 "Graceful restart capability parameters\n"
2933 "Set the time to defer the BGP route selection after restart\n"
2934 "Delay value (seconds, 0 - disable)\n")
2936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2938 uint32_t defer_time
;
2940 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2941 bgp
->select_defer_time
= defer_time
;
2942 if (defer_time
== 0)
2943 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2945 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2950 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2951 no_bgp_graceful_restart_stalepath_time_cmd
,
2952 "no bgp graceful-restart stalepath-time [(1-4095)]",
2955 "Graceful restart capability parameters\n"
2956 "Set the max time to hold onto restarting peer's stale paths\n"
2957 "Delay value (seconds)\n")
2959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2961 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2965 DEFUN (no_bgp_graceful_restart_restart_time
,
2966 no_bgp_graceful_restart_restart_time_cmd
,
2967 "no bgp graceful-restart restart-time [(0-4095)]",
2970 "Graceful restart capability parameters\n"
2971 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2972 "Delay value (seconds)\n")
2974 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2976 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2980 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2981 no_bgp_graceful_restart_select_defer_time_cmd
,
2982 "no bgp graceful-restart select-defer-time [(0-3600)]",
2985 "Graceful restart capability parameters\n"
2986 "Set the time to defer the BGP route selection after restart\n"
2987 "Delay value (seconds)\n")
2989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2991 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2992 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2997 DEFUN (bgp_graceful_restart_preserve_fw
,
2998 bgp_graceful_restart_preserve_fw_cmd
,
2999 "bgp graceful-restart preserve-fw-state",
3001 "Graceful restart capability parameters\n"
3002 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3005 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3009 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3010 no_bgp_graceful_restart_preserve_fw_cmd
,
3011 "no bgp graceful-restart preserve-fw-state",
3014 "Graceful restart capability parameters\n"
3015 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3018 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3022 DEFPY (bgp_graceful_restart_notification
,
3023 bgp_graceful_restart_notification_cmd
,
3024 "[no$no] bgp graceful-restart notification",
3027 "Graceful restart capability parameters\n"
3028 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3033 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3035 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3040 DEFPY (bgp_administrative_reset
,
3041 bgp_administrative_reset_cmd
,
3042 "[no$no] bgp hard-administrative-reset",
3045 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3050 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3052 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3057 DEFUN (bgp_graceful_restart_disable
,
3058 bgp_graceful_restart_disable_cmd
,
3059 "bgp graceful-restart-disable",
3063 int ret
= BGP_GR_FAILURE
;
3065 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3067 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3069 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3071 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3073 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3076 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3078 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3080 "Graceful restart configuration changed, reset all peers to take effect\n");
3082 return bgp_vty_return(vty
, ret
);
3085 DEFUN (no_bgp_graceful_restart_disable
,
3086 no_bgp_graceful_restart_disable_cmd
,
3087 "no bgp graceful-restart-disable",
3093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3095 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3097 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3099 int ret
= BGP_GR_FAILURE
;
3101 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3103 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3106 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3108 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3110 "Graceful restart configuration changed, reset all peers to take effect\n");
3112 return bgp_vty_return(vty
, ret
);
3115 DEFUN (bgp_neighbor_graceful_restart_set
,
3116 bgp_neighbor_graceful_restart_set_cmd
,
3117 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3125 int ret
= BGP_GR_FAILURE
;
3127 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3129 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3131 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3133 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3135 return CMD_WARNING_CONFIG_FAILED
;
3137 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3139 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3140 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3142 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3144 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3146 "Graceful restart configuration changed, reset this peer to take effect\n");
3148 return bgp_vty_return(vty
, ret
);
3151 DEFUN (no_bgp_neighbor_graceful_restart
,
3152 no_bgp_neighbor_graceful_restart_set_cmd
,
3153 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3161 int ret
= BGP_GR_FAILURE
;
3164 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3166 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3168 return CMD_WARNING_CONFIG_FAILED
;
3170 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3172 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3174 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3176 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3177 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3179 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3181 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3183 "Graceful restart configuration changed, reset this peer to take effect\n");
3185 return bgp_vty_return(vty
, ret
);
3188 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3189 bgp_neighbor_graceful_restart_helper_set_cmd
,
3190 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3193 GR_NEIGHBOR_HELPER_CMD
3198 int ret
= BGP_GR_FAILURE
;
3200 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3202 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3204 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3206 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3209 return CMD_WARNING_CONFIG_FAILED
;
3212 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3214 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3215 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3217 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3219 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3221 "Graceful restart configuration changed, reset this peer to take effect\n");
3223 return bgp_vty_return(vty
, ret
);
3226 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3227 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3228 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3232 NO_GR_NEIGHBOR_HELPER_CMD
3236 int ret
= BGP_GR_FAILURE
;
3239 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3241 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3243 return CMD_WARNING_CONFIG_FAILED
;
3245 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3247 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3249 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3251 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3252 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3254 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3256 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3258 "Graceful restart configuration changed, reset this peer to take effect\n");
3260 return bgp_vty_return(vty
, ret
);
3263 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3264 bgp_neighbor_graceful_restart_disable_set_cmd
,
3265 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3268 GR_NEIGHBOR_DISABLE_CMD
3273 int ret
= BGP_GR_FAILURE
;
3275 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3277 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3279 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3281 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3283 return CMD_WARNING_CONFIG_FAILED
;
3285 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3287 if (peer
->bgp
->t_startup
)
3288 bgp_peer_gr_flags_update(peer
);
3290 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3291 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3293 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3295 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3297 "Graceful restart configuration changed, reset this peer to take effect\n");
3299 return bgp_vty_return(vty
, ret
);
3302 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3303 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3304 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3308 NO_GR_NEIGHBOR_DISABLE_CMD
3312 int ret
= BGP_GR_FAILURE
;
3315 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3317 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3319 return CMD_WARNING_CONFIG_FAILED
;
3321 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3323 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3325 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3327 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3328 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3330 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3332 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3334 "Graceful restart configuration changed, reset this peer to take effect\n");
3336 return bgp_vty_return(vty
, ret
);
3339 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3340 bgp_graceful_restart_disable_eor_cmd
,
3341 "bgp graceful-restart disable-eor",
3343 "Graceful restart configuration parameters\n"
3344 "Disable EOR Check\n")
3346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3347 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3352 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3353 no_bgp_graceful_restart_disable_eor_cmd
,
3354 "no bgp graceful-restart disable-eor",
3357 "Graceful restart configuration parameters\n"
3358 "Disable EOR Check\n")
3360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3361 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3366 DEFUN (bgp_graceful_restart_rib_stale_time
,
3367 bgp_graceful_restart_rib_stale_time_cmd
,
3368 "bgp graceful-restart rib-stale-time (1-3600)",
3370 "Graceful restart configuration parameters\n"
3371 "Specify the stale route removal timer in rib\n"
3372 "Delay value (seconds)\n")
3374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3376 uint32_t stale_time
;
3378 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3379 bgp
->rib_stale_time
= stale_time
;
3380 /* Send the stale timer update message to RIB */
3381 if (bgp_zebra_stale_timer_update(bgp
))
3387 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3388 no_bgp_graceful_restart_rib_stale_time_cmd
,
3389 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3392 "Graceful restart configuration parameters\n"
3393 "Specify the stale route removal timer in rib\n"
3394 "Delay value (seconds)\n")
3396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3398 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3399 /* Send the stale timer update message to RIB */
3400 if (bgp_zebra_stale_timer_update(bgp
))
3406 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3407 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3409 "Enable Long-lived Graceful Restart\n"
3410 "Specifies maximum time to wait before purging long-lived stale routes\n"
3411 "Stale time value (seconds)\n")
3413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3415 uint32_t llgr_stale_time
;
3417 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3418 bgp
->llgr_stale_time
= llgr_stale_time
;
3423 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3424 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3426 "Enable Long-lived Graceful Restart\n"
3427 "Specifies maximum time to wait before purging long-lived stale routes\n"
3428 "Stale time value (seconds)\n")
3430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3432 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3437 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3440 bgp_static_redo_import_check(bgp
);
3441 bgp_redistribute_redo(bgp
);
3442 bgp_clear_star_soft_out(vty
, bgp
->name
);
3443 bgp_clear_star_soft_in(vty
, bgp
->name
);
3446 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3448 struct listnode
*node
, *nnode
;
3450 bool vrf_cfg
= false;
3452 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3455 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3456 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3457 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3459 "%% graceful-shutdown configuration found in vrf %s\n",
3460 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3461 VRF_DEFAULT_NAME
: bgp
->name
);
3468 "%%Failed: global graceful-shutdown not permitted\n");
3472 /* Set flag globally */
3473 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3475 /* Initiate processing for all BGP instances. */
3476 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3477 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3482 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3484 struct listnode
*node
, *nnode
;
3487 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3490 /* Unset flag globally */
3491 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3493 /* Initiate processing for all BGP instances. */
3494 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3495 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3500 /* "bgp graceful-shutdown" configuration */
3501 DEFUN (bgp_graceful_shutdown
,
3502 bgp_graceful_shutdown_cmd
,
3503 "bgp graceful-shutdown",
3505 "Graceful shutdown parameters\n")
3507 if (vty
->node
== CONFIG_NODE
)
3508 return bgp_global_graceful_shutdown_config_vty(vty
);
3510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3512 /* if configured globally, per-instance config is not allowed */
3513 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3515 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3516 return CMD_WARNING_CONFIG_FAILED
;
3519 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3520 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3521 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3527 DEFUN (no_bgp_graceful_shutdown
,
3528 no_bgp_graceful_shutdown_cmd
,
3529 "no bgp graceful-shutdown",
3532 "Graceful shutdown parameters\n")
3534 if (vty
->node
== CONFIG_NODE
)
3535 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3539 /* If configured globally, cannot remove from one bgp instance */
3540 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3542 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3543 return CMD_WARNING_CONFIG_FAILED
;
3546 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3547 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3548 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3554 /* "bgp fast-external-failover" configuration. */
3555 DEFUN (bgp_fast_external_failover
,
3556 bgp_fast_external_failover_cmd
,
3557 "bgp fast-external-failover",
3559 "Immediately reset session if a link to a directly connected external peer goes down\n")
3561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3562 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3566 DEFUN (no_bgp_fast_external_failover
,
3567 no_bgp_fast_external_failover_cmd
,
3568 "no bgp fast-external-failover",
3571 "Immediately reset session if a link to a directly connected external peer goes down\n")
3573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3574 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3578 /* "bgp bestpath compare-routerid" configuration. */
3579 DEFUN (bgp_bestpath_compare_router_id
,
3580 bgp_bestpath_compare_router_id_cmd
,
3581 "bgp bestpath compare-routerid",
3583 "Change the default bestpath selection\n"
3584 "Compare router-id for identical EBGP paths\n")
3586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3587 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3588 bgp_recalculate_all_bestpaths(bgp
);
3593 DEFUN (no_bgp_bestpath_compare_router_id
,
3594 no_bgp_bestpath_compare_router_id_cmd
,
3595 "no bgp bestpath compare-routerid",
3598 "Change the default bestpath selection\n"
3599 "Compare router-id for identical EBGP paths\n")
3601 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3602 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3603 bgp_recalculate_all_bestpaths(bgp
);
3608 /* "bgp bestpath as-path ignore" configuration. */
3609 DEFUN (bgp_bestpath_aspath_ignore
,
3610 bgp_bestpath_aspath_ignore_cmd
,
3611 "bgp bestpath as-path ignore",
3613 "Change the default bestpath selection\n"
3614 "AS-path attribute\n"
3615 "Ignore as-path length in selecting a route\n")
3617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3618 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3619 bgp_recalculate_all_bestpaths(bgp
);
3624 DEFUN (no_bgp_bestpath_aspath_ignore
,
3625 no_bgp_bestpath_aspath_ignore_cmd
,
3626 "no bgp bestpath as-path ignore",
3629 "Change the default bestpath selection\n"
3630 "AS-path attribute\n"
3631 "Ignore as-path length in selecting a route\n")
3633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3634 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3635 bgp_recalculate_all_bestpaths(bgp
);
3640 /* "bgp bestpath as-path confed" configuration. */
3641 DEFUN (bgp_bestpath_aspath_confed
,
3642 bgp_bestpath_aspath_confed_cmd
,
3643 "bgp bestpath as-path confed",
3645 "Change the default bestpath selection\n"
3646 "AS-path attribute\n"
3647 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3650 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3651 bgp_recalculate_all_bestpaths(bgp
);
3656 DEFUN (no_bgp_bestpath_aspath_confed
,
3657 no_bgp_bestpath_aspath_confed_cmd
,
3658 "no bgp bestpath as-path confed",
3661 "Change the default bestpath selection\n"
3662 "AS-path attribute\n"
3663 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3666 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3667 bgp_recalculate_all_bestpaths(bgp
);
3672 /* "bgp bestpath as-path multipath-relax" configuration. */
3673 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3674 bgp_bestpath_aspath_multipath_relax_cmd
,
3675 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3677 "Change the default bestpath selection\n"
3678 "AS-path attribute\n"
3679 "Allow load sharing across routes that have different AS paths (but same length)\n"
3680 "Generate an AS_SET\n"
3681 "Do not generate an AS_SET\n")
3683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3685 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3687 /* no-as-set is now the default behavior so we can silently
3689 if (argv_find(argv
, argc
, "as-set", &idx
))
3690 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3692 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3694 bgp_recalculate_all_bestpaths(bgp
);
3699 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3700 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3701 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3704 "Change the default bestpath selection\n"
3705 "AS-path attribute\n"
3706 "Allow load sharing across routes that have different AS paths (but same length)\n"
3707 "Generate an AS_SET\n"
3708 "Do not generate an AS_SET\n")
3710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3711 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3712 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3713 bgp_recalculate_all_bestpaths(bgp
);
3718 /* "bgp bestpath peer-type multipath-relax" configuration. */
3719 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3720 bgp_bestpath_peer_type_multipath_relax_cmd
,
3721 "bgp bestpath peer-type multipath-relax",
3723 "Change the default bestpath selection\n"
3725 "Allow load sharing across routes learned from different peer types\n")
3727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3728 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3729 bgp_recalculate_all_bestpaths(bgp
);
3734 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3735 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3736 "no bgp bestpath peer-type multipath-relax",
3738 "Change the default bestpath selection\n"
3740 "Allow load sharing across routes learned from different peer types\n")
3742 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3743 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3744 bgp_recalculate_all_bestpaths(bgp
);
3749 /* "bgp log-neighbor-changes" configuration. */
3750 DEFUN (bgp_log_neighbor_changes
,
3751 bgp_log_neighbor_changes_cmd
,
3752 "bgp log-neighbor-changes",
3754 "Log neighbor up/down and reset reason\n")
3756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3757 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3761 DEFUN (no_bgp_log_neighbor_changes
,
3762 no_bgp_log_neighbor_changes_cmd
,
3763 "no bgp log-neighbor-changes",
3766 "Log neighbor up/down and reset reason\n")
3768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3769 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3773 /* "bgp bestpath med" configuration. */
3774 DEFUN (bgp_bestpath_med
,
3775 bgp_bestpath_med_cmd
,
3776 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3778 "Change the default bestpath selection\n"
3780 "Compare MED among confederation paths\n"
3781 "Treat missing MED as the least preferred one\n"
3782 "Treat missing MED as the least preferred one\n"
3783 "Compare MED among confederation paths\n")
3785 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3788 if (argv_find(argv
, argc
, "confed", &idx
))
3789 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3791 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3792 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3794 bgp_recalculate_all_bestpaths(bgp
);
3799 DEFUN (no_bgp_bestpath_med
,
3800 no_bgp_bestpath_med_cmd
,
3801 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3804 "Change the default bestpath selection\n"
3806 "Compare MED among confederation paths\n"
3807 "Treat missing MED as the least preferred one\n"
3808 "Treat missing MED as the least preferred one\n"
3809 "Compare MED among confederation paths\n")
3811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3814 if (argv_find(argv
, argc
, "confed", &idx
))
3815 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3817 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3818 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3820 bgp_recalculate_all_bestpaths(bgp
);
3825 /* "bgp bestpath bandwidth" configuration. */
3826 DEFPY (bgp_bestpath_bw
,
3827 bgp_bestpath_bw_cmd
,
3828 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3830 "Change the default bestpath selection\n"
3831 "Link Bandwidth attribute\n"
3832 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3833 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3834 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3841 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3842 return CMD_ERR_INCOMPLETE
;
3844 if (!strcmp(bw_cfg
, "ignore"))
3845 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3846 else if (!strcmp(bw_cfg
, "skip-missing"))
3847 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3848 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3849 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3851 return CMD_ERR_NO_MATCH
;
3853 /* This config is used in route install, so redo that. */
3854 FOREACH_AFI_SAFI (afi
, safi
) {
3855 if (!bgp_fibupd_safi(safi
))
3857 bgp_zebra_announce_table(bgp
, afi
, safi
);
3863 DEFPY (no_bgp_bestpath_bw
,
3864 no_bgp_bestpath_bw_cmd
,
3865 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3868 "Change the default bestpath selection\n"
3869 "Link Bandwidth attribute\n"
3870 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3871 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3872 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3878 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3880 /* This config is used in route install, so redo that. */
3881 FOREACH_AFI_SAFI (afi
, safi
) {
3882 if (!bgp_fibupd_safi(safi
))
3884 bgp_zebra_announce_table(bgp
, afi
, safi
);
3889 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3890 "[no] bgp default <ipv4-unicast|"
3893 "ipv4-labeled-unicast|"
3898 "ipv6-labeled-unicast|"
3900 "l2vpn-evpn>$afi_safi",
3903 "Configure BGP defaults\n"
3904 "Activate ipv4-unicast for a peer by default\n"
3905 "Activate ipv4-multicast for a peer by default\n"
3906 "Activate ipv4-vpn for a peer by default\n"
3907 "Activate ipv4-labeled-unicast for a peer by default\n"
3908 "Activate ipv4-flowspec for a peer by default\n"
3909 "Activate ipv6-unicast for a peer by default\n"
3910 "Activate ipv6-multicast for a peer by default\n"
3911 "Activate ipv6-vpn for a peer by default\n"
3912 "Activate ipv6-labeled-unicast for a peer by default\n"
3913 "Activate ipv6-flowspec for a peer by default\n"
3914 "Activate l2vpn-evpn for a peer by default\n")
3916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3917 char afi_safi_str
[strlen(afi_safi
) + 1];
3918 char *afi_safi_str_tok
;
3920 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3921 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3922 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3923 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3927 * Impossible situation but making coverity happy
3929 assert(afi
!= AFI_MAX
);
3931 if (strmatch(safi_str
, "labeled"))
3932 safi
= bgp_vty_safi_from_str("labeled-unicast");
3934 safi
= bgp_vty_safi_from_str(safi_str
);
3936 assert(safi
!= SAFI_MAX
);
3938 bgp
->default_af
[afi
][safi
] = false;
3940 if ((safi
== SAFI_LABELED_UNICAST
3941 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3942 || (safi
== SAFI_UNICAST
3943 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3944 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3946 bgp
->default_af
[afi
][safi
] = true;
3952 /* Display hostname in certain command outputs */
3953 DEFUN (bgp_default_show_hostname
,
3954 bgp_default_show_hostname_cmd
,
3955 "bgp default show-hostname",
3957 "Configure BGP defaults\n"
3958 "Show hostname in certain command outputs\n")
3960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3961 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3965 DEFUN (no_bgp_default_show_hostname
,
3966 no_bgp_default_show_hostname_cmd
,
3967 "no bgp default show-hostname",
3970 "Configure BGP defaults\n"
3971 "Show hostname in certain command outputs\n")
3973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3974 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3978 /* Display hostname in certain command outputs */
3979 DEFUN (bgp_default_show_nexthop_hostname
,
3980 bgp_default_show_nexthop_hostname_cmd
,
3981 "bgp default show-nexthop-hostname",
3983 "Configure BGP defaults\n"
3984 "Show hostname for nexthop in certain command outputs\n")
3986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3987 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3991 DEFUN (no_bgp_default_show_nexthop_hostname
,
3992 no_bgp_default_show_nexthop_hostname_cmd
,
3993 "no bgp default show-nexthop-hostname",
3996 "Configure BGP defaults\n"
3997 "Show hostname for nexthop in certain command outputs\n")
3999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4000 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4004 /* "bgp network import-check" configuration. */
4005 DEFUN (bgp_network_import_check
,
4006 bgp_network_import_check_cmd
,
4007 "bgp network import-check",
4009 "BGP network command\n"
4010 "Check BGP network route exists in IGP\n")
4012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4013 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4014 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4015 bgp_static_redo_import_check(bgp
);
4021 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4022 "bgp network import-check exact",
4024 "BGP network command\n"
4025 "Check BGP network route exists in IGP\n"
4026 "Match route precisely\n")
4028 DEFUN (no_bgp_network_import_check
,
4029 no_bgp_network_import_check_cmd
,
4030 "no bgp network import-check",
4033 "BGP network command\n"
4034 "Check BGP network route exists in IGP\n")
4036 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4037 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4038 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4039 bgp_static_redo_import_check(bgp
);
4045 DEFUN (bgp_default_local_preference
,
4046 bgp_default_local_preference_cmd
,
4047 "bgp default local-preference (0-4294967295)",
4049 "Configure BGP defaults\n"
4050 "local preference (higher=more preferred)\n"
4051 "Configure default local preference value\n")
4053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4055 uint32_t local_pref
;
4057 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4059 bgp_default_local_preference_set(bgp
, local_pref
);
4060 bgp_clear_star_soft_in(vty
, bgp
->name
);
4065 DEFUN (no_bgp_default_local_preference
,
4066 no_bgp_default_local_preference_cmd
,
4067 "no bgp default local-preference [(0-4294967295)]",
4070 "Configure BGP defaults\n"
4071 "local preference (higher=more preferred)\n"
4072 "Configure default local preference value\n")
4074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4075 bgp_default_local_preference_unset(bgp
);
4076 bgp_clear_star_soft_in(vty
, bgp
->name
);
4082 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4083 bgp_default_subgroup_pkt_queue_max_cmd
,
4084 "bgp default subgroup-pkt-queue-max (20-100)",
4086 "Configure BGP defaults\n"
4087 "subgroup-pkt-queue-max\n"
4088 "Configure subgroup packet queue max\n")
4090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4094 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4096 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4101 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4102 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4103 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4106 "Configure BGP defaults\n"
4107 "subgroup-pkt-queue-max\n"
4108 "Configure subgroup packet queue max\n")
4110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4111 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4116 DEFUN (bgp_rr_allow_outbound_policy
,
4117 bgp_rr_allow_outbound_policy_cmd
,
4118 "bgp route-reflector allow-outbound-policy",
4120 "Allow modifications made by out route-map\n"
4121 "on ibgp neighbors\n")
4123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4125 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4126 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4127 update_group_announce_rrclients(bgp
);
4128 bgp_clear_star_soft_out(vty
, bgp
->name
);
4134 DEFUN (no_bgp_rr_allow_outbound_policy
,
4135 no_bgp_rr_allow_outbound_policy_cmd
,
4136 "no bgp route-reflector allow-outbound-policy",
4139 "Allow modifications made by out route-map\n"
4140 "on ibgp neighbors\n")
4142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4144 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4145 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4146 update_group_announce_rrclients(bgp
);
4147 bgp_clear_star_soft_out(vty
, bgp
->name
);
4153 DEFUN (bgp_listen_limit
,
4154 bgp_listen_limit_cmd
,
4155 "bgp listen limit (1-65535)",
4157 "BGP Dynamic Neighbors listen commands\n"
4158 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4159 "Configure Dynamic Neighbors listen limit value\n")
4161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4165 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4167 bgp_listen_limit_set(bgp
, listen_limit
);
4172 DEFUN (no_bgp_listen_limit
,
4173 no_bgp_listen_limit_cmd
,
4174 "no bgp listen limit [(1-65535)]",
4177 "BGP Dynamic Neighbors listen commands\n"
4178 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4179 "Configure Dynamic Neighbors listen limit value\n")
4181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4182 bgp_listen_limit_unset(bgp
);
4188 * Check if this listen range is already configured. Check for exact
4189 * match or overlap based on input.
4191 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4192 struct prefix
*range
, int exact
)
4194 struct listnode
*node
, *nnode
;
4195 struct listnode
*node1
, *nnode1
;
4196 struct peer_group
*group
;
4201 afi
= family2afi(range
->family
);
4202 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4203 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4206 match
= prefix_same(range
, lr
);
4208 match
= (prefix_match(range
, lr
)
4209 || prefix_match(lr
, range
));
4218 DEFUN (bgp_listen_range
,
4219 bgp_listen_range_cmd
,
4220 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4222 "Configure BGP dynamic neighbors listen range\n"
4223 "Configure BGP dynamic neighbors listen range\n"
4225 "Member of the peer-group\n"
4226 "Peer-group name\n")
4228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4229 struct prefix range
;
4230 struct peer_group
*group
, *existing_group
;
4235 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4236 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4237 char *prefix
= argv
[idx
]->arg
;
4238 argv_find(argv
, argc
, "PGNAME", &idx
);
4239 char *peergroup
= argv
[idx
]->arg
;
4241 /* Convert IP prefix string to struct prefix. */
4242 ret
= str2prefix(prefix
, &range
);
4244 vty_out(vty
, "%% Malformed listen range\n");
4245 return CMD_WARNING_CONFIG_FAILED
;
4248 afi
= family2afi(range
.family
);
4250 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4252 "%% Malformed listen range (link-local address)\n");
4253 return CMD_WARNING_CONFIG_FAILED
;
4258 /* Check if same listen range is already configured. */
4259 existing_group
= listen_range_exists(bgp
, &range
, 1);
4260 if (existing_group
) {
4261 if (strcmp(existing_group
->name
, peergroup
) == 0)
4265 "%% Same listen range is attached to peer-group %s\n",
4266 existing_group
->name
);
4267 return CMD_WARNING_CONFIG_FAILED
;
4271 /* Check if an overlapping listen range exists. */
4272 if (listen_range_exists(bgp
, &range
, 0)) {
4274 "%% Listen range overlaps with existing listen range\n");
4275 return CMD_WARNING_CONFIG_FAILED
;
4278 group
= peer_group_lookup(bgp
, peergroup
);
4280 vty_out(vty
, "%% Configure the peer-group first\n");
4281 return CMD_WARNING_CONFIG_FAILED
;
4284 ret
= peer_group_listen_range_add(group
, &range
);
4285 return bgp_vty_return(vty
, ret
);
4288 DEFUN (no_bgp_listen_range
,
4289 no_bgp_listen_range_cmd
,
4290 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4293 "Unconfigure BGP dynamic neighbors listen range\n"
4294 "Unconfigure BGP dynamic neighbors listen range\n"
4296 "Member of the peer-group\n"
4297 "Peer-group name\n")
4299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4300 struct prefix range
;
4301 struct peer_group
*group
;
4306 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4307 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4308 char *prefix
= argv
[idx
]->arg
;
4309 argv_find(argv
, argc
, "PGNAME", &idx
);
4310 char *peergroup
= argv
[idx
]->arg
;
4312 /* Convert IP prefix string to struct prefix. */
4313 ret
= str2prefix(prefix
, &range
);
4315 vty_out(vty
, "%% Malformed listen range\n");
4316 return CMD_WARNING_CONFIG_FAILED
;
4319 afi
= family2afi(range
.family
);
4321 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4323 "%% Malformed listen range (link-local address)\n");
4324 return CMD_WARNING_CONFIG_FAILED
;
4329 group
= peer_group_lookup(bgp
, peergroup
);
4331 vty_out(vty
, "%% Peer-group does not exist\n");
4332 return CMD_WARNING_CONFIG_FAILED
;
4335 ret
= peer_group_listen_range_del(group
, &range
);
4336 return bgp_vty_return(vty
, ret
);
4339 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4341 struct peer_group
*group
;
4342 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4343 struct prefix
*range
;
4346 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4347 vty_out(vty
, " bgp listen limit %d\n",
4348 bgp
->dynamic_neighbors_limit
);
4350 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4351 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4352 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4355 " bgp listen range %pFX peer-group %s\n",
4356 range
, group
->name
);
4363 DEFUN (bgp_disable_connected_route_check
,
4364 bgp_disable_connected_route_check_cmd
,
4365 "bgp disable-ebgp-connected-route-check",
4367 "Disable checking if nexthop is connected on ebgp sessions\n")
4369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4370 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4371 bgp_clear_star_soft_in(vty
, bgp
->name
);
4376 DEFUN (no_bgp_disable_connected_route_check
,
4377 no_bgp_disable_connected_route_check_cmd
,
4378 "no bgp disable-ebgp-connected-route-check",
4381 "Disable checking if nexthop is connected on ebgp sessions\n")
4383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4384 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4385 bgp_clear_star_soft_in(vty
, bgp
->name
);
4391 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4397 int as_type
= AS_SPECIFIED
;
4400 if (as_str
[0] == 'i') {
4402 as_type
= AS_INTERNAL
;
4403 } else if (as_str
[0] == 'e') {
4405 as_type
= AS_EXTERNAL
;
4407 /* Get AS number. */
4408 as
= strtoul(as_str
, NULL
, 10);
4411 /* If peer is peer group or interface peer, call proper function. */
4412 ret
= str2sockunion(peer_str
, &su
);
4416 /* Check if existing interface peer */
4417 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4419 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4421 /* if not interface peer, check peer-group settings */
4422 if (ret
< 0 && !peer
) {
4423 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4426 "%% Create the peer-group or interface first\n");
4427 return CMD_WARNING_CONFIG_FAILED
;
4432 if (peer_address_self_check(bgp
, &su
)) {
4434 "%% Can not configure the local system as neighbor\n");
4435 return CMD_WARNING_CONFIG_FAILED
;
4437 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4440 return bgp_vty_return(vty
, ret
);
4443 DEFUN (bgp_default_shutdown
,
4444 bgp_default_shutdown_cmd
,
4445 "[no] bgp default shutdown",
4448 "Configure BGP defaults\n"
4449 "Apply administrative shutdown to newly configured peers\n")
4451 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4452 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4456 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4458 "Administrative shutdown of the BGP instance\n"
4459 "Add a shutdown message (RFC 8203)\n"
4460 "Shutdown message\n")
4462 char *msgstr
= NULL
;
4464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4467 msgstr
= argv_concat(argv
, argc
, 3);
4469 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4470 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4471 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4472 return CMD_WARNING_CONFIG_FAILED
;
4475 bgp_shutdown_enable(bgp
, msgstr
);
4476 XFREE(MTYPE_TMP
, msgstr
);
4481 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4482 BGP_STR
"Administrative shutdown of the BGP instance\n")
4484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4486 bgp_shutdown_enable(bgp
, NULL
);
4491 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4492 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4494 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4496 bgp_shutdown_disable(bgp
);
4501 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4502 "no bgp shutdown message MSG...", NO_STR BGP_STR
4503 "Administrative shutdown of the BGP instance\n"
4504 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4506 DEFUN (neighbor_remote_as
,
4507 neighbor_remote_as_cmd
,
4508 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4511 "Specify a BGP neighbor\n"
4513 "Internal BGP peer\n"
4514 "External BGP peer\n")
4517 int idx_remote_as
= 3;
4518 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4519 argv
[idx_remote_as
]->arg
);
4522 DEFPY (bgp_allow_martian
,
4523 bgp_allow_martian_cmd
,
4524 "[no]$no bgp allow-martian-nexthop",
4527 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4532 bgp
->allow_martian
= false;
4534 bgp
->allow_martian
= true;
4539 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4540 * sessions do not wait for hold timer expiry to bring down the sessions
4541 * when nexthop becomes unreachable
4543 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4544 BGP_STR
"Fast convergence for bgp sessions\n")
4546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4547 bgp
->fast_convergence
= true;
4552 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4553 "no bgp fast-convergence",
4554 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4557 bgp
->fast_convergence
= false;
4562 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4564 const char *peer_group_name
,
4567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4569 int as_type
= AS_UNSPECIFIED
;
4571 struct peer_group
*group
;
4574 group
= peer_group_lookup(bgp
, conf_if
);
4577 vty_out(vty
, "%% Name conflict with peer-group \n");
4578 return CMD_WARNING_CONFIG_FAILED
;
4582 if (as_str
[0] == 'i') {
4583 as_type
= AS_INTERNAL
;
4584 } else if (as_str
[0] == 'e') {
4585 as_type
= AS_EXTERNAL
;
4587 /* Get AS number. */
4588 as
= strtoul(as_str
, NULL
, 10);
4589 as_type
= AS_SPECIFIED
;
4593 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4596 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4598 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4602 vty_out(vty
, "%% BGP failed to create peer\n");
4603 return CMD_WARNING_CONFIG_FAILED
;
4607 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4609 /* Request zebra to initiate IPv6 RAs on this interface. We do
4611 * any unnumbered peer in order to not worry about run-time
4613 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4615 * gets deleted later etc.)
4618 bgp_zebra_initiate_radv(bgp
, peer
);
4621 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4622 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4624 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4626 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4628 /* v6only flag changed. Reset bgp seesion */
4629 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4630 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4631 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4632 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4634 bgp_session_reset(peer
);
4637 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4638 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4639 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4640 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4643 if (peer_group_name
) {
4644 group
= peer_group_lookup(bgp
, peer_group_name
);
4646 vty_out(vty
, "%% Configure the peer-group first\n");
4647 return CMD_WARNING_CONFIG_FAILED
;
4650 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4653 return bgp_vty_return(vty
, ret
);
4656 DEFUN (neighbor_interface_config
,
4657 neighbor_interface_config_cmd
,
4658 "neighbor WORD interface [peer-group PGNAME]",
4660 "Interface name or neighbor tag\n"
4661 "Enable BGP on interface\n"
4662 "Member of the peer-group\n"
4663 "Peer-group name\n")
4666 int idx_peer_group_word
= 4;
4668 if (argc
> idx_peer_group_word
)
4669 return peer_conf_interface_get(
4670 vty
, argv
[idx_word
]->arg
, 0,
4671 argv
[idx_peer_group_word
]->arg
, NULL
);
4673 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4677 DEFUN (neighbor_interface_config_v6only
,
4678 neighbor_interface_config_v6only_cmd
,
4679 "neighbor WORD interface v6only [peer-group PGNAME]",
4681 "Interface name or neighbor tag\n"
4682 "Enable BGP on interface\n"
4683 "Enable BGP with v6 link-local only\n"
4684 "Member of the peer-group\n"
4685 "Peer-group name\n")
4688 int idx_peer_group_word
= 5;
4690 if (argc
> idx_peer_group_word
)
4691 return peer_conf_interface_get(
4692 vty
, argv
[idx_word
]->arg
, 1,
4693 argv
[idx_peer_group_word
]->arg
, NULL
);
4695 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4699 DEFUN (neighbor_interface_config_remote_as
,
4700 neighbor_interface_config_remote_as_cmd
,
4701 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4703 "Interface name or neighbor tag\n"
4704 "Enable BGP on interface\n"
4705 "Specify a BGP neighbor\n"
4707 "Internal BGP peer\n"
4708 "External BGP peer\n")
4711 int idx_remote_as
= 4;
4712 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4713 argv
[idx_remote_as
]->arg
);
4716 DEFUN (neighbor_interface_v6only_config_remote_as
,
4717 neighbor_interface_v6only_config_remote_as_cmd
,
4718 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4720 "Interface name or neighbor tag\n"
4721 "Enable BGP with v6 link-local only\n"
4722 "Enable BGP on interface\n"
4723 "Specify a BGP neighbor\n"
4725 "Internal BGP peer\n"
4726 "External BGP peer\n")
4729 int idx_remote_as
= 5;
4730 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4731 argv
[idx_remote_as
]->arg
);
4734 DEFUN (neighbor_peer_group
,
4735 neighbor_peer_group_cmd
,
4736 "neighbor WORD peer-group",
4738 "Interface name or neighbor tag\n"
4739 "Configure peer-group\n")
4741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4744 struct peer_group
*group
;
4746 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4748 vty_out(vty
, "%% Name conflict with interface: \n");
4749 return CMD_WARNING_CONFIG_FAILED
;
4752 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4754 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4755 return CMD_WARNING_CONFIG_FAILED
;
4763 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4767 "Specify a BGP neighbor\n"
4769 "Internal BGP peer\n"
4770 "External BGP peer\n")
4772 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4776 struct peer_group
*group
;
4780 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4782 /* look up for neighbor by interface name config. */
4783 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4785 /* Request zebra to terminate IPv6 RAs on this
4788 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4789 peer_notify_unconfig(peer
);
4794 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4796 peer_group_notify_unconfig(group
);
4797 peer_group_delete(group
);
4799 vty_out(vty
, "%% Create the peer-group first\n");
4800 return CMD_WARNING_CONFIG_FAILED
;
4803 peer
= peer_lookup(bgp
, &su
);
4805 if (peer_dynamic_neighbor(peer
)) {
4807 "%% Operation not allowed on a dynamic neighbor\n");
4808 return CMD_WARNING_CONFIG_FAILED
;
4811 other
= peer
->doppelganger
;
4813 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4814 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4816 peer_notify_unconfig(peer
);
4818 if (other
&& other
->status
!= Deleted
) {
4819 peer_notify_unconfig(other
);
4828 DEFUN (no_neighbor_interface_config
,
4829 no_neighbor_interface_config_cmd
,
4830 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4834 "Configure BGP on interface\n"
4835 "Enable BGP with v6 link-local only\n"
4836 "Member of the peer-group\n"
4838 "Specify a BGP neighbor\n"
4840 "Internal BGP peer\n"
4841 "External BGP peer\n")
4843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4847 /* look up for neighbor by interface name config. */
4848 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4850 /* Request zebra to terminate IPv6 RAs on this interface. */
4852 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4853 peer_notify_unconfig(peer
);
4856 vty_out(vty
, "%% Create the bgp interface first\n");
4857 return CMD_WARNING_CONFIG_FAILED
;
4862 DEFUN (no_neighbor_peer_group
,
4863 no_neighbor_peer_group_cmd
,
4864 "no neighbor WORD peer-group",
4868 "Configure peer-group\n")
4870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4872 struct peer_group
*group
;
4874 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4876 peer_group_notify_unconfig(group
);
4877 peer_group_delete(group
);
4879 vty_out(vty
, "%% Create the peer-group first\n");
4880 return CMD_WARNING_CONFIG_FAILED
;
4885 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4886 no_neighbor_interface_peer_group_remote_as_cmd
,
4887 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4890 "Interface name or neighbor tag\n"
4891 "Specify a BGP neighbor\n"
4893 "Internal BGP peer\n"
4894 "External BGP peer\n")
4896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4898 struct peer_group
*group
;
4901 /* look up for neighbor by interface name config. */
4902 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4904 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4908 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4910 peer_group_remote_as_delete(group
);
4912 vty_out(vty
, "%% Create the peer-group or interface first\n");
4913 return CMD_WARNING_CONFIG_FAILED
;
4918 DEFUN (neighbor_local_as
,
4919 neighbor_local_as_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4923 "Specify a local-as number\n"
4924 "AS number used as local AS\n")
4932 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4934 return CMD_WARNING_CONFIG_FAILED
;
4936 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4937 ret
= peer_local_as_set(peer
, as
, 0, 0);
4938 return bgp_vty_return(vty
, ret
);
4941 DEFUN (neighbor_local_as_no_prepend
,
4942 neighbor_local_as_no_prepend_cmd
,
4943 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4946 "Specify a local-as number\n"
4947 "AS number used as local AS\n"
4948 "Do not prepend local-as to updates from ebgp peers\n")
4956 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4958 return CMD_WARNING_CONFIG_FAILED
;
4960 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4961 ret
= peer_local_as_set(peer
, as
, 1, 0);
4962 return bgp_vty_return(vty
, ret
);
4965 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4966 neighbor_local_as_no_prepend_replace_as_cmd
,
4967 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4970 "Specify a local-as number\n"
4971 "AS number used as local AS\n"
4972 "Do not prepend local-as to updates from ebgp peers\n"
4973 "Do not prepend local-as to updates from ibgp peers\n")
4981 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4983 return CMD_WARNING_CONFIG_FAILED
;
4985 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4986 ret
= peer_local_as_set(peer
, as
, 1, 1);
4987 return bgp_vty_return(vty
, ret
);
4990 DEFUN (no_neighbor_local_as
,
4991 no_neighbor_local_as_cmd
,
4992 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4996 "Specify a local-as number\n"
4997 "AS number used as local AS\n"
4998 "Do not prepend local-as to updates from ebgp peers\n"
4999 "Do not prepend local-as to updates from ibgp peers\n")
5005 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5007 return CMD_WARNING_CONFIG_FAILED
;
5009 ret
= peer_local_as_unset(peer
);
5010 return bgp_vty_return(vty
, ret
);
5014 DEFUN (neighbor_solo
,
5016 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5019 "Solo peer - part of its own update group\n")
5025 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5027 return CMD_WARNING_CONFIG_FAILED
;
5029 ret
= update_group_adjust_soloness(peer
, 1);
5030 return bgp_vty_return(vty
, ret
);
5033 DEFUN (no_neighbor_solo
,
5034 no_neighbor_solo_cmd
,
5035 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5039 "Solo peer - part of its own update group\n")
5045 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5047 return CMD_WARNING_CONFIG_FAILED
;
5049 ret
= update_group_adjust_soloness(peer
, 0);
5050 return bgp_vty_return(vty
, ret
);
5053 DEFUN (neighbor_password
,
5054 neighbor_password_cmd
,
5055 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5066 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5068 return CMD_WARNING_CONFIG_FAILED
;
5070 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5071 return bgp_vty_return(vty
, ret
);
5074 DEFUN (no_neighbor_password
,
5075 no_neighbor_password_cmd
,
5076 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5087 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5089 return CMD_WARNING_CONFIG_FAILED
;
5091 ret
= peer_password_unset(peer
);
5092 return bgp_vty_return(vty
, ret
);
5095 DEFUN (neighbor_activate
,
5096 neighbor_activate_cmd
,
5097 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5100 "Enable the Address Family for this Neighbor\n")
5106 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5108 return CMD_WARNING_CONFIG_FAILED
;
5110 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5111 return bgp_vty_return(vty
, ret
);
5114 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5115 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5116 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5117 "Enable the Address Family for this Neighbor\n")
5119 DEFUN (no_neighbor_activate
,
5120 no_neighbor_activate_cmd
,
5121 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5125 "Enable the Address Family for this Neighbor\n")
5132 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5134 return CMD_WARNING_CONFIG_FAILED
;
5136 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5137 return bgp_vty_return(vty
, ret
);
5140 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5141 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5142 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5143 "Enable the Address Family for this Neighbor\n")
5145 DEFUN (neighbor_set_peer_group
,
5146 neighbor_set_peer_group_cmd
,
5147 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5150 "Member of the peer-group\n"
5151 "Peer-group name\n")
5153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5160 struct peer_group
*group
;
5162 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5164 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5166 vty_out(vty
, "%% Malformed address or name: %s\n",
5167 argv
[idx_peer
]->arg
);
5168 return CMD_WARNING_CONFIG_FAILED
;
5171 if (peer_address_self_check(bgp
, &su
)) {
5173 "%% Can not configure the local system as neighbor\n");
5174 return CMD_WARNING_CONFIG_FAILED
;
5177 /* Disallow for dynamic neighbor. */
5178 peer
= peer_lookup(bgp
, &su
);
5179 if (peer
&& peer_dynamic_neighbor(peer
)) {
5181 "%% Operation not allowed on a dynamic neighbor\n");
5182 return CMD_WARNING_CONFIG_FAILED
;
5186 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5188 vty_out(vty
, "%% Configure the peer-group first\n");
5189 return CMD_WARNING_CONFIG_FAILED
;
5192 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5194 return bgp_vty_return(vty
, ret
);
5197 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5198 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5199 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5200 "Member of the peer-group\n"
5201 "Peer-group name\n")
5203 DEFUN (no_neighbor_set_peer_group
,
5204 no_neighbor_set_peer_group_cmd
,
5205 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5209 "Member of the peer-group\n"
5210 "Peer-group name\n")
5212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5217 struct peer_group
*group
;
5219 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5221 return CMD_WARNING_CONFIG_FAILED
;
5223 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5225 vty_out(vty
, "%% Configure the peer-group first\n");
5226 return CMD_WARNING_CONFIG_FAILED
;
5229 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5230 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5232 peer_notify_unconfig(peer
);
5233 ret
= peer_delete(peer
);
5235 return bgp_vty_return(vty
, ret
);
5238 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5239 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5240 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5241 "Member of the peer-group\n"
5242 "Peer-group name\n")
5244 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5245 uint64_t flag
, int set
)
5250 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5252 return CMD_WARNING_CONFIG_FAILED
;
5255 * If 'neighbor <interface>', then this is for directly connected peers,
5256 * we should not accept disable-connected-check.
5258 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5260 "%s is directly connected peer, cannot accept disable-connected-check\n",
5262 return CMD_WARNING_CONFIG_FAILED
;
5265 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5266 peer_tx_shutdown_message_unset(peer
);
5269 ret
= peer_flag_set(peer
, flag
);
5271 ret
= peer_flag_unset(peer
, flag
);
5273 return bgp_vty_return(vty
, ret
);
5276 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5278 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5281 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5284 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5287 /* neighbor passive. */
5288 DEFUN (neighbor_passive
,
5289 neighbor_passive_cmd
,
5290 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5293 "Don't send open messages to this neighbor\n")
5296 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5299 DEFUN (no_neighbor_passive
,
5300 no_neighbor_passive_cmd
,
5301 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5305 "Don't send open messages to this neighbor\n")
5308 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5311 /* neighbor shutdown. */
5312 DEFUN (neighbor_shutdown_msg
,
5313 neighbor_shutdown_msg_cmd
,
5314 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5317 "Administratively shut down this neighbor\n"
5318 "Add a shutdown message (RFC 8203)\n"
5319 "Shutdown message\n")
5325 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5329 return CMD_WARNING_CONFIG_FAILED
;
5330 message
= argv_concat(argv
, argc
, 4);
5331 peer_tx_shutdown_message_set(peer
, message
);
5332 XFREE(MTYPE_TMP
, message
);
5335 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5338 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5339 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5340 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5341 "Administratively shut down this neighbor\n")
5343 DEFUN (no_neighbor_shutdown_msg
,
5344 no_neighbor_shutdown_msg_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5349 "Administratively shut down this neighbor\n"
5350 "Remove a shutdown message (RFC 8203)\n"
5351 "Shutdown message\n")
5355 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5356 PEER_FLAG_SHUTDOWN
);
5359 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5360 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5361 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5362 "Administratively shut down this neighbor\n")
5364 DEFUN(neighbor_shutdown_rtt
,
5365 neighbor_shutdown_rtt_cmd
,
5366 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5369 "Administratively shut down this neighbor\n"
5370 "Shutdown if round-trip-time is higher than expected\n"
5371 "Round-trip-time in milliseconds\n"
5372 "Specify the number of keepalives before shutdown\n"
5373 "The number of keepalives with higher RTT to shutdown\n")
5380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5383 return CMD_WARNING_CONFIG_FAILED
;
5385 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5387 if (argv_find(argv
, argc
, "count", &idx_count
))
5388 peer
->rtt_keepalive_conf
=
5389 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5391 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5392 PEER_FLAG_RTT_SHUTDOWN
);
5395 DEFUN(no_neighbor_shutdown_rtt
,
5396 no_neighbor_shutdown_rtt_cmd
,
5397 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5401 "Administratively shut down this neighbor\n"
5402 "Shutdown if round-trip-time is higher than expected\n"
5403 "Round-trip-time in milliseconds\n"
5404 "Specify the number of keepalives before shutdown\n"
5405 "The number of keepalives with higher RTT to shutdown\n")
5410 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5413 return CMD_WARNING_CONFIG_FAILED
;
5415 peer
->rtt_expected
= 0;
5416 peer
->rtt_keepalive_conf
= 1;
5418 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5419 PEER_FLAG_RTT_SHUTDOWN
);
5422 /* neighbor capability dynamic. */
5423 DEFUN (neighbor_capability_dynamic
,
5424 neighbor_capability_dynamic_cmd
,
5425 "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_set_vty(vty
, argv
[idx_peer
]->arg
,
5433 PEER_FLAG_DYNAMIC_CAPABILITY
);
5436 DEFUN (no_neighbor_capability_dynamic
,
5437 no_neighbor_capability_dynamic_cmd
,
5438 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5442 "Advertise capability to the peer\n"
5443 "Advertise dynamic capability to this neighbor\n")
5446 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5447 PEER_FLAG_DYNAMIC_CAPABILITY
);
5450 /* neighbor dont-capability-negotiate */
5451 DEFUN (neighbor_dont_capability_negotiate
,
5452 neighbor_dont_capability_negotiate_cmd
,
5453 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5456 "Do not perform capability negotiation\n")
5459 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5460 PEER_FLAG_DONT_CAPABILITY
);
5463 DEFUN (no_neighbor_dont_capability_negotiate
,
5464 no_neighbor_dont_capability_negotiate_cmd
,
5465 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5469 "Do not perform capability negotiation\n")
5472 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5473 PEER_FLAG_DONT_CAPABILITY
);
5476 /* neighbor capability extended next hop encoding */
5477 DEFUN (neighbor_capability_enhe
,
5478 neighbor_capability_enhe_cmd
,
5479 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5482 "Advertise capability to the peer\n"
5483 "Advertise extended next-hop capability to the peer\n")
5488 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5489 if (peer
&& peer
->conf_if
)
5492 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5493 PEER_FLAG_CAPABILITY_ENHE
);
5496 DEFUN (no_neighbor_capability_enhe
,
5497 no_neighbor_capability_enhe_cmd
,
5498 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5502 "Advertise capability to the peer\n"
5503 "Advertise extended next-hop capability to the peer\n")
5508 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5509 if (peer
&& peer
->conf_if
) {
5511 "Peer %s cannot have capability extended-nexthop turned off\n",
5512 argv
[idx_peer
]->arg
);
5513 return CMD_WARNING_CONFIG_FAILED
;
5516 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5517 PEER_FLAG_CAPABILITY_ENHE
);
5520 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5521 afi_t afi
, safi_t safi
, uint32_t flag
,
5527 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5529 return CMD_WARNING_CONFIG_FAILED
;
5532 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5534 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5536 return bgp_vty_return(vty
, ret
);
5539 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5540 afi_t afi
, safi_t safi
, uint32_t flag
)
5542 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5545 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5546 afi_t afi
, safi_t safi
, uint32_t flag
)
5548 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5551 /* neighbor capability orf prefix-list. */
5552 DEFUN (neighbor_capability_orf_prefix
,
5553 neighbor_capability_orf_prefix_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5557 "Advertise capability to the peer\n"
5558 "Advertise ORF capability to the peer\n"
5559 "Advertise prefixlist ORF capability to this neighbor\n"
5560 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5561 "Capability to RECEIVE the ORF from this neighbor\n"
5562 "Capability to SEND the ORF to this neighbor\n")
5564 int idx_send_recv
= 5;
5565 char *peer_str
= argv
[1]->arg
;
5567 afi_t afi
= bgp_node_afi(vty
);
5568 safi_t safi
= bgp_node_safi(vty
);
5570 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5572 return CMD_WARNING_CONFIG_FAILED
;
5574 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5575 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5576 PEER_FLAG_ORF_PREFIX_SM
);
5578 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5579 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5580 PEER_FLAG_ORF_PREFIX_RM
);
5582 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5583 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5584 PEER_FLAG_ORF_PREFIX_SM
)
5585 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5586 PEER_FLAG_ORF_PREFIX_RM
);
5588 return CMD_WARNING_CONFIG_FAILED
;
5592 neighbor_capability_orf_prefix
,
5593 neighbor_capability_orf_prefix_hidden_cmd
,
5594 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5595 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5596 "Advertise capability to the peer\n"
5597 "Advertise ORF capability to the peer\n"
5598 "Advertise prefixlist ORF capability to this neighbor\n"
5599 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5600 "Capability to RECEIVE the ORF from this neighbor\n"
5601 "Capability to SEND the ORF to this neighbor\n")
5603 DEFUN (no_neighbor_capability_orf_prefix
,
5604 no_neighbor_capability_orf_prefix_cmd
,
5605 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5609 "Advertise capability to the peer\n"
5610 "Advertise ORF capability to the peer\n"
5611 "Advertise prefixlist ORF capability to this neighbor\n"
5612 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5613 "Capability to RECEIVE the ORF from this neighbor\n"
5614 "Capability to SEND the ORF to this neighbor\n")
5616 int idx_send_recv
= 6;
5617 char *peer_str
= argv
[2]->arg
;
5619 afi_t afi
= bgp_node_afi(vty
);
5620 safi_t safi
= bgp_node_safi(vty
);
5622 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5624 return CMD_WARNING_CONFIG_FAILED
;
5626 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5627 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5628 PEER_FLAG_ORF_PREFIX_SM
);
5630 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5631 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5632 PEER_FLAG_ORF_PREFIX_RM
);
5634 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5635 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5636 PEER_FLAG_ORF_PREFIX_SM
)
5637 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5638 PEER_FLAG_ORF_PREFIX_RM
);
5640 return CMD_WARNING_CONFIG_FAILED
;
5644 no_neighbor_capability_orf_prefix
,
5645 no_neighbor_capability_orf_prefix_hidden_cmd
,
5646 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5647 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5648 "Advertise capability to the peer\n"
5649 "Advertise ORF capability to the peer\n"
5650 "Advertise prefixlist ORF capability to this neighbor\n"
5651 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5652 "Capability to RECEIVE the ORF from this neighbor\n"
5653 "Capability to SEND the ORF to this neighbor\n")
5655 /* neighbor next-hop-self. */
5656 DEFUN (neighbor_nexthop_self
,
5657 neighbor_nexthop_self_cmd
,
5658 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5661 "Disable the next hop calculation for this neighbor\n")
5664 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5665 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5668 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5669 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5670 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5671 "Disable the next hop calculation for this neighbor\n")
5673 /* neighbor next-hop-self. */
5674 DEFUN (neighbor_nexthop_self_force
,
5675 neighbor_nexthop_self_force_cmd
,
5676 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5679 "Disable the next hop calculation for this neighbor\n"
5680 "Set the next hop to self for reflected routes\n")
5683 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5685 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5688 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5689 neighbor_nexthop_self_force_hidden_cmd
,
5690 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5691 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5692 "Disable the next hop calculation for this neighbor\n"
5693 "Set the next hop to self for reflected routes\n")
5695 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5696 neighbor_nexthop_self_all_hidden_cmd
,
5697 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5698 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5699 "Disable the next hop calculation for this neighbor\n"
5700 "Set the next hop to self for reflected routes\n")
5702 DEFUN (no_neighbor_nexthop_self
,
5703 no_neighbor_nexthop_self_cmd
,
5704 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5708 "Disable the next hop calculation for this neighbor\n")
5711 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5712 bgp_node_afi(vty
), bgp_node_safi(vty
),
5713 PEER_FLAG_NEXTHOP_SELF
);
5716 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5717 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5718 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5719 "Disable the next hop calculation for this neighbor\n")
5721 DEFUN (no_neighbor_nexthop_self_force
,
5722 no_neighbor_nexthop_self_force_cmd
,
5723 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5727 "Disable the next hop calculation for this neighbor\n"
5728 "Set the next hop to self for reflected routes\n")
5731 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5732 bgp_node_afi(vty
), bgp_node_safi(vty
),
5733 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5736 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5737 no_neighbor_nexthop_self_force_hidden_cmd
,
5738 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5739 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5740 "Disable the next hop calculation for this neighbor\n"
5741 "Set the next hop to self for reflected routes\n")
5743 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5744 no_neighbor_nexthop_self_all_hidden_cmd
,
5745 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5746 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Disable the next hop calculation for this neighbor\n"
5748 "Set the next hop to self for reflected routes\n")
5750 /* neighbor as-override */
5751 DEFUN (neighbor_as_override
,
5752 neighbor_as_override_cmd
,
5753 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5756 "Override ASNs in outbound updates if aspath equals remote-as\n")
5759 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5760 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5763 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5764 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5765 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5766 "Override ASNs in outbound updates if aspath equals remote-as\n")
5768 DEFUN (no_neighbor_as_override
,
5769 no_neighbor_as_override_cmd
,
5770 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5774 "Override ASNs in outbound updates if aspath equals remote-as\n")
5777 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5778 bgp_node_afi(vty
), bgp_node_safi(vty
),
5779 PEER_FLAG_AS_OVERRIDE
);
5782 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5783 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5784 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5785 "Override ASNs in outbound updates if aspath equals remote-as\n")
5787 /* neighbor remove-private-AS. */
5788 DEFUN (neighbor_remove_private_as
,
5789 neighbor_remove_private_as_cmd
,
5790 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5793 "Remove private ASNs in outbound updates\n")
5796 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5798 PEER_FLAG_REMOVE_PRIVATE_AS
);
5801 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5802 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5804 "Remove private ASNs in outbound updates\n")
5806 DEFUN (neighbor_remove_private_as_all
,
5807 neighbor_remove_private_as_all_cmd
,
5808 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5811 "Remove private ASNs in outbound updates\n"
5812 "Apply to all AS numbers\n")
5815 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5817 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5820 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5821 neighbor_remove_private_as_all_hidden_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5823 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5824 "Remove private ASNs in outbound updates\n"
5825 "Apply to all AS numbers\n")
5827 DEFUN (neighbor_remove_private_as_replace_as
,
5828 neighbor_remove_private_as_replace_as_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5832 "Remove private ASNs in outbound updates\n"
5833 "Replace private ASNs with our ASN in outbound updates\n")
5836 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5838 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5841 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5842 neighbor_remove_private_as_replace_as_hidden_cmd
,
5843 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5844 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5845 "Remove private ASNs in outbound updates\n"
5846 "Replace private ASNs with our ASN in outbound updates\n")
5848 DEFUN (neighbor_remove_private_as_all_replace_as
,
5849 neighbor_remove_private_as_all_replace_as_cmd
,
5850 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5853 "Remove private ASNs in outbound updates\n"
5854 "Apply to all AS numbers\n"
5855 "Replace private ASNs with our ASN in outbound updates\n")
5858 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5860 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5864 neighbor_remove_private_as_all_replace_as
,
5865 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5866 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5867 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5868 "Remove private ASNs in outbound updates\n"
5869 "Apply to all AS numbers\n"
5870 "Replace private ASNs with our ASN in outbound updates\n")
5872 DEFUN (no_neighbor_remove_private_as
,
5873 no_neighbor_remove_private_as_cmd
,
5874 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5878 "Remove private ASNs in outbound updates\n")
5881 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5882 bgp_node_afi(vty
), bgp_node_safi(vty
),
5883 PEER_FLAG_REMOVE_PRIVATE_AS
);
5886 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5887 no_neighbor_remove_private_as_hidden_cmd
,
5888 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5889 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5890 "Remove private ASNs in outbound updates\n")
5892 DEFUN (no_neighbor_remove_private_as_all
,
5893 no_neighbor_remove_private_as_all_cmd
,
5894 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5898 "Remove private ASNs in outbound updates\n"
5899 "Apply to all AS numbers\n")
5902 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5903 bgp_node_afi(vty
), bgp_node_safi(vty
),
5904 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5907 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5908 no_neighbor_remove_private_as_all_hidden_cmd
,
5909 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5910 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5911 "Remove private ASNs in outbound updates\n"
5912 "Apply to all AS numbers\n")
5914 DEFUN (no_neighbor_remove_private_as_replace_as
,
5915 no_neighbor_remove_private_as_replace_as_cmd
,
5916 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5920 "Remove private ASNs in outbound updates\n"
5921 "Replace private ASNs with our ASN in outbound updates\n")
5924 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5925 bgp_node_afi(vty
), bgp_node_safi(vty
),
5926 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5929 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5930 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5931 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5932 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5933 "Remove private ASNs in outbound updates\n"
5934 "Replace private ASNs with our ASN in outbound updates\n")
5936 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5937 no_neighbor_remove_private_as_all_replace_as_cmd
,
5938 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5942 "Remove private ASNs in outbound updates\n"
5943 "Apply to all AS numbers\n"
5944 "Replace private ASNs with our ASN in outbound updates\n")
5947 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5948 bgp_node_afi(vty
), bgp_node_safi(vty
),
5949 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5953 no_neighbor_remove_private_as_all_replace_as
,
5954 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Remove private ASNs in outbound updates\n"
5958 "Apply to all AS numbers\n"
5959 "Replace private ASNs with our ASN in outbound updates\n")
5962 /* neighbor send-community. */
5963 DEFUN (neighbor_send_community
,
5964 neighbor_send_community_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5968 "Send Community attribute to this neighbor\n")
5972 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5974 PEER_FLAG_SEND_COMMUNITY
);
5977 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5978 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5979 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5980 "Send Community attribute to this neighbor\n")
5982 DEFUN (no_neighbor_send_community
,
5983 no_neighbor_send_community_cmd
,
5984 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5988 "Send Community attribute to this neighbor\n")
5992 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5993 bgp_node_afi(vty
), bgp_node_safi(vty
),
5994 PEER_FLAG_SEND_COMMUNITY
);
5997 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5998 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5999 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6000 "Send Community attribute to this neighbor\n")
6002 /* neighbor send-community extended. */
6003 DEFUN (neighbor_send_community_type
,
6004 neighbor_send_community_type_cmd
,
6005 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6008 "Send Community attribute to this neighbor\n"
6009 "Send Standard and Extended Community attributes\n"
6010 "Send Standard, Large and Extended Community attributes\n"
6011 "Send Extended Community attributes\n"
6012 "Send Standard Community attributes\n"
6013 "Send Large Community attributes\n")
6015 const char *type
= argv
[argc
- 1]->text
;
6016 char *peer_str
= argv
[1]->arg
;
6018 afi_t afi
= bgp_node_afi(vty
);
6019 safi_t safi
= bgp_node_safi(vty
);
6021 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6023 return CMD_WARNING_CONFIG_FAILED
;
6025 if (strmatch(type
, "standard"))
6026 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6027 PEER_FLAG_SEND_COMMUNITY
);
6029 if (strmatch(type
, "extended"))
6030 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6031 PEER_FLAG_SEND_EXT_COMMUNITY
);
6033 if (strmatch(type
, "large"))
6034 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6035 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6037 if (strmatch(type
, "both")) {
6038 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6039 PEER_FLAG_SEND_COMMUNITY
)
6040 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6041 PEER_FLAG_SEND_EXT_COMMUNITY
);
6043 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6044 PEER_FLAG_SEND_COMMUNITY
)
6045 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6046 PEER_FLAG_SEND_EXT_COMMUNITY
)
6047 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6048 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6052 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6053 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6055 "Send Community attribute to this neighbor\n"
6056 "Send Standard and Extended Community attributes\n"
6057 "Send Standard, Large and Extended Community attributes\n"
6058 "Send Extended Community attributes\n"
6059 "Send Standard Community attributes\n"
6060 "Send Large Community attributes\n")
6062 DEFUN (no_neighbor_send_community_type
,
6063 no_neighbor_send_community_type_cmd
,
6064 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6068 "Send Community attribute to this neighbor\n"
6069 "Send Standard and Extended Community attributes\n"
6070 "Send Standard, Large and Extended Community attributes\n"
6071 "Send Extended Community attributes\n"
6072 "Send Standard Community attributes\n"
6073 "Send Large Community attributes\n")
6075 const char *type
= argv
[argc
- 1]->text
;
6076 char *peer_str
= argv
[2]->arg
;
6078 afi_t afi
= bgp_node_afi(vty
);
6079 safi_t safi
= bgp_node_safi(vty
);
6081 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6083 return CMD_WARNING_CONFIG_FAILED
;
6085 if (strmatch(type
, "standard"))
6086 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6087 PEER_FLAG_SEND_COMMUNITY
);
6089 if (strmatch(type
, "extended"))
6090 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6091 PEER_FLAG_SEND_EXT_COMMUNITY
);
6093 if (strmatch(type
, "large"))
6094 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6095 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6097 if (strmatch(type
, "both")) {
6099 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6100 PEER_FLAG_SEND_COMMUNITY
)
6101 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6102 PEER_FLAG_SEND_EXT_COMMUNITY
);
6105 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6106 PEER_FLAG_SEND_COMMUNITY
)
6107 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6108 PEER_FLAG_SEND_EXT_COMMUNITY
)
6109 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6110 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6114 no_neighbor_send_community_type
,
6115 no_neighbor_send_community_type_hidden_cmd
,
6116 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6117 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6118 "Send Community attribute to this neighbor\n"
6119 "Send Standard and Extended Community attributes\n"
6120 "Send Standard, Large and Extended Community attributes\n"
6121 "Send Extended Community attributes\n"
6122 "Send Standard Community attributes\n"
6123 "Send Large Community attributes\n")
6125 /* neighbor soft-reconfig. */
6126 DEFUN (neighbor_soft_reconfiguration
,
6127 neighbor_soft_reconfiguration_cmd
,
6128 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6131 "Per neighbor soft reconfiguration\n"
6132 "Allow inbound soft reconfiguration for this neighbor\n")
6135 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6137 PEER_FLAG_SOFT_RECONFIG
);
6140 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6141 neighbor_soft_reconfiguration_hidden_cmd
,
6142 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6143 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6144 "Per neighbor soft reconfiguration\n"
6145 "Allow inbound soft reconfiguration for this neighbor\n")
6147 DEFUN (no_neighbor_soft_reconfiguration
,
6148 no_neighbor_soft_reconfiguration_cmd
,
6149 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6153 "Per neighbor soft reconfiguration\n"
6154 "Allow inbound soft reconfiguration for this neighbor\n")
6157 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6158 bgp_node_afi(vty
), bgp_node_safi(vty
),
6159 PEER_FLAG_SOFT_RECONFIG
);
6162 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6163 no_neighbor_soft_reconfiguration_hidden_cmd
,
6164 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6165 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6166 "Per neighbor soft reconfiguration\n"
6167 "Allow inbound soft reconfiguration for this neighbor\n")
6169 DEFUN (neighbor_route_reflector_client
,
6170 neighbor_route_reflector_client_cmd
,
6171 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6174 "Configure a neighbor as Route Reflector client\n")
6180 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6182 return CMD_WARNING_CONFIG_FAILED
;
6184 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6186 PEER_FLAG_REFLECTOR_CLIENT
);
6189 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6190 neighbor_route_reflector_client_hidden_cmd
,
6191 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6192 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6193 "Configure a neighbor as Route Reflector client\n")
6195 DEFUN (no_neighbor_route_reflector_client
,
6196 no_neighbor_route_reflector_client_cmd
,
6197 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6201 "Configure a neighbor as Route Reflector client\n")
6204 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6205 bgp_node_afi(vty
), bgp_node_safi(vty
),
6206 PEER_FLAG_REFLECTOR_CLIENT
);
6209 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6210 no_neighbor_route_reflector_client_hidden_cmd
,
6211 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6213 "Configure a neighbor as Route Reflector client\n")
6215 /* optimal-route-reflection Root Routers configuration */
6216 DEFPY (optimal_route_reflection
,
6217 optimal_route_reflection_cmd
,
6218 "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]",
6220 "Create ORR group and assign root router(s)\n"
6222 "Primary Root address\n"
6223 "Primary Root IPv6 address\n"
6224 "Secondary Root address\n"
6225 "Secondary Root IPv6 address\n"
6226 "Tertiary Root address\n"
6227 "Tertiary Root IPv6 address\n")
6229 if (!no
&& !primary
) {
6230 vty_out(vty
, "%% Specify Primary Root address\n");
6231 return CMD_WARNING_CONFIG_FAILED
;
6233 return bgp_afi_safi_orr_group_set_vty(
6234 vty
, bgp_node_afi(vty
), bgp_node_safi(vty
), orr_group
,
6235 primary_str
, secondary_str
, tertiary_str
, !!no
);
6238 /* neighbor optimal-route-reflection group*/
6239 DEFPY (neighbor_optimal_route_reflection
,
6240 neighbor_optimal_route_reflection_cmd
,
6241 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group",
6245 "Apply ORR group configuration to the neighbor\n"
6248 return peer_orr_group_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
6249 bgp_node_safi(vty
), orr_group
, !!no
);
6252 /* neighbor route-server-client. */
6253 DEFUN (neighbor_route_server_client
,
6254 neighbor_route_server_client_cmd
,
6255 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6258 "Configure a neighbor as Route Server client\n")
6263 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6265 return CMD_WARNING_CONFIG_FAILED
;
6266 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6268 PEER_FLAG_RSERVER_CLIENT
);
6271 ALIAS_HIDDEN(neighbor_route_server_client
,
6272 neighbor_route_server_client_hidden_cmd
,
6273 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6274 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6275 "Configure a neighbor as Route Server client\n")
6277 DEFUN (no_neighbor_route_server_client
,
6278 no_neighbor_route_server_client_cmd
,
6279 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6283 "Configure a neighbor as Route Server client\n")
6286 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6287 bgp_node_afi(vty
), bgp_node_safi(vty
),
6288 PEER_FLAG_RSERVER_CLIENT
);
6291 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6292 no_neighbor_route_server_client_hidden_cmd
,
6293 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6294 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6295 "Configure a neighbor as Route Server client\n")
6297 DEFUN (neighbor_nexthop_local_unchanged
,
6298 neighbor_nexthop_local_unchanged_cmd
,
6299 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6302 "Configure treatment of outgoing link-local nexthop attribute\n"
6303 "Leave link-local nexthop unchanged for this peer\n")
6306 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6308 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6311 DEFUN (no_neighbor_nexthop_local_unchanged
,
6312 no_neighbor_nexthop_local_unchanged_cmd
,
6313 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6317 "Configure treatment of outgoing link-local-nexthop attribute\n"
6318 "Leave link-local nexthop unchanged for this peer\n")
6321 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6322 bgp_node_afi(vty
), bgp_node_safi(vty
),
6323 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6326 DEFUN (neighbor_attr_unchanged
,
6327 neighbor_attr_unchanged_cmd
,
6328 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6331 "BGP attribute is propagated unchanged to this neighbor\n"
6332 "As-path attribute\n"
6333 "Nexthop attribute\n"
6337 char *peer_str
= argv
[1]->arg
;
6339 bool aspath
= false;
6340 bool nexthop
= false;
6342 afi_t afi
= bgp_node_afi(vty
);
6343 safi_t safi
= bgp_node_safi(vty
);
6346 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6348 return CMD_WARNING_CONFIG_FAILED
;
6350 if (argv_find(argv
, argc
, "as-path", &idx
))
6354 if (argv_find(argv
, argc
, "next-hop", &idx
))
6358 if (argv_find(argv
, argc
, "med", &idx
))
6361 /* no flags means all of them! */
6362 if (!aspath
&& !nexthop
&& !med
) {
6363 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6364 PEER_FLAG_AS_PATH_UNCHANGED
);
6365 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6366 PEER_FLAG_NEXTHOP_UNCHANGED
);
6367 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6368 PEER_FLAG_MED_UNCHANGED
);
6371 if (peer_af_flag_check(peer
, afi
, safi
,
6372 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6373 ret
|= peer_af_flag_unset_vty(
6374 vty
, peer_str
, afi
, safi
,
6375 PEER_FLAG_AS_PATH_UNCHANGED
);
6378 ret
|= peer_af_flag_set_vty(
6379 vty
, peer_str
, afi
, safi
,
6380 PEER_FLAG_AS_PATH_UNCHANGED
);
6383 if (peer_af_flag_check(peer
, afi
, safi
,
6384 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6385 ret
|= peer_af_flag_unset_vty(
6386 vty
, peer_str
, afi
, safi
,
6387 PEER_FLAG_NEXTHOP_UNCHANGED
);
6390 ret
|= peer_af_flag_set_vty(
6391 vty
, peer_str
, afi
, safi
,
6392 PEER_FLAG_NEXTHOP_UNCHANGED
);
6395 if (peer_af_flag_check(peer
, afi
, safi
,
6396 PEER_FLAG_MED_UNCHANGED
)) {
6397 ret
|= peer_af_flag_unset_vty(
6398 vty
, peer_str
, afi
, safi
,
6399 PEER_FLAG_MED_UNCHANGED
);
6402 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6403 PEER_FLAG_MED_UNCHANGED
);
6410 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6411 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6412 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6413 "BGP attribute is propagated unchanged to this neighbor\n"
6414 "As-path attribute\n"
6415 "Nexthop attribute\n"
6418 DEFUN (no_neighbor_attr_unchanged
,
6419 no_neighbor_attr_unchanged_cmd
,
6420 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6424 "BGP attribute is propagated unchanged to this neighbor\n"
6425 "As-path attribute\n"
6426 "Nexthop attribute\n"
6430 char *peer_str
= argv
[2]->arg
;
6432 bool aspath
= false;
6433 bool nexthop
= false;
6435 afi_t afi
= bgp_node_afi(vty
);
6436 safi_t safi
= bgp_node_safi(vty
);
6439 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6441 return CMD_WARNING_CONFIG_FAILED
;
6443 if (argv_find(argv
, argc
, "as-path", &idx
))
6447 if (argv_find(argv
, argc
, "next-hop", &idx
))
6451 if (argv_find(argv
, argc
, "med", &idx
))
6454 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6455 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6456 PEER_FLAG_AS_PATH_UNCHANGED
)
6457 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6458 PEER_FLAG_NEXTHOP_UNCHANGED
)
6459 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6460 PEER_FLAG_MED_UNCHANGED
);
6463 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6464 PEER_FLAG_AS_PATH_UNCHANGED
);
6467 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6468 PEER_FLAG_NEXTHOP_UNCHANGED
);
6471 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6472 PEER_FLAG_MED_UNCHANGED
);
6478 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6479 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6480 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6481 "BGP attribute is propagated unchanged to this neighbor\n"
6482 "As-path attribute\n"
6483 "Nexthop attribute\n"
6486 /* EBGP multihop configuration. */
6487 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6488 const char *ttl_str
)
6493 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6495 return CMD_WARNING_CONFIG_FAILED
;
6498 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6503 ttl
= strtoul(ttl_str
, NULL
, 10);
6505 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6508 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6512 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6514 return CMD_WARNING_CONFIG_FAILED
;
6516 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6519 /* neighbor ebgp-multihop. */
6520 DEFUN (neighbor_ebgp_multihop
,
6521 neighbor_ebgp_multihop_cmd
,
6522 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6525 "Allow EBGP neighbors not on directly connected networks\n")
6528 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6531 DEFUN (neighbor_ebgp_multihop_ttl
,
6532 neighbor_ebgp_multihop_ttl_cmd
,
6533 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6536 "Allow EBGP neighbors not on directly connected networks\n"
6537 "maximum hop count\n")
6541 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6542 argv
[idx_number
]->arg
);
6545 DEFUN (no_neighbor_ebgp_multihop
,
6546 no_neighbor_ebgp_multihop_cmd
,
6547 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6551 "Allow EBGP neighbors not on directly connected networks\n"
6552 "maximum hop count\n")
6555 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6558 static uint8_t get_role_by_name(const char *role_str
)
6560 if (strncmp(role_str
, "peer", 2) == 0)
6562 if (strncmp(role_str
, "provider", 2) == 0)
6563 return ROLE_PROVIDER
;
6564 if (strncmp(role_str
, "customer", 2) == 0)
6565 return ROLE_CUSTOMER
;
6566 if (strncmp(role_str
, "rs-server", 4) == 0)
6567 return ROLE_RS_SERVER
;
6568 if (strncmp(role_str
, "rs-client", 4) == 0)
6569 return ROLE_RS_CLIENT
;
6570 return ROLE_UNDEFINED
;
6573 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6574 const char *role_str
, bool strict_mode
)
6578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6580 return CMD_WARNING_CONFIG_FAILED
;
6581 uint8_t role
= get_role_by_name(role_str
);
6583 if (role
== ROLE_UNDEFINED
)
6584 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6585 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6588 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6592 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6594 return CMD_WARNING_CONFIG_FAILED
;
6595 return bgp_vty_return(vty
, peer_role_unset(peer
));
6598 DEFPY(neighbor_role
,
6600 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6603 "Set session role\n"
6609 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6613 DEFPY(neighbor_role_strict
,
6614 neighbor_role_strict_cmd
,
6615 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6618 "Set session role\n"
6620 "Use additional restriction on peer\n")
6625 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6629 DEFPY(no_neighbor_role
,
6630 no_neighbor_role_cmd
,
6631 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6635 "Set session role\n"
6637 "Use additional restriction on peer\n")
6641 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6644 /* disable-connected-check */
6645 DEFUN (neighbor_disable_connected_check
,
6646 neighbor_disable_connected_check_cmd
,
6647 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6650 "one-hop away EBGP peer using loopback address\n"
6651 "Enforce EBGP neighbors perform multihop\n")
6654 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6655 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6658 DEFUN (no_neighbor_disable_connected_check
,
6659 no_neighbor_disable_connected_check_cmd
,
6660 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6664 "one-hop away EBGP peer using loopback address\n"
6665 "Enforce EBGP neighbors perform multihop\n")
6668 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6669 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6672 /* disable-link-bw-encoding-ieee */
6673 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6674 neighbor_disable_link_bw_encoding_ieee_cmd
,
6675 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6676 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6677 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6681 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6682 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6685 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6686 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6687 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6688 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6689 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6693 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6694 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6697 /* extended-optional-parameters */
6698 DEFUN(neighbor_extended_optional_parameters
,
6699 neighbor_extended_optional_parameters_cmd
,
6700 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6701 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6702 "Force the extended optional parameters format for OPEN messages\n")
6706 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6707 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6710 DEFUN(no_neighbor_extended_optional_parameters
,
6711 no_neighbor_extended_optional_parameters_cmd
,
6712 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6713 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6714 "Force the extended optional parameters format for OPEN messages\n")
6718 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6719 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6722 /* enforce-first-as */
6723 DEFUN (neighbor_enforce_first_as
,
6724 neighbor_enforce_first_as_cmd
,
6725 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6728 "Enforce the first AS for EBGP routes\n")
6732 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6733 PEER_FLAG_ENFORCE_FIRST_AS
);
6736 DEFUN (no_neighbor_enforce_first_as
,
6737 no_neighbor_enforce_first_as_cmd
,
6738 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6742 "Enforce the first AS for EBGP routes\n")
6746 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6747 PEER_FLAG_ENFORCE_FIRST_AS
);
6751 DEFUN (neighbor_description
,
6752 neighbor_description_cmd
,
6753 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6756 "Neighbor specific description\n"
6757 "Up to 80 characters describing this neighbor\n")
6764 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6766 return CMD_WARNING_CONFIG_FAILED
;
6768 str
= argv_concat(argv
, argc
, idx_line
);
6770 peer_description_set(peer
, str
);
6772 XFREE(MTYPE_TMP
, str
);
6777 DEFUN (no_neighbor_description
,
6778 no_neighbor_description_cmd
,
6779 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6783 "Neighbor specific description\n")
6788 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6790 return CMD_WARNING_CONFIG_FAILED
;
6792 peer_description_unset(peer
);
6797 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6798 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6799 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6800 "Neighbor specific description\n"
6801 "Up to 80 characters describing this neighbor\n")
6803 /* Neighbor update-source. */
6804 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6805 const char *source_str
)
6811 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6813 return CMD_WARNING_CONFIG_FAILED
;
6819 if (str2sockunion(source_str
, &su
) == 0)
6820 peer_update_source_addr_set(peer
, &su
);
6822 if (str2prefix(source_str
, &p
)) {
6824 "%% Invalid update-source, remove prefix length \n");
6825 return CMD_WARNING_CONFIG_FAILED
;
6827 peer_update_source_if_set(peer
, source_str
);
6830 peer_update_source_unset(peer
);
6835 #define BGP_UPDATE_SOURCE_HELP_STR \
6838 "Interface name (requires zebra to be running)\n"
6840 DEFUN (neighbor_update_source
,
6841 neighbor_update_source_cmd
,
6842 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6845 "Source of routing updates\n"
6846 BGP_UPDATE_SOURCE_HELP_STR
)
6850 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6851 argv
[idx_peer_2
]->arg
);
6854 DEFUN (no_neighbor_update_source
,
6855 no_neighbor_update_source_cmd
,
6856 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6860 "Source of routing updates\n"
6861 BGP_UPDATE_SOURCE_HELP_STR
)
6864 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6867 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6868 afi_t afi
, safi_t safi
,
6869 const char *rmap
, int set
)
6873 struct route_map
*route_map
= NULL
;
6875 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6877 return CMD_WARNING_CONFIG_FAILED
;
6881 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6882 ret
= peer_default_originate_set(peer
, afi
, safi
,
6885 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6887 return bgp_vty_return(vty
, ret
);
6890 /* neighbor default-originate. */
6891 DEFUN (neighbor_default_originate
,
6892 neighbor_default_originate_cmd
,
6893 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6896 "Originate default route to this neighbor\n")
6899 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6901 bgp_node_safi(vty
), NULL
, 1);
6904 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6905 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6906 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6907 "Originate default route to this neighbor\n")
6909 DEFUN (neighbor_default_originate_rmap
,
6910 neighbor_default_originate_rmap_cmd
,
6911 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6914 "Originate default route to this neighbor\n"
6915 "Route-map to specify criteria to originate default\n"
6920 return peer_default_originate_set_vty(
6921 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6922 argv
[idx_word
]->arg
, 1);
6926 neighbor_default_originate_rmap
,
6927 neighbor_default_originate_rmap_hidden_cmd
,
6928 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6929 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6930 "Originate default route to this neighbor\n"
6931 "Route-map to specify criteria to originate default\n"
6934 DEFUN (no_neighbor_default_originate
,
6935 no_neighbor_default_originate_cmd
,
6936 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6940 "Originate default route to this neighbor\n"
6941 "Route-map to specify criteria to originate default\n"
6945 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6947 bgp_node_safi(vty
), NULL
, 0);
6951 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6952 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6953 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6954 "Originate default route to this neighbor\n"
6955 "Route-map to specify criteria to originate default\n"
6959 /* Set neighbor's BGP port. */
6960 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6961 const char *port_str
)
6967 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6969 return CMD_WARNING_CONFIG_FAILED
;
6972 sp
= getservbyname("bgp", "tcp");
6973 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6975 port
= strtoul(port_str
, NULL
, 10);
6978 peer_port_set(peer
, port
);
6983 /* Set specified peer's BGP port. */
6984 DEFUN (neighbor_port
,
6986 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6989 "Neighbor's BGP port\n"
6990 "TCP port number\n")
6994 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6995 argv
[idx_number
]->arg
);
6998 DEFUN (no_neighbor_port
,
6999 no_neighbor_port_cmd
,
7000 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7004 "Neighbor's BGP port\n"
7005 "TCP port number\n")
7008 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7012 /* neighbor weight. */
7013 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7014 safi_t safi
, const char *weight_str
)
7018 unsigned long weight
;
7020 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7022 return CMD_WARNING_CONFIG_FAILED
;
7024 weight
= strtoul(weight_str
, NULL
, 10);
7026 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7027 return bgp_vty_return(vty
, ret
);
7030 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7036 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7038 return CMD_WARNING_CONFIG_FAILED
;
7040 ret
= peer_weight_unset(peer
, afi
, safi
);
7041 return bgp_vty_return(vty
, ret
);
7044 DEFUN (neighbor_weight
,
7045 neighbor_weight_cmd
,
7046 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7049 "Set default weight for routes from this neighbor\n"
7054 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7055 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7058 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7059 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7060 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7061 "Set default weight for routes from this neighbor\n"
7064 DEFUN (no_neighbor_weight
,
7065 no_neighbor_weight_cmd
,
7066 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7070 "Set default weight for routes from this neighbor\n"
7074 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7075 bgp_node_afi(vty
), bgp_node_safi(vty
));
7078 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7079 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7080 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7081 "Set default weight for routes from this neighbor\n"
7085 /* Override capability negotiation. */
7086 DEFUN (neighbor_override_capability
,
7087 neighbor_override_capability_cmd
,
7088 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7091 "Override capability negotiation result\n")
7094 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7095 PEER_FLAG_OVERRIDE_CAPABILITY
);
7098 DEFUN (no_neighbor_override_capability
,
7099 no_neighbor_override_capability_cmd
,
7100 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7104 "Override capability negotiation result\n")
7107 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7108 PEER_FLAG_OVERRIDE_CAPABILITY
);
7111 DEFUN (neighbor_strict_capability
,
7112 neighbor_strict_capability_cmd
,
7113 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7116 "Strict capability negotiation match\n")
7120 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7121 PEER_FLAG_STRICT_CAP_MATCH
);
7124 DEFUN (no_neighbor_strict_capability
,
7125 no_neighbor_strict_capability_cmd
,
7126 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7130 "Strict capability negotiation match\n")
7134 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7135 PEER_FLAG_STRICT_CAP_MATCH
);
7138 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7139 const char *keep_str
, const char *hold_str
)
7146 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7148 return CMD_WARNING_CONFIG_FAILED
;
7150 keepalive
= strtoul(keep_str
, NULL
, 10);
7151 holdtime
= strtoul(hold_str
, NULL
, 10);
7153 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7155 return bgp_vty_return(vty
, ret
);
7158 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7163 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7165 return CMD_WARNING_CONFIG_FAILED
;
7167 ret
= peer_timers_unset(peer
);
7169 return bgp_vty_return(vty
, ret
);
7172 DEFUN (neighbor_timers
,
7173 neighbor_timers_cmd
,
7174 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7177 "BGP per neighbor timers\n"
7178 "Keepalive interval\n"
7183 int idx_number_2
= 4;
7184 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7185 argv
[idx_number
]->arg
,
7186 argv
[idx_number_2
]->arg
);
7189 DEFUN (no_neighbor_timers
,
7190 no_neighbor_timers_cmd
,
7191 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7195 "BGP per neighbor timers\n"
7196 "Keepalive interval\n"
7200 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7204 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7205 const char *time_str
)
7211 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7213 return CMD_WARNING_CONFIG_FAILED
;
7215 connect
= strtoul(time_str
, NULL
, 10);
7217 ret
= peer_timers_connect_set(peer
, connect
);
7219 return bgp_vty_return(vty
, ret
);
7222 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7227 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7229 return CMD_WARNING_CONFIG_FAILED
;
7231 ret
= peer_timers_connect_unset(peer
);
7233 return bgp_vty_return(vty
, ret
);
7236 DEFUN (neighbor_timers_connect
,
7237 neighbor_timers_connect_cmd
,
7238 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7241 "BGP per neighbor timers\n"
7242 "BGP connect timer\n"
7247 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7248 argv
[idx_number
]->arg
);
7251 DEFUN (no_neighbor_timers_connect
,
7252 no_neighbor_timers_connect_cmd
,
7253 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7257 "BGP per neighbor timers\n"
7258 "BGP connect timer\n"
7262 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7265 DEFPY (neighbor_timers_delayopen
,
7266 neighbor_timers_delayopen_cmd
,
7267 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7270 "BGP per neighbor timers\n"
7271 "RFC 4271 DelayOpenTimer\n"
7272 "DelayOpenTime timer interval\n")
7276 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7278 return CMD_WARNING_CONFIG_FAILED
;
7281 if (peer_timers_delayopen_unset(peer
))
7282 return CMD_WARNING_CONFIG_FAILED
;
7284 if (peer_timers_delayopen_set(peer
, interval
))
7285 return CMD_WARNING_CONFIG_FAILED
;
7291 DEFPY (no_neighbor_timers_delayopen
,
7292 no_neighbor_timers_delayopen_cmd
,
7293 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7297 "BGP per neighbor timers\n"
7298 "RFC 4271 DelayOpenTimer\n"
7299 "DelayOpenTime timer interval\n")
7303 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7305 return CMD_WARNING_CONFIG_FAILED
;
7307 if (peer_timers_delayopen_unset(peer
))
7308 return CMD_WARNING_CONFIG_FAILED
;
7313 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7314 const char *time_str
, int set
)
7318 uint32_t routeadv
= 0;
7320 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7322 return CMD_WARNING_CONFIG_FAILED
;
7325 routeadv
= strtoul(time_str
, NULL
, 10);
7328 ret
= peer_advertise_interval_set(peer
, routeadv
);
7330 ret
= peer_advertise_interval_unset(peer
);
7332 return bgp_vty_return(vty
, ret
);
7335 DEFUN (neighbor_advertise_interval
,
7336 neighbor_advertise_interval_cmd
,
7337 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7340 "Minimum interval between sending BGP routing updates\n"
7341 "time in seconds\n")
7345 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7346 argv
[idx_number
]->arg
, 1);
7349 DEFUN (no_neighbor_advertise_interval
,
7350 no_neighbor_advertise_interval_cmd
,
7351 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7355 "Minimum interval between sending BGP routing updates\n"
7356 "time in seconds\n")
7359 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7363 /* Time to wait before processing route-map updates */
7364 DEFUN (bgp_set_route_map_delay_timer
,
7365 bgp_set_route_map_delay_timer_cmd
,
7366 "bgp route-map delay-timer (0-600)",
7368 "BGP route-map delay timer\n"
7369 "Time in secs to wait before processing route-map changes\n"
7370 "0 disables the timer, no route updates happen when route-maps change\n")
7373 uint32_t rmap_delay_timer
;
7375 if (argv
[idx_number
]->arg
) {
7376 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7377 bm
->rmap_update_timer
= rmap_delay_timer
;
7379 /* if the dynamic update handling is being disabled, and a timer
7381 * running, stop the timer and act as if the timer has already
7384 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7385 THREAD_OFF(bm
->t_rmap_update
);
7386 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7391 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7392 return CMD_WARNING_CONFIG_FAILED
;
7396 DEFUN (no_bgp_set_route_map_delay_timer
,
7397 no_bgp_set_route_map_delay_timer_cmd
,
7398 "no bgp route-map delay-timer [(0-600)]",
7401 "Default BGP route-map delay timer\n"
7402 "Reset to default time to wait for processing route-map changes\n"
7403 "0 disables the timer, no route updates happen when route-maps change\n")
7406 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7411 /* neighbor interface */
7412 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7417 peer
= peer_lookup_vty(vty
, ip_str
);
7418 if (!peer
|| peer
->conf_if
) {
7419 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7420 return CMD_WARNING_CONFIG_FAILED
;
7424 peer_interface_set(peer
, str
);
7426 peer_interface_unset(peer
);
7431 DEFUN (neighbor_interface
,
7432 neighbor_interface_cmd
,
7433 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7442 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7445 DEFUN (no_neighbor_interface
,
7446 no_neighbor_interface_cmd
,
7447 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7456 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7459 DEFUN (neighbor_distribute_list
,
7460 neighbor_distribute_list_cmd
,
7461 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7464 "Filter updates to/from this neighbor\n"
7465 "IP Access-list name\n"
7466 "Filter incoming updates\n"
7467 "Filter outgoing updates\n")
7474 const char *pstr
= argv
[idx_peer
]->arg
;
7475 const char *acl
= argv
[idx_acl
]->arg
;
7476 const char *inout
= argv
[argc
- 1]->text
;
7478 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7480 return CMD_WARNING_CONFIG_FAILED
;
7482 /* Check filter direction. */
7483 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7484 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7487 return bgp_vty_return(vty
, ret
);
7491 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7492 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7493 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7494 "Filter updates to/from this neighbor\n"
7495 "IP Access-list name\n"
7496 "Filter incoming updates\n"
7497 "Filter outgoing updates\n")
7499 DEFUN (no_neighbor_distribute_list
,
7500 no_neighbor_distribute_list_cmd
,
7501 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7505 "Filter updates to/from this neighbor\n"
7506 "IP Access-list name\n"
7507 "Filter incoming updates\n"
7508 "Filter outgoing updates\n")
7514 const char *pstr
= argv
[idx_peer
]->arg
;
7515 const char *inout
= argv
[argc
- 1]->text
;
7517 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7519 return CMD_WARNING_CONFIG_FAILED
;
7521 /* Check filter direction. */
7522 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7523 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7526 return bgp_vty_return(vty
, ret
);
7530 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7531 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7532 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7533 "Filter updates to/from this neighbor\n"
7534 "IP Access-list name\n"
7535 "Filter incoming updates\n"
7536 "Filter outgoing updates\n")
7538 /* Set prefix list to the peer. */
7539 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7540 afi_t afi
, safi_t safi
,
7541 const char *name_str
,
7542 const char *direct_str
)
7545 int direct
= FILTER_IN
;
7548 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7550 return CMD_WARNING_CONFIG_FAILED
;
7552 /* Check filter direction. */
7553 if (strncmp(direct_str
, "i", 1) == 0)
7555 else if (strncmp(direct_str
, "o", 1) == 0)
7556 direct
= FILTER_OUT
;
7558 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7560 return bgp_vty_return(vty
, ret
);
7563 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7564 afi_t afi
, safi_t safi
,
7565 const char *direct_str
)
7569 int direct
= FILTER_IN
;
7571 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7573 return CMD_WARNING_CONFIG_FAILED
;
7575 /* Check filter direction. */
7576 if (strncmp(direct_str
, "i", 1) == 0)
7578 else if (strncmp(direct_str
, "o", 1) == 0)
7579 direct
= FILTER_OUT
;
7581 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7583 return bgp_vty_return(vty
, ret
);
7586 DEFUN (neighbor_prefix_list
,
7587 neighbor_prefix_list_cmd
,
7588 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7591 "Filter updates to/from this neighbor\n"
7592 "Name of a prefix list\n"
7593 "Filter incoming updates\n"
7594 "Filter outgoing updates\n")
7599 return peer_prefix_list_set_vty(
7600 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7601 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7604 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7605 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7606 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7607 "Filter updates to/from this neighbor\n"
7608 "Name of a prefix list\n"
7609 "Filter incoming updates\n"
7610 "Filter outgoing updates\n")
7612 DEFUN (no_neighbor_prefix_list
,
7613 no_neighbor_prefix_list_cmd
,
7614 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7618 "Filter updates to/from this neighbor\n"
7619 "Name of a prefix list\n"
7620 "Filter incoming updates\n"
7621 "Filter outgoing updates\n")
7625 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7626 bgp_node_afi(vty
), bgp_node_safi(vty
),
7627 argv
[idx_in_out
]->arg
);
7630 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7631 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7632 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7633 "Filter updates to/from this neighbor\n"
7634 "Name of a prefix list\n"
7635 "Filter incoming updates\n"
7636 "Filter outgoing updates\n")
7638 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7639 safi_t safi
, const char *name_str
,
7640 const char *direct_str
)
7644 int direct
= FILTER_IN
;
7646 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7648 return CMD_WARNING_CONFIG_FAILED
;
7650 /* Check filter direction. */
7651 if (strncmp(direct_str
, "i", 1) == 0)
7653 else if (strncmp(direct_str
, "o", 1) == 0)
7654 direct
= FILTER_OUT
;
7656 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7658 return bgp_vty_return(vty
, ret
);
7661 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7662 safi_t safi
, const char *direct_str
)
7666 int direct
= FILTER_IN
;
7668 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7670 return CMD_WARNING_CONFIG_FAILED
;
7672 /* Check filter direction. */
7673 if (strncmp(direct_str
, "i", 1) == 0)
7675 else if (strncmp(direct_str
, "o", 1) == 0)
7676 direct
= FILTER_OUT
;
7678 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7680 return bgp_vty_return(vty
, ret
);
7683 DEFUN (neighbor_filter_list
,
7684 neighbor_filter_list_cmd
,
7685 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7688 "Establish BGP filters\n"
7689 "AS path access-list name\n"
7690 "Filter incoming routes\n"
7691 "Filter outgoing routes\n")
7696 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7697 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7698 argv
[idx_in_out
]->arg
);
7701 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7702 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7703 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7704 "Establish BGP filters\n"
7705 "AS path access-list name\n"
7706 "Filter incoming routes\n"
7707 "Filter outgoing routes\n")
7709 DEFUN (no_neighbor_filter_list
,
7710 no_neighbor_filter_list_cmd
,
7711 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7715 "Establish BGP filters\n"
7716 "AS path access-list name\n"
7717 "Filter incoming routes\n"
7718 "Filter outgoing routes\n")
7722 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7723 bgp_node_afi(vty
), bgp_node_safi(vty
),
7724 argv
[idx_in_out
]->arg
);
7727 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7728 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7729 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7730 "Establish BGP filters\n"
7731 "AS path access-list name\n"
7732 "Filter incoming routes\n"
7733 "Filter outgoing routes\n")
7735 /* Set advertise-map to the peer. */
7736 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7737 afi_t afi
, safi_t safi
,
7738 const char *advertise_str
,
7739 const char *condition_str
, bool condition
,
7742 int ret
= CMD_WARNING_CONFIG_FAILED
;
7744 struct route_map
*advertise_map
;
7745 struct route_map
*condition_map
;
7747 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7751 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7752 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7755 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7756 advertise_map
, condition_str
,
7757 condition_map
, condition
);
7759 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7760 advertise_map
, condition_str
,
7761 condition_map
, condition
);
7763 return bgp_vty_return(vty
, ret
);
7766 DEFPY (bgp_condadv_period
,
7767 bgp_condadv_period_cmd
,
7768 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7771 "Conditional advertisement settings\n"
7772 "Set period to rescan BGP table to check if condition is met\n"
7773 "Period between BGP table scans, in seconds; default 60\n")
7775 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7777 bgp
->condition_check_period
=
7778 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7783 DEFPY (neighbor_advertise_map
,
7784 neighbor_advertise_map_cmd
,
7785 "[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",
7789 "Route-map to conditionally advertise routes\n"
7790 "Name of advertise map\n"
7791 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7792 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7793 "Name of the exist or non exist map\n")
7795 bool condition
= CONDITION_EXIST
;
7797 if (!strcmp(exist
, "non-exist-map"))
7798 condition
= CONDITION_NON_EXIST
;
7800 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7801 bgp_node_safi(vty
), advertise_str
,
7802 condition_str
, condition
, !no
);
7805 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7806 "[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",
7807 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7808 "Route-map to conditionally advertise routes\n"
7809 "Name of advertise map\n"
7810 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7811 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7812 "Name of the exist or non exist map\n")
7814 /* Set route-map to the peer. */
7815 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7816 afi_t afi
, safi_t safi
, const char *name_str
,
7817 const char *direct_str
)
7821 int direct
= RMAP_IN
;
7822 struct route_map
*route_map
;
7824 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7826 return CMD_WARNING_CONFIG_FAILED
;
7828 /* Check filter direction. */
7829 if (strncmp(direct_str
, "in", 2) == 0)
7831 else if (strncmp(direct_str
, "o", 1) == 0)
7834 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7835 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7837 return bgp_vty_return(vty
, ret
);
7840 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7841 afi_t afi
, safi_t safi
,
7842 const char *direct_str
)
7846 int direct
= RMAP_IN
;
7848 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7850 return CMD_WARNING_CONFIG_FAILED
;
7852 /* Check filter direction. */
7853 if (strncmp(direct_str
, "in", 2) == 0)
7855 else if (strncmp(direct_str
, "o", 1) == 0)
7858 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7860 return bgp_vty_return(vty
, ret
);
7863 DEFUN (neighbor_route_map
,
7864 neighbor_route_map_cmd
,
7865 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7868 "Apply route map to neighbor\n"
7869 "Name of route map\n"
7870 "Apply map to incoming routes\n"
7871 "Apply map to outbound routes\n")
7876 return peer_route_map_set_vty(
7877 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7878 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7881 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7882 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7883 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7884 "Apply route map to neighbor\n"
7885 "Name of route map\n"
7886 "Apply map to incoming routes\n"
7887 "Apply map to outbound routes\n")
7889 DEFUN (no_neighbor_route_map
,
7890 no_neighbor_route_map_cmd
,
7891 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7895 "Apply route map to neighbor\n"
7896 "Name of route map\n"
7897 "Apply map to incoming routes\n"
7898 "Apply map to outbound routes\n")
7902 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7903 bgp_node_afi(vty
), bgp_node_safi(vty
),
7904 argv
[idx_in_out
]->arg
);
7907 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7908 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7909 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7910 "Apply route map to neighbor\n"
7911 "Name of route map\n"
7912 "Apply map to incoming routes\n"
7913 "Apply map to outbound routes\n")
7915 /* Set unsuppress-map to the peer. */
7916 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7917 afi_t afi
, safi_t safi
,
7918 const char *name_str
)
7922 struct route_map
*route_map
;
7924 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7926 return CMD_WARNING_CONFIG_FAILED
;
7928 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7929 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7931 return bgp_vty_return(vty
, ret
);
7934 /* Unset route-map from the peer. */
7935 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7936 afi_t afi
, safi_t safi
)
7941 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7943 return CMD_WARNING_CONFIG_FAILED
;
7945 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7947 return bgp_vty_return(vty
, ret
);
7950 DEFUN (neighbor_unsuppress_map
,
7951 neighbor_unsuppress_map_cmd
,
7952 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7955 "Route-map to selectively unsuppress suppressed routes\n"
7956 "Name of route map\n")
7960 return peer_unsuppress_map_set_vty(
7961 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7962 argv
[idx_word
]->arg
);
7965 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7966 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7967 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7968 "Route-map to selectively unsuppress suppressed routes\n"
7969 "Name of route map\n")
7971 DEFUN (no_neighbor_unsuppress_map
,
7972 no_neighbor_unsuppress_map_cmd
,
7973 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7977 "Route-map to selectively unsuppress suppressed routes\n"
7978 "Name of route map\n")
7981 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7983 bgp_node_safi(vty
));
7986 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7987 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7988 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7989 "Route-map to selectively unsuppress suppressed routes\n"
7990 "Name of route map\n")
7992 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7993 afi_t afi
, safi_t safi
,
7994 const char *num_str
,
7995 const char *threshold_str
, int warning
,
7996 const char *restart_str
,
7997 const char *force_str
)
8005 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8007 return CMD_WARNING_CONFIG_FAILED
;
8009 max
= strtoul(num_str
, NULL
, 10);
8011 threshold
= atoi(threshold_str
);
8013 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8016 restart
= atoi(restart_str
);
8020 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8021 restart
, force_str
? true : false);
8023 return bgp_vty_return(vty
, ret
);
8026 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8027 afi_t afi
, safi_t safi
)
8032 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8034 return CMD_WARNING_CONFIG_FAILED
;
8036 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8038 return bgp_vty_return(vty
, ret
);
8041 /* Maximum number of prefix to be sent to the neighbor. */
8042 DEFUN(neighbor_maximum_prefix_out
,
8043 neighbor_maximum_prefix_out_cmd
,
8044 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8047 "Maximum number of prefixes to be sent to this peer\n"
8048 "Maximum no. of prefix limit\n")
8055 afi_t afi
= bgp_node_afi(vty
);
8056 safi_t safi
= bgp_node_safi(vty
);
8058 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8060 return CMD_WARNING_CONFIG_FAILED
;
8062 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8064 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8066 return bgp_vty_return(vty
, ret
);
8069 DEFUN(no_neighbor_maximum_prefix_out
,
8070 no_neighbor_maximum_prefix_out_cmd
,
8071 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8075 "Maximum number of prefixes to be sent to this peer\n"
8076 "Maximum no. of prefix limit\n")
8081 afi_t afi
= bgp_node_afi(vty
);
8082 safi_t safi
= bgp_node_safi(vty
);
8084 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8086 return CMD_WARNING_CONFIG_FAILED
;
8088 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8090 return bgp_vty_return(vty
, ret
);
8093 /* Maximum number of prefix configuration. Prefix count is different
8094 for each peer configuration. So this configuration can be set for
8095 each peer configuration. */
8096 DEFUN (neighbor_maximum_prefix
,
8097 neighbor_maximum_prefix_cmd
,
8098 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8101 "Maximum number of prefix accept from this peer\n"
8102 "maximum no. of prefix limit\n"
8103 "Force checking all received routes not only accepted\n")
8110 if (argv_find(argv
, argc
, "force", &idx_force
))
8111 force
= argv
[idx_force
]->arg
;
8113 return peer_maximum_prefix_set_vty(
8114 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8115 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8118 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8119 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8120 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8121 "Maximum number of prefix accept from this peer\n"
8122 "maximum no. of prefix limit\n"
8123 "Force checking all received routes not only accepted\n")
8125 DEFUN (neighbor_maximum_prefix_threshold
,
8126 neighbor_maximum_prefix_threshold_cmd
,
8127 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8130 "Maximum number of prefix accept from this peer\n"
8131 "maximum no. of prefix limit\n"
8132 "Threshold value (%) at which to generate a warning msg\n"
8133 "Force checking all received routes not only accepted\n")
8137 int idx_number_2
= 4;
8141 if (argv_find(argv
, argc
, "force", &idx_force
))
8142 force
= argv
[idx_force
]->arg
;
8144 return peer_maximum_prefix_set_vty(
8145 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8146 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8150 neighbor_maximum_prefix_threshold
,
8151 neighbor_maximum_prefix_threshold_hidden_cmd
,
8152 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8153 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8154 "Maximum number of prefix accept from this peer\n"
8155 "maximum no. of prefix limit\n"
8156 "Threshold value (%) at which to generate a warning msg\n"
8157 "Force checking all received routes not only accepted\n")
8159 DEFUN (neighbor_maximum_prefix_warning
,
8160 neighbor_maximum_prefix_warning_cmd
,
8161 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8164 "Maximum number of prefix accept from this peer\n"
8165 "maximum no. of prefix limit\n"
8166 "Only give warning message when limit is exceeded\n"
8167 "Force checking all received routes not only accepted\n")
8174 if (argv_find(argv
, argc
, "force", &idx_force
))
8175 force
= argv
[idx_force
]->arg
;
8177 return peer_maximum_prefix_set_vty(
8178 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8179 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8183 neighbor_maximum_prefix_warning
,
8184 neighbor_maximum_prefix_warning_hidden_cmd
,
8185 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8186 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8187 "Maximum number of prefix accept from this peer\n"
8188 "maximum no. of prefix limit\n"
8189 "Only give warning message when limit is exceeded\n"
8190 "Force checking all received routes not only accepted\n")
8192 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8193 neighbor_maximum_prefix_threshold_warning_cmd
,
8194 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8197 "Maximum number of prefix accept from this peer\n"
8198 "maximum no. of prefix limit\n"
8199 "Threshold value (%) at which to generate a warning msg\n"
8200 "Only give warning message when limit is exceeded\n"
8201 "Force checking all received routes not only accepted\n")
8205 int idx_number_2
= 4;
8209 if (argv_find(argv
, argc
, "force", &idx_force
))
8210 force
= argv
[idx_force
]->arg
;
8212 return peer_maximum_prefix_set_vty(
8213 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8214 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8218 neighbor_maximum_prefix_threshold_warning
,
8219 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8220 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8221 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8222 "Maximum number of prefix accept from this peer\n"
8223 "maximum no. of prefix limit\n"
8224 "Threshold value (%) at which to generate a warning msg\n"
8225 "Only give warning message when limit is exceeded\n"
8226 "Force checking all received routes not only accepted\n")
8228 DEFUN (neighbor_maximum_prefix_restart
,
8229 neighbor_maximum_prefix_restart_cmd
,
8230 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8233 "Maximum number of prefix accept from this peer\n"
8234 "maximum no. of prefix limit\n"
8235 "Restart bgp connection after limit is exceeded\n"
8236 "Restart interval in minutes\n"
8237 "Force checking all received routes not only accepted\n")
8241 int idx_number_2
= 5;
8245 if (argv_find(argv
, argc
, "force", &idx_force
))
8246 force
= argv
[idx_force
]->arg
;
8248 return peer_maximum_prefix_set_vty(
8249 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8250 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8254 neighbor_maximum_prefix_restart
,
8255 neighbor_maximum_prefix_restart_hidden_cmd
,
8256 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8257 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8258 "Maximum number of prefix accept from this peer\n"
8259 "maximum no. of prefix limit\n"
8260 "Restart bgp connection after limit is exceeded\n"
8261 "Restart interval in minutes\n"
8262 "Force checking all received routes not only accepted\n")
8264 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8265 neighbor_maximum_prefix_threshold_restart_cmd
,
8266 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8269 "Maximum number of prefixes to accept from this peer\n"
8270 "maximum no. of prefix limit\n"
8271 "Threshold value (%) at which to generate a warning msg\n"
8272 "Restart bgp connection after limit is exceeded\n"
8273 "Restart interval in minutes\n"
8274 "Force checking all received routes not only accepted\n")
8278 int idx_number_2
= 4;
8279 int idx_number_3
= 6;
8283 if (argv_find(argv
, argc
, "force", &idx_force
))
8284 force
= argv
[idx_force
]->arg
;
8286 return peer_maximum_prefix_set_vty(
8287 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8288 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8289 argv
[idx_number_3
]->arg
, force
);
8293 neighbor_maximum_prefix_threshold_restart
,
8294 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8295 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8296 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8297 "Maximum number of prefixes to accept from this peer\n"
8298 "maximum no. of prefix limit\n"
8299 "Threshold value (%) at which to generate a warning msg\n"
8300 "Restart bgp connection after limit is exceeded\n"
8301 "Restart interval in minutes\n"
8302 "Force checking all received routes not only accepted\n")
8304 DEFUN (no_neighbor_maximum_prefix
,
8305 no_neighbor_maximum_prefix_cmd
,
8306 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8310 "Maximum number of prefixes to accept from this peer\n"
8311 "maximum no. of prefix limit\n"
8312 "Threshold value (%) at which to generate a warning msg\n"
8313 "Restart bgp connection after limit is exceeded\n"
8314 "Restart interval in minutes\n"
8315 "Only give warning message when limit is exceeded\n"
8316 "Force checking all received routes not only accepted\n")
8319 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8321 bgp_node_safi(vty
));
8325 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8326 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8327 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8328 "Maximum number of prefixes to accept from this peer\n"
8329 "maximum no. of prefix limit\n"
8330 "Threshold value (%) at which to generate a warning msg\n"
8331 "Restart bgp connection after limit is exceeded\n"
8332 "Restart interval in minutes\n"
8333 "Only give warning message when limit is exceeded\n"
8334 "Force checking all received routes not only accepted\n")
8336 /* "neighbor accept-own" */
8337 DEFPY (neighbor_accept_own
,
8338 neighbor_accept_own_cmd
,
8339 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8343 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8346 afi_t afi
= bgp_node_afi(vty
);
8347 safi_t safi
= bgp_node_safi(vty
);
8350 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8352 return CMD_WARNING_CONFIG_FAILED
;
8355 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8357 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8359 return bgp_vty_return(vty
, ret
);
8362 /* "neighbor soo" */
8363 DEFPY (neighbor_soo
,
8365 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8368 "Set the Site-of-Origin (SoO) extended community\n"
8369 "VPN extended community\n")
8372 afi_t afi
= bgp_node_afi(vty
);
8373 safi_t safi
= bgp_node_safi(vty
);
8374 struct ecommunity
*ecomm_soo
;
8376 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8378 return CMD_WARNING_CONFIG_FAILED
;
8380 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8382 vty_out(vty
, "%% Malformed SoO extended community\n");
8385 ecommunity_str(ecomm_soo
);
8387 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8388 ecommunity_free(&peer
->soo
[afi
][safi
]);
8389 peer
->soo
[afi
][safi
] = ecomm_soo
;
8390 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8393 return bgp_vty_return(vty
,
8394 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8397 DEFPY (no_neighbor_soo
,
8398 no_neighbor_soo_cmd
,
8399 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8403 "Set the Site-of-Origin (SoO) extended community\n"
8404 "VPN extended community\n")
8407 afi_t afi
= bgp_node_afi(vty
);
8408 safi_t safi
= bgp_node_safi(vty
);
8410 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8412 return CMD_WARNING_CONFIG_FAILED
;
8414 ecommunity_free(&peer
->soo
[afi
][safi
]);
8416 return bgp_vty_return(
8417 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8420 /* "neighbor allowas-in" */
8421 DEFUN (neighbor_allowas_in
,
8422 neighbor_allowas_in_cmd
,
8423 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8426 "Accept as-path with my AS present in it\n"
8427 "Number of occurrences of AS number\n"
8428 "Only accept my AS in the as-path if the route was originated in my AS\n")
8431 int idx_number_origin
= 3;
8437 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8439 return CMD_WARNING_CONFIG_FAILED
;
8441 if (argc
<= idx_number_origin
)
8444 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8447 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8450 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8453 return bgp_vty_return(vty
, ret
);
8457 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8458 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8459 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8460 "Accept as-path with my AS present in it\n"
8461 "Number of occurrences of AS number\n"
8462 "Only accept my AS in the as-path if the route was originated in my AS\n")
8464 DEFUN (no_neighbor_allowas_in
,
8465 no_neighbor_allowas_in_cmd
,
8466 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8470 "allow local ASN appears in aspath attribute\n"
8471 "Number of occurrences of AS number\n"
8472 "Only accept my AS in the as-path if the route was originated in my AS\n")
8478 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8480 return CMD_WARNING_CONFIG_FAILED
;
8482 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8483 bgp_node_safi(vty
));
8485 return bgp_vty_return(vty
, ret
);
8489 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8490 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8491 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8492 "allow local ASN appears in aspath attribute\n"
8493 "Number of occurrences of AS number\n"
8494 "Only accept my AS in the as-path if the route was originated in my AS\n")
8496 DEFUN (neighbor_ttl_security
,
8497 neighbor_ttl_security_cmd
,
8498 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8501 "BGP ttl-security parameters\n"
8502 "Specify the maximum number of hops to the BGP peer\n"
8503 "Number of hops to BGP peer\n")
8510 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8512 return CMD_WARNING_CONFIG_FAILED
;
8514 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8517 * If 'neighbor swpX', then this is for directly connected peers,
8518 * we should not accept a ttl-security hops value greater than 1.
8520 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8522 "%s is directly connected peer, hops cannot exceed 1\n",
8523 argv
[idx_peer
]->arg
);
8524 return CMD_WARNING_CONFIG_FAILED
;
8527 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8530 DEFUN (no_neighbor_ttl_security
,
8531 no_neighbor_ttl_security_cmd
,
8532 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8536 "BGP ttl-security parameters\n"
8537 "Specify the maximum number of hops to the BGP peer\n"
8538 "Number of hops to BGP peer\n")
8543 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8545 return CMD_WARNING_CONFIG_FAILED
;
8547 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8550 /* disable-addpath-rx */
8551 DEFUN(neighbor_disable_addpath_rx
,
8552 neighbor_disable_addpath_rx_cmd
,
8553 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8556 "Do not accept additional paths\n")
8558 char *peer_str
= argv
[1]->arg
;
8560 afi_t afi
= bgp_node_afi(vty
);
8561 safi_t safi
= bgp_node_safi(vty
);
8563 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8565 return CMD_WARNING_CONFIG_FAILED
;
8567 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8568 PEER_FLAG_DISABLE_ADDPATH_RX
);
8571 DEFUN(no_neighbor_disable_addpath_rx
,
8572 no_neighbor_disable_addpath_rx_cmd
,
8573 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8577 "Do not accept additional paths\n")
8579 char *peer_str
= argv
[2]->arg
;
8581 afi_t afi
= bgp_node_afi(vty
);
8582 safi_t safi
= bgp_node_safi(vty
);
8584 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8586 return CMD_WARNING_CONFIG_FAILED
;
8588 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8589 PEER_FLAG_DISABLE_ADDPATH_RX
);
8592 DEFUN (neighbor_addpath_tx_all_paths
,
8593 neighbor_addpath_tx_all_paths_cmd
,
8594 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8597 "Use addpath to advertise all paths to a neighbor\n")
8602 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8604 return CMD_WARNING_CONFIG_FAILED
;
8606 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8611 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8612 neighbor_addpath_tx_all_paths_hidden_cmd
,
8613 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8614 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8615 "Use addpath to advertise all paths to a neighbor\n")
8617 DEFUN (no_neighbor_addpath_tx_all_paths
,
8618 no_neighbor_addpath_tx_all_paths_cmd
,
8619 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8623 "Use addpath to advertise all paths to a neighbor\n")
8628 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8630 return CMD_WARNING_CONFIG_FAILED
;
8632 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8633 != BGP_ADDPATH_ALL
) {
8635 "%% Peer not currently configured to transmit all paths.");
8636 return CMD_WARNING_CONFIG_FAILED
;
8639 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8645 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8646 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8647 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8648 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8649 "Use addpath to advertise all paths to a neighbor\n")
8651 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8652 neighbor_addpath_tx_bestpath_per_as_cmd
,
8653 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8656 "Use addpath to advertise the bestpath per each neighboring AS\n")
8661 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8663 return CMD_WARNING_CONFIG_FAILED
;
8665 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8666 BGP_ADDPATH_BEST_PER_AS
);
8671 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8672 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8673 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8674 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8675 "Use addpath to advertise the bestpath per each neighboring AS\n")
8677 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8678 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8679 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8683 "Use addpath to advertise the bestpath per each neighboring AS\n")
8688 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8690 return CMD_WARNING_CONFIG_FAILED
;
8692 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8693 != BGP_ADDPATH_BEST_PER_AS
) {
8695 "%% Peer not currently configured to transmit all best path per as.");
8696 return CMD_WARNING_CONFIG_FAILED
;
8699 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8705 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8706 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8707 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8708 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8709 "Use addpath to advertise the bestpath per each neighboring AS\n")
8712 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8713 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8716 "Detect AS loops before sending to neighbor\n")
8720 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8722 return CMD_WARNING_CONFIG_FAILED
;
8724 peer
->as_path_loop_detection
= true;
8730 no_neighbor_aspath_loop_detection
,
8731 no_neighbor_aspath_loop_detection_cmd
,
8732 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8736 "Detect AS loops before sending to neighbor\n")
8740 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8742 return CMD_WARNING_CONFIG_FAILED
;
8744 peer
->as_path_loop_detection
= false;
8749 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8750 struct ecommunity
**list
, bool is_rt6
)
8752 struct ecommunity
*ecom
= NULL
;
8753 struct ecommunity
*ecomadd
;
8755 for (; argc
; --argc
, ++argv
) {
8757 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8758 ECOMMUNITY_ROUTE_TARGET
,
8761 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8762 ECOMMUNITY_ROUTE_TARGET
,
8765 vty_out(vty
, "Malformed community-list value\n");
8767 ecommunity_free(&ecom
);
8768 return CMD_WARNING_CONFIG_FAILED
;
8772 ecommunity_merge(ecom
, ecomadd
);
8773 ecommunity_free(&ecomadd
);
8780 ecommunity_free(&*list
);
8788 * v2vimport is true if we are handling a `import vrf ...` command
8790 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8794 switch (vty
->node
) {
8803 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8808 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8809 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8810 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8811 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8813 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8817 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8818 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8819 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8820 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8822 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8829 DEFPY (af_rd_vpn_export
,
8830 af_rd_vpn_export_cmd
,
8831 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8833 "Specify route distinguisher\n"
8834 "Between current address-family and vpn\n"
8835 "For routes leaked from current address-family to vpn\n"
8836 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8839 struct prefix_rd prd
;
8845 if (argv_find(argv
, argc
, "no", &idx
))
8849 ret
= str2prefix_rd(rd_str
, &prd
);
8851 vty_out(vty
, "%% Malformed rd\n");
8852 return CMD_WARNING_CONFIG_FAILED
;
8856 afi
= vpn_policy_getafi(vty
, bgp
, false);
8858 return CMD_WARNING_CONFIG_FAILED
;
8861 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8863 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8864 bgp_get_default(), bgp
);
8867 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8868 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8869 BGP_VPN_POLICY_TOVPN_RD_SET
);
8871 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8872 BGP_VPN_POLICY_TOVPN_RD_SET
);
8875 /* post-change: re-export vpn routes */
8876 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8877 bgp_get_default(), bgp
);
8882 ALIAS (af_rd_vpn_export
,
8883 af_no_rd_vpn_export_cmd
,
8886 "Specify route distinguisher\n"
8887 "Between current address-family and vpn\n"
8888 "For routes leaked from current address-family to vpn\n")
8890 DEFPY (af_label_vpn_export
,
8891 af_label_vpn_export_cmd
,
8892 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8894 "label value for VRF\n"
8895 "Between current address-family and vpn\n"
8896 "For routes leaked from current address-family to vpn\n"
8897 "Label Value <0-1048575>\n"
8898 "Automatically assign a label\n")
8900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8901 mpls_label_t label
= MPLS_LABEL_NONE
;
8906 if (argv_find(argv
, argc
, "no", &idx
))
8909 /* If "no ...", squash trailing parameter */
8915 label
= label_val
; /* parser should force unsigned */
8918 afi
= vpn_policy_getafi(vty
, bgp
, false);
8920 return CMD_WARNING_CONFIG_FAILED
;
8923 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8924 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8929 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8931 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8932 bgp_get_default(), bgp
);
8934 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8935 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8937 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8940 * label has previously been automatically
8941 * assigned by labelpool: release it
8943 * NB if tovpn_label == MPLS_LABEL_NONE it
8944 * means the automatic assignment is in flight
8945 * and therefore the labelpool callback must
8946 * detect that the auto label is not needed.
8949 bgp_lp_release(LP_TYPE_VRF
,
8950 &bgp
->vpn_policy
[afi
],
8951 bgp
->vpn_policy
[afi
].tovpn_label
);
8953 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8954 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8957 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8959 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8960 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8961 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8962 vpn_leak_label_callback
);
8965 /* post-change: re-export vpn routes */
8966 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8967 bgp_get_default(), bgp
);
8969 hook_call(bgp_snmp_update_last_changed
, bgp
);
8973 DEFPY (af_sid_vpn_export
,
8974 af_sid_vpn_export_cmd
,
8975 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
8977 "sid value for VRF\n"
8978 "Between current address-family and vpn\n"
8979 "For routes leaked from current address-family to vpn\n"
8980 "Sid allocation index\n"
8981 "Automatically assign a label\n")
8983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8989 if (argv_find(argv
, argc
, "no", &idx
))
8991 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8992 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8994 afi
= vpn_policy_getafi(vty
, bgp
, false);
8996 return CMD_WARNING_CONFIG_FAILED
;
9000 vty_out(vty
, "It's not implemented\n");
9001 return CMD_WARNING_CONFIG_FAILED
;
9004 if (bgp
->tovpn_sid_index
!= 0 ||
9005 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9007 "per-vrf sid and per-af sid are mutually exclusive\n"
9008 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9009 return CMD_WARNING_CONFIG_FAILED
;
9012 /* skip when it's already configured */
9013 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9014 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9015 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9019 * mode change between sid_idx and sid_auto isn't supported.
9020 * user must negate sid vpn export when they want to change the mode
9022 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9023 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9024 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9025 vty_out(vty
, "it's already configured as %s.\n",
9026 sid_auto
? "auto-mode" : "idx-mode");
9027 return CMD_WARNING_CONFIG_FAILED
;
9031 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9032 bgp_get_default(), bgp
);
9035 /* SID allocation auto-mode */
9037 zlog_debug("%s: auto sid alloc.", __func__
);
9038 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9039 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9041 /* SID allocation index-mode */
9043 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9044 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9048 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9049 bgp_get_default(), bgp
);
9053 DEFPY (bgp_sid_vpn_export
,
9054 bgp_sid_vpn_export_cmd
,
9055 "[no] sid vpn per-vrf export <(1-255)$sid_idx|auto$sid_auto>",
9057 "sid value for VRF\n"
9058 "Between current vrf and vpn\n"
9059 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9060 "For routes leaked from current vrf to vpn\n"
9061 "Sid allocation index\n"
9062 "Automatically assign a label\n")
9064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9067 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9068 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9071 /* when per-VRF SID is not set, do nothing */
9072 if (bgp
->tovpn_sid_index
== 0 &&
9073 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9078 bgp
->tovpn_sid_index
= 0;
9079 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9082 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9083 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9084 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9085 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9086 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9087 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9089 "per-vrf sid and per-af sid are mutually exclusive\n"
9090 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9091 return CMD_WARNING_CONFIG_FAILED
;
9094 /* skip when it's already configured */
9095 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9096 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9100 * mode change between sid_idx and sid_auto isn't supported.
9101 * user must negate sid vpn export when they want to change the mode
9103 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9105 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9106 vty_out(vty
, "it's already configured as %s.\n",
9107 sid_auto
? "auto-mode" : "idx-mode");
9108 return CMD_WARNING_CONFIG_FAILED
;
9112 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9114 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9118 /* SID allocation auto-mode */
9120 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9121 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9122 } else if (sid_idx
!= 0) {
9123 /* SID allocation index-mode */
9125 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9127 bgp
->tovpn_sid_index
= sid_idx
;
9131 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9133 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9134 bgp_get_default(), bgp
);
9139 ALIAS (af_label_vpn_export
,
9140 af_no_label_vpn_export_cmd
,
9141 "no label vpn export",
9143 "label value for VRF\n"
9144 "Between current address-family and vpn\n"
9145 "For routes leaked from current address-family to vpn\n")
9147 ALIAS (bgp_sid_vpn_export
,
9148 no_bgp_sid_vpn_export_cmd
,
9149 "no$no sid vpn per-vrf export",
9151 "sid value for VRF\n"
9152 "Between current vrf and vpn\n"
9153 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9154 "For routes leaked from current vrf to vpn\n")
9156 DEFPY (af_nexthop_vpn_export
,
9157 af_nexthop_vpn_export_cmd
,
9158 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9160 "Specify next hop to use for VRF advertised prefixes\n"
9161 "Between current address-family and vpn\n"
9162 "For routes leaked from current address-family to vpn\n"
9166 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9172 vty_out(vty
, "%% Nexthop required\n");
9173 return CMD_WARNING_CONFIG_FAILED
;
9175 if (!sockunion2hostprefix(nexthop_su
, &p
))
9176 return CMD_WARNING_CONFIG_FAILED
;
9179 afi
= vpn_policy_getafi(vty
, bgp
, false);
9181 return CMD_WARNING_CONFIG_FAILED
;
9184 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9186 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9187 bgp_get_default(), bgp
);
9190 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9191 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9192 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9194 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9195 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9198 /* post-change: re-export vpn routes */
9199 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9200 bgp_get_default(), bgp
);
9205 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9207 if (!strcmp(dstr
, "import")) {
9208 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9209 } else if (!strcmp(dstr
, "export")) {
9210 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9211 } else if (!strcmp(dstr
, "both")) {
9212 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9213 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9215 vty_out(vty
, "%% direction parse error\n");
9216 return CMD_WARNING_CONFIG_FAILED
;
9221 DEFPY (af_rt_vpn_imexport
,
9222 af_rt_vpn_imexport_cmd
,
9223 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9225 "Specify route target list\n"
9226 "Specify route target list\n"
9227 "Between current address-family and vpn\n"
9228 "For routes leaked from vpn to current address-family: match any\n"
9229 "For routes leaked from current address-family to vpn: set\n"
9230 "both import: match any and export: set\n"
9231 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9233 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9235 struct ecommunity
*ecom
= NULL
;
9236 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9237 enum vpn_policy_direction dir
;
9242 if (argv_find(argv
, argc
, "no", &idx
))
9245 afi
= vpn_policy_getafi(vty
, bgp
, false);
9247 return CMD_WARNING_CONFIG_FAILED
;
9249 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9250 if (ret
!= CMD_SUCCESS
)
9254 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9255 vty_out(vty
, "%% Missing RTLIST\n");
9256 return CMD_WARNING_CONFIG_FAILED
;
9258 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9259 if (ret
!= CMD_SUCCESS
) {
9264 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9268 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9271 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9273 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9274 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9275 ecommunity_dup(ecom
);
9277 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9279 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9280 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9283 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9287 ecommunity_free(&ecom
);
9292 ALIAS (af_rt_vpn_imexport
,
9293 af_no_rt_vpn_imexport_cmd
,
9294 "no <rt|route-target> vpn <import|export|both>$direction_str",
9296 "Specify route target list\n"
9297 "Specify route target list\n"
9298 "Between current address-family and vpn\n"
9299 "For routes leaked from vpn to current address-family\n"
9300 "For routes leaked from current address-family to vpn\n"
9301 "both import and export\n")
9303 DEFPY (af_route_map_vpn_imexport
,
9304 af_route_map_vpn_imexport_cmd
,
9305 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9306 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9308 "Specify route map\n"
9309 "Between current address-family and vpn\n"
9310 "For routes leaked from vpn to current address-family\n"
9311 "For routes leaked from current address-family to vpn\n"
9312 "name of route-map\n")
9314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9316 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9317 enum vpn_policy_direction dir
;
9322 if (argv_find(argv
, argc
, "no", &idx
))
9325 afi
= vpn_policy_getafi(vty
, bgp
, false);
9327 return CMD_WARNING_CONFIG_FAILED
;
9329 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9330 if (ret
!= CMD_SUCCESS
)
9333 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9337 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9340 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9341 XFREE(MTYPE_ROUTE_MAP_NAME
,
9342 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9343 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9344 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9345 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9346 route_map_lookup_warn_noexist(vty
, rmap_str
);
9347 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9350 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9351 XFREE(MTYPE_ROUTE_MAP_NAME
,
9352 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9353 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9354 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9357 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9363 ALIAS (af_route_map_vpn_imexport
,
9364 af_no_route_map_vpn_imexport_cmd
,
9365 "no route-map vpn <import|export>$direction_str",
9367 "Specify route map\n"
9368 "Between current address-family and vpn\n"
9369 "For routes leaked from vpn to current address-family\n"
9370 "For routes leaked from current address-family to vpn\n")
9372 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9373 "import vrf route-map RMAP$rmap_str",
9374 "Import routes from another VRF\n"
9375 "Vrf routes being filtered\n"
9376 "Specify route map\n"
9377 "name of route-map\n")
9379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9380 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9382 struct bgp
*bgp_default
;
9384 afi
= vpn_policy_getafi(vty
, bgp
, true);
9386 return CMD_WARNING_CONFIG_FAILED
;
9388 bgp_default
= bgp_get_default();
9393 /* Auto-create assuming the same AS */
9394 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9395 BGP_INSTANCE_TYPE_DEFAULT
);
9399 "VRF default is not configured as a bgp instance\n");
9404 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9406 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9407 XFREE(MTYPE_ROUTE_MAP_NAME
,
9408 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9409 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9410 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9411 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9412 route_map_lookup_warn_noexist(vty
, rmap_str
);
9413 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9416 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9417 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9419 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9424 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9425 "no import vrf route-map [RMAP$rmap_str]",
9427 "Import routes from another VRF\n"
9428 "Vrf routes being filtered\n"
9429 "Specify route map\n"
9430 "name of route-map\n")
9432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9433 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9436 afi
= vpn_policy_getafi(vty
, bgp
, true);
9438 return CMD_WARNING_CONFIG_FAILED
;
9440 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9442 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9443 XFREE(MTYPE_ROUTE_MAP_NAME
,
9444 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9445 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9446 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9448 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9449 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9450 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9452 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9457 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9458 "[no] import vrf VIEWVRFNAME$import_name",
9460 "Import routes from another VRF\n"
9461 "VRF to import from\n"
9462 "The name of the VRF\n")
9464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9465 struct listnode
*node
;
9466 struct bgp
*vrf_bgp
, *bgp_default
;
9469 bool remove
= false;
9472 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9476 if (import_name
== NULL
) {
9477 vty_out(vty
, "%% Missing import name\n");
9481 if (strcmp(import_name
, "route-map") == 0) {
9482 vty_out(vty
, "%% Must include route-map name\n");
9486 if (argv_find(argv
, argc
, "no", &idx
))
9489 afi
= vpn_policy_getafi(vty
, bgp
, true);
9491 return CMD_WARNING_CONFIG_FAILED
;
9493 safi
= bgp_node_safi(vty
);
9495 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9496 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9497 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9498 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9499 remove
? "unimport" : "import", import_name
);
9503 bgp_default
= bgp_get_default();
9505 /* Auto-create assuming the same AS */
9506 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9507 BGP_INSTANCE_TYPE_DEFAULT
);
9511 "VRF default is not configured as a bgp instance\n");
9516 vrf_bgp
= bgp_lookup_by_name(import_name
);
9518 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9519 vrf_bgp
= bgp_default
;
9521 /* Auto-create assuming the same AS */
9522 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9526 "VRF %s is not configured as a bgp instance\n",
9533 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9535 /* Already importing from "import_vrf"? */
9536 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9538 if (strcmp(vname
, import_name
) == 0)
9542 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9548 /* This command is valid only in a bgp vrf instance or the default instance */
9549 DEFPY (bgp_imexport_vpn
,
9550 bgp_imexport_vpn_cmd
,
9551 "[no] <import|export>$direction_str vpn",
9553 "Import routes to this address-family\n"
9554 "Export routes from this address-family\n"
9555 "to/from default instance VPN RIB\n")
9557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9564 enum vpn_policy_direction dir
;
9566 if (argv_find(argv
, argc
, "no", &idx
))
9569 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9570 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9572 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9573 return CMD_WARNING_CONFIG_FAILED
;
9576 afi
= bgp_node_afi(vty
);
9577 safi
= bgp_node_safi(vty
);
9578 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9579 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9580 return CMD_WARNING_CONFIG_FAILED
;
9583 if (!strcmp(direction_str
, "import")) {
9584 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9585 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9586 } else if (!strcmp(direction_str
, "export")) {
9587 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9588 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9590 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9591 return CMD_WARNING_CONFIG_FAILED
;
9594 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9597 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9598 if (!previous_state
) {
9599 /* trigger export current vrf */
9600 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9603 if (previous_state
) {
9604 /* trigger un-export current vrf */
9605 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9607 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9610 hook_call(bgp_snmp_init_stats
, bgp
);
9615 DEFPY (af_routetarget_import
,
9616 af_routetarget_import_cmd
,
9617 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9619 "Specify route target list\n"
9620 "Specify route target list\n"
9621 "Specify route target list\n"
9622 "Specify route target list\n"
9623 "Flow-spec redirect type route target\n"
9624 "Import routes to this address-family\n"
9625 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9629 struct ecommunity
*ecom
= NULL
;
9631 int idx
= 0, idx_unused
= 0;
9635 if (argv_find(argv
, argc
, "no", &idx
))
9638 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9639 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9642 afi
= vpn_policy_getafi(vty
, bgp
, false);
9644 return CMD_WARNING_CONFIG_FAILED
;
9646 if (rt6
&& afi
!= AFI_IP6
)
9647 return CMD_WARNING_CONFIG_FAILED
;
9650 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9651 vty_out(vty
, "%% Missing RTLIST\n");
9652 return CMD_WARNING_CONFIG_FAILED
;
9654 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9655 if (ret
!= CMD_SUCCESS
)
9660 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9661 ecommunity_free(&bgp
->vpn_policy
[afi
]
9662 .import_redirect_rtlist
);
9663 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9664 ecommunity_dup(ecom
);
9666 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9667 ecommunity_free(&bgp
->vpn_policy
[afi
]
9668 .import_redirect_rtlist
);
9669 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9673 ecommunity_free(&ecom
);
9678 DEFUN_NOSH (address_family_ipv4_safi
,
9679 address_family_ipv4_safi_cmd
,
9680 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9681 "Enter Address Family command mode\n"
9683 BGP_SAFI_WITH_LABEL_HELP_STR
)
9687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9688 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9689 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9690 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9691 && safi
!= SAFI_EVPN
) {
9693 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9694 return CMD_WARNING_CONFIG_FAILED
;
9696 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9698 vty
->node
= BGP_IPV4_NODE
;
9703 DEFUN_NOSH (address_family_ipv6_safi
,
9704 address_family_ipv6_safi_cmd
,
9705 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9706 "Enter Address Family command mode\n"
9708 BGP_SAFI_WITH_LABEL_HELP_STR
)
9711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9712 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9713 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9714 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9715 && safi
!= SAFI_EVPN
) {
9717 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9718 return CMD_WARNING_CONFIG_FAILED
;
9720 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9722 vty
->node
= BGP_IPV6_NODE
;
9727 #ifdef KEEP_OLD_VPN_COMMANDS
9728 DEFUN_NOSH (address_family_vpnv4
,
9729 address_family_vpnv4_cmd
,
9730 "address-family vpnv4 [unicast]",
9731 "Enter Address Family command mode\n"
9733 BGP_AF_MODIFIER_STR
)
9735 vty
->node
= BGP_VPNV4_NODE
;
9739 DEFUN_NOSH (address_family_vpnv6
,
9740 address_family_vpnv6_cmd
,
9741 "address-family vpnv6 [unicast]",
9742 "Enter Address Family command mode\n"
9744 BGP_AF_MODIFIER_STR
)
9746 vty
->node
= BGP_VPNV6_NODE
;
9749 #endif /* KEEP_OLD_VPN_COMMANDS */
9751 DEFUN_NOSH (address_family_evpn
,
9752 address_family_evpn_cmd
,
9753 "address-family l2vpn evpn",
9754 "Enter Address Family command mode\n"
9756 BGP_AF_MODIFIER_STR
)
9758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9759 vty
->node
= BGP_EVPN_NODE
;
9763 DEFUN_NOSH (bgp_segment_routing_srv6
,
9764 bgp_segment_routing_srv6_cmd
,
9765 "segment-routing srv6",
9766 "Segment-Routing configuration\n"
9767 "Segment-Routing SRv6 configuration\n")
9769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9770 bgp
->srv6_enabled
= true;
9771 vty
->node
= BGP_SRV6_NODE
;
9775 DEFUN (no_bgp_segment_routing_srv6
,
9776 no_bgp_segment_routing_srv6_cmd
,
9777 "no segment-routing srv6",
9779 "Segment-Routing configuration\n"
9780 "Segment-Routing SRv6 configuration\n")
9782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9784 if (strlen(bgp
->srv6_locator_name
) > 0)
9785 if (bgp_srv6_locator_unset(bgp
) < 0)
9786 return CMD_WARNING_CONFIG_FAILED
;
9788 bgp
->srv6_enabled
= false;
9792 DEFPY (bgp_srv6_locator
,
9793 bgp_srv6_locator_cmd
,
9794 "locator NAME$name",
9795 "Specify SRv6 locator\n"
9796 "Specify SRv6 locator\n")
9798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9801 if (strlen(bgp
->srv6_locator_name
) > 0
9802 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9803 vty_out(vty
, "srv6 locator is already configured\n");
9804 return CMD_WARNING_CONFIG_FAILED
;
9807 snprintf(bgp
->srv6_locator_name
,
9808 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9810 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9812 return CMD_WARNING_CONFIG_FAILED
;
9817 DEFPY (no_bgp_srv6_locator
,
9818 no_bgp_srv6_locator_cmd
,
9819 "no locator NAME$name",
9821 "Specify SRv6 locator\n"
9822 "Specify SRv6 locator\n")
9824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9826 /* when locator isn't configured, do nothing */
9827 if (strlen(bgp
->srv6_locator_name
) < 1)
9830 /* name validation */
9831 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9832 vty_out(vty
, "%% No srv6 locator is configured\n");
9833 return CMD_WARNING_CONFIG_FAILED
;
9837 if (bgp_srv6_locator_unset(bgp
) < 0)
9838 return CMD_WARNING_CONFIG_FAILED
;
9843 DEFPY (show_bgp_srv6
,
9845 "show bgp segment-routing srv6",
9848 "BGP Segment Routing\n"
9849 "BGP Segment Routing SRv6\n")
9852 struct listnode
*node
;
9853 struct srv6_locator_chunk
*chunk
;
9854 struct bgp_srv6_function
*func
;
9857 bgp
= bgp_get_default();
9861 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9862 vty_out(vty
, "locator_chunks:\n");
9863 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9864 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9865 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9866 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9867 vty_out(vty
, " func-length: %d\n",
9868 chunk
->function_bits_length
);
9869 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9872 vty_out(vty
, "functions:\n");
9873 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9874 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9875 vty_out(vty
, "- sid: %s\n", buf
);
9876 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9879 vty_out(vty
, "bgps:\n");
9880 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9881 vty_out(vty
, "- name: %s\n",
9882 bgp
->name
? bgp
->name
: "default");
9884 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9885 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9886 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9887 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9888 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9894 DEFUN_NOSH (exit_address_family
,
9895 exit_address_family_cmd
,
9896 "exit-address-family",
9897 "Exit from Address Family configuration mode\n")
9899 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9900 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9901 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9902 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9903 || vty
->node
== BGP_EVPN_NODE
9904 || vty
->node
== BGP_FLOWSPECV4_NODE
9905 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9906 vty
->node
= BGP_NODE
;
9910 /* Recalculate bestpath and re-advertise a prefix */
9911 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9912 const char *ip_str
, afi_t afi
, safi_t safi
,
9913 struct prefix_rd
*prd
)
9916 struct prefix match
;
9917 struct bgp_dest
*dest
;
9918 struct bgp_dest
*rm
;
9920 struct bgp_table
*table
;
9921 struct bgp_table
*rib
;
9923 /* BGP structure lookup. */
9925 bgp
= bgp_lookup_by_name(view_name
);
9927 vty_out(vty
, "%% Can't find BGP instance %s\n",
9932 bgp
= bgp_get_default();
9934 vty_out(vty
, "%% No BGP process is configured\n");
9939 /* Check IP address argument. */
9940 ret
= str2prefix(ip_str
, &match
);
9942 vty_out(vty
, "%% address is malformed\n");
9946 match
.family
= afi2family(afi
);
9947 rib
= bgp
->rib
[afi
][safi
];
9949 if (safi
== SAFI_MPLS_VPN
) {
9950 for (dest
= bgp_table_top(rib
); dest
;
9951 dest
= bgp_route_next(dest
)) {
9952 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9954 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9957 table
= bgp_dest_get_bgp_table_info(dest
);
9961 rm
= bgp_node_match(table
, &match
);
9963 const struct prefix
*rm_p
=
9964 bgp_dest_get_prefix(rm
);
9966 if (rm_p
->prefixlen
== match
.prefixlen
) {
9968 BGP_NODE_USER_CLEAR
);
9969 bgp_process(bgp
, rm
, afi
, safi
);
9971 bgp_dest_unlock_node(rm
);
9975 dest
= bgp_node_match(rib
, &match
);
9977 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9979 if (dest_p
->prefixlen
== match
.prefixlen
) {
9980 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9981 bgp_process(bgp
, dest
, afi
, safi
);
9983 bgp_dest_unlock_node(dest
);
9990 /* one clear bgp command to rule them all */
9991 DEFUN (clear_ip_bgp_all
,
9992 clear_ip_bgp_all_cmd
,
9993 "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>]",
9997 BGP_INSTANCE_HELP_STR
10000 BGP_SAFI_WITH_LABEL_HELP_STR
10001 BGP_AF_MODIFIER_STR
10002 "Clear all peers\n"
10003 "BGP IPv4 neighbor to clear\n"
10004 "BGP IPv6 neighbor to clear\n"
10005 "BGP neighbor on interface to clear\n"
10006 "Clear peers with the AS number\n"
10007 "Clear all external peers\n"
10008 "Clear all members of peer-group\n"
10009 "BGP peer-group name\n"
10014 "Push out prefix-list ORF and do inbound soft reconfig\n"
10016 "Reset message statistics\n")
10020 afi_t afi
= AFI_UNSPEC
;
10021 safi_t safi
= SAFI_UNSPEC
;
10022 enum clear_sort clr_sort
= clear_peer
;
10023 enum bgp_clear_type clr_type
;
10024 char *clr_arg
= NULL
;
10028 /* clear [ip] bgp */
10029 if (argv_find(argv
, argc
, "ip", &idx
))
10032 /* [<vrf> VIEWVRFNAME] */
10033 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10034 vrf
= argv
[idx
+ 1]->arg
;
10036 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10038 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10039 /* [<view> VIEWVRFNAME] */
10040 vrf
= argv
[idx
+ 1]->arg
;
10043 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10044 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10045 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10047 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10048 if (argv_find(argv
, argc
, "*", &idx
)) {
10049 clr_sort
= clear_all
;
10050 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10051 clr_sort
= clear_peer
;
10052 clr_arg
= argv
[idx
]->arg
;
10053 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10054 clr_sort
= clear_peer
;
10055 clr_arg
= argv
[idx
]->arg
;
10056 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10057 clr_sort
= clear_group
;
10059 clr_arg
= argv
[idx
]->arg
;
10060 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10061 clr_sort
= clear_peer
;
10062 clr_arg
= argv
[idx
]->arg
;
10063 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10064 clr_sort
= clear_peer
;
10065 clr_arg
= argv
[idx
]->arg
;
10066 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10067 clr_sort
= clear_as
;
10068 clr_arg
= argv
[idx
]->arg
;
10069 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10070 clr_sort
= clear_external
;
10073 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10074 if (argv_find(argv
, argc
, "soft", &idx
)) {
10075 if (argv_find(argv
, argc
, "in", &idx
)
10076 || argv_find(argv
, argc
, "out", &idx
))
10077 clr_type
= strmatch(argv
[idx
]->text
, "in")
10078 ? BGP_CLEAR_SOFT_IN
10079 : BGP_CLEAR_SOFT_OUT
;
10081 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10082 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10083 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10084 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10085 : BGP_CLEAR_SOFT_IN
;
10086 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10087 clr_type
= BGP_CLEAR_SOFT_OUT
;
10088 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10089 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10091 clr_type
= BGP_CLEAR_SOFT_NONE
;
10093 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10096 DEFUN (clear_ip_bgp_prefix
,
10097 clear_ip_bgp_prefix_cmd
,
10098 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10102 BGP_INSTANCE_HELP_STR
10103 "Clear bestpath and re-advertise\n"
10107 char *prefix
= NULL
;
10111 /* [<view|vrf> VIEWVRFNAME] */
10112 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10113 vrf
= argv
[idx
+ 1]->arg
;
10115 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10117 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10118 /* [<view> VIEWVRFNAME] */
10119 vrf
= argv
[idx
+ 1]->arg
;
10123 prefix
= argv
[argc
- 1]->arg
;
10125 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10128 DEFUN (clear_bgp_ipv6_safi_prefix
,
10129 clear_bgp_ipv6_safi_prefix_cmd
,
10130 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10136 "Clear bestpath and re-advertise\n"
10140 int idx_ipv6_prefix
= 0;
10141 safi_t safi
= SAFI_UNICAST
;
10142 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10143 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10145 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10146 return bgp_clear_prefix(
10147 vty
, NULL
, prefix
, AFI_IP6
,
10151 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10152 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10153 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10157 BGP_INSTANCE_HELP_STR
10160 "Clear bestpath and re-advertise\n"
10164 int idx_vrfview
= 0;
10165 int idx_ipv6_prefix
= 0;
10166 safi_t safi
= SAFI_UNICAST
;
10167 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10168 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10169 char *vrfview
= NULL
;
10171 /* [<view|vrf> VIEWVRFNAME] */
10172 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10173 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10174 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10176 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10177 /* [<view> VIEWVRFNAME] */
10178 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10180 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10182 return bgp_clear_prefix(
10183 vty
, vrfview
, prefix
,
10184 AFI_IP6
, safi
, NULL
);
10187 DEFUN (show_bgp_views
,
10188 show_bgp_views_cmd
,
10189 "show [ip] bgp views",
10193 "Show the defined BGP views\n")
10195 struct list
*inst
= bm
->bgp
;
10196 struct listnode
*node
;
10199 vty_out(vty
, "Defined BGP views:\n");
10200 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10202 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10204 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10208 return CMD_SUCCESS
;
10211 DEFUN (show_bgp_vrfs
,
10213 "show [ip] bgp vrfs [json]",
10220 char buf
[ETHER_ADDR_STRLEN
];
10221 struct list
*inst
= bm
->bgp
;
10222 struct listnode
*node
;
10224 bool uj
= use_json(argc
, argv
);
10225 json_object
*json
= NULL
;
10226 json_object
*json_vrfs
= NULL
;
10230 json
= json_object_new_object();
10231 json_vrfs
= json_object_new_object();
10234 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10235 const char *name
, *type
;
10237 struct listnode
*node2
, *nnode2
;
10238 int peers_cfg
, peers_estb
;
10239 json_object
*json_vrf
= NULL
;
10242 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10246 if (!uj
&& count
== 1) {
10248 "%4s %-5s %-16s %9s %10s %-37s\n",
10249 "Type", "Id", "routerId", "#PeersCfg",
10250 "#PeersEstb", "Name");
10251 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10252 "L3-VNI", "RouterMAC", "Interface");
10255 peers_cfg
= peers_estb
= 0;
10257 json_vrf
= json_object_new_object();
10260 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10261 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10264 if (peer_established(peer
))
10268 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10269 name
= VRF_DEFAULT_NAME
;
10278 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10280 : (int64_t)bgp
->vrf_id
;
10281 char buf
[BUFSIZ
] = {0};
10283 json_object_string_add(json_vrf
, "type", type
);
10284 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10285 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10287 json_object_int_add(json_vrf
, "numConfiguredPeers",
10289 json_object_int_add(json_vrf
, "numEstablishedPeers",
10292 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10293 json_object_string_add(
10295 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10296 json_object_string_add(json_vrf
, "interface",
10297 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10299 json_object_object_add(json_vrfs
, name
, json_vrf
);
10301 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10303 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10304 : (int)bgp
->vrf_id
,
10305 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10306 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10308 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10309 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10315 json_object_object_add(json
, "vrfs", json_vrfs
);
10317 json_object_int_add(json
, "totalVrfs", count
);
10319 vty_json(vty
, json
);
10323 "\nTotal number of VRFs (including default): %d\n",
10327 return CMD_SUCCESS
;
10330 DEFUN (show_bgp_mac_hash
,
10331 show_bgp_mac_hash_cmd
,
10332 "show bgp mac hash",
10336 "Mac Address database\n")
10338 bgp_mac_dump_table(vty
);
10340 return CMD_SUCCESS
;
10343 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10345 struct vty
*vty
= (struct vty
*)args
;
10346 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10348 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10351 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10353 vty_out(vty
, "self nexthop database:\n");
10354 bgp_nexthop_show_address_hash(vty
, bgp
);
10356 vty_out(vty
, "Tunnel-ip database:\n");
10357 hash_iterate(bgp
->tip_hash
,
10358 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10362 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10363 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10364 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10365 "martian next-hops\n"
10366 "martian next-hop database\n")
10368 struct bgp
*bgp
= NULL
;
10372 /* [<vrf> VIEWVRFNAME] */
10373 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10374 name
= argv
[idx
+ 1]->arg
;
10375 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10377 } else if (argv_find(argv
, argc
, "view", &idx
))
10378 /* [<view> VIEWVRFNAME] */
10379 name
= argv
[idx
+ 1]->arg
;
10381 bgp
= bgp_lookup_by_name(name
);
10383 bgp
= bgp_get_default();
10386 vty_out(vty
, "%% No BGP process is configured\n");
10387 return CMD_WARNING
;
10389 bgp_show_martian_nexthops(vty
, bgp
);
10391 return CMD_SUCCESS
;
10394 DEFUN (show_bgp_memory
,
10395 show_bgp_memory_cmd
,
10396 "show [ip] bgp memory",
10400 "Global BGP memory statistics\n")
10402 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10403 unsigned long count
;
10405 /* RIB related usage stats */
10406 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10407 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10408 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10409 count
* sizeof(struct bgp_dest
)));
10411 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10412 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10413 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10414 count
* sizeof(struct bgp_path_info
)));
10415 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10416 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10419 memstrbuf
, sizeof(memstrbuf
),
10420 count
* sizeof(struct bgp_path_info_extra
)));
10422 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10423 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10424 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10425 count
* sizeof(struct bgp_static
)));
10427 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10428 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10429 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10430 count
* sizeof(struct bpacket
)));
10433 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10434 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10435 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10436 count
* sizeof(struct bgp_adj_in
)));
10437 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10438 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10439 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10440 count
* sizeof(struct bgp_adj_out
)));
10442 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10443 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10445 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10446 count
* sizeof(struct bgp_nexthop_cache
)));
10448 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10449 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10451 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10452 count
* sizeof(struct bgp_damp_info
)));
10455 count
= attr_count();
10456 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10457 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10458 count
* sizeof(struct attr
)));
10460 if ((count
= attr_unknown_count()))
10461 vty_out(vty
, "%ld unknown attributes\n", count
);
10463 /* AS_PATH attributes */
10464 count
= aspath_count();
10465 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10466 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10467 count
* sizeof(struct aspath
)));
10469 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10470 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10471 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10472 count
* sizeof(struct assegment
)));
10474 /* Other attributes */
10475 if ((count
= community_count()))
10476 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10477 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10478 count
* sizeof(struct community
)));
10479 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10481 "%ld BGP ext-community entries, using %s of memory\n",
10483 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10484 count
* sizeof(struct ecommunity
)));
10485 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10487 "%ld BGP large-community entries, using %s of memory\n",
10488 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10489 count
* sizeof(struct lcommunity
)));
10491 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10492 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10493 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10494 count
* sizeof(struct cluster_list
)));
10496 /* Peer related usage */
10497 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10498 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10499 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10500 count
* sizeof(struct peer
)));
10502 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10503 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10504 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10505 count
* sizeof(struct peer_group
)));
10508 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10509 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10510 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10511 count
* sizeof(regex_t
)));
10512 return CMD_SUCCESS
;
10515 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10517 json_object
*bestpath
= json_object_new_object();
10519 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10520 json_object_string_add(bestpath
, "asPath", "ignore");
10522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10523 json_object_string_add(bestpath
, "asPath", "confed");
10525 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10526 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10527 json_object_string_add(bestpath
, "multiPathRelax",
10530 json_object_string_add(bestpath
, "multiPathRelax",
10533 json_object_string_add(bestpath
, "multiPathRelax", "false");
10535 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10536 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10538 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10539 json_object_string_add(bestpath
, "compareRouterId", "true");
10540 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10541 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10542 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10543 json_object_string_add(bestpath
, "med", "confed");
10544 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10545 json_object_string_add(bestpath
, "med",
10546 "missing-as-worst");
10548 json_object_string_add(bestpath
, "med", "true");
10551 json_object_object_add(json
, "bestPath", bestpath
);
10554 /* Print the error code/subcode for why the peer is down */
10555 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10556 json_object
*json_peer
, bool use_json
)
10558 const char *code_str
;
10559 const char *subcode_str
;
10562 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10563 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10564 char errorcodesubcode_hexstr
[5];
10565 char errorcodesubcode_str
[256];
10567 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10568 subcode_str
= bgp_notify_subcode_str(
10570 peer
->notify
.subcode
);
10572 snprintf(errorcodesubcode_hexstr
,
10573 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10574 peer
->notify
.code
, peer
->notify
.subcode
);
10575 json_object_string_add(json_peer
,
10576 "lastErrorCodeSubcode",
10577 errorcodesubcode_hexstr
);
10578 snprintf(errorcodesubcode_str
, 255, "%s%s",
10579 code_str
, subcode_str
);
10580 json_object_string_add(json_peer
,
10581 "lastNotificationReason",
10582 errorcodesubcode_str
);
10583 json_object_boolean_add(json_peer
,
10584 "lastNotificationHardReset",
10585 peer
->notify
.hard_reset
);
10586 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10587 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10588 && (peer
->notify
.subcode
10589 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10590 || peer
->notify
.subcode
10591 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10592 && peer
->notify
.length
) {
10594 const char *msg_str
;
10596 msg_str
= bgp_notify_admin_message(
10597 msgbuf
, sizeof(msgbuf
),
10598 (uint8_t *)peer
->notify
.data
,
10599 peer
->notify
.length
);
10601 json_object_string_add(
10603 "lastShutdownDescription",
10608 json_object_string_add(json_peer
, "lastResetDueTo",
10609 peer_down_str
[(int)peer
->last_reset
]);
10610 json_object_int_add(json_peer
, "lastResetCode",
10613 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10614 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10615 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10617 bgp_notify_subcode_str(peer
->notify
.code
,
10618 peer
->notify
.subcode
);
10619 vty_out(vty
, " Notification %s (%s%s%s)\n",
10620 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10623 code_str
, subcode_str
,
10624 peer
->notify
.hard_reset
10625 ? bgp_notify_subcode_str(
10627 BGP_NOTIFY_CEASE_HARD_RESET
)
10630 vty_out(vty
, " %s\n",
10631 peer_down_str
[(int)peer
->last_reset
]);
10636 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10639 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10642 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10643 struct peer
*peer
, json_object
*json_peer
,
10644 int max_neighbor_width
, bool use_json
)
10646 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10650 if (peer_dynamic_neighbor(peer
))
10651 json_object_boolean_true_add(json_peer
,
10653 if (peer
->hostname
)
10654 json_object_string_add(json_peer
, "hostname",
10657 if (peer
->domainname
)
10658 json_object_string_add(json_peer
, "domainname",
10660 json_object_int_add(json_peer
, "connectionsEstablished",
10661 peer
->established
);
10662 json_object_int_add(json_peer
, "connectionsDropped",
10664 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10665 use_json
, json_peer
);
10666 if (peer_established(peer
))
10667 json_object_string_add(json_peer
, "lastResetDueTo",
10668 "AFI/SAFI Not Negotiated");
10670 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10673 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10675 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10676 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10677 peer
->hostname
, peer
->host
);
10679 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10681 /* pad the neighbor column with spaces */
10682 if (len
< max_neighbor_width
)
10683 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10685 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10687 peer_uptime(peer
->uptime
, timebuf
,
10688 BGP_UPTIME_LEN
, 0, NULL
));
10689 if (peer_established(peer
))
10690 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10692 bgp_show_peer_reset(vty
, peer
, NULL
,
10697 /* Strip peer's description to the given size. */
10698 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10700 static char stripped
[BUFSIZ
];
10702 uint32_t last_space
= 0;
10705 if (*(desc
+ i
) == 0) {
10706 stripped
[i
] = '\0';
10709 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10711 stripped
[i
] = *(desc
+ i
);
10715 if (last_space
> size
)
10716 stripped
[size
+ 1] = '\0';
10718 stripped
[last_space
] = '\0';
10723 /* Determine whether var peer should be filtered out of the summary. */
10724 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10725 struct peer
*fpeer
, int as_type
,
10729 /* filter neighbor XXXX */
10730 if (fpeer
&& fpeer
!= peer
)
10733 /* filter remote-as (internal|external) */
10734 if (as_type
!= AS_UNSPECIFIED
) {
10735 if (peer
->as_type
== AS_SPECIFIED
) {
10736 if (as_type
== AS_INTERNAL
) {
10737 if (peer
->as
!= peer
->local_as
)
10739 } else if (peer
->as
== peer
->local_as
)
10741 } else if (as_type
!= peer
->as_type
)
10743 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10749 /* Show BGP peer's summary information.
10751 * Peer's description is stripped according to if `wide` option is given
10754 * When adding new columns to `show bgp summary` output, please make
10755 * sure `Desc` is the lastest column to show because it can contain
10756 * whitespaces and the whole output will be tricky.
10758 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10759 struct peer
*fpeer
, int as_type
, as_t as
,
10760 uint16_t show_flags
)
10763 struct listnode
*node
, *nnode
;
10764 unsigned int count
= 0, dn_count
= 0;
10765 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10766 char neighbor_buf
[VTY_BUFSIZ
];
10767 int neighbor_col_default_width
= 16;
10768 int len
, failed_count
= 0;
10769 unsigned int filtered_count
= 0;
10770 int max_neighbor_width
= 0;
10772 json_object
*json
= NULL
;
10773 json_object
*json_peer
= NULL
;
10774 json_object
*json_peers
= NULL
;
10775 struct peer_af
*paf
;
10776 struct bgp_filter
*filter
;
10777 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10778 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10779 bool show_established
=
10780 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10781 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10782 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10784 /* labeled-unicast routes are installed in the unicast table so in order
10786 * display the correct PfxRcd value we must look at SAFI_UNICAST
10789 if (safi
== SAFI_LABELED_UNICAST
)
10790 pfx_rcd_safi
= SAFI_UNICAST
;
10792 pfx_rcd_safi
= safi
;
10795 json
= json_object_new_object();
10796 json_peers
= json_object_new_object();
10797 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10798 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10805 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10808 if (peer
->afc
[afi
][safi
]) {
10809 /* See if we have at least a single failed peer */
10810 if (bgp_has_peer_failed(peer
, afi
, safi
))
10814 if (peer_dynamic_neighbor(peer
))
10819 /* Loop over all neighbors that will be displayed to determine
10821 * characters are needed for the Neighbor column
10823 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10824 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10831 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10834 if (peer
->afc
[afi
][safi
]) {
10835 memset(dn_flag
, '\0', sizeof(dn_flag
));
10836 if (peer_dynamic_neighbor(peer
))
10840 && CHECK_FLAG(bgp
->flags
,
10841 BGP_FLAG_SHOW_HOSTNAME
))
10842 snprintf(neighbor_buf
,
10843 sizeof(neighbor_buf
),
10844 "%s%s(%s) ", dn_flag
,
10845 peer
->hostname
, peer
->host
);
10847 snprintf(neighbor_buf
,
10848 sizeof(neighbor_buf
), "%s%s ",
10849 dn_flag
, peer
->host
);
10851 len
= strlen(neighbor_buf
);
10853 if (len
> max_neighbor_width
)
10854 max_neighbor_width
= len
;
10856 /* See if we have at least a single failed peer */
10857 if (bgp_has_peer_failed(peer
, afi
, safi
))
10863 /* Originally we displayed the Neighbor column as 16
10864 * characters wide so make that the default
10866 if (max_neighbor_width
< neighbor_col_default_width
)
10867 max_neighbor_width
= neighbor_col_default_width
;
10870 if (show_failed
&& !failed_count
) {
10872 json_object_int_add(json
, "failedPeersCount", 0);
10873 json_object_int_add(json
, "dynamicPeers", dn_count
);
10874 json_object_int_add(json
, "totalPeers", count
);
10876 vty_json(vty
, json
);
10878 vty_out(vty
, "%% No failed BGP neighbors found\n");
10880 return CMD_SUCCESS
;
10883 count
= 0; /* Reset the value as its used again */
10884 filtered_count
= 0;
10886 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10887 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10890 if (!peer
->afc
[afi
][safi
])
10894 unsigned long ents
;
10895 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10898 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10900 : (int64_t)bgp
->vrf_id
;
10902 /* Usage summary and header */
10904 json_object_string_addf(json
, "routerId",
10907 json_object_int_add(json
, "as", bgp
->as
);
10908 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10909 json_object_string_add(
10912 == BGP_INSTANCE_TYPE_DEFAULT
)
10917 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10918 &bgp
->router_id
, bgp
->as
,
10919 bgp
->vrf_id
== VRF_UNKNOWN
10921 : (int)bgp
->vrf_id
);
10922 vty_out(vty
, "\n");
10925 if (bgp_update_delay_configured(bgp
)) {
10927 json_object_int_add(
10928 json
, "updateDelayLimit",
10929 bgp
->v_update_delay
);
10931 if (bgp
->v_update_delay
10932 != bgp
->v_establish_wait
)
10933 json_object_int_add(
10935 "updateDelayEstablishWait",
10936 bgp
->v_establish_wait
);
10938 if (bgp_update_delay_active(bgp
)) {
10939 json_object_string_add(
10941 "updateDelayFirstNeighbor",
10942 bgp
->update_delay_begin_time
);
10943 json_object_boolean_true_add(
10945 "updateDelayInProgress");
10947 if (bgp
->update_delay_over
) {
10948 json_object_string_add(
10950 "updateDelayFirstNeighbor",
10951 bgp
->update_delay_begin_time
);
10952 json_object_string_add(
10954 "updateDelayBestpathResumed",
10955 bgp
->update_delay_end_time
);
10956 json_object_string_add(
10958 "updateDelayZebraUpdateResume",
10959 bgp
->update_delay_zebra_resume_time
);
10960 json_object_string_add(
10962 "updateDelayPeerUpdateResume",
10963 bgp
->update_delay_peers_resume_time
);
10968 "Read-only mode update-delay limit: %d seconds\n",
10969 bgp
->v_update_delay
);
10970 if (bgp
->v_update_delay
10971 != bgp
->v_establish_wait
)
10973 " Establish wait: %d seconds\n",
10974 bgp
->v_establish_wait
);
10976 if (bgp_update_delay_active(bgp
)) {
10978 " First neighbor established: %s\n",
10979 bgp
->update_delay_begin_time
);
10981 " Delay in progress\n");
10983 if (bgp
->update_delay_over
) {
10985 " First neighbor established: %s\n",
10986 bgp
->update_delay_begin_time
);
10988 " Best-paths resumed: %s\n",
10989 bgp
->update_delay_end_time
);
10991 " zebra update resumed: %s\n",
10992 bgp
->update_delay_zebra_resume_time
);
10994 " peers update resumed: %s\n",
10995 bgp
->update_delay_peers_resume_time
);
11002 if (bgp_maxmed_onstartup_configured(bgp
)
11003 && bgp
->maxmed_active
)
11004 json_object_boolean_true_add(
11005 json
, "maxMedOnStartup");
11006 if (bgp
->v_maxmed_admin
)
11007 json_object_boolean_true_add(
11008 json
, "maxMedAdministrative");
11010 json_object_int_add(
11011 json
, "tableVersion",
11012 bgp_table_version(bgp
->rib
[afi
][safi
]));
11014 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11015 json_object_int_add(json
, "ribCount", ents
);
11016 json_object_int_add(
11018 ents
* sizeof(struct bgp_dest
));
11020 ents
= bgp
->af_peer_count
[afi
][safi
];
11021 json_object_int_add(json
, "peerCount", ents
);
11022 json_object_int_add(json
, "peerMemory",
11023 ents
* sizeof(struct peer
));
11025 if ((ents
= listcount(bgp
->group
))) {
11026 json_object_int_add(
11027 json
, "peerGroupCount", ents
);
11028 json_object_int_add(
11029 json
, "peerGroupMemory",
11030 ents
* sizeof(struct
11034 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11035 BGP_CONFIG_DAMPENING
))
11036 json_object_boolean_true_add(
11037 json
, "dampeningEnabled");
11040 if (bgp_maxmed_onstartup_configured(bgp
)
11041 && bgp
->maxmed_active
)
11043 "Max-med on-startup active\n");
11044 if (bgp
->v_maxmed_admin
)
11046 "Max-med administrative active\n");
11049 "BGP table version %" PRIu64
11052 bgp
->rib
[afi
][safi
]));
11054 ents
= bgp_table_count(
11055 bgp
->rib
[afi
][safi
]);
11057 "RIB entries %ld, using %s of memory\n",
11067 /* Peer related usage */
11068 ents
= bgp
->af_peer_count
[afi
][safi
];
11070 "Peers %ld, using %s of memory\n",
11080 if ((ents
= listcount(bgp
->group
)))
11082 "Peer groups %ld, using %s of memory\n",
11092 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11093 BGP_CONFIG_DAMPENING
))
11095 "Dampening enabled.\n");
11098 vty_out(vty
, "\n");
11100 /* Subtract 8 here because 'Neighbor' is
11102 vty_out(vty
, "Neighbor");
11103 vty_out(vty
, "%*s",
11104 max_neighbor_width
- 8, " ");
11106 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11111 paf
= peer_af_find(peer
, afi
, safi
);
11112 filter
= &peer
->filter
[afi
][safi
];
11115 /* Works for both failed & successful cases */
11116 if (peer_dynamic_neighbor(peer
))
11121 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11127 bgp_has_peer_failed(peer
, afi
, safi
)) {
11128 json_peer
= json_object_new_object();
11129 bgp_show_failed_summary(vty
, bgp
, peer
,
11130 json_peer
, 0, use_json
);
11131 } else if (!show_failed
) {
11132 if (show_established
11133 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11138 json_peer
= json_object_new_object();
11139 if (peer_dynamic_neighbor(peer
)) {
11140 json_object_boolean_true_add(json_peer
,
11144 if (peer
->hostname
)
11145 json_object_string_add(json_peer
, "hostname",
11148 if (peer
->domainname
)
11149 json_object_string_add(json_peer
, "domainname",
11152 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11153 json_object_int_add(
11154 json_peer
, "localAs",
11155 peer
->change_local_as
11156 ? peer
->change_local_as
11158 json_object_int_add(json_peer
, "version", 4);
11159 json_object_int_add(json_peer
, "msgRcvd",
11160 PEER_TOTAL_RX(peer
));
11161 json_object_int_add(json_peer
, "msgSent",
11162 PEER_TOTAL_TX(peer
));
11164 atomic_size_t outq_count
, inq_count
;
11165 outq_count
= atomic_load_explicit(
11166 &peer
->obuf
->count
,
11167 memory_order_relaxed
);
11168 inq_count
= atomic_load_explicit(
11169 &peer
->ibuf
->count
,
11170 memory_order_relaxed
);
11172 json_object_int_add(json_peer
, "tableVersion",
11173 peer
->version
[afi
][safi
]);
11174 json_object_int_add(json_peer
, "outq",
11176 json_object_int_add(json_peer
, "inq",
11178 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11179 use_json
, json_peer
);
11181 json_object_int_add(json_peer
, "pfxRcd",
11182 peer
->pcount
[afi
][pfx_rcd_safi
]);
11184 if (paf
&& PAF_SUBGRP(paf
))
11185 json_object_int_add(
11186 json_peer
, "pfxSnt",
11187 (PAF_SUBGRP(paf
))->scount
);
11189 json_object_int_add(json_peer
, "pfxSnt",
11192 /* BGP FSM state */
11193 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11194 || CHECK_FLAG(peer
->bgp
->flags
,
11195 BGP_FLAG_SHUTDOWN
))
11196 json_object_string_add(json_peer
,
11199 else if (peer
->afc_recv
[afi
][safi
])
11200 json_object_string_add(
11201 json_peer
, "state",
11202 lookup_msg(bgp_status_msg
,
11203 peer
->status
, NULL
));
11204 else if (CHECK_FLAG(
11206 PEER_STATUS_PREFIX_OVERFLOW
))
11207 json_object_string_add(json_peer
,
11211 json_object_string_add(
11212 json_peer
, "state",
11213 lookup_msg(bgp_status_msg
,
11214 peer
->status
, NULL
));
11216 /* BGP peer state */
11217 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11218 || CHECK_FLAG(peer
->bgp
->flags
,
11219 BGP_FLAG_SHUTDOWN
))
11220 json_object_string_add(json_peer
,
11223 else if (CHECK_FLAG(
11225 PEER_STATUS_PREFIX_OVERFLOW
))
11226 json_object_string_add(json_peer
,
11229 else if (CHECK_FLAG(peer
->flags
,
11230 PEER_FLAG_PASSIVE
))
11231 json_object_string_add(json_peer
,
11234 else if (CHECK_FLAG(peer
->sflags
,
11235 PEER_STATUS_NSF_WAIT
))
11236 json_object_string_add(json_peer
,
11239 else if (CHECK_FLAG(
11241 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11242 && (!bgp_inbound_policy_exists(peer
,
11244 || !bgp_outbound_policy_exists(
11246 json_object_string_add(json_peer
,
11250 json_object_string_add(
11251 json_peer
, "peerState", "OK");
11253 json_object_int_add(json_peer
, "connectionsEstablished",
11254 peer
->established
);
11255 json_object_int_add(json_peer
, "connectionsDropped",
11258 json_object_string_add(
11259 json_peer
, "desc", peer
->desc
);
11261 /* Avoid creating empty peer dicts in JSON */
11262 if (json_peer
== NULL
)
11266 json_object_string_add(json_peer
, "idType",
11268 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11269 json_object_string_add(json_peer
, "idType",
11271 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11272 json_object_string_add(json_peer
, "idType",
11274 json_object_object_add(json_peers
, peer
->host
,
11277 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11283 bgp_has_peer_failed(peer
, afi
, safi
)) {
11284 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11285 max_neighbor_width
,
11287 } else if (!show_failed
) {
11288 if (show_established
11289 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11294 if ((count
- filtered_count
) == 1) {
11295 /* display headline before the first
11297 vty_out(vty
, "\n");
11299 /* Subtract 8 here because 'Neighbor' is
11301 vty_out(vty
, "Neighbor");
11302 vty_out(vty
, "%*s",
11303 max_neighbor_width
- 8, " ");
11306 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11307 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11310 memset(dn_flag
, '\0', sizeof(dn_flag
));
11311 if (peer_dynamic_neighbor(peer
)) {
11316 && CHECK_FLAG(bgp
->flags
,
11317 BGP_FLAG_SHOW_HOSTNAME
))
11318 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11322 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11324 /* pad the neighbor column with spaces */
11325 if (len
< max_neighbor_width
)
11326 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11329 atomic_size_t outq_count
, inq_count
;
11330 outq_count
= atomic_load_explicit(
11331 &peer
->obuf
->count
,
11332 memory_order_relaxed
);
11333 inq_count
= atomic_load_explicit(
11334 &peer
->ibuf
->count
,
11335 memory_order_relaxed
);
11339 "4 %10u %10u %9u %9u %8" PRIu64
11342 peer
->change_local_as
11343 ? peer
->change_local_as
11345 PEER_TOTAL_RX(peer
),
11346 PEER_TOTAL_TX(peer
),
11347 peer
->version
[afi
][safi
],
11348 inq_count
, outq_count
,
11349 peer_uptime(peer
->uptime
,
11354 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11356 peer
->as
, PEER_TOTAL_RX(peer
),
11357 PEER_TOTAL_TX(peer
),
11358 peer
->version
[afi
][safi
],
11359 inq_count
, outq_count
,
11360 peer_uptime(peer
->uptime
,
11365 if (peer_established(peer
)) {
11366 if (peer
->afc_recv
[afi
][safi
]) {
11369 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11370 && !bgp_inbound_policy_exists(
11372 vty_out(vty
, " %12s",
11381 vty_out(vty
, " NoNeg");
11384 if (paf
&& PAF_SUBGRP(paf
)) {
11387 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11388 && !bgp_outbound_policy_exists(
11390 vty_out(vty
, " %8s",
11399 vty_out(vty
, " NoNeg");
11402 if (CHECK_FLAG(peer
->flags
,
11403 PEER_FLAG_SHUTDOWN
)
11404 || CHECK_FLAG(peer
->bgp
->flags
,
11405 BGP_FLAG_SHUTDOWN
))
11406 vty_out(vty
, " Idle (Admin)");
11407 else if (CHECK_FLAG(
11409 PEER_STATUS_PREFIX_OVERFLOW
))
11410 vty_out(vty
, " Idle (PfxCt)");
11412 vty_out(vty
, " %12s",
11413 lookup_msg(bgp_status_msg
,
11414 peer
->status
, NULL
));
11416 vty_out(vty
, " %8u", 0);
11418 /* Make sure `Desc` column is the lastest in
11422 vty_out(vty
, " %s",
11423 bgp_peer_description_stripped(
11425 show_wide
? 64 : 20));
11427 vty_out(vty
, " N/A");
11428 vty_out(vty
, "\n");
11435 json_object_object_add(json
, "peers", json_peers
);
11436 json_object_int_add(json
, "failedPeers", failed_count
);
11437 json_object_int_add(json
, "displayedPeers",
11438 count
- filtered_count
);
11439 json_object_int_add(json
, "totalPeers", count
);
11440 json_object_int_add(json
, "dynamicPeers", dn_count
);
11443 bgp_show_bestpath_json(bgp
, json
);
11445 vty_json(vty
, json
);
11448 if (filtered_count
== count
)
11449 vty_out(vty
, "\n%% No matching neighbor\n");
11452 vty_out(vty
, "\nDisplayed neighbors %d",
11454 else if (as_type
!= AS_UNSPECIFIED
|| as
11455 || fpeer
|| show_established
)
11456 vty_out(vty
, "\nDisplayed neighbors %d",
11457 count
- filtered_count
);
11459 vty_out(vty
, "\nTotal number of neighbors %d\n",
11463 vty_out(vty
, "No %s neighbor is configured\n",
11464 get_afi_safi_str(afi
, safi
, false));
11468 vty_out(vty
, "* - dynamic neighbor\n");
11469 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11470 dn_count
, bgp
->dynamic_neighbors_limit
);
11474 return CMD_SUCCESS
;
11477 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11478 int safi
, struct peer
*fpeer
, int as_type
,
11479 as_t as
, uint16_t show_flags
)
11482 int afi_wildcard
= (afi
== AFI_MAX
);
11483 int safi_wildcard
= (safi
== SAFI_MAX
);
11484 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11485 bool nbr_output
= false;
11486 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11488 if (use_json
&& is_wildcard
)
11489 vty_out(vty
, "{\n");
11491 afi
= 1; /* AFI_IP */
11492 while (afi
< AFI_MAX
) {
11494 safi
= 1; /* SAFI_UNICAST */
11495 while (safi
< SAFI_MAX
) {
11496 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11501 * So limit output to those afi/safi
11503 * actualy have something interesting in
11508 vty_out(vty
, ",\n");
11512 vty_out(vty
, "\"%s\":",
11513 get_afi_safi_str(afi
,
11518 "\n%s Summary (%s):\n",
11519 get_afi_safi_str(afi
,
11525 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11526 as_type
, as
, show_flags
);
11529 if (!safi_wildcard
)
11537 if (use_json
&& is_wildcard
)
11538 vty_out(vty
, "}\n");
11539 else if (!nbr_output
) {
11541 vty_out(vty
, "{}\n");
11543 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11548 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11550 const char *neighbor
,
11551 int as_type
, as_t as
,
11552 uint16_t show_flags
)
11554 struct listnode
*node
, *nnode
;
11556 struct peer
*fpeer
= NULL
;
11558 bool nbr_output
= false;
11559 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11562 vty_out(vty
, "{\n");
11564 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11568 vty_out(vty
, ",\n");
11572 vty_out(vty
, "\"%s\":",
11573 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11578 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11583 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11588 vty_out(vty
, "}\n");
11589 else if (!nbr_output
)
11590 vty_out(vty
, "%% BGP instance not found\n");
11593 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11594 safi_t safi
, const char *neighbor
, int as_type
,
11595 as_t as
, uint16_t show_flags
)
11598 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11599 struct peer
*fpeer
= NULL
;
11602 if (strmatch(name
, "all")) {
11603 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11606 return CMD_SUCCESS
;
11608 bgp
= bgp_lookup_by_name(name
);
11612 vty_out(vty
, "{}\n");
11615 "%% BGP instance not found\n");
11616 return CMD_WARNING
;
11620 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11623 return CMD_WARNING
;
11625 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11626 as_type
, as
, show_flags
);
11627 return CMD_SUCCESS
;
11631 bgp
= bgp_get_default();
11635 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11638 return CMD_WARNING
;
11640 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11644 vty_out(vty
, "{}\n");
11646 vty_out(vty
, "%% BGP instance not found\n");
11647 return CMD_WARNING
;
11650 return CMD_SUCCESS
;
11653 /* `show [ip] bgp summary' commands. */
11654 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11655 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11656 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11657 "]] [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]",
11658 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11659 BGP_SAFI_WITH_LABEL_HELP_STR
11660 "Display the entries for all address families\n"
11661 "Summary of BGP neighbor status\n"
11662 "Show only sessions in Established state\n"
11663 "Show only sessions not in Established state\n"
11664 "Show only the specified neighbor session\n"
11665 "Neighbor to display information about\n"
11666 "Neighbor to display information about\n"
11667 "Neighbor on BGP configured interface\n"
11668 "Show only the specified remote AS sessions\n"
11670 "Internal (iBGP) AS sessions\n"
11671 "External (eBGP) AS sessions\n"
11672 "Shorten the information on BGP instances\n"
11673 "Increase table width for longer output\n" JSON_STR
)
11676 afi_t afi
= AFI_MAX
;
11677 safi_t safi
= SAFI_MAX
;
11678 as_t as
= 0; /* 0 means AS filter not set */
11679 int as_type
= AS_UNSPECIFIED
;
11680 uint16_t show_flags
= 0;
11684 /* show [ip] bgp */
11685 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11687 /* [<vrf> VIEWVRFNAME] */
11688 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11689 vrf
= argv
[idx
+ 1]->arg
;
11690 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11692 } else if (argv_find(argv
, argc
, "view", &idx
))
11693 /* [<view> VIEWVRFNAME] */
11694 vrf
= argv
[idx
+ 1]->arg
;
11695 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11696 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11697 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11700 if (argv_find(argv
, argc
, "failed", &idx
))
11701 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11703 if (argv_find(argv
, argc
, "established", &idx
))
11704 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11706 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11707 if (argv
[idx
+ 1]->arg
[0] == 'i')
11708 as_type
= AS_INTERNAL
;
11709 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11710 as_type
= AS_EXTERNAL
;
11712 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11715 if (argv_find(argv
, argc
, "terse", &idx
))
11716 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11718 if (argv_find(argv
, argc
, "wide", &idx
))
11719 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11721 if (argv_find(argv
, argc
, "json", &idx
))
11722 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11724 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11728 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11731 return get_afi_safi_json_str(afi
, safi
);
11733 return get_afi_safi_vty_str(afi
, safi
);
11737 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11738 afi_t afi
, safi_t safi
,
11739 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11740 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11741 bool use_json
, json_object
*json_pref
)
11744 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11745 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11747 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11748 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11749 json_object_string_add(json_pref
, "sendMode",
11750 "advertisedAndReceived");
11751 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11752 json_object_string_add(json_pref
, "sendMode",
11754 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11755 json_object_string_add(json_pref
, "sendMode",
11758 vty_out(vty
, " Send-mode: ");
11759 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11760 vty_out(vty
, "advertised");
11761 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11762 vty_out(vty
, "%sreceived",
11763 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11767 vty_out(vty
, "\n");
11772 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11773 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11775 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11776 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11777 json_object_string_add(json_pref
, "recvMode",
11778 "advertisedAndReceived");
11779 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11780 json_object_string_add(json_pref
, "recvMode",
11782 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11783 json_object_string_add(json_pref
, "recvMode",
11786 vty_out(vty
, " Receive-mode: ");
11787 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11788 vty_out(vty
, "advertised");
11789 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11790 vty_out(vty
, "%sreceived",
11791 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11795 vty_out(vty
, "\n");
11800 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11808 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11809 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11810 && (peer_established(p
))) {
11811 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11812 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11816 json_object_boolean_add(json
, "rBit", rbit
);
11817 json_object_boolean_add(json
, "nBit", nbit
);
11819 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11820 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11824 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11829 const char *mode
= "NotApplicable";
11832 vty_out(vty
, "\n Remote GR Mode: ");
11834 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11835 && (peer_established(peer
))) {
11837 if ((peer
->nsf_af_count
== 0)
11838 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11842 } else if (peer
->nsf_af_count
== 0
11843 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11847 } else if (peer
->nsf_af_count
!= 0
11848 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11855 json_object_string_add(json
, "remoteGrMode", mode
);
11857 vty_out(vty
, mode
, "\n");
11860 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11865 const char *mode
= "Invalid";
11868 vty_out(vty
, " Local GR Mode: ");
11870 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11872 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11874 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11876 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11877 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11879 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11881 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11888 json_object_string_add(json
, "localGrMode", mode
);
11890 vty_out(vty
, mode
, "\n");
11894 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11895 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11899 json_object
*json_afi_safi
= NULL
;
11900 json_object
*json_timer
= NULL
;
11901 json_object
*json_endofrib_status
= NULL
;
11902 bool eor_flag
= false;
11904 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11905 if (!peer
->afc
[afi
][safi
])
11908 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11909 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11913 json_afi_safi
= json_object_new_object();
11914 json_endofrib_status
= json_object_new_object();
11915 json_timer
= json_object_new_object();
11918 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11924 vty_out(vty
, " %s:\n",
11925 get_afi_safi_str(afi
, safi
, false));
11927 vty_out(vty
, " F bit: ");
11930 if (peer
->nsf
[afi
][safi
] &&
11931 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11932 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11935 json_object_boolean_true_add(json_afi_safi
,
11938 vty_out(vty
, "True\n");
11941 json_object_boolean_false_add(json_afi_safi
,
11944 vty_out(vty
, "False\n");
11948 vty_out(vty
, " End-of-RIB sent: ");
11950 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11951 PEER_STATUS_EOR_SEND
)) {
11953 json_object_boolean_true_add(
11954 json_endofrib_status
, "endOfRibSend");
11956 PRINT_EOR_JSON(eor_flag
);
11958 vty_out(vty
, "Yes\n");
11960 " End-of-RIB sent after update: ");
11962 PRINT_EOR(eor_flag
);
11966 json_object_boolean_false_add(
11967 json_endofrib_status
, "endOfRibSend");
11968 json_object_boolean_false_add(
11969 json_endofrib_status
,
11970 "endOfRibSentAfterUpdate");
11972 vty_out(vty
, "No\n");
11974 " End-of-RIB sent after update: ");
11975 vty_out(vty
, "No\n");
11980 vty_out(vty
, " End-of-RIB received: ");
11982 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11983 PEER_STATUS_EOR_RECEIVED
)) {
11985 json_object_boolean_true_add(
11986 json_endofrib_status
, "endOfRibRecv");
11988 vty_out(vty
, "Yes\n");
11991 json_object_boolean_false_add(
11992 json_endofrib_status
, "endOfRibRecv");
11994 vty_out(vty
, "No\n");
11998 json_object_int_add(json_timer
, "stalePathTimer",
11999 peer
->bgp
->stalepath_time
);
12001 if (peer
->t_gr_stale
!= NULL
) {
12002 json_object_int_add(json_timer
,
12003 "stalePathTimerRemaining",
12004 thread_timer_remain_second(
12005 peer
->t_gr_stale
));
12008 /* Display Configured Selection
12009 * Deferral only when when
12010 * Gr mode is enabled.
12012 if (CHECK_FLAG(peer
->flags
,
12013 PEER_FLAG_GRACEFUL_RESTART
)) {
12014 json_object_int_add(json_timer
,
12015 "selectionDeferralTimer",
12016 peer
->bgp
->stalepath_time
);
12019 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12022 json_object_int_add(
12024 "selectionDeferralTimerRemaining",
12025 thread_timer_remain_second(
12026 peer
->bgp
->gr_info
[afi
][safi
]
12027 .t_select_deferral
));
12030 vty_out(vty
, " Timers:\n");
12032 " Configured Stale Path Time(sec): %u\n",
12033 peer
->bgp
->stalepath_time
);
12035 if (peer
->t_gr_stale
!= NULL
)
12037 " Stale Path Remaining(sec): %ld\n",
12038 thread_timer_remain_second(
12039 peer
->t_gr_stale
));
12040 /* Display Configured Selection
12041 * Deferral only when when
12042 * Gr mode is enabled.
12044 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12046 " Configured Selection Deferral Time(sec): %u\n",
12047 peer
->bgp
->select_defer_time
);
12049 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12052 " Selection Deferral Time Remaining(sec): %ld\n",
12053 thread_timer_remain_second(
12054 peer
->bgp
->gr_info
[afi
][safi
]
12055 .t_select_deferral
));
12058 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12059 json_endofrib_status
);
12060 json_object_object_add(json_afi_safi
, "timers",
12062 json_object_object_add(
12063 json
, get_afi_safi_str(afi
, safi
, true),
12069 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12075 json_object
*json_timer
= NULL
;
12077 json_timer
= json_object_new_object();
12079 json_object_int_add(json_timer
, "configuredRestartTimer",
12080 p
->bgp
->restart_time
);
12082 json_object_int_add(json_timer
, "receivedRestartTimer",
12085 if (p
->t_gr_restart
!= NULL
)
12086 json_object_int_add(
12087 json_timer
, "restartTimerRemaining",
12088 thread_timer_remain_second(p
->t_gr_restart
));
12090 json_object_object_add(json
, "timers", json_timer
);
12093 vty_out(vty
, " Timers:\n");
12094 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12095 p
->bgp
->restart_time
);
12097 vty_out(vty
, " Received Restart Time(sec): %u\n",
12099 if (p
->t_gr_restart
!= NULL
)
12100 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12101 thread_timer_remain_second(p
->t_gr_restart
));
12102 if (p
->t_gr_restart
!= NULL
) {
12103 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12104 thread_timer_remain_second(p
->t_gr_restart
));
12109 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12110 bool use_json
, json_object
*json
)
12112 char dn_flag
[2] = {0};
12113 /* '*' + v6 address of neighbor */
12114 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12116 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12121 json_object_string_addf(json
, "neighborAddr", "%pSU",
12124 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12127 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12131 json_object_string_add(json
, "neighborAddr",
12134 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12137 /* more gr info in new format */
12138 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12141 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12142 safi_t safi
, bool use_json
,
12143 json_object
*json_neigh
)
12145 struct bgp_filter
*filter
;
12146 struct peer_af
*paf
;
12147 char orf_pfx_name
[BUFSIZ
];
12149 json_object
*json_af
= NULL
;
12150 json_object
*json_prefA
= NULL
;
12151 json_object
*json_prefB
= NULL
;
12152 json_object
*json_addr
= NULL
;
12153 json_object
*json_advmap
= NULL
;
12156 json_addr
= json_object_new_object();
12157 json_af
= json_object_new_object();
12158 filter
= &p
->filter
[afi
][safi
];
12160 if (peer_group_active(p
))
12161 json_object_string_add(json_addr
, "peerGroupMember",
12164 paf
= peer_af_find(p
, afi
, safi
);
12165 if (paf
&& PAF_SUBGRP(paf
)) {
12166 json_object_int_add(json_addr
, "updateGroupId",
12167 PAF_UPDGRP(paf
)->id
);
12168 json_object_int_add(json_addr
, "subGroupId",
12169 PAF_SUBGRP(paf
)->id
);
12170 json_object_int_add(json_addr
, "packetQueueLength",
12171 bpacket_queue_virtual_length(paf
));
12174 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12175 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12176 PEER_CAP_ORF_PREFIX_SM_RCV
)
12177 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12178 PEER_CAP_ORF_PREFIX_RM_ADV
)
12179 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12180 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12181 json_object_int_add(json_af
, "orfType",
12183 json_prefA
= json_object_new_object();
12184 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12185 PEER_CAP_ORF_PREFIX_SM_ADV
,
12186 PEER_CAP_ORF_PREFIX_RM_ADV
,
12187 PEER_CAP_ORF_PREFIX_SM_RCV
,
12188 PEER_CAP_ORF_PREFIX_RM_RCV
,
12189 use_json
, json_prefA
);
12190 json_object_object_add(json_af
, "orfPrefixList",
12194 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12195 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12196 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12197 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12198 PEER_CAP_ORF_PREFIX_RM_ADV
)
12199 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12200 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12201 json_object_int_add(json_af
, "orfOldType",
12202 ORF_TYPE_PREFIX_OLD
);
12203 json_prefB
= json_object_new_object();
12204 bgp_show_peer_afi_orf_cap(
12205 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12206 PEER_CAP_ORF_PREFIX_RM_ADV
,
12207 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12208 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12210 json_object_object_add(json_af
, "orfOldPrefixList",
12214 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12215 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12216 PEER_CAP_ORF_PREFIX_SM_RCV
)
12217 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12218 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12219 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12220 PEER_CAP_ORF_PREFIX_RM_ADV
)
12221 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12222 PEER_CAP_ORF_PREFIX_RM_RCV
)
12223 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12224 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12225 json_object_object_add(json_addr
, "afDependentCap",
12228 json_object_free(json_af
);
12230 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12231 p
->host
, afi
, safi
);
12232 orf_pfx_count
= prefix_bgp_show_prefix_list(
12233 NULL
, afi
, orf_pfx_name
, use_json
);
12235 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12236 PEER_STATUS_ORF_PREFIX_SEND
)
12237 || orf_pfx_count
) {
12238 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12239 PEER_STATUS_ORF_PREFIX_SEND
))
12240 json_object_boolean_true_add(json_neigh
,
12243 json_object_int_add(json_addr
, "orfRecvCounter",
12246 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12247 PEER_STATUS_ORF_WAIT_REFRESH
))
12248 json_object_string_add(
12249 json_addr
, "orfFirstUpdate",
12250 "deferredUntilORFOrRouteRefreshRecvd");
12252 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12253 PEER_FLAG_REFLECTOR_CLIENT
))
12254 json_object_boolean_true_add(json_addr
,
12255 "routeReflectorClient");
12256 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12257 PEER_FLAG_RSERVER_CLIENT
))
12258 json_object_boolean_true_add(json_addr
,
12259 "routeServerClient");
12260 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12261 json_object_boolean_true_add(json_addr
,
12262 "inboundSoftConfigPermit");
12264 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12265 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12266 json_object_boolean_true_add(
12268 "privateAsNumsAllReplacedInUpdatesToNbr");
12269 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12270 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12271 json_object_boolean_true_add(
12273 "privateAsNumsReplacedInUpdatesToNbr");
12274 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12275 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12276 json_object_boolean_true_add(
12278 "privateAsNumsAllRemovedInUpdatesToNbr");
12279 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12280 PEER_FLAG_REMOVE_PRIVATE_AS
))
12281 json_object_boolean_true_add(
12283 "privateAsNumsRemovedInUpdatesToNbr");
12285 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12286 json_object_boolean_true_add(
12288 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12291 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12292 json_object_string_add(json_addr
,
12293 "overrideASNsInOutboundUpdates",
12294 "ifAspathEqualRemoteAs");
12296 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12297 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12298 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12299 json_object_boolean_true_add(json_addr
,
12300 "routerAlwaysNextHop");
12301 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12302 PEER_FLAG_AS_PATH_UNCHANGED
))
12303 json_object_boolean_true_add(
12304 json_addr
, "unchangedAsPathPropogatedToNbr");
12305 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12306 PEER_FLAG_NEXTHOP_UNCHANGED
))
12307 json_object_boolean_true_add(
12308 json_addr
, "unchangedNextHopPropogatedToNbr");
12309 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12310 json_object_boolean_true_add(
12311 json_addr
, "unchangedMedPropogatedToNbr");
12312 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12313 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12314 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12315 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12316 PEER_FLAG_SEND_COMMUNITY
)
12317 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12318 PEER_FLAG_SEND_EXT_COMMUNITY
))
12319 json_object_string_add(json_addr
,
12320 "commAttriSentToNbr",
12321 "extendedAndStandard");
12322 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12323 PEER_FLAG_SEND_EXT_COMMUNITY
))
12324 json_object_string_add(json_addr
,
12325 "commAttriSentToNbr",
12328 json_object_string_add(json_addr
,
12329 "commAttriSentToNbr",
12332 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12333 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12334 if (p
->default_rmap
[afi
][safi
].name
)
12335 json_object_string_add(
12336 json_addr
, "defaultRouteMap",
12337 p
->default_rmap
[afi
][safi
].name
);
12339 if (paf
&& PAF_SUBGRP(paf
)
12340 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12341 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12342 json_object_boolean_true_add(json_addr
,
12345 json_object_boolean_true_add(json_addr
,
12349 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12350 if (is_evpn_enabled())
12351 json_object_boolean_true_add(
12352 json_addr
, "advertiseAllVnis");
12355 if (filter
->plist
[FILTER_IN
].name
12356 || filter
->dlist
[FILTER_IN
].name
12357 || filter
->aslist
[FILTER_IN
].name
12358 || filter
->map
[RMAP_IN
].name
)
12359 json_object_boolean_true_add(json_addr
,
12360 "inboundPathPolicyConfig");
12361 if (filter
->plist
[FILTER_OUT
].name
12362 || filter
->dlist
[FILTER_OUT
].name
12363 || filter
->aslist
[FILTER_OUT
].name
12364 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12365 json_object_boolean_true_add(
12366 json_addr
, "outboundPathPolicyConfig");
12369 if (filter
->plist
[FILTER_IN
].name
)
12370 json_object_string_add(json_addr
,
12371 "incomingUpdatePrefixFilterList",
12372 filter
->plist
[FILTER_IN
].name
);
12373 if (filter
->plist
[FILTER_OUT
].name
)
12374 json_object_string_add(json_addr
,
12375 "outgoingUpdatePrefixFilterList",
12376 filter
->plist
[FILTER_OUT
].name
);
12378 /* distribute-list */
12379 if (filter
->dlist
[FILTER_IN
].name
)
12380 json_object_string_add(
12381 json_addr
, "incomingUpdateNetworkFilterList",
12382 filter
->dlist
[FILTER_IN
].name
);
12383 if (filter
->dlist
[FILTER_OUT
].name
)
12384 json_object_string_add(
12385 json_addr
, "outgoingUpdateNetworkFilterList",
12386 filter
->dlist
[FILTER_OUT
].name
);
12389 if (filter
->aslist
[FILTER_IN
].name
)
12390 json_object_string_add(json_addr
,
12391 "incomingUpdateAsPathFilterList",
12392 filter
->aslist
[FILTER_IN
].name
);
12393 if (filter
->aslist
[FILTER_OUT
].name
)
12394 json_object_string_add(json_addr
,
12395 "outgoingUpdateAsPathFilterList",
12396 filter
->aslist
[FILTER_OUT
].name
);
12399 if (filter
->map
[RMAP_IN
].name
)
12400 json_object_string_add(
12401 json_addr
, "routeMapForIncomingAdvertisements",
12402 filter
->map
[RMAP_IN
].name
);
12403 if (filter
->map
[RMAP_OUT
].name
)
12404 json_object_string_add(
12405 json_addr
, "routeMapForOutgoingAdvertisements",
12406 filter
->map
[RMAP_OUT
].name
);
12408 /* ebgp-requires-policy (inbound) */
12409 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12410 && !bgp_inbound_policy_exists(p
, filter
))
12411 json_object_string_add(
12412 json_addr
, "inboundEbgpRequiresPolicy",
12413 "Inbound updates discarded due to missing policy");
12415 /* ebgp-requires-policy (outbound) */
12416 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12417 && (!bgp_outbound_policy_exists(p
, filter
)))
12418 json_object_string_add(
12419 json_addr
, "outboundEbgpRequiresPolicy",
12420 "Outbound updates discarded due to missing policy");
12422 /* unsuppress-map */
12423 if (filter
->usmap
.name
)
12424 json_object_string_add(json_addr
,
12425 "selectiveUnsuppressRouteMap",
12426 filter
->usmap
.name
);
12428 /* advertise-map */
12429 if (filter
->advmap
.aname
) {
12430 json_advmap
= json_object_new_object();
12431 json_object_string_add(json_advmap
, "condition",
12432 filter
->advmap
.condition
12435 json_object_string_add(json_advmap
, "conditionMap",
12436 filter
->advmap
.cname
);
12437 json_object_string_add(json_advmap
, "advertiseMap",
12438 filter
->advmap
.aname
);
12439 json_object_string_add(
12440 json_advmap
, "advertiseStatus",
12441 filter
->advmap
.update_type
==
12442 UPDATE_TYPE_ADVERTISE
12445 json_object_object_add(json_addr
, "advertiseMap",
12449 /* Receive prefix count */
12450 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12451 p
->pcount
[afi
][safi
]);
12452 if (paf
&& PAF_SUBGRP(paf
))
12453 json_object_int_add(json_addr
, "sentPrefixCounter",
12454 (PAF_SUBGRP(paf
))->scount
);
12456 /* Maximum prefix */
12457 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12458 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12459 p
->pmax_out
[afi
][safi
]);
12461 /* Maximum prefix */
12462 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12463 json_object_int_add(json_addr
, "prefixAllowedMax",
12464 p
->pmax
[afi
][safi
]);
12465 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12466 PEER_FLAG_MAX_PREFIX_WARNING
))
12467 json_object_boolean_true_add(
12468 json_addr
, "prefixAllowedMaxWarning");
12469 json_object_int_add(json_addr
,
12470 "prefixAllowedWarningThresh",
12471 p
->pmax_threshold
[afi
][safi
]);
12472 if (p
->pmax_restart
[afi
][safi
])
12473 json_object_int_add(
12475 "prefixAllowedRestartIntervalMsecs",
12476 p
->pmax_restart
[afi
][safi
] * 60000);
12478 json_object_object_add(json_neigh
,
12479 get_afi_safi_str(afi
, safi
, true),
12483 filter
= &p
->filter
[afi
][safi
];
12485 vty_out(vty
, " For address family: %s\n",
12486 get_afi_safi_str(afi
, safi
, false));
12488 if (peer_group_active(p
))
12489 vty_out(vty
, " %s peer-group member\n",
12492 paf
= peer_af_find(p
, afi
, safi
);
12493 if (paf
&& PAF_SUBGRP(paf
)) {
12494 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12495 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12496 vty_out(vty
, " Packet Queue length %d\n",
12497 bpacket_queue_virtual_length(paf
));
12499 vty_out(vty
, " Not part of any update group\n");
12501 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12502 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12503 PEER_CAP_ORF_PREFIX_SM_RCV
)
12504 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12505 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12506 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12507 PEER_CAP_ORF_PREFIX_RM_ADV
)
12508 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12509 PEER_CAP_ORF_PREFIX_RM_RCV
)
12510 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12511 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12512 vty_out(vty
, " AF-dependant capabilities:\n");
12514 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12515 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12516 PEER_CAP_ORF_PREFIX_SM_RCV
)
12517 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12518 PEER_CAP_ORF_PREFIX_RM_ADV
)
12519 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12520 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12522 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12524 bgp_show_peer_afi_orf_cap(
12525 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12526 PEER_CAP_ORF_PREFIX_RM_ADV
,
12527 PEER_CAP_ORF_PREFIX_SM_RCV
,
12528 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12530 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12531 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12532 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12533 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12534 PEER_CAP_ORF_PREFIX_RM_ADV
)
12535 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12536 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12538 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12539 ORF_TYPE_PREFIX_OLD
);
12540 bgp_show_peer_afi_orf_cap(
12541 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12542 PEER_CAP_ORF_PREFIX_RM_ADV
,
12543 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12544 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12547 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12548 p
->host
, afi
, safi
);
12549 orf_pfx_count
= prefix_bgp_show_prefix_list(
12550 NULL
, afi
, orf_pfx_name
, use_json
);
12552 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12553 PEER_STATUS_ORF_PREFIX_SEND
)
12554 || orf_pfx_count
) {
12555 vty_out(vty
, " Outbound Route Filter (ORF):");
12556 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12557 PEER_STATUS_ORF_PREFIX_SEND
))
12558 vty_out(vty
, " sent;");
12560 vty_out(vty
, " received (%d entries)",
12562 vty_out(vty
, "\n");
12564 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12565 PEER_STATUS_ORF_WAIT_REFRESH
))
12567 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12569 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12570 PEER_FLAG_REFLECTOR_CLIENT
))
12571 vty_out(vty
, " Route-Reflector Client\n");
12572 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12573 PEER_FLAG_RSERVER_CLIENT
))
12574 vty_out(vty
, " Route-Server Client\n");
12576 if (peer_af_flag_check(p
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
12577 vty_out(vty
, " ORR group (configured) : %s\n",
12578 p
->orr_group_name
[afi
][safi
]);
12580 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12582 " Inbound soft reconfiguration allowed\n");
12584 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12585 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12587 " Private AS numbers (all) replaced in updates to this neighbor\n");
12588 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12589 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12591 " Private AS numbers replaced in updates to this neighbor\n");
12592 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12593 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12595 " Private AS numbers (all) removed in updates to this neighbor\n");
12596 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12597 PEER_FLAG_REMOVE_PRIVATE_AS
))
12599 " Private AS numbers removed in updates to this neighbor\n");
12601 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12602 vty_out(vty
, " %s\n",
12603 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12604 ->human_description
);
12606 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12608 " Override ASNs in outbound updates if aspath equals remote-as\n");
12610 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12611 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12612 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12613 vty_out(vty
, " NEXT_HOP is always this router\n");
12614 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12615 PEER_FLAG_AS_PATH_UNCHANGED
))
12617 " AS_PATH is propagated unchanged to this neighbor\n");
12618 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12619 PEER_FLAG_NEXTHOP_UNCHANGED
))
12621 " NEXT_HOP is propagated unchanged to this neighbor\n");
12622 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12624 " MED is propagated unchanged to this neighbor\n");
12625 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12626 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12627 PEER_FLAG_SEND_EXT_COMMUNITY
)
12628 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12629 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12631 " Community attribute sent to this neighbor");
12632 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12633 PEER_FLAG_SEND_COMMUNITY
)
12634 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12635 PEER_FLAG_SEND_EXT_COMMUNITY
)
12636 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12637 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12638 vty_out(vty
, "(all)\n");
12639 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12640 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12641 vty_out(vty
, "(large)\n");
12642 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12643 PEER_FLAG_SEND_EXT_COMMUNITY
))
12644 vty_out(vty
, "(extended)\n");
12646 vty_out(vty
, "(standard)\n");
12648 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12649 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12650 vty_out(vty
, " Default information originate,");
12652 if (p
->default_rmap
[afi
][safi
].name
)
12653 vty_out(vty
, " default route-map %s%s,",
12654 p
->default_rmap
[afi
][safi
].map
? "*"
12656 p
->default_rmap
[afi
][safi
].name
);
12657 if (paf
&& PAF_SUBGRP(paf
)
12658 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12659 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12660 vty_out(vty
, " default sent\n");
12662 vty_out(vty
, " default not sent\n");
12665 /* advertise-vni-all */
12666 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12667 if (is_evpn_enabled())
12668 vty_out(vty
, " advertise-all-vni\n");
12671 if (filter
->plist
[FILTER_IN
].name
12672 || filter
->dlist
[FILTER_IN
].name
12673 || filter
->aslist
[FILTER_IN
].name
12674 || filter
->map
[RMAP_IN
].name
)
12675 vty_out(vty
, " Inbound path policy configured\n");
12676 if (filter
->plist
[FILTER_OUT
].name
12677 || filter
->dlist
[FILTER_OUT
].name
12678 || filter
->aslist
[FILTER_OUT
].name
12679 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12680 vty_out(vty
, " Outbound path policy configured\n");
12683 if (filter
->plist
[FILTER_IN
].name
)
12685 " Incoming update prefix filter list is %s%s\n",
12686 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12687 filter
->plist
[FILTER_IN
].name
);
12688 if (filter
->plist
[FILTER_OUT
].name
)
12690 " Outgoing update prefix filter list is %s%s\n",
12691 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12692 filter
->plist
[FILTER_OUT
].name
);
12694 /* distribute-list */
12695 if (filter
->dlist
[FILTER_IN
].name
)
12697 " Incoming update network filter list is %s%s\n",
12698 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12699 filter
->dlist
[FILTER_IN
].name
);
12700 if (filter
->dlist
[FILTER_OUT
].name
)
12702 " Outgoing update network filter list is %s%s\n",
12703 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12704 filter
->dlist
[FILTER_OUT
].name
);
12707 if (filter
->aslist
[FILTER_IN
].name
)
12709 " Incoming update AS path filter list is %s%s\n",
12710 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12711 filter
->aslist
[FILTER_IN
].name
);
12712 if (filter
->aslist
[FILTER_OUT
].name
)
12714 " Outgoing update AS path filter list is %s%s\n",
12715 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12716 filter
->aslist
[FILTER_OUT
].name
);
12719 if (filter
->map
[RMAP_IN
].name
)
12721 " Route map for incoming advertisements is %s%s\n",
12722 filter
->map
[RMAP_IN
].map
? "*" : "",
12723 filter
->map
[RMAP_IN
].name
);
12724 if (filter
->map
[RMAP_OUT
].name
)
12726 " Route map for outgoing advertisements is %s%s\n",
12727 filter
->map
[RMAP_OUT
].map
? "*" : "",
12728 filter
->map
[RMAP_OUT
].name
);
12730 /* ebgp-requires-policy (inbound) */
12731 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12732 && !bgp_inbound_policy_exists(p
, filter
))
12734 " Inbound updates discarded due to missing policy\n");
12736 /* ebgp-requires-policy (outbound) */
12737 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12738 && !bgp_outbound_policy_exists(p
, filter
))
12740 " Outbound updates discarded due to missing policy\n");
12742 /* unsuppress-map */
12743 if (filter
->usmap
.name
)
12745 " Route map for selective unsuppress is %s%s\n",
12746 filter
->usmap
.map
? "*" : "",
12747 filter
->usmap
.name
);
12749 /* advertise-map */
12750 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12752 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12753 filter
->advmap
.condition
? "EXIST"
12755 filter
->advmap
.cmap
? "*" : "",
12756 filter
->advmap
.cname
,
12757 filter
->advmap
.amap
? "*" : "",
12758 filter
->advmap
.aname
,
12759 filter
->advmap
.update_type
==
12760 UPDATE_TYPE_ADVERTISE
12764 /* Receive prefix count */
12765 vty_out(vty
, " %u accepted prefixes\n",
12766 p
->pcount
[afi
][safi
]);
12768 /* maximum-prefix-out */
12769 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12770 PEER_FLAG_MAX_PREFIX_OUT
))
12772 " Maximum allowed prefixes sent %u\n",
12773 p
->pmax_out
[afi
][safi
]);
12775 /* Maximum prefix */
12776 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12778 " Maximum prefixes allowed %u%s\n",
12779 p
->pmax
[afi
][safi
],
12780 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12781 PEER_FLAG_MAX_PREFIX_WARNING
)
12782 ? " (warning-only)"
12784 vty_out(vty
, " Threshold for warning message %d%%",
12785 p
->pmax_threshold
[afi
][safi
]);
12786 if (p
->pmax_restart
[afi
][safi
])
12787 vty_out(vty
, ", restart interval %d min",
12788 p
->pmax_restart
[afi
][safi
]);
12789 vty_out(vty
, "\n");
12792 vty_out(vty
, "\n");
12796 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12800 char buf1
[PREFIX2STR_BUFFER
];
12801 char timebuf
[BGP_UPTIME_LEN
];
12807 json_object
*json_neigh
= NULL
;
12809 uint32_t sync_tcp_mss
;
12814 json_neigh
= json_object_new_object();
12816 memset(dn_flag
, '\0', sizeof(dn_flag
));
12817 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12821 if (p
->conf_if
) /* Configured interface name. */
12822 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12824 else /* Configured IP address. */
12825 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12830 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12831 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12833 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12834 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12837 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12839 if (p
->change_local_as
)
12840 json_object_int_add(json_neigh
, "localAs",
12841 p
->change_local_as
);
12843 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12845 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12846 json_object_boolean_true_add(json_neigh
,
12847 "localAsNoPrepend");
12849 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12850 json_object_boolean_true_add(json_neigh
,
12851 "localAsReplaceAs");
12853 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12854 || (p
->as_type
== AS_INTERNAL
))
12855 vty_out(vty
, "remote AS %u, ", p
->as
);
12857 vty_out(vty
, "remote AS Unspecified, ");
12858 vty_out(vty
, "local AS %u%s%s, ",
12859 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12860 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12863 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12867 /* peer type internal or confed-internal */
12868 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12870 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12871 json_object_boolean_true_add(
12872 json_neigh
, "nbrConfedInternalLink");
12874 json_object_boolean_true_add(json_neigh
,
12875 "nbrInternalLink");
12877 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12878 vty_out(vty
, "confed-internal link\n");
12880 vty_out(vty
, "internal link\n");
12882 /* peer type external or confed-external */
12883 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12885 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12886 json_object_boolean_true_add(
12887 json_neigh
, "nbrConfedExternalLink");
12889 json_object_boolean_true_add(json_neigh
,
12890 "nbrExternalLink");
12892 if (bgp_confederation_peers_check(bgp
, p
->as
))
12893 vty_out(vty
, "confed-external link\n");
12895 vty_out(vty
, "external link\n");
12899 json_object_boolean_true_add(json_neigh
,
12900 "nbrUnspecifiedLink");
12902 vty_out(vty
, "unspecified link\n");
12907 json_object_string_add(json_neigh
, "localRole",
12908 bgp_get_name_by_role(p
->local_role
));
12909 json_object_string_add(json_neigh
, "remoteRole",
12910 bgp_get_name_by_role(p
->remote_role
));
12912 vty_out(vty
, " Local Role: %s\n",
12913 bgp_get_name_by_role(p
->local_role
));
12914 vty_out(vty
, " Remote Role: %s\n",
12915 bgp_get_name_by_role(p
->remote_role
));
12922 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12924 vty_out(vty
, " Description: %s\n", p
->desc
);
12930 json_object_string_add(json_neigh
, "hostname",
12934 json_object_string_add(json_neigh
, "domainname",
12937 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12938 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12941 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12948 json_object_string_add(json_neigh
, "peerGroup",
12952 struct prefix prefix
, *range
= NULL
;
12954 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12955 range
= peer_group_lookup_dynamic_neighbor_range(
12956 p
->group
, &prefix
);
12959 json_object_string_addf(
12961 "peerSubnetRangeGroup", "%pFX",
12967 " Member of peer-group %s for session parameters\n",
12971 struct prefix prefix
, *range
= NULL
;
12973 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12974 range
= peer_group_lookup_dynamic_neighbor_range(
12975 p
->group
, &prefix
);
12979 " Belongs to the subnet range group: %pFX\n",
12987 /* Administrative shutdown. */
12988 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12989 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12990 json_object_boolean_true_add(json_neigh
,
12994 json_object_int_add(json_neigh
, "bgpVersion", 4);
12995 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12997 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13000 /* Confederation */
13001 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13002 && bgp_confederation_peers_check(bgp
, p
->as
))
13003 json_object_boolean_true_add(json_neigh
,
13007 json_object_string_add(
13008 json_neigh
, "bgpState",
13009 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13011 if (peer_established(p
)) {
13014 uptime
= monotime(NULL
);
13015 uptime
-= p
->uptime
;
13016 epoch_tbuf
= time(NULL
) - uptime
;
13018 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13020 json_object_string_add(json_neigh
, "bgpTimerUpString",
13021 peer_uptime(p
->uptime
, timebuf
,
13024 json_object_int_add(json_neigh
,
13025 "bgpTimerUpEstablishedEpoch",
13029 else if (p
->status
== Active
) {
13030 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13031 json_object_string_add(json_neigh
, "bgpStateIs",
13033 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13034 json_object_string_add(json_neigh
, "bgpStateIs",
13042 uptime
= monotime(NULL
);
13043 uptime
-= p
->readtime
;
13044 gmtime_r(&uptime
, &tm
);
13046 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13047 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13048 + (tm
.tm_hour
* 3600000));
13050 uptime
= monotime(NULL
);
13051 uptime
-= p
->last_write
;
13052 gmtime_r(&uptime
, &tm
);
13054 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13055 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13056 + (tm
.tm_hour
* 3600000));
13058 uptime
= monotime(NULL
);
13059 uptime
-= p
->update_time
;
13060 gmtime_r(&uptime
, &tm
);
13062 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13063 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13064 + (tm
.tm_hour
* 3600000));
13066 /* Configured timer values. */
13067 json_object_int_add(json_neigh
,
13068 "bgpTimerConfiguredHoldTimeMsecs",
13069 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13070 ? p
->holdtime
* 1000
13071 : bgp
->default_holdtime
* 1000);
13072 json_object_int_add(json_neigh
,
13073 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13074 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13075 ? p
->keepalive
* 1000
13076 : bgp
->default_keepalive
* 1000);
13077 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13078 p
->v_holdtime
* 1000);
13079 json_object_int_add(json_neigh
,
13080 "bgpTimerKeepAliveIntervalMsecs",
13081 p
->v_keepalive
* 1000);
13082 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13083 json_object_int_add(json_neigh
,
13084 "bgpTimerDelayOpenTimeMsecs",
13085 p
->v_delayopen
* 1000);
13088 /* Configured and Synced tcp-mss value for peer */
13089 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13090 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13091 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13093 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13097 /* Extended Optional Parameters Length for BGP OPEN Message */
13098 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13099 json_object_boolean_true_add(
13100 json_neigh
, "extendedOptionalParametersLength");
13102 json_object_boolean_false_add(
13103 json_neigh
, "extendedOptionalParametersLength");
13105 /* Conditional advertisements */
13106 json_object_int_add(
13108 "bgpTimerConfiguredConditionalAdvertisementsSec",
13109 bgp
->condition_check_period
);
13110 if (thread_is_scheduled(bgp
->t_condition_check
))
13111 json_object_int_add(
13113 "bgpTimerUntilConditionalAdvertisementsSec",
13114 thread_timer_remain_second(
13115 bgp
->t_condition_check
));
13117 /* Administrative shutdown. */
13118 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13119 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13120 vty_out(vty
, " Administratively shut down\n");
13123 vty_out(vty
, " BGP version 4");
13124 vty_out(vty
, ", remote router ID %s",
13125 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13126 vty_out(vty
, ", local router ID %s\n",
13127 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13130 /* Confederation */
13131 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13132 && bgp_confederation_peers_check(bgp
, p
->as
))
13134 " Neighbor under common administration\n");
13137 vty_out(vty
, " BGP state = %s",
13138 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13140 if (peer_established(p
))
13141 vty_out(vty
, ", up for %8s",
13142 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13145 else if (p
->status
== Active
) {
13146 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13147 vty_out(vty
, " (passive)");
13148 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13149 vty_out(vty
, " (NSF passive)");
13151 vty_out(vty
, "\n");
13154 vty_out(vty
, " Last read %s",
13155 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13157 vty_out(vty
, ", Last write %s\n",
13158 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13161 /* Configured timer values. */
13163 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13164 p
->v_holdtime
, p
->v_keepalive
);
13165 vty_out(vty
, " Configured hold time is %d seconds",
13166 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13168 : bgp
->default_holdtime
);
13169 vty_out(vty
, ", keepalive interval is %d seconds\n",
13170 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13172 : bgp
->default_keepalive
);
13173 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13175 " Configured DelayOpenTime is %d seconds\n",
13178 /* Configured and synced tcp-mss value for peer */
13179 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13180 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13181 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13182 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13185 /* Extended Optional Parameters Length for BGP OPEN Message */
13186 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13188 " Extended Optional Parameters Length is enabled\n");
13190 /* Conditional advertisements */
13192 " Configured conditional advertisements interval is %d seconds\n",
13193 bgp
->condition_check_period
);
13194 if (thread_is_scheduled(bgp
->t_condition_check
))
13196 " Time until conditional advertisements begin is %lu seconds\n",
13197 thread_timer_remain_second(
13198 bgp
->t_condition_check
));
13201 if (peer_established(p
) &&
13202 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13204 json_object
*json_cap
= NULL
;
13206 json_cap
= json_object_new_object();
13209 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13210 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13211 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13212 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13213 json_object_string_add(
13214 json_cap
, "4byteAs",
13215 "advertisedAndReceived");
13216 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13217 json_object_string_add(json_cap
,
13220 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13221 json_object_string_add(json_cap
,
13226 /* Extended Message Support */
13227 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13228 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13229 json_object_string_add(json_cap
,
13231 "advertisedAndReceived");
13232 else if (CHECK_FLAG(p
->cap
,
13233 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13234 json_object_string_add(json_cap
,
13237 else if (CHECK_FLAG(p
->cap
,
13238 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13239 json_object_string_add(json_cap
,
13244 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13245 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13246 json_object
*json_add
= NULL
;
13247 const char *print_store
;
13249 json_add
= json_object_new_object();
13251 FOREACH_AFI_SAFI (afi
, safi
) {
13252 json_object
*json_sub
= NULL
;
13253 json_sub
= json_object_new_object();
13254 print_store
= get_afi_safi_str(
13258 p
->af_cap
[afi
][safi
],
13259 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13261 p
->af_cap
[afi
][safi
],
13262 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13266 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13270 PEER_CAP_ADDPATH_AF_TX_RCV
))
13271 json_object_boolean_true_add(
13273 "txAdvertisedAndReceived");
13278 PEER_CAP_ADDPATH_AF_TX_ADV
))
13279 json_object_boolean_true_add(
13286 PEER_CAP_ADDPATH_AF_TX_RCV
))
13287 json_object_boolean_true_add(
13293 p
->af_cap
[afi
][safi
],
13294 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13296 p
->af_cap
[afi
][safi
],
13297 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13301 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13305 PEER_CAP_ADDPATH_AF_RX_RCV
))
13306 json_object_boolean_true_add(
13308 "rxAdvertisedAndReceived");
13313 PEER_CAP_ADDPATH_AF_RX_ADV
))
13314 json_object_boolean_true_add(
13321 PEER_CAP_ADDPATH_AF_RX_RCV
))
13322 json_object_boolean_true_add(
13328 p
->af_cap
[afi
][safi
],
13329 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13331 p
->af_cap
[afi
][safi
],
13332 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13334 p
->af_cap
[afi
][safi
],
13335 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13337 p
->af_cap
[afi
][safi
],
13338 PEER_CAP_ADDPATH_AF_RX_RCV
))
13339 json_object_object_add(
13340 json_add
, print_store
,
13343 json_object_free(json_sub
);
13346 json_object_object_add(json_cap
, "addPath",
13351 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13352 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13353 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13354 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13355 json_object_string_add(
13356 json_cap
, "dynamic",
13357 "advertisedAndReceived");
13358 else if (CHECK_FLAG(p
->cap
,
13359 PEER_CAP_DYNAMIC_ADV
))
13360 json_object_string_add(json_cap
,
13363 else if (CHECK_FLAG(p
->cap
,
13364 PEER_CAP_DYNAMIC_RCV
))
13365 json_object_string_add(json_cap
,
13371 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13372 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13373 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13374 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13375 json_object_string_add(
13377 "advertisedAndReceived");
13378 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13379 json_object_string_add(json_cap
, "role",
13381 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13382 json_object_string_add(json_cap
, "role",
13386 /* Extended nexthop */
13387 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13388 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13389 json_object
*json_nxt
= NULL
;
13390 const char *print_store
;
13393 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13394 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13395 json_object_string_add(
13396 json_cap
, "extendedNexthop",
13397 "advertisedAndReceived");
13398 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13399 json_object_string_add(
13400 json_cap
, "extendedNexthop",
13402 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13403 json_object_string_add(
13404 json_cap
, "extendedNexthop",
13407 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13408 json_nxt
= json_object_new_object();
13410 for (safi
= SAFI_UNICAST
;
13411 safi
< SAFI_MAX
; safi
++) {
13415 PEER_CAP_ENHE_AF_RCV
)) {
13421 json_object_string_add(
13424 "recieved"); /* misspelled for compatibility */
13427 json_object_object_add(
13429 "extendedNexthopFamililesByPeer",
13434 /* Long-lived Graceful Restart */
13435 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13436 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13437 json_object
*json_llgr
= NULL
;
13438 const char *afi_safi_str
;
13440 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13441 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13442 json_object_string_add(
13444 "longLivedGracefulRestart",
13445 "advertisedAndReceived");
13446 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13447 json_object_string_add(
13449 "longLivedGracefulRestart",
13451 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13452 json_object_string_add(
13454 "longLivedGracefulRestart",
13457 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13458 json_llgr
= json_object_new_object();
13460 FOREACH_AFI_SAFI (afi
, safi
) {
13464 PEER_CAP_ENHE_AF_RCV
)) {
13470 json_object_string_add(
13476 json_object_object_add(
13478 "longLivedGracefulRestartByPeer",
13483 /* Route Refresh */
13484 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13485 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13486 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13487 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13488 (CHECK_FLAG(p
->cap
,
13489 PEER_CAP_REFRESH_NEW_RCV
) ||
13491 PEER_CAP_REFRESH_OLD_RCV
))) {
13494 PEER_CAP_REFRESH_OLD_RCV
) &&
13497 PEER_CAP_REFRESH_NEW_RCV
))
13498 json_object_string_add(
13501 "advertisedAndReceivedOldNew");
13505 PEER_CAP_REFRESH_OLD_RCV
))
13506 json_object_string_add(
13509 "advertisedAndReceivedOld");
13511 json_object_string_add(
13514 "advertisedAndReceivedNew");
13516 } else if (CHECK_FLAG(p
->cap
,
13517 PEER_CAP_REFRESH_ADV
))
13518 json_object_string_add(json_cap
,
13521 else if (CHECK_FLAG(p
->cap
,
13522 PEER_CAP_REFRESH_NEW_RCV
) ||
13524 PEER_CAP_REFRESH_OLD_RCV
))
13525 json_object_string_add(json_cap
,
13530 /* Enhanced Route Refresh */
13531 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13532 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13533 if (CHECK_FLAG(p
->cap
,
13534 PEER_CAP_ENHANCED_RR_ADV
) &&
13536 PEER_CAP_ENHANCED_RR_RCV
))
13537 json_object_string_add(
13539 "enhancedRouteRefresh",
13540 "advertisedAndReceived");
13541 else if (CHECK_FLAG(p
->cap
,
13542 PEER_CAP_ENHANCED_RR_ADV
))
13543 json_object_string_add(
13545 "enhancedRouteRefresh",
13547 else if (CHECK_FLAG(p
->cap
,
13548 PEER_CAP_ENHANCED_RR_RCV
))
13549 json_object_string_add(
13551 "enhancedRouteRefresh",
13555 /* Multiprotocol Extensions */
13556 json_object
*json_multi
= NULL
;
13558 json_multi
= json_object_new_object();
13560 FOREACH_AFI_SAFI (afi
, safi
) {
13561 if (p
->afc_adv
[afi
][safi
] ||
13562 p
->afc_recv
[afi
][safi
]) {
13563 json_object
*json_exten
= NULL
;
13564 json_exten
= json_object_new_object();
13566 if (p
->afc_adv
[afi
][safi
] &&
13567 p
->afc_recv
[afi
][safi
])
13568 json_object_boolean_true_add(
13570 "advertisedAndReceived");
13571 else if (p
->afc_adv
[afi
][safi
])
13572 json_object_boolean_true_add(
13575 else if (p
->afc_recv
[afi
][safi
])
13576 json_object_boolean_true_add(
13577 json_exten
, "received");
13579 json_object_object_add(
13581 get_afi_safi_str(afi
, safi
,
13586 json_object_object_add(json_cap
,
13587 "multiprotocolExtensions",
13590 /* Hostname capabilities */
13591 json_object
*json_hname
= NULL
;
13593 json_hname
= json_object_new_object();
13595 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13596 json_object_string_add(
13597 json_hname
, "advHostName",
13598 bgp
->peer_self
->hostname
13599 ? bgp
->peer_self
->hostname
13601 json_object_string_add(
13602 json_hname
, "advDomainName",
13603 bgp
->peer_self
->domainname
13604 ? bgp
->peer_self
->domainname
13609 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13610 json_object_string_add(
13611 json_hname
, "rcvHostName",
13612 p
->hostname
? p
->hostname
: "n/a");
13613 json_object_string_add(
13614 json_hname
, "rcvDomainName",
13615 p
->domainname
? p
->domainname
: "n/a");
13618 json_object_object_add(json_cap
, "hostName",
13621 /* Graceful Restart */
13622 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13623 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13624 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13625 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13626 json_object_string_add(
13627 json_cap
, "gracefulRestart",
13628 "advertisedAndReceived");
13629 else if (CHECK_FLAG(p
->cap
,
13630 PEER_CAP_RESTART_ADV
))
13631 json_object_string_add(
13633 "gracefulRestartCapability",
13635 else if (CHECK_FLAG(p
->cap
,
13636 PEER_CAP_RESTART_RCV
))
13637 json_object_string_add(
13639 "gracefulRestartCapability",
13642 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13643 int restart_af_count
= 0;
13644 json_object
*json_restart
= NULL
;
13645 json_restart
= json_object_new_object();
13647 json_object_int_add(
13649 "gracefulRestartRemoteTimerMsecs",
13650 p
->v_gr_restart
* 1000);
13652 FOREACH_AFI_SAFI (afi
, safi
) {
13656 PEER_CAP_RESTART_AF_RCV
)) {
13657 json_object
*json_sub
=
13660 json_object_new_object();
13666 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13667 json_object_boolean_true_add(
13670 restart_af_count
++;
13671 json_object_object_add(
13680 if (!restart_af_count
) {
13681 json_object_string_add(
13683 "addressFamiliesByPeer",
13685 json_object_free(json_restart
);
13687 json_object_object_add(
13689 "addressFamiliesByPeer",
13693 json_object_object_add(
13694 json_neigh
, "neighborCapabilities", json_cap
);
13696 vty_out(vty
, " Neighbor capabilities:\n");
13699 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13700 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13701 vty_out(vty
, " 4 Byte AS:");
13702 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13703 vty_out(vty
, " advertised");
13704 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13705 vty_out(vty
, " %sreceived",
13710 vty_out(vty
, "\n");
13713 /* Extended Message Support */
13714 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13715 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13716 vty_out(vty
, " Extended Message:");
13717 if (CHECK_FLAG(p
->cap
,
13718 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13719 vty_out(vty
, " advertised");
13720 if (CHECK_FLAG(p
->cap
,
13721 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13722 vty_out(vty
, " %sreceived",
13725 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13728 vty_out(vty
, "\n");
13732 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13733 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13734 vty_out(vty
, " AddPath:\n");
13736 FOREACH_AFI_SAFI (afi
, safi
) {
13738 p
->af_cap
[afi
][safi
],
13739 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13741 p
->af_cap
[afi
][safi
],
13742 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13743 vty_out(vty
, " %s: TX ",
13751 PEER_CAP_ADDPATH_AF_TX_ADV
))
13758 PEER_CAP_ADDPATH_AF_TX_RCV
))
13765 PEER_CAP_ADDPATH_AF_TX_ADV
)
13769 vty_out(vty
, "\n");
13773 p
->af_cap
[afi
][safi
],
13774 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13776 p
->af_cap
[afi
][safi
],
13777 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13778 vty_out(vty
, " %s: RX ",
13786 PEER_CAP_ADDPATH_AF_RX_ADV
))
13793 PEER_CAP_ADDPATH_AF_RX_RCV
))
13800 PEER_CAP_ADDPATH_AF_RX_ADV
)
13804 vty_out(vty
, "\n");
13810 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13811 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13812 vty_out(vty
, " Dynamic:");
13813 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13814 vty_out(vty
, " advertised");
13815 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13816 vty_out(vty
, " %sreceived",
13818 PEER_CAP_DYNAMIC_ADV
)
13821 vty_out(vty
, "\n");
13825 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13826 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13827 vty_out(vty
, " Role:");
13828 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13829 vty_out(vty
, " advertised");
13830 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13831 vty_out(vty
, " %sreceived",
13836 vty_out(vty
, "\n");
13839 /* Extended nexthop */
13840 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13841 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13842 vty_out(vty
, " Extended nexthop:");
13843 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13844 vty_out(vty
, " advertised");
13845 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13846 vty_out(vty
, " %sreceived",
13851 vty_out(vty
, "\n");
13853 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13855 " Address families by peer:\n ");
13856 for (safi
= SAFI_UNICAST
;
13857 safi
< SAFI_MAX
; safi
++)
13861 PEER_CAP_ENHE_AF_RCV
))
13871 /* Long-lived Graceful Restart */
13872 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13873 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13875 " Long-lived Graceful Restart:");
13876 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13877 vty_out(vty
, " advertised");
13878 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13879 vty_out(vty
, " %sreceived",
13884 vty_out(vty
, "\n");
13886 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13888 " Address families by peer:\n");
13889 FOREACH_AFI_SAFI (afi
, safi
)
13893 PEER_CAP_LLGR_AF_RCV
))
13903 /* Route Refresh */
13904 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13905 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13906 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13907 vty_out(vty
, " Route refresh:");
13908 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13909 vty_out(vty
, " advertised");
13910 if (CHECK_FLAG(p
->cap
,
13911 PEER_CAP_REFRESH_NEW_RCV
) ||
13913 PEER_CAP_REFRESH_OLD_RCV
))
13914 vty_out(vty
, " %sreceived(%s)",
13916 PEER_CAP_REFRESH_ADV
)
13921 PEER_CAP_REFRESH_OLD_RCV
) &&
13924 PEER_CAP_REFRESH_NEW_RCV
))
13928 PEER_CAP_REFRESH_OLD_RCV
)
13932 vty_out(vty
, "\n");
13935 /* Enhanced Route Refresh */
13936 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13937 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13938 vty_out(vty
, " Enhanced Route Refresh:");
13939 if (CHECK_FLAG(p
->cap
,
13940 PEER_CAP_ENHANCED_RR_ADV
))
13941 vty_out(vty
, " advertised");
13942 if (CHECK_FLAG(p
->cap
,
13943 PEER_CAP_ENHANCED_RR_RCV
))
13944 vty_out(vty
, " %sreceived",
13946 PEER_CAP_REFRESH_ADV
)
13949 vty_out(vty
, "\n");
13952 /* Multiprotocol Extensions */
13953 FOREACH_AFI_SAFI (afi
, safi
)
13954 if (p
->afc_adv
[afi
][safi
] ||
13955 p
->afc_recv
[afi
][safi
]) {
13956 vty_out(vty
, " Address Family %s:",
13957 get_afi_safi_str(afi
, safi
,
13959 if (p
->afc_adv
[afi
][safi
])
13960 vty_out(vty
, " advertised");
13961 if (p
->afc_recv
[afi
][safi
])
13962 vty_out(vty
, " %sreceived",
13963 p
->afc_adv
[afi
][safi
]
13966 vty_out(vty
, "\n");
13969 /* Hostname capability */
13970 vty_out(vty
, " Hostname Capability:");
13972 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13974 " advertised (name: %s,domain name: %s)",
13975 bgp
->peer_self
->hostname
13976 ? bgp
->peer_self
->hostname
13978 bgp
->peer_self
->domainname
13979 ? bgp
->peer_self
->domainname
13982 vty_out(vty
, " not advertised");
13985 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13987 " received (name: %s,domain name: %s)",
13988 p
->hostname
? p
->hostname
: "n/a",
13989 p
->domainname
? p
->domainname
: "n/a");
13991 vty_out(vty
, " not received");
13994 vty_out(vty
, "\n");
13996 /* Graceful Restart */
13997 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13998 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14000 " Graceful Restart Capability:");
14001 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14002 vty_out(vty
, " advertised");
14003 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14004 vty_out(vty
, " %sreceived",
14006 PEER_CAP_RESTART_ADV
)
14009 vty_out(vty
, "\n");
14011 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14012 int restart_af_count
= 0;
14015 " Remote Restart timer is %d seconds\n",
14018 " Address families by peer:\n ");
14020 FOREACH_AFI_SAFI (afi
, safi
)
14024 PEER_CAP_RESTART_AF_RCV
)) {
14025 vty_out(vty
, "%s%s(%s)",
14037 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14039 : "not preserved");
14040 restart_af_count
++;
14042 if (!restart_af_count
)
14043 vty_out(vty
, "none");
14044 vty_out(vty
, "\n");
14046 } /* Graceful Restart */
14050 /* graceful restart information */
14051 json_object
*json_grace
= NULL
;
14052 json_object
*json_grace_send
= NULL
;
14053 json_object
*json_grace_recv
= NULL
;
14054 int eor_send_af_count
= 0;
14055 int eor_receive_af_count
= 0;
14058 json_grace
= json_object_new_object();
14059 json_grace_send
= json_object_new_object();
14060 json_grace_recv
= json_object_new_object();
14062 if ((peer_established(p
)) &&
14063 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14064 FOREACH_AFI_SAFI (afi
, safi
) {
14065 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14066 PEER_STATUS_EOR_SEND
)) {
14067 json_object_boolean_true_add(
14069 get_afi_safi_str(afi
, safi
,
14071 eor_send_af_count
++;
14074 FOREACH_AFI_SAFI (afi
, safi
) {
14075 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14076 PEER_STATUS_EOR_RECEIVED
)) {
14077 json_object_boolean_true_add(
14079 get_afi_safi_str(afi
, safi
,
14081 eor_receive_af_count
++;
14085 json_object_object_add(json_grace
, "endOfRibSend",
14087 json_object_object_add(json_grace
, "endOfRibRecv",
14091 if (p
->t_gr_restart
)
14092 json_object_int_add(
14093 json_grace
, "gracefulRestartTimerMsecs",
14094 thread_timer_remain_second(p
->t_gr_restart
) *
14098 json_object_int_add(
14099 json_grace
, "gracefulStalepathTimerMsecs",
14100 thread_timer_remain_second(p
->t_gr_stale
) *
14102 /* more gr info in new format */
14103 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
14104 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14107 vty_out(vty
, " Graceful restart information:\n");
14108 if ((peer_established(p
)) &&
14109 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14111 vty_out(vty
, " End-of-RIB send: ");
14112 FOREACH_AFI_SAFI (afi
, safi
) {
14113 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14114 PEER_STATUS_EOR_SEND
)) {
14115 vty_out(vty
, "%s%s",
14116 eor_send_af_count
? ", " : "",
14117 get_afi_safi_str(afi
, safi
,
14119 eor_send_af_count
++;
14122 vty_out(vty
, "\n");
14123 vty_out(vty
, " End-of-RIB received: ");
14124 FOREACH_AFI_SAFI (afi
, safi
) {
14125 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14126 PEER_STATUS_EOR_RECEIVED
)) {
14127 vty_out(vty
, "%s%s",
14128 eor_receive_af_count
? ", "
14130 get_afi_safi_str(afi
, safi
,
14132 eor_receive_af_count
++;
14135 vty_out(vty
, "\n");
14138 if (p
->t_gr_restart
)
14140 " The remaining time of restart timer is %ld\n",
14141 thread_timer_remain_second(p
->t_gr_restart
));
14145 " The remaining time of stalepath timer is %ld\n",
14146 thread_timer_remain_second(p
->t_gr_stale
));
14148 /* more gr info in new format */
14149 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14153 json_object
*json_stat
= NULL
;
14154 json_stat
= json_object_new_object();
14155 /* Packet counts. */
14157 atomic_size_t outq_count
, inq_count
;
14158 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14159 memory_order_relaxed
);
14160 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14161 memory_order_relaxed
);
14163 json_object_int_add(json_stat
, "depthInq",
14164 (unsigned long)inq_count
);
14165 json_object_int_add(json_stat
, "depthOutq",
14166 (unsigned long)outq_count
);
14167 json_object_int_add(json_stat
, "opensSent",
14168 atomic_load_explicit(&p
->open_out
,
14169 memory_order_relaxed
));
14170 json_object_int_add(json_stat
, "opensRecv",
14171 atomic_load_explicit(&p
->open_in
,
14172 memory_order_relaxed
));
14173 json_object_int_add(json_stat
, "notificationsSent",
14174 atomic_load_explicit(&p
->notify_out
,
14175 memory_order_relaxed
));
14176 json_object_int_add(json_stat
, "notificationsRecv",
14177 atomic_load_explicit(&p
->notify_in
,
14178 memory_order_relaxed
));
14179 json_object_int_add(json_stat
, "updatesSent",
14180 atomic_load_explicit(&p
->update_out
,
14181 memory_order_relaxed
));
14182 json_object_int_add(json_stat
, "updatesRecv",
14183 atomic_load_explicit(&p
->update_in
,
14184 memory_order_relaxed
));
14185 json_object_int_add(json_stat
, "keepalivesSent",
14186 atomic_load_explicit(&p
->keepalive_out
,
14187 memory_order_relaxed
));
14188 json_object_int_add(json_stat
, "keepalivesRecv",
14189 atomic_load_explicit(&p
->keepalive_in
,
14190 memory_order_relaxed
));
14191 json_object_int_add(json_stat
, "routeRefreshSent",
14192 atomic_load_explicit(&p
->refresh_out
,
14193 memory_order_relaxed
));
14194 json_object_int_add(json_stat
, "routeRefreshRecv",
14195 atomic_load_explicit(&p
->refresh_in
,
14196 memory_order_relaxed
));
14197 json_object_int_add(json_stat
, "capabilitySent",
14198 atomic_load_explicit(&p
->dynamic_cap_out
,
14199 memory_order_relaxed
));
14200 json_object_int_add(json_stat
, "capabilityRecv",
14201 atomic_load_explicit(&p
->dynamic_cap_in
,
14202 memory_order_relaxed
));
14203 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14204 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14205 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14207 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14208 notify_out
, notify_in
, update_out
, update_in
,
14209 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14210 dynamic_cap_out
, dynamic_cap_in
;
14211 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14212 memory_order_relaxed
);
14213 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14214 memory_order_relaxed
);
14215 open_out
= atomic_load_explicit(&p
->open_out
,
14216 memory_order_relaxed
);
14218 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14219 notify_out
= atomic_load_explicit(&p
->notify_out
,
14220 memory_order_relaxed
);
14221 notify_in
= atomic_load_explicit(&p
->notify_in
,
14222 memory_order_relaxed
);
14223 update_out
= atomic_load_explicit(&p
->update_out
,
14224 memory_order_relaxed
);
14225 update_in
= atomic_load_explicit(&p
->update_in
,
14226 memory_order_relaxed
);
14227 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14228 memory_order_relaxed
);
14229 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14230 memory_order_relaxed
);
14231 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14232 memory_order_relaxed
);
14233 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14234 memory_order_relaxed
);
14235 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14236 memory_order_relaxed
);
14237 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14238 memory_order_relaxed
);
14240 /* Packet counts. */
14241 vty_out(vty
, " Message statistics:\n");
14242 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14243 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14244 vty_out(vty
, " Sent Rcvd\n");
14245 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14247 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14249 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14251 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14253 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14255 vty_out(vty
, " Capability: %10zu %10zu\n",
14256 dynamic_cap_out
, dynamic_cap_in
);
14257 vty_out(vty
, " Total: %10u %10u\n",
14258 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14262 /* advertisement-interval */
14263 json_object_int_add(json_neigh
,
14264 "minBtwnAdvertisementRunsTimerMsecs",
14265 p
->v_routeadv
* 1000);
14267 /* Update-source. */
14268 if (p
->update_if
|| p
->update_source
) {
14270 json_object_string_add(json_neigh
,
14273 else if (p
->update_source
)
14274 json_object_string_addf(json_neigh
,
14275 "updateSource", "%pSU",
14279 /* advertisement-interval */
14281 " Minimum time between advertisement runs is %d seconds\n",
14284 /* Update-source. */
14285 if (p
->update_if
|| p
->update_source
) {
14286 vty_out(vty
, " Update source is ");
14288 vty_out(vty
, "%s", p
->update_if
);
14289 else if (p
->update_source
)
14290 vty_out(vty
, "%pSU", p
->update_source
);
14291 vty_out(vty
, "\n");
14294 vty_out(vty
, "\n");
14297 /* Address Family Information */
14298 json_object
*json_hold
= NULL
;
14301 json_hold
= json_object_new_object();
14303 FOREACH_AFI_SAFI (afi
, safi
)
14304 if (p
->afc
[afi
][safi
])
14305 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14309 json_object_object_add(json_neigh
, "addressFamilyInfo",
14311 json_object_int_add(json_neigh
, "connectionsEstablished",
14313 json_object_int_add(json_neigh
, "connectionsDropped",
14316 vty_out(vty
, " Connections established %d; dropped %d\n",
14317 p
->established
, p
->dropped
);
14319 if (!p
->last_reset
) {
14321 json_object_string_add(json_neigh
, "lastReset",
14324 vty_out(vty
, " Last reset never\n");
14330 uptime
= monotime(NULL
);
14331 uptime
-= p
->resettime
;
14332 gmtime_r(&uptime
, &tm
);
14334 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14336 + (tm
.tm_min
* 60000)
14337 + (tm
.tm_hour
* 3600000));
14338 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14340 vty_out(vty
, " Last reset %s, ",
14341 peer_uptime(p
->resettime
, timebuf
,
14342 BGP_UPTIME_LEN
, 0, NULL
));
14344 bgp_show_peer_reset(vty
, p
, NULL
, false);
14345 if (p
->last_reset_cause_size
) {
14346 msg
= p
->last_reset_cause
;
14348 " Message received that caused BGP to send a NOTIFICATION:\n ");
14349 for (i
= 1; i
<= p
->last_reset_cause_size
;
14351 vty_out(vty
, "%02X", *msg
++);
14353 if (i
!= p
->last_reset_cause_size
) {
14355 vty_out(vty
, "\n ");
14356 } else if (i
% 4 == 0) {
14361 vty_out(vty
, "\n");
14366 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14368 json_object_boolean_true_add(json_neigh
,
14369 "prefixesConfigExceedMax");
14372 " Peer had exceeded the max. no. of prefixes configured.\n");
14374 if (p
->t_pmax_restart
) {
14376 json_object_boolean_true_add(
14377 json_neigh
, "reducePrefixNumFrom");
14378 json_object_int_add(json_neigh
,
14379 "restartInTimerMsec",
14380 thread_timer_remain_second(
14385 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14386 p
->host
, thread_timer_remain_second(
14387 p
->t_pmax_restart
));
14390 json_object_boolean_true_add(
14392 "reducePrefixNumAndClearIpBgp");
14395 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14400 /* EBGP Multihop and GTSM */
14401 if (p
->sort
!= BGP_PEER_IBGP
) {
14403 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14404 json_object_int_add(json_neigh
,
14405 "externalBgpNbrMaxHopsAway",
14408 json_object_int_add(json_neigh
,
14409 "externalBgpNbrMaxHopsAway",
14412 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14414 " External BGP neighbor may be up to %d hops away.\n",
14418 " External BGP neighbor may be up to %d hops away.\n",
14423 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14424 json_object_int_add(json_neigh
,
14425 "internalBgpNbrMaxHopsAway",
14428 json_object_int_add(json_neigh
,
14429 "internalBgpNbrMaxHopsAway",
14432 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14434 " Internal BGP neighbor may be up to %d hops away.\n",
14438 " Internal BGP neighbor may be up to %d hops away.\n",
14443 /* Local address. */
14446 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14448 json_object_int_add(json_neigh
, "portLocal",
14449 ntohs(p
->su_local
->sin
.sin_port
));
14451 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14452 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14455 json_object_string_add(json_neigh
, "hostLocal",
14457 json_object_int_add(json_neigh
, "portLocal", -1);
14461 /* Remote address. */
14462 if (p
->su_remote
) {
14464 json_object_string_addf(json_neigh
, "hostForeign",
14465 "%pSU", p
->su_remote
);
14466 json_object_int_add(json_neigh
, "portForeign",
14467 ntohs(p
->su_remote
->sin
.sin_port
));
14469 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14471 ntohs(p
->su_remote
->sin
.sin_port
));
14474 json_object_string_add(json_neigh
, "hostForeign",
14476 json_object_int_add(json_neigh
, "portForeign", -1);
14480 /* Nexthop display. */
14483 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14485 json_object_string_addf(json_neigh
, "nexthopGlobal",
14486 "%pI6", &p
->nexthop
.v6_global
);
14487 json_object_string_addf(json_neigh
, "nexthopLocal",
14488 "%pI6", &p
->nexthop
.v6_local
);
14489 if (p
->shared_network
)
14490 json_object_string_add(json_neigh
,
14494 json_object_string_add(json_neigh
,
14496 "nonSharedNetwork");
14498 vty_out(vty
, "Nexthop: %s\n",
14499 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14501 vty_out(vty
, "Nexthop global: %s\n",
14502 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14504 vty_out(vty
, "Nexthop local: %s\n",
14505 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14507 vty_out(vty
, "BGP connection: %s\n",
14508 p
->shared_network
? "shared network"
14509 : "non shared network");
14513 /* Timer information. */
14515 json_object_int_add(json_neigh
, "connectRetryTimer",
14517 if (peer_established(p
) && p
->rtt
)
14518 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14521 json_object_int_add(
14522 json_neigh
, "nextStartTimerDueInMsecs",
14523 thread_timer_remain_second(p
->t_start
) * 1000);
14525 json_object_int_add(
14526 json_neigh
, "nextConnectTimerDueInMsecs",
14527 thread_timer_remain_second(p
->t_connect
)
14529 if (p
->t_routeadv
) {
14530 json_object_int_add(json_neigh
, "mraiInterval",
14532 json_object_int_add(
14533 json_neigh
, "mraiTimerExpireInMsecs",
14534 thread_timer_remain_second(p
->t_routeadv
)
14538 json_object_int_add(json_neigh
, "authenticationEnabled",
14542 json_object_string_add(json_neigh
, "readThread", "on");
14544 json_object_string_add(json_neigh
, "readThread", "off");
14546 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14547 json_object_string_add(json_neigh
, "writeThread", "on");
14549 json_object_string_add(json_neigh
, "writeThread",
14552 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14554 if (peer_established(p
) && p
->rtt
)
14555 vty_out(vty
, "Estimated round trip time: %d ms\n",
14558 vty_out(vty
, "Next start timer due in %ld seconds\n",
14559 thread_timer_remain_second(p
->t_start
));
14561 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14562 thread_timer_remain_second(p
->t_connect
));
14565 "MRAI (interval %u) timer expires in %ld seconds\n",
14567 thread_timer_remain_second(p
->t_routeadv
));
14569 vty_out(vty
, "Peer Authentication Enabled\n");
14571 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14572 p
->t_read
? "on" : "off",
14573 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14578 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14579 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14580 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14583 vty_out(vty
, "\n");
14585 /* BFD information. */
14587 bgp_bfd_show_info(vty
, p
, json_neigh
);
14590 if (p
->conf_if
) /* Configured interface name. */
14591 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14592 else /* Configured IP address. */
14593 json_object_object_add(json
, p
->host
, json_neigh
);
14597 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14598 enum show_type type
,
14599 union sockunion
*su
,
14600 const char *conf_if
, afi_t afi
,
14603 struct listnode
*node
, *nnode
;
14606 safi_t safi
= SAFI_UNICAST
;
14607 json_object
*json
= NULL
;
14608 json_object
*json_neighbor
= NULL
;
14611 json
= json_object_new_object();
14612 json_neighbor
= json_object_new_object();
14615 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14617 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14620 if ((peer
->afc
[afi
][safi
]) == 0)
14623 if (type
== show_all
) {
14624 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14628 json_object_object_add(json
, peer
->host
,
14630 json_neighbor
= NULL
;
14633 } else if (type
== show_peer
) {
14636 && !strcmp(peer
->conf_if
, conf_if
))
14638 && !strcmp(peer
->hostname
, conf_if
))) {
14640 bgp_show_peer_gr_status(vty
, peer
,
14645 if (sockunion_same(&peer
->su
, su
)) {
14647 bgp_show_peer_gr_status(vty
, peer
,
14652 if (use_json
&& find
)
14653 json_object_object_add(json
, peer
->host
,
14658 json_neighbor
= NULL
;
14663 if (type
== show_peer
&& !find
) {
14665 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14667 vty_out(vty
, "%% No such neighbor\n");
14671 json_object_free(json_neighbor
);
14672 vty_json(vty
, json
);
14674 vty_out(vty
, "\n");
14677 return CMD_SUCCESS
;
14680 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14681 enum show_type type
, union sockunion
*su
,
14682 const char *conf_if
, bool use_json
,
14685 struct listnode
*node
, *nnode
;
14688 bool nbr_output
= false;
14689 afi_t afi
= AFI_MAX
;
14690 safi_t safi
= SAFI_MAX
;
14692 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14694 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14698 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14699 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14704 bgp_show_peer(vty
, peer
, use_json
, json
);
14710 && !strcmp(peer
->conf_if
, conf_if
))
14712 && !strcmp(peer
->hostname
, conf_if
))) {
14714 bgp_show_peer(vty
, peer
, use_json
,
14718 if (sockunion_same(&peer
->su
, su
)) {
14720 bgp_show_peer(vty
, peer
, use_json
,
14725 case show_ipv4_peer
:
14726 case show_ipv6_peer
:
14727 FOREACH_SAFI (safi
) {
14728 if (peer
->afc
[afi
][safi
]) {
14731 && !strcmp(peer
->conf_if
, conf_if
))
14733 && !strcmp(peer
->hostname
, conf_if
))) {
14735 bgp_show_peer(vty
, peer
, use_json
,
14740 if (sockunion_same(&peer
->su
, su
)) {
14742 bgp_show_peer(vty
, peer
, use_json
,
14750 case show_ipv4_all
:
14751 case show_ipv6_all
:
14752 FOREACH_SAFI (safi
) {
14753 if (peer
->afc
[afi
][safi
]) {
14754 bgp_show_peer(vty
, peer
, use_json
, json
);
14763 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14764 type
== show_ipv6_peer
) && !find
) {
14766 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14768 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14771 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14772 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14773 vty_out(vty
, "%% No BGP neighbors found\n");
14776 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14777 json
, JSON_C_TO_STRING_PRETTY
));
14779 vty_out(vty
, "\n");
14782 return CMD_SUCCESS
;
14785 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14786 enum show_type type
,
14787 const char *ip_str
,
14788 afi_t afi
, bool use_json
)
14793 union sockunion su
;
14795 bgp
= bgp_get_default();
14801 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14805 ret
= str2sockunion(ip_str
, &su
);
14807 bgp_show_neighbor_graceful_restart(
14808 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14810 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14811 NULL
, afi
, use_json
);
14813 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14817 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14818 enum show_type type
,
14819 const char *ip_str
,
14822 struct listnode
*node
, *nnode
;
14824 union sockunion su
;
14825 json_object
*json
= NULL
;
14826 int ret
, is_first
= 1;
14827 bool nbr_output
= false;
14830 vty_out(vty
, "{\n");
14832 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14835 if (!(json
= json_object_new_object())) {
14837 EC_BGP_JSON_MEM_ERROR
,
14838 "Unable to allocate memory for JSON object");
14840 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14844 json_object_int_add(json
, "vrfId",
14845 (bgp
->vrf_id
== VRF_UNKNOWN
)
14847 : (int64_t)bgp
->vrf_id
);
14848 json_object_string_add(
14850 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14855 vty_out(vty
, ",\n");
14859 vty_out(vty
, "\"%s\":",
14860 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14864 vty_out(vty
, "\nInstance %s:\n",
14865 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14870 if (type
== show_peer
|| type
== show_ipv4_peer
||
14871 type
== show_ipv6_peer
) {
14872 ret
= str2sockunion(ip_str
, &su
);
14874 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14877 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14880 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14883 json_object_free(json
);
14888 vty_out(vty
, "}\n");
14889 else if (!nbr_output
)
14890 vty_out(vty
, "%% BGP instance not found\n");
14893 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14894 enum show_type type
, const char *ip_str
,
14899 union sockunion su
;
14900 json_object
*json
= NULL
;
14903 if (strmatch(name
, "all")) {
14904 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14906 return CMD_SUCCESS
;
14908 bgp
= bgp_lookup_by_name(name
);
14911 json
= json_object_new_object();
14912 vty_json(vty
, json
);
14915 "%% BGP instance not found\n");
14917 return CMD_WARNING
;
14921 bgp
= bgp_get_default();
14925 json
= json_object_new_object();
14927 ret
= str2sockunion(ip_str
, &su
);
14929 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14932 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14935 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14938 json_object_free(json
);
14941 vty_out(vty
, "{}\n");
14943 vty_out(vty
, "%% BGP instance not found\n");
14946 return CMD_SUCCESS
;
14951 /* "show [ip] bgp neighbors graceful-restart" commands. */
14952 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14953 show_ip_bgp_neighbors_graceful_restart_cmd
,
14954 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14960 "Neighbor to display information about\n"
14961 "Neighbor to display information about\n"
14962 "Neighbor on BGP configured interface\n"
14966 char *sh_arg
= NULL
;
14967 enum show_type sh_type
;
14969 afi_t afi
= AFI_MAX
;
14970 bool uj
= use_json(argc
, argv
);
14972 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14977 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14978 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14979 || argv_find(argv
, argc
, "WORD", &idx
)) {
14980 sh_type
= show_peer
;
14981 sh_arg
= argv
[idx
]->arg
;
14983 sh_type
= show_all
;
14985 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14986 return CMD_SUCCESS
;
14989 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14993 /* "show [ip] bgp neighbors" commands. */
14994 DEFUN (show_ip_bgp_neighbors
,
14995 show_ip_bgp_neighbors_cmd
,
14996 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15000 BGP_INSTANCE_HELP_STR
15003 "Detailed information on TCP and BGP neighbor connections\n"
15004 "Neighbor to display information about\n"
15005 "Neighbor to display information about\n"
15006 "Neighbor on BGP configured interface\n"
15010 char *sh_arg
= NULL
;
15011 enum show_type sh_type
;
15012 afi_t afi
= AFI_MAX
;
15014 bool uj
= use_json(argc
, argv
);
15018 /* [<vrf> VIEWVRFNAME] */
15019 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15020 vrf
= argv
[idx
+ 1]->arg
;
15021 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15023 } else if (argv_find(argv
, argc
, "view", &idx
))
15024 /* [<view> VIEWVRFNAME] */
15025 vrf
= argv
[idx
+ 1]->arg
;
15029 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15030 sh_type
= show_ipv4_all
;
15032 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15033 sh_type
= show_ipv6_all
;
15036 sh_type
= show_all
;
15039 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15040 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15041 || argv_find(argv
, argc
, "WORD", &idx
)) {
15042 sh_type
= show_peer
;
15043 sh_arg
= argv
[idx
]->arg
;
15046 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15047 sh_type
= show_ipv4_peer
;
15048 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15049 sh_type
= show_ipv6_peer
;
15052 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15055 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15056 paths' and `show ip mbgp paths'. Those functions results are the
15058 DEFUN (show_ip_bgp_paths
,
15059 show_ip_bgp_paths_cmd
,
15060 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15065 "Path information\n")
15067 vty_out(vty
, "Address Refcnt Path\n");
15068 aspath_print_all_vty(vty
);
15069 return CMD_SUCCESS
;
15074 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15077 struct community
*com
;
15079 com
= (struct community
*)bucket
->data
;
15080 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15081 community_str(com
, false, false));
15084 /* Show BGP's community internal data. */
15085 DEFUN (show_ip_bgp_community_info
,
15086 show_ip_bgp_community_info_cmd
,
15087 "show [ip] bgp community-info",
15091 "List all bgp community information\n")
15093 vty_out(vty
, "Address Refcnt Community\n");
15095 hash_iterate(community_hash(),
15096 (void (*)(struct hash_bucket
*,
15097 void *))community_show_all_iterator
,
15100 return CMD_SUCCESS
;
15103 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15106 struct lcommunity
*lcom
;
15108 lcom
= (struct lcommunity
*)bucket
->data
;
15109 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15110 lcommunity_str(lcom
, false, false));
15113 /* Show BGP's community internal data. */
15114 DEFUN (show_ip_bgp_lcommunity_info
,
15115 show_ip_bgp_lcommunity_info_cmd
,
15116 "show ip bgp large-community-info",
15120 "List all bgp large-community information\n")
15122 vty_out(vty
, "Address Refcnt Large-community\n");
15124 hash_iterate(lcommunity_hash(),
15125 (void (*)(struct hash_bucket
*,
15126 void *))lcommunity_show_all_iterator
,
15129 return CMD_SUCCESS
;
15131 /* Graceful Restart */
15133 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15140 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15142 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15144 switch (bgp_global_gr_mode
) {
15146 case GLOBAL_HELPER
:
15147 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15151 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15154 case GLOBAL_DISABLE
:
15155 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15158 case GLOBAL_INVALID
:
15160 "Global BGP GR Mode Invalid\n");
15163 vty_out(vty
, "\n");
15166 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15167 enum show_type type
,
15168 const char *ip_str
,
15169 afi_t afi
, bool use_json
)
15171 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15174 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15176 bgp_show_neighbor_graceful_restart_vty(
15177 vty
, type
, ip_str
, afi
, use_json
);
15180 } else if (afi
!= AFI_MAX
) {
15181 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15184 return CMD_ERR_INCOMPLETE
;
15187 return CMD_SUCCESS
;
15189 /* Graceful Restart */
15191 DEFUN (show_ip_bgp_attr_info
,
15192 show_ip_bgp_attr_info_cmd
,
15193 "show [ip] bgp attribute-info",
15197 "List all bgp attribute information\n")
15199 attr_show_all(vty
);
15200 return CMD_SUCCESS
;
15203 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15204 afi_t afi
, safi_t safi
,
15205 bool use_json
, json_object
*json
)
15208 struct listnode
*node
;
15211 enum vpn_policy_direction dir
;
15214 json_object
*json_import_vrfs
= NULL
;
15215 json_object
*json_export_vrfs
= NULL
;
15217 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15220 vty_json(vty
, json
);
15222 return CMD_WARNING
;
15225 /* Provide context for the block */
15226 json_object_string_add(json
, "vrf", name
? name
: "default");
15227 json_object_string_add(json
, "afiSafi",
15228 get_afi_safi_str(afi
, safi
, true));
15230 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15231 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15232 json_object_string_add(json
, "importFromVrfs", "none");
15233 json_object_string_add(json
, "importRts", "none");
15235 json_import_vrfs
= json_object_new_array();
15237 for (ALL_LIST_ELEMENTS_RO(
15238 bgp
->vpn_policy
[afi
].import_vrf
,
15240 json_object_array_add(json_import_vrfs
,
15241 json_object_new_string(vname
));
15243 json_object_object_add(json
, "importFromVrfs",
15245 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15246 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15247 ecom_str
= ecommunity_ecom2str(
15248 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15249 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15250 json_object_string_add(json
, "importRts",
15252 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15254 json_object_string_add(json
, "importRts",
15258 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15259 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15260 json_object_string_add(json
, "exportToVrfs", "none");
15261 json_object_string_add(json
, "routeDistinguisher",
15263 json_object_string_add(json
, "exportRts", "none");
15265 json_export_vrfs
= json_object_new_array();
15267 for (ALL_LIST_ELEMENTS_RO(
15268 bgp
->vpn_policy
[afi
].export_vrf
,
15270 json_object_array_add(json_export_vrfs
,
15271 json_object_new_string(vname
));
15272 json_object_object_add(json
, "exportToVrfs",
15274 json_object_string_addf(json
, "routeDistinguisher",
15276 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15278 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15279 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15280 ecom_str
= ecommunity_ecom2str(
15281 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15282 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15283 json_object_string_add(json
, "exportRts",
15285 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15287 json_object_string_add(json
, "exportRts",
15292 vty_json(vty
, json
);
15295 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15298 vty_out(vty
, "%% No such BGP instance exist\n");
15299 return CMD_WARNING
;
15302 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15303 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15305 "This VRF is not importing %s routes from any other VRF\n",
15306 get_afi_safi_str(afi
, safi
, false));
15309 "This VRF is importing %s routes from the following VRFs:\n",
15310 get_afi_safi_str(afi
, safi
, false));
15312 for (ALL_LIST_ELEMENTS_RO(
15313 bgp
->vpn_policy
[afi
].import_vrf
,
15315 vty_out(vty
, " %s\n", vname
);
15317 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15319 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15320 ecom_str
= ecommunity_ecom2str(
15321 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15322 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15323 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15325 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15327 vty_out(vty
, "Import RT(s):\n");
15330 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15331 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15333 "This VRF is not exporting %s routes to any other VRF\n",
15334 get_afi_safi_str(afi
, safi
, false));
15337 "This VRF is exporting %s routes to the following VRFs:\n",
15338 get_afi_safi_str(afi
, safi
, false));
15340 for (ALL_LIST_ELEMENTS_RO(
15341 bgp
->vpn_policy
[afi
].export_vrf
,
15343 vty_out(vty
, " %s\n", vname
);
15345 vty_out(vty
, "RD: %pRD\n",
15346 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15348 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15349 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15350 ecom_str
= ecommunity_ecom2str(
15351 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15352 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15353 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15354 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15356 vty_out(vty
, "Import RT(s):\n");
15360 return CMD_SUCCESS
;
15363 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15364 safi_t safi
, bool use_json
)
15366 struct listnode
*node
, *nnode
;
15368 char *vrf_name
= NULL
;
15369 json_object
*json
= NULL
;
15370 json_object
*json_vrf
= NULL
;
15371 json_object
*json_vrfs
= NULL
;
15374 json
= json_object_new_object();
15375 json_vrfs
= json_object_new_object();
15378 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15380 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15381 vrf_name
= bgp
->name
;
15384 json_vrf
= json_object_new_object();
15386 vty_out(vty
, "\nInstance %s:\n",
15387 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15388 ? VRF_DEFAULT_NAME
: bgp
->name
);
15390 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15392 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15393 json_object_object_add(json_vrfs
,
15394 VRF_DEFAULT_NAME
, json_vrf
);
15396 json_object_object_add(json_vrfs
, vrf_name
,
15402 json_object_object_add(json
, "vrfs", json_vrfs
);
15403 vty_json(vty
, json
);
15406 return CMD_SUCCESS
;
15409 /* "show [ip] bgp route-leak" command. */
15410 DEFUN (show_ip_bgp_route_leak
,
15411 show_ip_bgp_route_leak_cmd
,
15412 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15416 BGP_INSTANCE_HELP_STR
15419 "Route leaking information\n"
15423 afi_t afi
= AFI_MAX
;
15424 safi_t safi
= SAFI_MAX
;
15426 bool uj
= use_json(argc
, argv
);
15428 json_object
*json
= NULL
;
15430 /* show [ip] bgp */
15431 if (argv_find(argv
, argc
, "ip", &idx
)) {
15433 safi
= SAFI_UNICAST
;
15435 /* [vrf VIEWVRFNAME] */
15436 if (argv_find(argv
, argc
, "view", &idx
)) {
15438 "%% This command is not applicable to BGP views\n");
15439 return CMD_WARNING
;
15442 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15443 vrf
= argv
[idx
+ 1]->arg
;
15444 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15447 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15448 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15449 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15451 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15453 "%% This command is applicable only for unicast ipv4|ipv6\n");
15454 return CMD_WARNING
;
15457 if (vrf
&& strmatch(vrf
, "all"))
15458 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15461 json
= json_object_new_object();
15463 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15466 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15469 struct listnode
*node
, *nnode
;
15472 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15473 vty_out(vty
, "\nInstance %s:\n",
15474 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15477 update_group_show(bgp
, afi
, safi
, vty
, 0);
15481 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15482 int safi
, uint64_t subgrp_id
)
15487 if (strmatch(name
, "all")) {
15488 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15489 return CMD_SUCCESS
;
15491 bgp
= bgp_lookup_by_name(name
);
15494 bgp
= bgp_get_default();
15498 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15499 return CMD_SUCCESS
;
15502 DEFUN (show_ip_bgp_updgrps
,
15503 show_ip_bgp_updgrps_cmd
,
15504 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15508 BGP_INSTANCE_HELP_STR
15510 BGP_SAFI_WITH_LABEL_HELP_STR
15511 "Detailed info about dynamic update groups\n"
15512 "Specific subgroup to display detailed info for\n")
15515 afi_t afi
= AFI_IP6
;
15516 safi_t safi
= SAFI_UNICAST
;
15517 uint64_t subgrp_id
= 0;
15521 /* show [ip] bgp */
15522 if (argv_find(argv
, argc
, "ip", &idx
))
15524 /* [<vrf> VIEWVRFNAME] */
15525 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15526 vrf
= argv
[idx
+ 1]->arg
;
15527 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15529 } else if (argv_find(argv
, argc
, "view", &idx
))
15530 /* [<view> VIEWVRFNAME] */
15531 vrf
= argv
[idx
+ 1]->arg
;
15532 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15533 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15534 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15537 /* get subgroup id, if provided */
15539 if (argv
[idx
]->type
== VARIABLE_TKN
)
15540 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15542 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15545 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15546 show_bgp_instance_all_ipv6_updgrps_cmd
,
15547 "show [ip] bgp <view|vrf> all update-groups",
15551 BGP_INSTANCE_ALL_HELP_STR
15552 "Detailed info about dynamic update groups\n")
15554 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15555 return CMD_SUCCESS
;
15558 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15559 show_bgp_l2vpn_evpn_updgrps_cmd
,
15560 "show [ip] bgp l2vpn evpn update-groups",
15564 "l2vpn address family\n"
15565 "evpn sub-address family\n"
15566 "Detailed info about dynamic update groups\n")
15569 uint64_t subgrp_id
= 0;
15571 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15572 return CMD_SUCCESS
;
15575 DEFUN (show_bgp_updgrps_stats
,
15576 show_bgp_updgrps_stats_cmd
,
15577 "show [ip] bgp update-groups statistics",
15581 "Detailed info about dynamic update groups\n"
15586 bgp
= bgp_get_default();
15588 update_group_show_stats(bgp
, vty
);
15590 return CMD_SUCCESS
;
15593 DEFUN (show_bgp_instance_updgrps_stats
,
15594 show_bgp_instance_updgrps_stats_cmd
,
15595 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15599 BGP_INSTANCE_HELP_STR
15600 "Detailed info about dynamic update groups\n"
15606 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15608 update_group_show_stats(bgp
, vty
);
15610 return CMD_SUCCESS
;
15613 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15614 afi_t afi
, safi_t safi
,
15615 const char *what
, uint64_t subgrp_id
)
15620 bgp
= bgp_lookup_by_name(name
);
15622 bgp
= bgp_get_default();
15625 if (!strcmp(what
, "advertise-queue"))
15626 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15628 else if (!strcmp(what
, "advertised-routes"))
15629 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15631 else if (!strcmp(what
, "packet-queue"))
15632 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15637 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15638 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15639 "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",
15640 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15642 "Detailed info about dynamic update groups\n"
15643 "Specific subgroup to display info for\n"
15644 "Advertisement queue\n"
15645 "Announced routes\n"
15648 uint64_t subgrp_id
= 0;
15652 subgrp_id
= strtoull(sgid
, NULL
, 10);
15657 afiz
= bgp_vty_afi_from_str(afi
);
15661 afiz
= bgp_vty_afi_from_str(afi
);
15662 if (afiz
!= AFI_IP
)
15664 "%% Cannot specify both 'ip' and 'ipv6'\n");
15665 return CMD_WARNING
;
15668 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15670 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15671 return CMD_SUCCESS
;
15674 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15677 struct listnode
*node
, *nnode
;
15678 struct prefix
*range
;
15683 const char *peer_status
;
15687 json_object
*json_peer_group
= NULL
;
15688 json_object
*json_peer_group_afc
= NULL
;
15689 json_object
*json_peer_group_members
= NULL
;
15690 json_object
*json_peer_group_dynamic
= NULL
;
15691 json_object
*json_peer_group_dynamic_af
= NULL
;
15692 json_object
*json_peer_group_ranges
= NULL
;
15694 conf
= group
->conf
;
15697 json_peer_group
= json_object_new_object();
15698 json_peer_group_afc
= json_object_new_array();
15701 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15703 json_object_int_add(json_peer_group
, "remoteAs",
15706 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15707 group
->name
, conf
->as
);
15708 } else if (conf
->as_type
== AS_INTERNAL
) {
15710 json_object_int_add(json_peer_group
, "remoteAs",
15713 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15714 group
->name
, group
->bgp
->as
);
15717 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15720 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15722 json_object_string_add(json_peer_group
, "type",
15725 vty_out(vty
, " Peer-group type is internal\n");
15728 json_object_string_add(json_peer_group
, "type",
15731 vty_out(vty
, " Peer-group type is external\n");
15734 /* Display AFs configured. */
15736 vty_out(vty
, " Configured address-families:");
15738 FOREACH_AFI_SAFI (afi
, safi
) {
15739 if (conf
->afc
[afi
][safi
]) {
15742 json_object_array_add(
15743 json_peer_group_afc
,
15744 json_object_new_string(get_afi_safi_str(
15745 afi
, safi
, false)));
15747 vty_out(vty
, " %s;",
15748 get_afi_safi_str(afi
, safi
, false));
15753 json_object_object_add(json_peer_group
,
15754 "addressFamiliesConfigured",
15755 json_peer_group_afc
);
15758 vty_out(vty
, " none\n");
15760 vty_out(vty
, "\n");
15763 /* Display listen ranges (for dynamic neighbors), if any */
15764 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15765 lr_count
= listcount(group
->listen_range
[afi
]);
15768 if (!json_peer_group_dynamic
)
15769 json_peer_group_dynamic
=
15770 json_object_new_object();
15772 json_peer_group_dynamic_af
=
15773 json_object_new_object();
15774 json_peer_group_ranges
=
15775 json_object_new_array();
15776 json_object_int_add(json_peer_group_dynamic_af
,
15777 "count", lr_count
);
15779 vty_out(vty
, " %d %s listen range(s)\n",
15780 lr_count
, afi2str(afi
));
15783 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15788 snprintfrr(buf
, sizeof(buf
), "%pFX",
15791 json_object_array_add(
15792 json_peer_group_ranges
,
15793 json_object_new_string(buf
));
15795 vty_out(vty
, " %pFX\n", range
);
15800 json_object_object_add(
15801 json_peer_group_dynamic_af
, "ranges",
15802 json_peer_group_ranges
);
15804 json_object_object_add(
15805 json_peer_group_dynamic
, afi2str(afi
),
15806 json_peer_group_dynamic_af
);
15811 if (json_peer_group_dynamic
)
15812 json_object_object_add(json_peer_group
, "dynamicRanges",
15813 json_peer_group_dynamic
);
15815 /* Display group members and their status */
15816 if (listcount(group
->peer
)) {
15818 json_peer_group_members
= json_object_new_object();
15820 vty_out(vty
, " Peer-group members:\n");
15821 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15822 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15823 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15824 peer_status
= "Idle (Admin)";
15825 else if (CHECK_FLAG(peer
->sflags
,
15826 PEER_STATUS_PREFIX_OVERFLOW
))
15827 peer_status
= "Idle (PfxCt)";
15829 peer_status
= lookup_msg(bgp_status_msg
,
15830 peer
->status
, NULL
);
15832 dynamic
= peer_dynamic_neighbor(peer
);
15835 json_object
*json_peer_group_member
=
15836 json_object_new_object();
15838 json_object_string_add(json_peer_group_member
,
15839 "status", peer_status
);
15842 json_object_boolean_true_add(
15843 json_peer_group_member
,
15846 json_object_object_add(json_peer_group_members
,
15848 json_peer_group_member
);
15850 vty_out(vty
, " %s %s %s \n", peer
->host
,
15851 dynamic
? "(dynamic)" : "",
15856 json_object_object_add(json_peer_group
, "members",
15857 json_peer_group_members
);
15861 json_object_object_add(json
, group
->name
, json_peer_group
);
15863 return CMD_SUCCESS
;
15866 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15867 const char *group_name
, bool uj
)
15870 struct listnode
*node
, *nnode
;
15871 struct peer_group
*group
;
15872 bool found
= false;
15873 json_object
*json
= NULL
;
15876 json
= json_object_new_object();
15878 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15882 vty_json(vty
, json
);
15884 vty_out(vty
, "%% BGP instance not found\n");
15886 return CMD_WARNING
;
15889 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15891 if (strmatch(group
->name
, group_name
)) {
15892 bgp_show_one_peer_group(vty
, group
, json
);
15897 bgp_show_one_peer_group(vty
, group
, json
);
15901 if (group_name
&& !found
&& !uj
)
15902 vty_out(vty
, "%% No such peer-group\n");
15905 vty_json(vty
, json
);
15907 return CMD_SUCCESS
;
15910 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15911 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15912 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15913 "Detailed information on BGP peer groups\n"
15914 "Peer group name\n" JSON_STR
)
15918 bool uj
= use_json(argc
, argv
);
15920 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15922 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15924 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15928 /* Redistribute VTY commands. */
15930 DEFUN (bgp_redistribute_ipv4
,
15931 bgp_redistribute_ipv4_cmd
,
15932 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15933 "Redistribute information from another routing protocol\n"
15934 FRR_IP_REDIST_HELP_STR_BGPD
)
15936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15937 int idx_protocol
= 1;
15940 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15942 vty_out(vty
, "%% Invalid route type\n");
15943 return CMD_WARNING_CONFIG_FAILED
;
15946 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15947 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15951 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15952 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15953 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15955 DEFUN (bgp_redistribute_ipv4_rmap
,
15956 bgp_redistribute_ipv4_rmap_cmd
,
15957 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15958 "Redistribute information from another routing protocol\n"
15959 FRR_IP_REDIST_HELP_STR_BGPD
15960 "Route map reference\n"
15961 "Pointer to route-map entries\n")
15963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15964 int idx_protocol
= 1;
15967 struct bgp_redist
*red
;
15969 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15970 vty
, argv
[idx_word
]->arg
);
15972 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15974 vty_out(vty
, "%% Invalid route type\n");
15975 return CMD_WARNING_CONFIG_FAILED
;
15978 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15980 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15981 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15985 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15986 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15987 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15988 "Route map reference\n"
15989 "Pointer to route-map entries\n")
15991 DEFUN (bgp_redistribute_ipv4_metric
,
15992 bgp_redistribute_ipv4_metric_cmd
,
15993 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15994 "Redistribute information from another routing protocol\n"
15995 FRR_IP_REDIST_HELP_STR_BGPD
15996 "Metric for redistributed routes\n"
15997 "Default metric\n")
15999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16000 int idx_protocol
= 1;
16001 int idx_number
= 3;
16004 struct bgp_redist
*red
;
16007 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16009 vty_out(vty
, "%% Invalid route type\n");
16010 return CMD_WARNING_CONFIG_FAILED
;
16012 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16014 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16015 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16016 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16020 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16021 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16022 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16023 "Metric for redistributed routes\n"
16024 "Default metric\n")
16026 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16027 bgp_redistribute_ipv4_rmap_metric_cmd
,
16028 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16029 "Redistribute information from another routing protocol\n"
16030 FRR_IP_REDIST_HELP_STR_BGPD
16031 "Route map reference\n"
16032 "Pointer to route-map entries\n"
16033 "Metric for redistributed routes\n"
16034 "Default metric\n")
16036 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16037 int idx_protocol
= 1;
16039 int idx_number
= 5;
16042 struct bgp_redist
*red
;
16044 struct route_map
*route_map
=
16045 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16047 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16049 vty_out(vty
, "%% Invalid route type\n");
16050 return CMD_WARNING_CONFIG_FAILED
;
16052 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16054 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16056 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16057 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16058 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16062 bgp_redistribute_ipv4_rmap_metric
,
16063 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16064 "redistribute " FRR_IP_REDIST_STR_BGPD
16065 " route-map RMAP_NAME metric (0-4294967295)",
16066 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16067 "Route map reference\n"
16068 "Pointer to route-map entries\n"
16069 "Metric for redistributed routes\n"
16070 "Default metric\n")
16072 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16073 bgp_redistribute_ipv4_metric_rmap_cmd
,
16074 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16075 "Redistribute information from another routing protocol\n"
16076 FRR_IP_REDIST_HELP_STR_BGPD
16077 "Metric for redistributed routes\n"
16079 "Route map reference\n"
16080 "Pointer to route-map entries\n")
16082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16083 int idx_protocol
= 1;
16084 int idx_number
= 3;
16088 struct bgp_redist
*red
;
16090 struct route_map
*route_map
=
16091 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16093 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16095 vty_out(vty
, "%% Invalid route type\n");
16096 return CMD_WARNING_CONFIG_FAILED
;
16098 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16100 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16101 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16103 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16104 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16108 bgp_redistribute_ipv4_metric_rmap
,
16109 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16110 "redistribute " FRR_IP_REDIST_STR_BGPD
16111 " metric (0-4294967295) route-map RMAP_NAME",
16112 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16113 "Metric for redistributed routes\n"
16115 "Route map reference\n"
16116 "Pointer to route-map entries\n")
16118 DEFUN (bgp_redistribute_ipv4_ospf
,
16119 bgp_redistribute_ipv4_ospf_cmd
,
16120 "redistribute <ospf|table> (1-65535)",
16121 "Redistribute information from another routing protocol\n"
16122 "Open Shortest Path First (OSPFv2)\n"
16123 "Non-main Kernel Routing Table\n"
16124 "Instance ID/Table ID\n")
16126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16127 int idx_ospf_table
= 1;
16128 int idx_number
= 2;
16129 unsigned short instance
;
16130 unsigned short protocol
;
16132 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16134 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16135 protocol
= ZEBRA_ROUTE_OSPF
;
16137 protocol
= ZEBRA_ROUTE_TABLE
;
16139 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16140 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16143 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16144 "redistribute <ospf|table> (1-65535)",
16145 "Redistribute information from another routing protocol\n"
16146 "Open Shortest Path First (OSPFv2)\n"
16147 "Non-main Kernel Routing Table\n"
16148 "Instance ID/Table ID\n")
16150 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16151 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16152 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16153 "Redistribute information from another routing protocol\n"
16154 "Open Shortest Path First (OSPFv2)\n"
16155 "Non-main Kernel Routing Table\n"
16156 "Instance ID/Table ID\n"
16157 "Route map reference\n"
16158 "Pointer to route-map entries\n")
16160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16161 int idx_ospf_table
= 1;
16162 int idx_number
= 2;
16164 struct bgp_redist
*red
;
16165 unsigned short instance
;
16168 struct route_map
*route_map
=
16169 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16171 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16172 protocol
= ZEBRA_ROUTE_OSPF
;
16174 protocol
= ZEBRA_ROUTE_TABLE
;
16176 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16177 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16179 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16180 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16183 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16184 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16185 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16186 "Redistribute information from another routing protocol\n"
16187 "Open Shortest Path First (OSPFv2)\n"
16188 "Non-main Kernel Routing Table\n"
16189 "Instance ID/Table ID\n"
16190 "Route map reference\n"
16191 "Pointer to route-map entries\n")
16193 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16194 bgp_redistribute_ipv4_ospf_metric_cmd
,
16195 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16196 "Redistribute information from another routing protocol\n"
16197 "Open Shortest Path First (OSPFv2)\n"
16198 "Non-main Kernel Routing Table\n"
16199 "Instance ID/Table ID\n"
16200 "Metric for redistributed routes\n"
16201 "Default metric\n")
16203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16204 int idx_ospf_table
= 1;
16205 int idx_number
= 2;
16206 int idx_number_2
= 4;
16208 struct bgp_redist
*red
;
16209 unsigned short instance
;
16213 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16214 protocol
= ZEBRA_ROUTE_OSPF
;
16216 protocol
= ZEBRA_ROUTE_TABLE
;
16218 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16219 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16221 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16222 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16224 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16227 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16228 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16229 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16230 "Redistribute information from another routing protocol\n"
16231 "Open Shortest Path First (OSPFv2)\n"
16232 "Non-main Kernel Routing Table\n"
16233 "Instance ID/Table ID\n"
16234 "Metric for redistributed routes\n"
16235 "Default metric\n")
16237 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16238 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16239 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16240 "Redistribute information from another routing protocol\n"
16241 "Open Shortest Path First (OSPFv2)\n"
16242 "Non-main Kernel Routing Table\n"
16243 "Instance ID/Table ID\n"
16244 "Route map reference\n"
16245 "Pointer to route-map entries\n"
16246 "Metric for redistributed routes\n"
16247 "Default metric\n")
16249 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16250 int idx_ospf_table
= 1;
16251 int idx_number
= 2;
16253 int idx_number_2
= 6;
16255 struct bgp_redist
*red
;
16256 unsigned short instance
;
16259 struct route_map
*route_map
=
16260 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16262 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16263 protocol
= ZEBRA_ROUTE_OSPF
;
16265 protocol
= ZEBRA_ROUTE_TABLE
;
16267 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16268 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16270 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16272 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16273 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16275 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16279 bgp_redistribute_ipv4_ospf_rmap_metric
,
16280 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16281 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16282 "Redistribute information from another routing protocol\n"
16283 "Open Shortest Path First (OSPFv2)\n"
16284 "Non-main Kernel Routing Table\n"
16285 "Instance ID/Table ID\n"
16286 "Route map reference\n"
16287 "Pointer to route-map entries\n"
16288 "Metric for redistributed routes\n"
16289 "Default metric\n")
16291 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16292 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16293 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16294 "Redistribute information from another routing protocol\n"
16295 "Open Shortest Path First (OSPFv2)\n"
16296 "Non-main Kernel Routing Table\n"
16297 "Instance ID/Table ID\n"
16298 "Metric for redistributed routes\n"
16300 "Route map reference\n"
16301 "Pointer to route-map entries\n")
16303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16304 int idx_ospf_table
= 1;
16305 int idx_number
= 2;
16306 int idx_number_2
= 4;
16309 struct bgp_redist
*red
;
16310 unsigned short instance
;
16313 struct route_map
*route_map
=
16314 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16316 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16317 protocol
= ZEBRA_ROUTE_OSPF
;
16319 protocol
= ZEBRA_ROUTE_TABLE
;
16321 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16322 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16324 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16325 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16328 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16329 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16333 bgp_redistribute_ipv4_ospf_metric_rmap
,
16334 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16335 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16336 "Redistribute information from another routing protocol\n"
16337 "Open Shortest Path First (OSPFv2)\n"
16338 "Non-main Kernel Routing Table\n"
16339 "Instance ID/Table ID\n"
16340 "Metric for redistributed routes\n"
16342 "Route map reference\n"
16343 "Pointer to route-map entries\n")
16345 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16346 no_bgp_redistribute_ipv4_ospf_cmd
,
16347 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16349 "Redistribute information from another routing protocol\n"
16350 "Open Shortest Path First (OSPFv2)\n"
16351 "Non-main Kernel Routing Table\n"
16352 "Instance ID/Table ID\n"
16353 "Metric for redistributed routes\n"
16355 "Route map reference\n"
16356 "Pointer to route-map entries\n")
16358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16359 int idx_ospf_table
= 2;
16360 int idx_number
= 3;
16361 unsigned short instance
;
16364 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16365 protocol
= ZEBRA_ROUTE_OSPF
;
16367 protocol
= ZEBRA_ROUTE_TABLE
;
16369 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16370 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16374 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16375 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16377 "Redistribute information from another routing protocol\n"
16378 "Open Shortest Path First (OSPFv2)\n"
16379 "Non-main Kernel Routing Table\n"
16380 "Instance ID/Table ID\n"
16381 "Metric for redistributed routes\n"
16383 "Route map reference\n"
16384 "Pointer to route-map entries\n")
16386 DEFUN (no_bgp_redistribute_ipv4
,
16387 no_bgp_redistribute_ipv4_cmd
,
16388 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16390 "Redistribute information from another routing protocol\n"
16391 FRR_IP_REDIST_HELP_STR_BGPD
16392 "Metric for redistributed routes\n"
16394 "Route map reference\n"
16395 "Pointer to route-map entries\n")
16397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16398 int idx_protocol
= 2;
16401 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16403 vty_out(vty
, "%% Invalid route type\n");
16404 return CMD_WARNING_CONFIG_FAILED
;
16406 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16410 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16411 "no redistribute " FRR_IP_REDIST_STR_BGPD
16412 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16414 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16415 "Metric for redistributed routes\n"
16417 "Route map reference\n"
16418 "Pointer to route-map entries\n")
16420 DEFUN (bgp_redistribute_ipv6
,
16421 bgp_redistribute_ipv6_cmd
,
16422 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16423 "Redistribute information from another routing protocol\n"
16424 FRR_IP6_REDIST_HELP_STR_BGPD
)
16426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16427 int idx_protocol
= 1;
16430 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16432 vty_out(vty
, "%% Invalid route type\n");
16433 return CMD_WARNING_CONFIG_FAILED
;
16436 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16437 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16440 DEFUN (bgp_redistribute_ipv6_rmap
,
16441 bgp_redistribute_ipv6_rmap_cmd
,
16442 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16443 "Redistribute information from another routing protocol\n"
16444 FRR_IP6_REDIST_HELP_STR_BGPD
16445 "Route map reference\n"
16446 "Pointer to route-map entries\n")
16448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16449 int idx_protocol
= 1;
16452 struct bgp_redist
*red
;
16454 struct route_map
*route_map
=
16455 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16457 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16459 vty_out(vty
, "%% Invalid route type\n");
16460 return CMD_WARNING_CONFIG_FAILED
;
16463 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16465 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16466 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16469 DEFUN (bgp_redistribute_ipv6_metric
,
16470 bgp_redistribute_ipv6_metric_cmd
,
16471 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16472 "Redistribute information from another routing protocol\n"
16473 FRR_IP6_REDIST_HELP_STR_BGPD
16474 "Metric for redistributed routes\n"
16475 "Default metric\n")
16477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16478 int idx_protocol
= 1;
16479 int idx_number
= 3;
16482 struct bgp_redist
*red
;
16485 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16487 vty_out(vty
, "%% Invalid route type\n");
16488 return CMD_WARNING_CONFIG_FAILED
;
16490 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16492 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16493 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16494 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16497 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16498 bgp_redistribute_ipv6_rmap_metric_cmd
,
16499 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16500 "Redistribute information from another routing protocol\n"
16501 FRR_IP6_REDIST_HELP_STR_BGPD
16502 "Route map reference\n"
16503 "Pointer to route-map entries\n"
16504 "Metric for redistributed routes\n"
16505 "Default metric\n")
16507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16508 int idx_protocol
= 1;
16510 int idx_number
= 5;
16513 struct bgp_redist
*red
;
16515 struct route_map
*route_map
=
16516 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16518 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16520 vty_out(vty
, "%% Invalid route type\n");
16521 return CMD_WARNING_CONFIG_FAILED
;
16523 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16525 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16527 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16528 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16530 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16533 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16534 bgp_redistribute_ipv6_metric_rmap_cmd
,
16535 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16536 "Redistribute information from another routing protocol\n"
16537 FRR_IP6_REDIST_HELP_STR_BGPD
16538 "Metric for redistributed routes\n"
16540 "Route map reference\n"
16541 "Pointer to route-map entries\n")
16543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16544 int idx_protocol
= 1;
16545 int idx_number
= 3;
16549 struct bgp_redist
*red
;
16551 struct route_map
*route_map
=
16552 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16554 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16556 vty_out(vty
, "%% Invalid route type\n");
16557 return CMD_WARNING_CONFIG_FAILED
;
16559 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16561 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16562 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16565 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16566 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16569 DEFUN (no_bgp_redistribute_ipv6
,
16570 no_bgp_redistribute_ipv6_cmd
,
16571 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16573 "Redistribute information from another routing protocol\n"
16574 FRR_IP6_REDIST_HELP_STR_BGPD
16575 "Metric for redistributed routes\n"
16577 "Route map reference\n"
16578 "Pointer to route-map entries\n")
16580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16581 int idx_protocol
= 2;
16584 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16586 vty_out(vty
, "%% Invalid route type\n");
16587 return CMD_WARNING_CONFIG_FAILED
;
16590 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16593 /* Neighbor update tcp-mss. */
16594 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16595 const char *tcp_mss_str
)
16598 uint32_t tcp_mss_val
= 0;
16600 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16602 return CMD_WARNING_CONFIG_FAILED
;
16605 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16606 peer_tcp_mss_set(peer
, tcp_mss_val
);
16608 peer_tcp_mss_unset(peer
);
16611 return CMD_SUCCESS
;
16614 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16615 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16616 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16617 "TCP max segment size\n"
16620 int peer_index
= 1;
16624 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16625 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16626 argv
[mss_index
]->arg
);
16629 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16630 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16631 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16632 "TCP max segment size\n"
16635 int peer_index
= 2;
16638 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16639 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16642 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16643 "[no$no] bgp retain route-target all",
16645 "Retain BGP updates\n"
16646 "Retain BGP updates based on route-target values\n"
16647 "Retain all BGP updates\n")
16650 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16652 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16653 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16654 if (check
!= !no
) {
16656 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16657 [bgp_node_safi(vty
)],
16658 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16660 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16661 [bgp_node_safi(vty
)],
16662 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16663 /* trigger a flush to re-sync with ADJ-RIB-in */
16664 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16665 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16667 return CMD_SUCCESS
;
16670 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16671 afi_t afi
, safi_t safi
)
16675 /* Unicast redistribution only. */
16676 if (safi
!= SAFI_UNICAST
)
16679 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16680 /* Redistribute BGP does not make sense. */
16681 if (i
!= ZEBRA_ROUTE_BGP
) {
16682 struct list
*red_list
;
16683 struct listnode
*node
;
16684 struct bgp_redist
*red
;
16686 red_list
= bgp
->redist
[afi
][i
];
16690 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16691 /* "redistribute" configuration. */
16692 vty_out(vty
, " redistribute %s",
16693 zebra_route_string(i
));
16695 vty_out(vty
, " %d", red
->instance
);
16696 if (red
->redist_metric_flag
)
16697 vty_out(vty
, " metric %u",
16698 red
->redist_metric
);
16699 if (red
->rmap
.name
)
16700 vty_out(vty
, " route-map %s",
16702 vty_out(vty
, "\n");
16708 /* peer-group helpers for config-write */
16710 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16712 if (!peer_group_active(peer
)) {
16713 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16714 return !CHECK_FLAG(peer
->flags
, flag
);
16716 return !!CHECK_FLAG(peer
->flags
, flag
);
16719 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16722 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16725 if (!peer_group_active(peer
)) {
16726 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16727 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16729 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16732 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16735 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16736 uint8_t type
, int direct
)
16738 struct bgp_filter
*filter
;
16740 if (peer_group_active(peer
))
16741 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16744 filter
= &peer
->filter
[afi
][safi
];
16746 case PEER_FT_DISTRIBUTE_LIST
:
16747 return !!(filter
->dlist
[direct
].name
);
16748 case PEER_FT_FILTER_LIST
:
16749 return !!(filter
->aslist
[direct
].name
);
16750 case PEER_FT_PREFIX_LIST
:
16751 return !!(filter
->plist
[direct
].name
);
16752 case PEER_FT_ROUTE_MAP
:
16753 return !!(filter
->map
[direct
].name
);
16754 case PEER_FT_UNSUPPRESS_MAP
:
16755 return !!(filter
->usmap
.name
);
16756 case PEER_FT_ADVERTISE_MAP
:
16757 return !!(filter
->advmap
.aname
16758 && ((filter
->advmap
.condition
== direct
)
16759 && filter
->advmap
.cname
));
16765 /* Return true if the addpath type is set for peer and different from
16768 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16771 enum bgp_addpath_strat type
, g_type
;
16773 type
= peer
->addpath_type
[afi
][safi
];
16775 if (type
!= BGP_ADDPATH_NONE
) {
16776 if (peer_group_active(peer
)) {
16777 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16779 if (type
!= g_type
)
16791 /* This is part of the address-family block (unicast only) */
16792 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16796 uint32_t tovpn_sid_index
= 0;
16798 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16799 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16800 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16801 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16802 bgp
->vpn_policy
[afi
]
16803 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16805 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16806 bgp
->vpn_policy
[afi
]
16807 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16809 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16810 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16811 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16812 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16815 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16816 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16818 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16821 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16822 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16823 bgp
->vpn_policy
[afi
].tovpn_label
);
16827 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16828 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16829 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16830 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16831 } else if (tovpn_sid_index
!= 0) {
16832 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16836 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16837 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16838 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16840 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16841 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16843 char buf
[PREFIX_STRLEN
];
16844 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16845 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16848 vty_out(vty
, "%*snexthop vpn export %s\n",
16852 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16853 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16855 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16856 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16858 char *b
= ecommunity_ecom2str(
16859 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16860 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16861 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16862 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16864 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16865 char *b
= ecommunity_ecom2str(
16866 bgp
->vpn_policy
[afi
]
16867 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16868 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16869 ECOMMUNITY_ROUTE_TARGET
);
16870 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16871 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16873 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16874 char *b
= ecommunity_ecom2str(
16875 bgp
->vpn_policy
[afi
]
16876 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16877 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16878 ECOMMUNITY_ROUTE_TARGET
);
16879 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16880 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16884 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16885 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16886 bgp
->vpn_policy
[afi
]
16887 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16889 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16890 char *b
= ecommunity_ecom2str(
16891 bgp
->vpn_policy
[afi
]
16892 .import_redirect_rtlist
,
16893 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16894 ECOMMUNITY_ROUTE_TARGET
);
16896 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16897 != ECOMMUNITY_SIZE
)
16898 vty_out(vty
, "%*srt6 redirect import %s\n",
16901 vty_out(vty
, "%*srt redirect import %s\n",
16903 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16907 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16908 afi_t afi
, safi_t safi
)
16910 struct bgp_filter
*filter
;
16914 filter
= &peer
->filter
[afi
][safi
];
16916 /* distribute-list. */
16917 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16919 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16920 filter
->dlist
[FILTER_IN
].name
);
16922 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16924 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16925 filter
->dlist
[FILTER_OUT
].name
);
16928 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16930 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16931 filter
->plist
[FILTER_IN
].name
);
16933 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16935 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16936 filter
->plist
[FILTER_OUT
].name
);
16939 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16940 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16941 filter
->map
[RMAP_IN
].name
);
16943 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16945 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16946 filter
->map
[RMAP_OUT
].name
);
16948 /* unsuppress-map */
16949 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16950 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16951 filter
->usmap
.name
);
16953 /* advertise-map : always applied in OUT direction*/
16954 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16955 CONDITION_NON_EXIST
))
16957 " neighbor %s advertise-map %s non-exist-map %s\n",
16958 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16960 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16962 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16963 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16966 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16968 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16969 filter
->aslist
[FILTER_IN
].name
);
16971 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16973 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16974 filter
->aslist
[FILTER_OUT
].name
);
16977 /* BGP peer configuration display function. */
16978 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16981 struct peer
*g_peer
= NULL
;
16983 int if_pg_printed
= false;
16984 int if_ras_printed
= false;
16986 /* Skip dynamic neighbors. */
16987 if (peer_dynamic_neighbor(peer
))
16991 addr
= peer
->conf_if
;
16995 /************************************
16996 ****** Global to the neighbor ******
16997 ************************************/
16998 if (peer
->conf_if
) {
16999 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17000 vty_out(vty
, " neighbor %s interface v6only", addr
);
17002 vty_out(vty
, " neighbor %s interface", addr
);
17004 if (peer_group_active(peer
)) {
17005 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17006 if_pg_printed
= true;
17007 } else if (peer
->as_type
== AS_SPECIFIED
) {
17008 vty_out(vty
, " remote-as %u", peer
->as
);
17009 if_ras_printed
= true;
17010 } else if (peer
->as_type
== AS_INTERNAL
) {
17011 vty_out(vty
, " remote-as internal");
17012 if_ras_printed
= true;
17013 } else if (peer
->as_type
== AS_EXTERNAL
) {
17014 vty_out(vty
, " remote-as external");
17015 if_ras_printed
= true;
17018 vty_out(vty
, "\n");
17021 /* remote-as and peer-group */
17022 /* peer is a member of a peer-group */
17023 if (peer_group_active(peer
)) {
17024 g_peer
= peer
->group
->conf
;
17026 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17027 if (peer
->as_type
== AS_SPECIFIED
) {
17028 vty_out(vty
, " neighbor %s remote-as %u\n",
17030 } else if (peer
->as_type
== AS_INTERNAL
) {
17032 " neighbor %s remote-as internal\n",
17034 } else if (peer
->as_type
== AS_EXTERNAL
) {
17036 " neighbor %s remote-as external\n",
17041 /* For swpX peers we displayed the peer-group
17042 * via 'neighbor swpX interface peer-group PGNAME' */
17043 if (!if_pg_printed
)
17044 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17045 peer
->group
->name
);
17048 /* peer is NOT a member of a peer-group */
17050 /* peer is a peer-group, declare the peer-group */
17051 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17052 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17055 if (!if_ras_printed
) {
17056 if (peer
->as_type
== AS_SPECIFIED
) {
17057 vty_out(vty
, " neighbor %s remote-as %u\n",
17059 } else if (peer
->as_type
== AS_INTERNAL
) {
17061 " neighbor %s remote-as internal\n",
17063 } else if (peer
->as_type
== AS_EXTERNAL
) {
17065 " neighbor %s remote-as external\n",
17072 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17073 vty_out(vty
, " neighbor %s local-as %u", addr
,
17074 peer
->change_local_as
);
17075 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17076 vty_out(vty
, " no-prepend");
17077 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17078 vty_out(vty
, " replace-as");
17079 vty_out(vty
, "\n");
17084 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17088 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17089 if (peer
->tx_shutdown_message
)
17090 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17091 peer
->tx_shutdown_message
);
17093 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17096 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17097 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17098 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17101 if (peer
->bfd_config
)
17102 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17105 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17106 vty_out(vty
, " neighbor %s password %s\n", addr
,
17109 /* neighbor solo */
17110 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17111 if (!peer_group_active(peer
)) {
17112 vty_out(vty
, " neighbor %s solo\n", addr
);
17117 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17118 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17121 /* Local interface name */
17122 if (peer
->ifname
) {
17123 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17126 /* TCP max segment size */
17127 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17128 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17131 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17132 vty_out(vty
, " neighbor %s passive\n", addr
);
17134 /* ebgp-multihop */
17135 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17136 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17137 && peer
->ttl
== MAXTTL
)) {
17138 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17139 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17145 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17146 peer
->local_role
!= ROLE_UNDEFINED
)
17147 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17148 bgp_get_name_by_role(peer
->local_role
),
17149 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17153 /* ttl-security hops */
17154 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17155 if (!peer_group_active(peer
)
17156 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17157 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17158 addr
, peer
->gtsm_hops
);
17162 /* disable-connected-check */
17163 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17164 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17166 /* link-bw-encoding-ieee */
17167 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17168 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17171 /* extended-optional-parameters */
17172 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17173 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17176 /* enforce-first-as */
17177 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17178 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17180 /* update-source */
17181 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17182 if (peer
->update_source
)
17183 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17184 peer
->update_source
);
17185 else if (peer
->update_if
)
17186 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17190 /* advertisement-interval */
17191 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17192 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17196 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17197 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17198 peer
->keepalive
, peer
->holdtime
);
17200 /* timers connect */
17201 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17202 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17204 /* need special-case handling for changed default values due to
17205 * config profile / version (because there is no "timers bgp connect"
17206 * command, we need to save this per-peer :/)
17208 else if (!peer_group_active(peer
) && !peer
->connect
&&
17209 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17210 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17211 peer
->bgp
->default_connect_retry
);
17213 /* timers delayopen */
17214 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17215 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17217 /* Save config even though flag is not set if default values have been
17220 else if (!peer_group_active(peer
) && !peer
->delayopen
17221 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17222 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17223 peer
->bgp
->default_delayopen
);
17225 /* capability dynamic */
17226 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17227 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17229 /* capability extended-nexthop */
17230 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17231 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17234 " no neighbor %s capability extended-nexthop\n",
17236 else if (!peer
->conf_if
)
17238 " neighbor %s capability extended-nexthop\n",
17242 /* dont-capability-negotiation */
17243 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17244 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17246 /* override-capability */
17247 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17248 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17250 /* strict-capability-match */
17251 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17252 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17254 /* Sender side AS path loop detection. */
17255 if (peer
->as_path_loop_detection
)
17256 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17259 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17260 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17262 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17263 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17265 " neighbor %s graceful-restart-helper\n", addr
);
17266 } else if (CHECK_FLAG(
17267 peer
->peer_gr_new_status_flag
,
17268 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17270 " neighbor %s graceful-restart\n", addr
);
17272 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17273 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17275 peer
->peer_gr_new_status_flag
,
17276 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17277 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17283 /* BGP peer configuration display function. */
17284 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17285 struct peer
*peer
, afi_t afi
, safi_t safi
)
17287 struct peer
*g_peer
= NULL
;
17289 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17291 /* Skip dynamic neighbors. */
17292 if (peer_dynamic_neighbor(peer
))
17296 addr
= peer
->conf_if
;
17300 /************************************
17301 ****** Per AF to the neighbor ******
17302 ************************************/
17303 if (peer_group_active(peer
)) {
17304 g_peer
= peer
->group
->conf
;
17306 /* If the peer-group is active but peer is not, print a 'no
17308 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17309 vty_out(vty
, " no neighbor %s activate\n", addr
);
17312 /* If the peer-group is not active but peer is, print an
17314 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17315 vty_out(vty
, " neighbor %s activate\n", addr
);
17318 if (peer
->afc
[afi
][safi
]) {
17319 if (safi
== SAFI_ENCAP
)
17320 vty_out(vty
, " neighbor %s activate\n", addr
);
17321 else if (!bgp
->default_af
[afi
][safi
])
17322 vty_out(vty
, " neighbor %s activate\n", addr
);
17324 if (bgp
->default_af
[afi
][safi
])
17325 vty_out(vty
, " no neighbor %s activate\n",
17330 /* addpath TX knobs */
17331 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17332 switch (peer
->addpath_type
[afi
][safi
]) {
17333 case BGP_ADDPATH_ALL
:
17334 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17337 case BGP_ADDPATH_BEST_PER_AS
:
17339 " neighbor %s addpath-tx-bestpath-per-AS\n",
17342 case BGP_ADDPATH_MAX
:
17343 case BGP_ADDPATH_NONE
:
17348 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17349 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17351 /* ORF capability. */
17352 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17353 || peergroup_af_flag_check(peer
, afi
, safi
,
17354 PEER_FLAG_ORF_PREFIX_RM
)) {
17355 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17357 if (peergroup_af_flag_check(peer
, afi
, safi
,
17358 PEER_FLAG_ORF_PREFIX_SM
)
17359 && peergroup_af_flag_check(peer
, afi
, safi
,
17360 PEER_FLAG_ORF_PREFIX_RM
))
17361 vty_out(vty
, " both");
17362 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17363 PEER_FLAG_ORF_PREFIX_SM
))
17364 vty_out(vty
, " send");
17366 vty_out(vty
, " receive");
17367 vty_out(vty
, "\n");
17370 /* Route reflector client. */
17371 if (peergroup_af_flag_check(peer
, afi
, safi
,
17372 PEER_FLAG_REFLECTOR_CLIENT
)) {
17373 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17376 /* next-hop-self force */
17377 if (peergroup_af_flag_check(peer
, afi
, safi
,
17378 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17379 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17382 /* next-hop-self */
17383 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17384 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17387 /* remove-private-AS */
17388 if (peergroup_af_flag_check(peer
, afi
, safi
,
17389 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17390 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17394 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17395 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17396 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17400 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17401 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17402 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17405 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17406 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17407 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17411 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17412 vty_out(vty
, " neighbor %s as-override\n", addr
);
17415 /* send-community print. */
17416 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17417 PEER_FLAG_SEND_COMMUNITY
);
17418 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17419 PEER_FLAG_SEND_EXT_COMMUNITY
);
17420 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17421 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17423 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17424 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17427 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17430 " no neighbor %s send-community extended\n",
17434 vty_out(vty
, " no neighbor %s send-community large\n",
17438 /* Default information */
17439 if (peergroup_af_flag_check(peer
, afi
, safi
,
17440 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17441 vty_out(vty
, " neighbor %s default-originate", addr
);
17443 if (peer
->default_rmap
[afi
][safi
].name
)
17444 vty_out(vty
, " route-map %s",
17445 peer
->default_rmap
[afi
][safi
].name
);
17447 vty_out(vty
, "\n");
17450 /* Soft reconfiguration inbound. */
17451 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17452 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17456 /* maximum-prefix. */
17457 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17458 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17459 peer
->pmax
[afi
][safi
]);
17461 if (peer
->pmax_threshold
[afi
][safi
]
17462 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17463 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17464 if (peer_af_flag_check(peer
, afi
, safi
,
17465 PEER_FLAG_MAX_PREFIX_WARNING
))
17466 vty_out(vty
, " warning-only");
17467 if (peer
->pmax_restart
[afi
][safi
])
17468 vty_out(vty
, " restart %u",
17469 peer
->pmax_restart
[afi
][safi
]);
17470 if (peer_af_flag_check(peer
, afi
, safi
,
17471 PEER_FLAG_MAX_PREFIX_FORCE
))
17472 vty_out(vty
, " force");
17474 vty_out(vty
, "\n");
17477 /* maximum-prefix-out */
17478 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17479 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17480 addr
, peer
->pmax_out
[afi
][safi
]);
17482 /* Route server client. */
17483 if (peergroup_af_flag_check(peer
, afi
, safi
,
17484 PEER_FLAG_RSERVER_CLIENT
)) {
17485 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17488 /* Nexthop-local unchanged. */
17489 if (peergroup_af_flag_check(peer
, afi
, safi
,
17490 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17491 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17494 /* allowas-in <1-10> */
17495 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17496 if (peer_af_flag_check(peer
, afi
, safi
,
17497 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17498 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17499 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17500 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17502 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17503 peer
->allowas_in
[afi
][safi
]);
17508 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17509 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17512 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17513 char *soo_str
= ecommunity_ecom2str(
17514 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17516 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17517 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17521 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17522 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17523 peer
->weight
[afi
][safi
]);
17526 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17528 /* atribute-unchanged. */
17529 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17530 || (safi
!= SAFI_EVPN
17531 && peer_af_flag_check(peer
, afi
, safi
,
17532 PEER_FLAG_NEXTHOP_UNCHANGED
))
17533 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17535 if (!peer_group_active(peer
)
17536 || peergroup_af_flag_check(peer
, afi
, safi
,
17537 PEER_FLAG_AS_PATH_UNCHANGED
)
17538 || peergroup_af_flag_check(peer
, afi
, safi
,
17539 PEER_FLAG_NEXTHOP_UNCHANGED
)
17540 || peergroup_af_flag_check(peer
, afi
, safi
,
17541 PEER_FLAG_MED_UNCHANGED
)) {
17544 " neighbor %s attribute-unchanged%s%s%s\n",
17546 peer_af_flag_check(peer
, afi
, safi
,
17547 PEER_FLAG_AS_PATH_UNCHANGED
)
17550 peer_af_flag_check(peer
, afi
, safi
,
17551 PEER_FLAG_NEXTHOP_UNCHANGED
)
17554 peer_af_flag_check(peer
, afi
, safi
,
17555 PEER_FLAG_MED_UNCHANGED
)
17561 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
17562 vty_out(vty
, " neighbor %s optimal-route-reflection %s\n",
17563 addr
, peer
->orr_group_name
[afi
][safi
]);
17566 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17569 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17570 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17571 vty_out(vty
, " no bgp retain route-target all\n");
17574 /* Address family based peer configuration display. */
17575 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17579 struct peer_group
*group
;
17580 struct listnode
*node
, *nnode
;
17583 vty_frame(vty
, " !\n address-family ");
17584 if (afi
== AFI_IP
) {
17585 if (safi
== SAFI_UNICAST
)
17586 vty_frame(vty
, "ipv4 unicast");
17587 else if (safi
== SAFI_LABELED_UNICAST
)
17588 vty_frame(vty
, "ipv4 labeled-unicast");
17589 else if (safi
== SAFI_MULTICAST
)
17590 vty_frame(vty
, "ipv4 multicast");
17591 else if (safi
== SAFI_MPLS_VPN
)
17592 vty_frame(vty
, "ipv4 vpn");
17593 else if (safi
== SAFI_ENCAP
)
17594 vty_frame(vty
, "ipv4 encap");
17595 else if (safi
== SAFI_FLOWSPEC
)
17596 vty_frame(vty
, "ipv4 flowspec");
17597 } else if (afi
== AFI_IP6
) {
17598 if (safi
== SAFI_UNICAST
)
17599 vty_frame(vty
, "ipv6 unicast");
17600 else if (safi
== SAFI_LABELED_UNICAST
)
17601 vty_frame(vty
, "ipv6 labeled-unicast");
17602 else if (safi
== SAFI_MULTICAST
)
17603 vty_frame(vty
, "ipv6 multicast");
17604 else if (safi
== SAFI_MPLS_VPN
)
17605 vty_frame(vty
, "ipv6 vpn");
17606 else if (safi
== SAFI_ENCAP
)
17607 vty_frame(vty
, "ipv6 encap");
17608 else if (safi
== SAFI_FLOWSPEC
)
17609 vty_frame(vty
, "ipv6 flowspec");
17610 } else if (afi
== AFI_L2VPN
) {
17611 if (safi
== SAFI_EVPN
)
17612 vty_frame(vty
, "l2vpn evpn");
17614 vty_frame(vty
, "\n");
17616 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17618 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17620 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17622 /* BGP flag dampening. */
17623 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17624 bgp_config_write_damp(vty
, afi
, safi
);
17626 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17627 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17629 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17630 /* Do not display doppelganger peers */
17631 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17632 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17635 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17636 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17638 if (safi
== SAFI_EVPN
)
17639 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17641 if (safi
== SAFI_FLOWSPEC
)
17642 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17644 if (safi
== SAFI_MPLS_VPN
)
17645 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17647 if (safi
== SAFI_UNICAST
) {
17648 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17649 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17650 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17652 vty_out(vty
, " export vpn\n");
17654 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17655 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17657 vty_out(vty
, " import vpn\n");
17659 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17660 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17663 for (ALL_LIST_ELEMENTS_RO(
17664 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17666 vty_out(vty
, " import vrf %s\n", name
);
17670 /* Optimal Route Reflection */
17671 bgp_config_write_orr(vty
, bgp
, afi
, safi
);
17673 vty_endframe(vty
, " exit-address-family\n");
17676 int bgp_config_write(struct vty
*vty
)
17679 struct peer_group
*group
;
17681 struct listnode
*node
, *nnode
;
17682 struct listnode
*mnode
, *mnnode
;
17685 uint32_t tovpn_sid_index
= 0;
17687 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17688 vty_out(vty
, "bgp route-map delay-timer %u\n",
17689 bm
->rmap_update_timer
);
17691 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17692 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17693 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17694 vty_out(vty
, " %d", bm
->v_establish_wait
);
17695 vty_out(vty
, "\n");
17698 if (bm
->wait_for_fib
)
17699 vty_out(vty
, "bgp suppress-fib-pending\n");
17701 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17702 vty_out(vty
, "bgp graceful-shutdown\n");
17704 /* No-RIB (Zebra) option flag configuration */
17705 if (bgp_option_check(BGP_OPT_NO_FIB
))
17706 vty_out(vty
, "bgp no-rib\n");
17708 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17709 vty_out(vty
, "bgp send-extra-data zebra\n");
17711 /* BGP session DSCP value */
17712 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17713 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17715 /* BGP configuration. */
17716 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17718 /* skip all auto created vrf as they dont have user config */
17719 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17722 /* Router bgp ASN */
17723 vty_out(vty
, "router bgp %u", bgp
->as
);
17726 vty_out(vty
, " %s %s",
17727 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17728 ? "view" : "vrf", bgp
->name
);
17729 vty_out(vty
, "\n");
17731 /* BGP fast-external-failover. */
17732 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17733 vty_out(vty
, " no bgp fast-external-failover\n");
17735 /* BGP router ID. */
17736 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17737 vty_out(vty
, " bgp router-id %pI4\n",
17738 &bgp
->router_id_static
);
17740 /* Suppress fib pending */
17741 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17742 vty_out(vty
, " bgp suppress-fib-pending\n");
17744 /* BGP log-neighbor-changes. */
17745 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17746 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17747 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17748 CHECK_FLAG(bgp
->flags
,
17749 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17753 /* BGP configuration. */
17754 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17755 vty_out(vty
, " bgp always-compare-med\n");
17757 /* RFC8212 default eBGP policy. */
17758 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17759 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17760 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17761 CHECK_FLAG(bgp
->flags
,
17762 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17766 /* draft-ietf-idr-deprecate-as-set-confed-set */
17767 if (bgp
->reject_as_sets
)
17768 vty_out(vty
, " bgp reject-as-sets\n");
17770 /* Suppress duplicate updates if the route actually not changed
17772 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17773 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17774 vty_out(vty
, " %sbgp suppress-duplicates\n",
17775 CHECK_FLAG(bgp
->flags
,
17776 BGP_FLAG_SUPPRESS_DUPLICATES
)
17780 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17782 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17783 SAVE_BGP_HARD_ADMIN_RESET
)
17784 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17785 CHECK_FLAG(bgp
->flags
,
17786 BGP_FLAG_HARD_ADMIN_RESET
)
17790 /* BGP default <afi>-<safi> */
17791 FOREACH_AFI_SAFI (afi
, safi
) {
17792 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17793 if (!bgp
->default_af
[afi
][safi
])
17794 vty_out(vty
, " no bgp default %s\n",
17795 get_bgp_default_af_flag(afi
,
17797 } else if (bgp
->default_af
[afi
][safi
])
17798 vty_out(vty
, " bgp default %s\n",
17799 get_bgp_default_af_flag(afi
, safi
));
17802 /* BGP default local-preference. */
17803 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17804 vty_out(vty
, " bgp default local-preference %u\n",
17805 bgp
->default_local_pref
);
17807 /* BGP default show-hostname */
17808 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17809 != SAVE_BGP_SHOW_HOSTNAME
)
17810 vty_out(vty
, " %sbgp default show-hostname\n",
17811 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17815 /* BGP default show-nexthop-hostname */
17816 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17817 != SAVE_BGP_SHOW_HOSTNAME
)
17818 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17819 CHECK_FLAG(bgp
->flags
,
17820 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17824 /* BGP default subgroup-pkt-queue-max. */
17825 if (bgp
->default_subgroup_pkt_queue_max
17826 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17827 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17828 bgp
->default_subgroup_pkt_queue_max
);
17830 /* BGP client-to-client reflection. */
17831 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17832 vty_out(vty
, " no bgp client-to-client reflection\n");
17834 /* BGP cluster ID. */
17835 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17836 vty_out(vty
, " bgp cluster-id %pI4\n",
17839 /* Disable ebgp connected nexthop check */
17840 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17842 " bgp disable-ebgp-connected-route-check\n");
17844 /* Confederation identifier*/
17845 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17846 vty_out(vty
, " bgp confederation identifier %u\n",
17849 /* Confederation peer */
17850 if (bgp
->confed_peers_cnt
> 0) {
17853 vty_out(vty
, " bgp confederation peers");
17855 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17856 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17858 vty_out(vty
, "\n");
17861 /* BGP deterministic-med. */
17862 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17863 != SAVE_BGP_DETERMINISTIC_MED
)
17864 vty_out(vty
, " %sbgp deterministic-med\n",
17865 CHECK_FLAG(bgp
->flags
,
17866 BGP_FLAG_DETERMINISTIC_MED
)
17870 /* BGP update-delay. */
17871 bgp_config_write_update_delay(vty
, bgp
);
17873 if (bgp
->v_maxmed_onstartup
17874 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17875 vty_out(vty
, " bgp max-med on-startup %u",
17876 bgp
->v_maxmed_onstartup
);
17877 if (bgp
->maxmed_onstartup_value
17878 != BGP_MAXMED_VALUE_DEFAULT
)
17879 vty_out(vty
, " %u",
17880 bgp
->maxmed_onstartup_value
);
17881 vty_out(vty
, "\n");
17883 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17884 vty_out(vty
, " bgp max-med administrative");
17885 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17886 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17887 vty_out(vty
, "\n");
17891 bgp_config_write_wpkt_quanta(vty
, bgp
);
17893 bgp_config_write_rpkt_quanta(vty
, bgp
);
17895 /* coalesce time */
17896 bgp_config_write_coalesce_time(vty
, bgp
);
17898 /* BGP per-instance graceful-shutdown */
17899 /* BGP-wide settings and per-instance settings are mutually
17902 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17903 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17904 vty_out(vty
, " bgp graceful-shutdown\n");
17906 /* Long-lived Graceful Restart */
17907 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17909 " bgp long-lived-graceful-restart stale-time %u\n",
17910 bgp
->llgr_stale_time
);
17912 /* BGP graceful-restart. */
17913 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17915 " bgp graceful-restart stalepath-time %u\n",
17916 bgp
->stalepath_time
);
17918 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17919 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17920 bgp
->restart_time
);
17922 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17923 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17924 vty_out(vty
, " %sbgp graceful-restart notification\n",
17925 CHECK_FLAG(bgp
->flags
,
17926 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17930 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17932 " bgp graceful-restart select-defer-time %u\n",
17933 bgp
->select_defer_time
);
17935 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17936 vty_out(vty
, " bgp graceful-restart\n");
17938 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17939 vty_out(vty
, " bgp graceful-restart-disable\n");
17941 /* BGP graceful-restart Preserve State F bit. */
17942 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17944 " bgp graceful-restart preserve-fw-state\n");
17946 /* BGP TCP keepalive */
17947 bgp_config_tcp_keepalive(vty
, bgp
);
17949 /* Stale timer for RIB */
17950 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17952 " bgp graceful-restart rib-stale-time %u\n",
17953 bgp
->rib_stale_time
);
17955 /* BGP bestpath method. */
17956 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17957 vty_out(vty
, " bgp bestpath as-path ignore\n");
17958 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17959 vty_out(vty
, " bgp bestpath as-path confed\n");
17961 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17962 if (CHECK_FLAG(bgp
->flags
,
17963 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17965 " bgp bestpath as-path multipath-relax as-set\n");
17968 " bgp bestpath as-path multipath-relax\n");
17972 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17974 " bgp route-reflector allow-outbound-policy\n");
17976 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17977 vty_out(vty
, " bgp bestpath compare-routerid\n");
17978 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17979 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17980 vty_out(vty
, " bgp bestpath med");
17981 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17982 vty_out(vty
, " confed");
17983 if (CHECK_FLAG(bgp
->flags
,
17984 BGP_FLAG_MED_MISSING_AS_WORST
))
17985 vty_out(vty
, " missing-as-worst");
17986 vty_out(vty
, "\n");
17989 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17991 " bgp bestpath peer-type multipath-relax\n");
17993 /* Link bandwidth handling. */
17994 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17995 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17996 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17997 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17998 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17999 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18001 /* BGP network import check. */
18002 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18003 != SAVE_BGP_IMPORT_CHECK
)
18004 vty_out(vty
, " %sbgp network import-check\n",
18005 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18009 /* BGP timers configuration. */
18010 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18011 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18012 vty_out(vty
, " timers bgp %u %u\n",
18013 bgp
->default_keepalive
, bgp
->default_holdtime
);
18015 /* BGP minimum holdtime configuration. */
18016 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18017 && bgp
->default_min_holdtime
!= 0)
18018 vty_out(vty
, " bgp minimum-holdtime %u\n",
18019 bgp
->default_min_holdtime
);
18021 /* Conditional advertisement timer configuration */
18022 if (bgp
->condition_check_period
18023 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18025 " bgp conditional-advertisement timer %u\n",
18026 bgp
->condition_check_period
);
18029 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18030 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18033 /* Normal neighbor configuration. */
18034 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18035 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18036 bgp_config_write_peer_global(vty
, bgp
, peer
);
18039 /* listen range and limit for dynamic BGP neighbors */
18040 bgp_config_write_listen(vty
, bgp
);
18043 * BGP default autoshutdown neighbors
18045 * This must be placed after any peer and peer-group
18046 * configuration, to avoid setting all peers to shutdown after
18047 * a daemon restart, which is undesired behavior. (see #2286)
18049 if (bgp
->autoshutdown
)
18050 vty_out(vty
, " bgp default shutdown\n");
18052 /* BGP instance administrative shutdown */
18053 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18054 vty_out(vty
, " bgp shutdown\n");
18056 if (bgp
->allow_martian
)
18057 vty_out(vty
, " bgp allow-martian-nexthop\n");
18059 if (bgp
->fast_convergence
)
18060 vty_out(vty
, " bgp fast-convergence\n");
18062 if (bgp
->srv6_enabled
) {
18063 vty_frame(vty
, " !\n segment-routing srv6\n");
18064 if (strlen(bgp
->srv6_locator_name
))
18065 vty_out(vty
, " locator %s\n",
18066 bgp
->srv6_locator_name
);
18067 vty_endframe(vty
, " exit\n");
18070 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18071 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18072 vty_out(vty
, " sid vpn per-vrf export auto\n");
18073 } else if (tovpn_sid_index
!= 0) {
18074 vty_out(vty
, " sid vpn per-vrf export %d\n",
18078 /* IPv4 unicast configuration. */
18079 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18081 /* IPv4 multicast configuration. */
18082 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18084 /* IPv4 labeled-unicast configuration. */
18085 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18087 /* IPv4 VPN configuration. */
18088 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18090 /* ENCAPv4 configuration. */
18091 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18093 /* FLOWSPEC v4 configuration. */
18094 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18096 /* IPv6 unicast configuration. */
18097 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18099 /* IPv6 multicast configuration. */
18100 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18102 /* IPv6 labeled-unicast configuration. */
18103 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18104 SAFI_LABELED_UNICAST
);
18106 /* IPv6 VPN configuration. */
18107 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18109 /* ENCAPv6 configuration. */
18110 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18112 /* FLOWSPEC v6 configuration. */
18113 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18115 /* EVPN configuration. */
18116 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18118 hook_call(bgp_inst_config_write
, bgp
, vty
);
18120 #ifdef ENABLE_BGP_VNC
18121 bgp_rfapi_cfg_write(vty
, bgp
);
18124 vty_out(vty
, "exit\n");
18125 vty_out(vty
, "!\n");
18131 /* BGP node structure. */
18132 static struct cmd_node bgp_node
= {
18135 .parent_node
= CONFIG_NODE
,
18136 .prompt
= "%s(config-router)# ",
18137 .config_write
= bgp_config_write
,
18140 static struct cmd_node bgp_ipv4_unicast_node
= {
18141 .name
= "bgp ipv4 unicast",
18142 .node
= BGP_IPV4_NODE
,
18143 .parent_node
= BGP_NODE
,
18144 .prompt
= "%s(config-router-af)# ",
18148 static struct cmd_node bgp_ipv4_multicast_node
= {
18149 .name
= "bgp ipv4 multicast",
18150 .node
= BGP_IPV4M_NODE
,
18151 .parent_node
= BGP_NODE
,
18152 .prompt
= "%s(config-router-af)# ",
18156 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18157 .name
= "bgp ipv4 labeled unicast",
18158 .node
= BGP_IPV4L_NODE
,
18159 .parent_node
= BGP_NODE
,
18160 .prompt
= "%s(config-router-af)# ",
18164 static struct cmd_node bgp_ipv6_unicast_node
= {
18165 .name
= "bgp ipv6 unicast",
18166 .node
= BGP_IPV6_NODE
,
18167 .parent_node
= BGP_NODE
,
18168 .prompt
= "%s(config-router-af)# ",
18172 static struct cmd_node bgp_ipv6_multicast_node
= {
18173 .name
= "bgp ipv6 multicast",
18174 .node
= BGP_IPV6M_NODE
,
18175 .parent_node
= BGP_NODE
,
18176 .prompt
= "%s(config-router-af)# ",
18180 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18181 .name
= "bgp ipv6 labeled unicast",
18182 .node
= BGP_IPV6L_NODE
,
18183 .parent_node
= BGP_NODE
,
18184 .prompt
= "%s(config-router-af)# ",
18188 static struct cmd_node bgp_vpnv4_node
= {
18189 .name
= "bgp vpnv4",
18190 .node
= BGP_VPNV4_NODE
,
18191 .parent_node
= BGP_NODE
,
18192 .prompt
= "%s(config-router-af)# ",
18196 static struct cmd_node bgp_vpnv6_node
= {
18197 .name
= "bgp vpnv6",
18198 .node
= BGP_VPNV6_NODE
,
18199 .parent_node
= BGP_NODE
,
18200 .prompt
= "%s(config-router-af-vpnv6)# ",
18204 static struct cmd_node bgp_evpn_node
= {
18205 .name
= "bgp evpn",
18206 .node
= BGP_EVPN_NODE
,
18207 .parent_node
= BGP_NODE
,
18208 .prompt
= "%s(config-router-evpn)# ",
18212 static struct cmd_node bgp_evpn_vni_node
= {
18213 .name
= "bgp evpn vni",
18214 .node
= BGP_EVPN_VNI_NODE
,
18215 .parent_node
= BGP_EVPN_NODE
,
18216 .prompt
= "%s(config-router-af-vni)# ",
18219 static struct cmd_node bgp_flowspecv4_node
= {
18220 .name
= "bgp ipv4 flowspec",
18221 .node
= BGP_FLOWSPECV4_NODE
,
18222 .parent_node
= BGP_NODE
,
18223 .prompt
= "%s(config-router-af)# ",
18227 static struct cmd_node bgp_flowspecv6_node
= {
18228 .name
= "bgp ipv6 flowspec",
18229 .node
= BGP_FLOWSPECV6_NODE
,
18230 .parent_node
= BGP_NODE
,
18231 .prompt
= "%s(config-router-af-vpnv6)# ",
18235 static struct cmd_node bgp_srv6_node
= {
18236 .name
= "bgp srv6",
18237 .node
= BGP_SRV6_NODE
,
18238 .parent_node
= BGP_NODE
,
18239 .prompt
= "%s(config-router-srv6)# ",
18242 static void community_list_vty(void);
18244 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18247 struct peer_group
*group
;
18248 struct listnode
*lnbgp
, *lnpeer
;
18250 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18251 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18253 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18257 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18261 struct listnode
*lnbgp
, *lnpeer
;
18263 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18264 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18265 /* only provide suggestions on the appropriate input
18267 * they'll otherwise show up multiple times */
18268 enum cmd_token_type match_type
;
18269 char *name
= peer
->host
;
18271 if (peer
->conf_if
) {
18272 match_type
= VARIABLE_TKN
;
18273 name
= peer
->conf_if
;
18274 } else if (strchr(peer
->host
, ':'))
18275 match_type
= IPV6_TKN
;
18277 match_type
= IPV4_TKN
;
18279 if (token
->type
!= match_type
)
18282 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18287 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18289 bgp_ac_peer(comps
, token
);
18291 if (token
->type
== VARIABLE_TKN
)
18292 bgp_ac_peergroup(comps
, token
);
18295 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18296 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18297 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18298 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18299 {.completions
= NULL
}};
18301 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18302 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18303 {.completions
= NULL
} };
18305 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18307 static struct thread
*t_bgp_cfg
;
18309 bool bgp_config_inprocess(void)
18311 return thread_is_scheduled(t_bgp_cfg
);
18314 static void bgp_config_finish(struct thread
*t
)
18316 struct listnode
*node
;
18319 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18320 hook_call(bgp_config_end
, bgp
);
18323 static void bgp_config_start(void)
18325 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18326 THREAD_OFF(t_bgp_cfg
);
18327 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18328 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18331 /* When we receive a hook the configuration is read,
18332 * we start a timer to make sure we postpone sending
18333 * EoR before route-maps are processed.
18334 * This is especially valid if using `bgp route-map delay-timer`.
18336 static void bgp_config_end(void)
18338 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18339 uint32_t bgp_post_config_delay
=
18340 thread_is_scheduled(bm
->t_rmap_update
)
18341 ? thread_timer_remain_second(bm
->t_rmap_update
)
18342 : BGP_POST_CONFIG_DELAY_SECONDS
;
18344 /* If BGP config processing thread isn't running, then
18345 * we can return and rely it's properly handled.
18347 if (!bgp_config_inprocess())
18350 THREAD_OFF(t_bgp_cfg
);
18352 /* Start a new timer to make sure we don't send EoR
18353 * before route-maps are processed.
18355 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18356 bgp_post_config_delay
, &t_bgp_cfg
);
18359 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18362 struct interface
*ifp
;
18363 struct bgp_interface
*iifp
;
18365 FOR_ALL_INTERFACES (vrf
, ifp
) {
18370 if_vty_config_start(vty
, ifp
);
18372 if (CHECK_FLAG(iifp
->flags
,
18373 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18374 vty_out(vty
, " mpls bgp forwarding\n");
18378 if_vty_config_end(vty
);
18384 /* Configuration write function for bgpd. */
18385 static int config_write_interface(struct vty
*vty
)
18388 struct vrf
*vrf
= NULL
;
18390 /* Display all VRF aware OSPF interface configuration */
18391 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18392 write
+= config_write_interface_one(vty
, vrf
);
18398 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18399 "[no$no] mpls bgp forwarding",
18400 NO_STR MPLS_STR BGP_STR
18401 "Enable MPLS forwarding for eBGP directly connected peers\n")
18404 struct bgp_interface
*iifp
;
18406 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18409 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18410 return CMD_WARNING_CONFIG_FAILED
;
18412 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18413 if (check
!= !no
) {
18415 UNSET_FLAG(iifp
->flags
,
18416 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18418 SET_FLAG(iifp
->flags
,
18419 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18420 /* trigger a nht update on eBGP sessions */
18421 if (if_is_operative(ifp
))
18422 bgp_nht_ifp_up(ifp
);
18424 return CMD_SUCCESS
;
18427 /* Initialization of BGP interface. */
18428 static void bgp_vty_if_init(void)
18430 /* Install interface node. */
18431 if_cmd_init(config_write_interface
);
18433 /* "mpls bgp forwarding" commands. */
18434 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18437 void bgp_vty_init(void)
18439 cmd_variable_handler_register(bgp_var_neighbor
);
18440 cmd_variable_handler_register(bgp_var_peergroup
);
18442 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18444 /* Install bgp top node. */
18445 install_node(&bgp_node
);
18446 install_node(&bgp_ipv4_unicast_node
);
18447 install_node(&bgp_ipv4_multicast_node
);
18448 install_node(&bgp_ipv4_labeled_unicast_node
);
18449 install_node(&bgp_ipv6_unicast_node
);
18450 install_node(&bgp_ipv6_multicast_node
);
18451 install_node(&bgp_ipv6_labeled_unicast_node
);
18452 install_node(&bgp_vpnv4_node
);
18453 install_node(&bgp_vpnv6_node
);
18454 install_node(&bgp_evpn_node
);
18455 install_node(&bgp_evpn_vni_node
);
18456 install_node(&bgp_flowspecv4_node
);
18457 install_node(&bgp_flowspecv6_node
);
18458 install_node(&bgp_srv6_node
);
18460 /* Install default VTY commands to new nodes. */
18461 install_default(BGP_NODE
);
18462 install_default(BGP_IPV4_NODE
);
18463 install_default(BGP_IPV4M_NODE
);
18464 install_default(BGP_IPV4L_NODE
);
18465 install_default(BGP_IPV6_NODE
);
18466 install_default(BGP_IPV6M_NODE
);
18467 install_default(BGP_IPV6L_NODE
);
18468 install_default(BGP_VPNV4_NODE
);
18469 install_default(BGP_VPNV6_NODE
);
18470 install_default(BGP_FLOWSPECV4_NODE
);
18471 install_default(BGP_FLOWSPECV6_NODE
);
18472 install_default(BGP_EVPN_NODE
);
18473 install_default(BGP_EVPN_VNI_NODE
);
18474 install_default(BGP_SRV6_NODE
);
18476 /* "bgp local-mac" hidden commands. */
18477 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18478 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18480 /* "bgp suppress-fib-pending" global */
18481 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18483 /* bgp route-map delay-timer commands. */
18484 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18485 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18487 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18489 /* bgp fast-convergence command */
18490 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18491 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18493 /* global bgp update-delay command */
18494 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18495 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18497 /* global bgp graceful-shutdown command */
18498 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18499 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18501 /* Dummy commands (Currently not supported) */
18502 install_element(BGP_NODE
, &no_synchronization_cmd
);
18503 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18505 /* "router bgp" commands. */
18506 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18508 /* "no router bgp" commands. */
18509 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18511 /* "bgp session-dscp command */
18512 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18513 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18515 /* "bgp router-id" commands. */
18516 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18519 /* "bgp suppress-fib-pending" command */
18520 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18522 /* "bgp cluster-id" commands. */
18523 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18524 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18526 /* "bgp no-rib" commands. */
18527 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18528 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18530 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18532 /* "bgp confederation" commands. */
18533 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18534 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18536 /* "bgp confederation peers" commands. */
18537 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18538 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18540 /* bgp max-med command */
18541 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18542 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18543 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18544 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18545 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18547 /* "neighbor role" commands. */
18548 install_element(BGP_NODE
, &neighbor_role_cmd
);
18549 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18550 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18552 /* bgp disable-ebgp-connected-nh-check */
18553 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18554 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18556 /* bgp update-delay command */
18557 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18558 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18560 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18561 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18563 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18564 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18566 /* "maximum-paths" commands. */
18567 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18568 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18569 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18570 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18571 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18572 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18573 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18574 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18575 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18576 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18577 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18578 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18579 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18580 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18581 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18583 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18584 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18585 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18586 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18587 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18588 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18589 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18590 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18591 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18592 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18594 /* "timers bgp" commands. */
18595 install_element(BGP_NODE
, &bgp_timers_cmd
);
18596 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18598 /* "minimum-holdtime" commands. */
18599 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18600 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18602 /* route-map delay-timer commands - per instance for backwards compat.
18604 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18605 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18607 /* "bgp client-to-client reflection" commands */
18608 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18609 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18611 /* "bgp always-compare-med" commands */
18612 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18613 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18615 /* bgp ebgp-requires-policy */
18616 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18617 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18619 /* bgp suppress-duplicates */
18620 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18621 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18623 /* bgp reject-as-sets */
18624 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18625 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18627 /* "bgp deterministic-med" commands */
18628 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18629 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18631 /* "bgp graceful-restart" command */
18632 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18633 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18635 /* "bgp graceful-restart-disable" command */
18636 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18637 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18639 /* "neighbor a:b:c:d graceful-restart" command */
18640 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18641 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18643 /* "neighbor a:b:c:d graceful-restart-disable" command */
18644 install_element(BGP_NODE
,
18645 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18646 install_element(BGP_NODE
,
18647 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18649 /* "neighbor a:b:c:d graceful-restart-helper" command */
18650 install_element(BGP_NODE
,
18651 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18652 install_element(BGP_NODE
,
18653 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18655 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18656 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18657 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18658 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18659 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18660 install_element(BGP_NODE
,
18661 &no_bgp_graceful_restart_select_defer_time_cmd
);
18662 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18663 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18664 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18666 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18667 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18668 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18669 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18671 /* "bgp graceful-shutdown" commands */
18672 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18673 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18675 /* "bgp hard-administrative-reset" commands */
18676 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18678 /* "bgp long-lived-graceful-restart" commands */
18679 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18680 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18682 /* "bgp fast-external-failover" commands */
18683 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18684 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18686 /* "bgp bestpath compare-routerid" commands */
18687 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18688 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18690 /* "bgp bestpath as-path ignore" commands */
18691 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18692 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18694 /* "bgp bestpath as-path confed" commands */
18695 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18696 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18698 /* "bgp bestpath as-path multipath-relax" commands */
18699 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18700 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18702 /* "bgp bestpath peer-type multipath-relax" commands */
18703 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18704 install_element(BGP_NODE
,
18705 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18707 /* "bgp log-neighbor-changes" commands */
18708 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18709 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18711 /* "bgp bestpath med" commands */
18712 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18713 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18715 /* "bgp bestpath bandwidth" commands */
18716 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18717 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18719 /* "no bgp default <afi>-<safi>" commands. */
18720 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18722 /* "bgp network import-check" commands. */
18723 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18724 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18725 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18727 /* "bgp default local-preference" commands. */
18728 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18729 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18731 /* bgp default show-hostname */
18732 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18733 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18735 /* bgp default show-nexthop-hostname */
18736 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18737 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18739 /* "bgp default subgroup-pkt-queue-max" commands. */
18740 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18741 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18743 /* bgp ibgp-allow-policy-mods command */
18744 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18745 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18747 /* "bgp listen limit" commands. */
18748 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18749 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18751 /* "bgp listen range" commands. */
18752 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18753 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18755 /* "bgp default shutdown" command */
18756 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18758 /* "bgp shutdown" commands */
18759 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18760 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18761 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18762 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18764 /* "neighbor remote-as" commands. */
18765 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18766 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18767 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18768 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18769 install_element(BGP_NODE
,
18770 &neighbor_interface_v6only_config_remote_as_cmd
);
18771 install_element(BGP_NODE
, &no_neighbor_cmd
);
18772 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18774 /* "neighbor peer-group" commands. */
18775 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18776 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18777 install_element(BGP_NODE
,
18778 &no_neighbor_interface_peer_group_remote_as_cmd
);
18780 /* "neighbor local-as" commands. */
18781 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18782 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18783 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18784 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18786 /* "neighbor solo" commands. */
18787 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18788 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18790 /* "neighbor password" commands. */
18791 install_element(BGP_NODE
, &neighbor_password_cmd
);
18792 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18794 /* "neighbor activate" commands. */
18795 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18796 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18797 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18798 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18799 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18800 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18801 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18802 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18803 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18804 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18805 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18806 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18808 /* "no neighbor activate" commands. */
18809 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18810 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18811 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18812 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18813 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18814 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18815 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18816 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18817 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18818 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18819 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18820 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18822 /* "neighbor peer-group" set commands. */
18823 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18824 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18825 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18826 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18827 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18828 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18829 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18830 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18831 install_element(BGP_FLOWSPECV4_NODE
,
18832 &neighbor_set_peer_group_hidden_cmd
);
18833 install_element(BGP_FLOWSPECV6_NODE
,
18834 &neighbor_set_peer_group_hidden_cmd
);
18836 /* "no neighbor peer-group unset" commands. */
18837 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18838 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18839 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18840 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18841 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18842 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18843 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18844 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18845 install_element(BGP_FLOWSPECV4_NODE
,
18846 &no_neighbor_set_peer_group_hidden_cmd
);
18847 install_element(BGP_FLOWSPECV6_NODE
,
18848 &no_neighbor_set_peer_group_hidden_cmd
);
18850 /* "neighbor softreconfiguration inbound" commands.*/
18851 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18852 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18853 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18854 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18855 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18856 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18857 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18858 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18859 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18860 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18861 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18862 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18863 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18864 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18865 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18866 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18867 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18868 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18869 install_element(BGP_FLOWSPECV4_NODE
,
18870 &neighbor_soft_reconfiguration_cmd
);
18871 install_element(BGP_FLOWSPECV4_NODE
,
18872 &no_neighbor_soft_reconfiguration_cmd
);
18873 install_element(BGP_FLOWSPECV6_NODE
,
18874 &neighbor_soft_reconfiguration_cmd
);
18875 install_element(BGP_FLOWSPECV6_NODE
,
18876 &no_neighbor_soft_reconfiguration_cmd
);
18877 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18878 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18880 /* "neighbor attribute-unchanged" commands. */
18881 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18882 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18883 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18884 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18885 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18886 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18887 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18888 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18889 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18890 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18891 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18892 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18893 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18894 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18895 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18896 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18897 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18898 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18900 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18901 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18903 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18904 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18905 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18906 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18908 /* "nexthop-local unchanged" commands */
18909 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18910 install_element(BGP_IPV6_NODE
,
18911 &no_neighbor_nexthop_local_unchanged_cmd
);
18913 /* "neighbor next-hop-self" commands. */
18914 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18915 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18916 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18917 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18918 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18919 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18921 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18922 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18923 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18924 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18925 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18926 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18927 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18928 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18929 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18930 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18931 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18932 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18933 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18935 /* "neighbor next-hop-self force" commands. */
18936 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18937 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18938 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18939 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18940 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18941 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18942 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18943 install_element(BGP_IPV4_NODE
,
18944 &no_neighbor_nexthop_self_all_hidden_cmd
);
18945 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18946 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18947 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18948 install_element(BGP_IPV4M_NODE
,
18949 &no_neighbor_nexthop_self_all_hidden_cmd
);
18950 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18951 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18952 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18953 install_element(BGP_IPV4L_NODE
,
18954 &no_neighbor_nexthop_self_all_hidden_cmd
);
18955 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18956 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18957 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18958 install_element(BGP_IPV6_NODE
,
18959 &no_neighbor_nexthop_self_all_hidden_cmd
);
18960 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18961 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18962 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18963 install_element(BGP_IPV6M_NODE
,
18964 &no_neighbor_nexthop_self_all_hidden_cmd
);
18965 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18966 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18967 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18968 install_element(BGP_IPV6L_NODE
,
18969 &no_neighbor_nexthop_self_all_hidden_cmd
);
18970 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18971 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18972 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18973 install_element(BGP_VPNV4_NODE
,
18974 &no_neighbor_nexthop_self_all_hidden_cmd
);
18975 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18976 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18977 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18978 install_element(BGP_VPNV6_NODE
,
18979 &no_neighbor_nexthop_self_all_hidden_cmd
);
18980 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18981 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18983 /* "neighbor as-override" commands. */
18984 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18985 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18986 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18987 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18988 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18989 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18990 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18991 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18992 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18993 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18994 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18995 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18996 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18997 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18998 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18999 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19000 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19001 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19003 /* "neighbor remove-private-AS" commands. */
19004 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19005 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19006 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19007 install_element(BGP_NODE
,
19008 &no_neighbor_remove_private_as_all_hidden_cmd
);
19009 install_element(BGP_NODE
,
19010 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19011 install_element(BGP_NODE
,
19012 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19013 install_element(BGP_NODE
,
19014 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19017 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19018 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19019 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19020 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19021 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19022 install_element(BGP_IPV4_NODE
,
19023 &neighbor_remove_private_as_replace_as_cmd
);
19024 install_element(BGP_IPV4_NODE
,
19025 &no_neighbor_remove_private_as_replace_as_cmd
);
19026 install_element(BGP_IPV4_NODE
,
19027 &neighbor_remove_private_as_all_replace_as_cmd
);
19028 install_element(BGP_IPV4_NODE
,
19029 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19030 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19031 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19032 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19033 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19034 install_element(BGP_IPV4M_NODE
,
19035 &neighbor_remove_private_as_replace_as_cmd
);
19036 install_element(BGP_IPV4M_NODE
,
19037 &no_neighbor_remove_private_as_replace_as_cmd
);
19038 install_element(BGP_IPV4M_NODE
,
19039 &neighbor_remove_private_as_all_replace_as_cmd
);
19040 install_element(BGP_IPV4M_NODE
,
19041 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19042 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19043 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19044 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19045 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19046 install_element(BGP_IPV4L_NODE
,
19047 &neighbor_remove_private_as_replace_as_cmd
);
19048 install_element(BGP_IPV4L_NODE
,
19049 &no_neighbor_remove_private_as_replace_as_cmd
);
19050 install_element(BGP_IPV4L_NODE
,
19051 &neighbor_remove_private_as_all_replace_as_cmd
);
19052 install_element(BGP_IPV4L_NODE
,
19053 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19054 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19055 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19056 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19057 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19058 install_element(BGP_IPV6_NODE
,
19059 &neighbor_remove_private_as_replace_as_cmd
);
19060 install_element(BGP_IPV6_NODE
,
19061 &no_neighbor_remove_private_as_replace_as_cmd
);
19062 install_element(BGP_IPV6_NODE
,
19063 &neighbor_remove_private_as_all_replace_as_cmd
);
19064 install_element(BGP_IPV6_NODE
,
19065 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19066 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19067 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19068 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19069 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19070 install_element(BGP_IPV6M_NODE
,
19071 &neighbor_remove_private_as_replace_as_cmd
);
19072 install_element(BGP_IPV6M_NODE
,
19073 &no_neighbor_remove_private_as_replace_as_cmd
);
19074 install_element(BGP_IPV6M_NODE
,
19075 &neighbor_remove_private_as_all_replace_as_cmd
);
19076 install_element(BGP_IPV6M_NODE
,
19077 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19078 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19079 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19080 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19081 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19082 install_element(BGP_IPV6L_NODE
,
19083 &neighbor_remove_private_as_replace_as_cmd
);
19084 install_element(BGP_IPV6L_NODE
,
19085 &no_neighbor_remove_private_as_replace_as_cmd
);
19086 install_element(BGP_IPV6L_NODE
,
19087 &neighbor_remove_private_as_all_replace_as_cmd
);
19088 install_element(BGP_IPV6L_NODE
,
19089 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19090 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19091 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19092 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19093 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19094 install_element(BGP_VPNV4_NODE
,
19095 &neighbor_remove_private_as_replace_as_cmd
);
19096 install_element(BGP_VPNV4_NODE
,
19097 &no_neighbor_remove_private_as_replace_as_cmd
);
19098 install_element(BGP_VPNV4_NODE
,
19099 &neighbor_remove_private_as_all_replace_as_cmd
);
19100 install_element(BGP_VPNV4_NODE
,
19101 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19102 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19103 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19104 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19105 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19106 install_element(BGP_VPNV6_NODE
,
19107 &neighbor_remove_private_as_replace_as_cmd
);
19108 install_element(BGP_VPNV6_NODE
,
19109 &no_neighbor_remove_private_as_replace_as_cmd
);
19110 install_element(BGP_VPNV6_NODE
,
19111 &neighbor_remove_private_as_all_replace_as_cmd
);
19112 install_element(BGP_VPNV6_NODE
,
19113 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19115 /* "neighbor send-community" commands.*/
19116 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19117 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19118 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19119 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19120 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19121 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19122 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19123 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19124 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19125 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19126 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19127 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19128 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19129 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19130 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19131 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19132 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19133 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19134 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19135 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19136 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19137 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19138 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19139 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19140 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19141 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19142 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19143 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19144 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19145 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19146 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19147 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19148 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19149 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19150 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19151 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19153 /* "neighbor route-reflector" commands.*/
19154 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19155 install_element(BGP_NODE
,
19156 &no_neighbor_route_reflector_client_hidden_cmd
);
19157 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19158 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19159 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19160 install_element(BGP_IPV4M_NODE
,
19161 &no_neighbor_route_reflector_client_cmd
);
19162 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19163 install_element(BGP_IPV4L_NODE
,
19164 &no_neighbor_route_reflector_client_cmd
);
19165 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19166 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19167 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19168 install_element(BGP_IPV6M_NODE
,
19169 &no_neighbor_route_reflector_client_cmd
);
19170 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19171 install_element(BGP_IPV6L_NODE
,
19172 &no_neighbor_route_reflector_client_cmd
);
19173 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19174 install_element(BGP_VPNV4_NODE
,
19175 &no_neighbor_route_reflector_client_cmd
);
19176 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19177 install_element(BGP_VPNV6_NODE
,
19178 &no_neighbor_route_reflector_client_cmd
);
19179 install_element(BGP_FLOWSPECV4_NODE
,
19180 &neighbor_route_reflector_client_cmd
);
19181 install_element(BGP_FLOWSPECV4_NODE
,
19182 &no_neighbor_route_reflector_client_cmd
);
19183 install_element(BGP_FLOWSPECV6_NODE
,
19184 &neighbor_route_reflector_client_cmd
);
19185 install_element(BGP_FLOWSPECV6_NODE
,
19186 &no_neighbor_route_reflector_client_cmd
);
19187 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19188 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19190 /* "optimal-route-reflection" commands */
19191 install_element(BGP_IPV4_NODE
, &optimal_route_reflection_cmd
);
19192 install_element(BGP_IPV4M_NODE
, &optimal_route_reflection_cmd
);
19193 install_element(BGP_IPV4L_NODE
, &optimal_route_reflection_cmd
);
19194 install_element(BGP_IPV6_NODE
, &optimal_route_reflection_cmd
);
19195 install_element(BGP_IPV6M_NODE
, &optimal_route_reflection_cmd
);
19196 install_element(BGP_IPV6L_NODE
, &optimal_route_reflection_cmd
);
19197 install_element(BGP_VPNV4_NODE
, &optimal_route_reflection_cmd
);
19198 install_element(BGP_VPNV6_NODE
, &optimal_route_reflection_cmd
);
19199 install_element(BGP_FLOWSPECV4_NODE
, &optimal_route_reflection_cmd
);
19200 install_element(BGP_FLOWSPECV6_NODE
, &optimal_route_reflection_cmd
);
19201 install_element(BGP_EVPN_NODE
, &optimal_route_reflection_cmd
);
19203 /* "neighbor optimal-route-reflection" commands */
19204 install_element(BGP_IPV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19205 install_element(BGP_IPV4M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19206 install_element(BGP_IPV4L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19207 install_element(BGP_IPV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19208 install_element(BGP_IPV6M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19209 install_element(BGP_IPV6L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19210 install_element(BGP_VPNV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19211 install_element(BGP_VPNV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19212 install_element(BGP_FLOWSPECV4_NODE
,
19213 &neighbor_optimal_route_reflection_cmd
);
19214 install_element(BGP_FLOWSPECV6_NODE
,
19215 &neighbor_optimal_route_reflection_cmd
);
19216 install_element(BGP_EVPN_NODE
, &neighbor_optimal_route_reflection_cmd
);
19218 /* "neighbor route-server" commands.*/
19219 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19220 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19221 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19222 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19223 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19224 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19225 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19226 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19227 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19228 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19229 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19230 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19231 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19232 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19233 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19234 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19235 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19236 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19237 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19238 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19239 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19240 install_element(BGP_FLOWSPECV4_NODE
,
19241 &no_neighbor_route_server_client_cmd
);
19242 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19243 install_element(BGP_FLOWSPECV6_NODE
,
19244 &no_neighbor_route_server_client_cmd
);
19246 /* "neighbor disable-addpath-rx" commands. */
19247 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19248 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19249 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19250 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19251 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19252 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19253 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19254 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19255 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19256 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19257 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19258 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19259 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19260 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19261 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19262 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19264 /* "neighbor addpath-tx-all-paths" commands.*/
19265 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19266 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19267 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19268 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19269 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19270 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19271 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19272 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19273 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19274 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19275 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19276 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19277 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19278 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19279 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19280 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19281 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19282 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19284 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19285 install_element(BGP_NODE
,
19286 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19287 install_element(BGP_NODE
,
19288 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19289 install_element(BGP_IPV4_NODE
,
19290 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19291 install_element(BGP_IPV4_NODE
,
19292 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19293 install_element(BGP_IPV4M_NODE
,
19294 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19295 install_element(BGP_IPV4M_NODE
,
19296 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19297 install_element(BGP_IPV4L_NODE
,
19298 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19299 install_element(BGP_IPV4L_NODE
,
19300 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19301 install_element(BGP_IPV6_NODE
,
19302 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19303 install_element(BGP_IPV6_NODE
,
19304 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19305 install_element(BGP_IPV6M_NODE
,
19306 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19307 install_element(BGP_IPV6M_NODE
,
19308 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19309 install_element(BGP_IPV6L_NODE
,
19310 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19311 install_element(BGP_IPV6L_NODE
,
19312 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19313 install_element(BGP_VPNV4_NODE
,
19314 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19315 install_element(BGP_VPNV4_NODE
,
19316 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19317 install_element(BGP_VPNV6_NODE
,
19318 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19319 install_element(BGP_VPNV6_NODE
,
19320 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19322 /* "neighbor sender-as-path-loop-detection" commands. */
19323 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19324 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19326 /* "neighbor passive" commands. */
19327 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19328 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19331 /* "neighbor shutdown" commands. */
19332 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19333 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19334 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19335 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19336 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19337 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19339 /* "neighbor capability extended-nexthop" commands.*/
19340 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19341 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19343 /* "neighbor capability orf prefix-list" commands.*/
19344 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19345 install_element(BGP_NODE
,
19346 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19347 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19348 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19349 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19350 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19351 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19352 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19353 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19354 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19355 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19356 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19357 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19358 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19360 /* "neighbor capability dynamic" commands.*/
19361 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19362 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19364 /* "neighbor dont-capability-negotiate" commands. */
19365 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19366 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19368 /* "neighbor ebgp-multihop" commands. */
19369 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19370 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19371 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19373 /* "neighbor disable-connected-check" commands. */
19374 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19375 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19377 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19378 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19379 install_element(BGP_NODE
,
19380 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19382 /* "neighbor extended-optional-parameters" commands. */
19383 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19384 install_element(BGP_NODE
,
19385 &no_neighbor_extended_optional_parameters_cmd
);
19387 /* "neighbor enforce-first-as" commands. */
19388 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19389 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19391 /* "neighbor description" commands. */
19392 install_element(BGP_NODE
, &neighbor_description_cmd
);
19393 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19394 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19396 /* "neighbor update-source" commands. "*/
19397 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19398 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19400 /* "neighbor default-originate" commands. */
19401 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19402 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19403 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19404 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19405 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19406 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19407 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19408 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19409 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19410 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19411 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19412 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19413 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19414 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19415 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19416 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19417 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19418 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19419 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19420 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19421 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19423 /* "neighbor port" commands. */
19424 install_element(BGP_NODE
, &neighbor_port_cmd
);
19425 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19427 /* "neighbor weight" commands. */
19428 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19429 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19431 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19432 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19433 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19434 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19435 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19436 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19437 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19438 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19439 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19440 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19441 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19442 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19443 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19444 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19445 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19446 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19448 /* "neighbor override-capability" commands. */
19449 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19450 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19452 /* "neighbor strict-capability-match" commands. */
19453 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19454 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19456 /* "neighbor timers" commands. */
19457 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19458 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19460 /* "neighbor timers connect" commands. */
19461 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19462 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19464 /* "neighbor timers delayopen" commands. */
19465 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19466 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19468 /* "neighbor advertisement-interval" commands. */
19469 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19470 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19472 /* "neighbor interface" commands. */
19473 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19474 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19476 /* "neighbor distribute" commands. */
19477 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19478 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19479 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19480 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19481 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19482 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19483 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19484 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19485 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19486 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19487 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19488 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19489 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19490 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19491 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19492 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19493 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19494 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19496 /* "neighbor prefix-list" commands. */
19497 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19498 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19499 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19500 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19501 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19502 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19503 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19504 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19505 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19506 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19507 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19508 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19509 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19510 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19511 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19512 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19513 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19514 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19515 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19516 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19517 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19518 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19520 /* "neighbor filter-list" commands. */
19521 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19522 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19523 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19524 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19525 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19526 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19527 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19528 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19529 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19530 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19531 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19532 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19533 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19534 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19535 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19536 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19537 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19538 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19539 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19540 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19541 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19542 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19544 /* "neighbor route-map" commands. */
19545 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19546 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19547 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19548 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19549 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19550 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19551 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19552 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19553 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19554 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19555 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19556 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19557 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19558 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19559 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19560 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19561 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19562 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19563 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19564 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19565 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19566 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19567 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19568 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19570 /* "neighbor unsuppress-map" commands. */
19571 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19572 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19573 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19574 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19575 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19576 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19577 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19578 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19579 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19580 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19581 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19582 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19583 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19584 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19585 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19586 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19587 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19588 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19590 /* "neighbor advertise-map" commands. */
19591 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19592 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19593 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19594 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19595 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19596 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19597 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19598 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19599 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19600 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19602 /* neighbor maximum-prefix-out commands. */
19603 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19604 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19605 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19606 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19607 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19608 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19609 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19610 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19611 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19612 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19613 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19614 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19615 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19616 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19617 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19618 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19619 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19620 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19622 /* "neighbor maximum-prefix" commands. */
19623 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19624 install_element(BGP_NODE
,
19625 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19626 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19627 install_element(BGP_NODE
,
19628 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19629 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19630 install_element(BGP_NODE
,
19631 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19632 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19633 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19634 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19635 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19636 install_element(BGP_IPV4_NODE
,
19637 &neighbor_maximum_prefix_threshold_warning_cmd
);
19638 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19639 install_element(BGP_IPV4_NODE
,
19640 &neighbor_maximum_prefix_threshold_restart_cmd
);
19641 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19642 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19643 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19644 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19645 install_element(BGP_IPV4M_NODE
,
19646 &neighbor_maximum_prefix_threshold_warning_cmd
);
19647 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19648 install_element(BGP_IPV4M_NODE
,
19649 &neighbor_maximum_prefix_threshold_restart_cmd
);
19650 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19651 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19652 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19653 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19654 install_element(BGP_IPV4L_NODE
,
19655 &neighbor_maximum_prefix_threshold_warning_cmd
);
19656 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19657 install_element(BGP_IPV4L_NODE
,
19658 &neighbor_maximum_prefix_threshold_restart_cmd
);
19659 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19660 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19661 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19662 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19663 install_element(BGP_IPV6_NODE
,
19664 &neighbor_maximum_prefix_threshold_warning_cmd
);
19665 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19666 install_element(BGP_IPV6_NODE
,
19667 &neighbor_maximum_prefix_threshold_restart_cmd
);
19668 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19669 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19670 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19671 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19672 install_element(BGP_IPV6M_NODE
,
19673 &neighbor_maximum_prefix_threshold_warning_cmd
);
19674 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19675 install_element(BGP_IPV6M_NODE
,
19676 &neighbor_maximum_prefix_threshold_restart_cmd
);
19677 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19678 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19679 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19680 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19681 install_element(BGP_IPV6L_NODE
,
19682 &neighbor_maximum_prefix_threshold_warning_cmd
);
19683 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19684 install_element(BGP_IPV6L_NODE
,
19685 &neighbor_maximum_prefix_threshold_restart_cmd
);
19686 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19687 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19688 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19689 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19690 install_element(BGP_VPNV4_NODE
,
19691 &neighbor_maximum_prefix_threshold_warning_cmd
);
19692 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19693 install_element(BGP_VPNV4_NODE
,
19694 &neighbor_maximum_prefix_threshold_restart_cmd
);
19695 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19696 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19697 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19698 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19699 install_element(BGP_VPNV6_NODE
,
19700 &neighbor_maximum_prefix_threshold_warning_cmd
);
19701 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19702 install_element(BGP_VPNV6_NODE
,
19703 &neighbor_maximum_prefix_threshold_restart_cmd
);
19704 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19706 /* "neighbor allowas-in" */
19707 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19708 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19709 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19710 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19711 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19712 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19713 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19714 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19715 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19716 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19717 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19718 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19719 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19720 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19721 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19722 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19723 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19724 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19725 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19726 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19728 /* neighbor accept-own */
19729 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19730 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19732 /* "neighbor soo" */
19733 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19734 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19735 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19736 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19737 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19738 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19739 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19740 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19741 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19742 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19743 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19744 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19745 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19746 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19747 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19748 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19749 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19750 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19752 /* address-family commands. */
19753 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19754 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19755 #ifdef KEEP_OLD_VPN_COMMANDS
19756 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19757 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19758 #endif /* KEEP_OLD_VPN_COMMANDS */
19760 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19762 /* "exit-address-family" command. */
19763 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19764 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19765 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19766 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19767 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19768 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19769 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19770 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19771 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19772 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19773 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19775 /* BGP retain all route-target */
19776 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19777 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19779 /* "clear ip bgp commands" */
19780 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19782 /* clear ip bgp prefix */
19783 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19784 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19785 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19787 /* "show [ip] bgp summary" commands. */
19788 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19789 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19790 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19791 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19792 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19793 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19794 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19796 /* "show [ip] bgp neighbors" commands. */
19797 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19799 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19801 /* "show [ip] bgp peer-group" commands. */
19802 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19804 /* "show [ip] bgp paths" commands. */
19805 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19807 /* "show [ip] bgp community" commands. */
19808 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19810 /* "show ip bgp large-community" commands. */
19811 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19812 /* "show [ip] bgp attribute-info" commands. */
19813 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19814 /* "show [ip] bgp route-leak" command */
19815 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19817 /* "redistribute" commands. */
19818 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19819 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19820 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19821 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19822 install_element(BGP_NODE
,
19823 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19824 install_element(BGP_NODE
,
19825 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19826 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19827 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19828 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19829 install_element(BGP_NODE
,
19830 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19831 install_element(BGP_NODE
,
19832 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19833 install_element(BGP_NODE
,
19834 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19835 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19836 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19837 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19838 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19839 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19840 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19841 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19842 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19843 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19844 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19845 install_element(BGP_IPV4_NODE
,
19846 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19847 install_element(BGP_IPV4_NODE
,
19848 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19849 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19850 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19851 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19852 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19853 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19854 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19856 /* import|export vpn [route-map RMAP_NAME] */
19857 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19858 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19860 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19861 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19863 /* ttl_security commands */
19864 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19865 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19867 /* "bgp tcp-keepalive" commands */
19868 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19869 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19871 /* "show [ip] bgp memory" commands. */
19872 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19874 /* "show bgp martian next-hop" */
19875 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19877 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19879 /* "show [ip] bgp views" commands. */
19880 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19882 /* "show [ip] bgp vrfs" commands. */
19883 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19885 /* Community-list. */
19886 community_list_vty();
19888 community_alias_vty();
19890 /* vpn-policy commands */
19891 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19892 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19893 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19894 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19895 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19896 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19897 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19898 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19899 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19900 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19901 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19902 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19904 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19905 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19907 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19908 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19909 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19910 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19911 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19912 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19913 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19914 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19915 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19916 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19918 /* tcp-mss command */
19919 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19920 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19922 /* srv6 commands */
19923 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19924 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19925 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19926 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19927 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19928 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19929 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19930 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
19931 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
19936 #include "memory.h"
19937 #include "bgp_regex.h"
19938 #include "bgp_clist.h"
19939 #include "bgp_ecommunity.h"
19941 /* VTY functions. */
19943 /* Direction value to string conversion. */
19944 static const char *community_direct_str(int direct
)
19947 case COMMUNITY_DENY
:
19949 case COMMUNITY_PERMIT
:
19956 /* Display error string. */
19957 static void community_list_perror(struct vty
*vty
, int ret
)
19960 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19961 vty_out(vty
, "%% Can't find community-list\n");
19963 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19964 vty_out(vty
, "%% Malformed community-list value\n");
19966 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19968 "%% Community name conflict, previously defined as standard community\n");
19970 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19972 "%% Community name conflict, previously defined as expanded community\n");
19977 /* "community-list" keyword help string. */
19978 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19980 /*community-list standard */
19981 DEFUN (community_list_standard
,
19982 bgp_community_list_standard_cmd
,
19983 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19986 "Community list number (standard)\n"
19987 "Add an standard community-list entry\n"
19988 "Community list name\n"
19989 "Sequence number of an entry\n"
19990 "Sequence number\n"
19991 "Specify community to reject\n"
19992 "Specify community to accept\n"
19995 char *cl_name_or_number
= NULL
;
19998 int style
= COMMUNITY_LIST_STANDARD
;
20001 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20002 seq
= argv
[idx
]->arg
;
20005 argv_find(argv
, argc
, "(1-99)", &idx
);
20006 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20007 cl_name_or_number
= argv
[idx
]->arg
;
20008 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20010 argv_find(argv
, argc
, "AA:NN", &idx
);
20011 char *str
= argv_concat(argv
, argc
, idx
);
20013 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20016 XFREE(MTYPE_TMP
, str
);
20019 /* Display error string. */
20020 community_list_perror(vty
, ret
);
20021 return CMD_WARNING_CONFIG_FAILED
;
20024 return CMD_SUCCESS
;
20027 DEFUN (no_community_list_standard_all
,
20028 no_bgp_community_list_standard_all_cmd
,
20029 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20033 "Community list number (standard)\n"
20034 "Add an standard community-list entry\n"
20035 "Community list name\n"
20036 "Sequence number of an entry\n"
20037 "Sequence number\n"
20038 "Specify community to reject\n"
20039 "Specify community to accept\n"
20042 char *cl_name_or_number
= NULL
;
20045 int style
= COMMUNITY_LIST_STANDARD
;
20049 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20050 seq
= argv
[idx
]->arg
;
20053 argv_find(argv
, argc
, "permit", &idx
);
20054 argv_find(argv
, argc
, "deny", &idx
);
20057 direct
= argv_find(argv
, argc
, "permit", &idx
)
20062 argv_find(argv
, argc
, "AA:NN", &idx
);
20063 str
= argv_concat(argv
, argc
, idx
);
20067 argv_find(argv
, argc
, "(1-99)", &idx
);
20068 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20069 cl_name_or_number
= argv
[idx
]->arg
;
20071 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20074 XFREE(MTYPE_TMP
, str
);
20077 community_list_perror(vty
, ret
);
20078 return CMD_WARNING_CONFIG_FAILED
;
20081 return CMD_SUCCESS
;
20084 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20085 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20086 NO_STR BGP_STR COMMUNITY_LIST_STR
20087 "Community list number (standard)\n"
20088 "Add an standard community-list entry\n"
20089 "Community list name\n")
20091 /*community-list expanded */
20092 DEFUN (community_list_expanded_all
,
20093 bgp_community_list_expanded_all_cmd
,
20094 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20097 "Community list number (expanded)\n"
20098 "Add an expanded community-list entry\n"
20099 "Community list name\n"
20100 "Sequence number of an entry\n"
20101 "Sequence number\n"
20102 "Specify community to reject\n"
20103 "Specify community to accept\n"
20106 char *cl_name_or_number
= NULL
;
20109 int style
= COMMUNITY_LIST_EXPANDED
;
20112 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20113 seq
= argv
[idx
]->arg
;
20117 argv_find(argv
, argc
, "(100-500)", &idx
);
20118 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20119 cl_name_or_number
= argv
[idx
]->arg
;
20120 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20122 argv_find(argv
, argc
, "AA:NN", &idx
);
20123 char *str
= argv_concat(argv
, argc
, idx
);
20125 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20128 XFREE(MTYPE_TMP
, str
);
20131 /* Display error string. */
20132 community_list_perror(vty
, ret
);
20133 return CMD_WARNING_CONFIG_FAILED
;
20136 return CMD_SUCCESS
;
20139 DEFUN (no_community_list_expanded_all
,
20140 no_bgp_community_list_expanded_all_cmd
,
20141 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20145 "Community list number (expanded)\n"
20146 "Add an expanded community-list entry\n"
20147 "Community list name\n"
20148 "Sequence number of an entry\n"
20149 "Sequence number\n"
20150 "Specify community to reject\n"
20151 "Specify community to accept\n"
20154 char *cl_name_or_number
= NULL
;
20158 int style
= COMMUNITY_LIST_EXPANDED
;
20161 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20162 seq
= argv
[idx
]->arg
;
20165 argv_find(argv
, argc
, "permit", &idx
);
20166 argv_find(argv
, argc
, "deny", &idx
);
20169 direct
= argv_find(argv
, argc
, "permit", &idx
)
20174 argv_find(argv
, argc
, "AA:NN", &idx
);
20175 str
= argv_concat(argv
, argc
, idx
);
20179 argv_find(argv
, argc
, "(100-500)", &idx
);
20180 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20181 cl_name_or_number
= argv
[idx
]->arg
;
20183 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20186 XFREE(MTYPE_TMP
, str
);
20189 community_list_perror(vty
, ret
);
20190 return CMD_WARNING_CONFIG_FAILED
;
20193 return CMD_SUCCESS
;
20196 ALIAS(no_community_list_expanded_all
,
20197 no_bgp_community_list_expanded_all_list_cmd
,
20198 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20199 NO_STR BGP_STR COMMUNITY_LIST_STR
20200 "Community list number (expanded)\n"
20201 "Add an expanded community-list entry\n"
20202 "Community list name\n")
20204 /* Return configuration string of community-list entry. */
20205 static const char *community_list_config_str(struct community_entry
*entry
)
20212 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20213 str
= community_str(entry
->u
.com
, false, false);
20214 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20215 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20217 str
= entry
->config
;
20222 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20224 struct community_entry
*entry
;
20226 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20227 if (entry
== list
->head
) {
20228 if (all_digit(list
->name
))
20229 vty_out(vty
, "Community %s list %s\n",
20230 entry
->style
== COMMUNITY_LIST_STANDARD
20232 : "(expanded) access",
20235 vty_out(vty
, "Named Community %s list %s\n",
20236 entry
->style
== COMMUNITY_LIST_STANDARD
20242 vty_out(vty
, " %s\n",
20243 community_direct_str(entry
->direct
));
20245 vty_out(vty
, " %s %s\n",
20246 community_direct_str(entry
->direct
),
20247 community_list_config_str(entry
));
20251 DEFUN (show_community_list
,
20252 show_bgp_community_list_cmd
,
20253 "show bgp community-list",
20256 "List community-list\n")
20258 struct community_list
*list
;
20259 struct community_list_master
*cm
;
20261 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20263 return CMD_SUCCESS
;
20265 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20266 community_list_show(vty
, list
);
20268 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20269 community_list_show(vty
, list
);
20271 return CMD_SUCCESS
;
20274 DEFUN (show_community_list_arg
,
20275 show_bgp_community_list_arg_cmd
,
20276 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20279 "List community-list\n"
20280 "Community-list number\n"
20281 "Community-list name\n"
20282 "Detailed information on community-list\n")
20284 int idx_comm_list
= 3;
20285 struct community_list
*list
;
20287 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20288 COMMUNITY_LIST_MASTER
);
20290 vty_out(vty
, "%% Can't find community-list\n");
20291 return CMD_WARNING
;
20294 community_list_show(vty
, list
);
20296 return CMD_SUCCESS
;
20300 * Large Community code.
20302 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20303 struct cmd_token
**argv
, int style
,
20304 int reject_all_digit_name
)
20313 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20314 seq
= argv
[idx
]->arg
;
20317 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20320 /* All digit name check. */
20322 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20323 argv_find(argv
, argc
, "(1-99)", &idx
);
20324 argv_find(argv
, argc
, "(100-500)", &idx
);
20325 cl_name
= argv
[idx
]->arg
;
20326 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20327 vty_out(vty
, "%% Community name cannot have all digits\n");
20328 return CMD_WARNING_CONFIG_FAILED
;
20332 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20333 argv_find(argv
, argc
, "LINE", &idx
);
20334 /* Concat community string argument. */
20336 str
= argv_concat(argv
, argc
, idx
);
20340 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20342 /* Free temporary community list string allocated by
20344 XFREE(MTYPE_TMP
, str
);
20347 community_list_perror(vty
, ret
);
20348 return CMD_WARNING_CONFIG_FAILED
;
20350 return CMD_SUCCESS
;
20353 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20354 struct cmd_token
**argv
, int style
)
20362 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20363 seq
= argv
[idx
]->arg
;
20366 argv_find(argv
, argc
, "permit", &idx
);
20367 argv_find(argv
, argc
, "deny", &idx
);
20370 /* Check the list direct. */
20371 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20372 direct
= COMMUNITY_PERMIT
;
20374 direct
= COMMUNITY_DENY
;
20377 argv_find(argv
, argc
, "LINE", &idx
);
20378 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20379 /* Concat community string argument. */
20380 str
= argv_concat(argv
, argc
, idx
);
20384 argv_find(argv
, argc
, "(1-99)", &idx
);
20385 argv_find(argv
, argc
, "(100-500)", &idx
);
20386 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20388 /* Unset community list. */
20389 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20392 /* Free temporary community list string allocated by
20394 XFREE(MTYPE_TMP
, str
);
20397 community_list_perror(vty
, ret
);
20398 return CMD_WARNING_CONFIG_FAILED
;
20401 return CMD_SUCCESS
;
20404 /* "large-community-list" keyword help string. */
20405 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20406 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20408 DEFUN (lcommunity_list_standard
,
20409 bgp_lcommunity_list_standard_cmd
,
20410 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20412 LCOMMUNITY_LIST_STR
20413 "Large Community list number (standard)\n"
20414 "Sequence number of an entry\n"
20415 "Sequence number\n"
20416 "Specify large community to reject\n"
20417 "Specify large community to accept\n"
20418 LCOMMUNITY_VAL_STR
)
20420 return lcommunity_list_set_vty(vty
, argc
, argv
,
20421 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20424 DEFUN (lcommunity_list_expanded
,
20425 bgp_lcommunity_list_expanded_cmd
,
20426 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20428 LCOMMUNITY_LIST_STR
20429 "Large Community list number (expanded)\n"
20430 "Sequence number of an entry\n"
20431 "Sequence number\n"
20432 "Specify large community to reject\n"
20433 "Specify large community to accept\n"
20434 "An ordered list as a regular-expression\n")
20436 return lcommunity_list_set_vty(vty
, argc
, argv
,
20437 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20440 DEFUN (lcommunity_list_name_standard
,
20441 bgp_lcommunity_list_name_standard_cmd
,
20442 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20444 LCOMMUNITY_LIST_STR
20445 "Specify standard large-community-list\n"
20446 "Large Community list name\n"
20447 "Sequence number of an entry\n"
20448 "Sequence number\n"
20449 "Specify large community to reject\n"
20450 "Specify large community to accept\n"
20451 LCOMMUNITY_VAL_STR
)
20453 return lcommunity_list_set_vty(vty
, argc
, argv
,
20454 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20457 DEFUN (lcommunity_list_name_expanded
,
20458 bgp_lcommunity_list_name_expanded_cmd
,
20459 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20461 LCOMMUNITY_LIST_STR
20462 "Specify expanded large-community-list\n"
20463 "Large Community list name\n"
20464 "Sequence number of an entry\n"
20465 "Sequence number\n"
20466 "Specify large community to reject\n"
20467 "Specify large community to accept\n"
20468 "An ordered list as a regular-expression\n")
20470 return lcommunity_list_set_vty(vty
, argc
, argv
,
20471 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20474 DEFUN (no_lcommunity_list_all
,
20475 no_bgp_lcommunity_list_all_cmd
,
20476 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20479 LCOMMUNITY_LIST_STR
20480 "Large Community list number (standard)\n"
20481 "Large Community list number (expanded)\n"
20482 "Large Community list name\n")
20484 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20485 LARGE_COMMUNITY_LIST_STANDARD
);
20488 DEFUN (no_lcommunity_list_name_standard_all
,
20489 no_bgp_lcommunity_list_name_standard_all_cmd
,
20490 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20493 LCOMMUNITY_LIST_STR
20494 "Specify standard large-community-list\n"
20495 "Large Community list name\n")
20497 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20498 LARGE_COMMUNITY_LIST_STANDARD
);
20501 DEFUN (no_lcommunity_list_name_expanded_all
,
20502 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20503 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20506 LCOMMUNITY_LIST_STR
20507 "Specify expanded large-community-list\n"
20508 "Large Community list name\n")
20510 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20511 LARGE_COMMUNITY_LIST_EXPANDED
);
20514 DEFUN (no_lcommunity_list_standard
,
20515 no_bgp_lcommunity_list_standard_cmd
,
20516 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20519 LCOMMUNITY_LIST_STR
20520 "Large Community list number (standard)\n"
20521 "Sequence number of an entry\n"
20522 "Sequence number\n"
20523 "Specify large community to reject\n"
20524 "Specify large community to accept\n"
20525 LCOMMUNITY_VAL_STR
)
20527 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20528 LARGE_COMMUNITY_LIST_STANDARD
);
20531 DEFUN (no_lcommunity_list_expanded
,
20532 no_bgp_lcommunity_list_expanded_cmd
,
20533 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20536 LCOMMUNITY_LIST_STR
20537 "Large Community list number (expanded)\n"
20538 "Sequence number of an entry\n"
20539 "Sequence number\n"
20540 "Specify large community to reject\n"
20541 "Specify large community to accept\n"
20542 "An ordered list as a regular-expression\n")
20544 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20545 LARGE_COMMUNITY_LIST_EXPANDED
);
20548 DEFUN (no_lcommunity_list_name_standard
,
20549 no_bgp_lcommunity_list_name_standard_cmd
,
20550 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20553 LCOMMUNITY_LIST_STR
20554 "Specify standard large-community-list\n"
20555 "Large Community list name\n"
20556 "Sequence number of an entry\n"
20557 "Sequence number\n"
20558 "Specify large community to reject\n"
20559 "Specify large community to accept\n"
20560 LCOMMUNITY_VAL_STR
)
20562 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20563 LARGE_COMMUNITY_LIST_STANDARD
);
20566 DEFUN (no_lcommunity_list_name_expanded
,
20567 no_bgp_lcommunity_list_name_expanded_cmd
,
20568 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20571 LCOMMUNITY_LIST_STR
20572 "Specify expanded large-community-list\n"
20573 "Large community list name\n"
20574 "Sequence number of an entry\n"
20575 "Sequence number\n"
20576 "Specify large community to reject\n"
20577 "Specify large community to accept\n"
20578 "An ordered list as a regular-expression\n")
20580 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20581 LARGE_COMMUNITY_LIST_EXPANDED
);
20584 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20586 struct community_entry
*entry
;
20588 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20589 if (entry
== list
->head
) {
20590 if (all_digit(list
->name
))
20591 vty_out(vty
, "Large community %s list %s\n",
20593 LARGE_COMMUNITY_LIST_STANDARD
20595 : "(expanded) access",
20599 "Named large community %s list %s\n",
20601 LARGE_COMMUNITY_LIST_STANDARD
20607 vty_out(vty
, " %s\n",
20608 community_direct_str(entry
->direct
));
20610 vty_out(vty
, " %s %s\n",
20611 community_direct_str(entry
->direct
),
20612 community_list_config_str(entry
));
20616 DEFUN (show_lcommunity_list
,
20617 show_bgp_lcommunity_list_cmd
,
20618 "show bgp large-community-list",
20621 "List large-community list\n")
20623 struct community_list
*list
;
20624 struct community_list_master
*cm
;
20626 cm
= community_list_master_lookup(bgp_clist
,
20627 LARGE_COMMUNITY_LIST_MASTER
);
20629 return CMD_SUCCESS
;
20631 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20632 lcommunity_list_show(vty
, list
);
20634 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20635 lcommunity_list_show(vty
, list
);
20637 return CMD_SUCCESS
;
20640 DEFUN (show_lcommunity_list_arg
,
20641 show_bgp_lcommunity_list_arg_cmd
,
20642 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20645 "List large-community list\n"
20646 "Large-community-list number\n"
20647 "Large-community-list name\n"
20648 "Detailed information on large-community-list\n")
20650 struct community_list
*list
;
20652 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20653 LARGE_COMMUNITY_LIST_MASTER
);
20655 vty_out(vty
, "%% Can't find large-community-list\n");
20656 return CMD_WARNING
;
20659 lcommunity_list_show(vty
, list
);
20661 return CMD_SUCCESS
;
20664 /* "extcommunity-list" keyword help string. */
20665 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20666 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20668 DEFUN (extcommunity_list_standard
,
20669 bgp_extcommunity_list_standard_cmd
,
20670 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20672 EXTCOMMUNITY_LIST_STR
20673 "Extended Community list number (standard)\n"
20674 "Specify standard extcommunity-list\n"
20675 "Community list name\n"
20676 "Sequence number of an entry\n"
20677 "Sequence number\n"
20678 "Specify community to reject\n"
20679 "Specify community to accept\n"
20680 EXTCOMMUNITY_VAL_STR
)
20682 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20684 char *cl_number_or_name
= NULL
;
20689 argv_find(argv
, argc
, "(1-99)", &idx
);
20690 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20691 cl_number_or_name
= argv
[idx
]->arg
;
20693 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20694 seq
= argv
[idx
]->arg
;
20696 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20698 argv_find(argv
, argc
, "AA:NN", &idx
);
20699 char *str
= argv_concat(argv
, argc
, idx
);
20701 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20704 XFREE(MTYPE_TMP
, str
);
20707 community_list_perror(vty
, ret
);
20708 return CMD_WARNING_CONFIG_FAILED
;
20711 return CMD_SUCCESS
;
20714 DEFUN (extcommunity_list_name_expanded
,
20715 bgp_extcommunity_list_name_expanded_cmd
,
20716 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20718 EXTCOMMUNITY_LIST_STR
20719 "Extended Community list number (expanded)\n"
20720 "Specify expanded extcommunity-list\n"
20721 "Extended Community list name\n"
20722 "Sequence number of an entry\n"
20723 "Sequence number\n"
20724 "Specify community to reject\n"
20725 "Specify community to accept\n"
20726 "An ordered list as a regular-expression\n")
20728 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20730 char *cl_number_or_name
= NULL
;
20734 argv_find(argv
, argc
, "(100-500)", &idx
);
20735 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20736 cl_number_or_name
= argv
[idx
]->arg
;
20738 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20739 seq
= argv
[idx
]->arg
;
20741 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20743 argv_find(argv
, argc
, "LINE", &idx
);
20744 char *str
= argv_concat(argv
, argc
, idx
);
20746 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20749 XFREE(MTYPE_TMP
, str
);
20752 community_list_perror(vty
, ret
);
20753 return CMD_WARNING_CONFIG_FAILED
;
20756 return CMD_SUCCESS
;
20759 DEFUN (no_extcommunity_list_standard_all
,
20760 no_bgp_extcommunity_list_standard_all_cmd
,
20761 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20764 EXTCOMMUNITY_LIST_STR
20765 "Extended Community list number (standard)\n"
20766 "Specify standard extcommunity-list\n"
20767 "Community list name\n"
20768 "Sequence number of an entry\n"
20769 "Sequence number\n"
20770 "Specify community to reject\n"
20771 "Specify community to accept\n"
20772 EXTCOMMUNITY_VAL_STR
)
20774 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20776 char *cl_number_or_name
= NULL
;
20781 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20782 seq
= argv
[idx
]->arg
;
20785 argv_find(argv
, argc
, "permit", &idx
);
20786 argv_find(argv
, argc
, "deny", &idx
);
20788 direct
= argv_find(argv
, argc
, "permit", &idx
)
20793 argv_find(argv
, argc
, "AA:NN", &idx
);
20794 str
= argv_concat(argv
, argc
, idx
);
20798 argv_find(argv
, argc
, "(1-99)", &idx
);
20799 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20800 cl_number_or_name
= argv
[idx
]->arg
;
20802 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20803 seq
, direct
, style
);
20805 XFREE(MTYPE_TMP
, str
);
20808 community_list_perror(vty
, ret
);
20809 return CMD_WARNING_CONFIG_FAILED
;
20812 return CMD_SUCCESS
;
20815 ALIAS(no_extcommunity_list_standard_all
,
20816 no_bgp_extcommunity_list_standard_all_list_cmd
,
20817 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20818 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20819 "Extended Community list number (standard)\n"
20820 "Specify standard extcommunity-list\n"
20821 "Community list name\n")
20823 DEFUN (no_extcommunity_list_expanded_all
,
20824 no_bgp_extcommunity_list_expanded_all_cmd
,
20825 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20828 EXTCOMMUNITY_LIST_STR
20829 "Extended Community list number (expanded)\n"
20830 "Specify expanded extcommunity-list\n"
20831 "Extended Community list name\n"
20832 "Sequence number of an entry\n"
20833 "Sequence number\n"
20834 "Specify community to reject\n"
20835 "Specify community to accept\n"
20836 "An ordered list as a regular-expression\n")
20838 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20840 char *cl_number_or_name
= NULL
;
20845 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20846 seq
= argv
[idx
]->arg
;
20849 argv_find(argv
, argc
, "permit", &idx
);
20850 argv_find(argv
, argc
, "deny", &idx
);
20853 direct
= argv_find(argv
, argc
, "permit", &idx
)
20858 argv_find(argv
, argc
, "LINE", &idx
);
20859 str
= argv_concat(argv
, argc
, idx
);
20863 argv_find(argv
, argc
, "(100-500)", &idx
);
20864 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20865 cl_number_or_name
= argv
[idx
]->arg
;
20867 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20868 seq
, direct
, style
);
20870 XFREE(MTYPE_TMP
, str
);
20873 community_list_perror(vty
, ret
);
20874 return CMD_WARNING_CONFIG_FAILED
;
20877 return CMD_SUCCESS
;
20880 ALIAS(no_extcommunity_list_expanded_all
,
20881 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20882 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20883 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20884 "Extended Community list number (expanded)\n"
20885 "Specify expanded extcommunity-list\n"
20886 "Extended Community list name\n")
20888 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20890 struct community_entry
*entry
;
20892 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20893 if (entry
== list
->head
) {
20894 if (all_digit(list
->name
))
20895 vty_out(vty
, "Extended community %s list %s\n",
20896 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20898 : "(expanded) access",
20902 "Named extended community %s list %s\n",
20903 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20909 vty_out(vty
, " %s\n",
20910 community_direct_str(entry
->direct
));
20912 vty_out(vty
, " %s %s\n",
20913 community_direct_str(entry
->direct
),
20914 community_list_config_str(entry
));
20918 DEFUN (show_extcommunity_list
,
20919 show_bgp_extcommunity_list_cmd
,
20920 "show bgp extcommunity-list",
20923 "List extended-community list\n")
20925 struct community_list
*list
;
20926 struct community_list_master
*cm
;
20928 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20930 return CMD_SUCCESS
;
20932 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20933 extcommunity_list_show(vty
, list
);
20935 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20936 extcommunity_list_show(vty
, list
);
20938 return CMD_SUCCESS
;
20941 DEFUN (show_extcommunity_list_arg
,
20942 show_bgp_extcommunity_list_arg_cmd
,
20943 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20946 "List extended-community list\n"
20947 "Extcommunity-list number\n"
20948 "Extcommunity-list name\n"
20949 "Detailed information on extcommunity-list\n")
20951 int idx_comm_list
= 3;
20952 struct community_list
*list
;
20954 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20955 EXTCOMMUNITY_LIST_MASTER
);
20957 vty_out(vty
, "%% Can't find extcommunity-list\n");
20958 return CMD_WARNING
;
20961 extcommunity_list_show(vty
, list
);
20963 return CMD_SUCCESS
;
20966 /* Display community-list and extcommunity-list configuration. */
20967 static int community_list_config_write(struct vty
*vty
)
20969 struct community_list
*list
;
20970 struct community_entry
*entry
;
20971 struct community_list_master
*cm
;
20974 /* Community-list. */
20975 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20977 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20978 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20980 "bgp community-list %s seq %" PRId64
" %s %s\n",
20981 list
->name
, entry
->seq
,
20982 community_direct_str(entry
->direct
),
20983 community_list_config_str(entry
));
20986 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20987 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20989 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20990 entry
->style
== COMMUNITY_LIST_STANDARD
20993 list
->name
, entry
->seq
,
20994 community_direct_str(entry
->direct
),
20995 community_list_config_str(entry
));
20999 /* Extcommunity-list. */
21000 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21002 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21003 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21005 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21006 list
->name
, entry
->seq
,
21007 community_direct_str(entry
->direct
),
21008 community_list_config_str(entry
));
21011 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21012 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21014 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21015 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21018 list
->name
, entry
->seq
,
21019 community_direct_str(entry
->direct
),
21020 community_list_config_str(entry
));
21025 /* lcommunity-list. */
21026 cm
= community_list_master_lookup(bgp_clist
,
21027 LARGE_COMMUNITY_LIST_MASTER
);
21029 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21030 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21032 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21033 list
->name
, entry
->seq
,
21034 community_direct_str(entry
->direct
),
21035 community_list_config_str(entry
));
21038 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21039 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21041 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21043 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21046 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21047 community_list_config_str(entry
));
21054 static int community_list_config_write(struct vty
*vty
);
21055 static struct cmd_node community_list_node
= {
21056 .name
= "community list",
21057 .node
= COMMUNITY_LIST_NODE
,
21059 .config_write
= community_list_config_write
,
21062 static void community_list_vty(void)
21064 install_node(&community_list_node
);
21066 /* Community-list. */
21067 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21068 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21069 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21070 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21071 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21072 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21073 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21074 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21076 /* Extcommunity-list. */
21077 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21078 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21079 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21080 install_element(CONFIG_NODE
,
21081 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21082 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21083 install_element(CONFIG_NODE
,
21084 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21085 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21086 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21088 /* Large Community List */
21089 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21090 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21091 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21092 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21093 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21094 install_element(CONFIG_NODE
,
21095 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21096 install_element(CONFIG_NODE
,
21097 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21098 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21099 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21100 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21101 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21102 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21103 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21105 bgp_community_list_command_completion_setup();
21108 static struct cmd_node community_alias_node
= {
21109 .name
= "community alias",
21110 .node
= COMMUNITY_ALIAS_NODE
,
21112 .config_write
= bgp_community_alias_write
,
21115 void community_alias_vty(void)
21117 install_node(&community_alias_node
);
21119 /* Community-list. */
21120 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21122 bgp_community_alias_command_completion_setup();