2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
161 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
164 afi_t afi
, bool use_json
);
166 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
172 return BGP_IPV4_NODE
;
174 return BGP_IPV4M_NODE
;
175 case SAFI_LABELED_UNICAST
:
176 return BGP_IPV4L_NODE
;
178 return BGP_VPNV4_NODE
;
180 return BGP_FLOWSPECV4_NODE
;
183 return BGP_IPV4_NODE
;
188 return BGP_IPV6_NODE
;
190 return BGP_IPV6M_NODE
;
191 case SAFI_LABELED_UNICAST
:
192 return BGP_IPV6L_NODE
;
194 return BGP_VPNV6_NODE
;
196 return BGP_FLOWSPECV6_NODE
;
199 return BGP_IPV4_NODE
;
202 return BGP_EVPN_NODE
;
205 // We should never be here but to clarify the switch statement..
206 return BGP_IPV4_NODE
;
209 // Impossible to happen
210 return BGP_IPV4_NODE
;
213 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
216 if (safi
== SAFI_UNICAST
)
217 return "IPv4 Unicast";
218 if (safi
== SAFI_MULTICAST
)
219 return "IPv4 Multicast";
220 if (safi
== SAFI_LABELED_UNICAST
)
221 return "IPv4 Labeled Unicast";
222 if (safi
== SAFI_MPLS_VPN
)
224 if (safi
== SAFI_ENCAP
)
226 if (safi
== SAFI_FLOWSPEC
)
227 return "IPv4 Flowspec";
228 } else if (afi
== AFI_IP6
) {
229 if (safi
== SAFI_UNICAST
)
230 return "IPv6 Unicast";
231 if (safi
== SAFI_MULTICAST
)
232 return "IPv6 Multicast";
233 if (safi
== SAFI_LABELED_UNICAST
)
234 return "IPv6 Labeled Unicast";
235 if (safi
== SAFI_MPLS_VPN
)
237 if (safi
== SAFI_ENCAP
)
239 if (safi
== SAFI_FLOWSPEC
)
240 return "IPv6 Flowspec";
241 } else if (afi
== AFI_L2VPN
) {
242 if (safi
== SAFI_EVPN
)
250 * Please note that we have intentionally camelCased
251 * the return strings here. So if you want
252 * to use this function, please ensure you
253 * are doing this within json output
255 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
258 if (safi
== SAFI_UNICAST
)
259 return "ipv4Unicast";
260 if (safi
== SAFI_MULTICAST
)
261 return "ipv4Multicast";
262 if (safi
== SAFI_LABELED_UNICAST
)
263 return "ipv4LabeledUnicast";
264 if (safi
== SAFI_MPLS_VPN
)
266 if (safi
== SAFI_ENCAP
)
268 if (safi
== SAFI_FLOWSPEC
)
269 return "ipv4Flowspec";
270 } else if (afi
== AFI_IP6
) {
271 if (safi
== SAFI_UNICAST
)
272 return "ipv6Unicast";
273 if (safi
== SAFI_MULTICAST
)
274 return "ipv6Multicast";
275 if (safi
== SAFI_LABELED_UNICAST
)
276 return "ipv6LabeledUnicast";
277 if (safi
== SAFI_MPLS_VPN
)
279 if (safi
== SAFI_ENCAP
)
281 if (safi
== SAFI_FLOWSPEC
)
282 return "ipv6Flowspec";
283 } else if (afi
== AFI_L2VPN
) {
284 if (safi
== SAFI_EVPN
)
291 /* unset srv6 locator */
292 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
295 struct listnode
*node
, *nnode
;
296 struct srv6_locator_chunk
*chunk
;
297 struct bgp_srv6_function
*func
;
300 /* release chunk notification via ZAPI */
301 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
302 bgp
->srv6_locator_name
);
307 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
308 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
309 srv6_locator_chunk_free(&chunk
);
312 /* refresh functions */
313 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
314 listnode_delete(bgp
->srv6_functions
, func
);
315 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
318 /* refresh tovpn_sid */
319 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
320 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
323 /* refresh vpnv4 tovpn_sid */
324 XFREE(MTYPE_BGP_SRV6_SID
,
325 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
327 /* refresh vpnv6 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
331 /* refresh per-vrf tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
335 /* update vpn bgp processes */
336 vpn_leak_postchange_all();
338 /* refresh tovpn_sid_locator */
339 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
340 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
343 /* refresh vpnv4 tovpn_sid_locator */
344 srv6_locator_chunk_free(
345 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
347 /* refresh vpnv6 tovpn_sid_locator */
348 srv6_locator_chunk_free(
349 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
351 /* refresh per-vrf tovpn_sid_locator */
352 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
355 /* clear locator name */
356 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
361 /* Utility function to get address family from current node. */
362 afi_t
bgp_node_afi(struct vty
*vty
)
370 case BGP_FLOWSPECV6_NODE
:
383 /* Utility function to get subsequent address family from current
385 safi_t
bgp_node_safi(struct vty
*vty
)
391 safi
= SAFI_MPLS_VPN
;
395 safi
= SAFI_MULTICAST
;
402 safi
= SAFI_LABELED_UNICAST
;
404 case BGP_FLOWSPECV4_NODE
:
405 case BGP_FLOWSPECV6_NODE
:
406 safi
= SAFI_FLOWSPEC
;
416 * Converts an AFI in string form to afi_t
418 * @param afi string, one of
422 * @return the corresponding afi_t
424 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
426 afi_t afi
= AFI_MAX
; /* unknown */
427 if (strmatch(afi_str
, "ipv4"))
429 else if (strmatch(afi_str
, "ipv6"))
431 else if (strmatch(afi_str
, "l2vpn"))
436 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
440 if (argv_find(argv
, argc
, "ipv4", index
)) {
444 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
448 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
456 /* supports <unicast|multicast|vpn|labeled-unicast> */
457 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
459 safi_t safi
= SAFI_MAX
; /* unknown */
460 if (strmatch(safi_str
, "multicast"))
461 safi
= SAFI_MULTICAST
;
462 else if (strmatch(safi_str
, "unicast"))
464 else if (strmatch(safi_str
, "vpn"))
465 safi
= SAFI_MPLS_VPN
;
466 else if (strmatch(safi_str
, "evpn"))
468 else if (strmatch(safi_str
, "labeled-unicast"))
469 safi
= SAFI_LABELED_UNICAST
;
470 else if (strmatch(safi_str
, "flowspec"))
471 safi
= SAFI_FLOWSPEC
;
475 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
479 if (argv_find(argv
, argc
, "unicast", index
)) {
482 *safi
= SAFI_UNICAST
;
483 } else if (argv_find(argv
, argc
, "multicast", index
)) {
486 *safi
= SAFI_MULTICAST
;
487 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
490 *safi
= SAFI_LABELED_UNICAST
;
491 } else if (argv_find(argv
, argc
, "vpn", index
)) {
494 *safi
= SAFI_MPLS_VPN
;
495 } else if (argv_find(argv
, argc
, "evpn", index
)) {
499 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
502 *safi
= SAFI_FLOWSPEC
;
508 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
511 * address-family identifier
514 * subsequent address-family identifier
517 * default_af string corresponding to the supplied afi/safi pair.
518 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
521 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
527 return "ipv4-unicast";
529 return "ipv4-multicast";
534 case SAFI_LABELED_UNICAST
:
535 return "ipv4-labeled-unicast";
537 return "ipv4-flowspec";
539 return "unknown-afi/safi";
545 return "ipv6-unicast";
547 return "ipv6-multicast";
552 case SAFI_LABELED_UNICAST
:
553 return "ipv6-labeled-unicast";
555 return "ipv6-flowspec";
557 return "unknown-afi/safi";
565 return "unknown-afi/safi";
569 return "unknown-afi/safi";
571 /* all AFIs are accounted for above, so this shouldn't happen */
572 return "unknown-afi/safi";
575 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
576 enum bgp_instance_type inst_type
)
578 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
580 if (ret
== BGP_CREATED
) {
581 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
582 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
584 if (DFLT_BGP_IMPORT_CHECK
)
585 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
586 if (DFLT_BGP_SHOW_HOSTNAME
)
587 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
588 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
589 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
590 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
592 if (DFLT_BGP_DETERMINISTIC_MED
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
594 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
596 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
598 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
600 if (DFLT_BGP_HARD_ADMIN_RESET
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
609 * bgp_vty_find_and_parse_afi_safi_bgp
611 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
612 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
613 * to appropriate values for the calling function. This is to allow the
614 * calling function to make decisions appropriate for the show command
615 * that is being parsed.
617 * The show commands are generally of the form:
618 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
619 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
621 * Since we use argv_find if the show command in particular doesn't have:
623 * [<view|vrf> VIEWVRFNAME]
624 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
625 * The command parsing should still be ok.
627 * vty -> The vty for the command so we can output some useful data in
628 * the event of a parse error in the vrf.
629 * argv -> The command tokens
630 * argc -> How many command tokens we have
631 * idx -> The current place in the command, generally should be 0 for this
633 * afi -> The parsed afi if it was included in the show command, returned here
634 * safi -> The parsed safi if it was included in the show command, returned here
635 * bgp -> Pointer to the bgp data structure we need to fill in.
636 * use_json -> json is configured or not
638 * The function returns the correct location in the parse tree for the
641 * Returns 0 for failure to parse correctly, else the idx position of where
642 * it found the last token.
644 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
645 struct cmd_token
**argv
, int argc
,
646 int *idx
, afi_t
*afi
, safi_t
*safi
,
647 struct bgp
**bgp
, bool use_json
)
649 char *vrf_name
= NULL
;
655 if (argv_find(argv
, argc
, "ip", idx
))
658 if (argv_find(argv
, argc
, "view", idx
))
659 vrf_name
= argv
[*idx
+ 1]->arg
;
660 else if (argv_find(argv
, argc
, "vrf", idx
)) {
661 vrf_name
= argv
[*idx
+ 1]->arg
;
662 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
666 if (strmatch(vrf_name
, "all"))
669 *bgp
= bgp_lookup_by_name(vrf_name
);
672 json_object
*json
= NULL
;
673 json
= json_object_new_object();
674 json_object_string_add(
676 "View/Vrf is unknown");
680 vty_out(vty
, "View/Vrf %s is unknown\n",
687 *bgp
= bgp_get_default();
690 json_object
*json
= NULL
;
691 json
= json_object_new_object();
692 json_object_string_add(
694 "Default BGP instance not found");
699 "Default BGP instance not found\n");
705 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
706 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
712 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
714 struct interface
*ifp
= NULL
;
715 struct listnode
*node
;
716 struct bgp_listener
*listener
;
717 union sockunion all_su
;
719 if (su
->sa
.sa_family
== AF_INET
) {
720 (void)str2sockunion("0.0.0.0", &all_su
);
721 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
722 } else if (su
->sa
.sa_family
== AF_INET6
) {
723 (void)str2sockunion("::", &all_su
);
724 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
725 su
->sin6
.sin6_scope_id
,
730 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
731 if (sockunion_family(su
) !=
732 sockunion_family(&listener
->su
))
735 /* If 0.0.0.0/:: is a listener, then treat as self and
738 if (!sockunion_cmp(&listener
->su
, su
) ||
739 !sockunion_cmp(&listener
->su
, &all_su
))
747 /* Utility function for looking up peer from VTY. */
748 /* This is used only for configuration, so disallow if attempted on
749 * a dynamic neighbor.
751 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
753 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
762 ret
= str2sockunion(ip_str
, &su
);
764 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
766 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
769 "%% Malformed address or name: %s\n",
775 peer
= peer_lookup(bgp
, &su
);
778 "%% Specify remote-as or peer-group commands first\n");
781 if (peer_dynamic_neighbor(peer
)) {
783 "%% Operation not allowed on a dynamic neighbor\n");
790 /* Utility function for looking up peer or peer group. */
791 /* This is used only for configuration, so disallow if attempted on
792 * a dynamic neighbor.
794 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
796 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
799 struct peer
*peer
= NULL
;
800 struct peer_group
*group
= NULL
;
806 ret
= str2sockunion(peer_str
, &su
);
808 /* IP address, locate peer. */
809 peer
= peer_lookup(bgp
, &su
);
811 /* Not IP, could match either peer configured on interface or a
813 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
815 group
= peer_group_lookup(bgp
, peer_str
);
819 if (peer_dynamic_neighbor(peer
)) {
821 "%pBP: Operation not allowed on a dynamic neighbor",
824 "%% Operation not allowed on a dynamic neighbor\n");
834 zlog_warn("Specify remote-as or peer-group commands first before: %s",
836 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
841 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
843 const char *str
= NULL
;
848 case BGP_GR_NO_OPERATION
:
850 case BGP_ERR_INVALID_VALUE
:
851 str
= "Invalid value";
853 case BGP_ERR_INVALID_FLAG
:
854 str
= "Invalid flag";
856 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
857 str
= "Peer-group has been shutdown. Activate the peer-group first";
859 case BGP_ERR_PEER_FLAG_CONFLICT
:
860 str
= "Can't set override-capability and strict-capability-match at the same time";
862 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
863 str
= "Specify remote-as or peer-group remote AS first";
865 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
866 str
= "Cannot change the peer-group. Deconfigure first";
868 case BGP_ERR_PEER_GROUP_MISMATCH
:
869 str
= "Peer is not a member of this peer-group";
871 case BGP_ERR_PEER_FILTER_CONFLICT
:
872 str
= "Prefix/distribute list can not co-exist";
874 case BGP_ERR_NOT_INTERNAL_PEER
:
875 str
= "Invalid command. Not an internal neighbor";
877 case BGP_ERR_REMOVE_PRIVATE_AS
:
878 str
= "remove-private-AS cannot be configured for IBGP peers";
880 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
881 str
= "Cannot have local-as same as BGP AS number";
883 case BGP_ERR_TCPSIG_FAILED
:
884 str
= "Error while applying TCP-Sig to session(s)";
886 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
887 str
= "ebgp-multihop and ttl-security cannot be configured together";
889 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
890 str
= "ttl-security only allowed for EBGP peers";
892 case BGP_ERR_AS_OVERRIDE
:
893 str
= "as-override cannot be configured for IBGP peers";
895 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
896 str
= "Invalid limit for number of dynamic neighbors";
898 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
899 str
= "Dynamic neighbor listen range already exists";
901 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
902 str
= "Operation not allowed on a dynamic neighbor";
904 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
905 str
= "Operation not allowed on a directly connected neighbor";
907 case BGP_ERR_PEER_SAFI_CONFLICT
:
908 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
910 case BGP_ERR_GR_INVALID_CMD
:
911 str
= "The Graceful Restart command used is not valid at this moment.";
913 case BGP_ERR_GR_OPERATION_FAILED
:
914 str
= "The Graceful Restart Operation failed due to an err.";
916 case BGP_ERR_PEER_GROUP_MEMBER
:
917 str
= "Peer-group member cannot override remote-as of peer-group.";
919 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
920 str
= "Peer-group members must be all internal or all external.";
922 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
923 str
= "Range specified cannot be deleted because it is not part of current config.";
925 case BGP_ERR_INSTANCE_MISMATCH
:
926 str
= "Instance specified does not match the current instance.";
928 case BGP_ERR_NO_INTERFACE_CONFIG
:
929 str
= "Interface specified is not being used for interface based peer.";
931 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
932 str
= "No configuration already specified for soft reconfiguration.";
934 case BGP_ERR_AS_MISMATCH
:
935 str
= "BGP is already running.";
937 case BGP_ERR_AF_UNCONFIGURED
:
938 str
= "AFI/SAFI specified is not currently configured.";
940 case BGP_ERR_INVALID_AS
:
941 str
= "Confederation AS specified is the same AS as our AS.";
943 case BGP_ERR_INVALID_ROLE_NAME
:
944 str
= "Invalid role name";
946 case BGP_ERR_INVALID_INTERNAL_ROLE
:
947 str
= "External roles can be set only on eBGP session";
951 vty_out(vty
, "%% %s\n", str
);
952 return CMD_WARNING_CONFIG_FAILED
;
957 /* BGP clear sort. */
966 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
967 safi_t safi
, int error
)
970 case BGP_ERR_AF_UNCONFIGURED
:
973 "%% BGP: Enable %s address family for the neighbor %s\n",
974 get_afi_safi_str(afi
, safi
, false), peer
->host
);
977 "%% BGP: Enable %s address family for the neighbor %s",
978 get_afi_safi_str(afi
, safi
, false), peer
->host
);
980 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
983 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
987 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
995 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
996 struct listnode
**nnode
, enum bgp_clear_type stype
)
1001 /* if afi/.safi not specified, spin thru all of them */
1002 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1005 enum bgp_af_index index
;
1007 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1008 paf
= peer
->peer_af_array
[index
];
1012 if (paf
&& paf
->subgroup
)
1013 SET_FLAG(paf
->subgroup
->sflags
,
1014 SUBGRP_STATUS_FORCE_UPDATES
);
1017 tmp_safi
= paf
->safi
;
1018 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1021 if (stype
== BGP_CLEAR_SOFT_NONE
)
1022 ret
= peer_clear(peer
, nnode
);
1024 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1027 /* if afi specified and safi not, spin thru safis on this afi */
1028 } else if (safi
== SAFI_UNSPEC
) {
1031 for (tmp_safi
= SAFI_UNICAST
;
1032 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1033 if (!peer
->afc
[afi
][tmp_safi
])
1036 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1037 if (paf
&& paf
->subgroup
)
1038 SET_FLAG(paf
->subgroup
->sflags
,
1039 SUBGRP_STATUS_FORCE_UPDATES
);
1041 if (stype
== BGP_CLEAR_SOFT_NONE
)
1042 ret
= peer_clear(peer
, nnode
);
1044 ret
= peer_clear_soft(peer
, afi
,
1047 /* both afi/safi specified, let the caller know if not defined */
1049 if (!peer
->afc
[afi
][safi
])
1052 paf
= peer_af_find(peer
, afi
, safi
);
1053 if (paf
&& paf
->subgroup
)
1054 SET_FLAG(paf
->subgroup
->sflags
,
1055 SUBGRP_STATUS_FORCE_UPDATES
);
1057 if (stype
== BGP_CLEAR_SOFT_NONE
)
1058 ret
= peer_clear(peer
, nnode
);
1060 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1066 /* `clear ip bgp' functions. */
1067 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1068 enum clear_sort sort
, enum bgp_clear_type stype
,
1075 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1077 /* Clear all neighbors. */
1079 * Pass along pointer to next node to peer_clear() when walking all
1080 * nodes on the BGP instance as that may get freed if it is a
1083 if (sort
== clear_all
) {
1084 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1086 bgp_peer_gr_flags_update(peer
);
1088 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1089 gr_router_detected
= true;
1091 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1095 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1098 if (gr_router_detected
1099 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1100 bgp_zebra_send_capabilities(bgp
, false);
1101 } else if (!gr_router_detected
1102 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1103 bgp_zebra_send_capabilities(bgp
, true);
1106 /* This is to apply read-only mode on this clear. */
1107 if (stype
== BGP_CLEAR_SOFT_NONE
)
1108 bgp
->update_delay_over
= 0;
1113 /* Clear specified neighbor. */
1114 if (sort
== clear_peer
) {
1117 /* Make sockunion for lookup. */
1118 ret
= str2sockunion(arg
, &su
);
1120 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1122 peer
= peer_lookup_by_hostname(bgp
, arg
);
1125 "Malformed address or name: %s\n",
1131 peer
= peer_lookup(bgp
, &su
);
1134 "%% BGP: Unknown neighbor - \"%s\"\n",
1140 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1141 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1143 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1145 /* if afi/safi not defined for this peer, let caller know */
1147 ret
= BGP_ERR_AF_UNCONFIGURED
;
1150 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1155 /* Clear all neighbors belonging to a specific peer-group. */
1156 if (sort
== clear_group
) {
1157 struct peer_group
*group
;
1159 group
= peer_group_lookup(bgp
, arg
);
1161 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1165 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1166 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1169 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1176 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1177 get_afi_safi_str(afi
, safi
, false), arg
);
1182 /* Clear all external (eBGP) neighbors. */
1183 if (sort
== clear_external
) {
1184 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1185 if (peer
->sort
== BGP_PEER_IBGP
)
1188 bgp_peer_gr_flags_update(peer
);
1190 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1191 gr_router_detected
= true;
1193 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1196 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1201 if (gr_router_detected
1202 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1203 bgp_zebra_send_capabilities(bgp
, false);
1204 } else if (!gr_router_detected
1205 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1206 bgp_zebra_send_capabilities(bgp
, true);
1211 "%% BGP: No external %s peer is configured\n",
1212 get_afi_safi_str(afi
, safi
, false));
1217 /* Clear all neighbors belonging to a specific AS. */
1218 if (sort
== clear_as
) {
1219 as_t as
= strtoul(arg
, NULL
, 10);
1221 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1225 bgp_peer_gr_flags_update(peer
);
1227 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1228 gr_router_detected
= true;
1230 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1233 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1238 if (gr_router_detected
1239 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1240 bgp_zebra_send_capabilities(bgp
, false);
1241 } else if (!gr_router_detected
1242 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1243 bgp_zebra_send_capabilities(bgp
, true);
1248 "%% BGP: No %s peer is configured with AS %s\n",
1249 get_afi_safi_str(afi
, safi
, false), arg
);
1257 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1258 safi_t safi
, enum clear_sort sort
,
1259 enum bgp_clear_type stype
, const char *arg
)
1263 /* BGP structure lookup. */
1265 bgp
= bgp_lookup_by_name(name
);
1267 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1271 bgp
= bgp_get_default();
1273 vty_out(vty
, "No BGP process is configured\n");
1278 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1281 /* clear soft inbound */
1282 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1287 FOREACH_AFI_SAFI (afi
, safi
)
1288 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1289 BGP_CLEAR_SOFT_IN
, NULL
);
1292 /* clear soft outbound */
1293 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1298 FOREACH_AFI_SAFI (afi
, safi
)
1299 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1300 BGP_CLEAR_SOFT_OUT
, NULL
);
1304 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1306 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1309 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1310 uint64_t flag
, int set
)
1315 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1317 return CMD_WARNING_CONFIG_FAILED
;
1320 * If 'neighbor <interface>', then this is for directly connected peers,
1321 * we should not accept disable-connected-check.
1323 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1325 "%s is directly connected peer, cannot accept disable-connected-check\n",
1327 return CMD_WARNING_CONFIG_FAILED
;
1330 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1331 peer_tx_shutdown_message_unset(peer
);
1334 ret
= peer_flag_set(peer
, flag
);
1336 ret
= peer_flag_unset(peer
, flag
);
1338 return bgp_vty_return(vty
, ret
);
1341 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1343 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1346 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1349 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1352 #include "bgpd/bgp_vty_clippy.c"
1354 DEFUN_HIDDEN (bgp_local_mac
,
1356 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1358 "Local MAC config\n"
1359 "VxLAN Network Identifier\n"
1363 "mac-mobility sequence\n"
1373 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1374 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1375 vty_out(vty
, "%% Malformed MAC address\n");
1378 memset(&ip
, 0, sizeof(ip
));
1379 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1381 bgp
= bgp_get_default();
1383 vty_out(vty
, "Default BGP instance is not there\n");
1387 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1390 vty_out(vty
, "Internal error\n");
1397 DEFUN_HIDDEN (no_bgp_local_mac
,
1398 no_bgp_local_mac_cmd
,
1399 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1402 "Local MAC config\n"
1403 "VxLAN Network Identifier\n"
1414 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1415 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1416 vty_out(vty
, "%% Malformed MAC address\n");
1419 memset(&ip
, 0, sizeof(ip
));
1421 bgp
= bgp_get_default();
1423 vty_out(vty
, "Default BGP instance is not there\n");
1427 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1429 vty_out(vty
, "Internal error\n");
1436 DEFUN (no_synchronization
,
1437 no_synchronization_cmd
,
1438 "no synchronization",
1440 "Perform IGP synchronization\n")
1445 DEFUN (no_auto_summary
,
1446 no_auto_summary_cmd
,
1449 "Enable automatic network number summarization\n")
1454 /* "router bgp" commands. */
1455 DEFUN_NOSH (router_bgp
,
1457 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1461 BGP_INSTANCE_HELP_STR
)
1464 int idx_view_vrf
= 3;
1470 const char *name
= NULL
;
1471 enum bgp_instance_type inst_type
;
1473 // "router bgp" without an ASN
1475 // Pending: Make VRF option available for ASN less config
1476 bgp
= bgp_get_default();
1479 vty_out(vty
, "%% No BGP process is configured\n");
1480 return CMD_WARNING_CONFIG_FAILED
;
1483 if (listcount(bm
->bgp
) > 1) {
1484 vty_out(vty
, "%% Please specify ASN and VRF\n");
1485 return CMD_WARNING_CONFIG_FAILED
;
1491 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1493 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1494 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1495 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1497 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1499 name
= argv
[idx_vrf
]->arg
;
1501 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1502 if (strmatch(name
, VRF_DEFAULT_NAME
))
1505 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1506 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1507 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1510 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1511 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1513 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1515 case BGP_ERR_AS_MISMATCH
:
1516 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1517 return CMD_WARNING_CONFIG_FAILED
;
1518 case BGP_ERR_INSTANCE_MISMATCH
:
1520 "BGP instance name and AS number mismatch\n");
1522 "BGP instance is already running; AS is %u\n",
1524 return CMD_WARNING_CONFIG_FAILED
;
1528 * If we just instantiated the default instance, complete
1529 * any pending VRF-VPN leaking that was configured via
1530 * earlier "router bgp X vrf FOO" blocks.
1532 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1533 vpn_leak_postchange_all();
1535 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1536 bgp_vpn_leak_export(bgp
);
1537 /* Pending: handle when user tries to change a view to vrf n vv.
1541 /* unset the auto created flag as the user config is now present */
1542 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1543 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1548 /* "no router bgp" commands. */
1549 DEFUN (no_router_bgp
,
1551 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1556 BGP_INSTANCE_HELP_STR
)
1562 const char *name
= NULL
;
1564 // "no router bgp" without an ASN
1566 // Pending: Make VRF option available for ASN less config
1567 bgp
= bgp_get_default();
1570 vty_out(vty
, "%% No BGP process is configured\n");
1571 return CMD_WARNING_CONFIG_FAILED
;
1574 if (listcount(bm
->bgp
) > 1) {
1575 vty_out(vty
, "%% Please specify ASN and VRF\n");
1576 return CMD_WARNING_CONFIG_FAILED
;
1580 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1582 return CMD_WARNING_CONFIG_FAILED
;
1585 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1588 name
= argv
[idx_vrf
]->arg
;
1589 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1590 && strmatch(name
, VRF_DEFAULT_NAME
))
1594 /* Lookup bgp structure. */
1595 bgp
= bgp_lookup(as
, name
);
1597 vty_out(vty
, "%% Can't find BGP instance\n");
1598 return CMD_WARNING_CONFIG_FAILED
;
1602 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1604 return CMD_WARNING_CONFIG_FAILED
;
1607 /* Cannot delete default instance if vrf instances exist */
1608 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1609 struct listnode
*node
;
1610 struct bgp
*tmp_bgp
;
1612 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1613 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1615 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1616 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1617 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1618 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1619 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1620 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1621 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1622 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1623 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1624 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1625 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1626 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1627 (bgp
== bgp_get_evpn() &&
1628 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1629 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1630 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1631 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1632 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1633 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1634 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1635 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1636 (hashcount(tmp_bgp
->vnihash
))) {
1638 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1639 return CMD_WARNING_CONFIG_FAILED
;
1650 /* bgp session-dscp */
1652 DEFPY (bgp_session_dscp
,
1653 bgp_session_dscp_cmd
,
1654 "bgp session-dscp (0-63)$dscp",
1656 "Override default (C6) bgp TCP session DSCP value\n"
1657 "Manually configured dscp parameter\n")
1659 bm
->tcp_dscp
= dscp
<< 2;
1664 DEFPY (no_bgp_session_dscp
,
1665 no_bgp_session_dscp_cmd
,
1666 "no bgp session-dscp [(0-63)]",
1669 "Override default (C6) bgp TCP session DSCP value\n"
1670 "Manually configured dscp parameter\n")
1672 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1677 /* BGP router-id. */
1679 DEFPY (bgp_router_id
,
1681 "bgp router-id A.B.C.D",
1683 "Override configured router identifier\n"
1684 "Manually configured router identifier\n")
1686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1687 bgp_router_id_static_set(bgp
, router_id
);
1691 DEFPY (no_bgp_router_id
,
1692 no_bgp_router_id_cmd
,
1693 "no bgp router-id [A.B.C.D]",
1696 "Override configured router identifier\n"
1697 "Manually configured router identifier\n")
1699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1701 if (router_id_str
) {
1702 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1703 vty_out(vty
, "%% BGP router-id doesn't match\n");
1704 return CMD_WARNING_CONFIG_FAILED
;
1708 router_id
.s_addr
= 0;
1709 bgp_router_id_static_set(bgp
, router_id
);
1714 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1715 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1717 "Add community specific parameters\n"
1718 "Create an alias for a community\n"
1719 "Community (AA:BB or AA:BB:CC)\n"
1722 struct community_alias ca
= {};
1723 struct community_alias
*lookup_community
;
1724 struct community_alias
*lookup_alias
;
1725 struct community
*comm
;
1726 struct lcommunity
*lcomm
;
1727 uint8_t invalid
= 0;
1729 comm
= community_str2com(community
);
1732 community_free(&comm
);
1734 lcomm
= lcommunity_str2com(community
);
1737 lcommunity_free(&lcomm
);
1740 vty_out(vty
, "Invalid community format\n");
1744 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1745 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1747 lookup_community
= bgp_ca_community_lookup(&ca
);
1748 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1751 bgp_ca_alias_delete(&ca
);
1752 bgp_ca_community_delete(&ca
);
1755 /* Lookup if community hash table has an item
1756 * with the same alias name.
1758 strlcpy(ca
.community
, lookup_alias
->community
,
1759 sizeof(ca
.community
));
1760 if (bgp_ca_community_lookup(&ca
)) {
1762 "community (%s) already has this alias (%s)\n",
1763 lookup_alias
->community
,
1764 lookup_alias
->alias
);
1767 bgp_ca_alias_delete(&ca
);
1770 if (lookup_community
) {
1771 /* Lookup if alias hash table has an item
1772 * with the same community.
1774 strlcpy(ca
.alias
, lookup_community
->alias
,
1776 if (bgp_ca_alias_lookup(&ca
)) {
1778 "alias (%s) already has this community (%s)\n",
1779 lookup_community
->alias
,
1780 lookup_community
->community
);
1783 bgp_ca_community_delete(&ca
);
1786 bgp_ca_alias_insert(&ca
);
1787 bgp_ca_community_insert(&ca
);
1793 DEFPY (bgp_global_suppress_fib_pending
,
1794 bgp_global_suppress_fib_pending_cmd
,
1795 "[no] bgp suppress-fib-pending",
1798 "Advertise only routes that are programmed in kernel to peers globally\n")
1800 bm_wait_for_fib_set(!no
);
1805 DEFPY (bgp_suppress_fib_pending
,
1806 bgp_suppress_fib_pending_cmd
,
1807 "[no] bgp suppress-fib-pending",
1810 "Advertise only routes that are programmed in kernel to peers\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1814 bgp_suppress_fib_pending_set(bgp
, !no
);
1819 /* BGP Cluster ID. */
1820 DEFUN (bgp_cluster_id
,
1822 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1824 "Configure Route-Reflector Cluster-id\n"
1825 "Route-Reflector Cluster-id in IP address format\n"
1826 "Route-Reflector Cluster-id as 32 bit quantity\n")
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1831 struct in_addr cluster
;
1833 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1835 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1836 return CMD_WARNING_CONFIG_FAILED
;
1839 bgp_cluster_id_set(bgp
, &cluster
);
1840 bgp_clear_star_soft_out(vty
, bgp
->name
);
1845 DEFUN (no_bgp_cluster_id
,
1846 no_bgp_cluster_id_cmd
,
1847 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1850 "Configure Route-Reflector Cluster-id\n"
1851 "Route-Reflector Cluster-id in IP address format\n"
1852 "Route-Reflector Cluster-id as 32 bit quantity\n")
1854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1855 bgp_cluster_id_unset(bgp
);
1856 bgp_clear_star_soft_out(vty
, bgp
->name
);
1865 "Disable BGP route installation to RIB (Zebra)\n")
1867 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1869 "%% No-RIB option is already set, nothing to do here.\n");
1873 bgp_option_norib_set_runtime();
1878 DEFPY (no_bgp_norib
,
1883 "Disable BGP route installation to RIB (Zebra)\n")
1885 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1887 "%% No-RIB option is not set, nothing to do here.\n");
1891 bgp_option_norib_unset_runtime();
1896 DEFPY (no_bgp_send_extra_data
,
1897 no_bgp_send_extra_data_cmd
,
1898 "[no] bgp send-extra-data zebra",
1901 "Extra data to Zebra for display/use\n"
1905 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1907 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1912 DEFUN (bgp_confederation_identifier
,
1913 bgp_confederation_identifier_cmd
,
1914 "bgp confederation identifier (1-4294967295)",
1916 "AS confederation parameters\n"
1918 "Set routing domain confederation AS\n")
1920 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1924 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1926 bgp_confederation_id_set(bgp
, as
);
1931 DEFUN (no_bgp_confederation_identifier
,
1932 no_bgp_confederation_identifier_cmd
,
1933 "no bgp confederation identifier [(1-4294967295)]",
1936 "AS confederation parameters\n"
1938 "Set routing domain confederation AS\n")
1940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1941 bgp_confederation_id_unset(bgp
);
1946 DEFUN (bgp_confederation_peers
,
1947 bgp_confederation_peers_cmd
,
1948 "bgp confederation peers (1-4294967295)...",
1950 "AS confederation parameters\n"
1951 "Peer ASs in BGP confederation\n"
1954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1959 for (i
= idx_asn
; i
< argc
; i
++) {
1960 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1961 bgp_confederation_peers_add(bgp
, as
);
1966 DEFUN (no_bgp_confederation_peers
,
1967 no_bgp_confederation_peers_cmd
,
1968 "no bgp confederation peers (1-4294967295)...",
1971 "AS confederation parameters\n"
1972 "Peer ASs in BGP confederation\n"
1975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1980 for (i
= idx_asn
; i
< argc
; i
++) {
1981 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1983 bgp_confederation_peers_remove(bgp
, as
);
1989 * Central routine for maximum-paths configuration.
1990 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1991 * @set: 1 for setting values, 0 for removing the max-paths config.
1993 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1994 const char *mpaths
, uint16_t options
,
1997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 uint16_t maxpaths
= 0;
2003 afi
= bgp_node_afi(vty
);
2004 safi
= bgp_node_safi(vty
);
2007 maxpaths
= strtol(mpaths
, NULL
, 10);
2008 if (maxpaths
> multipath_num
) {
2010 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2011 maxpaths
, multipath_num
);
2012 return CMD_WARNING_CONFIG_FAILED
;
2014 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2017 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2021 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2022 (set
== 1) ? "" : "un",
2023 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2024 maxpaths
, afi
, safi
);
2025 return CMD_WARNING_CONFIG_FAILED
;
2028 bgp_recalculate_all_bestpaths(bgp
);
2033 DEFUN (bgp_maxmed_admin
,
2034 bgp_maxmed_admin_cmd
,
2035 "bgp max-med administrative ",
2037 "Advertise routes with max-med\n"
2038 "Administratively applied, for an indefinite period\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2042 bgp
->v_maxmed_admin
= 1;
2043 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2045 bgp_maxmed_update(bgp
);
2050 DEFUN (bgp_maxmed_admin_medv
,
2051 bgp_maxmed_admin_medv_cmd
,
2052 "bgp max-med administrative (0-4294967295)",
2054 "Advertise routes with max-med\n"
2055 "Administratively applied, for an indefinite period\n"
2056 "Max MED value to be used\n")
2058 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2061 bgp
->v_maxmed_admin
= 1;
2062 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2064 bgp_maxmed_update(bgp
);
2069 DEFUN (no_bgp_maxmed_admin
,
2070 no_bgp_maxmed_admin_cmd
,
2071 "no bgp max-med administrative [(0-4294967295)]",
2074 "Advertise routes with max-med\n"
2075 "Administratively applied, for an indefinite period\n"
2076 "Max MED value to be used\n")
2078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2080 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2081 bgp_maxmed_update(bgp
);
2086 DEFUN (bgp_maxmed_onstartup
,
2087 bgp_maxmed_onstartup_cmd
,
2088 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2090 "Advertise routes with max-med\n"
2091 "Effective on a startup\n"
2092 "Time (seconds) period for max-med\n"
2093 "Max MED value to be used\n")
2095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2098 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2099 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2100 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2101 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2103 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2105 bgp_maxmed_update(bgp
);
2110 DEFUN (no_bgp_maxmed_onstartup
,
2111 no_bgp_maxmed_onstartup_cmd
,
2112 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2115 "Advertise routes with max-med\n"
2116 "Effective on a startup\n"
2117 "Time (seconds) period for max-med\n"
2118 "Max MED value to be used\n")
2120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2122 /* Cancel max-med onstartup if its on */
2123 if (bgp
->t_maxmed_onstartup
) {
2124 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2125 bgp
->maxmed_onstartup_over
= 1;
2128 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2129 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2131 bgp_maxmed_update(bgp
);
2136 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2137 uint16_t update_delay
,
2138 uint16_t establish_wait
)
2140 struct listnode
*node
, *nnode
;
2142 bool vrf_cfg
= false;
2145 * See if update-delay is set per-vrf and warn user to delete it
2146 * Note that we only need to check this if this is the first time
2147 * setting the global config.
2149 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2150 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2151 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2153 "%% update-delay configuration found in vrf %s\n",
2154 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2164 "%%Failed: global update-delay config not permitted\n");
2168 if (!establish_wait
) { /* update-delay <delay> */
2169 bm
->v_update_delay
= update_delay
;
2170 bm
->v_establish_wait
= bm
->v_update_delay
;
2172 /* update-delay <delay> <establish-wait> */
2173 if (update_delay
< establish_wait
) {
2175 "%%Failed: update-delay less than the establish-wait!\n");
2176 return CMD_WARNING_CONFIG_FAILED
;
2179 bm
->v_update_delay
= update_delay
;
2180 bm
->v_establish_wait
= establish_wait
;
2183 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2184 bgp
->v_update_delay
= bm
->v_update_delay
;
2185 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2191 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2193 struct listnode
*node
, *nnode
;
2196 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2197 bm
->v_establish_wait
= bm
->v_update_delay
;
2199 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2200 bgp
->v_update_delay
= bm
->v_update_delay
;
2201 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2207 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2208 uint16_t establish_wait
)
2210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2212 /* if configured globally, per-instance config is not allowed */
2213 if (bm
->v_update_delay
) {
2215 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2216 return CMD_WARNING_CONFIG_FAILED
;
2220 if (!establish_wait
) /* update-delay <delay> */
2222 bgp
->v_update_delay
= update_delay
;
2223 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2227 /* update-delay <delay> <establish-wait> */
2228 if (update_delay
< establish_wait
) {
2230 "%%Failed: update-delay less than the establish-wait!\n");
2231 return CMD_WARNING_CONFIG_FAILED
;
2234 bgp
->v_update_delay
= update_delay
;
2235 bgp
->v_establish_wait
= establish_wait
;
2240 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2244 /* If configured globally, cannot remove from one bgp instance */
2245 if (bm
->v_update_delay
) {
2247 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2248 return CMD_WARNING_CONFIG_FAILED
;
2250 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2251 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2256 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2258 /* If configured globally, no need to display per-instance value */
2259 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2260 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2261 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2262 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2267 /* Global update-delay configuration */
2268 DEFPY (bgp_global_update_delay
,
2269 bgp_global_update_delay_cmd
,
2270 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2272 "Force initial delay for best-path and updates for all bgp instances\n"
2273 "Max delay in seconds\n"
2274 "Establish wait in seconds\n")
2276 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2279 /* Global update-delay deconfiguration */
2280 DEFPY (no_bgp_global_update_delay
,
2281 no_bgp_global_update_delay_cmd
,
2282 "no bgp 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_global_update_delay_deconfig_vty(vty
);
2292 /* Update-delay configuration */
2294 DEFPY (bgp_update_delay
,
2295 bgp_update_delay_cmd
,
2296 "update-delay (0-3600)$delay [(1-3600)$wait]",
2297 "Force initial delay for best-path and updates\n"
2298 "Max delay in seconds\n"
2299 "Establish wait in seconds\n")
2301 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2304 /* Update-delay deconfiguration */
2305 DEFPY (no_bgp_update_delay
,
2306 no_bgp_update_delay_cmd
,
2307 "no update-delay [(0-3600) [(1-3600)]]",
2309 "Force initial delay for best-path and updates\n"
2310 "Max delay in seconds\n"
2311 "Establish wait in seconds\n")
2313 return bgp_update_delay_deconfig_vty(vty
);
2317 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2322 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2323 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2328 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2331 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2333 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2334 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2339 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2342 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2343 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2344 vty_out(vty
, " write-quanta %d\n", quanta
);
2347 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2350 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2351 if (quanta
!= BGP_READ_PACKET_MAX
)
2352 vty_out(vty
, " read-quanta %d\n", quanta
);
2355 /* Packet quanta configuration
2357 * XXX: The value set here controls the size of a stack buffer in the IO
2358 * thread. When changing these limits be careful to prevent stack overflow.
2360 * Furthermore, the maximums used here should correspond to
2361 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2363 DEFPY (bgp_wpkt_quanta
,
2364 bgp_wpkt_quanta_cmd
,
2365 "[no] write-quanta (1-64)$quanta",
2367 "How many packets to write to peer socket per run\n"
2368 "Number of packets\n")
2370 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2373 DEFPY (bgp_rpkt_quanta
,
2374 bgp_rpkt_quanta_cmd
,
2375 "[no] read-quanta (1-10)$quanta",
2377 "How many packets to read from peer socket per I/O cycle\n"
2378 "Number of packets\n")
2380 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2383 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2385 if (!bgp
->heuristic_coalesce
)
2386 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2389 /* BGP TCP keepalive */
2390 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2392 if (bgp
->tcp_keepalive_idle
) {
2393 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2394 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2395 bgp
->tcp_keepalive_probes
);
2399 DEFUN (bgp_coalesce_time
,
2400 bgp_coalesce_time_cmd
,
2401 "coalesce-time (0-4294967295)",
2402 "Subgroup coalesce timer\n"
2403 "Subgroup coalesce timer value (in ms)\n")
2405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2409 bgp
->heuristic_coalesce
= false;
2411 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2412 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2417 DEFUN (no_bgp_coalesce_time
,
2418 no_bgp_coalesce_time_cmd
,
2419 "no coalesce-time (0-4294967295)",
2421 "Subgroup coalesce timer\n"
2422 "Subgroup coalesce timer value (in ms)\n")
2424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2426 bgp
->heuristic_coalesce
= true;
2427 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2431 /* Maximum-paths configuration */
2432 DEFUN (bgp_maxpaths
,
2434 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2435 "Forward packets over multiple paths\n"
2436 "Number of paths\n")
2439 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2440 argv
[idx_number
]->arg
, 0, 1);
2443 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2444 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2445 "Forward packets over multiple paths\n"
2446 "Number of paths\n")
2448 DEFUN (bgp_maxpaths_ibgp
,
2449 bgp_maxpaths_ibgp_cmd
,
2450 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2451 "Forward packets over multiple paths\n"
2453 "Number of paths\n")
2456 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2457 argv
[idx_number
]->arg
, 0, 1);
2460 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2461 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2462 "Forward packets over multiple paths\n"
2464 "Number of paths\n")
2466 DEFUN (bgp_maxpaths_ibgp_cluster
,
2467 bgp_maxpaths_ibgp_cluster_cmd
,
2468 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2469 "Forward packets over multiple paths\n"
2472 "Match the cluster length\n")
2475 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2476 argv
[idx_number
]->arg
, true, 1);
2479 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2480 "maximum-paths ibgp " CMD_RANGE_STR(
2481 1, MULTIPATH_NUM
) " equal-cluster-length",
2482 "Forward packets over multiple paths\n"
2485 "Match the cluster length\n")
2487 DEFUN (no_bgp_maxpaths
,
2488 no_bgp_maxpaths_cmd
,
2489 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2491 "Forward packets over multiple paths\n"
2492 "Number of paths\n")
2494 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2497 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2498 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2499 "Forward packets over multiple paths\n"
2500 "Number of paths\n")
2502 DEFUN (no_bgp_maxpaths_ibgp
,
2503 no_bgp_maxpaths_ibgp_cmd
,
2504 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2506 "Forward packets over multiple paths\n"
2509 "Match the cluster length\n")
2511 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2514 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2515 "no maximum-paths ibgp [" CMD_RANGE_STR(
2516 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2518 "Forward packets over multiple paths\n"
2521 "Match the cluster length\n")
2523 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2524 afi_t afi
, safi_t safi
)
2526 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2527 vty_out(vty
, " maximum-paths %d\n",
2528 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2531 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2532 vty_out(vty
, " maximum-paths ibgp %d",
2533 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2534 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2535 vty_out(vty
, " equal-cluster-length");
2544 "timers bgp (0-65535) (0-65535)",
2545 "Adjust routing timers\n"
2547 "Keepalive interval\n"
2550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2552 int idx_number_2
= 3;
2553 unsigned long keepalive
= 0;
2554 unsigned long holdtime
= 0;
2556 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2557 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2559 /* Holdtime value check. */
2560 if (holdtime
< 3 && holdtime
!= 0) {
2562 "%% hold time value must be either 0 or greater than 3\n");
2563 return CMD_WARNING_CONFIG_FAILED
;
2566 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2567 BGP_DEFAULT_DELAYOPEN
);
2572 DEFUN (no_bgp_timers
,
2574 "no timers bgp [(0-65535) (0-65535)]",
2576 "Adjust routing timers\n"
2578 "Keepalive interval\n"
2581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2582 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2583 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2588 /* BGP minimum holdtime. */
2590 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2591 "bgp minimum-holdtime (1-65535)",
2592 "BGP specific commands\n"
2593 "BGP minimum holdtime\n"
2596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2598 unsigned long min_holdtime
;
2600 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2602 bgp
->default_min_holdtime
= min_holdtime
;
2607 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2608 "no bgp minimum-holdtime [(1-65535)]",
2610 "BGP specific commands\n"
2611 "BGP minimum holdtime\n"
2614 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2616 bgp
->default_min_holdtime
= 0;
2621 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2622 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2624 "TCP keepalive parameters\n"
2625 "TCP keepalive idle time (seconds)\n"
2626 "TCP keepalive interval (seconds)\n"
2627 "TCP keepalive maximum probes\n")
2629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2631 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2637 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2638 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2641 "TCP keepalive parameters\n"
2642 "TCP keepalive idle time (seconds)\n"
2643 "TCP keepalive interval (seconds)\n"
2644 "TCP keepalive maximum probes\n")
2646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2648 bgp_tcp_keepalive_unset(bgp
);
2653 DEFUN (bgp_client_to_client_reflection
,
2654 bgp_client_to_client_reflection_cmd
,
2655 "bgp client-to-client reflection",
2657 "Configure client to client route reflection\n"
2658 "reflection of routes allowed\n")
2660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2661 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2662 bgp_clear_star_soft_out(vty
, bgp
->name
);
2667 DEFUN (no_bgp_client_to_client_reflection
,
2668 no_bgp_client_to_client_reflection_cmd
,
2669 "no bgp client-to-client reflection",
2672 "Configure client to client route reflection\n"
2673 "reflection of routes allowed\n")
2675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2676 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2677 bgp_clear_star_soft_out(vty
, bgp
->name
);
2682 /* "bgp always-compare-med" configuration. */
2683 DEFUN (bgp_always_compare_med
,
2684 bgp_always_compare_med_cmd
,
2685 "bgp always-compare-med",
2687 "Allow comparing MED from different neighbors\n")
2689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2690 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2691 bgp_recalculate_all_bestpaths(bgp
);
2696 DEFUN (no_bgp_always_compare_med
,
2697 no_bgp_always_compare_med_cmd
,
2698 "no bgp always-compare-med",
2701 "Allow comparing MED from different neighbors\n")
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2705 bgp_recalculate_all_bestpaths(bgp
);
2711 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2712 "bgp ebgp-requires-policy",
2714 "Require in and out policy for eBGP peers (RFC8212)\n")
2716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2717 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2721 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2722 "no bgp ebgp-requires-policy",
2725 "Require in and out policy for eBGP peers (RFC8212)\n")
2727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2728 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2732 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2733 "bgp suppress-duplicates",
2735 "Suppress duplicate updates if the route actually not changed\n")
2737 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2738 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2742 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2743 "no bgp suppress-duplicates",
2746 "Suppress duplicate updates if the route actually not changed\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2749 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2753 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2754 "bgp reject-as-sets",
2756 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2759 struct listnode
*node
, *nnode
;
2762 bgp
->reject_as_sets
= true;
2764 /* Reset existing BGP sessions to reject routes
2765 * with aspath containing AS_SET or AS_CONFED_SET.
2767 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2768 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2769 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2770 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2771 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2778 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2779 "no bgp reject-as-sets",
2782 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2785 struct listnode
*node
, *nnode
;
2788 bgp
->reject_as_sets
= false;
2790 /* Reset existing BGP sessions to reject routes
2791 * with aspath containing AS_SET or AS_CONFED_SET.
2793 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2794 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2795 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2796 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2797 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2804 /* "bgp deterministic-med" configuration. */
2805 DEFUN (bgp_deterministic_med
,
2806 bgp_deterministic_med_cmd
,
2807 "bgp deterministic-med",
2809 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2813 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2814 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2815 bgp_recalculate_all_bestpaths(bgp
);
2821 DEFUN (no_bgp_deterministic_med
,
2822 no_bgp_deterministic_med_cmd
,
2823 "no bgp deterministic-med",
2826 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2829 int bestpath_per_as_used
;
2833 struct listnode
*node
, *nnode
;
2835 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2836 bestpath_per_as_used
= 0;
2838 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2839 FOREACH_AFI_SAFI (afi
, safi
)
2840 if (bgp_addpath_dmed_required(
2841 peer
->addpath_type
[afi
][safi
])) {
2842 bestpath_per_as_used
= 1;
2846 if (bestpath_per_as_used
)
2850 if (bestpath_per_as_used
) {
2852 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2853 return CMD_WARNING_CONFIG_FAILED
;
2855 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2856 bgp_recalculate_all_bestpaths(bgp
);
2863 /* "bgp graceful-restart mode" configuration. */
2864 DEFUN (bgp_graceful_restart
,
2865 bgp_graceful_restart_cmd
,
2866 "bgp graceful-restart",
2871 int ret
= BGP_GR_FAILURE
;
2873 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2874 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2878 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2880 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2883 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2884 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2886 "Graceful restart configuration changed, reset all peers to take effect\n");
2887 return bgp_vty_return(vty
, ret
);
2890 DEFUN (no_bgp_graceful_restart
,
2891 no_bgp_graceful_restart_cmd
,
2892 "no bgp graceful-restart",
2898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2900 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2901 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2903 int ret
= BGP_GR_FAILURE
;
2905 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2907 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2910 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2911 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2913 "Graceful restart configuration changed, reset all peers to take effect\n");
2915 return bgp_vty_return(vty
, ret
);
2918 DEFUN (bgp_graceful_restart_stalepath_time
,
2919 bgp_graceful_restart_stalepath_time_cmd
,
2920 "bgp graceful-restart stalepath-time (1-4095)",
2922 "Graceful restart capability parameters\n"
2923 "Set the max time to hold onto restarting peer's stale paths\n"
2924 "Delay value (seconds)\n")
2926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2930 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2931 bgp
->stalepath_time
= stalepath
;
2935 DEFUN (bgp_graceful_restart_restart_time
,
2936 bgp_graceful_restart_restart_time_cmd
,
2937 "bgp graceful-restart restart-time (0-4095)",
2939 "Graceful restart capability parameters\n"
2940 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2941 "Delay value (seconds)\n")
2943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2947 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2948 bgp
->restart_time
= restart
;
2952 DEFUN (bgp_graceful_restart_select_defer_time
,
2953 bgp_graceful_restart_select_defer_time_cmd
,
2954 "bgp graceful-restart select-defer-time (0-3600)",
2956 "Graceful restart capability parameters\n"
2957 "Set the time to defer the BGP route selection after restart\n"
2958 "Delay value (seconds, 0 - disable)\n")
2960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2962 uint32_t defer_time
;
2964 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2965 bgp
->select_defer_time
= defer_time
;
2966 if (defer_time
== 0)
2967 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2969 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2974 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2975 no_bgp_graceful_restart_stalepath_time_cmd
,
2976 "no bgp graceful-restart stalepath-time [(1-4095)]",
2979 "Graceful restart capability parameters\n"
2980 "Set the max time to hold onto restarting peer's stale paths\n"
2981 "Delay value (seconds)\n")
2983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2985 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2989 DEFUN (no_bgp_graceful_restart_restart_time
,
2990 no_bgp_graceful_restart_restart_time_cmd
,
2991 "no bgp graceful-restart restart-time [(0-4095)]",
2994 "Graceful restart capability parameters\n"
2995 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2996 "Delay value (seconds)\n")
2998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3000 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3004 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3005 no_bgp_graceful_restart_select_defer_time_cmd
,
3006 "no bgp graceful-restart select-defer-time [(0-3600)]",
3009 "Graceful restart capability parameters\n"
3010 "Set the time to defer the BGP route selection after restart\n"
3011 "Delay value (seconds)\n")
3013 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3015 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3016 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3021 DEFUN (bgp_graceful_restart_preserve_fw
,
3022 bgp_graceful_restart_preserve_fw_cmd
,
3023 "bgp graceful-restart preserve-fw-state",
3025 "Graceful restart capability parameters\n"
3026 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3029 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3033 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3034 no_bgp_graceful_restart_preserve_fw_cmd
,
3035 "no bgp graceful-restart preserve-fw-state",
3038 "Graceful restart capability parameters\n"
3039 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3041 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3042 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3046 DEFPY (bgp_graceful_restart_notification
,
3047 bgp_graceful_restart_notification_cmd
,
3048 "[no$no] bgp graceful-restart notification",
3051 "Graceful restart capability parameters\n"
3052 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3057 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3059 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3064 DEFPY (bgp_administrative_reset
,
3065 bgp_administrative_reset_cmd
,
3066 "[no$no] bgp hard-administrative-reset",
3069 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3074 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3076 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3081 DEFUN (bgp_graceful_restart_disable
,
3082 bgp_graceful_restart_disable_cmd
,
3083 "bgp graceful-restart-disable",
3087 int ret
= BGP_GR_FAILURE
;
3089 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3091 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3095 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3097 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3100 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3102 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3104 "Graceful restart configuration changed, reset all peers to take effect\n");
3106 return bgp_vty_return(vty
, ret
);
3109 DEFUN (no_bgp_graceful_restart_disable
,
3110 no_bgp_graceful_restart_disable_cmd
,
3111 "no bgp graceful-restart-disable",
3117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3119 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3121 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3123 int ret
= BGP_GR_FAILURE
;
3125 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3127 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3130 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3132 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3134 "Graceful restart configuration changed, reset all peers to take effect\n");
3136 return bgp_vty_return(vty
, ret
);
3139 DEFUN (bgp_neighbor_graceful_restart_set
,
3140 bgp_neighbor_graceful_restart_set_cmd
,
3141 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3149 int ret
= BGP_GR_FAILURE
;
3151 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3153 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3155 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3157 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3159 return CMD_WARNING_CONFIG_FAILED
;
3161 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3163 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3164 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3166 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3168 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3170 "Graceful restart configuration changed, reset this peer to take effect\n");
3172 return bgp_vty_return(vty
, ret
);
3175 DEFUN (no_bgp_neighbor_graceful_restart
,
3176 no_bgp_neighbor_graceful_restart_set_cmd
,
3177 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3185 int ret
= BGP_GR_FAILURE
;
3188 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3190 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3192 return CMD_WARNING_CONFIG_FAILED
;
3194 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3196 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3198 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3200 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3201 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3203 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3205 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3207 "Graceful restart configuration changed, reset this peer to take effect\n");
3209 return bgp_vty_return(vty
, ret
);
3212 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3213 bgp_neighbor_graceful_restart_helper_set_cmd
,
3214 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3217 GR_NEIGHBOR_HELPER_CMD
3222 int ret
= BGP_GR_FAILURE
;
3224 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3226 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3228 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3233 return CMD_WARNING_CONFIG_FAILED
;
3236 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3238 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3239 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3241 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3243 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3245 "Graceful restart configuration changed, reset this peer to take effect\n");
3247 return bgp_vty_return(vty
, ret
);
3250 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3251 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3252 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3256 NO_GR_NEIGHBOR_HELPER_CMD
3260 int ret
= BGP_GR_FAILURE
;
3263 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3265 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3267 return CMD_WARNING_CONFIG_FAILED
;
3269 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3271 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3273 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3275 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3276 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3278 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3280 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3282 "Graceful restart configuration changed, reset this peer to take effect\n");
3284 return bgp_vty_return(vty
, ret
);
3287 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3288 bgp_neighbor_graceful_restart_disable_set_cmd
,
3289 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3292 GR_NEIGHBOR_DISABLE_CMD
3297 int ret
= BGP_GR_FAILURE
;
3299 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3301 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3303 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3305 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3307 return CMD_WARNING_CONFIG_FAILED
;
3309 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3311 if (peer
->bgp
->t_startup
)
3312 bgp_peer_gr_flags_update(peer
);
3314 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3315 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3317 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3319 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3321 "Graceful restart configuration changed, reset this peer to take effect\n");
3323 return bgp_vty_return(vty
, ret
);
3326 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3327 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3328 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3332 NO_GR_NEIGHBOR_DISABLE_CMD
3336 int ret
= BGP_GR_FAILURE
;
3339 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3341 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3343 return CMD_WARNING_CONFIG_FAILED
;
3345 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3347 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3349 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3351 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3352 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3354 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3356 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3358 "Graceful restart configuration changed, reset this peer to take effect\n");
3360 return bgp_vty_return(vty
, ret
);
3363 DEFPY (neighbor_graceful_shutdown
,
3364 neighbor_graceful_shutdown_cmd
,
3365 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3369 "Graceful shutdown\n")
3374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3377 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3379 return CMD_WARNING_CONFIG_FAILED
;
3382 ret
= peer_flag_unset_vty(vty
, neighbor
,
3383 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3385 ret
= peer_flag_set_vty(vty
, neighbor
,
3386 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3388 FOREACH_AFI_SAFI (afi
, safi
) {
3389 if (!peer
->afc
[afi
][safi
])
3392 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3399 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3400 bgp_graceful_restart_disable_eor_cmd
,
3401 "bgp graceful-restart disable-eor",
3403 "Graceful restart configuration parameters\n"
3404 "Disable EOR Check\n")
3406 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3407 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3412 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3413 no_bgp_graceful_restart_disable_eor_cmd
,
3414 "no bgp graceful-restart disable-eor",
3417 "Graceful restart configuration parameters\n"
3418 "Disable EOR Check\n")
3420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3421 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3426 DEFUN (bgp_graceful_restart_rib_stale_time
,
3427 bgp_graceful_restart_rib_stale_time_cmd
,
3428 "bgp graceful-restart rib-stale-time (1-3600)",
3430 "Graceful restart configuration parameters\n"
3431 "Specify the stale route removal timer in rib\n"
3432 "Delay value (seconds)\n")
3434 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3436 uint32_t stale_time
;
3438 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3439 bgp
->rib_stale_time
= stale_time
;
3440 /* Send the stale timer update message to RIB */
3441 if (bgp_zebra_stale_timer_update(bgp
))
3447 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3448 no_bgp_graceful_restart_rib_stale_time_cmd
,
3449 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3452 "Graceful restart configuration parameters\n"
3453 "Specify the stale route removal timer in rib\n"
3454 "Delay value (seconds)\n")
3456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3458 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3459 /* Send the stale timer update message to RIB */
3460 if (bgp_zebra_stale_timer_update(bgp
))
3466 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3467 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3469 "Enable Long-lived Graceful Restart\n"
3470 "Specifies maximum time to wait before purging long-lived stale routes\n"
3471 "Stale time value (seconds)\n")
3473 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3475 uint32_t llgr_stale_time
;
3477 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3478 bgp
->llgr_stale_time
= llgr_stale_time
;
3483 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3484 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3486 "Enable Long-lived Graceful Restart\n"
3487 "Specifies maximum time to wait before purging long-lived stale routes\n"
3488 "Stale time value (seconds)\n")
3490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3492 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3497 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3500 bgp_static_redo_import_check(bgp
);
3501 bgp_redistribute_redo(bgp
);
3502 bgp_clear_star_soft_out(vty
, bgp
->name
);
3503 bgp_clear_star_soft_in(vty
, bgp
->name
);
3506 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3508 struct listnode
*node
, *nnode
;
3510 bool vrf_cfg
= false;
3512 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3515 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3516 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3517 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3519 "%% graceful-shutdown configuration found in vrf %s\n",
3520 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3521 VRF_DEFAULT_NAME
: bgp
->name
);
3528 "%%Failed: global graceful-shutdown not permitted\n");
3532 /* Set flag globally */
3533 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3535 /* Initiate processing for all BGP instances. */
3536 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3537 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3542 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3544 struct listnode
*node
, *nnode
;
3547 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3550 /* Unset flag globally */
3551 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3553 /* Initiate processing for all BGP instances. */
3554 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3555 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3560 /* "bgp graceful-shutdown" configuration */
3561 DEFUN (bgp_graceful_shutdown
,
3562 bgp_graceful_shutdown_cmd
,
3563 "bgp graceful-shutdown",
3565 "Graceful shutdown parameters\n")
3567 if (vty
->node
== CONFIG_NODE
)
3568 return bgp_global_graceful_shutdown_config_vty(vty
);
3570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3572 /* if configured globally, per-instance config is not allowed */
3573 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3575 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3576 return CMD_WARNING_CONFIG_FAILED
;
3579 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3580 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3581 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3587 DEFUN (no_bgp_graceful_shutdown
,
3588 no_bgp_graceful_shutdown_cmd
,
3589 "no bgp graceful-shutdown",
3592 "Graceful shutdown parameters\n")
3594 if (vty
->node
== CONFIG_NODE
)
3595 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3599 /* If configured globally, cannot remove from one bgp instance */
3600 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3602 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3603 return CMD_WARNING_CONFIG_FAILED
;
3606 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3607 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3608 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3614 /* "bgp fast-external-failover" configuration. */
3615 DEFUN (bgp_fast_external_failover
,
3616 bgp_fast_external_failover_cmd
,
3617 "bgp fast-external-failover",
3619 "Immediately reset session if a link to a directly connected external peer goes down\n")
3621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3622 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3626 DEFUN (no_bgp_fast_external_failover
,
3627 no_bgp_fast_external_failover_cmd
,
3628 "no bgp fast-external-failover",
3631 "Immediately reset session if a link to a directly connected external peer goes down\n")
3633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3634 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3638 DEFPY (bgp_bestpath_aigp
,
3639 bgp_bestpath_aigp_cmd
,
3640 "[no$no] bgp bestpath aigp",
3643 "Change the default bestpath selection\n"
3644 "Evaluate the AIGP attribute during the best path selection process\n")
3646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3649 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3651 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3653 bgp_recalculate_all_bestpaths(bgp
);
3658 /* "bgp bestpath compare-routerid" configuration. */
3659 DEFUN (bgp_bestpath_compare_router_id
,
3660 bgp_bestpath_compare_router_id_cmd
,
3661 "bgp bestpath compare-routerid",
3663 "Change the default bestpath selection\n"
3664 "Compare router-id for identical EBGP paths\n")
3666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3667 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3668 bgp_recalculate_all_bestpaths(bgp
);
3673 DEFUN (no_bgp_bestpath_compare_router_id
,
3674 no_bgp_bestpath_compare_router_id_cmd
,
3675 "no bgp bestpath compare-routerid",
3678 "Change the default bestpath selection\n"
3679 "Compare router-id for identical EBGP paths\n")
3681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3682 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3683 bgp_recalculate_all_bestpaths(bgp
);
3688 /* "bgp bestpath as-path ignore" configuration. */
3689 DEFUN (bgp_bestpath_aspath_ignore
,
3690 bgp_bestpath_aspath_ignore_cmd
,
3691 "bgp bestpath as-path ignore",
3693 "Change the default bestpath selection\n"
3694 "AS-path attribute\n"
3695 "Ignore as-path length in selecting a route\n")
3697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3698 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3699 bgp_recalculate_all_bestpaths(bgp
);
3704 DEFUN (no_bgp_bestpath_aspath_ignore
,
3705 no_bgp_bestpath_aspath_ignore_cmd
,
3706 "no bgp bestpath as-path ignore",
3709 "Change the default bestpath selection\n"
3710 "AS-path attribute\n"
3711 "Ignore as-path length in selecting a route\n")
3713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3714 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3715 bgp_recalculate_all_bestpaths(bgp
);
3720 /* "bgp bestpath as-path confed" configuration. */
3721 DEFUN (bgp_bestpath_aspath_confed
,
3722 bgp_bestpath_aspath_confed_cmd
,
3723 "bgp bestpath as-path confed",
3725 "Change the default bestpath selection\n"
3726 "AS-path attribute\n"
3727 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3730 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3731 bgp_recalculate_all_bestpaths(bgp
);
3736 DEFUN (no_bgp_bestpath_aspath_confed
,
3737 no_bgp_bestpath_aspath_confed_cmd
,
3738 "no bgp bestpath as-path confed",
3741 "Change the default bestpath selection\n"
3742 "AS-path attribute\n"
3743 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3745 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3746 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3747 bgp_recalculate_all_bestpaths(bgp
);
3752 /* "bgp bestpath as-path multipath-relax" configuration. */
3753 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3754 bgp_bestpath_aspath_multipath_relax_cmd
,
3755 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3757 "Change the default bestpath selection\n"
3758 "AS-path attribute\n"
3759 "Allow load sharing across routes that have different AS paths (but same length)\n"
3760 "Generate an AS_SET\n"
3761 "Do not generate an AS_SET\n")
3763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3765 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3767 /* no-as-set is now the default behavior so we can silently
3769 if (argv_find(argv
, argc
, "as-set", &idx
))
3770 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3772 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3774 bgp_recalculate_all_bestpaths(bgp
);
3779 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3780 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3781 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3784 "Change the default bestpath selection\n"
3785 "AS-path attribute\n"
3786 "Allow load sharing across routes that have different AS paths (but same length)\n"
3787 "Generate an AS_SET\n"
3788 "Do not generate an AS_SET\n")
3790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3791 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3792 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3793 bgp_recalculate_all_bestpaths(bgp
);
3798 /* "bgp bestpath peer-type multipath-relax" configuration. */
3799 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3800 bgp_bestpath_peer_type_multipath_relax_cmd
,
3801 "bgp bestpath peer-type multipath-relax",
3803 "Change the default bestpath selection\n"
3805 "Allow load sharing across routes learned from different peer types\n")
3807 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3808 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3809 bgp_recalculate_all_bestpaths(bgp
);
3814 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3815 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3816 "no bgp bestpath peer-type multipath-relax",
3818 "Change the default bestpath selection\n"
3820 "Allow load sharing across routes learned from different peer types\n")
3822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3823 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3824 bgp_recalculate_all_bestpaths(bgp
);
3829 /* "bgp log-neighbor-changes" configuration. */
3830 DEFUN (bgp_log_neighbor_changes
,
3831 bgp_log_neighbor_changes_cmd
,
3832 "bgp log-neighbor-changes",
3834 "Log neighbor up/down and reset reason\n")
3836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3837 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3841 DEFUN (no_bgp_log_neighbor_changes
,
3842 no_bgp_log_neighbor_changes_cmd
,
3843 "no bgp log-neighbor-changes",
3846 "Log neighbor up/down and reset reason\n")
3848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3849 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3853 /* "bgp bestpath med" configuration. */
3854 DEFUN (bgp_bestpath_med
,
3855 bgp_bestpath_med_cmd
,
3856 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3858 "Change the default bestpath selection\n"
3860 "Compare MED among confederation paths\n"
3861 "Treat missing MED as the least preferred one\n"
3862 "Treat missing MED as the least preferred one\n"
3863 "Compare MED among confederation paths\n")
3865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3868 if (argv_find(argv
, argc
, "confed", &idx
))
3869 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3871 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3872 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3874 bgp_recalculate_all_bestpaths(bgp
);
3879 DEFUN (no_bgp_bestpath_med
,
3880 no_bgp_bestpath_med_cmd
,
3881 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3884 "Change the default bestpath selection\n"
3886 "Compare MED among confederation paths\n"
3887 "Treat missing MED as the least preferred one\n"
3888 "Treat missing MED as the least preferred one\n"
3889 "Compare MED among confederation paths\n")
3891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3894 if (argv_find(argv
, argc
, "confed", &idx
))
3895 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3897 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3898 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3900 bgp_recalculate_all_bestpaths(bgp
);
3905 /* "bgp bestpath bandwidth" configuration. */
3906 DEFPY (bgp_bestpath_bw
,
3907 bgp_bestpath_bw_cmd
,
3908 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3910 "Change the default bestpath selection\n"
3911 "Link Bandwidth attribute\n"
3912 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3913 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3914 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3921 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3922 return CMD_ERR_INCOMPLETE
;
3924 if (!strcmp(bw_cfg
, "ignore"))
3925 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3926 else if (!strcmp(bw_cfg
, "skip-missing"))
3927 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3928 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3929 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3931 return CMD_ERR_NO_MATCH
;
3933 /* This config is used in route install, so redo that. */
3934 FOREACH_AFI_SAFI (afi
, safi
) {
3935 if (!bgp_fibupd_safi(safi
))
3937 bgp_zebra_announce_table(bgp
, afi
, safi
);
3943 DEFPY (no_bgp_bestpath_bw
,
3944 no_bgp_bestpath_bw_cmd
,
3945 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3948 "Change the default bestpath selection\n"
3949 "Link Bandwidth attribute\n"
3950 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3951 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3952 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3958 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3960 /* This config is used in route install, so redo that. */
3961 FOREACH_AFI_SAFI (afi
, safi
) {
3962 if (!bgp_fibupd_safi(safi
))
3964 bgp_zebra_announce_table(bgp
, afi
, safi
);
3969 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3970 "[no] bgp default <ipv4-unicast|"
3973 "ipv4-labeled-unicast|"
3978 "ipv6-labeled-unicast|"
3980 "l2vpn-evpn>$afi_safi",
3983 "Configure BGP defaults\n"
3984 "Activate ipv4-unicast for a peer by default\n"
3985 "Activate ipv4-multicast for a peer by default\n"
3986 "Activate ipv4-vpn for a peer by default\n"
3987 "Activate ipv4-labeled-unicast for a peer by default\n"
3988 "Activate ipv4-flowspec for a peer by default\n"
3989 "Activate ipv6-unicast for a peer by default\n"
3990 "Activate ipv6-multicast for a peer by default\n"
3991 "Activate ipv6-vpn for a peer by default\n"
3992 "Activate ipv6-labeled-unicast for a peer by default\n"
3993 "Activate ipv6-flowspec for a peer by default\n"
3994 "Activate l2vpn-evpn for a peer by default\n")
3996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3997 char afi_safi_str
[strlen(afi_safi
) + 1];
3998 char *afi_safi_str_tok
;
4000 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4001 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4002 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4003 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4007 * Impossible situation but making coverity happy
4009 assert(afi
!= AFI_MAX
);
4011 if (strmatch(safi_str
, "labeled"))
4012 safi
= bgp_vty_safi_from_str("labeled-unicast");
4014 safi
= bgp_vty_safi_from_str(safi_str
);
4016 assert(safi
!= SAFI_MAX
);
4018 bgp
->default_af
[afi
][safi
] = false;
4020 if ((safi
== SAFI_LABELED_UNICAST
4021 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4022 || (safi
== SAFI_UNICAST
4023 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4024 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4026 bgp
->default_af
[afi
][safi
] = true;
4032 /* Display hostname in certain command outputs */
4033 DEFUN (bgp_default_show_hostname
,
4034 bgp_default_show_hostname_cmd
,
4035 "bgp default show-hostname",
4037 "Configure BGP defaults\n"
4038 "Show hostname in certain command outputs\n")
4040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4041 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4045 DEFUN (no_bgp_default_show_hostname
,
4046 no_bgp_default_show_hostname_cmd
,
4047 "no bgp default show-hostname",
4050 "Configure BGP defaults\n"
4051 "Show hostname in certain command outputs\n")
4053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4054 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4058 /* Display hostname in certain command outputs */
4059 DEFUN (bgp_default_show_nexthop_hostname
,
4060 bgp_default_show_nexthop_hostname_cmd
,
4061 "bgp default show-nexthop-hostname",
4063 "Configure BGP defaults\n"
4064 "Show hostname for nexthop in certain command outputs\n")
4066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4067 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4071 DEFUN (no_bgp_default_show_nexthop_hostname
,
4072 no_bgp_default_show_nexthop_hostname_cmd
,
4073 "no bgp default show-nexthop-hostname",
4076 "Configure BGP defaults\n"
4077 "Show hostname for nexthop in certain command outputs\n")
4079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4080 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4084 /* "bgp network import-check" configuration. */
4085 DEFUN (bgp_network_import_check
,
4086 bgp_network_import_check_cmd
,
4087 "bgp network import-check",
4089 "BGP network command\n"
4090 "Check BGP network route exists in IGP\n")
4092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4093 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4094 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4095 bgp_static_redo_import_check(bgp
);
4101 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4102 "bgp network import-check exact",
4104 "BGP network command\n"
4105 "Check BGP network route exists in IGP\n"
4106 "Match route precisely\n")
4108 DEFUN (no_bgp_network_import_check
,
4109 no_bgp_network_import_check_cmd
,
4110 "no bgp network import-check",
4113 "BGP network command\n"
4114 "Check BGP network route exists in IGP\n")
4116 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4117 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4118 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4119 bgp_static_redo_import_check(bgp
);
4125 DEFUN (bgp_default_local_preference
,
4126 bgp_default_local_preference_cmd
,
4127 "bgp default local-preference (0-4294967295)",
4129 "Configure BGP defaults\n"
4130 "local preference (higher=more preferred)\n"
4131 "Configure default local preference value\n")
4133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4135 uint32_t local_pref
;
4137 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4139 bgp_default_local_preference_set(bgp
, local_pref
);
4140 bgp_clear_star_soft_in(vty
, bgp
->name
);
4145 DEFUN (no_bgp_default_local_preference
,
4146 no_bgp_default_local_preference_cmd
,
4147 "no bgp default local-preference [(0-4294967295)]",
4150 "Configure BGP defaults\n"
4151 "local preference (higher=more preferred)\n"
4152 "Configure default local preference value\n")
4154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4155 bgp_default_local_preference_unset(bgp
);
4156 bgp_clear_star_soft_in(vty
, bgp
->name
);
4162 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4163 bgp_default_subgroup_pkt_queue_max_cmd
,
4164 "bgp default subgroup-pkt-queue-max (20-100)",
4166 "Configure BGP defaults\n"
4167 "subgroup-pkt-queue-max\n"
4168 "Configure subgroup packet queue max\n")
4170 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4174 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4176 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4181 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4182 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4183 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4186 "Configure BGP defaults\n"
4187 "subgroup-pkt-queue-max\n"
4188 "Configure subgroup packet queue max\n")
4190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4191 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4196 DEFUN (bgp_rr_allow_outbound_policy
,
4197 bgp_rr_allow_outbound_policy_cmd
,
4198 "bgp route-reflector allow-outbound-policy",
4200 "Allow modifications made by out route-map\n"
4201 "on ibgp neighbors\n")
4203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4205 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4206 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4207 update_group_announce_rrclients(bgp
);
4208 bgp_clear_star_soft_out(vty
, bgp
->name
);
4214 DEFUN (no_bgp_rr_allow_outbound_policy
,
4215 no_bgp_rr_allow_outbound_policy_cmd
,
4216 "no bgp route-reflector allow-outbound-policy",
4219 "Allow modifications made by out route-map\n"
4220 "on ibgp neighbors\n")
4222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4224 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4225 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4226 update_group_announce_rrclients(bgp
);
4227 bgp_clear_star_soft_out(vty
, bgp
->name
);
4233 DEFUN (bgp_listen_limit
,
4234 bgp_listen_limit_cmd
,
4235 "bgp listen limit (1-65535)",
4237 "BGP Dynamic Neighbors listen commands\n"
4238 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4239 "Configure Dynamic Neighbors listen limit value\n")
4241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4245 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4247 bgp_listen_limit_set(bgp
, listen_limit
);
4252 DEFUN (no_bgp_listen_limit
,
4253 no_bgp_listen_limit_cmd
,
4254 "no bgp listen limit [(1-65535)]",
4257 "BGP Dynamic Neighbors listen commands\n"
4258 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4259 "Configure Dynamic Neighbors listen limit value\n")
4261 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4262 bgp_listen_limit_unset(bgp
);
4268 * Check if this listen range is already configured. Check for exact
4269 * match or overlap based on input.
4271 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4272 struct prefix
*range
, int exact
)
4274 struct listnode
*node
, *nnode
;
4275 struct listnode
*node1
, *nnode1
;
4276 struct peer_group
*group
;
4281 afi
= family2afi(range
->family
);
4282 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4283 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4286 match
= prefix_same(range
, lr
);
4288 match
= (prefix_match(range
, lr
)
4289 || prefix_match(lr
, range
));
4298 DEFUN (bgp_listen_range
,
4299 bgp_listen_range_cmd
,
4300 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4302 "Configure BGP dynamic neighbors listen range\n"
4303 "Configure BGP dynamic neighbors listen range\n"
4305 "Member of the peer-group\n"
4306 "Peer-group name\n")
4308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4309 struct prefix range
;
4310 struct peer_group
*group
, *existing_group
;
4315 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4316 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4317 char *prefix
= argv
[idx
]->arg
;
4318 argv_find(argv
, argc
, "PGNAME", &idx
);
4319 char *peergroup
= argv
[idx
]->arg
;
4321 /* Convert IP prefix string to struct prefix. */
4322 ret
= str2prefix(prefix
, &range
);
4324 vty_out(vty
, "%% Malformed listen range\n");
4325 return CMD_WARNING_CONFIG_FAILED
;
4328 afi
= family2afi(range
.family
);
4330 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4332 "%% Malformed listen range (link-local address)\n");
4333 return CMD_WARNING_CONFIG_FAILED
;
4338 /* Check if same listen range is already configured. */
4339 existing_group
= listen_range_exists(bgp
, &range
, 1);
4340 if (existing_group
) {
4341 if (strcmp(existing_group
->name
, peergroup
) == 0)
4345 "%% Same listen range is attached to peer-group %s\n",
4346 existing_group
->name
);
4347 return CMD_WARNING_CONFIG_FAILED
;
4351 /* Check if an overlapping listen range exists. */
4352 if (listen_range_exists(bgp
, &range
, 0)) {
4354 "%% Listen range overlaps with existing listen range\n");
4355 return CMD_WARNING_CONFIG_FAILED
;
4358 group
= peer_group_lookup(bgp
, peergroup
);
4360 vty_out(vty
, "%% Configure the peer-group first\n");
4361 return CMD_WARNING_CONFIG_FAILED
;
4364 ret
= peer_group_listen_range_add(group
, &range
);
4365 return bgp_vty_return(vty
, ret
);
4368 DEFUN (no_bgp_listen_range
,
4369 no_bgp_listen_range_cmd
,
4370 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4373 "Unconfigure BGP dynamic neighbors listen range\n"
4374 "Unconfigure BGP dynamic neighbors listen range\n"
4376 "Member of the peer-group\n"
4377 "Peer-group name\n")
4379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4380 struct prefix range
;
4381 struct peer_group
*group
;
4386 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4387 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4388 char *prefix
= argv
[idx
]->arg
;
4389 argv_find(argv
, argc
, "PGNAME", &idx
);
4390 char *peergroup
= argv
[idx
]->arg
;
4392 /* Convert IP prefix string to struct prefix. */
4393 ret
= str2prefix(prefix
, &range
);
4395 vty_out(vty
, "%% Malformed listen range\n");
4396 return CMD_WARNING_CONFIG_FAILED
;
4399 afi
= family2afi(range
.family
);
4401 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4403 "%% Malformed listen range (link-local address)\n");
4404 return CMD_WARNING_CONFIG_FAILED
;
4409 group
= peer_group_lookup(bgp
, peergroup
);
4411 vty_out(vty
, "%% Peer-group does not exist\n");
4412 return CMD_WARNING_CONFIG_FAILED
;
4415 ret
= peer_group_listen_range_del(group
, &range
);
4416 return bgp_vty_return(vty
, ret
);
4419 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4421 struct peer_group
*group
;
4422 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4423 struct prefix
*range
;
4426 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4427 vty_out(vty
, " bgp listen limit %d\n",
4428 bgp
->dynamic_neighbors_limit
);
4430 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4431 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4432 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4435 " bgp listen range %pFX peer-group %s\n",
4436 range
, group
->name
);
4443 DEFUN (bgp_disable_connected_route_check
,
4444 bgp_disable_connected_route_check_cmd
,
4445 "bgp disable-ebgp-connected-route-check",
4447 "Disable checking if nexthop is connected on ebgp sessions\n")
4449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4450 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4451 bgp_clear_star_soft_in(vty
, bgp
->name
);
4456 DEFUN (no_bgp_disable_connected_route_check
,
4457 no_bgp_disable_connected_route_check_cmd
,
4458 "no bgp disable-ebgp-connected-route-check",
4461 "Disable checking if nexthop is connected on ebgp sessions\n")
4463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4464 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4465 bgp_clear_star_soft_in(vty
, bgp
->name
);
4471 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4477 int as_type
= AS_SPECIFIED
;
4480 if (as_str
[0] == 'i') {
4482 as_type
= AS_INTERNAL
;
4483 } else if (as_str
[0] == 'e') {
4485 as_type
= AS_EXTERNAL
;
4487 /* Get AS number. */
4488 as
= strtoul(as_str
, NULL
, 10);
4491 /* If peer is peer group or interface peer, call proper function. */
4492 ret
= str2sockunion(peer_str
, &su
);
4496 /* Check if existing interface peer */
4497 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4499 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4501 /* if not interface peer, check peer-group settings */
4502 if (ret
< 0 && !peer
) {
4503 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4506 "%% Create the peer-group or interface first\n");
4507 return CMD_WARNING_CONFIG_FAILED
;
4512 if (peer_address_self_check(bgp
, &su
)) {
4514 "%% Can not configure the local system as neighbor\n");
4515 return CMD_WARNING_CONFIG_FAILED
;
4517 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4520 return bgp_vty_return(vty
, ret
);
4523 DEFUN (bgp_default_shutdown
,
4524 bgp_default_shutdown_cmd
,
4525 "[no] bgp default shutdown",
4528 "Configure BGP defaults\n"
4529 "Apply administrative shutdown to newly configured peers\n")
4531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4532 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4536 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4538 "Administrative shutdown of the BGP instance\n"
4539 "Add a shutdown message (RFC 8203)\n"
4540 "Shutdown message\n")
4542 char *msgstr
= NULL
;
4544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4547 msgstr
= argv_concat(argv
, argc
, 3);
4549 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4550 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4551 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4552 return CMD_WARNING_CONFIG_FAILED
;
4555 bgp_shutdown_enable(bgp
, msgstr
);
4556 XFREE(MTYPE_TMP
, msgstr
);
4561 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4562 BGP_STR
"Administrative shutdown of the BGP instance\n")
4564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4566 bgp_shutdown_enable(bgp
, NULL
);
4571 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4572 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4576 bgp_shutdown_disable(bgp
);
4581 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4582 "no bgp shutdown message MSG...", NO_STR BGP_STR
4583 "Administrative shutdown of the BGP instance\n"
4584 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4586 DEFUN (neighbor_remote_as
,
4587 neighbor_remote_as_cmd
,
4588 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4591 "Specify a BGP neighbor\n"
4593 "Internal BGP peer\n"
4594 "External BGP peer\n")
4597 int idx_remote_as
= 3;
4598 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4599 argv
[idx_remote_as
]->arg
);
4602 DEFPY (bgp_allow_martian
,
4603 bgp_allow_martian_cmd
,
4604 "[no]$no bgp allow-martian-nexthop",
4607 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4612 bgp
->allow_martian
= false;
4614 bgp
->allow_martian
= true;
4619 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4620 * sessions do not wait for hold timer expiry to bring down the sessions
4621 * when nexthop becomes unreachable
4623 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4624 BGP_STR
"Fast convergence for bgp sessions\n")
4626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4627 bgp
->fast_convergence
= true;
4632 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4633 "no bgp fast-convergence",
4634 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4637 bgp
->fast_convergence
= false;
4642 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4644 const char *peer_group_name
,
4647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4649 int as_type
= AS_UNSPECIFIED
;
4651 struct peer_group
*group
;
4654 group
= peer_group_lookup(bgp
, conf_if
);
4657 vty_out(vty
, "%% Name conflict with peer-group \n");
4658 return CMD_WARNING_CONFIG_FAILED
;
4662 if (as_str
[0] == 'i') {
4663 as_type
= AS_INTERNAL
;
4664 } else if (as_str
[0] == 'e') {
4665 as_type
= AS_EXTERNAL
;
4667 /* Get AS number. */
4668 as
= strtoul(as_str
, NULL
, 10);
4669 as_type
= AS_SPECIFIED
;
4673 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4676 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4678 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4682 vty_out(vty
, "%% BGP failed to create peer\n");
4683 return CMD_WARNING_CONFIG_FAILED
;
4687 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4689 /* Request zebra to initiate IPv6 RAs on this interface. We do
4691 * any unnumbered peer in order to not worry about run-time
4693 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4695 * gets deleted later etc.)
4698 bgp_zebra_initiate_radv(bgp
, peer
);
4701 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4702 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4704 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4706 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4708 /* v6only flag changed. Reset bgp seesion */
4709 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4710 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4711 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4712 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4714 bgp_session_reset(peer
);
4717 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4718 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4719 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4720 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4723 if (peer_group_name
) {
4724 group
= peer_group_lookup(bgp
, peer_group_name
);
4726 vty_out(vty
, "%% Configure the peer-group first\n");
4727 return CMD_WARNING_CONFIG_FAILED
;
4730 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4733 return bgp_vty_return(vty
, ret
);
4736 DEFUN (neighbor_interface_config
,
4737 neighbor_interface_config_cmd
,
4738 "neighbor WORD interface [peer-group PGNAME]",
4740 "Interface name or neighbor tag\n"
4741 "Enable BGP on interface\n"
4742 "Member of the peer-group\n"
4743 "Peer-group name\n")
4746 int idx_peer_group_word
= 4;
4748 if (argc
> idx_peer_group_word
)
4749 return peer_conf_interface_get(
4750 vty
, argv
[idx_word
]->arg
, 0,
4751 argv
[idx_peer_group_word
]->arg
, NULL
);
4753 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4757 DEFUN (neighbor_interface_config_v6only
,
4758 neighbor_interface_config_v6only_cmd
,
4759 "neighbor WORD interface v6only [peer-group PGNAME]",
4761 "Interface name or neighbor tag\n"
4762 "Enable BGP on interface\n"
4763 "Enable BGP with v6 link-local only\n"
4764 "Member of the peer-group\n"
4765 "Peer-group name\n")
4768 int idx_peer_group_word
= 5;
4770 if (argc
> idx_peer_group_word
)
4771 return peer_conf_interface_get(
4772 vty
, argv
[idx_word
]->arg
, 1,
4773 argv
[idx_peer_group_word
]->arg
, NULL
);
4775 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4779 DEFUN (neighbor_interface_config_remote_as
,
4780 neighbor_interface_config_remote_as_cmd
,
4781 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4783 "Interface name or neighbor tag\n"
4784 "Enable BGP on interface\n"
4785 "Specify a BGP neighbor\n"
4787 "Internal BGP peer\n"
4788 "External BGP peer\n")
4791 int idx_remote_as
= 4;
4792 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4793 argv
[idx_remote_as
]->arg
);
4796 DEFUN (neighbor_interface_v6only_config_remote_as
,
4797 neighbor_interface_v6only_config_remote_as_cmd
,
4798 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4800 "Interface name or neighbor tag\n"
4801 "Enable BGP with v6 link-local only\n"
4802 "Enable BGP on interface\n"
4803 "Specify a BGP neighbor\n"
4805 "Internal BGP peer\n"
4806 "External BGP peer\n")
4809 int idx_remote_as
= 5;
4810 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4811 argv
[idx_remote_as
]->arg
);
4814 DEFUN (neighbor_peer_group
,
4815 neighbor_peer_group_cmd
,
4816 "neighbor WORD peer-group",
4818 "Interface name or neighbor tag\n"
4819 "Configure peer-group\n")
4821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4824 struct peer_group
*group
;
4826 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4828 vty_out(vty
, "%% Name conflict with interface: \n");
4829 return CMD_WARNING_CONFIG_FAILED
;
4832 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4834 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4835 return CMD_WARNING_CONFIG_FAILED
;
4843 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4847 "Specify a BGP neighbor\n"
4849 "Internal BGP peer\n"
4850 "External BGP peer\n")
4852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4856 struct peer_group
*group
;
4860 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4862 /* look up for neighbor by interface name config. */
4863 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4865 /* Request zebra to terminate IPv6 RAs on this
4868 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4869 peer_notify_unconfig(peer
);
4874 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->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
;
4883 peer
= peer_lookup(bgp
, &su
);
4885 if (peer_dynamic_neighbor(peer
)) {
4887 "%% Operation not allowed on a dynamic neighbor\n");
4888 return CMD_WARNING_CONFIG_FAILED
;
4891 other
= peer
->doppelganger
;
4893 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4894 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4896 peer_notify_unconfig(peer
);
4898 if (other
&& other
->status
!= Deleted
) {
4899 peer_notify_unconfig(other
);
4908 DEFUN (no_neighbor_interface_config
,
4909 no_neighbor_interface_config_cmd
,
4910 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4914 "Configure BGP on interface\n"
4915 "Enable BGP with v6 link-local only\n"
4916 "Member of the peer-group\n"
4918 "Specify a BGP neighbor\n"
4920 "Internal BGP peer\n"
4921 "External BGP peer\n")
4923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4927 /* look up for neighbor by interface name config. */
4928 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4930 /* Request zebra to terminate IPv6 RAs on this interface. */
4932 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4933 peer_notify_unconfig(peer
);
4936 vty_out(vty
, "%% Create the bgp interface first\n");
4937 return CMD_WARNING_CONFIG_FAILED
;
4942 DEFUN (no_neighbor_peer_group
,
4943 no_neighbor_peer_group_cmd
,
4944 "no neighbor WORD peer-group",
4948 "Configure peer-group\n")
4950 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4952 struct peer_group
*group
;
4954 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4956 peer_group_notify_unconfig(group
);
4957 peer_group_delete(group
);
4959 vty_out(vty
, "%% Create the peer-group first\n");
4960 return CMD_WARNING_CONFIG_FAILED
;
4965 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4966 no_neighbor_interface_peer_group_remote_as_cmd
,
4967 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4970 "Interface name or neighbor tag\n"
4971 "Specify a BGP neighbor\n"
4973 "Internal BGP peer\n"
4974 "External BGP peer\n")
4976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4978 struct peer_group
*group
;
4981 /* look up for neighbor by interface name config. */
4982 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4984 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4988 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4990 peer_group_remote_as_delete(group
);
4992 vty_out(vty
, "%% Create the peer-group or interface first\n");
4993 return CMD_WARNING_CONFIG_FAILED
;
4998 DEFUN (neighbor_local_as
,
4999 neighbor_local_as_cmd
,
5000 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
5003 "Specify a local-as number\n"
5004 "AS number used as local AS\n")
5012 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5014 return CMD_WARNING_CONFIG_FAILED
;
5016 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5017 ret
= peer_local_as_set(peer
, as
, 0, 0);
5018 return bgp_vty_return(vty
, ret
);
5021 DEFUN (neighbor_local_as_no_prepend
,
5022 neighbor_local_as_no_prepend_cmd
,
5023 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
5026 "Specify a local-as number\n"
5027 "AS number used as local AS\n"
5028 "Do not prepend local-as to updates from ebgp peers\n")
5036 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5038 return CMD_WARNING_CONFIG_FAILED
;
5040 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5041 ret
= peer_local_as_set(peer
, as
, 1, 0);
5042 return bgp_vty_return(vty
, ret
);
5045 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5046 neighbor_local_as_no_prepend_replace_as_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
5050 "Specify a local-as number\n"
5051 "AS number used as local AS\n"
5052 "Do not prepend local-as to updates from ebgp peers\n"
5053 "Do not prepend local-as to updates from ibgp peers\n")
5061 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5063 return CMD_WARNING_CONFIG_FAILED
;
5065 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5066 ret
= peer_local_as_set(peer
, as
, 1, 1);
5067 return bgp_vty_return(vty
, ret
);
5070 DEFUN (no_neighbor_local_as
,
5071 no_neighbor_local_as_cmd
,
5072 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
5076 "Specify a local-as number\n"
5077 "AS number used as local AS\n"
5078 "Do not prepend local-as to updates from ebgp peers\n"
5079 "Do not prepend local-as to updates from ibgp peers\n")
5085 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5087 return CMD_WARNING_CONFIG_FAILED
;
5089 ret
= peer_local_as_unset(peer
);
5090 return bgp_vty_return(vty
, ret
);
5094 DEFUN (neighbor_solo
,
5096 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5099 "Solo peer - part of its own update group\n")
5105 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5107 return CMD_WARNING_CONFIG_FAILED
;
5109 ret
= update_group_adjust_soloness(peer
, 1);
5110 return bgp_vty_return(vty
, ret
);
5113 DEFUN (no_neighbor_solo
,
5114 no_neighbor_solo_cmd
,
5115 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5119 "Solo peer - part of its own update group\n")
5125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5127 return CMD_WARNING_CONFIG_FAILED
;
5129 ret
= update_group_adjust_soloness(peer
, 0);
5130 return bgp_vty_return(vty
, ret
);
5133 DEFUN (neighbor_password
,
5134 neighbor_password_cmd
,
5135 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5146 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5148 return CMD_WARNING_CONFIG_FAILED
;
5150 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5151 return bgp_vty_return(vty
, ret
);
5154 DEFUN (no_neighbor_password
,
5155 no_neighbor_password_cmd
,
5156 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5167 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5169 return CMD_WARNING_CONFIG_FAILED
;
5171 ret
= peer_password_unset(peer
);
5172 return bgp_vty_return(vty
, ret
);
5175 DEFUN (neighbor_activate
,
5176 neighbor_activate_cmd
,
5177 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5180 "Enable the Address Family for this Neighbor\n")
5186 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5188 return CMD_WARNING_CONFIG_FAILED
;
5190 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5191 return bgp_vty_return(vty
, ret
);
5194 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5195 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5196 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5197 "Enable the Address Family for this Neighbor\n")
5199 DEFUN (no_neighbor_activate
,
5200 no_neighbor_activate_cmd
,
5201 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5205 "Enable the Address Family for this Neighbor\n")
5212 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5214 return CMD_WARNING_CONFIG_FAILED
;
5216 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5217 return bgp_vty_return(vty
, ret
);
5220 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5221 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5222 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5223 "Enable the Address Family for this Neighbor\n")
5225 DEFUN (neighbor_set_peer_group
,
5226 neighbor_set_peer_group_cmd
,
5227 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5230 "Member of the peer-group\n"
5231 "Peer-group name\n")
5233 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5240 struct peer_group
*group
;
5242 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5244 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5246 vty_out(vty
, "%% Malformed address or name: %s\n",
5247 argv
[idx_peer
]->arg
);
5248 return CMD_WARNING_CONFIG_FAILED
;
5251 if (peer_address_self_check(bgp
, &su
)) {
5253 "%% Can not configure the local system as neighbor\n");
5254 return CMD_WARNING_CONFIG_FAILED
;
5257 /* Disallow for dynamic neighbor. */
5258 peer
= peer_lookup(bgp
, &su
);
5259 if (peer
&& peer_dynamic_neighbor(peer
)) {
5261 "%% Operation not allowed on a dynamic neighbor\n");
5262 return CMD_WARNING_CONFIG_FAILED
;
5266 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5268 vty_out(vty
, "%% Configure the peer-group first\n");
5269 return CMD_WARNING_CONFIG_FAILED
;
5272 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5274 return bgp_vty_return(vty
, ret
);
5277 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5278 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5279 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5280 "Member of the peer-group\n"
5281 "Peer-group name\n")
5283 DEFUN (no_neighbor_set_peer_group
,
5284 no_neighbor_set_peer_group_cmd
,
5285 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5289 "Member of the peer-group\n"
5290 "Peer-group name\n")
5292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5297 struct peer_group
*group
;
5299 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5301 return CMD_WARNING_CONFIG_FAILED
;
5303 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5305 vty_out(vty
, "%% Configure the peer-group first\n");
5306 return CMD_WARNING_CONFIG_FAILED
;
5309 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5310 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5312 peer_notify_unconfig(peer
);
5313 ret
= peer_delete(peer
);
5315 return bgp_vty_return(vty
, ret
);
5318 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5319 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5320 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5321 "Member of the peer-group\n"
5322 "Peer-group name\n")
5324 /* neighbor passive. */
5325 DEFUN (neighbor_passive
,
5326 neighbor_passive_cmd
,
5327 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5330 "Don't send open messages to this neighbor\n")
5333 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5336 DEFUN (no_neighbor_passive
,
5337 no_neighbor_passive_cmd
,
5338 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5342 "Don't send open messages to this neighbor\n")
5345 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5348 /* neighbor shutdown. */
5349 DEFUN (neighbor_shutdown_msg
,
5350 neighbor_shutdown_msg_cmd
,
5351 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5354 "Administratively shut down this neighbor\n"
5355 "Add a shutdown message (RFC 8203)\n"
5356 "Shutdown message\n")
5362 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5366 return CMD_WARNING_CONFIG_FAILED
;
5367 message
= argv_concat(argv
, argc
, 4);
5368 peer_tx_shutdown_message_set(peer
, message
);
5369 XFREE(MTYPE_TMP
, message
);
5372 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5375 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5376 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5377 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5378 "Administratively shut down this neighbor\n")
5380 DEFUN (no_neighbor_shutdown_msg
,
5381 no_neighbor_shutdown_msg_cmd
,
5382 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5386 "Administratively shut down this neighbor\n"
5387 "Remove a shutdown message (RFC 8203)\n"
5388 "Shutdown message\n")
5392 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5393 PEER_FLAG_SHUTDOWN
);
5396 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5397 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5398 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5399 "Administratively shut down this neighbor\n")
5401 DEFUN(neighbor_shutdown_rtt
,
5402 neighbor_shutdown_rtt_cmd
,
5403 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5406 "Administratively shut down this neighbor\n"
5407 "Shutdown if round-trip-time is higher than expected\n"
5408 "Round-trip-time in milliseconds\n"
5409 "Specify the number of keepalives before shutdown\n"
5410 "The number of keepalives with higher RTT to shutdown\n")
5417 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5420 return CMD_WARNING_CONFIG_FAILED
;
5422 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5424 if (argv_find(argv
, argc
, "count", &idx_count
))
5425 peer
->rtt_keepalive_conf
=
5426 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5428 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5429 PEER_FLAG_RTT_SHUTDOWN
);
5432 DEFUN(no_neighbor_shutdown_rtt
,
5433 no_neighbor_shutdown_rtt_cmd
,
5434 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5438 "Administratively shut down this neighbor\n"
5439 "Shutdown if round-trip-time is higher than expected\n"
5440 "Round-trip-time in milliseconds\n"
5441 "Specify the number of keepalives before shutdown\n"
5442 "The number of keepalives with higher RTT to shutdown\n")
5447 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5450 return CMD_WARNING_CONFIG_FAILED
;
5452 peer
->rtt_expected
= 0;
5453 peer
->rtt_keepalive_conf
= 1;
5455 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5456 PEER_FLAG_RTT_SHUTDOWN
);
5459 /* neighbor capability dynamic. */
5460 DEFUN (neighbor_capability_dynamic
,
5461 neighbor_capability_dynamic_cmd
,
5462 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5465 "Advertise capability to the peer\n"
5466 "Advertise dynamic capability to this neighbor\n")
5469 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5470 PEER_FLAG_DYNAMIC_CAPABILITY
);
5473 DEFUN (no_neighbor_capability_dynamic
,
5474 no_neighbor_capability_dynamic_cmd
,
5475 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5479 "Advertise capability to the peer\n"
5480 "Advertise dynamic capability to this neighbor\n")
5483 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5484 PEER_FLAG_DYNAMIC_CAPABILITY
);
5487 /* neighbor dont-capability-negotiate */
5488 DEFUN (neighbor_dont_capability_negotiate
,
5489 neighbor_dont_capability_negotiate_cmd
,
5490 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5493 "Do not perform capability negotiation\n")
5496 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5497 PEER_FLAG_DONT_CAPABILITY
);
5500 DEFUN (no_neighbor_dont_capability_negotiate
,
5501 no_neighbor_dont_capability_negotiate_cmd
,
5502 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5506 "Do not perform capability negotiation\n")
5509 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5510 PEER_FLAG_DONT_CAPABILITY
);
5513 /* neighbor capability extended next hop encoding */
5514 DEFUN (neighbor_capability_enhe
,
5515 neighbor_capability_enhe_cmd
,
5516 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5519 "Advertise capability to the peer\n"
5520 "Advertise extended next-hop capability to the peer\n")
5525 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5526 if (peer
&& peer
->conf_if
)
5529 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5530 PEER_FLAG_CAPABILITY_ENHE
);
5533 DEFUN (no_neighbor_capability_enhe
,
5534 no_neighbor_capability_enhe_cmd
,
5535 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5539 "Advertise capability to the peer\n"
5540 "Advertise extended next-hop capability to the peer\n")
5545 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5546 if (peer
&& peer
->conf_if
) {
5548 "Peer %s cannot have capability extended-nexthop turned off\n",
5549 argv
[idx_peer
]->arg
);
5550 return CMD_WARNING_CONFIG_FAILED
;
5553 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5554 PEER_FLAG_CAPABILITY_ENHE
);
5557 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5558 afi_t afi
, safi_t safi
, uint32_t flag
,
5564 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5566 return CMD_WARNING_CONFIG_FAILED
;
5569 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5571 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5573 return bgp_vty_return(vty
, ret
);
5576 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5577 afi_t afi
, safi_t safi
, uint32_t flag
)
5579 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5582 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5583 afi_t afi
, safi_t safi
, uint32_t flag
)
5585 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5588 /* neighbor capability orf prefix-list. */
5589 DEFUN (neighbor_capability_orf_prefix
,
5590 neighbor_capability_orf_prefix_cmd
,
5591 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5594 "Advertise capability to the peer\n"
5595 "Advertise ORF capability to the peer\n"
5596 "Advertise prefixlist ORF capability to this neighbor\n"
5597 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5598 "Capability to RECEIVE the ORF from this neighbor\n"
5599 "Capability to SEND the ORF to this neighbor\n")
5601 int idx_send_recv
= 5;
5602 char *peer_str
= argv
[1]->arg
;
5604 afi_t afi
= bgp_node_afi(vty
);
5605 safi_t safi
= bgp_node_safi(vty
);
5607 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5609 return CMD_WARNING_CONFIG_FAILED
;
5611 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5612 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5613 PEER_FLAG_ORF_PREFIX_SM
);
5615 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5616 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5617 PEER_FLAG_ORF_PREFIX_RM
);
5619 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5620 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5621 PEER_FLAG_ORF_PREFIX_SM
)
5622 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5623 PEER_FLAG_ORF_PREFIX_RM
);
5625 return CMD_WARNING_CONFIG_FAILED
;
5629 neighbor_capability_orf_prefix
,
5630 neighbor_capability_orf_prefix_hidden_cmd
,
5631 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5632 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5633 "Advertise capability to the peer\n"
5634 "Advertise ORF capability to the peer\n"
5635 "Advertise prefixlist ORF capability to this neighbor\n"
5636 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5637 "Capability to RECEIVE the ORF from this neighbor\n"
5638 "Capability to SEND the ORF to this neighbor\n")
5640 DEFUN (no_neighbor_capability_orf_prefix
,
5641 no_neighbor_capability_orf_prefix_cmd
,
5642 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5646 "Advertise capability to the peer\n"
5647 "Advertise ORF capability to the peer\n"
5648 "Advertise prefixlist ORF capability to this neighbor\n"
5649 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5650 "Capability to RECEIVE the ORF from this neighbor\n"
5651 "Capability to SEND the ORF to this neighbor\n")
5653 int idx_send_recv
= 6;
5654 char *peer_str
= argv
[2]->arg
;
5656 afi_t afi
= bgp_node_afi(vty
);
5657 safi_t safi
= bgp_node_safi(vty
);
5659 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5661 return CMD_WARNING_CONFIG_FAILED
;
5663 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5664 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5665 PEER_FLAG_ORF_PREFIX_SM
);
5667 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5668 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5669 PEER_FLAG_ORF_PREFIX_RM
);
5671 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5672 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5673 PEER_FLAG_ORF_PREFIX_SM
)
5674 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5675 PEER_FLAG_ORF_PREFIX_RM
);
5677 return CMD_WARNING_CONFIG_FAILED
;
5681 no_neighbor_capability_orf_prefix
,
5682 no_neighbor_capability_orf_prefix_hidden_cmd
,
5683 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5684 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5685 "Advertise capability to the peer\n"
5686 "Advertise ORF capability to the peer\n"
5687 "Advertise prefixlist ORF capability to this neighbor\n"
5688 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5689 "Capability to RECEIVE the ORF from this neighbor\n"
5690 "Capability to SEND the ORF to this neighbor\n")
5692 /* neighbor next-hop-self. */
5693 DEFUN (neighbor_nexthop_self
,
5694 neighbor_nexthop_self_cmd
,
5695 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5698 "Disable the next hop calculation for this neighbor\n")
5701 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5702 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5705 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5706 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5707 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5708 "Disable the next hop calculation for this neighbor\n")
5710 /* neighbor next-hop-self. */
5711 DEFUN (neighbor_nexthop_self_force
,
5712 neighbor_nexthop_self_force_cmd
,
5713 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5716 "Disable the next hop calculation for this neighbor\n"
5717 "Set the next hop to self for reflected routes\n")
5720 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5722 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5725 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5726 neighbor_nexthop_self_force_hidden_cmd
,
5727 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5728 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5729 "Disable the next hop calculation for this neighbor\n"
5730 "Set the next hop to self for reflected routes\n")
5732 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5733 neighbor_nexthop_self_all_hidden_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5735 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Disable the next hop calculation for this neighbor\n"
5737 "Set the next hop to self for reflected routes\n")
5739 DEFUN (no_neighbor_nexthop_self
,
5740 no_neighbor_nexthop_self_cmd
,
5741 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5745 "Disable the next hop calculation for this neighbor\n")
5748 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5749 bgp_node_afi(vty
), bgp_node_safi(vty
),
5750 PEER_FLAG_NEXTHOP_SELF
);
5753 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5754 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5755 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5756 "Disable the next hop calculation for this neighbor\n")
5758 DEFUN (no_neighbor_nexthop_self_force
,
5759 no_neighbor_nexthop_self_force_cmd
,
5760 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5764 "Disable the next hop calculation for this neighbor\n"
5765 "Set the next hop to self for reflected routes\n")
5768 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5769 bgp_node_afi(vty
), bgp_node_safi(vty
),
5770 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5773 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5774 no_neighbor_nexthop_self_force_hidden_cmd
,
5775 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5776 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5777 "Disable the next hop calculation for this neighbor\n"
5778 "Set the next hop to self for reflected routes\n")
5780 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5781 no_neighbor_nexthop_self_all_hidden_cmd
,
5782 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5783 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5784 "Disable the next hop calculation for this neighbor\n"
5785 "Set the next hop to self for reflected routes\n")
5787 /* neighbor as-override */
5788 DEFUN (neighbor_as_override
,
5789 neighbor_as_override_cmd
,
5790 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5793 "Override ASNs in outbound updates if aspath equals remote-as\n")
5796 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5797 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5800 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5801 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5803 "Override ASNs in outbound updates if aspath equals remote-as\n")
5805 DEFUN (no_neighbor_as_override
,
5806 no_neighbor_as_override_cmd
,
5807 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5811 "Override ASNs in outbound updates if aspath equals remote-as\n")
5814 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5815 bgp_node_afi(vty
), bgp_node_safi(vty
),
5816 PEER_FLAG_AS_OVERRIDE
);
5819 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5820 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5821 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5822 "Override ASNs in outbound updates if aspath equals remote-as\n")
5824 /* neighbor remove-private-AS. */
5825 DEFUN (neighbor_remove_private_as
,
5826 neighbor_remove_private_as_cmd
,
5827 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5830 "Remove private ASNs in outbound updates\n")
5833 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5835 PEER_FLAG_REMOVE_PRIVATE_AS
);
5838 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5840 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5841 "Remove private ASNs in outbound updates\n")
5843 DEFUN (neighbor_remove_private_as_all
,
5844 neighbor_remove_private_as_all_cmd
,
5845 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5848 "Remove private ASNs in outbound updates\n"
5849 "Apply to all AS numbers\n")
5852 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5854 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5857 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5858 neighbor_remove_private_as_all_hidden_cmd
,
5859 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5860 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5861 "Remove private ASNs in outbound updates\n"
5862 "Apply to all AS numbers\n")
5864 DEFUN (neighbor_remove_private_as_replace_as
,
5865 neighbor_remove_private_as_replace_as_cmd
,
5866 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5869 "Remove private ASNs in outbound updates\n"
5870 "Replace private ASNs with our ASN in outbound updates\n")
5873 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5875 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5878 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5879 neighbor_remove_private_as_replace_as_hidden_cmd
,
5880 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5882 "Remove private ASNs in outbound updates\n"
5883 "Replace private ASNs with our ASN in outbound updates\n")
5885 DEFUN (neighbor_remove_private_as_all_replace_as
,
5886 neighbor_remove_private_as_all_replace_as_cmd
,
5887 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5890 "Remove private ASNs in outbound updates\n"
5891 "Apply to all AS numbers\n"
5892 "Replace private ASNs with our ASN in outbound updates\n")
5895 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5897 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5901 neighbor_remove_private_as_all_replace_as
,
5902 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5903 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5904 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5905 "Remove private ASNs in outbound updates\n"
5906 "Apply to all AS numbers\n"
5907 "Replace private ASNs with our ASN in outbound updates\n")
5909 DEFUN (no_neighbor_remove_private_as
,
5910 no_neighbor_remove_private_as_cmd
,
5911 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5915 "Remove private ASNs in outbound updates\n")
5918 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5919 bgp_node_afi(vty
), bgp_node_safi(vty
),
5920 PEER_FLAG_REMOVE_PRIVATE_AS
);
5923 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5924 no_neighbor_remove_private_as_hidden_cmd
,
5925 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5926 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5927 "Remove private ASNs in outbound updates\n")
5929 DEFUN (no_neighbor_remove_private_as_all
,
5930 no_neighbor_remove_private_as_all_cmd
,
5931 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5935 "Remove private ASNs in outbound updates\n"
5936 "Apply to all AS numbers\n")
5939 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5940 bgp_node_afi(vty
), bgp_node_safi(vty
),
5941 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5944 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5945 no_neighbor_remove_private_as_all_hidden_cmd
,
5946 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Remove private ASNs in outbound updates\n"
5949 "Apply to all AS numbers\n")
5951 DEFUN (no_neighbor_remove_private_as_replace_as
,
5952 no_neighbor_remove_private_as_replace_as_cmd
,
5953 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5957 "Remove private ASNs in outbound updates\n"
5958 "Replace private ASNs with our ASN in outbound updates\n")
5961 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5962 bgp_node_afi(vty
), bgp_node_safi(vty
),
5963 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5966 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5967 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5968 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5969 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5970 "Remove private ASNs in outbound updates\n"
5971 "Replace private ASNs with our ASN in outbound updates\n")
5973 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5974 no_neighbor_remove_private_as_all_replace_as_cmd
,
5975 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5979 "Remove private ASNs in outbound updates\n"
5980 "Apply to all AS numbers\n"
5981 "Replace private ASNs with our ASN in outbound updates\n")
5984 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5985 bgp_node_afi(vty
), bgp_node_safi(vty
),
5986 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5990 no_neighbor_remove_private_as_all_replace_as
,
5991 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5992 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5993 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5994 "Remove private ASNs in outbound updates\n"
5995 "Apply to all AS numbers\n"
5996 "Replace private ASNs with our ASN in outbound updates\n")
5999 /* neighbor send-community. */
6000 DEFUN (neighbor_send_community
,
6001 neighbor_send_community_cmd
,
6002 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6005 "Send Community attribute to this neighbor\n")
6009 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6011 PEER_FLAG_SEND_COMMUNITY
);
6014 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6015 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6017 "Send Community attribute to this neighbor\n")
6019 DEFUN (no_neighbor_send_community
,
6020 no_neighbor_send_community_cmd
,
6021 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6025 "Send Community attribute to this neighbor\n")
6029 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6030 bgp_node_afi(vty
), bgp_node_safi(vty
),
6031 PEER_FLAG_SEND_COMMUNITY
);
6034 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6035 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6036 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6037 "Send Community attribute to this neighbor\n")
6039 /* neighbor send-community extended. */
6040 DEFUN (neighbor_send_community_type
,
6041 neighbor_send_community_type_cmd
,
6042 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6045 "Send Community attribute to this neighbor\n"
6046 "Send Standard and Extended Community attributes\n"
6047 "Send Standard, Large and Extended Community attributes\n"
6048 "Send Extended Community attributes\n"
6049 "Send Standard Community attributes\n"
6050 "Send Large Community attributes\n")
6052 const char *type
= argv
[argc
- 1]->text
;
6053 char *peer_str
= argv
[1]->arg
;
6055 afi_t afi
= bgp_node_afi(vty
);
6056 safi_t safi
= bgp_node_safi(vty
);
6058 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6060 return CMD_WARNING_CONFIG_FAILED
;
6062 if (strmatch(type
, "standard"))
6063 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6064 PEER_FLAG_SEND_COMMUNITY
);
6066 if (strmatch(type
, "extended"))
6067 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6068 PEER_FLAG_SEND_EXT_COMMUNITY
);
6070 if (strmatch(type
, "large"))
6071 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6072 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6074 if (strmatch(type
, "both")) {
6075 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6076 PEER_FLAG_SEND_COMMUNITY
)
6077 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6078 PEER_FLAG_SEND_EXT_COMMUNITY
);
6080 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6081 PEER_FLAG_SEND_COMMUNITY
)
6082 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6083 PEER_FLAG_SEND_EXT_COMMUNITY
)
6084 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6085 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6089 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6090 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6091 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6092 "Send Community attribute to this neighbor\n"
6093 "Send Standard and Extended Community attributes\n"
6094 "Send Standard, Large and Extended Community attributes\n"
6095 "Send Extended Community attributes\n"
6096 "Send Standard Community attributes\n"
6097 "Send Large Community attributes\n")
6099 DEFUN (no_neighbor_send_community_type
,
6100 no_neighbor_send_community_type_cmd
,
6101 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6105 "Send Community attribute to this neighbor\n"
6106 "Send Standard and Extended Community attributes\n"
6107 "Send Standard, Large and Extended Community attributes\n"
6108 "Send Extended Community attributes\n"
6109 "Send Standard Community attributes\n"
6110 "Send Large Community attributes\n")
6112 const char *type
= argv
[argc
- 1]->text
;
6113 char *peer_str
= argv
[2]->arg
;
6115 afi_t afi
= bgp_node_afi(vty
);
6116 safi_t safi
= bgp_node_safi(vty
);
6118 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6120 return CMD_WARNING_CONFIG_FAILED
;
6122 if (strmatch(type
, "standard"))
6123 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6124 PEER_FLAG_SEND_COMMUNITY
);
6126 if (strmatch(type
, "extended"))
6127 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6128 PEER_FLAG_SEND_EXT_COMMUNITY
);
6130 if (strmatch(type
, "large"))
6131 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6132 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6134 if (strmatch(type
, "both")) {
6136 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6137 PEER_FLAG_SEND_COMMUNITY
)
6138 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6139 PEER_FLAG_SEND_EXT_COMMUNITY
);
6142 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6143 PEER_FLAG_SEND_COMMUNITY
)
6144 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6145 PEER_FLAG_SEND_EXT_COMMUNITY
)
6146 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6147 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6151 no_neighbor_send_community_type
,
6152 no_neighbor_send_community_type_hidden_cmd
,
6153 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6154 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6155 "Send Community attribute to this neighbor\n"
6156 "Send Standard and Extended Community attributes\n"
6157 "Send Standard, Large and Extended Community attributes\n"
6158 "Send Extended Community attributes\n"
6159 "Send Standard Community attributes\n"
6160 "Send Large Community attributes\n")
6162 /* neighbor soft-reconfig. */
6163 DEFUN (neighbor_soft_reconfiguration
,
6164 neighbor_soft_reconfiguration_cmd
,
6165 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6168 "Per neighbor soft reconfiguration\n"
6169 "Allow inbound soft reconfiguration for this neighbor\n")
6172 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6174 PEER_FLAG_SOFT_RECONFIG
);
6177 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6178 neighbor_soft_reconfiguration_hidden_cmd
,
6179 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6180 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6181 "Per neighbor soft reconfiguration\n"
6182 "Allow inbound soft reconfiguration for this neighbor\n")
6184 DEFUN (no_neighbor_soft_reconfiguration
,
6185 no_neighbor_soft_reconfiguration_cmd
,
6186 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6190 "Per neighbor soft reconfiguration\n"
6191 "Allow inbound soft reconfiguration for this neighbor\n")
6194 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6195 bgp_node_afi(vty
), bgp_node_safi(vty
),
6196 PEER_FLAG_SOFT_RECONFIG
);
6199 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6200 no_neighbor_soft_reconfiguration_hidden_cmd
,
6201 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6203 "Per neighbor soft reconfiguration\n"
6204 "Allow inbound soft reconfiguration for this neighbor\n")
6206 DEFUN (neighbor_route_reflector_client
,
6207 neighbor_route_reflector_client_cmd
,
6208 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6211 "Configure a neighbor as Route Reflector client\n")
6217 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6219 return CMD_WARNING_CONFIG_FAILED
;
6221 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6223 PEER_FLAG_REFLECTOR_CLIENT
);
6226 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6227 neighbor_route_reflector_client_hidden_cmd
,
6228 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6229 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6230 "Configure a neighbor as Route Reflector client\n")
6232 DEFUN (no_neighbor_route_reflector_client
,
6233 no_neighbor_route_reflector_client_cmd
,
6234 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6238 "Configure a neighbor as Route Reflector client\n")
6241 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6242 bgp_node_afi(vty
), bgp_node_safi(vty
),
6243 PEER_FLAG_REFLECTOR_CLIENT
);
6246 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6247 no_neighbor_route_reflector_client_hidden_cmd
,
6248 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6249 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6250 "Configure a neighbor as Route Reflector client\n")
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 DEFPY (neighbor_aigp
,
6560 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6564 "Enable send and receive of the AIGP attribute per neighbor\n")
6568 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6570 return CMD_WARNING_CONFIG_FAILED
;
6573 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6575 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6578 static uint8_t get_role_by_name(const char *role_str
)
6580 if (strncmp(role_str
, "peer", 2) == 0)
6582 if (strncmp(role_str
, "provider", 2) == 0)
6583 return ROLE_PROVIDER
;
6584 if (strncmp(role_str
, "customer", 2) == 0)
6585 return ROLE_CUSTOMER
;
6586 if (strncmp(role_str
, "rs-server", 4) == 0)
6587 return ROLE_RS_SERVER
;
6588 if (strncmp(role_str
, "rs-client", 4) == 0)
6589 return ROLE_RS_CLIENT
;
6590 return ROLE_UNDEFINED
;
6593 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6594 const char *role_str
, bool strict_mode
)
6598 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6600 return CMD_WARNING_CONFIG_FAILED
;
6601 uint8_t role
= get_role_by_name(role_str
);
6603 if (role
== ROLE_UNDEFINED
)
6604 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6605 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6608 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6612 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6614 return CMD_WARNING_CONFIG_FAILED
;
6615 return bgp_vty_return(vty
, peer_role_unset(peer
));
6618 DEFPY(neighbor_role
,
6620 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6623 "Set session role\n"
6629 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6633 DEFPY(neighbor_role_strict
,
6634 neighbor_role_strict_cmd
,
6635 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6638 "Set session role\n"
6640 "Use additional restriction on peer\n")
6645 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6649 DEFPY(no_neighbor_role
,
6650 no_neighbor_role_cmd
,
6651 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6655 "Set session role\n"
6657 "Use additional restriction on peer\n")
6661 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6664 /* disable-connected-check */
6665 DEFUN (neighbor_disable_connected_check
,
6666 neighbor_disable_connected_check_cmd
,
6667 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6670 "one-hop away EBGP peer using loopback address\n"
6671 "Enforce EBGP neighbors perform multihop\n")
6674 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6675 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6678 DEFUN (no_neighbor_disable_connected_check
,
6679 no_neighbor_disable_connected_check_cmd
,
6680 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6684 "one-hop away EBGP peer using loopback address\n"
6685 "Enforce EBGP neighbors perform multihop\n")
6688 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6689 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6692 /* disable-link-bw-encoding-ieee */
6693 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6694 neighbor_disable_link_bw_encoding_ieee_cmd
,
6695 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6696 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6697 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6701 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6702 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6705 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6706 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6707 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6708 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6709 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6713 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6714 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6717 /* extended-optional-parameters */
6718 DEFUN(neighbor_extended_optional_parameters
,
6719 neighbor_extended_optional_parameters_cmd
,
6720 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6721 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6722 "Force the extended optional parameters format for OPEN messages\n")
6726 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6727 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6730 DEFUN(no_neighbor_extended_optional_parameters
,
6731 no_neighbor_extended_optional_parameters_cmd
,
6732 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6733 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6734 "Force the extended optional parameters format for OPEN messages\n")
6738 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6739 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6742 /* enforce-first-as */
6743 DEFUN (neighbor_enforce_first_as
,
6744 neighbor_enforce_first_as_cmd
,
6745 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6748 "Enforce the first AS for EBGP routes\n")
6752 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6753 PEER_FLAG_ENFORCE_FIRST_AS
);
6756 DEFUN (no_neighbor_enforce_first_as
,
6757 no_neighbor_enforce_first_as_cmd
,
6758 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6762 "Enforce the first AS for EBGP routes\n")
6766 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6767 PEER_FLAG_ENFORCE_FIRST_AS
);
6771 DEFUN (neighbor_description
,
6772 neighbor_description_cmd
,
6773 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6776 "Neighbor specific description\n"
6777 "Up to 80 characters describing this neighbor\n")
6784 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6786 return CMD_WARNING_CONFIG_FAILED
;
6788 str
= argv_concat(argv
, argc
, idx_line
);
6790 peer_description_set(peer
, str
);
6792 XFREE(MTYPE_TMP
, str
);
6797 DEFUN (no_neighbor_description
,
6798 no_neighbor_description_cmd
,
6799 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6803 "Neighbor specific description\n")
6808 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6810 return CMD_WARNING_CONFIG_FAILED
;
6812 peer_description_unset(peer
);
6817 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6818 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6819 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6820 "Neighbor specific description\n"
6821 "Up to 80 characters describing this neighbor\n")
6823 /* Neighbor update-source. */
6824 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6825 const char *source_str
)
6831 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6833 return CMD_WARNING_CONFIG_FAILED
;
6839 if (str2sockunion(source_str
, &su
) == 0)
6840 peer_update_source_addr_set(peer
, &su
);
6842 if (str2prefix(source_str
, &p
)) {
6844 "%% Invalid update-source, remove prefix length \n");
6845 return CMD_WARNING_CONFIG_FAILED
;
6847 peer_update_source_if_set(peer
, source_str
);
6850 peer_update_source_unset(peer
);
6855 #define BGP_UPDATE_SOURCE_HELP_STR \
6858 "Interface name (requires zebra to be running)\n"
6860 DEFUN (neighbor_update_source
,
6861 neighbor_update_source_cmd
,
6862 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6865 "Source of routing updates\n"
6866 BGP_UPDATE_SOURCE_HELP_STR
)
6870 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6871 argv
[idx_peer_2
]->arg
);
6874 DEFUN (no_neighbor_update_source
,
6875 no_neighbor_update_source_cmd
,
6876 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6880 "Source of routing updates\n"
6881 BGP_UPDATE_SOURCE_HELP_STR
)
6884 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6887 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6888 afi_t afi
, safi_t safi
,
6889 const char *rmap
, int set
)
6893 struct route_map
*route_map
= NULL
;
6895 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6897 return CMD_WARNING_CONFIG_FAILED
;
6901 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6902 ret
= peer_default_originate_set(peer
, afi
, safi
,
6905 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6907 return bgp_vty_return(vty
, ret
);
6910 /* neighbor default-originate. */
6911 DEFUN (neighbor_default_originate
,
6912 neighbor_default_originate_cmd
,
6913 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6916 "Originate default route to this neighbor\n")
6919 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6921 bgp_node_safi(vty
), NULL
, 1);
6924 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6925 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6926 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6927 "Originate default route to this neighbor\n")
6929 DEFUN (neighbor_default_originate_rmap
,
6930 neighbor_default_originate_rmap_cmd
,
6931 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6934 "Originate default route to this neighbor\n"
6935 "Route-map to specify criteria to originate default\n"
6940 return peer_default_originate_set_vty(
6941 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6942 argv
[idx_word
]->arg
, 1);
6946 neighbor_default_originate_rmap
,
6947 neighbor_default_originate_rmap_hidden_cmd
,
6948 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6949 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6950 "Originate default route to this neighbor\n"
6951 "Route-map to specify criteria to originate default\n"
6954 DEFUN (no_neighbor_default_originate
,
6955 no_neighbor_default_originate_cmd
,
6956 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6960 "Originate default route to this neighbor\n"
6961 "Route-map to specify criteria to originate default\n"
6965 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6967 bgp_node_safi(vty
), NULL
, 0);
6971 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6972 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6974 "Originate default route to this neighbor\n"
6975 "Route-map to specify criteria to originate default\n"
6979 /* Set neighbor's BGP port. */
6980 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6981 const char *port_str
)
6987 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6989 return CMD_WARNING_CONFIG_FAILED
;
6992 sp
= getservbyname("bgp", "tcp");
6993 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6995 port
= strtoul(port_str
, NULL
, 10);
6998 peer_port_set(peer
, port
);
7003 /* Set specified peer's BGP port. */
7004 DEFUN (neighbor_port
,
7006 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7009 "Neighbor's BGP port\n"
7010 "TCP port number\n")
7014 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7015 argv
[idx_number
]->arg
);
7018 DEFUN (no_neighbor_port
,
7019 no_neighbor_port_cmd
,
7020 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7024 "Neighbor's BGP port\n"
7025 "TCP port number\n")
7028 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7032 /* neighbor weight. */
7033 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7034 safi_t safi
, const char *weight_str
)
7038 unsigned long weight
;
7040 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7042 return CMD_WARNING_CONFIG_FAILED
;
7044 weight
= strtoul(weight_str
, NULL
, 10);
7046 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7047 return bgp_vty_return(vty
, ret
);
7050 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7056 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7058 return CMD_WARNING_CONFIG_FAILED
;
7060 ret
= peer_weight_unset(peer
, afi
, safi
);
7061 return bgp_vty_return(vty
, ret
);
7064 DEFUN (neighbor_weight
,
7065 neighbor_weight_cmd
,
7066 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7069 "Set default weight for routes from this neighbor\n"
7074 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7075 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7078 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7079 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7080 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7081 "Set default weight for routes from this neighbor\n"
7084 DEFUN (no_neighbor_weight
,
7085 no_neighbor_weight_cmd
,
7086 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7090 "Set default weight for routes from this neighbor\n"
7094 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7095 bgp_node_afi(vty
), bgp_node_safi(vty
));
7098 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7099 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7100 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7101 "Set default weight for routes from this neighbor\n"
7105 /* Override capability negotiation. */
7106 DEFUN (neighbor_override_capability
,
7107 neighbor_override_capability_cmd
,
7108 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7111 "Override capability negotiation result\n")
7114 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7115 PEER_FLAG_OVERRIDE_CAPABILITY
);
7118 DEFUN (no_neighbor_override_capability
,
7119 no_neighbor_override_capability_cmd
,
7120 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7124 "Override capability negotiation result\n")
7127 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7128 PEER_FLAG_OVERRIDE_CAPABILITY
);
7131 DEFUN (neighbor_strict_capability
,
7132 neighbor_strict_capability_cmd
,
7133 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7136 "Strict capability negotiation match\n")
7140 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7141 PEER_FLAG_STRICT_CAP_MATCH
);
7144 DEFUN (no_neighbor_strict_capability
,
7145 no_neighbor_strict_capability_cmd
,
7146 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7150 "Strict capability negotiation match\n")
7154 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7155 PEER_FLAG_STRICT_CAP_MATCH
);
7158 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7159 const char *keep_str
, const char *hold_str
)
7166 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7168 return CMD_WARNING_CONFIG_FAILED
;
7170 keepalive
= strtoul(keep_str
, NULL
, 10);
7171 holdtime
= strtoul(hold_str
, NULL
, 10);
7173 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7175 return bgp_vty_return(vty
, ret
);
7178 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7183 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7185 return CMD_WARNING_CONFIG_FAILED
;
7187 ret
= peer_timers_unset(peer
);
7189 return bgp_vty_return(vty
, ret
);
7192 DEFUN (neighbor_timers
,
7193 neighbor_timers_cmd
,
7194 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7197 "BGP per neighbor timers\n"
7198 "Keepalive interval\n"
7203 int idx_number_2
= 4;
7204 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7205 argv
[idx_number
]->arg
,
7206 argv
[idx_number_2
]->arg
);
7209 DEFUN (no_neighbor_timers
,
7210 no_neighbor_timers_cmd
,
7211 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7215 "BGP per neighbor timers\n"
7216 "Keepalive interval\n"
7220 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7224 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7225 const char *time_str
)
7231 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7233 return CMD_WARNING_CONFIG_FAILED
;
7235 connect
= strtoul(time_str
, NULL
, 10);
7237 ret
= peer_timers_connect_set(peer
, connect
);
7239 return bgp_vty_return(vty
, ret
);
7242 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7247 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7249 return CMD_WARNING_CONFIG_FAILED
;
7251 ret
= peer_timers_connect_unset(peer
);
7253 return bgp_vty_return(vty
, ret
);
7256 DEFUN (neighbor_timers_connect
,
7257 neighbor_timers_connect_cmd
,
7258 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7261 "BGP per neighbor timers\n"
7262 "BGP connect timer\n"
7267 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7268 argv
[idx_number
]->arg
);
7271 DEFUN (no_neighbor_timers_connect
,
7272 no_neighbor_timers_connect_cmd
,
7273 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7277 "BGP per neighbor timers\n"
7278 "BGP connect timer\n"
7282 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7285 DEFPY (neighbor_timers_delayopen
,
7286 neighbor_timers_delayopen_cmd
,
7287 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7290 "BGP per neighbor timers\n"
7291 "RFC 4271 DelayOpenTimer\n"
7292 "DelayOpenTime timer interval\n")
7296 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7298 return CMD_WARNING_CONFIG_FAILED
;
7301 if (peer_timers_delayopen_unset(peer
))
7302 return CMD_WARNING_CONFIG_FAILED
;
7304 if (peer_timers_delayopen_set(peer
, interval
))
7305 return CMD_WARNING_CONFIG_FAILED
;
7311 DEFPY (no_neighbor_timers_delayopen
,
7312 no_neighbor_timers_delayopen_cmd
,
7313 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7317 "BGP per neighbor timers\n"
7318 "RFC 4271 DelayOpenTimer\n"
7319 "DelayOpenTime timer interval\n")
7323 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7325 return CMD_WARNING_CONFIG_FAILED
;
7327 if (peer_timers_delayopen_unset(peer
))
7328 return CMD_WARNING_CONFIG_FAILED
;
7333 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7334 const char *time_str
, int set
)
7338 uint32_t routeadv
= 0;
7340 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7342 return CMD_WARNING_CONFIG_FAILED
;
7345 routeadv
= strtoul(time_str
, NULL
, 10);
7348 ret
= peer_advertise_interval_set(peer
, routeadv
);
7350 ret
= peer_advertise_interval_unset(peer
);
7352 return bgp_vty_return(vty
, ret
);
7355 DEFUN (neighbor_advertise_interval
,
7356 neighbor_advertise_interval_cmd
,
7357 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7360 "Minimum interval between sending BGP routing updates\n"
7361 "time in seconds\n")
7365 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7366 argv
[idx_number
]->arg
, 1);
7369 DEFUN (no_neighbor_advertise_interval
,
7370 no_neighbor_advertise_interval_cmd
,
7371 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7375 "Minimum interval between sending BGP routing updates\n"
7376 "time in seconds\n")
7379 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7383 /* Time to wait before processing route-map updates */
7384 DEFUN (bgp_set_route_map_delay_timer
,
7385 bgp_set_route_map_delay_timer_cmd
,
7386 "bgp route-map delay-timer (0-600)",
7388 "BGP route-map delay timer\n"
7389 "Time in secs to wait before processing route-map changes\n"
7390 "0 disables the timer, no route updates happen when route-maps change\n")
7393 uint32_t rmap_delay_timer
;
7395 if (argv
[idx_number
]->arg
) {
7396 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7397 bm
->rmap_update_timer
= rmap_delay_timer
;
7399 /* if the dynamic update handling is being disabled, and a timer
7401 * running, stop the timer and act as if the timer has already
7404 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7405 THREAD_OFF(bm
->t_rmap_update
);
7406 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7411 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7412 return CMD_WARNING_CONFIG_FAILED
;
7416 DEFUN (no_bgp_set_route_map_delay_timer
,
7417 no_bgp_set_route_map_delay_timer_cmd
,
7418 "no bgp route-map delay-timer [(0-600)]",
7421 "Default BGP route-map delay timer\n"
7422 "Reset to default time to wait for processing route-map changes\n"
7423 "0 disables the timer, no route updates happen when route-maps change\n")
7426 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7431 /* neighbor interface */
7432 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7437 peer
= peer_lookup_vty(vty
, ip_str
);
7438 if (!peer
|| peer
->conf_if
) {
7439 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7440 return CMD_WARNING_CONFIG_FAILED
;
7444 peer_interface_set(peer
, str
);
7446 peer_interface_unset(peer
);
7451 DEFUN (neighbor_interface
,
7452 neighbor_interface_cmd
,
7453 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7462 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7465 DEFUN (no_neighbor_interface
,
7466 no_neighbor_interface_cmd
,
7467 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7476 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7479 DEFUN (neighbor_distribute_list
,
7480 neighbor_distribute_list_cmd
,
7481 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7484 "Filter updates to/from this neighbor\n"
7485 "IP Access-list name\n"
7486 "Filter incoming updates\n"
7487 "Filter outgoing updates\n")
7494 const char *pstr
= argv
[idx_peer
]->arg
;
7495 const char *acl
= argv
[idx_acl
]->arg
;
7496 const char *inout
= argv
[argc
- 1]->text
;
7498 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7500 return CMD_WARNING_CONFIG_FAILED
;
7502 /* Check filter direction. */
7503 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7504 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7507 return bgp_vty_return(vty
, ret
);
7511 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7512 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7513 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7514 "Filter updates to/from this neighbor\n"
7515 "IP Access-list name\n"
7516 "Filter incoming updates\n"
7517 "Filter outgoing updates\n")
7519 DEFUN (no_neighbor_distribute_list
,
7520 no_neighbor_distribute_list_cmd
,
7521 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7525 "Filter updates to/from this neighbor\n"
7526 "IP Access-list name\n"
7527 "Filter incoming updates\n"
7528 "Filter outgoing updates\n")
7534 const char *pstr
= argv
[idx_peer
]->arg
;
7535 const char *inout
= argv
[argc
- 1]->text
;
7537 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7539 return CMD_WARNING_CONFIG_FAILED
;
7541 /* Check filter direction. */
7542 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7543 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7546 return bgp_vty_return(vty
, ret
);
7550 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7551 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7552 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7553 "Filter updates to/from this neighbor\n"
7554 "IP Access-list name\n"
7555 "Filter incoming updates\n"
7556 "Filter outgoing updates\n")
7558 /* Set prefix list to the peer. */
7559 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7560 afi_t afi
, safi_t safi
,
7561 const char *name_str
,
7562 const char *direct_str
)
7565 int direct
= FILTER_IN
;
7568 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7570 return CMD_WARNING_CONFIG_FAILED
;
7572 /* Check filter direction. */
7573 if (strncmp(direct_str
, "i", 1) == 0)
7575 else if (strncmp(direct_str
, "o", 1) == 0)
7576 direct
= FILTER_OUT
;
7578 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7580 return bgp_vty_return(vty
, ret
);
7583 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7584 afi_t afi
, safi_t safi
,
7585 const char *direct_str
)
7589 int direct
= FILTER_IN
;
7591 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7593 return CMD_WARNING_CONFIG_FAILED
;
7595 /* Check filter direction. */
7596 if (strncmp(direct_str
, "i", 1) == 0)
7598 else if (strncmp(direct_str
, "o", 1) == 0)
7599 direct
= FILTER_OUT
;
7601 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7603 return bgp_vty_return(vty
, ret
);
7606 DEFUN (neighbor_prefix_list
,
7607 neighbor_prefix_list_cmd
,
7608 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7611 "Filter updates to/from this neighbor\n"
7612 "Name of a prefix list\n"
7613 "Filter incoming updates\n"
7614 "Filter outgoing updates\n")
7619 return peer_prefix_list_set_vty(
7620 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7621 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7624 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7625 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7626 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7627 "Filter updates to/from this neighbor\n"
7628 "Name of a prefix list\n"
7629 "Filter incoming updates\n"
7630 "Filter outgoing updates\n")
7632 DEFUN (no_neighbor_prefix_list
,
7633 no_neighbor_prefix_list_cmd
,
7634 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7638 "Filter updates to/from this neighbor\n"
7639 "Name of a prefix list\n"
7640 "Filter incoming updates\n"
7641 "Filter outgoing updates\n")
7645 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7646 bgp_node_afi(vty
), bgp_node_safi(vty
),
7647 argv
[idx_in_out
]->arg
);
7650 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7651 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7652 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7653 "Filter updates to/from this neighbor\n"
7654 "Name of a prefix list\n"
7655 "Filter incoming updates\n"
7656 "Filter outgoing updates\n")
7658 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7659 safi_t safi
, const char *name_str
,
7660 const char *direct_str
)
7664 int direct
= FILTER_IN
;
7666 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7668 return CMD_WARNING_CONFIG_FAILED
;
7670 /* Check filter direction. */
7671 if (strncmp(direct_str
, "i", 1) == 0)
7673 else if (strncmp(direct_str
, "o", 1) == 0)
7674 direct
= FILTER_OUT
;
7676 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7678 return bgp_vty_return(vty
, ret
);
7681 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7682 safi_t safi
, const char *direct_str
)
7686 int direct
= FILTER_IN
;
7688 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7690 return CMD_WARNING_CONFIG_FAILED
;
7692 /* Check filter direction. */
7693 if (strncmp(direct_str
, "i", 1) == 0)
7695 else if (strncmp(direct_str
, "o", 1) == 0)
7696 direct
= FILTER_OUT
;
7698 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7700 return bgp_vty_return(vty
, ret
);
7703 DEFUN (neighbor_filter_list
,
7704 neighbor_filter_list_cmd
,
7705 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7708 "Establish BGP filters\n"
7709 "AS path access-list name\n"
7710 "Filter incoming routes\n"
7711 "Filter outgoing routes\n")
7716 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7717 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7718 argv
[idx_in_out
]->arg
);
7721 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7722 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7723 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7724 "Establish BGP filters\n"
7725 "AS path access-list name\n"
7726 "Filter incoming routes\n"
7727 "Filter outgoing routes\n")
7729 DEFUN (no_neighbor_filter_list
,
7730 no_neighbor_filter_list_cmd
,
7731 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7735 "Establish BGP filters\n"
7736 "AS path access-list name\n"
7737 "Filter incoming routes\n"
7738 "Filter outgoing routes\n")
7742 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7743 bgp_node_afi(vty
), bgp_node_safi(vty
),
7744 argv
[idx_in_out
]->arg
);
7747 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7748 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7749 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7750 "Establish BGP filters\n"
7751 "AS path access-list name\n"
7752 "Filter incoming routes\n"
7753 "Filter outgoing routes\n")
7755 /* Set advertise-map to the peer. */
7756 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7757 afi_t afi
, safi_t safi
,
7758 const char *advertise_str
,
7759 const char *condition_str
, bool condition
,
7762 int ret
= CMD_WARNING_CONFIG_FAILED
;
7764 struct route_map
*advertise_map
;
7765 struct route_map
*condition_map
;
7767 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7771 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7772 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7775 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7776 advertise_map
, condition_str
,
7777 condition_map
, condition
);
7779 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7780 advertise_map
, condition_str
,
7781 condition_map
, condition
);
7783 return bgp_vty_return(vty
, ret
);
7786 DEFPY (bgp_condadv_period
,
7787 bgp_condadv_period_cmd
,
7788 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7791 "Conditional advertisement settings\n"
7792 "Set period to rescan BGP table to check if condition is met\n"
7793 "Period between BGP table scans, in seconds; default 60\n")
7795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7797 bgp
->condition_check_period
=
7798 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7803 DEFPY (neighbor_advertise_map
,
7804 neighbor_advertise_map_cmd
,
7805 "[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",
7809 "Route-map to conditionally advertise routes\n"
7810 "Name of advertise map\n"
7811 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7812 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7813 "Name of the exist or non exist map\n")
7815 bool condition
= CONDITION_EXIST
;
7817 if (!strcmp(exist
, "non-exist-map"))
7818 condition
= CONDITION_NON_EXIST
;
7820 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7821 bgp_node_safi(vty
), advertise_str
,
7822 condition_str
, condition
, !no
);
7825 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7826 "[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",
7827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7828 "Route-map to conditionally advertise routes\n"
7829 "Name of advertise map\n"
7830 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7831 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7832 "Name of the exist or non exist map\n")
7834 /* Set route-map to the peer. */
7835 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7836 afi_t afi
, safi_t safi
, const char *name_str
,
7837 const char *direct_str
)
7841 int direct
= RMAP_IN
;
7842 struct route_map
*route_map
;
7844 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7846 return CMD_WARNING_CONFIG_FAILED
;
7848 /* Check filter direction. */
7849 if (strncmp(direct_str
, "in", 2) == 0)
7851 else if (strncmp(direct_str
, "o", 1) == 0)
7854 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7855 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7857 return bgp_vty_return(vty
, ret
);
7860 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7861 afi_t afi
, safi_t safi
,
7862 const char *direct_str
)
7866 int direct
= RMAP_IN
;
7868 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7870 return CMD_WARNING_CONFIG_FAILED
;
7872 /* Check filter direction. */
7873 if (strncmp(direct_str
, "in", 2) == 0)
7875 else if (strncmp(direct_str
, "o", 1) == 0)
7878 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7880 return bgp_vty_return(vty
, ret
);
7883 DEFUN (neighbor_route_map
,
7884 neighbor_route_map_cmd
,
7885 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7888 "Apply route map to neighbor\n"
7889 "Name of route map\n"
7890 "Apply map to incoming routes\n"
7891 "Apply map to outbound routes\n")
7896 return peer_route_map_set_vty(
7897 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7898 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7901 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7902 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7903 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7904 "Apply route map to neighbor\n"
7905 "Name of route map\n"
7906 "Apply map to incoming routes\n"
7907 "Apply map to outbound routes\n")
7909 DEFUN (no_neighbor_route_map
,
7910 no_neighbor_route_map_cmd
,
7911 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7915 "Apply route map to neighbor\n"
7916 "Name of route map\n"
7917 "Apply map to incoming routes\n"
7918 "Apply map to outbound routes\n")
7922 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7923 bgp_node_afi(vty
), bgp_node_safi(vty
),
7924 argv
[idx_in_out
]->arg
);
7927 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7928 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7929 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7930 "Apply route map to neighbor\n"
7931 "Name of route map\n"
7932 "Apply map to incoming routes\n"
7933 "Apply map to outbound routes\n")
7935 /* Set unsuppress-map to the peer. */
7936 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7937 afi_t afi
, safi_t safi
,
7938 const char *name_str
)
7942 struct route_map
*route_map
;
7944 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7946 return CMD_WARNING_CONFIG_FAILED
;
7948 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7949 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7951 return bgp_vty_return(vty
, ret
);
7954 /* Unset route-map from the peer. */
7955 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7956 afi_t afi
, safi_t safi
)
7961 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7963 return CMD_WARNING_CONFIG_FAILED
;
7965 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7967 return bgp_vty_return(vty
, ret
);
7970 DEFUN (neighbor_unsuppress_map
,
7971 neighbor_unsuppress_map_cmd
,
7972 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7975 "Route-map to selectively unsuppress suppressed routes\n"
7976 "Name of route map\n")
7980 return peer_unsuppress_map_set_vty(
7981 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7982 argv
[idx_word
]->arg
);
7985 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7986 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7987 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7988 "Route-map to selectively unsuppress suppressed routes\n"
7989 "Name of route map\n")
7991 DEFUN (no_neighbor_unsuppress_map
,
7992 no_neighbor_unsuppress_map_cmd
,
7993 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7997 "Route-map to selectively unsuppress suppressed routes\n"
7998 "Name of route map\n")
8001 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8003 bgp_node_safi(vty
));
8006 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8007 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8008 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8009 "Route-map to selectively unsuppress suppressed routes\n"
8010 "Name of route map\n")
8012 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8013 afi_t afi
, safi_t safi
,
8014 const char *num_str
,
8015 const char *threshold_str
, int warning
,
8016 const char *restart_str
,
8017 const char *force_str
)
8025 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8027 return CMD_WARNING_CONFIG_FAILED
;
8029 max
= strtoul(num_str
, NULL
, 10);
8031 threshold
= atoi(threshold_str
);
8033 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8036 restart
= atoi(restart_str
);
8040 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8041 restart
, force_str
? true : false);
8043 return bgp_vty_return(vty
, ret
);
8046 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8047 afi_t afi
, safi_t safi
)
8052 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8054 return CMD_WARNING_CONFIG_FAILED
;
8056 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8058 return bgp_vty_return(vty
, ret
);
8061 /* Maximum number of prefix to be sent to the neighbor. */
8062 DEFUN(neighbor_maximum_prefix_out
,
8063 neighbor_maximum_prefix_out_cmd
,
8064 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8067 "Maximum number of prefixes to be sent to this peer\n"
8068 "Maximum no. of prefix limit\n")
8075 afi_t afi
= bgp_node_afi(vty
);
8076 safi_t safi
= bgp_node_safi(vty
);
8078 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8080 return CMD_WARNING_CONFIG_FAILED
;
8082 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8084 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8086 return bgp_vty_return(vty
, ret
);
8089 DEFUN(no_neighbor_maximum_prefix_out
,
8090 no_neighbor_maximum_prefix_out_cmd
,
8091 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8095 "Maximum number of prefixes to be sent to this peer\n"
8096 "Maximum no. of prefix limit\n")
8101 afi_t afi
= bgp_node_afi(vty
);
8102 safi_t safi
= bgp_node_safi(vty
);
8104 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8106 return CMD_WARNING_CONFIG_FAILED
;
8108 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8110 return bgp_vty_return(vty
, ret
);
8113 /* Maximum number of prefix configuration. Prefix count is different
8114 for each peer configuration. So this configuration can be set for
8115 each peer configuration. */
8116 DEFUN (neighbor_maximum_prefix
,
8117 neighbor_maximum_prefix_cmd
,
8118 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
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")
8130 if (argv_find(argv
, argc
, "force", &idx_force
))
8131 force
= argv
[idx_force
]->arg
;
8133 return peer_maximum_prefix_set_vty(
8134 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8135 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8138 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8139 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8140 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8141 "Maximum number of prefix accept from this peer\n"
8142 "maximum no. of prefix limit\n"
8143 "Force checking all received routes not only accepted\n")
8145 DEFUN (neighbor_maximum_prefix_threshold
,
8146 neighbor_maximum_prefix_threshold_cmd
,
8147 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8150 "Maximum number of prefix accept from this peer\n"
8151 "maximum no. of prefix limit\n"
8152 "Threshold value (%) at which to generate a warning msg\n"
8153 "Force checking all received routes not only accepted\n")
8157 int idx_number_2
= 4;
8161 if (argv_find(argv
, argc
, "force", &idx_force
))
8162 force
= argv
[idx_force
]->arg
;
8164 return peer_maximum_prefix_set_vty(
8165 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8166 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8170 neighbor_maximum_prefix_threshold
,
8171 neighbor_maximum_prefix_threshold_hidden_cmd
,
8172 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8173 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8174 "Maximum number of prefix accept from this peer\n"
8175 "maximum no. of prefix limit\n"
8176 "Threshold value (%) at which to generate a warning msg\n"
8177 "Force checking all received routes not only accepted\n")
8179 DEFUN (neighbor_maximum_prefix_warning
,
8180 neighbor_maximum_prefix_warning_cmd
,
8181 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8184 "Maximum number of prefix accept from this peer\n"
8185 "maximum no. of prefix limit\n"
8186 "Only give warning message when limit is exceeded\n"
8187 "Force checking all received routes not only accepted\n")
8194 if (argv_find(argv
, argc
, "force", &idx_force
))
8195 force
= argv
[idx_force
]->arg
;
8197 return peer_maximum_prefix_set_vty(
8198 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8199 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8203 neighbor_maximum_prefix_warning
,
8204 neighbor_maximum_prefix_warning_hidden_cmd
,
8205 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8206 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8207 "Maximum number of prefix accept from this peer\n"
8208 "maximum no. of prefix limit\n"
8209 "Only give warning message when limit is exceeded\n"
8210 "Force checking all received routes not only accepted\n")
8212 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8213 neighbor_maximum_prefix_threshold_warning_cmd
,
8214 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8217 "Maximum number of prefix accept from this peer\n"
8218 "maximum no. of prefix limit\n"
8219 "Threshold value (%) at which to generate a warning msg\n"
8220 "Only give warning message when limit is exceeded\n"
8221 "Force checking all received routes not only accepted\n")
8225 int idx_number_2
= 4;
8229 if (argv_find(argv
, argc
, "force", &idx_force
))
8230 force
= argv
[idx_force
]->arg
;
8232 return peer_maximum_prefix_set_vty(
8233 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8234 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8238 neighbor_maximum_prefix_threshold_warning
,
8239 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8240 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8241 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8242 "Maximum number of prefix accept from this peer\n"
8243 "maximum no. of prefix limit\n"
8244 "Threshold value (%) at which to generate a warning msg\n"
8245 "Only give warning message when limit is exceeded\n"
8246 "Force checking all received routes not only accepted\n")
8248 DEFUN (neighbor_maximum_prefix_restart
,
8249 neighbor_maximum_prefix_restart_cmd
,
8250 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8253 "Maximum number of prefix accept from this peer\n"
8254 "maximum no. of prefix limit\n"
8255 "Restart bgp connection after limit is exceeded\n"
8256 "Restart interval in minutes\n"
8257 "Force checking all received routes not only accepted\n")
8261 int idx_number_2
= 5;
8265 if (argv_find(argv
, argc
, "force", &idx_force
))
8266 force
= argv
[idx_force
]->arg
;
8268 return peer_maximum_prefix_set_vty(
8269 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8270 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8274 neighbor_maximum_prefix_restart
,
8275 neighbor_maximum_prefix_restart_hidden_cmd
,
8276 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8277 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8278 "Maximum number of prefix accept from this peer\n"
8279 "maximum no. of prefix limit\n"
8280 "Restart bgp connection after limit is exceeded\n"
8281 "Restart interval in minutes\n"
8282 "Force checking all received routes not only accepted\n")
8284 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8285 neighbor_maximum_prefix_threshold_restart_cmd
,
8286 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8289 "Maximum number of prefixes to accept from this peer\n"
8290 "maximum no. of prefix limit\n"
8291 "Threshold value (%) at which to generate a warning msg\n"
8292 "Restart bgp connection after limit is exceeded\n"
8293 "Restart interval in minutes\n"
8294 "Force checking all received routes not only accepted\n")
8298 int idx_number_2
= 4;
8299 int idx_number_3
= 6;
8303 if (argv_find(argv
, argc
, "force", &idx_force
))
8304 force
= argv
[idx_force
]->arg
;
8306 return peer_maximum_prefix_set_vty(
8307 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8308 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8309 argv
[idx_number_3
]->arg
, force
);
8313 neighbor_maximum_prefix_threshold_restart
,
8314 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8315 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8316 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8317 "Maximum number of prefixes to accept from this peer\n"
8318 "maximum no. of prefix limit\n"
8319 "Threshold value (%) at which to generate a warning msg\n"
8320 "Restart bgp connection after limit is exceeded\n"
8321 "Restart interval in minutes\n"
8322 "Force checking all received routes not only accepted\n")
8324 DEFUN (no_neighbor_maximum_prefix
,
8325 no_neighbor_maximum_prefix_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]]",
8330 "Maximum number of prefixes to accept from this peer\n"
8331 "maximum no. of prefix limit\n"
8332 "Threshold value (%) at which to generate a warning msg\n"
8333 "Restart bgp connection after limit is exceeded\n"
8334 "Restart interval in minutes\n"
8335 "Only give warning message when limit is exceeded\n"
8336 "Force checking all received routes not only accepted\n")
8339 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8341 bgp_node_safi(vty
));
8345 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8346 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8347 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8348 "Maximum number of prefixes to accept from this peer\n"
8349 "maximum no. of prefix limit\n"
8350 "Threshold value (%) at which to generate a warning msg\n"
8351 "Restart bgp connection after limit is exceeded\n"
8352 "Restart interval in minutes\n"
8353 "Only give warning message when limit is exceeded\n"
8354 "Force checking all received routes not only accepted\n")
8356 /* "neighbor accept-own" */
8357 DEFPY (neighbor_accept_own
,
8358 neighbor_accept_own_cmd
,
8359 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8363 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8366 afi_t afi
= bgp_node_afi(vty
);
8367 safi_t safi
= bgp_node_safi(vty
);
8370 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8372 return CMD_WARNING_CONFIG_FAILED
;
8375 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8377 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8379 return bgp_vty_return(vty
, ret
);
8382 /* "neighbor soo" */
8383 DEFPY (neighbor_soo
,
8385 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8388 "Set the Site-of-Origin (SoO) extended community\n"
8389 "VPN extended community\n")
8392 afi_t afi
= bgp_node_afi(vty
);
8393 safi_t safi
= bgp_node_safi(vty
);
8394 struct ecommunity
*ecomm_soo
;
8396 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8398 return CMD_WARNING_CONFIG_FAILED
;
8400 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8402 vty_out(vty
, "%% Malformed SoO extended community\n");
8405 ecommunity_str(ecomm_soo
);
8407 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8408 ecommunity_free(&peer
->soo
[afi
][safi
]);
8409 peer
->soo
[afi
][safi
] = ecomm_soo
;
8410 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8413 return bgp_vty_return(vty
,
8414 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8417 DEFPY (no_neighbor_soo
,
8418 no_neighbor_soo_cmd
,
8419 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8423 "Set the Site-of-Origin (SoO) extended community\n"
8424 "VPN extended community\n")
8427 afi_t afi
= bgp_node_afi(vty
);
8428 safi_t safi
= bgp_node_safi(vty
);
8430 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8432 return CMD_WARNING_CONFIG_FAILED
;
8434 ecommunity_free(&peer
->soo
[afi
][safi
]);
8436 return bgp_vty_return(
8437 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8440 /* "neighbor allowas-in" */
8441 DEFUN (neighbor_allowas_in
,
8442 neighbor_allowas_in_cmd
,
8443 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8446 "Accept as-path with my AS present in it\n"
8447 "Number of occurrences of AS number\n"
8448 "Only accept my AS in the as-path if the route was originated in my AS\n")
8451 int idx_number_origin
= 3;
8457 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8459 return CMD_WARNING_CONFIG_FAILED
;
8461 if (argc
<= idx_number_origin
)
8464 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8467 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8470 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8473 return bgp_vty_return(vty
, ret
);
8477 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8478 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8479 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8480 "Accept as-path with my AS present in it\n"
8481 "Number of occurrences of AS number\n"
8482 "Only accept my AS in the as-path if the route was originated in my AS\n")
8484 DEFUN (no_neighbor_allowas_in
,
8485 no_neighbor_allowas_in_cmd
,
8486 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8490 "allow local ASN appears in aspath attribute\n"
8491 "Number of occurrences of AS number\n"
8492 "Only accept my AS in the as-path if the route was originated in my AS\n")
8498 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8500 return CMD_WARNING_CONFIG_FAILED
;
8502 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8503 bgp_node_safi(vty
));
8505 return bgp_vty_return(vty
, ret
);
8509 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8510 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8511 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8512 "allow local ASN appears in aspath attribute\n"
8513 "Number of occurrences of AS number\n"
8514 "Only accept my AS in the as-path if the route was originated in my AS\n")
8516 DEFUN (neighbor_ttl_security
,
8517 neighbor_ttl_security_cmd
,
8518 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8521 "BGP ttl-security parameters\n"
8522 "Specify the maximum number of hops to the BGP peer\n"
8523 "Number of hops to BGP peer\n")
8530 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8532 return CMD_WARNING_CONFIG_FAILED
;
8534 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8537 * If 'neighbor swpX', then this is for directly connected peers,
8538 * we should not accept a ttl-security hops value greater than 1.
8540 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8542 "%s is directly connected peer, hops cannot exceed 1\n",
8543 argv
[idx_peer
]->arg
);
8544 return CMD_WARNING_CONFIG_FAILED
;
8547 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8550 DEFUN (no_neighbor_ttl_security
,
8551 no_neighbor_ttl_security_cmd
,
8552 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8556 "BGP ttl-security parameters\n"
8557 "Specify the maximum number of hops to the BGP peer\n"
8558 "Number of hops to BGP peer\n")
8563 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8565 return CMD_WARNING_CONFIG_FAILED
;
8567 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8570 /* disable-addpath-rx */
8571 DEFUN(neighbor_disable_addpath_rx
,
8572 neighbor_disable_addpath_rx_cmd
,
8573 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8576 "Do not accept additional paths\n")
8578 char *peer_str
= argv
[1]->arg
;
8580 afi_t afi
= bgp_node_afi(vty
);
8581 safi_t safi
= bgp_node_safi(vty
);
8583 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8585 return CMD_WARNING_CONFIG_FAILED
;
8587 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8588 PEER_FLAG_DISABLE_ADDPATH_RX
);
8591 DEFUN(no_neighbor_disable_addpath_rx
,
8592 no_neighbor_disable_addpath_rx_cmd
,
8593 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8597 "Do not accept additional paths\n")
8599 char *peer_str
= argv
[2]->arg
;
8601 afi_t afi
= bgp_node_afi(vty
);
8602 safi_t safi
= bgp_node_safi(vty
);
8604 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8606 return CMD_WARNING_CONFIG_FAILED
;
8608 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8609 PEER_FLAG_DISABLE_ADDPATH_RX
);
8612 DEFUN (neighbor_addpath_tx_all_paths
,
8613 neighbor_addpath_tx_all_paths_cmd
,
8614 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8617 "Use addpath to advertise all paths to a neighbor\n")
8622 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8624 return CMD_WARNING_CONFIG_FAILED
;
8626 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8631 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8632 neighbor_addpath_tx_all_paths_hidden_cmd
,
8633 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8634 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8635 "Use addpath to advertise all paths to a neighbor\n")
8637 DEFUN (no_neighbor_addpath_tx_all_paths
,
8638 no_neighbor_addpath_tx_all_paths_cmd
,
8639 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8643 "Use addpath to advertise all paths to a neighbor\n")
8648 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8650 return CMD_WARNING_CONFIG_FAILED
;
8652 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8653 != BGP_ADDPATH_ALL
) {
8655 "%% Peer not currently configured to transmit all paths.");
8656 return CMD_WARNING_CONFIG_FAILED
;
8659 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8665 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8666 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8667 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8668 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8669 "Use addpath to advertise all paths to a neighbor\n")
8671 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8672 neighbor_addpath_tx_bestpath_per_as_cmd
,
8673 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8676 "Use addpath to advertise the bestpath per each neighboring AS\n")
8681 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8683 return CMD_WARNING_CONFIG_FAILED
;
8685 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8686 BGP_ADDPATH_BEST_PER_AS
);
8691 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8692 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8693 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8694 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8695 "Use addpath to advertise the bestpath per each neighboring AS\n")
8697 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8698 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8699 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8703 "Use addpath to advertise the bestpath per each neighboring AS\n")
8708 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8710 return CMD_WARNING_CONFIG_FAILED
;
8712 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8713 != BGP_ADDPATH_BEST_PER_AS
) {
8715 "%% Peer not currently configured to transmit all best path per as.");
8716 return CMD_WARNING_CONFIG_FAILED
;
8719 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8725 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8726 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8727 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8728 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8729 "Use addpath to advertise the bestpath per each neighboring AS\n")
8732 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8733 "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
= true;
8750 no_neighbor_aspath_loop_detection
,
8751 no_neighbor_aspath_loop_detection_cmd
,
8752 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8756 "Detect AS loops before sending to neighbor\n")
8760 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8762 return CMD_WARNING_CONFIG_FAILED
;
8764 peer
->as_path_loop_detection
= false;
8769 DEFPY(neighbor_path_attribute_discard
,
8770 neighbor_path_attribute_discard_cmd
,
8771 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...",
8774 "Manipulate path attributes from incoming UPDATE messages\n"
8775 "Drop specified attributes from incoming UPDATE messages\n"
8776 "Attribute number\n")
8780 const char *discard_attrs
= NULL
;
8782 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8784 return CMD_WARNING_CONFIG_FAILED
;
8786 argv_find(argv
, argc
, "(1-255)", &idx
);
8788 discard_attrs
= argv_concat(argv
, argc
, idx
);
8790 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
);
8795 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8796 struct ecommunity
**list
, bool is_rt6
)
8798 struct ecommunity
*ecom
= NULL
;
8799 struct ecommunity
*ecomadd
;
8801 for (; argc
; --argc
, ++argv
) {
8803 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8804 ECOMMUNITY_ROUTE_TARGET
,
8807 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8808 ECOMMUNITY_ROUTE_TARGET
,
8811 vty_out(vty
, "Malformed community-list value\n");
8813 ecommunity_free(&ecom
);
8814 return CMD_WARNING_CONFIG_FAILED
;
8818 ecommunity_merge(ecom
, ecomadd
);
8819 ecommunity_free(&ecomadd
);
8826 ecommunity_free(&*list
);
8834 * v2vimport is true if we are handling a `import vrf ...` command
8836 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8840 switch (vty
->node
) {
8849 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8854 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8855 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8856 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8857 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8859 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8863 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8864 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8865 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8866 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8868 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8875 DEFPY (af_rd_vpn_export
,
8876 af_rd_vpn_export_cmd
,
8877 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8879 "Specify route distinguisher\n"
8880 "Between current address-family and vpn\n"
8881 "For routes leaked from current address-family to vpn\n"
8882 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8885 struct prefix_rd prd
;
8891 if (argv_find(argv
, argc
, "no", &idx
))
8895 ret
= str2prefix_rd(rd_str
, &prd
);
8897 vty_out(vty
, "%% Malformed rd\n");
8898 return CMD_WARNING_CONFIG_FAILED
;
8902 afi
= vpn_policy_getafi(vty
, bgp
, false);
8904 return CMD_WARNING_CONFIG_FAILED
;
8907 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8909 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8910 bgp_get_default(), bgp
);
8913 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8914 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8915 BGP_VPN_POLICY_TOVPN_RD_SET
);
8917 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8918 BGP_VPN_POLICY_TOVPN_RD_SET
);
8921 /* post-change: re-export vpn routes */
8922 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8923 bgp_get_default(), bgp
);
8928 ALIAS (af_rd_vpn_export
,
8929 af_no_rd_vpn_export_cmd
,
8932 "Specify route distinguisher\n"
8933 "Between current address-family and vpn\n"
8934 "For routes leaked from current address-family to vpn\n")
8936 DEFPY (af_label_vpn_export
,
8937 af_label_vpn_export_cmd
,
8938 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8940 "label value for VRF\n"
8941 "Between current address-family and vpn\n"
8942 "For routes leaked from current address-family to vpn\n"
8943 "Label Value <0-1048575>\n"
8944 "Automatically assign a label\n")
8946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8947 mpls_label_t label
= MPLS_LABEL_NONE
;
8952 if (argv_find(argv
, argc
, "no", &idx
))
8955 /* If "no ...", squash trailing parameter */
8961 label
= label_val
; /* parser should force unsigned */
8964 afi
= vpn_policy_getafi(vty
, bgp
, false);
8966 return CMD_WARNING_CONFIG_FAILED
;
8969 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8970 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8975 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8977 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8978 bgp_get_default(), bgp
);
8980 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8981 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8983 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8986 * label has previously been automatically
8987 * assigned by labelpool: release it
8989 * NB if tovpn_label == MPLS_LABEL_NONE it
8990 * means the automatic assignment is in flight
8991 * and therefore the labelpool callback must
8992 * detect that the auto label is not needed.
8995 bgp_lp_release(LP_TYPE_VRF
,
8996 &bgp
->vpn_policy
[afi
],
8997 bgp
->vpn_policy
[afi
].tovpn_label
);
8999 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9000 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9003 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9005 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9006 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9007 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9008 vpn_leak_label_callback
);
9011 /* post-change: re-export vpn routes */
9012 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9013 bgp_get_default(), bgp
);
9015 hook_call(bgp_snmp_update_last_changed
, bgp
);
9019 DEFPY (af_sid_vpn_export
,
9020 af_sid_vpn_export_cmd
,
9021 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9023 "sid value for VRF\n"
9024 "Between current address-family and vpn\n"
9025 "For routes leaked from current address-family to vpn\n"
9026 "Sid allocation index\n"
9027 "Automatically assign a label\n")
9029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9035 if (argv_find(argv
, argc
, "no", &idx
))
9037 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9038 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9040 afi
= vpn_policy_getafi(vty
, bgp
, false);
9042 return CMD_WARNING_CONFIG_FAILED
;
9046 vty_out(vty
, "It's not implemented\n");
9047 return CMD_WARNING_CONFIG_FAILED
;
9050 if (bgp
->tovpn_sid_index
!= 0 ||
9051 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9053 "per-vrf sid and per-af sid are mutually exclusive\n"
9054 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9055 return CMD_WARNING_CONFIG_FAILED
;
9058 /* skip when it's already configured */
9059 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9060 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9061 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9065 * mode change between sid_idx and sid_auto isn't supported.
9066 * user must negate sid vpn export when they want to change the mode
9068 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9069 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9070 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9071 vty_out(vty
, "it's already configured as %s.\n",
9072 sid_auto
? "auto-mode" : "idx-mode");
9073 return CMD_WARNING_CONFIG_FAILED
;
9077 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9078 bgp_get_default(), bgp
);
9081 /* SID allocation auto-mode */
9083 zlog_debug("%s: auto sid alloc.", __func__
);
9084 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9085 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9087 /* SID allocation index-mode */
9089 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9090 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9094 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9095 bgp_get_default(), bgp
);
9099 DEFPY (bgp_sid_vpn_export
,
9100 bgp_sid_vpn_export_cmd
,
9101 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9103 "sid value for VRF\n"
9104 "Between current vrf and vpn\n"
9105 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9106 "For routes leaked from current vrf to vpn\n"
9107 "Sid allocation index\n"
9108 "Automatically assign a label\n")
9110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9113 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9114 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9117 /* when per-VRF SID is not set, do nothing */
9118 if (bgp
->tovpn_sid_index
== 0 &&
9119 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9124 bgp
->tovpn_sid_index
= 0;
9125 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9128 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9129 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9130 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9131 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9132 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9133 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9135 "per-vrf sid and per-af sid are mutually exclusive\n"
9136 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9137 return CMD_WARNING_CONFIG_FAILED
;
9140 /* skip when it's already configured */
9141 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9142 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9146 * mode change between sid_idx and sid_auto isn't supported.
9147 * user must negate sid vpn export when they want to change the mode
9149 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9151 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9152 vty_out(vty
, "it's already configured as %s.\n",
9153 sid_auto
? "auto-mode" : "idx-mode");
9154 return CMD_WARNING_CONFIG_FAILED
;
9158 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9160 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9164 /* SID allocation auto-mode */
9166 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9167 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9168 } else if (sid_idx
!= 0) {
9169 /* SID allocation index-mode */
9171 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9173 bgp
->tovpn_sid_index
= sid_idx
;
9177 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9179 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9180 bgp_get_default(), bgp
);
9185 ALIAS (af_label_vpn_export
,
9186 af_no_label_vpn_export_cmd
,
9187 "no label vpn export",
9189 "label value for VRF\n"
9190 "Between current address-family and vpn\n"
9191 "For routes leaked from current address-family to vpn\n")
9193 ALIAS (bgp_sid_vpn_export
,
9194 no_bgp_sid_vpn_export_cmd
,
9195 "no$no sid vpn per-vrf export",
9197 "sid value for VRF\n"
9198 "Between current vrf and vpn\n"
9199 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9200 "For routes leaked from current vrf to vpn\n")
9202 DEFPY (af_nexthop_vpn_export
,
9203 af_nexthop_vpn_export_cmd
,
9204 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9206 "Specify next hop to use for VRF advertised prefixes\n"
9207 "Between current address-family and vpn\n"
9208 "For routes leaked from current address-family to vpn\n"
9212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9218 vty_out(vty
, "%% Nexthop required\n");
9219 return CMD_WARNING_CONFIG_FAILED
;
9221 if (!sockunion2hostprefix(nexthop_su
, &p
))
9222 return CMD_WARNING_CONFIG_FAILED
;
9225 afi
= vpn_policy_getafi(vty
, bgp
, false);
9227 return CMD_WARNING_CONFIG_FAILED
;
9230 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9232 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9233 bgp_get_default(), bgp
);
9236 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9237 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9238 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9240 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9241 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9244 /* post-change: re-export vpn routes */
9245 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9246 bgp_get_default(), bgp
);
9251 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9253 if (!strcmp(dstr
, "import")) {
9254 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9255 } else if (!strcmp(dstr
, "export")) {
9256 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9257 } else if (!strcmp(dstr
, "both")) {
9258 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9259 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9261 vty_out(vty
, "%% direction parse error\n");
9262 return CMD_WARNING_CONFIG_FAILED
;
9267 DEFPY (af_rt_vpn_imexport
,
9268 af_rt_vpn_imexport_cmd
,
9269 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9271 "Specify route target list\n"
9272 "Specify route target list\n"
9273 "Between current address-family and vpn\n"
9274 "For routes leaked from vpn to current address-family: match any\n"
9275 "For routes leaked from current address-family to vpn: set\n"
9276 "both import: match any and export: set\n"
9277 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9281 struct ecommunity
*ecom
= NULL
;
9282 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9283 enum vpn_policy_direction dir
;
9288 if (argv_find(argv
, argc
, "no", &idx
))
9291 afi
= vpn_policy_getafi(vty
, bgp
, false);
9293 return CMD_WARNING_CONFIG_FAILED
;
9295 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9296 if (ret
!= CMD_SUCCESS
)
9300 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9301 vty_out(vty
, "%% Missing RTLIST\n");
9302 return CMD_WARNING_CONFIG_FAILED
;
9304 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9305 if (ret
!= CMD_SUCCESS
) {
9310 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9314 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9317 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9319 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9320 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9321 ecommunity_dup(ecom
);
9323 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9325 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9326 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9329 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9333 ecommunity_free(&ecom
);
9338 ALIAS (af_rt_vpn_imexport
,
9339 af_no_rt_vpn_imexport_cmd
,
9340 "no <rt|route-target> vpn <import|export|both>$direction_str",
9342 "Specify route target list\n"
9343 "Specify route target list\n"
9344 "Between current address-family and vpn\n"
9345 "For routes leaked from vpn to current address-family\n"
9346 "For routes leaked from current address-family to vpn\n"
9347 "both import and export\n")
9349 DEFPY (af_route_map_vpn_imexport
,
9350 af_route_map_vpn_imexport_cmd
,
9351 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9352 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9354 "Specify route map\n"
9355 "Between current address-family and vpn\n"
9356 "For routes leaked from vpn to current address-family\n"
9357 "For routes leaked from current address-family to vpn\n"
9358 "name of route-map\n")
9360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9362 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9363 enum vpn_policy_direction dir
;
9368 if (argv_find(argv
, argc
, "no", &idx
))
9371 afi
= vpn_policy_getafi(vty
, bgp
, false);
9373 return CMD_WARNING_CONFIG_FAILED
;
9375 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9376 if (ret
!= CMD_SUCCESS
)
9379 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9383 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9386 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9387 XFREE(MTYPE_ROUTE_MAP_NAME
,
9388 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9389 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9390 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9391 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9392 route_map_lookup_warn_noexist(vty
, rmap_str
);
9393 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9396 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9397 XFREE(MTYPE_ROUTE_MAP_NAME
,
9398 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9399 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9400 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9403 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9409 ALIAS (af_route_map_vpn_imexport
,
9410 af_no_route_map_vpn_imexport_cmd
,
9411 "no route-map vpn <import|export>$direction_str",
9413 "Specify route map\n"
9414 "Between current address-family and vpn\n"
9415 "For routes leaked from vpn to current address-family\n"
9416 "For routes leaked from current address-family to vpn\n")
9418 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9419 "import vrf route-map RMAP$rmap_str",
9420 "Import routes from another VRF\n"
9421 "Vrf routes being filtered\n"
9422 "Specify route map\n"
9423 "name of route-map\n")
9425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9426 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9428 struct bgp
*bgp_default
;
9430 afi
= vpn_policy_getafi(vty
, bgp
, true);
9432 return CMD_WARNING_CONFIG_FAILED
;
9434 bgp_default
= bgp_get_default();
9439 /* Auto-create assuming the same AS */
9440 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9441 BGP_INSTANCE_TYPE_DEFAULT
);
9445 "VRF default is not configured as a bgp instance\n");
9450 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9452 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9453 XFREE(MTYPE_ROUTE_MAP_NAME
,
9454 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9455 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9456 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9457 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9458 route_map_lookup_warn_noexist(vty
, rmap_str
);
9459 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9462 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9463 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9465 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9470 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9471 "no import vrf route-map [RMAP$rmap_str]",
9473 "Import routes from another VRF\n"
9474 "Vrf routes being filtered\n"
9475 "Specify route map\n"
9476 "name of route-map\n")
9478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9479 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9482 afi
= vpn_policy_getafi(vty
, bgp
, true);
9484 return CMD_WARNING_CONFIG_FAILED
;
9486 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9488 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9489 XFREE(MTYPE_ROUTE_MAP_NAME
,
9490 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9491 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9492 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9494 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9495 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9496 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9498 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9503 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9504 "[no] import vrf VIEWVRFNAME$import_name",
9506 "Import routes from another VRF\n"
9507 "VRF to import from\n"
9508 "The name of the VRF\n")
9510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9511 struct listnode
*node
;
9512 struct bgp
*vrf_bgp
, *bgp_default
;
9515 bool remove
= false;
9518 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9522 if (import_name
== NULL
) {
9523 vty_out(vty
, "%% Missing import name\n");
9527 if (strcmp(import_name
, "route-map") == 0) {
9528 vty_out(vty
, "%% Must include route-map name\n");
9532 if (argv_find(argv
, argc
, "no", &idx
))
9535 afi
= vpn_policy_getafi(vty
, bgp
, true);
9537 return CMD_WARNING_CONFIG_FAILED
;
9539 safi
= bgp_node_safi(vty
);
9541 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9542 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9543 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9544 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9545 remove
? "unimport" : "import", import_name
);
9549 bgp_default
= bgp_get_default();
9551 /* Auto-create assuming the same AS */
9552 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9553 BGP_INSTANCE_TYPE_DEFAULT
);
9557 "VRF default is not configured as a bgp instance\n");
9562 vrf_bgp
= bgp_lookup_by_name(import_name
);
9564 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9565 vrf_bgp
= bgp_default
;
9567 /* Auto-create assuming the same AS */
9568 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9572 "VRF %s is not configured as a bgp instance\n",
9579 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9581 /* Already importing from "import_vrf"? */
9582 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9584 if (strcmp(vname
, import_name
) == 0)
9588 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9594 /* This command is valid only in a bgp vrf instance or the default instance */
9595 DEFPY (bgp_imexport_vpn
,
9596 bgp_imexport_vpn_cmd
,
9597 "[no] <import|export>$direction_str vpn",
9599 "Import routes to this address-family\n"
9600 "Export routes from this address-family\n"
9601 "to/from default instance VPN RIB\n")
9603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9610 enum vpn_policy_direction dir
;
9612 if (argv_find(argv
, argc
, "no", &idx
))
9615 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9616 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9618 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9619 return CMD_WARNING_CONFIG_FAILED
;
9622 afi
= bgp_node_afi(vty
);
9623 safi
= bgp_node_safi(vty
);
9624 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9625 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9626 return CMD_WARNING_CONFIG_FAILED
;
9629 if (!strcmp(direction_str
, "import")) {
9630 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9631 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9632 } else if (!strcmp(direction_str
, "export")) {
9633 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9634 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9636 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9637 return CMD_WARNING_CONFIG_FAILED
;
9640 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9643 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9644 if (!previous_state
) {
9645 /* trigger export current vrf */
9646 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9649 if (previous_state
) {
9650 /* trigger un-export current vrf */
9651 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9653 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9656 hook_call(bgp_snmp_init_stats
, bgp
);
9661 DEFPY (af_routetarget_import
,
9662 af_routetarget_import_cmd
,
9663 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9665 "Specify route target list\n"
9666 "Specify route target list\n"
9667 "Specify route target list\n"
9668 "Specify route target list\n"
9669 "Flow-spec redirect type route target\n"
9670 "Import routes to this address-family\n"
9671 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9675 struct ecommunity
*ecom
= NULL
;
9677 int idx
= 0, idx_unused
= 0;
9681 if (argv_find(argv
, argc
, "no", &idx
))
9684 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9685 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9688 afi
= vpn_policy_getafi(vty
, bgp
, false);
9690 return CMD_WARNING_CONFIG_FAILED
;
9692 if (rt6
&& afi
!= AFI_IP6
)
9693 return CMD_WARNING_CONFIG_FAILED
;
9696 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9697 vty_out(vty
, "%% Missing RTLIST\n");
9698 return CMD_WARNING_CONFIG_FAILED
;
9700 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9701 if (ret
!= CMD_SUCCESS
)
9706 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9707 ecommunity_free(&bgp
->vpn_policy
[afi
]
9708 .import_redirect_rtlist
);
9709 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9710 ecommunity_dup(ecom
);
9712 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9713 ecommunity_free(&bgp
->vpn_policy
[afi
]
9714 .import_redirect_rtlist
);
9715 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9719 ecommunity_free(&ecom
);
9724 DEFUN_NOSH (address_family_ipv4_safi
,
9725 address_family_ipv4_safi_cmd
,
9726 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9727 "Enter Address Family command mode\n"
9729 BGP_SAFI_WITH_LABEL_HELP_STR
)
9733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9734 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9735 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9736 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9737 && safi
!= SAFI_EVPN
) {
9739 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9740 return CMD_WARNING_CONFIG_FAILED
;
9742 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9744 vty
->node
= BGP_IPV4_NODE
;
9749 DEFUN_NOSH (address_family_ipv6_safi
,
9750 address_family_ipv6_safi_cmd
,
9751 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9752 "Enter Address Family command mode\n"
9754 BGP_SAFI_WITH_LABEL_HELP_STR
)
9757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9758 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9759 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9760 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9761 && safi
!= SAFI_EVPN
) {
9763 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9764 return CMD_WARNING_CONFIG_FAILED
;
9766 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9768 vty
->node
= BGP_IPV6_NODE
;
9773 #ifdef KEEP_OLD_VPN_COMMANDS
9774 DEFUN_NOSH (address_family_vpnv4
,
9775 address_family_vpnv4_cmd
,
9776 "address-family vpnv4 [unicast]",
9777 "Enter Address Family command mode\n"
9779 BGP_AF_MODIFIER_STR
)
9781 vty
->node
= BGP_VPNV4_NODE
;
9785 DEFUN_NOSH (address_family_vpnv6
,
9786 address_family_vpnv6_cmd
,
9787 "address-family vpnv6 [unicast]",
9788 "Enter Address Family command mode\n"
9790 BGP_AF_MODIFIER_STR
)
9792 vty
->node
= BGP_VPNV6_NODE
;
9795 #endif /* KEEP_OLD_VPN_COMMANDS */
9797 DEFUN_NOSH (address_family_evpn
,
9798 address_family_evpn_cmd
,
9799 "address-family l2vpn evpn",
9800 "Enter Address Family command mode\n"
9802 BGP_AF_MODIFIER_STR
)
9804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9805 vty
->node
= BGP_EVPN_NODE
;
9809 DEFUN_NOSH (bgp_segment_routing_srv6
,
9810 bgp_segment_routing_srv6_cmd
,
9811 "segment-routing srv6",
9812 "Segment-Routing configuration\n"
9813 "Segment-Routing SRv6 configuration\n")
9815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9816 bgp
->srv6_enabled
= true;
9817 vty
->node
= BGP_SRV6_NODE
;
9821 DEFUN (no_bgp_segment_routing_srv6
,
9822 no_bgp_segment_routing_srv6_cmd
,
9823 "no segment-routing srv6",
9825 "Segment-Routing configuration\n"
9826 "Segment-Routing SRv6 configuration\n")
9828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9830 if (strlen(bgp
->srv6_locator_name
) > 0)
9831 if (bgp_srv6_locator_unset(bgp
) < 0)
9832 return CMD_WARNING_CONFIG_FAILED
;
9834 bgp
->srv6_enabled
= false;
9838 DEFPY (bgp_srv6_locator
,
9839 bgp_srv6_locator_cmd
,
9840 "locator NAME$name",
9841 "Specify SRv6 locator\n"
9842 "Specify SRv6 locator\n")
9844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9847 if (strlen(bgp
->srv6_locator_name
) > 0
9848 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9849 vty_out(vty
, "srv6 locator is already configured\n");
9850 return CMD_WARNING_CONFIG_FAILED
;
9853 snprintf(bgp
->srv6_locator_name
,
9854 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9856 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9858 return CMD_WARNING_CONFIG_FAILED
;
9863 DEFPY (no_bgp_srv6_locator
,
9864 no_bgp_srv6_locator_cmd
,
9865 "no locator NAME$name",
9867 "Specify SRv6 locator\n"
9868 "Specify SRv6 locator\n")
9870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9872 /* when locator isn't configured, do nothing */
9873 if (strlen(bgp
->srv6_locator_name
) < 1)
9876 /* name validation */
9877 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9878 vty_out(vty
, "%% No srv6 locator is configured\n");
9879 return CMD_WARNING_CONFIG_FAILED
;
9883 if (bgp_srv6_locator_unset(bgp
) < 0)
9884 return CMD_WARNING_CONFIG_FAILED
;
9889 DEFPY (show_bgp_srv6
,
9891 "show bgp segment-routing srv6",
9894 "BGP Segment Routing\n"
9895 "BGP Segment Routing SRv6\n")
9898 struct listnode
*node
;
9899 struct srv6_locator_chunk
*chunk
;
9900 struct bgp_srv6_function
*func
;
9902 bgp
= bgp_get_default();
9906 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9907 vty_out(vty
, "locator_chunks:\n");
9908 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9909 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9910 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9911 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9912 vty_out(vty
, " func-length: %d\n",
9913 chunk
->function_bits_length
);
9914 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9917 vty_out(vty
, "functions:\n");
9918 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9919 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
9920 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9923 vty_out(vty
, "bgps:\n");
9924 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9925 vty_out(vty
, "- name: %s\n",
9926 bgp
->name
? bgp
->name
: "default");
9928 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9929 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9930 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9931 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9932 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9938 DEFUN_NOSH (exit_address_family
,
9939 exit_address_family_cmd
,
9940 "exit-address-family",
9941 "Exit from Address Family configuration mode\n")
9943 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9944 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9945 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9946 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9947 || vty
->node
== BGP_EVPN_NODE
9948 || vty
->node
== BGP_FLOWSPECV4_NODE
9949 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9950 vty
->node
= BGP_NODE
;
9954 /* Recalculate bestpath and re-advertise a prefix */
9955 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9956 const char *ip_str
, afi_t afi
, safi_t safi
,
9957 struct prefix_rd
*prd
)
9960 struct prefix match
;
9961 struct bgp_dest
*dest
;
9962 struct bgp_dest
*rm
;
9964 struct bgp_table
*table
;
9965 struct bgp_table
*rib
;
9967 /* BGP structure lookup. */
9969 bgp
= bgp_lookup_by_name(view_name
);
9971 vty_out(vty
, "%% Can't find BGP instance %s\n",
9976 bgp
= bgp_get_default();
9978 vty_out(vty
, "%% No BGP process is configured\n");
9983 /* Check IP address argument. */
9984 ret
= str2prefix(ip_str
, &match
);
9986 vty_out(vty
, "%% address is malformed\n");
9990 match
.family
= afi2family(afi
);
9991 rib
= bgp
->rib
[afi
][safi
];
9993 if (safi
== SAFI_MPLS_VPN
) {
9994 for (dest
= bgp_table_top(rib
); dest
;
9995 dest
= bgp_route_next(dest
)) {
9996 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9998 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10001 table
= bgp_dest_get_bgp_table_info(dest
);
10005 rm
= bgp_node_match(table
, &match
);
10007 const struct prefix
*rm_p
=
10008 bgp_dest_get_prefix(rm
);
10010 if (rm_p
->prefixlen
== match
.prefixlen
) {
10011 SET_FLAG(rm
->flags
,
10012 BGP_NODE_USER_CLEAR
);
10013 bgp_process(bgp
, rm
, afi
, safi
);
10015 bgp_dest_unlock_node(rm
);
10019 dest
= bgp_node_match(rib
, &match
);
10020 if (dest
!= NULL
) {
10021 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10023 if (dest_p
->prefixlen
== match
.prefixlen
) {
10024 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10025 bgp_process(bgp
, dest
, afi
, safi
);
10027 bgp_dest_unlock_node(dest
);
10031 return CMD_SUCCESS
;
10034 /* one clear bgp command to rule them all */
10035 DEFUN (clear_ip_bgp_all
,
10036 clear_ip_bgp_all_cmd
,
10037 "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>]",
10041 BGP_INSTANCE_HELP_STR
10044 BGP_SAFI_WITH_LABEL_HELP_STR
10045 BGP_AF_MODIFIER_STR
10046 "Clear all peers\n"
10047 "BGP IPv4 neighbor to clear\n"
10048 "BGP IPv6 neighbor to clear\n"
10049 "BGP neighbor on interface to clear\n"
10050 "Clear peers with the AS number\n"
10051 "Clear all external peers\n"
10052 "Clear all members of peer-group\n"
10053 "BGP peer-group name\n"
10058 "Push out prefix-list ORF and do inbound soft reconfig\n"
10060 "Reset message statistics\n")
10064 afi_t afi
= AFI_UNSPEC
;
10065 safi_t safi
= SAFI_UNSPEC
;
10066 enum clear_sort clr_sort
= clear_peer
;
10067 enum bgp_clear_type clr_type
;
10068 char *clr_arg
= NULL
;
10072 /* clear [ip] bgp */
10073 if (argv_find(argv
, argc
, "ip", &idx
))
10076 /* [<vrf> VIEWVRFNAME] */
10077 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10078 vrf
= argv
[idx
+ 1]->arg
;
10080 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10082 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10083 /* [<view> VIEWVRFNAME] */
10084 vrf
= argv
[idx
+ 1]->arg
;
10087 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10088 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10089 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10091 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10092 if (argv_find(argv
, argc
, "*", &idx
)) {
10093 clr_sort
= clear_all
;
10094 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10095 clr_sort
= clear_peer
;
10096 clr_arg
= argv
[idx
]->arg
;
10097 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10098 clr_sort
= clear_peer
;
10099 clr_arg
= argv
[idx
]->arg
;
10100 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10101 clr_sort
= clear_group
;
10103 clr_arg
= argv
[idx
]->arg
;
10104 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10105 clr_sort
= clear_peer
;
10106 clr_arg
= argv
[idx
]->arg
;
10107 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10108 clr_sort
= clear_peer
;
10109 clr_arg
= argv
[idx
]->arg
;
10110 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10111 clr_sort
= clear_as
;
10112 clr_arg
= argv
[idx
]->arg
;
10113 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10114 clr_sort
= clear_external
;
10117 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10118 if (argv_find(argv
, argc
, "soft", &idx
)) {
10119 if (argv_find(argv
, argc
, "in", &idx
)
10120 || argv_find(argv
, argc
, "out", &idx
))
10121 clr_type
= strmatch(argv
[idx
]->text
, "in")
10122 ? BGP_CLEAR_SOFT_IN
10123 : BGP_CLEAR_SOFT_OUT
;
10125 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10126 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10127 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10128 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10129 : BGP_CLEAR_SOFT_IN
;
10130 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10131 clr_type
= BGP_CLEAR_SOFT_OUT
;
10132 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10133 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10135 clr_type
= BGP_CLEAR_SOFT_NONE
;
10137 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10140 DEFUN (clear_ip_bgp_prefix
,
10141 clear_ip_bgp_prefix_cmd
,
10142 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10146 BGP_INSTANCE_HELP_STR
10147 "Clear bestpath and re-advertise\n"
10151 char *prefix
= NULL
;
10155 /* [<view|vrf> VIEWVRFNAME] */
10156 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10157 vrf
= argv
[idx
+ 1]->arg
;
10159 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10161 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10162 /* [<view> VIEWVRFNAME] */
10163 vrf
= argv
[idx
+ 1]->arg
;
10167 prefix
= argv
[argc
- 1]->arg
;
10169 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10172 DEFUN (clear_bgp_ipv6_safi_prefix
,
10173 clear_bgp_ipv6_safi_prefix_cmd
,
10174 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10180 "Clear bestpath and re-advertise\n"
10184 int idx_ipv6_prefix
= 0;
10185 safi_t safi
= SAFI_UNICAST
;
10186 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10187 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10189 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10190 return bgp_clear_prefix(
10191 vty
, NULL
, prefix
, AFI_IP6
,
10195 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10196 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10197 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10201 BGP_INSTANCE_HELP_STR
10204 "Clear bestpath and re-advertise\n"
10208 int idx_vrfview
= 0;
10209 int idx_ipv6_prefix
= 0;
10210 safi_t safi
= SAFI_UNICAST
;
10211 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10212 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10213 char *vrfview
= NULL
;
10215 /* [<view|vrf> VIEWVRFNAME] */
10216 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10217 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10218 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10220 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10221 /* [<view> VIEWVRFNAME] */
10222 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10224 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10226 return bgp_clear_prefix(
10227 vty
, vrfview
, prefix
,
10228 AFI_IP6
, safi
, NULL
);
10231 DEFUN (show_bgp_views
,
10232 show_bgp_views_cmd
,
10233 "show [ip] bgp views",
10237 "Show the defined BGP views\n")
10239 struct list
*inst
= bm
->bgp
;
10240 struct listnode
*node
;
10243 vty_out(vty
, "Defined BGP views:\n");
10244 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10246 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10248 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10252 return CMD_SUCCESS
;
10255 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10259 struct listnode
*node
;
10261 *peers_cfgd
= *peers_estbd
= 0;
10262 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10263 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10266 if (peer_established(peer
))
10271 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10274 int peers_cfg
, peers_estb
;
10276 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10279 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10281 : (int64_t)bgp
->vrf_id
;
10282 json_object_string_add(json
, "type", type
);
10283 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10284 json_object_string_addf(json
, "routerId", "%pI4",
10286 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10287 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10288 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10289 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10290 json_object_string_add(
10292 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10296 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10297 json_object
*json
, const char *name
,
10298 const char *type
, bool use_vrf
)
10300 int peers_cfg
, peers_estb
;
10302 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10306 print_bgp_vrfs(bgp
, vty
, json
, type
);
10308 vty_out(vty
, "BGP instance %s VRF id %d\n",
10310 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10311 : (int)bgp
->vrf_id
);
10312 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10314 "Num Configured Peers %d, Established %d\n",
10315 peers_cfg
, peers_estb
);
10318 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10320 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10327 print_bgp_vrfs(bgp
, vty
, json
, type
);
10329 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10331 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10332 : (int)bgp
->vrf_id
,
10333 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10334 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10335 bgp
->l3vni
, &bgp
->rmac
,
10336 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10341 return CMD_SUCCESS
;
10344 DEFPY (show_bgp_vrfs
,
10346 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10351 "Specific VRF name\n"
10354 struct list
*inst
= bm
->bgp
;
10355 struct listnode
*node
;
10357 bool uj
= use_json(argc
, argv
);
10358 json_object
*json
= NULL
;
10359 json_object
*json_vrfs
= NULL
;
10360 json_object
*json_vrf
= NULL
;
10362 const char *name
= vrf_name
;
10366 json
= json_object_new_object();
10369 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10370 bgp
= bgp_get_default();
10373 bgp
= bgp_lookup_by_name(name
);
10378 vty_json(vty
, json
);
10381 "%% Specified BGP instance not found\n");
10383 return CMD_WARNING
;
10389 json_vrf
= json_object_new_object();
10391 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10395 json_object_object_add(json
, name
, json_vrf
);
10396 vty_json(vty
, json
);
10399 return CMD_SUCCESS
;
10403 json_vrfs
= json_object_new_object();
10405 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10409 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10413 if (!uj
&& count
== 1) {
10415 "%4s %-5s %-16s %9s %10s %-37s\n",
10416 "Type", "Id", "routerId", "#PeersCfg",
10417 "#PeersEstb", "Name");
10418 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10419 "L3-VNI", "RouterMAC", "Interface");
10422 json_vrf
= json_object_new_object();
10424 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10425 name
= VRF_DEFAULT_NAME
;
10432 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10436 json_object_object_add(json_vrfs
, name
, json_vrf
);
10440 json_object_object_add(json
, "vrfs", json_vrfs
);
10441 json_object_int_add(json
, "totalVrfs", count
);
10442 vty_json(vty
, json
);
10446 "\nTotal number of VRFs (including default): %d\n",
10450 return CMD_SUCCESS
;
10453 DEFUN (show_bgp_mac_hash
,
10454 show_bgp_mac_hash_cmd
,
10455 "show bgp mac hash",
10459 "Mac Address database\n")
10461 bgp_mac_dump_table(vty
);
10463 return CMD_SUCCESS
;
10466 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10468 struct vty
*vty
= (struct vty
*)args
;
10469 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10471 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10474 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10476 vty_out(vty
, "self nexthop database:\n");
10477 bgp_nexthop_show_address_hash(vty
, bgp
);
10479 vty_out(vty
, "Tunnel-ip database:\n");
10480 hash_iterate(bgp
->tip_hash
,
10481 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10485 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10486 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10487 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10488 "martian next-hops\n"
10489 "martian next-hop database\n")
10491 struct bgp
*bgp
= NULL
;
10495 /* [<vrf> VIEWVRFNAME] */
10496 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10497 name
= argv
[idx
+ 1]->arg
;
10498 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10500 } else if (argv_find(argv
, argc
, "view", &idx
))
10501 /* [<view> VIEWVRFNAME] */
10502 name
= argv
[idx
+ 1]->arg
;
10504 bgp
= bgp_lookup_by_name(name
);
10506 bgp
= bgp_get_default();
10509 vty_out(vty
, "%% No BGP process is configured\n");
10510 return CMD_WARNING
;
10512 bgp_show_martian_nexthops(vty
, bgp
);
10514 return CMD_SUCCESS
;
10517 DEFUN (show_bgp_memory
,
10518 show_bgp_memory_cmd
,
10519 "show [ip] bgp memory",
10523 "Global BGP memory statistics\n")
10525 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10526 unsigned long count
;
10528 /* RIB related usage stats */
10529 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10530 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10531 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10532 count
* sizeof(struct bgp_dest
)));
10534 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10535 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10536 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10537 count
* sizeof(struct bgp_path_info
)));
10538 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10539 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10542 memstrbuf
, sizeof(memstrbuf
),
10543 count
* sizeof(struct bgp_path_info_extra
)));
10545 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10546 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10547 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10548 count
* sizeof(struct bgp_static
)));
10550 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10551 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10552 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10553 count
* sizeof(struct bpacket
)));
10556 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10557 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10558 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10559 count
* sizeof(struct bgp_adj_in
)));
10560 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10561 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10562 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10563 count
* sizeof(struct bgp_adj_out
)));
10565 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10566 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10568 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10569 count
* sizeof(struct bgp_nexthop_cache
)));
10571 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10572 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10574 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10575 count
* sizeof(struct bgp_damp_info
)));
10578 count
= attr_count();
10579 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10580 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10581 count
* sizeof(struct attr
)));
10583 if ((count
= attr_unknown_count()))
10584 vty_out(vty
, "%ld unknown attributes\n", count
);
10586 /* AS_PATH attributes */
10587 count
= aspath_count();
10588 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10589 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10590 count
* sizeof(struct aspath
)));
10592 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10593 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10594 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10595 count
* sizeof(struct assegment
)));
10597 /* Other attributes */
10598 if ((count
= community_count()))
10599 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10600 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10601 count
* sizeof(struct community
)));
10602 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10604 "%ld BGP ext-community entries, using %s of memory\n",
10606 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10607 count
* sizeof(struct ecommunity
)));
10608 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10610 "%ld BGP large-community entries, using %s of memory\n",
10611 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10612 count
* sizeof(struct lcommunity
)));
10614 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10615 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10616 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10617 count
* sizeof(struct cluster_list
)));
10619 /* Peer related usage */
10620 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10621 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10622 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10623 count
* sizeof(struct peer
)));
10625 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10626 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10627 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10628 count
* sizeof(struct peer_group
)));
10631 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10632 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10633 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10634 count
* sizeof(regex_t
)));
10635 return CMD_SUCCESS
;
10638 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10640 json_object
*bestpath
= json_object_new_object();
10642 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10643 json_object_string_add(bestpath
, "asPath", "ignore");
10645 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10646 json_object_string_add(bestpath
, "asPath", "confed");
10648 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10649 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10650 json_object_string_add(bestpath
, "multiPathRelax",
10653 json_object_string_add(bestpath
, "multiPathRelax",
10656 json_object_string_add(bestpath
, "multiPathRelax", "false");
10658 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10659 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10661 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10662 json_object_string_add(bestpath
, "compareRouterId", "true");
10663 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10664 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10665 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10666 json_object_string_add(bestpath
, "med", "confed");
10667 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10668 json_object_string_add(bestpath
, "med",
10669 "missing-as-worst");
10671 json_object_string_add(bestpath
, "med", "true");
10674 json_object_object_add(json
, "bestPath", bestpath
);
10677 /* Print the error code/subcode for why the peer is down */
10678 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10679 json_object
*json_peer
, bool use_json
)
10681 const char *code_str
;
10682 const char *subcode_str
;
10685 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10686 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10687 char errorcodesubcode_hexstr
[5];
10688 char errorcodesubcode_str
[256];
10690 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10691 subcode_str
= bgp_notify_subcode_str(
10693 peer
->notify
.subcode
);
10695 snprintf(errorcodesubcode_hexstr
,
10696 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10697 peer
->notify
.code
, peer
->notify
.subcode
);
10698 json_object_string_add(json_peer
,
10699 "lastErrorCodeSubcode",
10700 errorcodesubcode_hexstr
);
10701 snprintf(errorcodesubcode_str
, 255, "%s%s",
10702 code_str
, subcode_str
);
10703 json_object_string_add(json_peer
,
10704 "lastNotificationReason",
10705 errorcodesubcode_str
);
10706 json_object_boolean_add(json_peer
,
10707 "lastNotificationHardReset",
10708 peer
->notify
.hard_reset
);
10709 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10710 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10711 && (peer
->notify
.subcode
10712 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10713 || peer
->notify
.subcode
10714 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10715 && peer
->notify
.length
) {
10717 const char *msg_str
;
10719 msg_str
= bgp_notify_admin_message(
10720 msgbuf
, sizeof(msgbuf
),
10721 (uint8_t *)peer
->notify
.data
,
10722 peer
->notify
.length
);
10724 json_object_string_add(
10726 "lastShutdownDescription",
10731 json_object_string_add(json_peer
, "lastResetDueTo",
10732 peer_down_str
[(int)peer
->last_reset
]);
10733 json_object_int_add(json_peer
, "lastResetCode",
10736 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10737 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10738 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10740 bgp_notify_subcode_str(peer
->notify
.code
,
10741 peer
->notify
.subcode
);
10742 vty_out(vty
, " Notification %s (%s%s%s)\n",
10743 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10746 code_str
, subcode_str
,
10747 peer
->notify
.hard_reset
10748 ? bgp_notify_subcode_str(
10750 BGP_NOTIFY_CEASE_HARD_RESET
)
10753 vty_out(vty
, " %s\n",
10754 peer_down_str
[(int)peer
->last_reset
]);
10759 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10762 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10765 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10766 struct peer
*peer
, json_object
*json_peer
,
10767 int max_neighbor_width
, bool use_json
)
10769 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10773 if (peer_dynamic_neighbor(peer
))
10774 json_object_boolean_true_add(json_peer
,
10776 if (peer
->hostname
)
10777 json_object_string_add(json_peer
, "hostname",
10780 if (peer
->domainname
)
10781 json_object_string_add(json_peer
, "domainname",
10783 json_object_int_add(json_peer
, "connectionsEstablished",
10784 peer
->established
);
10785 json_object_int_add(json_peer
, "connectionsDropped",
10787 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10788 use_json
, json_peer
);
10789 if (peer_established(peer
))
10790 json_object_string_add(json_peer
, "lastResetDueTo",
10791 "AFI/SAFI Not Negotiated");
10793 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10796 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10798 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10799 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10800 peer
->hostname
, peer
->host
);
10802 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10804 /* pad the neighbor column with spaces */
10805 if (len
< max_neighbor_width
)
10806 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10808 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10810 peer_uptime(peer
->uptime
, timebuf
,
10811 BGP_UPTIME_LEN
, 0, NULL
));
10812 if (peer_established(peer
))
10813 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10815 bgp_show_peer_reset(vty
, peer
, NULL
,
10820 /* Strip peer's description to the given size. */
10821 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10823 static char stripped
[BUFSIZ
];
10825 uint32_t last_space
= 0;
10828 if (*(desc
+ i
) == 0) {
10829 stripped
[i
] = '\0';
10832 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10834 stripped
[i
] = *(desc
+ i
);
10838 if (last_space
> size
)
10839 stripped
[size
+ 1] = '\0';
10841 stripped
[last_space
] = '\0';
10846 /* Determine whether var peer should be filtered out of the summary. */
10847 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10848 struct peer
*fpeer
, int as_type
,
10852 /* filter neighbor XXXX */
10853 if (fpeer
&& fpeer
!= peer
)
10856 /* filter remote-as (internal|external) */
10857 if (as_type
!= AS_UNSPECIFIED
) {
10858 if (peer
->as_type
== AS_SPECIFIED
) {
10859 if (as_type
== AS_INTERNAL
) {
10860 if (peer
->as
!= peer
->local_as
)
10862 } else if (peer
->as
== peer
->local_as
)
10864 } else if (as_type
!= peer
->as_type
)
10866 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10872 /* Show BGP peer's summary information.
10874 * Peer's description is stripped according to if `wide` option is given
10877 * When adding new columns to `show bgp summary` output, please make
10878 * sure `Desc` is the lastest column to show because it can contain
10879 * whitespaces and the whole output will be tricky.
10881 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10882 struct peer
*fpeer
, int as_type
, as_t as
,
10883 uint16_t show_flags
)
10886 struct listnode
*node
, *nnode
;
10887 unsigned int count
= 0, dn_count
= 0;
10888 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10889 char neighbor_buf
[VTY_BUFSIZ
];
10890 int neighbor_col_default_width
= 16;
10891 int len
, failed_count
= 0;
10892 unsigned int filtered_count
= 0;
10893 int max_neighbor_width
= 0;
10895 json_object
*json
= NULL
;
10896 json_object
*json_peer
= NULL
;
10897 json_object
*json_peers
= NULL
;
10898 struct peer_af
*paf
;
10899 struct bgp_filter
*filter
;
10900 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10901 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10902 bool show_established
=
10903 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10904 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10905 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10907 /* labeled-unicast routes are installed in the unicast table so in order
10909 * display the correct PfxRcd value we must look at SAFI_UNICAST
10912 if (safi
== SAFI_LABELED_UNICAST
)
10913 pfx_rcd_safi
= SAFI_UNICAST
;
10915 pfx_rcd_safi
= safi
;
10918 json
= json_object_new_object();
10919 json_peers
= json_object_new_object();
10920 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10921 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10928 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10931 if (peer
->afc
[afi
][safi
]) {
10932 /* See if we have at least a single failed peer */
10933 if (bgp_has_peer_failed(peer
, afi
, safi
))
10937 if (peer_dynamic_neighbor(peer
))
10942 /* Loop over all neighbors that will be displayed to determine
10944 * characters are needed for the Neighbor column
10946 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10947 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10954 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10957 if (peer
->afc
[afi
][safi
]) {
10958 memset(dn_flag
, '\0', sizeof(dn_flag
));
10959 if (peer_dynamic_neighbor(peer
))
10963 && CHECK_FLAG(bgp
->flags
,
10964 BGP_FLAG_SHOW_HOSTNAME
))
10965 snprintf(neighbor_buf
,
10966 sizeof(neighbor_buf
),
10967 "%s%s(%s) ", dn_flag
,
10968 peer
->hostname
, peer
->host
);
10970 snprintf(neighbor_buf
,
10971 sizeof(neighbor_buf
), "%s%s ",
10972 dn_flag
, peer
->host
);
10974 len
= strlen(neighbor_buf
);
10976 if (len
> max_neighbor_width
)
10977 max_neighbor_width
= len
;
10979 /* See if we have at least a single failed peer */
10980 if (bgp_has_peer_failed(peer
, afi
, safi
))
10986 /* Originally we displayed the Neighbor column as 16
10987 * characters wide so make that the default
10989 if (max_neighbor_width
< neighbor_col_default_width
)
10990 max_neighbor_width
= neighbor_col_default_width
;
10993 if (show_failed
&& !failed_count
) {
10995 json_object_int_add(json
, "failedPeersCount", 0);
10996 json_object_int_add(json
, "dynamicPeers", dn_count
);
10997 json_object_int_add(json
, "totalPeers", count
);
10999 vty_json(vty
, json
);
11001 vty_out(vty
, "%% No failed BGP neighbors found\n");
11003 return CMD_SUCCESS
;
11006 count
= 0; /* Reset the value as its used again */
11007 filtered_count
= 0;
11009 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11010 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11013 if (!peer
->afc
[afi
][safi
])
11017 unsigned long ents
;
11018 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11021 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11023 : (int64_t)bgp
->vrf_id
;
11025 /* Usage summary and header */
11027 json_object_string_addf(json
, "routerId",
11030 json_object_int_add(json
, "as", bgp
->as
);
11031 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11032 json_object_string_add(
11035 == BGP_INSTANCE_TYPE_DEFAULT
)
11040 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11041 &bgp
->router_id
, bgp
->as
,
11042 bgp
->vrf_id
== VRF_UNKNOWN
11044 : (int)bgp
->vrf_id
);
11045 vty_out(vty
, "\n");
11048 if (bgp_update_delay_configured(bgp
)) {
11050 json_object_int_add(
11051 json
, "updateDelayLimit",
11052 bgp
->v_update_delay
);
11054 if (bgp
->v_update_delay
11055 != bgp
->v_establish_wait
)
11056 json_object_int_add(
11058 "updateDelayEstablishWait",
11059 bgp
->v_establish_wait
);
11061 if (bgp_update_delay_active(bgp
)) {
11062 json_object_string_add(
11064 "updateDelayFirstNeighbor",
11065 bgp
->update_delay_begin_time
);
11066 json_object_boolean_true_add(
11068 "updateDelayInProgress");
11070 if (bgp
->update_delay_over
) {
11071 json_object_string_add(
11073 "updateDelayFirstNeighbor",
11074 bgp
->update_delay_begin_time
);
11075 json_object_string_add(
11077 "updateDelayBestpathResumed",
11078 bgp
->update_delay_end_time
);
11079 json_object_string_add(
11081 "updateDelayZebraUpdateResume",
11082 bgp
->update_delay_zebra_resume_time
);
11083 json_object_string_add(
11085 "updateDelayPeerUpdateResume",
11086 bgp
->update_delay_peers_resume_time
);
11091 "Read-only mode update-delay limit: %d seconds\n",
11092 bgp
->v_update_delay
);
11093 if (bgp
->v_update_delay
11094 != bgp
->v_establish_wait
)
11096 " Establish wait: %d seconds\n",
11097 bgp
->v_establish_wait
);
11099 if (bgp_update_delay_active(bgp
)) {
11101 " First neighbor established: %s\n",
11102 bgp
->update_delay_begin_time
);
11104 " Delay in progress\n");
11106 if (bgp
->update_delay_over
) {
11108 " First neighbor established: %s\n",
11109 bgp
->update_delay_begin_time
);
11111 " Best-paths resumed: %s\n",
11112 bgp
->update_delay_end_time
);
11114 " zebra update resumed: %s\n",
11115 bgp
->update_delay_zebra_resume_time
);
11117 " peers update resumed: %s\n",
11118 bgp
->update_delay_peers_resume_time
);
11125 if (bgp_maxmed_onstartup_configured(bgp
)
11126 && bgp
->maxmed_active
)
11127 json_object_boolean_true_add(
11128 json
, "maxMedOnStartup");
11129 if (bgp
->v_maxmed_admin
)
11130 json_object_boolean_true_add(
11131 json
, "maxMedAdministrative");
11133 json_object_int_add(
11134 json
, "tableVersion",
11135 bgp_table_version(bgp
->rib
[afi
][safi
]));
11137 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11138 json_object_int_add(json
, "ribCount", ents
);
11139 json_object_int_add(
11141 ents
* sizeof(struct bgp_dest
));
11143 ents
= bgp
->af_peer_count
[afi
][safi
];
11144 json_object_int_add(json
, "peerCount", ents
);
11145 json_object_int_add(json
, "peerMemory",
11146 ents
* sizeof(struct peer
));
11148 if ((ents
= listcount(bgp
->group
))) {
11149 json_object_int_add(
11150 json
, "peerGroupCount", ents
);
11151 json_object_int_add(
11152 json
, "peerGroupMemory",
11153 ents
* sizeof(struct
11157 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11158 BGP_CONFIG_DAMPENING
))
11159 json_object_boolean_true_add(
11160 json
, "dampeningEnabled");
11163 if (bgp_maxmed_onstartup_configured(bgp
)
11164 && bgp
->maxmed_active
)
11166 "Max-med on-startup active\n");
11167 if (bgp
->v_maxmed_admin
)
11169 "Max-med administrative active\n");
11172 "BGP table version %" PRIu64
11175 bgp
->rib
[afi
][safi
]));
11177 ents
= bgp_table_count(
11178 bgp
->rib
[afi
][safi
]);
11180 "RIB entries %ld, using %s of memory\n",
11190 /* Peer related usage */
11191 ents
= bgp
->af_peer_count
[afi
][safi
];
11193 "Peers %ld, using %s of memory\n",
11203 if ((ents
= listcount(bgp
->group
)))
11205 "Peer groups %ld, using %s of memory\n",
11215 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11216 BGP_CONFIG_DAMPENING
))
11218 "Dampening enabled.\n");
11221 vty_out(vty
, "\n");
11223 /* Subtract 8 here because 'Neighbor' is
11225 vty_out(vty
, "Neighbor");
11226 vty_out(vty
, "%*s",
11227 max_neighbor_width
- 8, " ");
11229 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11234 paf
= peer_af_find(peer
, afi
, safi
);
11235 filter
= &peer
->filter
[afi
][safi
];
11238 /* Works for both failed & successful cases */
11239 if (peer_dynamic_neighbor(peer
))
11244 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11250 bgp_has_peer_failed(peer
, afi
, safi
)) {
11251 json_peer
= json_object_new_object();
11252 bgp_show_failed_summary(vty
, bgp
, peer
,
11253 json_peer
, 0, use_json
);
11254 } else if (!show_failed
) {
11255 if (show_established
11256 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11261 json_peer
= json_object_new_object();
11262 if (peer_dynamic_neighbor(peer
)) {
11263 json_object_boolean_true_add(json_peer
,
11267 if (peer
->hostname
)
11268 json_object_string_add(json_peer
, "hostname",
11271 if (peer
->domainname
)
11272 json_object_string_add(json_peer
, "domainname",
11275 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11276 json_object_int_add(
11277 json_peer
, "localAs",
11278 peer
->change_local_as
11279 ? peer
->change_local_as
11281 json_object_int_add(json_peer
, "version", 4);
11282 json_object_int_add(json_peer
, "msgRcvd",
11283 PEER_TOTAL_RX(peer
));
11284 json_object_int_add(json_peer
, "msgSent",
11285 PEER_TOTAL_TX(peer
));
11287 atomic_size_t outq_count
, inq_count
;
11288 outq_count
= atomic_load_explicit(
11289 &peer
->obuf
->count
,
11290 memory_order_relaxed
);
11291 inq_count
= atomic_load_explicit(
11292 &peer
->ibuf
->count
,
11293 memory_order_relaxed
);
11295 json_object_int_add(json_peer
, "tableVersion",
11296 peer
->version
[afi
][safi
]);
11297 json_object_int_add(json_peer
, "outq",
11299 json_object_int_add(json_peer
, "inq",
11301 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11302 use_json
, json_peer
);
11304 json_object_int_add(json_peer
, "pfxRcd",
11305 peer
->pcount
[afi
][pfx_rcd_safi
]);
11307 if (paf
&& PAF_SUBGRP(paf
))
11308 json_object_int_add(
11309 json_peer
, "pfxSnt",
11310 (PAF_SUBGRP(paf
))->scount
);
11312 json_object_int_add(json_peer
, "pfxSnt",
11315 /* BGP FSM state */
11316 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11317 || CHECK_FLAG(peer
->bgp
->flags
,
11318 BGP_FLAG_SHUTDOWN
))
11319 json_object_string_add(json_peer
,
11322 else if (peer
->afc_recv
[afi
][safi
])
11323 json_object_string_add(
11324 json_peer
, "state",
11325 lookup_msg(bgp_status_msg
,
11326 peer
->status
, NULL
));
11327 else if (CHECK_FLAG(
11329 PEER_STATUS_PREFIX_OVERFLOW
))
11330 json_object_string_add(json_peer
,
11334 json_object_string_add(
11335 json_peer
, "state",
11336 lookup_msg(bgp_status_msg
,
11337 peer
->status
, NULL
));
11339 /* BGP peer state */
11340 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11341 || CHECK_FLAG(peer
->bgp
->flags
,
11342 BGP_FLAG_SHUTDOWN
))
11343 json_object_string_add(json_peer
,
11346 else if (CHECK_FLAG(
11348 PEER_STATUS_PREFIX_OVERFLOW
))
11349 json_object_string_add(json_peer
,
11352 else if (CHECK_FLAG(peer
->flags
,
11353 PEER_FLAG_PASSIVE
))
11354 json_object_string_add(json_peer
,
11357 else if (CHECK_FLAG(peer
->sflags
,
11358 PEER_STATUS_NSF_WAIT
))
11359 json_object_string_add(json_peer
,
11362 else if (CHECK_FLAG(
11364 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11365 && (!bgp_inbound_policy_exists(peer
,
11367 || !bgp_outbound_policy_exists(
11369 json_object_string_add(json_peer
,
11373 json_object_string_add(
11374 json_peer
, "peerState", "OK");
11376 json_object_int_add(json_peer
, "connectionsEstablished",
11377 peer
->established
);
11378 json_object_int_add(json_peer
, "connectionsDropped",
11381 json_object_string_add(
11382 json_peer
, "desc", peer
->desc
);
11384 /* Avoid creating empty peer dicts in JSON */
11385 if (json_peer
== NULL
)
11389 json_object_string_add(json_peer
, "idType",
11391 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11392 json_object_string_add(json_peer
, "idType",
11394 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11395 json_object_string_add(json_peer
, "idType",
11397 json_object_object_add(json_peers
, peer
->host
,
11400 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11406 bgp_has_peer_failed(peer
, afi
, safi
)) {
11407 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11408 max_neighbor_width
,
11410 } else if (!show_failed
) {
11411 if (show_established
11412 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11417 if ((count
- filtered_count
) == 1) {
11418 /* display headline before the first
11420 vty_out(vty
, "\n");
11422 /* Subtract 8 here because 'Neighbor' is
11424 vty_out(vty
, "Neighbor");
11425 vty_out(vty
, "%*s",
11426 max_neighbor_width
- 8, " ");
11429 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11430 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11433 memset(dn_flag
, '\0', sizeof(dn_flag
));
11434 if (peer_dynamic_neighbor(peer
)) {
11439 && CHECK_FLAG(bgp
->flags
,
11440 BGP_FLAG_SHOW_HOSTNAME
))
11441 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11445 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11447 /* pad the neighbor column with spaces */
11448 if (len
< max_neighbor_width
)
11449 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11452 atomic_size_t outq_count
, inq_count
;
11453 outq_count
= atomic_load_explicit(
11454 &peer
->obuf
->count
,
11455 memory_order_relaxed
);
11456 inq_count
= atomic_load_explicit(
11457 &peer
->ibuf
->count
,
11458 memory_order_relaxed
);
11462 "4 %10u %10u %9u %9u %8" PRIu64
11465 peer
->change_local_as
11466 ? peer
->change_local_as
11468 PEER_TOTAL_RX(peer
),
11469 PEER_TOTAL_TX(peer
),
11470 peer
->version
[afi
][safi
],
11471 inq_count
, outq_count
,
11472 peer_uptime(peer
->uptime
,
11477 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11479 peer
->as
, PEER_TOTAL_RX(peer
),
11480 PEER_TOTAL_TX(peer
),
11481 peer
->version
[afi
][safi
],
11482 inq_count
, outq_count
,
11483 peer_uptime(peer
->uptime
,
11488 if (peer_established(peer
)) {
11489 if (peer
->afc_recv
[afi
][safi
]) {
11492 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11493 && !bgp_inbound_policy_exists(
11495 vty_out(vty
, " %12s",
11504 vty_out(vty
, " NoNeg");
11507 if (paf
&& PAF_SUBGRP(paf
)) {
11510 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11511 && !bgp_outbound_policy_exists(
11513 vty_out(vty
, " %8s",
11522 vty_out(vty
, " NoNeg");
11525 if (CHECK_FLAG(peer
->flags
,
11526 PEER_FLAG_SHUTDOWN
)
11527 || CHECK_FLAG(peer
->bgp
->flags
,
11528 BGP_FLAG_SHUTDOWN
))
11529 vty_out(vty
, " Idle (Admin)");
11530 else if (CHECK_FLAG(
11532 PEER_STATUS_PREFIX_OVERFLOW
))
11533 vty_out(vty
, " Idle (PfxCt)");
11535 vty_out(vty
, " %12s",
11536 lookup_msg(bgp_status_msg
,
11537 peer
->status
, NULL
));
11539 vty_out(vty
, " %8u", 0);
11541 /* Make sure `Desc` column is the lastest in
11545 vty_out(vty
, " %s",
11546 bgp_peer_description_stripped(
11548 show_wide
? 64 : 20));
11550 vty_out(vty
, " N/A");
11551 vty_out(vty
, "\n");
11558 json_object_object_add(json
, "peers", json_peers
);
11559 json_object_int_add(json
, "failedPeers", failed_count
);
11560 json_object_int_add(json
, "displayedPeers",
11561 count
- filtered_count
);
11562 json_object_int_add(json
, "totalPeers", count
);
11563 json_object_int_add(json
, "dynamicPeers", dn_count
);
11566 bgp_show_bestpath_json(bgp
, json
);
11568 vty_json(vty
, json
);
11571 if (filtered_count
== count
)
11572 vty_out(vty
, "\n%% No matching neighbor\n");
11575 vty_out(vty
, "\nDisplayed neighbors %d",
11577 else if (as_type
!= AS_UNSPECIFIED
|| as
11578 || fpeer
|| show_established
)
11579 vty_out(vty
, "\nDisplayed neighbors %d",
11580 count
- filtered_count
);
11582 vty_out(vty
, "\nTotal number of neighbors %d\n",
11586 vty_out(vty
, "No %s neighbor is configured\n",
11587 get_afi_safi_str(afi
, safi
, false));
11591 vty_out(vty
, "* - dynamic neighbor\n");
11592 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11593 dn_count
, bgp
->dynamic_neighbors_limit
);
11597 return CMD_SUCCESS
;
11600 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11601 int safi
, struct peer
*fpeer
, int as_type
,
11602 as_t as
, uint16_t show_flags
)
11605 int afi_wildcard
= (afi
== AFI_MAX
);
11606 int safi_wildcard
= (safi
== SAFI_MAX
);
11607 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11608 bool nbr_output
= false;
11609 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11611 if (use_json
&& is_wildcard
)
11612 vty_out(vty
, "{\n");
11614 afi
= 1; /* AFI_IP */
11615 while (afi
< AFI_MAX
) {
11617 safi
= 1; /* SAFI_UNICAST */
11618 while (safi
< SAFI_MAX
) {
11619 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11624 * So limit output to those afi/safi
11626 * actualy have something interesting in
11631 vty_out(vty
, ",\n");
11635 vty_out(vty
, "\"%s\":",
11636 get_afi_safi_str(afi
,
11641 "\n%s Summary (%s):\n",
11642 get_afi_safi_str(afi
,
11648 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11649 as_type
, as
, show_flags
);
11652 if (!safi_wildcard
)
11660 if (use_json
&& is_wildcard
)
11661 vty_out(vty
, "}\n");
11662 else if (!nbr_output
) {
11664 vty_out(vty
, "{}\n");
11666 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11671 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11673 const char *neighbor
,
11674 int as_type
, as_t as
,
11675 uint16_t show_flags
)
11677 struct listnode
*node
, *nnode
;
11679 struct peer
*fpeer
= NULL
;
11681 bool nbr_output
= false;
11682 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11685 vty_out(vty
, "{\n");
11687 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11691 vty_out(vty
, ",\n");
11695 vty_out(vty
, "\"%s\":",
11696 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11701 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11706 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11711 vty_out(vty
, "}\n");
11712 else if (!nbr_output
)
11713 vty_out(vty
, "%% BGP instance not found\n");
11716 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11717 safi_t safi
, const char *neighbor
, int as_type
,
11718 as_t as
, uint16_t show_flags
)
11721 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11722 struct peer
*fpeer
= NULL
;
11725 if (strmatch(name
, "all")) {
11726 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11729 return CMD_SUCCESS
;
11731 bgp
= bgp_lookup_by_name(name
);
11735 vty_out(vty
, "{}\n");
11738 "%% BGP instance not found\n");
11739 return CMD_WARNING
;
11743 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11746 return CMD_WARNING
;
11748 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11749 as_type
, as
, show_flags
);
11750 return CMD_SUCCESS
;
11754 bgp
= bgp_get_default();
11758 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11761 return CMD_WARNING
;
11763 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11767 vty_out(vty
, "{}\n");
11769 vty_out(vty
, "%% BGP instance not found\n");
11770 return CMD_WARNING
;
11773 return CMD_SUCCESS
;
11776 /* `show [ip] bgp summary' commands. */
11777 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11778 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11779 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11780 "]] [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]",
11781 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11782 BGP_SAFI_WITH_LABEL_HELP_STR
11783 "Display the entries for all address families\n"
11784 "Summary of BGP neighbor status\n"
11785 "Show only sessions in Established state\n"
11786 "Show only sessions not in Established state\n"
11787 "Show only the specified neighbor session\n"
11788 "Neighbor to display information about\n"
11789 "Neighbor to display information about\n"
11790 "Neighbor on BGP configured interface\n"
11791 "Show only the specified remote AS sessions\n"
11793 "Internal (iBGP) AS sessions\n"
11794 "External (eBGP) AS sessions\n"
11795 "Shorten the information on BGP instances\n"
11796 "Increase table width for longer output\n" JSON_STR
)
11799 afi_t afi
= AFI_MAX
;
11800 safi_t safi
= SAFI_MAX
;
11801 as_t as
= 0; /* 0 means AS filter not set */
11802 int as_type
= AS_UNSPECIFIED
;
11803 uint16_t show_flags
= 0;
11807 /* show [ip] bgp */
11808 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11810 /* [<vrf> VIEWVRFNAME] */
11811 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11812 vrf
= argv
[idx
+ 1]->arg
;
11813 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11815 } else if (argv_find(argv
, argc
, "view", &idx
))
11816 /* [<view> VIEWVRFNAME] */
11817 vrf
= argv
[idx
+ 1]->arg
;
11818 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11819 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11820 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11823 if (argv_find(argv
, argc
, "failed", &idx
))
11824 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11826 if (argv_find(argv
, argc
, "established", &idx
))
11827 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11829 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11830 if (argv
[idx
+ 1]->arg
[0] == 'i')
11831 as_type
= AS_INTERNAL
;
11832 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11833 as_type
= AS_EXTERNAL
;
11835 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11838 if (argv_find(argv
, argc
, "terse", &idx
))
11839 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11841 if (argv_find(argv
, argc
, "wide", &idx
))
11842 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11844 if (argv_find(argv
, argc
, "json", &idx
))
11845 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11847 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11851 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11854 return get_afi_safi_json_str(afi
, safi
);
11856 return get_afi_safi_vty_str(afi
, safi
);
11860 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11861 afi_t afi
, safi_t safi
,
11862 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11863 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11864 bool use_json
, json_object
*json_pref
)
11867 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11868 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11870 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11871 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11872 json_object_string_add(json_pref
, "sendMode",
11873 "advertisedAndReceived");
11874 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11875 json_object_string_add(json_pref
, "sendMode",
11877 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11878 json_object_string_add(json_pref
, "sendMode",
11881 vty_out(vty
, " Send-mode: ");
11882 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11883 vty_out(vty
, "advertised");
11884 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11885 vty_out(vty
, "%sreceived",
11886 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11890 vty_out(vty
, "\n");
11895 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11896 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11898 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11899 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11900 json_object_string_add(json_pref
, "recvMode",
11901 "advertisedAndReceived");
11902 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11903 json_object_string_add(json_pref
, "recvMode",
11905 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11906 json_object_string_add(json_pref
, "recvMode",
11909 vty_out(vty
, " Receive-mode: ");
11910 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11911 vty_out(vty
, "advertised");
11912 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11913 vty_out(vty
, "%sreceived",
11914 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11918 vty_out(vty
, "\n");
11923 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11930 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11931 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11932 && (peer_established(p
))) {
11933 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11934 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11938 json_object_boolean_add(json
, "rBit", rbit
);
11939 json_object_boolean_add(json
, "nBit", nbit
);
11941 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11942 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11946 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11950 const char *mode
= "NotApplicable";
11953 vty_out(vty
, "\n Remote GR Mode: ");
11955 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11956 && (peer_established(peer
))) {
11958 if ((peer
->nsf_af_count
== 0)
11959 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11963 } else if (peer
->nsf_af_count
== 0
11964 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11968 } else if (peer
->nsf_af_count
!= 0
11969 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11976 json_object_string_add(json
, "remoteGrMode", mode
);
11978 vty_out(vty
, mode
, "\n");
11981 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11985 const char *mode
= "Invalid";
11988 vty_out(vty
, " Local GR Mode: ");
11990 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11992 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11994 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11996 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11997 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11999 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12001 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12008 json_object_string_add(json
, "localGrMode", mode
);
12010 vty_out(vty
, mode
, "\n");
12013 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12014 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12018 json_object
*json_afi_safi
= NULL
;
12019 json_object
*json_timer
= NULL
;
12020 json_object
*json_endofrib_status
= NULL
;
12021 bool eor_flag
= false;
12023 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12024 if (!peer
->afc
[afi
][safi
])
12027 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12028 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12032 json_afi_safi
= json_object_new_object();
12033 json_endofrib_status
= json_object_new_object();
12034 json_timer
= json_object_new_object();
12037 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12043 vty_out(vty
, " %s:\n",
12044 get_afi_safi_str(afi
, safi
, false));
12046 vty_out(vty
, " F bit: ");
12049 if (peer
->nsf
[afi
][safi
] &&
12050 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12051 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12054 json_object_boolean_true_add(json_afi_safi
,
12057 vty_out(vty
, "True\n");
12060 json_object_boolean_false_add(json_afi_safi
,
12063 vty_out(vty
, "False\n");
12067 vty_out(vty
, " End-of-RIB sent: ");
12069 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12070 PEER_STATUS_EOR_SEND
)) {
12072 json_object_boolean_true_add(
12073 json_endofrib_status
, "endOfRibSend");
12075 PRINT_EOR_JSON(eor_flag
);
12077 vty_out(vty
, "Yes\n");
12079 " End-of-RIB sent after update: ");
12081 PRINT_EOR(eor_flag
);
12085 json_object_boolean_false_add(
12086 json_endofrib_status
, "endOfRibSend");
12087 json_object_boolean_false_add(
12088 json_endofrib_status
,
12089 "endOfRibSentAfterUpdate");
12091 vty_out(vty
, "No\n");
12093 " End-of-RIB sent after update: ");
12094 vty_out(vty
, "No\n");
12099 vty_out(vty
, " End-of-RIB received: ");
12101 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12102 PEER_STATUS_EOR_RECEIVED
)) {
12104 json_object_boolean_true_add(
12105 json_endofrib_status
, "endOfRibRecv");
12107 vty_out(vty
, "Yes\n");
12110 json_object_boolean_false_add(
12111 json_endofrib_status
, "endOfRibRecv");
12113 vty_out(vty
, "No\n");
12117 json_object_int_add(json_timer
, "stalePathTimer",
12118 peer
->bgp
->stalepath_time
);
12120 if (peer
->t_gr_stale
!= NULL
) {
12121 json_object_int_add(json_timer
,
12122 "stalePathTimerRemaining",
12123 thread_timer_remain_second(
12124 peer
->t_gr_stale
));
12127 /* Display Configured Selection
12128 * Deferral only when when
12129 * Gr mode is enabled.
12131 if (CHECK_FLAG(peer
->flags
,
12132 PEER_FLAG_GRACEFUL_RESTART
)) {
12133 json_object_int_add(json_timer
,
12134 "selectionDeferralTimer",
12135 peer
->bgp
->stalepath_time
);
12138 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12141 json_object_int_add(
12143 "selectionDeferralTimerRemaining",
12144 thread_timer_remain_second(
12145 peer
->bgp
->gr_info
[afi
][safi
]
12146 .t_select_deferral
));
12149 vty_out(vty
, " Timers:\n");
12151 " Configured Stale Path Time(sec): %u\n",
12152 peer
->bgp
->stalepath_time
);
12154 if (peer
->t_gr_stale
!= NULL
)
12156 " Stale Path Remaining(sec): %ld\n",
12157 thread_timer_remain_second(
12158 peer
->t_gr_stale
));
12159 /* Display Configured Selection
12160 * Deferral only when when
12161 * Gr mode is enabled.
12163 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12165 " Configured Selection Deferral Time(sec): %u\n",
12166 peer
->bgp
->select_defer_time
);
12168 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12171 " Selection Deferral Time Remaining(sec): %ld\n",
12172 thread_timer_remain_second(
12173 peer
->bgp
->gr_info
[afi
][safi
]
12174 .t_select_deferral
));
12177 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12178 json_endofrib_status
);
12179 json_object_object_add(json_afi_safi
, "timers",
12181 json_object_object_add(
12182 json
, get_afi_safi_str(afi
, safi
, true),
12188 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12193 json_object
*json_timer
= NULL
;
12195 json_timer
= json_object_new_object();
12197 json_object_int_add(json_timer
, "configuredRestartTimer",
12198 p
->bgp
->restart_time
);
12200 json_object_int_add(json_timer
, "receivedRestartTimer",
12203 if (p
->t_gr_restart
!= NULL
)
12204 json_object_int_add(
12205 json_timer
, "restartTimerRemaining",
12206 thread_timer_remain_second(p
->t_gr_restart
));
12208 json_object_object_add(json
, "timers", json_timer
);
12211 vty_out(vty
, " Timers:\n");
12212 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12213 p
->bgp
->restart_time
);
12215 vty_out(vty
, " Received Restart Time(sec): %u\n",
12217 if (p
->t_gr_restart
!= NULL
)
12218 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12219 thread_timer_remain_second(p
->t_gr_restart
));
12220 if (p
->t_gr_restart
!= NULL
) {
12221 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12222 thread_timer_remain_second(p
->t_gr_restart
));
12227 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12230 char dn_flag
[2] = {0};
12231 /* '*' + v6 address of neighbor */
12232 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12234 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12239 json_object_string_addf(json
, "neighborAddr", "%pSU",
12242 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12245 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12249 json_object_string_add(json
, "neighborAddr",
12252 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12255 /* more gr info in new format */
12256 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12259 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12260 safi_t safi
, bool use_json
,
12261 json_object
*json_neigh
)
12263 struct bgp_filter
*filter
;
12264 struct peer_af
*paf
;
12265 char orf_pfx_name
[BUFSIZ
];
12267 json_object
*json_af
= NULL
;
12268 json_object
*json_prefA
= NULL
;
12269 json_object
*json_prefB
= NULL
;
12270 json_object
*json_addr
= NULL
;
12271 json_object
*json_advmap
= NULL
;
12274 json_addr
= json_object_new_object();
12275 json_af
= json_object_new_object();
12276 filter
= &p
->filter
[afi
][safi
];
12278 if (peer_group_active(p
))
12279 json_object_string_add(json_addr
, "peerGroupMember",
12282 paf
= peer_af_find(p
, afi
, safi
);
12283 if (paf
&& PAF_SUBGRP(paf
)) {
12284 json_object_int_add(json_addr
, "updateGroupId",
12285 PAF_UPDGRP(paf
)->id
);
12286 json_object_int_add(json_addr
, "subGroupId",
12287 PAF_SUBGRP(paf
)->id
);
12288 json_object_int_add(json_addr
, "packetQueueLength",
12289 bpacket_queue_virtual_length(paf
));
12292 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12293 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12294 PEER_CAP_ORF_PREFIX_SM_RCV
)
12295 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12296 PEER_CAP_ORF_PREFIX_RM_ADV
)
12297 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12298 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12299 json_object_int_add(json_af
, "orfType",
12301 json_prefA
= json_object_new_object();
12302 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12303 PEER_CAP_ORF_PREFIX_SM_ADV
,
12304 PEER_CAP_ORF_PREFIX_RM_ADV
,
12305 PEER_CAP_ORF_PREFIX_SM_RCV
,
12306 PEER_CAP_ORF_PREFIX_RM_RCV
,
12307 use_json
, json_prefA
);
12308 json_object_object_add(json_af
, "orfPrefixList",
12312 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12313 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12314 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12315 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12316 PEER_CAP_ORF_PREFIX_RM_ADV
)
12317 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12318 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12319 json_object_int_add(json_af
, "orfOldType",
12320 ORF_TYPE_PREFIX_OLD
);
12321 json_prefB
= json_object_new_object();
12322 bgp_show_peer_afi_orf_cap(
12323 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12324 PEER_CAP_ORF_PREFIX_RM_ADV
,
12325 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12326 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12328 json_object_object_add(json_af
, "orfOldPrefixList",
12332 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12333 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12334 PEER_CAP_ORF_PREFIX_SM_RCV
)
12335 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12336 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12337 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12338 PEER_CAP_ORF_PREFIX_RM_ADV
)
12339 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12340 PEER_CAP_ORF_PREFIX_RM_RCV
)
12341 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12342 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12343 json_object_object_add(json_addr
, "afDependentCap",
12346 json_object_free(json_af
);
12348 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12349 p
->host
, afi
, safi
);
12350 orf_pfx_count
= prefix_bgp_show_prefix_list(
12351 NULL
, afi
, orf_pfx_name
, use_json
);
12353 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12354 PEER_STATUS_ORF_PREFIX_SEND
)
12355 || orf_pfx_count
) {
12356 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12357 PEER_STATUS_ORF_PREFIX_SEND
))
12358 json_object_boolean_true_add(json_neigh
,
12361 json_object_int_add(json_addr
, "orfRecvCounter",
12364 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12365 PEER_STATUS_ORF_WAIT_REFRESH
))
12366 json_object_string_add(
12367 json_addr
, "orfFirstUpdate",
12368 "deferredUntilORFOrRouteRefreshRecvd");
12370 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12371 PEER_FLAG_REFLECTOR_CLIENT
))
12372 json_object_boolean_true_add(json_addr
,
12373 "routeReflectorClient");
12374 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12375 PEER_FLAG_RSERVER_CLIENT
))
12376 json_object_boolean_true_add(json_addr
,
12377 "routeServerClient");
12378 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12379 json_object_boolean_true_add(json_addr
,
12380 "inboundSoftConfigPermit");
12382 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12383 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12384 json_object_boolean_true_add(
12386 "privateAsNumsAllReplacedInUpdatesToNbr");
12387 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12388 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12389 json_object_boolean_true_add(
12391 "privateAsNumsReplacedInUpdatesToNbr");
12392 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12393 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12394 json_object_boolean_true_add(
12396 "privateAsNumsAllRemovedInUpdatesToNbr");
12397 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12398 PEER_FLAG_REMOVE_PRIVATE_AS
))
12399 json_object_boolean_true_add(
12401 "privateAsNumsRemovedInUpdatesToNbr");
12403 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12404 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12405 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12406 json_object_boolean_true_add(json_addr
,
12407 "allowAsInOrigin");
12409 json_object_int_add(json_addr
, "allowAsInCount",
12410 p
->allowas_in
[afi
][safi
]);
12413 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12414 json_object_boolean_true_add(
12416 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12419 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12420 json_object_string_add(json_addr
,
12421 "overrideASNsInOutboundUpdates",
12422 "ifAspathEqualRemoteAs");
12424 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12425 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12426 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12427 json_object_boolean_true_add(json_addr
,
12428 "routerAlwaysNextHop");
12429 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12430 PEER_FLAG_AS_PATH_UNCHANGED
))
12431 json_object_boolean_true_add(
12432 json_addr
, "unchangedAsPathPropogatedToNbr");
12433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12434 PEER_FLAG_NEXTHOP_UNCHANGED
))
12435 json_object_boolean_true_add(
12436 json_addr
, "unchangedNextHopPropogatedToNbr");
12437 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12438 json_object_boolean_true_add(
12439 json_addr
, "unchangedMedPropogatedToNbr");
12440 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12441 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12442 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12443 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12444 PEER_FLAG_SEND_COMMUNITY
)
12445 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_SEND_EXT_COMMUNITY
))
12447 json_object_string_add(json_addr
,
12448 "commAttriSentToNbr",
12449 "extendedAndStandard");
12450 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12451 PEER_FLAG_SEND_EXT_COMMUNITY
))
12452 json_object_string_add(json_addr
,
12453 "commAttriSentToNbr",
12456 json_object_string_add(json_addr
,
12457 "commAttriSentToNbr",
12460 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12461 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12462 if (p
->default_rmap
[afi
][safi
].name
)
12463 json_object_string_add(
12464 json_addr
, "defaultRouteMap",
12465 p
->default_rmap
[afi
][safi
].name
);
12467 if (paf
&& PAF_SUBGRP(paf
)
12468 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12469 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12470 json_object_boolean_true_add(json_addr
,
12473 json_object_boolean_true_add(json_addr
,
12477 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12478 if (is_evpn_enabled())
12479 json_object_boolean_true_add(
12480 json_addr
, "advertiseAllVnis");
12483 if (filter
->plist
[FILTER_IN
].name
12484 || filter
->dlist
[FILTER_IN
].name
12485 || filter
->aslist
[FILTER_IN
].name
12486 || filter
->map
[RMAP_IN
].name
)
12487 json_object_boolean_true_add(json_addr
,
12488 "inboundPathPolicyConfig");
12489 if (filter
->plist
[FILTER_OUT
].name
12490 || filter
->dlist
[FILTER_OUT
].name
12491 || filter
->aslist
[FILTER_OUT
].name
12492 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12493 json_object_boolean_true_add(
12494 json_addr
, "outboundPathPolicyConfig");
12497 if (filter
->plist
[FILTER_IN
].name
)
12498 json_object_string_add(json_addr
,
12499 "incomingUpdatePrefixFilterList",
12500 filter
->plist
[FILTER_IN
].name
);
12501 if (filter
->plist
[FILTER_OUT
].name
)
12502 json_object_string_add(json_addr
,
12503 "outgoingUpdatePrefixFilterList",
12504 filter
->plist
[FILTER_OUT
].name
);
12506 /* distribute-list */
12507 if (filter
->dlist
[FILTER_IN
].name
)
12508 json_object_string_add(
12509 json_addr
, "incomingUpdateNetworkFilterList",
12510 filter
->dlist
[FILTER_IN
].name
);
12511 if (filter
->dlist
[FILTER_OUT
].name
)
12512 json_object_string_add(
12513 json_addr
, "outgoingUpdateNetworkFilterList",
12514 filter
->dlist
[FILTER_OUT
].name
);
12517 if (filter
->aslist
[FILTER_IN
].name
)
12518 json_object_string_add(json_addr
,
12519 "incomingUpdateAsPathFilterList",
12520 filter
->aslist
[FILTER_IN
].name
);
12521 if (filter
->aslist
[FILTER_OUT
].name
)
12522 json_object_string_add(json_addr
,
12523 "outgoingUpdateAsPathFilterList",
12524 filter
->aslist
[FILTER_OUT
].name
);
12527 if (filter
->map
[RMAP_IN
].name
)
12528 json_object_string_add(
12529 json_addr
, "routeMapForIncomingAdvertisements",
12530 filter
->map
[RMAP_IN
].name
);
12531 if (filter
->map
[RMAP_OUT
].name
)
12532 json_object_string_add(
12533 json_addr
, "routeMapForOutgoingAdvertisements",
12534 filter
->map
[RMAP_OUT
].name
);
12536 /* ebgp-requires-policy (inbound) */
12537 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12538 && !bgp_inbound_policy_exists(p
, filter
))
12539 json_object_string_add(
12540 json_addr
, "inboundEbgpRequiresPolicy",
12541 "Inbound updates discarded due to missing policy");
12543 /* ebgp-requires-policy (outbound) */
12544 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12545 && (!bgp_outbound_policy_exists(p
, filter
)))
12546 json_object_string_add(
12547 json_addr
, "outboundEbgpRequiresPolicy",
12548 "Outbound updates discarded due to missing policy");
12550 /* unsuppress-map */
12551 if (filter
->usmap
.name
)
12552 json_object_string_add(json_addr
,
12553 "selectiveUnsuppressRouteMap",
12554 filter
->usmap
.name
);
12556 /* advertise-map */
12557 if (filter
->advmap
.aname
) {
12558 json_advmap
= json_object_new_object();
12559 json_object_string_add(json_advmap
, "condition",
12560 filter
->advmap
.condition
12563 json_object_string_add(json_advmap
, "conditionMap",
12564 filter
->advmap
.cname
);
12565 json_object_string_add(json_advmap
, "advertiseMap",
12566 filter
->advmap
.aname
);
12567 json_object_string_add(
12568 json_advmap
, "advertiseStatus",
12569 filter
->advmap
.update_type
==
12570 UPDATE_TYPE_ADVERTISE
12573 json_object_object_add(json_addr
, "advertiseMap",
12577 /* Receive prefix count */
12578 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12579 p
->pcount
[afi
][safi
]);
12580 if (paf
&& PAF_SUBGRP(paf
))
12581 json_object_int_add(json_addr
, "sentPrefixCounter",
12582 (PAF_SUBGRP(paf
))->scount
);
12584 /* Maximum prefix */
12585 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12586 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12587 p
->pmax_out
[afi
][safi
]);
12589 /* Maximum prefix */
12590 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12591 json_object_int_add(json_addr
, "prefixAllowedMax",
12592 p
->pmax
[afi
][safi
]);
12593 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12594 PEER_FLAG_MAX_PREFIX_WARNING
))
12595 json_object_boolean_true_add(
12596 json_addr
, "prefixAllowedMaxWarning");
12597 json_object_int_add(json_addr
,
12598 "prefixAllowedWarningThresh",
12599 p
->pmax_threshold
[afi
][safi
]);
12600 if (p
->pmax_restart
[afi
][safi
])
12601 json_object_int_add(
12603 "prefixAllowedRestartIntervalMsecs",
12604 p
->pmax_restart
[afi
][safi
] * 60000);
12606 json_object_object_add(json_neigh
,
12607 get_afi_safi_str(afi
, safi
, true),
12611 filter
= &p
->filter
[afi
][safi
];
12613 vty_out(vty
, " For address family: %s\n",
12614 get_afi_safi_str(afi
, safi
, false));
12616 if (peer_group_active(p
))
12617 vty_out(vty
, " %s peer-group member\n",
12620 paf
= peer_af_find(p
, afi
, safi
);
12621 if (paf
&& PAF_SUBGRP(paf
)) {
12622 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12623 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12624 vty_out(vty
, " Packet Queue length %d\n",
12625 bpacket_queue_virtual_length(paf
));
12627 vty_out(vty
, " Not part of any update group\n");
12629 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12630 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12631 PEER_CAP_ORF_PREFIX_SM_RCV
)
12632 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12633 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12634 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12635 PEER_CAP_ORF_PREFIX_RM_ADV
)
12636 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12637 PEER_CAP_ORF_PREFIX_RM_RCV
)
12638 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12639 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12640 vty_out(vty
, " AF-dependant capabilities:\n");
12642 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12644 PEER_CAP_ORF_PREFIX_SM_RCV
)
12645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12646 PEER_CAP_ORF_PREFIX_RM_ADV
)
12647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12648 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12650 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12652 bgp_show_peer_afi_orf_cap(
12653 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12654 PEER_CAP_ORF_PREFIX_RM_ADV
,
12655 PEER_CAP_ORF_PREFIX_SM_RCV
,
12656 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12658 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12659 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12660 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12661 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12662 PEER_CAP_ORF_PREFIX_RM_ADV
)
12663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12664 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12666 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12667 ORF_TYPE_PREFIX_OLD
);
12668 bgp_show_peer_afi_orf_cap(
12669 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12670 PEER_CAP_ORF_PREFIX_RM_ADV
,
12671 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12672 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12675 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12676 p
->host
, afi
, safi
);
12677 orf_pfx_count
= prefix_bgp_show_prefix_list(
12678 NULL
, afi
, orf_pfx_name
, use_json
);
12680 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12681 PEER_STATUS_ORF_PREFIX_SEND
)
12682 || orf_pfx_count
) {
12683 vty_out(vty
, " Outbound Route Filter (ORF):");
12684 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12685 PEER_STATUS_ORF_PREFIX_SEND
))
12686 vty_out(vty
, " sent;");
12688 vty_out(vty
, " received (%d entries)",
12690 vty_out(vty
, "\n");
12692 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12693 PEER_STATUS_ORF_WAIT_REFRESH
))
12695 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12697 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12698 PEER_FLAG_REFLECTOR_CLIENT
))
12699 vty_out(vty
, " Route-Reflector Client\n");
12700 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12701 PEER_FLAG_RSERVER_CLIENT
))
12702 vty_out(vty
, " Route-Server Client\n");
12703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12705 " Inbound soft reconfiguration allowed\n");
12707 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12708 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12710 " Private AS numbers (all) replaced in updates to this neighbor\n");
12711 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12712 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12714 " Private AS numbers replaced in updates to this neighbor\n");
12715 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12716 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12718 " Private AS numbers (all) removed in updates to this neighbor\n");
12719 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12720 PEER_FLAG_REMOVE_PRIVATE_AS
))
12722 " Private AS numbers removed in updates to this neighbor\n");
12724 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12725 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12726 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12728 " Local AS allowed as path origin\n");
12731 " Local AS allowed in path, %d occurrences\n",
12732 p
->allowas_in
[afi
][safi
]);
12735 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12736 vty_out(vty
, " %s\n",
12737 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12738 ->human_description
);
12740 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12742 " Override ASNs in outbound updates if aspath equals remote-as\n");
12744 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12745 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12746 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12747 vty_out(vty
, " NEXT_HOP is always this router\n");
12748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12749 PEER_FLAG_AS_PATH_UNCHANGED
))
12751 " AS_PATH is propagated unchanged to this neighbor\n");
12752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12753 PEER_FLAG_NEXTHOP_UNCHANGED
))
12755 " NEXT_HOP is propagated unchanged to this neighbor\n");
12756 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12758 " MED is propagated unchanged to this neighbor\n");
12759 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12760 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12761 PEER_FLAG_SEND_EXT_COMMUNITY
)
12762 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12763 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12765 " Community attribute sent to this neighbor");
12766 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12767 PEER_FLAG_SEND_COMMUNITY
)
12768 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12769 PEER_FLAG_SEND_EXT_COMMUNITY
)
12770 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12771 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12772 vty_out(vty
, "(all)\n");
12773 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12774 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12775 vty_out(vty
, "(large)\n");
12776 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12777 PEER_FLAG_SEND_EXT_COMMUNITY
))
12778 vty_out(vty
, "(extended)\n");
12780 vty_out(vty
, "(standard)\n");
12782 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12783 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12784 vty_out(vty
, " Default information originate,");
12786 if (p
->default_rmap
[afi
][safi
].name
)
12787 vty_out(vty
, " default route-map %s%s,",
12788 p
->default_rmap
[afi
][safi
].map
? "*"
12790 p
->default_rmap
[afi
][safi
].name
);
12791 if (paf
&& PAF_SUBGRP(paf
)
12792 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12793 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12794 vty_out(vty
, " default sent\n");
12796 vty_out(vty
, " default not sent\n");
12799 /* advertise-vni-all */
12800 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12801 if (is_evpn_enabled())
12802 vty_out(vty
, " advertise-all-vni\n");
12805 if (filter
->plist
[FILTER_IN
].name
12806 || filter
->dlist
[FILTER_IN
].name
12807 || filter
->aslist
[FILTER_IN
].name
12808 || filter
->map
[RMAP_IN
].name
)
12809 vty_out(vty
, " Inbound path policy configured\n");
12810 if (filter
->plist
[FILTER_OUT
].name
12811 || filter
->dlist
[FILTER_OUT
].name
12812 || filter
->aslist
[FILTER_OUT
].name
12813 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12814 vty_out(vty
, " Outbound path policy configured\n");
12817 if (filter
->plist
[FILTER_IN
].name
)
12819 " Incoming update prefix filter list is %s%s\n",
12820 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12821 filter
->plist
[FILTER_IN
].name
);
12822 if (filter
->plist
[FILTER_OUT
].name
)
12824 " Outgoing update prefix filter list is %s%s\n",
12825 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12826 filter
->plist
[FILTER_OUT
].name
);
12828 /* distribute-list */
12829 if (filter
->dlist
[FILTER_IN
].name
)
12831 " Incoming update network filter list is %s%s\n",
12832 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12833 filter
->dlist
[FILTER_IN
].name
);
12834 if (filter
->dlist
[FILTER_OUT
].name
)
12836 " Outgoing update network filter list is %s%s\n",
12837 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12838 filter
->dlist
[FILTER_OUT
].name
);
12841 if (filter
->aslist
[FILTER_IN
].name
)
12843 " Incoming update AS path filter list is %s%s\n",
12844 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12845 filter
->aslist
[FILTER_IN
].name
);
12846 if (filter
->aslist
[FILTER_OUT
].name
)
12848 " Outgoing update AS path filter list is %s%s\n",
12849 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12850 filter
->aslist
[FILTER_OUT
].name
);
12853 if (filter
->map
[RMAP_IN
].name
)
12855 " Route map for incoming advertisements is %s%s\n",
12856 filter
->map
[RMAP_IN
].map
? "*" : "",
12857 filter
->map
[RMAP_IN
].name
);
12858 if (filter
->map
[RMAP_OUT
].name
)
12860 " Route map for outgoing advertisements is %s%s\n",
12861 filter
->map
[RMAP_OUT
].map
? "*" : "",
12862 filter
->map
[RMAP_OUT
].name
);
12864 /* ebgp-requires-policy (inbound) */
12865 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12866 && !bgp_inbound_policy_exists(p
, filter
))
12868 " Inbound updates discarded due to missing policy\n");
12870 /* ebgp-requires-policy (outbound) */
12871 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12872 && !bgp_outbound_policy_exists(p
, filter
))
12874 " Outbound updates discarded due to missing policy\n");
12876 /* unsuppress-map */
12877 if (filter
->usmap
.name
)
12879 " Route map for selective unsuppress is %s%s\n",
12880 filter
->usmap
.map
? "*" : "",
12881 filter
->usmap
.name
);
12883 /* advertise-map */
12884 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12886 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12887 filter
->advmap
.condition
? "EXIST"
12889 filter
->advmap
.cmap
? "*" : "",
12890 filter
->advmap
.cname
,
12891 filter
->advmap
.amap
? "*" : "",
12892 filter
->advmap
.aname
,
12893 filter
->advmap
.update_type
==
12894 UPDATE_TYPE_ADVERTISE
12898 /* Receive prefix count */
12899 vty_out(vty
, " %u accepted prefixes\n",
12900 p
->pcount
[afi
][safi
]);
12902 /* maximum-prefix-out */
12903 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12904 PEER_FLAG_MAX_PREFIX_OUT
))
12906 " Maximum allowed prefixes sent %u\n",
12907 p
->pmax_out
[afi
][safi
]);
12909 /* Maximum prefix */
12910 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12912 " Maximum prefixes allowed %u%s\n",
12913 p
->pmax
[afi
][safi
],
12914 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12915 PEER_FLAG_MAX_PREFIX_WARNING
)
12916 ? " (warning-only)"
12918 vty_out(vty
, " Threshold for warning message %d%%",
12919 p
->pmax_threshold
[afi
][safi
]);
12920 if (p
->pmax_restart
[afi
][safi
])
12921 vty_out(vty
, ", restart interval %d min",
12922 p
->pmax_restart
[afi
][safi
]);
12923 vty_out(vty
, "\n");
12926 vty_out(vty
, "\n");
12930 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12934 char timebuf
[BGP_UPTIME_LEN
];
12940 json_object
*json_neigh
= NULL
;
12942 uint32_t sync_tcp_mss
;
12947 json_neigh
= json_object_new_object();
12949 memset(dn_flag
, '\0', sizeof(dn_flag
));
12950 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12954 if (p
->conf_if
) /* Configured interface name. */
12955 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12957 else /* Configured IP address. */
12958 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12963 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12964 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12966 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12967 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12970 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12972 if (p
->change_local_as
)
12973 json_object_int_add(json_neigh
, "localAs",
12974 p
->change_local_as
);
12976 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12978 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12979 json_object_boolean_true_add(json_neigh
,
12980 "localAsNoPrepend");
12982 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12983 json_object_boolean_true_add(json_neigh
,
12984 "localAsReplaceAs");
12986 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12987 || (p
->as_type
== AS_INTERNAL
))
12988 vty_out(vty
, "remote AS %u, ", p
->as
);
12990 vty_out(vty
, "remote AS Unspecified, ");
12991 vty_out(vty
, "local AS %u%s%s, ",
12992 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12993 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12996 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13000 /* peer type internal or confed-internal */
13001 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13003 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13004 json_object_boolean_true_add(
13005 json_neigh
, "nbrConfedInternalLink");
13007 json_object_boolean_true_add(json_neigh
,
13008 "nbrInternalLink");
13010 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13011 vty_out(vty
, "confed-internal link\n");
13013 vty_out(vty
, "internal link\n");
13015 /* peer type external or confed-external */
13016 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13018 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13019 json_object_boolean_true_add(
13020 json_neigh
, "nbrConfedExternalLink");
13022 json_object_boolean_true_add(json_neigh
,
13023 "nbrExternalLink");
13025 if (bgp_confederation_peers_check(bgp
, p
->as
))
13026 vty_out(vty
, "confed-external link\n");
13028 vty_out(vty
, "external link\n");
13032 json_object_boolean_true_add(json_neigh
,
13033 "nbrUnspecifiedLink");
13035 vty_out(vty
, "unspecified link\n");
13040 json_object_string_add(json_neigh
, "localRole",
13041 bgp_get_name_by_role(p
->local_role
));
13042 json_object_string_add(json_neigh
, "remoteRole",
13043 bgp_get_name_by_role(p
->remote_role
));
13045 vty_out(vty
, " Local Role: %s\n",
13046 bgp_get_name_by_role(p
->local_role
));
13047 vty_out(vty
, " Remote Role: %s\n",
13048 bgp_get_name_by_role(p
->remote_role
));
13055 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13057 vty_out(vty
, " Description: %s\n", p
->desc
);
13062 json_object_string_add(json_neigh
, "hostname",
13066 json_object_string_add(json_neigh
, "domainname",
13069 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13070 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13073 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13077 json_object_string_add(json_neigh
, "hostname",
13084 json_object_string_add(json_neigh
, "peerGroup",
13088 struct prefix prefix
, *range
= NULL
;
13090 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13091 range
= peer_group_lookup_dynamic_neighbor_range(
13092 p
->group
, &prefix
);
13095 json_object_string_addf(
13097 "peerSubnetRangeGroup", "%pFX",
13103 " Member of peer-group %s for session parameters\n",
13107 struct prefix prefix
, *range
= NULL
;
13109 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13110 range
= peer_group_lookup_dynamic_neighbor_range(
13111 p
->group
, &prefix
);
13115 " Belongs to the subnet range group: %pFX\n",
13123 /* Administrative shutdown. */
13124 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13125 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13126 json_object_boolean_true_add(json_neigh
,
13130 json_object_int_add(json_neigh
, "bgpVersion", 4);
13131 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13133 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13136 /* Confederation */
13137 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13138 && bgp_confederation_peers_check(bgp
, p
->as
))
13139 json_object_boolean_true_add(json_neigh
,
13143 json_object_string_add(
13144 json_neigh
, "bgpState",
13145 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13147 if (peer_established(p
)) {
13150 uptime
= monotime(NULL
);
13151 uptime
-= p
->uptime
;
13152 epoch_tbuf
= time(NULL
) - uptime
;
13154 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13156 json_object_string_add(json_neigh
, "bgpTimerUpString",
13157 peer_uptime(p
->uptime
, timebuf
,
13160 json_object_int_add(json_neigh
,
13161 "bgpTimerUpEstablishedEpoch",
13165 else if (p
->status
== Active
) {
13166 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13167 json_object_string_add(json_neigh
, "bgpStateIs",
13169 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13170 json_object_string_add(json_neigh
, "bgpStateIs",
13178 uptime
= monotime(NULL
);
13179 uptime
-= p
->readtime
;
13180 gmtime_r(&uptime
, &tm
);
13182 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13183 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13184 + (tm
.tm_hour
* 3600000));
13186 uptime
= monotime(NULL
);
13187 uptime
-= p
->last_write
;
13188 gmtime_r(&uptime
, &tm
);
13190 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13191 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13192 + (tm
.tm_hour
* 3600000));
13194 uptime
= monotime(NULL
);
13195 uptime
-= p
->update_time
;
13196 gmtime_r(&uptime
, &tm
);
13198 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13199 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13200 + (tm
.tm_hour
* 3600000));
13202 /* Configured timer values. */
13203 json_object_int_add(json_neigh
,
13204 "bgpTimerConfiguredHoldTimeMsecs",
13205 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13206 ? p
->holdtime
* 1000
13207 : bgp
->default_holdtime
* 1000);
13208 json_object_int_add(json_neigh
,
13209 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13210 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13211 ? p
->keepalive
* 1000
13212 : bgp
->default_keepalive
* 1000);
13213 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13214 p
->v_holdtime
* 1000);
13215 json_object_int_add(json_neigh
,
13216 "bgpTimerKeepAliveIntervalMsecs",
13217 p
->v_keepalive
* 1000);
13218 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13219 json_object_int_add(json_neigh
,
13220 "bgpTimerDelayOpenTimeMsecs",
13221 p
->v_delayopen
* 1000);
13224 /* Configured and Synced tcp-mss value for peer */
13225 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13226 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13227 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13229 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13233 /* Extended Optional Parameters Length for BGP OPEN Message */
13234 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13235 json_object_boolean_true_add(
13236 json_neigh
, "extendedOptionalParametersLength");
13238 json_object_boolean_false_add(
13239 json_neigh
, "extendedOptionalParametersLength");
13241 /* Conditional advertisements */
13242 json_object_int_add(
13244 "bgpTimerConfiguredConditionalAdvertisementsSec",
13245 bgp
->condition_check_period
);
13246 if (thread_is_scheduled(bgp
->t_condition_check
))
13247 json_object_int_add(
13249 "bgpTimerUntilConditionalAdvertisementsSec",
13250 thread_timer_remain_second(
13251 bgp
->t_condition_check
));
13253 /* Administrative shutdown. */
13254 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13255 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13256 vty_out(vty
, " Administratively shut down\n");
13259 vty_out(vty
, " BGP version 4");
13260 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13261 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13263 /* Confederation */
13264 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13265 && bgp_confederation_peers_check(bgp
, p
->as
))
13267 " Neighbor under common administration\n");
13270 vty_out(vty
, " BGP state = %s",
13271 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13273 if (peer_established(p
))
13274 vty_out(vty
, ", up for %8s",
13275 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13278 else if (p
->status
== Active
) {
13279 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13280 vty_out(vty
, " (passive)");
13281 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13282 vty_out(vty
, " (NSF passive)");
13284 vty_out(vty
, "\n");
13287 vty_out(vty
, " Last read %s",
13288 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13290 vty_out(vty
, ", Last write %s\n",
13291 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13294 /* Configured timer values. */
13296 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13297 p
->v_holdtime
, p
->v_keepalive
);
13298 vty_out(vty
, " Configured hold time is %d seconds",
13299 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13301 : bgp
->default_holdtime
);
13302 vty_out(vty
, ", keepalive interval is %d seconds\n",
13303 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13305 : bgp
->default_keepalive
);
13306 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13308 " Configured DelayOpenTime is %d seconds\n",
13311 /* Configured and synced tcp-mss value for peer */
13312 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13313 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13314 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13315 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13318 /* Extended Optional Parameters Length for BGP OPEN Message */
13319 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13321 " Extended Optional Parameters Length is enabled\n");
13323 /* Conditional advertisements */
13325 " Configured conditional advertisements interval is %d seconds\n",
13326 bgp
->condition_check_period
);
13327 if (thread_is_scheduled(bgp
->t_condition_check
))
13329 " Time until conditional advertisements begin is %lu seconds\n",
13330 thread_timer_remain_second(
13331 bgp
->t_condition_check
));
13334 if (peer_established(p
) &&
13335 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13337 json_object
*json_cap
= NULL
;
13339 json_cap
= json_object_new_object();
13342 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13343 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13344 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13345 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13346 json_object_string_add(
13347 json_cap
, "4byteAs",
13348 "advertisedAndReceived");
13349 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13350 json_object_string_add(json_cap
,
13353 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13354 json_object_string_add(json_cap
,
13359 /* Extended Message Support */
13360 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13361 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13362 json_object_string_add(json_cap
,
13364 "advertisedAndReceived");
13365 else if (CHECK_FLAG(p
->cap
,
13366 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13367 json_object_string_add(json_cap
,
13370 else if (CHECK_FLAG(p
->cap
,
13371 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13372 json_object_string_add(json_cap
,
13377 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13378 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13379 json_object
*json_add
= NULL
;
13380 const char *print_store
;
13382 json_add
= json_object_new_object();
13384 FOREACH_AFI_SAFI (afi
, safi
) {
13385 json_object
*json_sub
= NULL
;
13386 json_sub
= json_object_new_object();
13387 print_store
= get_afi_safi_str(
13391 p
->af_cap
[afi
][safi
],
13392 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13394 p
->af_cap
[afi
][safi
],
13395 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13399 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13403 PEER_CAP_ADDPATH_AF_TX_RCV
))
13404 json_object_boolean_true_add(
13406 "txAdvertisedAndReceived");
13411 PEER_CAP_ADDPATH_AF_TX_ADV
))
13412 json_object_boolean_true_add(
13419 PEER_CAP_ADDPATH_AF_TX_RCV
))
13420 json_object_boolean_true_add(
13426 p
->af_cap
[afi
][safi
],
13427 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13429 p
->af_cap
[afi
][safi
],
13430 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13434 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13438 PEER_CAP_ADDPATH_AF_RX_RCV
))
13439 json_object_boolean_true_add(
13441 "rxAdvertisedAndReceived");
13446 PEER_CAP_ADDPATH_AF_RX_ADV
))
13447 json_object_boolean_true_add(
13454 PEER_CAP_ADDPATH_AF_RX_RCV
))
13455 json_object_boolean_true_add(
13461 p
->af_cap
[afi
][safi
],
13462 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13464 p
->af_cap
[afi
][safi
],
13465 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13467 p
->af_cap
[afi
][safi
],
13468 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13470 p
->af_cap
[afi
][safi
],
13471 PEER_CAP_ADDPATH_AF_RX_RCV
))
13472 json_object_object_add(
13473 json_add
, print_store
,
13476 json_object_free(json_sub
);
13479 json_object_object_add(json_cap
, "addPath",
13484 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13485 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13486 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13487 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13488 json_object_string_add(
13489 json_cap
, "dynamic",
13490 "advertisedAndReceived");
13491 else if (CHECK_FLAG(p
->cap
,
13492 PEER_CAP_DYNAMIC_ADV
))
13493 json_object_string_add(json_cap
,
13496 else if (CHECK_FLAG(p
->cap
,
13497 PEER_CAP_DYNAMIC_RCV
))
13498 json_object_string_add(json_cap
,
13504 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13505 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13506 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13507 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13508 json_object_string_add(
13510 "advertisedAndReceived");
13511 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13512 json_object_string_add(json_cap
, "role",
13514 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13515 json_object_string_add(json_cap
, "role",
13519 /* Extended nexthop */
13520 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13521 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13522 json_object
*json_nxt
= NULL
;
13523 const char *print_store
;
13526 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13527 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13528 json_object_string_add(
13529 json_cap
, "extendedNexthop",
13530 "advertisedAndReceived");
13531 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13532 json_object_string_add(
13533 json_cap
, "extendedNexthop",
13535 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13536 json_object_string_add(
13537 json_cap
, "extendedNexthop",
13540 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13541 json_nxt
= json_object_new_object();
13543 for (safi
= SAFI_UNICAST
;
13544 safi
< SAFI_MAX
; safi
++) {
13548 PEER_CAP_ENHE_AF_RCV
)) {
13554 json_object_string_add(
13557 "recieved"); /* misspelled for compatibility */
13560 json_object_object_add(
13562 "extendedNexthopFamililesByPeer",
13567 /* Long-lived Graceful Restart */
13568 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13569 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13570 json_object
*json_llgr
= NULL
;
13571 const char *afi_safi_str
;
13573 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13574 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13575 json_object_string_add(
13577 "longLivedGracefulRestart",
13578 "advertisedAndReceived");
13579 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13580 json_object_string_add(
13582 "longLivedGracefulRestart",
13584 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13585 json_object_string_add(
13587 "longLivedGracefulRestart",
13590 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13591 json_llgr
= json_object_new_object();
13593 FOREACH_AFI_SAFI (afi
, safi
) {
13597 PEER_CAP_ENHE_AF_RCV
)) {
13603 json_object_string_add(
13609 json_object_object_add(
13611 "longLivedGracefulRestartByPeer",
13616 /* Route Refresh */
13617 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13618 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13619 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13620 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13621 (CHECK_FLAG(p
->cap
,
13622 PEER_CAP_REFRESH_NEW_RCV
) ||
13624 PEER_CAP_REFRESH_OLD_RCV
))) {
13627 PEER_CAP_REFRESH_OLD_RCV
) &&
13630 PEER_CAP_REFRESH_NEW_RCV
))
13631 json_object_string_add(
13634 "advertisedAndReceivedOldNew");
13638 PEER_CAP_REFRESH_OLD_RCV
))
13639 json_object_string_add(
13642 "advertisedAndReceivedOld");
13644 json_object_string_add(
13647 "advertisedAndReceivedNew");
13649 } else if (CHECK_FLAG(p
->cap
,
13650 PEER_CAP_REFRESH_ADV
))
13651 json_object_string_add(json_cap
,
13654 else if (CHECK_FLAG(p
->cap
,
13655 PEER_CAP_REFRESH_NEW_RCV
) ||
13657 PEER_CAP_REFRESH_OLD_RCV
))
13658 json_object_string_add(json_cap
,
13663 /* Enhanced Route Refresh */
13664 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13665 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13666 if (CHECK_FLAG(p
->cap
,
13667 PEER_CAP_ENHANCED_RR_ADV
) &&
13669 PEER_CAP_ENHANCED_RR_RCV
))
13670 json_object_string_add(
13672 "enhancedRouteRefresh",
13673 "advertisedAndReceived");
13674 else if (CHECK_FLAG(p
->cap
,
13675 PEER_CAP_ENHANCED_RR_ADV
))
13676 json_object_string_add(
13678 "enhancedRouteRefresh",
13680 else if (CHECK_FLAG(p
->cap
,
13681 PEER_CAP_ENHANCED_RR_RCV
))
13682 json_object_string_add(
13684 "enhancedRouteRefresh",
13688 /* Multiprotocol Extensions */
13689 json_object
*json_multi
= NULL
;
13691 json_multi
= json_object_new_object();
13693 FOREACH_AFI_SAFI (afi
, safi
) {
13694 if (p
->afc_adv
[afi
][safi
] ||
13695 p
->afc_recv
[afi
][safi
]) {
13696 json_object
*json_exten
= NULL
;
13697 json_exten
= json_object_new_object();
13699 if (p
->afc_adv
[afi
][safi
] &&
13700 p
->afc_recv
[afi
][safi
])
13701 json_object_boolean_true_add(
13703 "advertisedAndReceived");
13704 else if (p
->afc_adv
[afi
][safi
])
13705 json_object_boolean_true_add(
13708 else if (p
->afc_recv
[afi
][safi
])
13709 json_object_boolean_true_add(
13710 json_exten
, "received");
13712 json_object_object_add(
13714 get_afi_safi_str(afi
, safi
,
13719 json_object_object_add(json_cap
,
13720 "multiprotocolExtensions",
13723 /* Hostname capabilities */
13724 json_object
*json_hname
= NULL
;
13726 json_hname
= json_object_new_object();
13728 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13729 json_object_string_add(
13730 json_hname
, "advHostName",
13731 bgp
->peer_self
->hostname
13732 ? bgp
->peer_self
->hostname
13734 json_object_string_add(
13735 json_hname
, "advDomainName",
13736 bgp
->peer_self
->domainname
13737 ? bgp
->peer_self
->domainname
13742 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13743 json_object_string_add(
13744 json_hname
, "rcvHostName",
13745 p
->hostname
? p
->hostname
: "n/a");
13746 json_object_string_add(
13747 json_hname
, "rcvDomainName",
13748 p
->domainname
? p
->domainname
: "n/a");
13751 json_object_object_add(json_cap
, "hostName",
13754 /* Graceful Restart */
13755 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13756 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13757 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13758 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13759 json_object_string_add(
13760 json_cap
, "gracefulRestart",
13761 "advertisedAndReceived");
13762 else if (CHECK_FLAG(p
->cap
,
13763 PEER_CAP_RESTART_ADV
))
13764 json_object_string_add(
13766 "gracefulRestartCapability",
13768 else if (CHECK_FLAG(p
->cap
,
13769 PEER_CAP_RESTART_RCV
))
13770 json_object_string_add(
13772 "gracefulRestartCapability",
13775 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13776 int restart_af_count
= 0;
13777 json_object
*json_restart
= NULL
;
13778 json_restart
= json_object_new_object();
13780 json_object_int_add(
13782 "gracefulRestartRemoteTimerMsecs",
13783 p
->v_gr_restart
* 1000);
13785 FOREACH_AFI_SAFI (afi
, safi
) {
13789 PEER_CAP_RESTART_AF_RCV
)) {
13790 json_object
*json_sub
=
13793 json_object_new_object();
13799 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13800 json_object_boolean_true_add(
13803 restart_af_count
++;
13804 json_object_object_add(
13813 if (!restart_af_count
) {
13814 json_object_string_add(
13816 "addressFamiliesByPeer",
13818 json_object_free(json_restart
);
13820 json_object_object_add(
13822 "addressFamiliesByPeer",
13826 json_object_object_add(
13827 json_neigh
, "neighborCapabilities", json_cap
);
13829 vty_out(vty
, " Neighbor capabilities:\n");
13832 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13833 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13834 vty_out(vty
, " 4 Byte AS:");
13835 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13836 vty_out(vty
, " advertised");
13837 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13838 vty_out(vty
, " %sreceived",
13843 vty_out(vty
, "\n");
13846 /* Extended Message Support */
13847 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13848 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13849 vty_out(vty
, " Extended Message:");
13850 if (CHECK_FLAG(p
->cap
,
13851 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13852 vty_out(vty
, " advertised");
13853 if (CHECK_FLAG(p
->cap
,
13854 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13855 vty_out(vty
, " %sreceived",
13858 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13861 vty_out(vty
, "\n");
13865 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13866 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13867 vty_out(vty
, " AddPath:\n");
13869 FOREACH_AFI_SAFI (afi
, safi
) {
13871 p
->af_cap
[afi
][safi
],
13872 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13874 p
->af_cap
[afi
][safi
],
13875 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13876 vty_out(vty
, " %s: TX ",
13884 PEER_CAP_ADDPATH_AF_TX_ADV
))
13891 PEER_CAP_ADDPATH_AF_TX_RCV
))
13898 PEER_CAP_ADDPATH_AF_TX_ADV
)
13902 vty_out(vty
, "\n");
13906 p
->af_cap
[afi
][safi
],
13907 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13909 p
->af_cap
[afi
][safi
],
13910 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13911 vty_out(vty
, " %s: RX ",
13919 PEER_CAP_ADDPATH_AF_RX_ADV
))
13926 PEER_CAP_ADDPATH_AF_RX_RCV
))
13933 PEER_CAP_ADDPATH_AF_RX_ADV
)
13937 vty_out(vty
, "\n");
13943 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13944 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13945 vty_out(vty
, " Dynamic:");
13946 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13947 vty_out(vty
, " advertised");
13948 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13949 vty_out(vty
, " %sreceived",
13951 PEER_CAP_DYNAMIC_ADV
)
13954 vty_out(vty
, "\n");
13958 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13959 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13960 vty_out(vty
, " Role:");
13961 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13962 vty_out(vty
, " advertised");
13963 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13964 vty_out(vty
, " %sreceived",
13969 vty_out(vty
, "\n");
13972 /* Extended nexthop */
13973 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13974 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13975 vty_out(vty
, " Extended nexthop:");
13976 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13977 vty_out(vty
, " advertised");
13978 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13979 vty_out(vty
, " %sreceived",
13984 vty_out(vty
, "\n");
13986 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13988 " Address families by peer:\n ");
13989 for (safi
= SAFI_UNICAST
;
13990 safi
< SAFI_MAX
; safi
++)
13994 PEER_CAP_ENHE_AF_RCV
))
14004 /* Long-lived Graceful Restart */
14005 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14006 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14008 " Long-lived Graceful Restart:");
14009 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14010 vty_out(vty
, " advertised");
14011 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14012 vty_out(vty
, " %sreceived",
14017 vty_out(vty
, "\n");
14019 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14021 " Address families by peer:\n");
14022 FOREACH_AFI_SAFI (afi
, safi
)
14026 PEER_CAP_LLGR_AF_RCV
))
14036 /* Route Refresh */
14037 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14038 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14039 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14040 vty_out(vty
, " Route refresh:");
14041 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14042 vty_out(vty
, " advertised");
14043 if (CHECK_FLAG(p
->cap
,
14044 PEER_CAP_REFRESH_NEW_RCV
) ||
14046 PEER_CAP_REFRESH_OLD_RCV
))
14047 vty_out(vty
, " %sreceived(%s)",
14049 PEER_CAP_REFRESH_ADV
)
14054 PEER_CAP_REFRESH_OLD_RCV
) &&
14057 PEER_CAP_REFRESH_NEW_RCV
))
14061 PEER_CAP_REFRESH_OLD_RCV
)
14065 vty_out(vty
, "\n");
14068 /* Enhanced Route Refresh */
14069 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14070 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14071 vty_out(vty
, " Enhanced Route Refresh:");
14072 if (CHECK_FLAG(p
->cap
,
14073 PEER_CAP_ENHANCED_RR_ADV
))
14074 vty_out(vty
, " advertised");
14075 if (CHECK_FLAG(p
->cap
,
14076 PEER_CAP_ENHANCED_RR_RCV
))
14077 vty_out(vty
, " %sreceived",
14079 PEER_CAP_REFRESH_ADV
)
14082 vty_out(vty
, "\n");
14085 /* Multiprotocol Extensions */
14086 FOREACH_AFI_SAFI (afi
, safi
)
14087 if (p
->afc_adv
[afi
][safi
] ||
14088 p
->afc_recv
[afi
][safi
]) {
14089 vty_out(vty
, " Address Family %s:",
14090 get_afi_safi_str(afi
, safi
,
14092 if (p
->afc_adv
[afi
][safi
])
14093 vty_out(vty
, " advertised");
14094 if (p
->afc_recv
[afi
][safi
])
14095 vty_out(vty
, " %sreceived",
14096 p
->afc_adv
[afi
][safi
]
14099 vty_out(vty
, "\n");
14102 /* Hostname capability */
14103 vty_out(vty
, " Hostname Capability:");
14105 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14107 " advertised (name: %s,domain name: %s)",
14108 bgp
->peer_self
->hostname
14109 ? bgp
->peer_self
->hostname
14111 bgp
->peer_self
->domainname
14112 ? bgp
->peer_self
->domainname
14115 vty_out(vty
, " not advertised");
14118 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14120 " received (name: %s,domain name: %s)",
14121 p
->hostname
? p
->hostname
: "n/a",
14122 p
->domainname
? p
->domainname
: "n/a");
14124 vty_out(vty
, " not received");
14127 vty_out(vty
, "\n");
14129 /* Graceful Restart */
14130 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14131 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14133 " Graceful Restart Capability:");
14134 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14135 vty_out(vty
, " advertised");
14136 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14137 vty_out(vty
, " %sreceived",
14139 PEER_CAP_RESTART_ADV
)
14142 vty_out(vty
, "\n");
14144 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14145 int restart_af_count
= 0;
14148 " Remote Restart timer is %d seconds\n",
14151 " Address families by peer:\n ");
14153 FOREACH_AFI_SAFI (afi
, safi
)
14157 PEER_CAP_RESTART_AF_RCV
)) {
14158 vty_out(vty
, "%s%s(%s)",
14170 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14172 : "not preserved");
14173 restart_af_count
++;
14175 if (!restart_af_count
)
14176 vty_out(vty
, "none");
14177 vty_out(vty
, "\n");
14179 } /* Graceful Restart */
14183 /* graceful restart information */
14184 json_object
*json_grace
= NULL
;
14185 json_object
*json_grace_send
= NULL
;
14186 json_object
*json_grace_recv
= NULL
;
14187 int eor_send_af_count
= 0;
14188 int eor_receive_af_count
= 0;
14191 json_grace
= json_object_new_object();
14192 json_grace_send
= json_object_new_object();
14193 json_grace_recv
= json_object_new_object();
14195 if ((peer_established(p
)) &&
14196 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14197 FOREACH_AFI_SAFI (afi
, safi
) {
14198 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14199 PEER_STATUS_EOR_SEND
)) {
14200 json_object_boolean_true_add(
14202 get_afi_safi_str(afi
, safi
,
14204 eor_send_af_count
++;
14207 FOREACH_AFI_SAFI (afi
, safi
) {
14208 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14209 PEER_STATUS_EOR_RECEIVED
)) {
14210 json_object_boolean_true_add(
14212 get_afi_safi_str(afi
, safi
,
14214 eor_receive_af_count
++;
14218 json_object_object_add(json_grace
, "endOfRibSend",
14220 json_object_object_add(json_grace
, "endOfRibRecv",
14224 if (p
->t_gr_restart
)
14225 json_object_int_add(
14226 json_grace
, "gracefulRestartTimerMsecs",
14227 thread_timer_remain_second(p
->t_gr_restart
) *
14231 json_object_int_add(
14232 json_grace
, "gracefulStalepathTimerMsecs",
14233 thread_timer_remain_second(p
->t_gr_stale
) *
14235 /* more gr info in new format */
14236 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14237 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14240 vty_out(vty
, " Graceful restart information:\n");
14241 if ((peer_established(p
)) &&
14242 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14244 vty_out(vty
, " End-of-RIB send: ");
14245 FOREACH_AFI_SAFI (afi
, safi
) {
14246 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14247 PEER_STATUS_EOR_SEND
)) {
14248 vty_out(vty
, "%s%s",
14249 eor_send_af_count
? ", " : "",
14250 get_afi_safi_str(afi
, safi
,
14252 eor_send_af_count
++;
14255 vty_out(vty
, "\n");
14256 vty_out(vty
, " End-of-RIB received: ");
14257 FOREACH_AFI_SAFI (afi
, safi
) {
14258 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14259 PEER_STATUS_EOR_RECEIVED
)) {
14260 vty_out(vty
, "%s%s",
14261 eor_receive_af_count
? ", "
14263 get_afi_safi_str(afi
, safi
,
14265 eor_receive_af_count
++;
14268 vty_out(vty
, "\n");
14271 if (p
->t_gr_restart
)
14273 " The remaining time of restart timer is %ld\n",
14274 thread_timer_remain_second(p
->t_gr_restart
));
14278 " The remaining time of stalepath timer is %ld\n",
14279 thread_timer_remain_second(p
->t_gr_stale
));
14281 /* more gr info in new format */
14282 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14286 json_object
*json_stat
= NULL
;
14287 json_stat
= json_object_new_object();
14288 /* Packet counts. */
14290 atomic_size_t outq_count
, inq_count
;
14291 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14292 memory_order_relaxed
);
14293 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14294 memory_order_relaxed
);
14296 json_object_int_add(json_stat
, "depthInq",
14297 (unsigned long)inq_count
);
14298 json_object_int_add(json_stat
, "depthOutq",
14299 (unsigned long)outq_count
);
14300 json_object_int_add(json_stat
, "opensSent",
14301 atomic_load_explicit(&p
->open_out
,
14302 memory_order_relaxed
));
14303 json_object_int_add(json_stat
, "opensRecv",
14304 atomic_load_explicit(&p
->open_in
,
14305 memory_order_relaxed
));
14306 json_object_int_add(json_stat
, "notificationsSent",
14307 atomic_load_explicit(&p
->notify_out
,
14308 memory_order_relaxed
));
14309 json_object_int_add(json_stat
, "notificationsRecv",
14310 atomic_load_explicit(&p
->notify_in
,
14311 memory_order_relaxed
));
14312 json_object_int_add(json_stat
, "updatesSent",
14313 atomic_load_explicit(&p
->update_out
,
14314 memory_order_relaxed
));
14315 json_object_int_add(json_stat
, "updatesRecv",
14316 atomic_load_explicit(&p
->update_in
,
14317 memory_order_relaxed
));
14318 json_object_int_add(json_stat
, "keepalivesSent",
14319 atomic_load_explicit(&p
->keepalive_out
,
14320 memory_order_relaxed
));
14321 json_object_int_add(json_stat
, "keepalivesRecv",
14322 atomic_load_explicit(&p
->keepalive_in
,
14323 memory_order_relaxed
));
14324 json_object_int_add(json_stat
, "routeRefreshSent",
14325 atomic_load_explicit(&p
->refresh_out
,
14326 memory_order_relaxed
));
14327 json_object_int_add(json_stat
, "routeRefreshRecv",
14328 atomic_load_explicit(&p
->refresh_in
,
14329 memory_order_relaxed
));
14330 json_object_int_add(json_stat
, "capabilitySent",
14331 atomic_load_explicit(&p
->dynamic_cap_out
,
14332 memory_order_relaxed
));
14333 json_object_int_add(json_stat
, "capabilityRecv",
14334 atomic_load_explicit(&p
->dynamic_cap_in
,
14335 memory_order_relaxed
));
14336 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14337 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14338 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14340 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14341 notify_out
, notify_in
, update_out
, update_in
,
14342 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14343 dynamic_cap_out
, dynamic_cap_in
;
14344 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14345 memory_order_relaxed
);
14346 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14347 memory_order_relaxed
);
14348 open_out
= atomic_load_explicit(&p
->open_out
,
14349 memory_order_relaxed
);
14351 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14352 notify_out
= atomic_load_explicit(&p
->notify_out
,
14353 memory_order_relaxed
);
14354 notify_in
= atomic_load_explicit(&p
->notify_in
,
14355 memory_order_relaxed
);
14356 update_out
= atomic_load_explicit(&p
->update_out
,
14357 memory_order_relaxed
);
14358 update_in
= atomic_load_explicit(&p
->update_in
,
14359 memory_order_relaxed
);
14360 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14361 memory_order_relaxed
);
14362 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14363 memory_order_relaxed
);
14364 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14365 memory_order_relaxed
);
14366 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14367 memory_order_relaxed
);
14368 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14369 memory_order_relaxed
);
14370 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14371 memory_order_relaxed
);
14373 /* Packet counts. */
14374 vty_out(vty
, " Message statistics:\n");
14375 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14376 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14377 vty_out(vty
, " Sent Rcvd\n");
14378 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14380 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14382 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14384 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14386 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14388 vty_out(vty
, " Capability: %10zu %10zu\n",
14389 dynamic_cap_out
, dynamic_cap_in
);
14390 vty_out(vty
, " Total: %10u %10u\n",
14391 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14395 /* advertisement-interval */
14396 json_object_int_add(json_neigh
,
14397 "minBtwnAdvertisementRunsTimerMsecs",
14398 p
->v_routeadv
* 1000);
14400 /* Update-source. */
14401 if (p
->update_if
|| p
->update_source
) {
14403 json_object_string_add(json_neigh
,
14406 else if (p
->update_source
)
14407 json_object_string_addf(json_neigh
,
14408 "updateSource", "%pSU",
14412 /* advertisement-interval */
14414 " Minimum time between advertisement runs is %d seconds\n",
14417 /* Update-source. */
14418 if (p
->update_if
|| p
->update_source
) {
14419 vty_out(vty
, " Update source is ");
14421 vty_out(vty
, "%s", p
->update_if
);
14422 else if (p
->update_source
)
14423 vty_out(vty
, "%pSU", p
->update_source
);
14424 vty_out(vty
, "\n");
14427 vty_out(vty
, "\n");
14430 /* Address Family Information */
14431 json_object
*json_hold
= NULL
;
14434 json_hold
= json_object_new_object();
14436 FOREACH_AFI_SAFI (afi
, safi
)
14437 if (p
->afc
[afi
][safi
])
14438 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14442 json_object_object_add(json_neigh
, "addressFamilyInfo",
14444 json_object_int_add(json_neigh
, "connectionsEstablished",
14446 json_object_int_add(json_neigh
, "connectionsDropped",
14449 vty_out(vty
, " Connections established %d; dropped %d\n",
14450 p
->established
, p
->dropped
);
14452 if (!p
->last_reset
) {
14454 json_object_string_add(json_neigh
, "lastReset",
14457 vty_out(vty
, " Last reset never\n");
14463 uptime
= monotime(NULL
);
14464 uptime
-= p
->resettime
;
14465 gmtime_r(&uptime
, &tm
);
14467 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14469 + (tm
.tm_min
* 60000)
14470 + (tm
.tm_hour
* 3600000));
14471 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14473 vty_out(vty
, " Last reset %s, ",
14474 peer_uptime(p
->resettime
, timebuf
,
14475 BGP_UPTIME_LEN
, 0, NULL
));
14477 bgp_show_peer_reset(vty
, p
, NULL
, false);
14478 if (p
->last_reset_cause_size
) {
14479 msg
= p
->last_reset_cause
;
14481 " Message received that caused BGP to send a NOTIFICATION:\n ");
14482 for (i
= 1; i
<= p
->last_reset_cause_size
;
14484 vty_out(vty
, "%02X", *msg
++);
14486 if (i
!= p
->last_reset_cause_size
) {
14488 vty_out(vty
, "\n ");
14489 } else if (i
% 4 == 0) {
14494 vty_out(vty
, "\n");
14499 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14501 json_object_boolean_true_add(json_neigh
,
14502 "prefixesConfigExceedMax");
14505 " Peer had exceeded the max. no. of prefixes configured.\n");
14507 if (p
->t_pmax_restart
) {
14509 json_object_boolean_true_add(
14510 json_neigh
, "reducePrefixNumFrom");
14511 json_object_int_add(json_neigh
,
14512 "restartInTimerMsec",
14513 thread_timer_remain_second(
14518 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14519 p
->host
, thread_timer_remain_second(
14520 p
->t_pmax_restart
));
14523 json_object_boolean_true_add(
14525 "reducePrefixNumAndClearIpBgp");
14528 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14533 /* EBGP Multihop and GTSM */
14534 if (p
->sort
!= BGP_PEER_IBGP
) {
14536 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14537 json_object_int_add(json_neigh
,
14538 "externalBgpNbrMaxHopsAway",
14541 json_object_int_add(json_neigh
,
14542 "externalBgpNbrMaxHopsAway",
14545 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14547 " External BGP neighbor may be up to %d hops away.\n",
14551 " External BGP neighbor may be up to %d hops away.\n",
14556 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14557 json_object_int_add(json_neigh
,
14558 "internalBgpNbrMaxHopsAway",
14561 json_object_int_add(json_neigh
,
14562 "internalBgpNbrMaxHopsAway",
14565 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14567 " Internal BGP neighbor may be up to %d hops away.\n",
14571 " Internal BGP neighbor may be up to %d hops away.\n",
14576 /* Local address. */
14579 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14581 json_object_int_add(json_neigh
, "portLocal",
14582 ntohs(p
->su_local
->sin
.sin_port
));
14584 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14585 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14588 json_object_string_add(json_neigh
, "hostLocal",
14590 json_object_int_add(json_neigh
, "portLocal", -1);
14594 /* Remote address. */
14595 if (p
->su_remote
) {
14597 json_object_string_addf(json_neigh
, "hostForeign",
14598 "%pSU", p
->su_remote
);
14599 json_object_int_add(json_neigh
, "portForeign",
14600 ntohs(p
->su_remote
->sin
.sin_port
));
14602 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14604 ntohs(p
->su_remote
->sin
.sin_port
));
14607 json_object_string_add(json_neigh
, "hostForeign",
14609 json_object_int_add(json_neigh
, "portForeign", -1);
14613 /* Nexthop display. */
14616 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14618 json_object_string_addf(json_neigh
, "nexthopGlobal",
14619 "%pI6", &p
->nexthop
.v6_global
);
14620 json_object_string_addf(json_neigh
, "nexthopLocal",
14621 "%pI6", &p
->nexthop
.v6_local
);
14622 if (p
->shared_network
)
14623 json_object_string_add(json_neigh
,
14627 json_object_string_add(json_neigh
,
14629 "nonSharedNetwork");
14631 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14632 vty_out(vty
, "Nexthop global: %pI6\n",
14633 &p
->nexthop
.v6_global
);
14634 vty_out(vty
, "Nexthop local: %pI6\n",
14635 &p
->nexthop
.v6_local
);
14636 vty_out(vty
, "BGP connection: %s\n",
14637 p
->shared_network
? "shared network"
14638 : "non shared network");
14642 json_object_string_add(json_neigh
, "nexthop",
14644 json_object_string_add(json_neigh
, "nexthopGlobal",
14646 json_object_string_add(json_neigh
, "nexthopLocal",
14648 json_object_string_add(json_neigh
, "bgpConnection",
14653 /* Timer information. */
14655 json_object_int_add(json_neigh
, "connectRetryTimer",
14657 if (peer_established(p
)) {
14658 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14660 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14661 json_object_int_add(json_neigh
,
14662 "shutdownRttInMsecs",
14664 json_object_int_add(json_neigh
,
14665 "shutdownRttAfterCount",
14666 p
->rtt_keepalive_rcv
);
14670 json_object_int_add(
14671 json_neigh
, "nextStartTimerDueInMsecs",
14672 thread_timer_remain_second(p
->t_start
) * 1000);
14674 json_object_int_add(
14675 json_neigh
, "nextConnectTimerDueInMsecs",
14676 thread_timer_remain_second(p
->t_connect
)
14678 if (p
->t_routeadv
) {
14679 json_object_int_add(json_neigh
, "mraiInterval",
14681 json_object_int_add(
14682 json_neigh
, "mraiTimerExpireInMsecs",
14683 thread_timer_remain_second(p
->t_routeadv
)
14687 json_object_int_add(json_neigh
, "authenticationEnabled",
14691 json_object_string_add(json_neigh
, "readThread", "on");
14693 json_object_string_add(json_neigh
, "readThread", "off");
14695 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14696 json_object_string_add(json_neigh
, "writeThread", "on");
14698 json_object_string_add(json_neigh
, "writeThread",
14701 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14703 if (peer_established(p
)) {
14704 vty_out(vty
, "Estimated round trip time: %d ms\n",
14706 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14708 "Shutdown when RTT > %dms, count > %u\n",
14709 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14712 vty_out(vty
, "Next start timer due in %ld seconds\n",
14713 thread_timer_remain_second(p
->t_start
));
14715 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14716 thread_timer_remain_second(p
->t_connect
));
14719 "MRAI (interval %u) timer expires in %ld seconds\n",
14721 thread_timer_remain_second(p
->t_routeadv
));
14723 vty_out(vty
, "Peer Authentication Enabled\n");
14725 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14726 p
->t_read
? "on" : "off",
14727 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14732 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14733 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14734 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14737 vty_out(vty
, "\n");
14739 /* BFD information. */
14741 bgp_bfd_show_info(vty
, p
, json_neigh
);
14744 if (p
->conf_if
) /* Configured interface name. */
14745 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14746 else /* Configured IP address. */
14747 json_object_object_add(json
, p
->host
, json_neigh
);
14751 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14752 enum show_type type
,
14753 union sockunion
*su
,
14754 const char *conf_if
, afi_t afi
,
14757 struct listnode
*node
, *nnode
;
14759 bool found
= false;
14760 safi_t safi
= SAFI_UNICAST
;
14761 json_object
*json_neighbor
= NULL
;
14763 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14765 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14768 if ((peer
->afc
[afi
][safi
]) == 0)
14772 json_neighbor
= json_object_new_object();
14774 if (type
== show_all
) {
14775 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14778 json_object_object_add(json
, peer
->host
,
14781 } else if (type
== show_peer
) {
14784 && !strcmp(peer
->conf_if
, conf_if
))
14786 && !strcmp(peer
->hostname
, conf_if
))) {
14788 bgp_show_peer_gr_status(vty
, peer
,
14792 if (sockunion_same(&peer
->su
, su
)) {
14794 bgp_show_peer_gr_status(vty
, peer
,
14800 json_object_object_add(json
, peer
->host
,
14803 json_object_free(json_neighbor
);
14811 if (type
== show_peer
&& !found
) {
14813 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14815 vty_out(vty
, "%% No such neighbor\n");
14819 vty_out(vty
, "\n");
14821 return CMD_SUCCESS
;
14824 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14825 enum show_type type
, union sockunion
*su
,
14826 const char *conf_if
, bool use_json
,
14829 struct listnode
*node
, *nnode
;
14832 bool nbr_output
= false;
14833 afi_t afi
= AFI_MAX
;
14834 safi_t safi
= SAFI_MAX
;
14836 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14838 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14842 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14843 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14848 bgp_show_peer(vty
, peer
, use_json
, json
);
14854 && !strcmp(peer
->conf_if
, conf_if
))
14856 && !strcmp(peer
->hostname
, conf_if
))) {
14858 bgp_show_peer(vty
, peer
, use_json
,
14862 if (sockunion_same(&peer
->su
, su
)) {
14864 bgp_show_peer(vty
, peer
, use_json
,
14869 case show_ipv4_peer
:
14870 case show_ipv6_peer
:
14871 FOREACH_SAFI (safi
) {
14872 if (peer
->afc
[afi
][safi
]) {
14875 && !strcmp(peer
->conf_if
, conf_if
))
14877 && !strcmp(peer
->hostname
, conf_if
))) {
14879 bgp_show_peer(vty
, peer
, use_json
,
14884 if (sockunion_same(&peer
->su
, su
)) {
14886 bgp_show_peer(vty
, peer
, use_json
,
14894 case show_ipv4_all
:
14895 case show_ipv6_all
:
14896 FOREACH_SAFI (safi
) {
14897 if (peer
->afc
[afi
][safi
]) {
14898 bgp_show_peer(vty
, peer
, use_json
, json
);
14907 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14908 type
== show_ipv6_peer
) && !find
) {
14910 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14912 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14915 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14916 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14917 vty_out(vty
, "%% No BGP neighbors found\n");
14920 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14921 json
, JSON_C_TO_STRING_PRETTY
));
14923 vty_out(vty
, "\n");
14926 return CMD_SUCCESS
;
14929 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14930 enum show_type type
,
14931 const char *ip_str
,
14932 afi_t afi
, json_object
*json
)
14937 union sockunion su
;
14939 bgp
= bgp_get_default();
14945 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
14948 ret
= str2sockunion(ip_str
, &su
);
14950 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
14951 ip_str
, afi
, json
);
14953 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14956 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14960 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14961 enum show_type type
,
14962 const char *ip_str
,
14965 struct listnode
*node
, *nnode
;
14967 union sockunion su
;
14968 json_object
*json
= NULL
;
14969 int ret
, is_first
= 1;
14970 bool nbr_output
= false;
14973 vty_out(vty
, "{\n");
14975 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14978 if (!(json
= json_object_new_object())) {
14980 EC_BGP_JSON_MEM_ERROR
,
14981 "Unable to allocate memory for JSON object");
14983 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14987 json_object_int_add(json
, "vrfId",
14988 (bgp
->vrf_id
== VRF_UNKNOWN
)
14990 : (int64_t)bgp
->vrf_id
);
14991 json_object_string_add(
14993 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14998 vty_out(vty
, ",\n");
15002 vty_out(vty
, "\"%s\":",
15003 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15007 vty_out(vty
, "\nInstance %s:\n",
15008 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15013 if (type
== show_peer
|| type
== show_ipv4_peer
||
15014 type
== show_ipv6_peer
) {
15015 ret
= str2sockunion(ip_str
, &su
);
15017 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15020 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15023 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15026 json_object_free(json
);
15031 vty_out(vty
, "}\n");
15032 else if (!nbr_output
)
15033 vty_out(vty
, "%% BGP instance not found\n");
15036 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15037 enum show_type type
, const char *ip_str
,
15042 union sockunion su
;
15043 json_object
*json
= NULL
;
15046 if (strmatch(name
, "all")) {
15047 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15049 return CMD_SUCCESS
;
15051 bgp
= bgp_lookup_by_name(name
);
15054 json
= json_object_new_object();
15055 vty_json(vty
, json
);
15058 "%% BGP instance not found\n");
15060 return CMD_WARNING
;
15064 bgp
= bgp_get_default();
15068 json
= json_object_new_object();
15070 ret
= str2sockunion(ip_str
, &su
);
15072 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15075 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15078 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15081 json_object_free(json
);
15084 vty_out(vty
, "{}\n");
15086 vty_out(vty
, "%% BGP instance not found\n");
15089 return CMD_SUCCESS
;
15094 /* "show [ip] bgp neighbors graceful-restart" commands. */
15095 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15096 show_ip_bgp_neighbors_graceful_restart_cmd
,
15097 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15103 "Neighbor to display information about\n"
15104 "Neighbor to display information about\n"
15105 "Neighbor on BGP configured interface\n"
15109 char *sh_arg
= NULL
;
15110 enum show_type sh_type
;
15112 afi_t afi
= AFI_MAX
;
15113 bool uj
= use_json(argc
, argv
);
15115 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15120 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15121 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15122 || argv_find(argv
, argc
, "WORD", &idx
)) {
15123 sh_type
= show_peer
;
15124 sh_arg
= argv
[idx
]->arg
;
15126 sh_type
= show_all
;
15128 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15129 return CMD_SUCCESS
;
15132 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15136 /* "show [ip] bgp neighbors" commands. */
15137 DEFUN (show_ip_bgp_neighbors
,
15138 show_ip_bgp_neighbors_cmd
,
15139 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15143 BGP_INSTANCE_HELP_STR
15146 "Detailed information on TCP and BGP neighbor connections\n"
15147 "Neighbor to display information about\n"
15148 "Neighbor to display information about\n"
15149 "Neighbor on BGP configured interface\n"
15153 char *sh_arg
= NULL
;
15154 enum show_type sh_type
;
15155 afi_t afi
= AFI_MAX
;
15157 bool uj
= use_json(argc
, argv
);
15161 /* [<vrf> VIEWVRFNAME] */
15162 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15163 vrf
= argv
[idx
+ 1]->arg
;
15164 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15166 } else if (argv_find(argv
, argc
, "view", &idx
))
15167 /* [<view> VIEWVRFNAME] */
15168 vrf
= argv
[idx
+ 1]->arg
;
15172 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15173 sh_type
= show_ipv4_all
;
15175 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15176 sh_type
= show_ipv6_all
;
15179 sh_type
= show_all
;
15182 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15183 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15184 || argv_find(argv
, argc
, "WORD", &idx
)) {
15185 sh_type
= show_peer
;
15186 sh_arg
= argv
[idx
]->arg
;
15189 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15190 sh_type
= show_ipv4_peer
;
15191 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15192 sh_type
= show_ipv6_peer
;
15195 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15198 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15199 paths' and `show ip mbgp paths'. Those functions results are the
15201 DEFUN (show_ip_bgp_paths
,
15202 show_ip_bgp_paths_cmd
,
15203 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15208 "Path information\n")
15210 vty_out(vty
, "Address Refcnt Path\n");
15211 aspath_print_all_vty(vty
);
15212 return CMD_SUCCESS
;
15217 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15220 struct community
*com
;
15222 com
= (struct community
*)bucket
->data
;
15223 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15224 community_str(com
, false, false));
15227 /* Show BGP's community internal data. */
15228 DEFUN (show_ip_bgp_community_info
,
15229 show_ip_bgp_community_info_cmd
,
15230 "show [ip] bgp community-info",
15234 "List all bgp community information\n")
15236 vty_out(vty
, "Address Refcnt Community\n");
15238 hash_iterate(community_hash(),
15239 (void (*)(struct hash_bucket
*,
15240 void *))community_show_all_iterator
,
15243 return CMD_SUCCESS
;
15246 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15249 struct lcommunity
*lcom
;
15251 lcom
= (struct lcommunity
*)bucket
->data
;
15252 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15253 lcommunity_str(lcom
, false, false));
15256 /* Show BGP's community internal data. */
15257 DEFUN (show_ip_bgp_lcommunity_info
,
15258 show_ip_bgp_lcommunity_info_cmd
,
15259 "show ip bgp large-community-info",
15263 "List all bgp large-community information\n")
15265 vty_out(vty
, "Address Refcnt Large-community\n");
15267 hash_iterate(lcommunity_hash(),
15268 (void (*)(struct hash_bucket
*,
15269 void *))lcommunity_show_all_iterator
,
15272 return CMD_SUCCESS
;
15274 /* Graceful Restart */
15276 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15281 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15283 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15285 switch (bgp_global_gr_mode
) {
15287 case GLOBAL_HELPER
:
15288 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15292 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15295 case GLOBAL_DISABLE
:
15296 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15299 case GLOBAL_INVALID
:
15301 "Global BGP GR Mode Invalid\n");
15304 vty_out(vty
, "\n");
15307 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15308 enum show_type type
,
15309 const char *ip_str
,
15310 afi_t afi
, bool use_json
)
15312 json_object
*json
= NULL
;
15315 json
= json_object_new_object();
15317 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15320 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15322 bgp_show_neighbor_graceful_restart_vty(
15323 vty
, type
, ip_str
, afi
, json
);
15326 } else if (afi
!= AFI_MAX
) {
15327 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15331 json_object_free(json
);
15332 return CMD_ERR_INCOMPLETE
;
15336 vty_json(vty
, json
);
15338 return CMD_SUCCESS
;
15340 /* Graceful Restart */
15342 DEFUN (show_ip_bgp_attr_info
,
15343 show_ip_bgp_attr_info_cmd
,
15344 "show [ip] bgp attribute-info",
15348 "List all bgp attribute information\n")
15350 attr_show_all(vty
);
15351 return CMD_SUCCESS
;
15354 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15355 afi_t afi
, safi_t safi
,
15356 bool use_json
, json_object
*json
)
15359 struct listnode
*node
;
15362 enum vpn_policy_direction dir
;
15365 json_object
*json_import_vrfs
= NULL
;
15366 json_object
*json_export_vrfs
= NULL
;
15368 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15371 vty_json(vty
, json
);
15373 return CMD_WARNING
;
15376 /* Provide context for the block */
15377 json_object_string_add(json
, "vrf", name
? name
: "default");
15378 json_object_string_add(json
, "afiSafi",
15379 get_afi_safi_str(afi
, safi
, true));
15381 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15382 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15383 json_object_string_add(json
, "importFromVrfs", "none");
15384 json_object_string_add(json
, "importRts", "none");
15386 json_import_vrfs
= json_object_new_array();
15388 for (ALL_LIST_ELEMENTS_RO(
15389 bgp
->vpn_policy
[afi
].import_vrf
,
15391 json_object_array_add(json_import_vrfs
,
15392 json_object_new_string(vname
));
15394 json_object_object_add(json
, "importFromVrfs",
15396 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15397 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15398 ecom_str
= ecommunity_ecom2str(
15399 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15400 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15401 json_object_string_add(json
, "importRts",
15403 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15405 json_object_string_add(json
, "importRts",
15409 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15410 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15411 json_object_string_add(json
, "exportToVrfs", "none");
15412 json_object_string_add(json
, "routeDistinguisher",
15414 json_object_string_add(json
, "exportRts", "none");
15416 json_export_vrfs
= json_object_new_array();
15418 for (ALL_LIST_ELEMENTS_RO(
15419 bgp
->vpn_policy
[afi
].export_vrf
,
15421 json_object_array_add(json_export_vrfs
,
15422 json_object_new_string(vname
));
15423 json_object_object_add(json
, "exportToVrfs",
15425 json_object_string_addf(json
, "routeDistinguisher",
15427 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15429 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15430 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15431 ecom_str
= ecommunity_ecom2str(
15432 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15433 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15434 json_object_string_add(json
, "exportRts",
15436 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15438 json_object_string_add(json
, "exportRts",
15443 vty_json(vty
, json
);
15446 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15449 vty_out(vty
, "%% No such BGP instance exist\n");
15450 return CMD_WARNING
;
15453 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15454 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15456 "This VRF is not importing %s routes from any other VRF\n",
15457 get_afi_safi_str(afi
, safi
, false));
15460 "This VRF is importing %s routes from the following VRFs:\n",
15461 get_afi_safi_str(afi
, safi
, false));
15463 for (ALL_LIST_ELEMENTS_RO(
15464 bgp
->vpn_policy
[afi
].import_vrf
,
15466 vty_out(vty
, " %s\n", vname
);
15468 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15470 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15471 ecom_str
= ecommunity_ecom2str(
15472 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15473 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15474 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15476 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15478 vty_out(vty
, "Import RT(s):\n");
15481 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15482 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15484 "This VRF is not exporting %s routes to any other VRF\n",
15485 get_afi_safi_str(afi
, safi
, false));
15488 "This VRF is exporting %s routes to the following VRFs:\n",
15489 get_afi_safi_str(afi
, safi
, false));
15491 for (ALL_LIST_ELEMENTS_RO(
15492 bgp
->vpn_policy
[afi
].export_vrf
,
15494 vty_out(vty
, " %s\n", vname
);
15496 vty_out(vty
, "RD: %pRD\n",
15497 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15499 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15500 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15501 ecom_str
= ecommunity_ecom2str(
15502 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15503 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15504 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15505 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15507 vty_out(vty
, "Import RT(s):\n");
15511 return CMD_SUCCESS
;
15514 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15515 safi_t safi
, bool use_json
)
15517 struct listnode
*node
, *nnode
;
15519 char *vrf_name
= NULL
;
15520 json_object
*json
= NULL
;
15521 json_object
*json_vrf
= NULL
;
15522 json_object
*json_vrfs
= NULL
;
15525 json
= json_object_new_object();
15526 json_vrfs
= json_object_new_object();
15529 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15531 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15532 vrf_name
= bgp
->name
;
15535 json_vrf
= json_object_new_object();
15537 vty_out(vty
, "\nInstance %s:\n",
15538 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15539 ? VRF_DEFAULT_NAME
: bgp
->name
);
15541 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15543 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15544 json_object_object_add(json_vrfs
,
15545 VRF_DEFAULT_NAME
, json_vrf
);
15547 json_object_object_add(json_vrfs
, vrf_name
,
15553 json_object_object_add(json
, "vrfs", json_vrfs
);
15554 vty_json(vty
, json
);
15557 return CMD_SUCCESS
;
15560 /* "show [ip] bgp route-leak" command. */
15561 DEFUN (show_ip_bgp_route_leak
,
15562 show_ip_bgp_route_leak_cmd
,
15563 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15567 BGP_INSTANCE_HELP_STR
15570 "Route leaking information\n"
15574 afi_t afi
= AFI_MAX
;
15575 safi_t safi
= SAFI_MAX
;
15577 bool uj
= use_json(argc
, argv
);
15579 json_object
*json
= NULL
;
15581 /* show [ip] bgp */
15582 if (argv_find(argv
, argc
, "ip", &idx
)) {
15584 safi
= SAFI_UNICAST
;
15586 /* [vrf VIEWVRFNAME] */
15587 if (argv_find(argv
, argc
, "view", &idx
)) {
15589 "%% This command is not applicable to BGP views\n");
15590 return CMD_WARNING
;
15593 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15594 vrf
= argv
[idx
+ 1]->arg
;
15595 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15598 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15599 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15600 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15602 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15604 "%% This command is applicable only for unicast ipv4|ipv6\n");
15605 return CMD_WARNING
;
15608 if (vrf
&& strmatch(vrf
, "all"))
15609 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15612 json
= json_object_new_object();
15614 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15617 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15618 safi_t safi
, bool uj
)
15620 struct listnode
*node
, *nnode
;
15623 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15625 vty_out(vty
, "\nInstance %s:\n",
15626 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15630 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15634 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15635 int safi
, uint64_t subgrp_id
, bool uj
)
15640 if (strmatch(name
, "all")) {
15641 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15642 return CMD_SUCCESS
;
15644 bgp
= bgp_lookup_by_name(name
);
15647 bgp
= bgp_get_default();
15651 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15652 return CMD_SUCCESS
;
15655 DEFUN (show_ip_bgp_updgrps
,
15656 show_ip_bgp_updgrps_cmd
,
15657 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15661 BGP_INSTANCE_HELP_STR
15663 BGP_SAFI_WITH_LABEL_HELP_STR
15664 "Detailed info about dynamic update groups\n"
15665 "Specific subgroup to display detailed info for\n"
15669 afi_t afi
= AFI_IP6
;
15670 safi_t safi
= SAFI_UNICAST
;
15671 uint64_t subgrp_id
= 0;
15675 bool uj
= use_json(argc
, argv
);
15677 /* show [ip] bgp */
15678 if (argv_find(argv
, argc
, "ip", &idx
))
15680 /* [<vrf> VIEWVRFNAME] */
15681 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15682 vrf
= argv
[idx
+ 1]->arg
;
15683 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15685 } else if (argv_find(argv
, argc
, "view", &idx
))
15686 /* [<view> VIEWVRFNAME] */
15687 vrf
= argv
[idx
+ 1]->arg
;
15688 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15689 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15690 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15693 /* get subgroup id, if provided */
15695 if (argv
[idx
]->type
== VARIABLE_TKN
)
15696 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15698 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15701 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15702 show_bgp_instance_all_ipv6_updgrps_cmd
,
15703 "show [ip] bgp <view|vrf> all update-groups [json]",
15707 BGP_INSTANCE_ALL_HELP_STR
15708 "Detailed info about dynamic update groups\n"
15711 bool uj
= use_json(argc
, argv
);
15713 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15714 return CMD_SUCCESS
;
15717 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15718 show_bgp_l2vpn_evpn_updgrps_cmd
,
15719 "show [ip] bgp l2vpn evpn update-groups",
15723 "l2vpn address family\n"
15724 "evpn sub-address family\n"
15725 "Detailed info about dynamic update groups\n")
15728 uint64_t subgrp_id
= 0;
15730 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15731 return CMD_SUCCESS
;
15734 DEFUN (show_bgp_updgrps_stats
,
15735 show_bgp_updgrps_stats_cmd
,
15736 "show [ip] bgp update-groups statistics",
15740 "Detailed info about dynamic update groups\n"
15745 bgp
= bgp_get_default();
15747 update_group_show_stats(bgp
, vty
);
15749 return CMD_SUCCESS
;
15752 DEFUN (show_bgp_instance_updgrps_stats
,
15753 show_bgp_instance_updgrps_stats_cmd
,
15754 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15758 BGP_INSTANCE_HELP_STR
15759 "Detailed info about dynamic update groups\n"
15765 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15767 update_group_show_stats(bgp
, vty
);
15769 return CMD_SUCCESS
;
15772 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15773 afi_t afi
, safi_t safi
,
15774 const char *what
, uint64_t subgrp_id
)
15779 bgp
= bgp_lookup_by_name(name
);
15781 bgp
= bgp_get_default();
15784 if (!strcmp(what
, "advertise-queue"))
15785 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15787 else if (!strcmp(what
, "advertised-routes"))
15788 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15790 else if (!strcmp(what
, "packet-queue"))
15791 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15796 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15797 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15798 "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",
15799 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15801 "Detailed info about dynamic update groups\n"
15802 "Specific subgroup to display info for\n"
15803 "Advertisement queue\n"
15804 "Announced routes\n"
15807 uint64_t subgrp_id
= 0;
15811 subgrp_id
= strtoull(sgid
, NULL
, 10);
15816 afiz
= bgp_vty_afi_from_str(afi
);
15820 afiz
= bgp_vty_afi_from_str(afi
);
15821 if (afiz
!= AFI_IP
)
15823 "%% Cannot specify both 'ip' and 'ipv6'\n");
15824 return CMD_WARNING
;
15827 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15829 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15830 return CMD_SUCCESS
;
15833 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15836 struct listnode
*node
, *nnode
;
15837 struct prefix
*range
;
15842 const char *peer_status
;
15846 json_object
*json_peer_group
= NULL
;
15847 json_object
*json_peer_group_afc
= NULL
;
15848 json_object
*json_peer_group_members
= NULL
;
15849 json_object
*json_peer_group_dynamic
= NULL
;
15850 json_object
*json_peer_group_dynamic_af
= NULL
;
15851 json_object
*json_peer_group_ranges
= NULL
;
15853 conf
= group
->conf
;
15856 json_peer_group
= json_object_new_object();
15857 json_peer_group_afc
= json_object_new_array();
15860 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15862 json_object_int_add(json_peer_group
, "remoteAs",
15865 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15866 group
->name
, conf
->as
);
15867 } else if (conf
->as_type
== AS_INTERNAL
) {
15869 json_object_int_add(json_peer_group
, "remoteAs",
15872 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15873 group
->name
, group
->bgp
->as
);
15876 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15879 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15881 json_object_string_add(json_peer_group
, "type",
15884 vty_out(vty
, " Peer-group type is internal\n");
15887 json_object_string_add(json_peer_group
, "type",
15890 vty_out(vty
, " Peer-group type is external\n");
15893 /* Display AFs configured. */
15895 vty_out(vty
, " Configured address-families:");
15897 FOREACH_AFI_SAFI (afi
, safi
) {
15898 if (conf
->afc
[afi
][safi
]) {
15901 json_object_array_add(
15902 json_peer_group_afc
,
15903 json_object_new_string(get_afi_safi_str(
15904 afi
, safi
, false)));
15906 vty_out(vty
, " %s;",
15907 get_afi_safi_str(afi
, safi
, false));
15912 json_object_object_add(json_peer_group
,
15913 "addressFamiliesConfigured",
15914 json_peer_group_afc
);
15917 vty_out(vty
, " none\n");
15919 vty_out(vty
, "\n");
15922 /* Display listen ranges (for dynamic neighbors), if any */
15923 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15924 lr_count
= listcount(group
->listen_range
[afi
]);
15927 if (!json_peer_group_dynamic
)
15928 json_peer_group_dynamic
=
15929 json_object_new_object();
15931 json_peer_group_dynamic_af
=
15932 json_object_new_object();
15933 json_peer_group_ranges
=
15934 json_object_new_array();
15935 json_object_int_add(json_peer_group_dynamic_af
,
15936 "count", lr_count
);
15938 vty_out(vty
, " %d %s listen range(s)\n",
15939 lr_count
, afi2str(afi
));
15942 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15947 snprintfrr(buf
, sizeof(buf
), "%pFX",
15950 json_object_array_add(
15951 json_peer_group_ranges
,
15952 json_object_new_string(buf
));
15954 vty_out(vty
, " %pFX\n", range
);
15959 json_object_object_add(
15960 json_peer_group_dynamic_af
, "ranges",
15961 json_peer_group_ranges
);
15963 json_object_object_add(
15964 json_peer_group_dynamic
, afi2str(afi
),
15965 json_peer_group_dynamic_af
);
15970 if (json_peer_group_dynamic
)
15971 json_object_object_add(json_peer_group
, "dynamicRanges",
15972 json_peer_group_dynamic
);
15974 /* Display group members and their status */
15975 if (listcount(group
->peer
)) {
15977 json_peer_group_members
= json_object_new_object();
15979 vty_out(vty
, " Peer-group members:\n");
15980 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15981 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15982 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15983 peer_status
= "Idle (Admin)";
15984 else if (CHECK_FLAG(peer
->sflags
,
15985 PEER_STATUS_PREFIX_OVERFLOW
))
15986 peer_status
= "Idle (PfxCt)";
15988 peer_status
= lookup_msg(bgp_status_msg
,
15989 peer
->status
, NULL
);
15991 dynamic
= peer_dynamic_neighbor(peer
);
15994 json_object
*json_peer_group_member
=
15995 json_object_new_object();
15997 json_object_string_add(json_peer_group_member
,
15998 "status", peer_status
);
16001 json_object_boolean_true_add(
16002 json_peer_group_member
,
16005 json_object_object_add(json_peer_group_members
,
16007 json_peer_group_member
);
16009 vty_out(vty
, " %s %s %s \n", peer
->host
,
16010 dynamic
? "(dynamic)" : "",
16015 json_object_object_add(json_peer_group
, "members",
16016 json_peer_group_members
);
16020 json_object_object_add(json
, group
->name
, json_peer_group
);
16022 return CMD_SUCCESS
;
16025 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16026 const char *group_name
, bool uj
)
16029 struct listnode
*node
, *nnode
;
16030 struct peer_group
*group
;
16031 bool found
= false;
16032 json_object
*json
= NULL
;
16035 json
= json_object_new_object();
16037 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16041 vty_json(vty
, json
);
16043 vty_out(vty
, "%% BGP instance not found\n");
16045 return CMD_WARNING
;
16048 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16050 if (strmatch(group
->name
, group_name
)) {
16051 bgp_show_one_peer_group(vty
, group
, json
);
16056 bgp_show_one_peer_group(vty
, group
, json
);
16060 if (group_name
&& !found
&& !uj
)
16061 vty_out(vty
, "%% No such peer-group\n");
16064 vty_json(vty
, json
);
16066 return CMD_SUCCESS
;
16069 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16070 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16071 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16072 "Detailed information on BGP peer groups\n"
16073 "Peer group name\n" JSON_STR
)
16077 bool uj
= use_json(argc
, argv
);
16079 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16081 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16083 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16087 /* Redistribute VTY commands. */
16089 DEFUN (bgp_redistribute_ipv4
,
16090 bgp_redistribute_ipv4_cmd
,
16091 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16092 "Redistribute information from another routing protocol\n"
16093 FRR_IP_REDIST_HELP_STR_BGPD
)
16095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16096 int idx_protocol
= 1;
16099 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16101 vty_out(vty
, "%% Invalid route type\n");
16102 return CMD_WARNING_CONFIG_FAILED
;
16105 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16106 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16110 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16111 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16112 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16114 DEFUN (bgp_redistribute_ipv4_rmap
,
16115 bgp_redistribute_ipv4_rmap_cmd
,
16116 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16117 "Redistribute information from another routing protocol\n"
16118 FRR_IP_REDIST_HELP_STR_BGPD
16119 "Route map reference\n"
16120 "Pointer to route-map entries\n")
16122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16123 int idx_protocol
= 1;
16126 struct bgp_redist
*red
;
16128 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16129 vty
, argv
[idx_word
]->arg
);
16131 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16133 vty_out(vty
, "%% Invalid route type\n");
16134 return CMD_WARNING_CONFIG_FAILED
;
16137 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16139 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16140 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16144 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16145 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16146 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16147 "Route map reference\n"
16148 "Pointer to route-map entries\n")
16150 DEFUN (bgp_redistribute_ipv4_metric
,
16151 bgp_redistribute_ipv4_metric_cmd
,
16152 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16153 "Redistribute information from another routing protocol\n"
16154 FRR_IP_REDIST_HELP_STR_BGPD
16155 "Metric for redistributed routes\n"
16156 "Default metric\n")
16158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16159 int idx_protocol
= 1;
16160 int idx_number
= 3;
16163 struct bgp_redist
*red
;
16166 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16168 vty_out(vty
, "%% Invalid route type\n");
16169 return CMD_WARNING_CONFIG_FAILED
;
16171 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16173 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16174 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16175 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16179 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16180 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16181 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16182 "Metric for redistributed routes\n"
16183 "Default metric\n")
16185 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16186 bgp_redistribute_ipv4_rmap_metric_cmd
,
16187 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16188 "Redistribute information from another routing protocol\n"
16189 FRR_IP_REDIST_HELP_STR_BGPD
16190 "Route map reference\n"
16191 "Pointer to route-map entries\n"
16192 "Metric for redistributed routes\n"
16193 "Default metric\n")
16195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16196 int idx_protocol
= 1;
16198 int idx_number
= 5;
16201 struct bgp_redist
*red
;
16203 struct route_map
*route_map
=
16204 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16206 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16208 vty_out(vty
, "%% Invalid route type\n");
16209 return CMD_WARNING_CONFIG_FAILED
;
16211 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16213 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16215 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16216 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16217 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16221 bgp_redistribute_ipv4_rmap_metric
,
16222 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16223 "redistribute " FRR_IP_REDIST_STR_BGPD
16224 " route-map RMAP_NAME metric (0-4294967295)",
16225 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16226 "Route map reference\n"
16227 "Pointer to route-map entries\n"
16228 "Metric for redistributed routes\n"
16229 "Default metric\n")
16231 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16232 bgp_redistribute_ipv4_metric_rmap_cmd
,
16233 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16234 "Redistribute information from another routing protocol\n"
16235 FRR_IP_REDIST_HELP_STR_BGPD
16236 "Metric for redistributed routes\n"
16238 "Route map reference\n"
16239 "Pointer to route-map entries\n")
16241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16242 int idx_protocol
= 1;
16243 int idx_number
= 3;
16247 struct bgp_redist
*red
;
16249 struct route_map
*route_map
=
16250 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16252 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16254 vty_out(vty
, "%% Invalid route type\n");
16255 return CMD_WARNING_CONFIG_FAILED
;
16257 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16259 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16260 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16262 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16263 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16267 bgp_redistribute_ipv4_metric_rmap
,
16268 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16269 "redistribute " FRR_IP_REDIST_STR_BGPD
16270 " metric (0-4294967295) route-map RMAP_NAME",
16271 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16272 "Metric for redistributed routes\n"
16274 "Route map reference\n"
16275 "Pointer to route-map entries\n")
16277 DEFUN (bgp_redistribute_ipv4_ospf
,
16278 bgp_redistribute_ipv4_ospf_cmd
,
16279 "redistribute <ospf|table> (1-65535)",
16280 "Redistribute information from another routing protocol\n"
16281 "Open Shortest Path First (OSPFv2)\n"
16282 "Non-main Kernel Routing Table\n"
16283 "Instance ID/Table ID\n")
16285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16286 int idx_ospf_table
= 1;
16287 int idx_number
= 2;
16288 unsigned short instance
;
16289 unsigned short protocol
;
16291 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16293 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16294 protocol
= ZEBRA_ROUTE_OSPF
;
16296 protocol
= ZEBRA_ROUTE_TABLE
;
16298 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16299 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16302 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16303 "redistribute <ospf|table> (1-65535)",
16304 "Redistribute information from another routing protocol\n"
16305 "Open Shortest Path First (OSPFv2)\n"
16306 "Non-main Kernel Routing Table\n"
16307 "Instance ID/Table ID\n")
16309 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16310 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16311 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16312 "Redistribute information from another routing protocol\n"
16313 "Open Shortest Path First (OSPFv2)\n"
16314 "Non-main Kernel Routing Table\n"
16315 "Instance ID/Table ID\n"
16316 "Route map reference\n"
16317 "Pointer to route-map entries\n")
16319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16320 int idx_ospf_table
= 1;
16321 int idx_number
= 2;
16323 struct bgp_redist
*red
;
16324 unsigned short instance
;
16327 struct route_map
*route_map
=
16328 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16330 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16331 protocol
= ZEBRA_ROUTE_OSPF
;
16333 protocol
= ZEBRA_ROUTE_TABLE
;
16335 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16336 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16338 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16339 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16342 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16343 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16344 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16345 "Redistribute information from another routing protocol\n"
16346 "Open Shortest Path First (OSPFv2)\n"
16347 "Non-main Kernel Routing Table\n"
16348 "Instance ID/Table ID\n"
16349 "Route map reference\n"
16350 "Pointer to route-map entries\n")
16352 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16353 bgp_redistribute_ipv4_ospf_metric_cmd
,
16354 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16355 "Redistribute information from another routing protocol\n"
16356 "Open Shortest Path First (OSPFv2)\n"
16357 "Non-main Kernel Routing Table\n"
16358 "Instance ID/Table ID\n"
16359 "Metric for redistributed routes\n"
16360 "Default metric\n")
16362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16363 int idx_ospf_table
= 1;
16364 int idx_number
= 2;
16365 int idx_number_2
= 4;
16367 struct bgp_redist
*red
;
16368 unsigned short instance
;
16372 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16373 protocol
= ZEBRA_ROUTE_OSPF
;
16375 protocol
= ZEBRA_ROUTE_TABLE
;
16377 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16378 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16380 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16381 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16383 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16386 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16387 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16388 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16389 "Redistribute information from another routing protocol\n"
16390 "Open Shortest Path First (OSPFv2)\n"
16391 "Non-main Kernel Routing Table\n"
16392 "Instance ID/Table ID\n"
16393 "Metric for redistributed routes\n"
16394 "Default metric\n")
16396 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16397 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16398 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16399 "Redistribute information from another routing protocol\n"
16400 "Open Shortest Path First (OSPFv2)\n"
16401 "Non-main Kernel Routing Table\n"
16402 "Instance ID/Table ID\n"
16403 "Route map reference\n"
16404 "Pointer to route-map entries\n"
16405 "Metric for redistributed routes\n"
16406 "Default metric\n")
16408 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16409 int idx_ospf_table
= 1;
16410 int idx_number
= 2;
16412 int idx_number_2
= 6;
16414 struct bgp_redist
*red
;
16415 unsigned short instance
;
16418 struct route_map
*route_map
=
16419 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16421 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16422 protocol
= ZEBRA_ROUTE_OSPF
;
16424 protocol
= ZEBRA_ROUTE_TABLE
;
16426 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16427 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16429 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16431 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16432 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16434 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16438 bgp_redistribute_ipv4_ospf_rmap_metric
,
16439 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16440 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16441 "Redistribute information from another routing protocol\n"
16442 "Open Shortest Path First (OSPFv2)\n"
16443 "Non-main Kernel Routing Table\n"
16444 "Instance ID/Table ID\n"
16445 "Route map reference\n"
16446 "Pointer to route-map entries\n"
16447 "Metric for redistributed routes\n"
16448 "Default metric\n")
16450 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16451 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16452 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16453 "Redistribute information from another routing protocol\n"
16454 "Open Shortest Path First (OSPFv2)\n"
16455 "Non-main Kernel Routing Table\n"
16456 "Instance ID/Table ID\n"
16457 "Metric for redistributed routes\n"
16459 "Route map reference\n"
16460 "Pointer to route-map entries\n")
16462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16463 int idx_ospf_table
= 1;
16464 int idx_number
= 2;
16465 int idx_number_2
= 4;
16468 struct bgp_redist
*red
;
16469 unsigned short instance
;
16472 struct route_map
*route_map
=
16473 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16475 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16476 protocol
= ZEBRA_ROUTE_OSPF
;
16478 protocol
= ZEBRA_ROUTE_TABLE
;
16480 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16481 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16483 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16484 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16487 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16488 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16492 bgp_redistribute_ipv4_ospf_metric_rmap
,
16493 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16494 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16495 "Redistribute information from another routing protocol\n"
16496 "Open Shortest Path First (OSPFv2)\n"
16497 "Non-main Kernel Routing Table\n"
16498 "Instance ID/Table ID\n"
16499 "Metric for redistributed routes\n"
16501 "Route map reference\n"
16502 "Pointer to route-map entries\n")
16504 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16505 no_bgp_redistribute_ipv4_ospf_cmd
,
16506 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16508 "Redistribute information from another routing protocol\n"
16509 "Open Shortest Path First (OSPFv2)\n"
16510 "Non-main Kernel Routing Table\n"
16511 "Instance ID/Table ID\n"
16512 "Metric for redistributed routes\n"
16514 "Route map reference\n"
16515 "Pointer to route-map entries\n")
16517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16518 int idx_ospf_table
= 2;
16519 int idx_number
= 3;
16520 unsigned short instance
;
16523 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16524 protocol
= ZEBRA_ROUTE_OSPF
;
16526 protocol
= ZEBRA_ROUTE_TABLE
;
16528 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16529 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16533 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16534 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16536 "Redistribute information from another routing protocol\n"
16537 "Open Shortest Path First (OSPFv2)\n"
16538 "Non-main Kernel Routing Table\n"
16539 "Instance ID/Table ID\n"
16540 "Metric for redistributed routes\n"
16542 "Route map reference\n"
16543 "Pointer to route-map entries\n")
16545 DEFUN (no_bgp_redistribute_ipv4
,
16546 no_bgp_redistribute_ipv4_cmd
,
16547 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16549 "Redistribute information from another routing protocol\n"
16550 FRR_IP_REDIST_HELP_STR_BGPD
16551 "Metric for redistributed routes\n"
16553 "Route map reference\n"
16554 "Pointer to route-map entries\n")
16556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16557 int idx_protocol
= 2;
16560 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16562 vty_out(vty
, "%% Invalid route type\n");
16563 return CMD_WARNING_CONFIG_FAILED
;
16565 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16569 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16570 "no redistribute " FRR_IP_REDIST_STR_BGPD
16571 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16573 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16574 "Metric for redistributed routes\n"
16576 "Route map reference\n"
16577 "Pointer to route-map entries\n")
16579 DEFUN (bgp_redistribute_ipv6
,
16580 bgp_redistribute_ipv6_cmd
,
16581 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16582 "Redistribute information from another routing protocol\n"
16583 FRR_IP6_REDIST_HELP_STR_BGPD
)
16585 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16586 int idx_protocol
= 1;
16589 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16591 vty_out(vty
, "%% Invalid route type\n");
16592 return CMD_WARNING_CONFIG_FAILED
;
16595 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16596 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16599 DEFUN (bgp_redistribute_ipv6_rmap
,
16600 bgp_redistribute_ipv6_rmap_cmd
,
16601 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16602 "Redistribute information from another routing protocol\n"
16603 FRR_IP6_REDIST_HELP_STR_BGPD
16604 "Route map reference\n"
16605 "Pointer to route-map entries\n")
16607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16608 int idx_protocol
= 1;
16611 struct bgp_redist
*red
;
16613 struct route_map
*route_map
=
16614 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16616 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16618 vty_out(vty
, "%% Invalid route type\n");
16619 return CMD_WARNING_CONFIG_FAILED
;
16622 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16624 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16625 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16628 DEFUN (bgp_redistribute_ipv6_metric
,
16629 bgp_redistribute_ipv6_metric_cmd
,
16630 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16631 "Redistribute information from another routing protocol\n"
16632 FRR_IP6_REDIST_HELP_STR_BGPD
16633 "Metric for redistributed routes\n"
16634 "Default metric\n")
16636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16637 int idx_protocol
= 1;
16638 int idx_number
= 3;
16641 struct bgp_redist
*red
;
16644 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16646 vty_out(vty
, "%% Invalid route type\n");
16647 return CMD_WARNING_CONFIG_FAILED
;
16649 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16651 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16652 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16653 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16656 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16657 bgp_redistribute_ipv6_rmap_metric_cmd
,
16658 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16659 "Redistribute information from another routing protocol\n"
16660 FRR_IP6_REDIST_HELP_STR_BGPD
16661 "Route map reference\n"
16662 "Pointer to route-map entries\n"
16663 "Metric for redistributed routes\n"
16664 "Default metric\n")
16666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16667 int idx_protocol
= 1;
16669 int idx_number
= 5;
16672 struct bgp_redist
*red
;
16674 struct route_map
*route_map
=
16675 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16677 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16679 vty_out(vty
, "%% Invalid route type\n");
16680 return CMD_WARNING_CONFIG_FAILED
;
16682 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16684 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16686 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16687 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16689 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16692 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16693 bgp_redistribute_ipv6_metric_rmap_cmd
,
16694 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16695 "Redistribute information from another routing protocol\n"
16696 FRR_IP6_REDIST_HELP_STR_BGPD
16697 "Metric for redistributed routes\n"
16699 "Route map reference\n"
16700 "Pointer to route-map entries\n")
16702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16703 int idx_protocol
= 1;
16704 int idx_number
= 3;
16708 struct bgp_redist
*red
;
16710 struct route_map
*route_map
=
16711 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16713 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16715 vty_out(vty
, "%% Invalid route type\n");
16716 return CMD_WARNING_CONFIG_FAILED
;
16718 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16720 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16721 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16724 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16725 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16728 DEFUN (no_bgp_redistribute_ipv6
,
16729 no_bgp_redistribute_ipv6_cmd
,
16730 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16732 "Redistribute information from another routing protocol\n"
16733 FRR_IP6_REDIST_HELP_STR_BGPD
16734 "Metric for redistributed routes\n"
16736 "Route map reference\n"
16737 "Pointer to route-map entries\n")
16739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16740 int idx_protocol
= 2;
16743 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16745 vty_out(vty
, "%% Invalid route type\n");
16746 return CMD_WARNING_CONFIG_FAILED
;
16749 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16752 /* Neighbor update tcp-mss. */
16753 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16754 const char *tcp_mss_str
)
16757 uint32_t tcp_mss_val
= 0;
16759 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16761 return CMD_WARNING_CONFIG_FAILED
;
16764 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16765 peer_tcp_mss_set(peer
, tcp_mss_val
);
16767 peer_tcp_mss_unset(peer
);
16770 return CMD_SUCCESS
;
16773 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16774 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16775 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16776 "TCP max segment size\n"
16779 int peer_index
= 1;
16783 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16784 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16785 argv
[mss_index
]->arg
);
16788 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16789 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16790 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16791 "TCP max segment size\n"
16794 int peer_index
= 2;
16797 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16798 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16801 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16802 "[no$no] bgp retain route-target all",
16804 "Retain BGP updates\n"
16805 "Retain BGP updates based on route-target values\n"
16806 "Retain all BGP updates\n")
16809 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16811 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16812 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16813 if (check
!= !no
) {
16815 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16816 [bgp_node_safi(vty
)],
16817 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16819 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16820 [bgp_node_safi(vty
)],
16821 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16822 /* trigger a flush to re-sync with ADJ-RIB-in */
16823 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16824 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16826 return CMD_SUCCESS
;
16829 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16830 afi_t afi
, safi_t safi
)
16834 /* Unicast redistribution only. */
16835 if (safi
!= SAFI_UNICAST
)
16838 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16839 /* Redistribute BGP does not make sense. */
16840 if (i
!= ZEBRA_ROUTE_BGP
) {
16841 struct list
*red_list
;
16842 struct listnode
*node
;
16843 struct bgp_redist
*red
;
16845 red_list
= bgp
->redist
[afi
][i
];
16849 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16850 /* "redistribute" configuration. */
16851 vty_out(vty
, " redistribute %s",
16852 zebra_route_string(i
));
16854 vty_out(vty
, " %d", red
->instance
);
16855 if (red
->redist_metric_flag
)
16856 vty_out(vty
, " metric %u",
16857 red
->redist_metric
);
16858 if (red
->rmap
.name
)
16859 vty_out(vty
, " route-map %s",
16861 vty_out(vty
, "\n");
16867 /* peer-group helpers for config-write */
16869 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16871 if (!peer_group_active(peer
)) {
16872 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16873 return !CHECK_FLAG(peer
->flags
, flag
);
16875 return !!CHECK_FLAG(peer
->flags
, flag
);
16878 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16881 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16884 if (!peer_group_active(peer
)) {
16885 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16886 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16888 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16891 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16894 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16895 uint8_t type
, int direct
)
16897 struct bgp_filter
*filter
;
16899 if (peer_group_active(peer
))
16900 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16903 filter
= &peer
->filter
[afi
][safi
];
16905 case PEER_FT_DISTRIBUTE_LIST
:
16906 return !!(filter
->dlist
[direct
].name
);
16907 case PEER_FT_FILTER_LIST
:
16908 return !!(filter
->aslist
[direct
].name
);
16909 case PEER_FT_PREFIX_LIST
:
16910 return !!(filter
->plist
[direct
].name
);
16911 case PEER_FT_ROUTE_MAP
:
16912 return !!(filter
->map
[direct
].name
);
16913 case PEER_FT_UNSUPPRESS_MAP
:
16914 return !!(filter
->usmap
.name
);
16915 case PEER_FT_ADVERTISE_MAP
:
16916 return !!(filter
->advmap
.aname
16917 && ((filter
->advmap
.condition
== direct
)
16918 && filter
->advmap
.cname
));
16924 /* Return true if the addpath type is set for peer and different from
16927 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16930 enum bgp_addpath_strat type
, g_type
;
16932 type
= peer
->addpath_type
[afi
][safi
];
16934 if (type
!= BGP_ADDPATH_NONE
) {
16935 if (peer_group_active(peer
)) {
16936 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16938 if (type
!= g_type
)
16950 /* This is part of the address-family block (unicast only) */
16951 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16955 uint32_t tovpn_sid_index
= 0;
16957 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16958 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16959 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16960 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16961 bgp
->vpn_policy
[afi
]
16962 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16964 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16965 bgp
->vpn_policy
[afi
]
16966 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16968 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16969 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16970 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16971 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16974 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16975 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16977 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16980 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16981 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16982 bgp
->vpn_policy
[afi
].tovpn_label
);
16986 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16987 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16988 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16989 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16990 } else if (tovpn_sid_index
!= 0) {
16991 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16995 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16996 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16997 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16999 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17000 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17002 char buf
[PREFIX_STRLEN
];
17003 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17004 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17007 vty_out(vty
, "%*snexthop vpn export %s\n",
17011 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17012 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17014 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17015 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17017 char *b
= ecommunity_ecom2str(
17018 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17019 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17020 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17021 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17023 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17024 char *b
= ecommunity_ecom2str(
17025 bgp
->vpn_policy
[afi
]
17026 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17027 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17028 ECOMMUNITY_ROUTE_TARGET
);
17029 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17030 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17032 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17033 char *b
= ecommunity_ecom2str(
17034 bgp
->vpn_policy
[afi
]
17035 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17036 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17037 ECOMMUNITY_ROUTE_TARGET
);
17038 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17039 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17043 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17044 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17045 bgp
->vpn_policy
[afi
]
17046 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17048 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17049 char *b
= ecommunity_ecom2str(
17050 bgp
->vpn_policy
[afi
]
17051 .import_redirect_rtlist
,
17052 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17053 ECOMMUNITY_ROUTE_TARGET
);
17055 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17056 != ECOMMUNITY_SIZE
)
17057 vty_out(vty
, "%*srt6 redirect import %s\n",
17060 vty_out(vty
, "%*srt redirect import %s\n",
17062 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17066 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17067 afi_t afi
, safi_t safi
)
17069 struct bgp_filter
*filter
;
17073 filter
= &peer
->filter
[afi
][safi
];
17075 /* distribute-list. */
17076 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17078 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17079 filter
->dlist
[FILTER_IN
].name
);
17081 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17083 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17084 filter
->dlist
[FILTER_OUT
].name
);
17087 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17089 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17090 filter
->plist
[FILTER_IN
].name
);
17092 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17094 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17095 filter
->plist
[FILTER_OUT
].name
);
17098 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17099 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17100 filter
->map
[RMAP_IN
].name
);
17102 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17104 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17105 filter
->map
[RMAP_OUT
].name
);
17107 /* unsuppress-map */
17108 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17109 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17110 filter
->usmap
.name
);
17112 /* advertise-map : always applied in OUT direction*/
17113 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17114 CONDITION_NON_EXIST
))
17116 " neighbor %s advertise-map %s non-exist-map %s\n",
17117 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17119 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17121 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17122 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17125 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17127 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17128 filter
->aslist
[FILTER_IN
].name
);
17130 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17132 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17133 filter
->aslist
[FILTER_OUT
].name
);
17136 /* BGP peer configuration display function. */
17137 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17140 struct peer
*g_peer
= NULL
;
17142 int if_pg_printed
= false;
17143 int if_ras_printed
= false;
17145 /* Skip dynamic neighbors. */
17146 if (peer_dynamic_neighbor(peer
))
17150 addr
= peer
->conf_if
;
17154 /************************************
17155 ****** Global to the neighbor ******
17156 ************************************/
17157 if (peer
->conf_if
) {
17158 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17159 vty_out(vty
, " neighbor %s interface v6only", addr
);
17161 vty_out(vty
, " neighbor %s interface", addr
);
17163 if (peer_group_active(peer
)) {
17164 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17165 if_pg_printed
= true;
17166 } else if (peer
->as_type
== AS_SPECIFIED
) {
17167 vty_out(vty
, " remote-as %u", peer
->as
);
17168 if_ras_printed
= true;
17169 } else if (peer
->as_type
== AS_INTERNAL
) {
17170 vty_out(vty
, " remote-as internal");
17171 if_ras_printed
= true;
17172 } else if (peer
->as_type
== AS_EXTERNAL
) {
17173 vty_out(vty
, " remote-as external");
17174 if_ras_printed
= true;
17177 vty_out(vty
, "\n");
17180 /* remote-as and peer-group */
17181 /* peer is a member of a peer-group */
17182 if (peer_group_active(peer
)) {
17183 g_peer
= peer
->group
->conf
;
17185 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17186 if (peer
->as_type
== AS_SPECIFIED
) {
17187 vty_out(vty
, " neighbor %s remote-as %u\n",
17189 } else if (peer
->as_type
== AS_INTERNAL
) {
17191 " neighbor %s remote-as internal\n",
17193 } else if (peer
->as_type
== AS_EXTERNAL
) {
17195 " neighbor %s remote-as external\n",
17200 /* For swpX peers we displayed the peer-group
17201 * via 'neighbor swpX interface peer-group PGNAME' */
17202 if (!if_pg_printed
)
17203 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17204 peer
->group
->name
);
17207 /* peer is NOT a member of a peer-group */
17209 /* peer is a peer-group, declare the peer-group */
17210 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17211 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17214 if (!if_ras_printed
) {
17215 if (peer
->as_type
== AS_SPECIFIED
) {
17216 vty_out(vty
, " neighbor %s remote-as %u\n",
17218 } else if (peer
->as_type
== AS_INTERNAL
) {
17220 " neighbor %s remote-as internal\n",
17222 } else if (peer
->as_type
== AS_EXTERNAL
) {
17224 " neighbor %s remote-as external\n",
17231 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17232 vty_out(vty
, " neighbor %s local-as %u", addr
,
17233 peer
->change_local_as
);
17234 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17235 vty_out(vty
, " no-prepend");
17236 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17237 vty_out(vty
, " replace-as");
17238 vty_out(vty
, "\n");
17243 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17247 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17248 if (peer
->tx_shutdown_message
)
17249 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17250 peer
->tx_shutdown_message
);
17252 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17255 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17256 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17257 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17260 if (peer
->bfd_config
)
17261 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17264 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17265 vty_out(vty
, " neighbor %s password %s\n", addr
,
17268 /* neighbor solo */
17269 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17270 if (!peer_group_active(peer
)) {
17271 vty_out(vty
, " neighbor %s solo\n", addr
);
17276 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17277 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17280 /* Local interface name */
17281 if (peer
->ifname
) {
17282 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17285 /* TCP max segment size */
17286 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17287 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17290 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17291 vty_out(vty
, " neighbor %s passive\n", addr
);
17293 /* ebgp-multihop */
17294 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17295 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17296 && peer
->ttl
== MAXTTL
)) {
17297 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17298 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17304 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17305 vty_out(vty
, " neighbor %s aigp\n", addr
);
17307 /* graceful-shutdown */
17308 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17309 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17312 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17313 peer
->local_role
!= ROLE_UNDEFINED
)
17314 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17315 bgp_get_name_by_role(peer
->local_role
),
17316 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17320 /* ttl-security hops */
17321 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17322 if (!peer_group_active(peer
)
17323 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17324 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17325 addr
, peer
->gtsm_hops
);
17329 /* disable-connected-check */
17330 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17331 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17333 /* link-bw-encoding-ieee */
17334 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17335 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17338 /* extended-optional-parameters */
17339 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17340 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17343 /* enforce-first-as */
17344 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17345 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17347 /* update-source */
17348 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17349 if (peer
->update_source
)
17350 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17351 peer
->update_source
);
17352 else if (peer
->update_if
)
17353 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17357 /* advertisement-interval */
17358 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17359 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17363 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17364 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17365 peer
->keepalive
, peer
->holdtime
);
17367 /* timers connect */
17368 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17369 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17371 /* need special-case handling for changed default values due to
17372 * config profile / version (because there is no "timers bgp connect"
17373 * command, we need to save this per-peer :/)
17375 else if (!peer_group_active(peer
) && !peer
->connect
&&
17376 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17377 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17378 peer
->bgp
->default_connect_retry
);
17380 /* timers delayopen */
17381 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17382 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17384 /* Save config even though flag is not set if default values have been
17387 else if (!peer_group_active(peer
) && !peer
->delayopen
17388 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17389 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17390 peer
->bgp
->default_delayopen
);
17392 /* capability dynamic */
17393 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17394 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17396 /* capability extended-nexthop */
17397 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17398 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17401 " no neighbor %s capability extended-nexthop\n",
17403 else if (!peer
->conf_if
)
17405 " neighbor %s capability extended-nexthop\n",
17409 /* dont-capability-negotiation */
17410 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17411 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17413 /* override-capability */
17414 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17415 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17417 /* strict-capability-match */
17418 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17419 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17421 /* Sender side AS path loop detection. */
17422 if (peer
->as_path_loop_detection
)
17423 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17426 /* path-attribute discard */
17427 char discard_attrs_str
[BUFSIZ
] = {0};
17428 bool discard_attrs
= bgp_path_attribute_discard(
17429 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17432 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17433 discard_attrs_str
);
17435 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17436 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17438 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17439 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17441 " neighbor %s graceful-restart-helper\n", addr
);
17442 } else if (CHECK_FLAG(
17443 peer
->peer_gr_new_status_flag
,
17444 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17446 " neighbor %s graceful-restart\n", addr
);
17448 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17449 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17451 peer
->peer_gr_new_status_flag
,
17452 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17453 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17459 /* BGP peer configuration display function. */
17460 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17461 struct peer
*peer
, afi_t afi
, safi_t safi
)
17463 struct peer
*g_peer
= NULL
;
17465 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17467 /* Skip dynamic neighbors. */
17468 if (peer_dynamic_neighbor(peer
))
17472 addr
= peer
->conf_if
;
17476 /************************************
17477 ****** Per AF to the neighbor ******
17478 ************************************/
17479 if (peer_group_active(peer
)) {
17480 g_peer
= peer
->group
->conf
;
17482 /* If the peer-group is active but peer is not, print a 'no
17484 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17485 vty_out(vty
, " no neighbor %s activate\n", addr
);
17488 /* If the peer-group is not active but peer is, print an
17490 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17491 vty_out(vty
, " neighbor %s activate\n", addr
);
17494 if (peer
->afc
[afi
][safi
]) {
17495 if (safi
== SAFI_ENCAP
)
17496 vty_out(vty
, " neighbor %s activate\n", addr
);
17497 else if (!bgp
->default_af
[afi
][safi
])
17498 vty_out(vty
, " neighbor %s activate\n", addr
);
17500 if (bgp
->default_af
[afi
][safi
])
17501 vty_out(vty
, " no neighbor %s activate\n",
17506 /* addpath TX knobs */
17507 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17508 switch (peer
->addpath_type
[afi
][safi
]) {
17509 case BGP_ADDPATH_ALL
:
17510 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17513 case BGP_ADDPATH_BEST_PER_AS
:
17515 " neighbor %s addpath-tx-bestpath-per-AS\n",
17518 case BGP_ADDPATH_MAX
:
17519 case BGP_ADDPATH_NONE
:
17524 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17525 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17527 /* ORF capability. */
17528 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17529 || peergroup_af_flag_check(peer
, afi
, safi
,
17530 PEER_FLAG_ORF_PREFIX_RM
)) {
17531 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17533 if (peergroup_af_flag_check(peer
, afi
, safi
,
17534 PEER_FLAG_ORF_PREFIX_SM
)
17535 && peergroup_af_flag_check(peer
, afi
, safi
,
17536 PEER_FLAG_ORF_PREFIX_RM
))
17537 vty_out(vty
, " both");
17538 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17539 PEER_FLAG_ORF_PREFIX_SM
))
17540 vty_out(vty
, " send");
17542 vty_out(vty
, " receive");
17543 vty_out(vty
, "\n");
17546 /* Route reflector client. */
17547 if (peergroup_af_flag_check(peer
, afi
, safi
,
17548 PEER_FLAG_REFLECTOR_CLIENT
)) {
17549 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17552 /* next-hop-self force */
17553 if (peergroup_af_flag_check(peer
, afi
, safi
,
17554 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17555 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17558 /* next-hop-self */
17559 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17560 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17563 /* remove-private-AS */
17564 if (peergroup_af_flag_check(peer
, afi
, safi
,
17565 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17566 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17570 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17571 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17572 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17576 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17577 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17578 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17581 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17582 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17583 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17587 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17588 vty_out(vty
, " neighbor %s as-override\n", addr
);
17591 /* send-community print. */
17592 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17593 PEER_FLAG_SEND_COMMUNITY
);
17594 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17595 PEER_FLAG_SEND_EXT_COMMUNITY
);
17596 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17597 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17599 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17600 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17603 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17606 " no neighbor %s send-community extended\n",
17610 vty_out(vty
, " no neighbor %s send-community large\n",
17614 /* Default information */
17615 if (peergroup_af_flag_check(peer
, afi
, safi
,
17616 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17617 vty_out(vty
, " neighbor %s default-originate", addr
);
17619 if (peer
->default_rmap
[afi
][safi
].name
)
17620 vty_out(vty
, " route-map %s",
17621 peer
->default_rmap
[afi
][safi
].name
);
17623 vty_out(vty
, "\n");
17626 /* Soft reconfiguration inbound. */
17627 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17628 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17632 /* maximum-prefix. */
17633 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17634 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17635 peer
->pmax
[afi
][safi
]);
17637 if (peer
->pmax_threshold
[afi
][safi
]
17638 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17639 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17640 if (peer_af_flag_check(peer
, afi
, safi
,
17641 PEER_FLAG_MAX_PREFIX_WARNING
))
17642 vty_out(vty
, " warning-only");
17643 if (peer
->pmax_restart
[afi
][safi
])
17644 vty_out(vty
, " restart %u",
17645 peer
->pmax_restart
[afi
][safi
]);
17646 if (peer_af_flag_check(peer
, afi
, safi
,
17647 PEER_FLAG_MAX_PREFIX_FORCE
))
17648 vty_out(vty
, " force");
17650 vty_out(vty
, "\n");
17653 /* maximum-prefix-out */
17654 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17655 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17656 addr
, peer
->pmax_out
[afi
][safi
]);
17658 /* Route server client. */
17659 if (peergroup_af_flag_check(peer
, afi
, safi
,
17660 PEER_FLAG_RSERVER_CLIENT
)) {
17661 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17664 /* Nexthop-local unchanged. */
17665 if (peergroup_af_flag_check(peer
, afi
, safi
,
17666 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17667 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17670 /* allowas-in <1-10> */
17671 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17672 if (peer_af_flag_check(peer
, afi
, safi
,
17673 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17674 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17675 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17676 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17678 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17679 peer
->allowas_in
[afi
][safi
]);
17684 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17685 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17688 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17689 char *soo_str
= ecommunity_ecom2str(
17690 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17692 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17693 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17697 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17698 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17699 peer
->weight
[afi
][safi
]);
17702 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17704 /* atribute-unchanged. */
17705 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17706 || (safi
!= SAFI_EVPN
17707 && peer_af_flag_check(peer
, afi
, safi
,
17708 PEER_FLAG_NEXTHOP_UNCHANGED
))
17709 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17711 if (!peer_group_active(peer
)
17712 || peergroup_af_flag_check(peer
, afi
, safi
,
17713 PEER_FLAG_AS_PATH_UNCHANGED
)
17714 || peergroup_af_flag_check(peer
, afi
, safi
,
17715 PEER_FLAG_NEXTHOP_UNCHANGED
)
17716 || peergroup_af_flag_check(peer
, afi
, safi
,
17717 PEER_FLAG_MED_UNCHANGED
)) {
17720 " neighbor %s attribute-unchanged%s%s%s\n",
17722 peer_af_flag_check(peer
, afi
, safi
,
17723 PEER_FLAG_AS_PATH_UNCHANGED
)
17726 peer_af_flag_check(peer
, afi
, safi
,
17727 PEER_FLAG_NEXTHOP_UNCHANGED
)
17730 peer_af_flag_check(peer
, afi
, safi
,
17731 PEER_FLAG_MED_UNCHANGED
)
17738 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17741 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17742 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17743 vty_out(vty
, " no bgp retain route-target all\n");
17746 /* Address family based peer configuration display. */
17747 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17751 struct peer_group
*group
;
17752 struct listnode
*node
, *nnode
;
17755 vty_frame(vty
, " !\n address-family ");
17756 if (afi
== AFI_IP
) {
17757 if (safi
== SAFI_UNICAST
)
17758 vty_frame(vty
, "ipv4 unicast");
17759 else if (safi
== SAFI_LABELED_UNICAST
)
17760 vty_frame(vty
, "ipv4 labeled-unicast");
17761 else if (safi
== SAFI_MULTICAST
)
17762 vty_frame(vty
, "ipv4 multicast");
17763 else if (safi
== SAFI_MPLS_VPN
)
17764 vty_frame(vty
, "ipv4 vpn");
17765 else if (safi
== SAFI_ENCAP
)
17766 vty_frame(vty
, "ipv4 encap");
17767 else if (safi
== SAFI_FLOWSPEC
)
17768 vty_frame(vty
, "ipv4 flowspec");
17769 } else if (afi
== AFI_IP6
) {
17770 if (safi
== SAFI_UNICAST
)
17771 vty_frame(vty
, "ipv6 unicast");
17772 else if (safi
== SAFI_LABELED_UNICAST
)
17773 vty_frame(vty
, "ipv6 labeled-unicast");
17774 else if (safi
== SAFI_MULTICAST
)
17775 vty_frame(vty
, "ipv6 multicast");
17776 else if (safi
== SAFI_MPLS_VPN
)
17777 vty_frame(vty
, "ipv6 vpn");
17778 else if (safi
== SAFI_ENCAP
)
17779 vty_frame(vty
, "ipv6 encap");
17780 else if (safi
== SAFI_FLOWSPEC
)
17781 vty_frame(vty
, "ipv6 flowspec");
17782 } else if (afi
== AFI_L2VPN
) {
17783 if (safi
== SAFI_EVPN
)
17784 vty_frame(vty
, "l2vpn evpn");
17786 vty_frame(vty
, "\n");
17788 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17790 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17792 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17794 /* BGP flag dampening. */
17795 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17796 bgp_config_write_damp(vty
, afi
, safi
);
17798 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17799 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17801 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17802 /* Do not display doppelganger peers */
17803 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17804 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17807 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17808 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17810 if (safi
== SAFI_EVPN
)
17811 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17813 if (safi
== SAFI_FLOWSPEC
)
17814 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17816 if (safi
== SAFI_MPLS_VPN
)
17817 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17819 if (safi
== SAFI_UNICAST
) {
17820 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17821 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17822 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17824 vty_out(vty
, " export vpn\n");
17826 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17827 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17829 vty_out(vty
, " import vpn\n");
17831 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17832 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17835 for (ALL_LIST_ELEMENTS_RO(
17836 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17838 vty_out(vty
, " import vrf %s\n", name
);
17842 vty_endframe(vty
, " exit-address-family\n");
17845 int bgp_config_write(struct vty
*vty
)
17848 struct peer_group
*group
;
17850 struct listnode
*node
, *nnode
;
17851 struct listnode
*mnode
, *mnnode
;
17854 uint32_t tovpn_sid_index
= 0;
17856 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17857 vty_out(vty
, "bgp route-map delay-timer %u\n",
17858 bm
->rmap_update_timer
);
17860 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17861 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17862 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17863 vty_out(vty
, " %d", bm
->v_establish_wait
);
17864 vty_out(vty
, "\n");
17867 if (bm
->wait_for_fib
)
17868 vty_out(vty
, "bgp suppress-fib-pending\n");
17870 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17871 vty_out(vty
, "bgp graceful-shutdown\n");
17873 /* No-RIB (Zebra) option flag configuration */
17874 if (bgp_option_check(BGP_OPT_NO_FIB
))
17875 vty_out(vty
, "bgp no-rib\n");
17877 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17878 vty_out(vty
, "bgp send-extra-data zebra\n");
17880 /* BGP session DSCP value */
17881 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17882 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17884 /* BGP InQ limit */
17885 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
17886 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17888 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
17889 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
17891 /* BGP configuration. */
17892 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17894 /* skip all auto created vrf as they dont have user config */
17895 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17898 /* Router bgp ASN */
17899 vty_out(vty
, "router bgp %u", bgp
->as
);
17902 vty_out(vty
, " %s %s",
17903 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17904 ? "view" : "vrf", bgp
->name
);
17905 vty_out(vty
, "\n");
17907 /* BGP fast-external-failover. */
17908 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17909 vty_out(vty
, " no bgp fast-external-failover\n");
17911 /* BGP router ID. */
17912 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17913 vty_out(vty
, " bgp router-id %pI4\n",
17914 &bgp
->router_id_static
);
17916 /* Suppress fib pending */
17917 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17918 vty_out(vty
, " bgp suppress-fib-pending\n");
17920 /* BGP log-neighbor-changes. */
17921 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17922 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17923 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17924 CHECK_FLAG(bgp
->flags
,
17925 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17929 /* BGP configuration. */
17930 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17931 vty_out(vty
, " bgp always-compare-med\n");
17933 /* RFC8212 default eBGP policy. */
17934 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17935 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17936 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17937 CHECK_FLAG(bgp
->flags
,
17938 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17942 /* draft-ietf-idr-deprecate-as-set-confed-set */
17943 if (bgp
->reject_as_sets
)
17944 vty_out(vty
, " bgp reject-as-sets\n");
17946 /* Suppress duplicate updates if the route actually not changed
17948 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17949 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17950 vty_out(vty
, " %sbgp suppress-duplicates\n",
17951 CHECK_FLAG(bgp
->flags
,
17952 BGP_FLAG_SUPPRESS_DUPLICATES
)
17956 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17958 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17959 SAVE_BGP_HARD_ADMIN_RESET
)
17960 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17961 CHECK_FLAG(bgp
->flags
,
17962 BGP_FLAG_HARD_ADMIN_RESET
)
17966 /* BGP default <afi>-<safi> */
17967 FOREACH_AFI_SAFI (afi
, safi
) {
17968 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17969 if (!bgp
->default_af
[afi
][safi
])
17970 vty_out(vty
, " no bgp default %s\n",
17971 get_bgp_default_af_flag(afi
,
17973 } else if (bgp
->default_af
[afi
][safi
])
17974 vty_out(vty
, " bgp default %s\n",
17975 get_bgp_default_af_flag(afi
, safi
));
17978 /* BGP default local-preference. */
17979 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17980 vty_out(vty
, " bgp default local-preference %u\n",
17981 bgp
->default_local_pref
);
17983 /* BGP default show-hostname */
17984 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17985 != SAVE_BGP_SHOW_HOSTNAME
)
17986 vty_out(vty
, " %sbgp default show-hostname\n",
17987 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17991 /* BGP default show-nexthop-hostname */
17992 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17993 != SAVE_BGP_SHOW_HOSTNAME
)
17994 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17995 CHECK_FLAG(bgp
->flags
,
17996 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18000 /* BGP default subgroup-pkt-queue-max. */
18001 if (bgp
->default_subgroup_pkt_queue_max
18002 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18003 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18004 bgp
->default_subgroup_pkt_queue_max
);
18006 /* BGP client-to-client reflection. */
18007 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18008 vty_out(vty
, " no bgp client-to-client reflection\n");
18010 /* BGP cluster ID. */
18011 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18012 vty_out(vty
, " bgp cluster-id %pI4\n",
18015 /* Disable ebgp connected nexthop check */
18016 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18018 " bgp disable-ebgp-connected-route-check\n");
18020 /* Confederation identifier*/
18021 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18022 vty_out(vty
, " bgp confederation identifier %u\n",
18025 /* Confederation peer */
18026 if (bgp
->confed_peers_cnt
> 0) {
18029 vty_out(vty
, " bgp confederation peers");
18031 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18032 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18034 vty_out(vty
, "\n");
18037 /* BGP deterministic-med. */
18038 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18039 != SAVE_BGP_DETERMINISTIC_MED
)
18040 vty_out(vty
, " %sbgp deterministic-med\n",
18041 CHECK_FLAG(bgp
->flags
,
18042 BGP_FLAG_DETERMINISTIC_MED
)
18046 /* BGP update-delay. */
18047 bgp_config_write_update_delay(vty
, bgp
);
18049 if (bgp
->v_maxmed_onstartup
18050 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18051 vty_out(vty
, " bgp max-med on-startup %u",
18052 bgp
->v_maxmed_onstartup
);
18053 if (bgp
->maxmed_onstartup_value
18054 != BGP_MAXMED_VALUE_DEFAULT
)
18055 vty_out(vty
, " %u",
18056 bgp
->maxmed_onstartup_value
);
18057 vty_out(vty
, "\n");
18059 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18060 vty_out(vty
, " bgp max-med administrative");
18061 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18062 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18063 vty_out(vty
, "\n");
18067 bgp_config_write_wpkt_quanta(vty
, bgp
);
18069 bgp_config_write_rpkt_quanta(vty
, bgp
);
18071 /* coalesce time */
18072 bgp_config_write_coalesce_time(vty
, bgp
);
18074 /* BGP per-instance graceful-shutdown */
18075 /* BGP-wide settings and per-instance settings are mutually
18078 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18079 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18080 vty_out(vty
, " bgp graceful-shutdown\n");
18082 /* Long-lived Graceful Restart */
18083 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18085 " bgp long-lived-graceful-restart stale-time %u\n",
18086 bgp
->llgr_stale_time
);
18088 /* BGP graceful-restart. */
18089 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18091 " bgp graceful-restart stalepath-time %u\n",
18092 bgp
->stalepath_time
);
18094 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18095 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18096 bgp
->restart_time
);
18098 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18099 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18100 vty_out(vty
, " %sbgp graceful-restart notification\n",
18101 CHECK_FLAG(bgp
->flags
,
18102 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18106 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18108 " bgp graceful-restart select-defer-time %u\n",
18109 bgp
->select_defer_time
);
18111 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18112 vty_out(vty
, " bgp graceful-restart\n");
18114 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18115 vty_out(vty
, " bgp graceful-restart-disable\n");
18117 /* BGP graceful-restart Preserve State F bit. */
18118 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18120 " bgp graceful-restart preserve-fw-state\n");
18122 /* BGP TCP keepalive */
18123 bgp_config_tcp_keepalive(vty
, bgp
);
18125 /* Stale timer for RIB */
18126 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18128 " bgp graceful-restart rib-stale-time %u\n",
18129 bgp
->rib_stale_time
);
18131 /* BGP bestpath method. */
18132 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18133 vty_out(vty
, " bgp bestpath as-path ignore\n");
18134 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18135 vty_out(vty
, " bgp bestpath as-path confed\n");
18137 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18138 if (CHECK_FLAG(bgp
->flags
,
18139 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18141 " bgp bestpath as-path multipath-relax as-set\n");
18144 " bgp bestpath as-path multipath-relax\n");
18148 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18150 " bgp route-reflector allow-outbound-policy\n");
18152 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18153 vty_out(vty
, " bgp bestpath compare-routerid\n");
18154 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18155 vty_out(vty
, " bgp bestpath aigp\n");
18156 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18157 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18158 vty_out(vty
, " bgp bestpath med");
18159 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18160 vty_out(vty
, " confed");
18161 if (CHECK_FLAG(bgp
->flags
,
18162 BGP_FLAG_MED_MISSING_AS_WORST
))
18163 vty_out(vty
, " missing-as-worst");
18164 vty_out(vty
, "\n");
18167 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18169 " bgp bestpath peer-type multipath-relax\n");
18171 /* Link bandwidth handling. */
18172 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18173 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18174 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18175 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18176 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18177 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18179 /* BGP network import check. */
18180 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18181 != SAVE_BGP_IMPORT_CHECK
)
18182 vty_out(vty
, " %sbgp network import-check\n",
18183 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18187 /* BGP timers configuration. */
18188 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18189 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18190 vty_out(vty
, " timers bgp %u %u\n",
18191 bgp
->default_keepalive
, bgp
->default_holdtime
);
18193 /* BGP minimum holdtime configuration. */
18194 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18195 && bgp
->default_min_holdtime
!= 0)
18196 vty_out(vty
, " bgp minimum-holdtime %u\n",
18197 bgp
->default_min_holdtime
);
18199 /* Conditional advertisement timer configuration */
18200 if (bgp
->condition_check_period
18201 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18203 " bgp conditional-advertisement timer %u\n",
18204 bgp
->condition_check_period
);
18207 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18208 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18211 /* Normal neighbor configuration. */
18212 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18213 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18214 bgp_config_write_peer_global(vty
, bgp
, peer
);
18217 /* listen range and limit for dynamic BGP neighbors */
18218 bgp_config_write_listen(vty
, bgp
);
18221 * BGP default autoshutdown neighbors
18223 * This must be placed after any peer and peer-group
18224 * configuration, to avoid setting all peers to shutdown after
18225 * a daemon restart, which is undesired behavior. (see #2286)
18227 if (bgp
->autoshutdown
)
18228 vty_out(vty
, " bgp default shutdown\n");
18230 /* BGP instance administrative shutdown */
18231 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18232 vty_out(vty
, " bgp shutdown\n");
18234 if (bgp
->allow_martian
)
18235 vty_out(vty
, " bgp allow-martian-nexthop\n");
18237 if (bgp
->fast_convergence
)
18238 vty_out(vty
, " bgp fast-convergence\n");
18240 if (bgp
->srv6_enabled
) {
18241 vty_frame(vty
, " !\n segment-routing srv6\n");
18242 if (strlen(bgp
->srv6_locator_name
))
18243 vty_out(vty
, " locator %s\n",
18244 bgp
->srv6_locator_name
);
18245 vty_endframe(vty
, " exit\n");
18248 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18249 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18250 vty_out(vty
, " sid vpn per-vrf export auto\n");
18251 } else if (tovpn_sid_index
!= 0) {
18252 vty_out(vty
, " sid vpn per-vrf export %d\n",
18256 /* IPv4 unicast configuration. */
18257 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18259 /* IPv4 multicast configuration. */
18260 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18262 /* IPv4 labeled-unicast configuration. */
18263 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18265 /* IPv4 VPN configuration. */
18266 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18268 /* ENCAPv4 configuration. */
18269 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18271 /* FLOWSPEC v4 configuration. */
18272 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18274 /* IPv6 unicast configuration. */
18275 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18277 /* IPv6 multicast configuration. */
18278 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18280 /* IPv6 labeled-unicast configuration. */
18281 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18282 SAFI_LABELED_UNICAST
);
18284 /* IPv6 VPN configuration. */
18285 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18287 /* ENCAPv6 configuration. */
18288 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18290 /* FLOWSPEC v6 configuration. */
18291 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18293 /* EVPN configuration. */
18294 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18296 hook_call(bgp_inst_config_write
, bgp
, vty
);
18298 #ifdef ENABLE_BGP_VNC
18299 bgp_rfapi_cfg_write(vty
, bgp
);
18302 vty_out(vty
, "exit\n");
18303 vty_out(vty
, "!\n");
18309 /* BGP node structure. */
18310 static struct cmd_node bgp_node
= {
18313 .parent_node
= CONFIG_NODE
,
18314 .prompt
= "%s(config-router)# ",
18315 .config_write
= bgp_config_write
,
18318 static struct cmd_node bgp_ipv4_unicast_node
= {
18319 .name
= "bgp ipv4 unicast",
18320 .node
= BGP_IPV4_NODE
,
18321 .parent_node
= BGP_NODE
,
18322 .prompt
= "%s(config-router-af)# ",
18326 static struct cmd_node bgp_ipv4_multicast_node
= {
18327 .name
= "bgp ipv4 multicast",
18328 .node
= BGP_IPV4M_NODE
,
18329 .parent_node
= BGP_NODE
,
18330 .prompt
= "%s(config-router-af)# ",
18334 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18335 .name
= "bgp ipv4 labeled unicast",
18336 .node
= BGP_IPV4L_NODE
,
18337 .parent_node
= BGP_NODE
,
18338 .prompt
= "%s(config-router-af)# ",
18342 static struct cmd_node bgp_ipv6_unicast_node
= {
18343 .name
= "bgp ipv6 unicast",
18344 .node
= BGP_IPV6_NODE
,
18345 .parent_node
= BGP_NODE
,
18346 .prompt
= "%s(config-router-af)# ",
18350 static struct cmd_node bgp_ipv6_multicast_node
= {
18351 .name
= "bgp ipv6 multicast",
18352 .node
= BGP_IPV6M_NODE
,
18353 .parent_node
= BGP_NODE
,
18354 .prompt
= "%s(config-router-af)# ",
18358 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18359 .name
= "bgp ipv6 labeled unicast",
18360 .node
= BGP_IPV6L_NODE
,
18361 .parent_node
= BGP_NODE
,
18362 .prompt
= "%s(config-router-af)# ",
18366 static struct cmd_node bgp_vpnv4_node
= {
18367 .name
= "bgp vpnv4",
18368 .node
= BGP_VPNV4_NODE
,
18369 .parent_node
= BGP_NODE
,
18370 .prompt
= "%s(config-router-af)# ",
18374 static struct cmd_node bgp_vpnv6_node
= {
18375 .name
= "bgp vpnv6",
18376 .node
= BGP_VPNV6_NODE
,
18377 .parent_node
= BGP_NODE
,
18378 .prompt
= "%s(config-router-af-vpnv6)# ",
18382 static struct cmd_node bgp_evpn_node
= {
18383 .name
= "bgp evpn",
18384 .node
= BGP_EVPN_NODE
,
18385 .parent_node
= BGP_NODE
,
18386 .prompt
= "%s(config-router-evpn)# ",
18390 static struct cmd_node bgp_evpn_vni_node
= {
18391 .name
= "bgp evpn vni",
18392 .node
= BGP_EVPN_VNI_NODE
,
18393 .parent_node
= BGP_EVPN_NODE
,
18394 .prompt
= "%s(config-router-af-vni)# ",
18397 static struct cmd_node bgp_flowspecv4_node
= {
18398 .name
= "bgp ipv4 flowspec",
18399 .node
= BGP_FLOWSPECV4_NODE
,
18400 .parent_node
= BGP_NODE
,
18401 .prompt
= "%s(config-router-af)# ",
18405 static struct cmd_node bgp_flowspecv6_node
= {
18406 .name
= "bgp ipv6 flowspec",
18407 .node
= BGP_FLOWSPECV6_NODE
,
18408 .parent_node
= BGP_NODE
,
18409 .prompt
= "%s(config-router-af-vpnv6)# ",
18413 static struct cmd_node bgp_srv6_node
= {
18414 .name
= "bgp srv6",
18415 .node
= BGP_SRV6_NODE
,
18416 .parent_node
= BGP_NODE
,
18417 .prompt
= "%s(config-router-srv6)# ",
18420 static void community_list_vty(void);
18422 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18425 struct peer_group
*group
;
18426 struct listnode
*lnbgp
, *lnpeer
;
18428 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18429 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18431 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18435 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18439 struct listnode
*lnbgp
, *lnpeer
;
18441 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18442 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18443 /* only provide suggestions on the appropriate input
18445 * they'll otherwise show up multiple times */
18446 enum cmd_token_type match_type
;
18447 char *name
= peer
->host
;
18449 if (peer
->conf_if
) {
18450 match_type
= VARIABLE_TKN
;
18451 name
= peer
->conf_if
;
18452 } else if (strchr(peer
->host
, ':'))
18453 match_type
= IPV6_TKN
;
18455 match_type
= IPV4_TKN
;
18457 if (token
->type
!= match_type
)
18460 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18465 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18467 bgp_ac_peer(comps
, token
);
18469 if (token
->type
== VARIABLE_TKN
)
18470 bgp_ac_peergroup(comps
, token
);
18473 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18474 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18475 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18476 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18477 {.completions
= NULL
}};
18479 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18480 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18481 {.completions
= NULL
} };
18483 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18485 static struct thread
*t_bgp_cfg
;
18487 bool bgp_config_inprocess(void)
18489 return thread_is_scheduled(t_bgp_cfg
);
18492 static void bgp_config_finish(struct thread
*t
)
18494 struct listnode
*node
;
18497 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18498 hook_call(bgp_config_end
, bgp
);
18501 static void bgp_config_start(void)
18503 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18504 THREAD_OFF(t_bgp_cfg
);
18505 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18506 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18509 /* When we receive a hook the configuration is read,
18510 * we start a timer to make sure we postpone sending
18511 * EoR before route-maps are processed.
18512 * This is especially valid if using `bgp route-map delay-timer`.
18514 static void bgp_config_end(void)
18516 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18517 uint32_t bgp_post_config_delay
=
18518 thread_is_scheduled(bm
->t_rmap_update
)
18519 ? thread_timer_remain_second(bm
->t_rmap_update
)
18520 : BGP_POST_CONFIG_DELAY_SECONDS
;
18522 /* If BGP config processing thread isn't running, then
18523 * we can return and rely it's properly handled.
18525 if (!bgp_config_inprocess())
18528 THREAD_OFF(t_bgp_cfg
);
18530 /* Start a new timer to make sure we don't send EoR
18531 * before route-maps are processed.
18533 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18534 bgp_post_config_delay
, &t_bgp_cfg
);
18537 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18540 struct interface
*ifp
;
18541 struct bgp_interface
*iifp
;
18543 FOR_ALL_INTERFACES (vrf
, ifp
) {
18548 if_vty_config_start(vty
, ifp
);
18550 if (CHECK_FLAG(iifp
->flags
,
18551 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18552 vty_out(vty
, " mpls bgp forwarding\n");
18556 if_vty_config_end(vty
);
18562 /* Configuration write function for bgpd. */
18563 static int config_write_interface(struct vty
*vty
)
18566 struct vrf
*vrf
= NULL
;
18568 /* Display all VRF aware OSPF interface configuration */
18569 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18570 write
+= config_write_interface_one(vty
, vrf
);
18576 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18577 "[no$no] mpls bgp forwarding",
18578 NO_STR MPLS_STR BGP_STR
18579 "Enable MPLS forwarding for eBGP directly connected peers\n")
18582 struct bgp_interface
*iifp
;
18584 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18587 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18588 return CMD_WARNING_CONFIG_FAILED
;
18590 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18591 if (check
!= !no
) {
18593 UNSET_FLAG(iifp
->flags
,
18594 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18596 SET_FLAG(iifp
->flags
,
18597 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18598 /* trigger a nht update on eBGP sessions */
18599 if (if_is_operative(ifp
))
18600 bgp_nht_ifp_up(ifp
);
18602 return CMD_SUCCESS
;
18605 DEFPY (bgp_inq_limit
,
18607 "bgp input-queue-limit (1-4294967295)$limit",
18609 "Set the BGP Input Queue limit for all peers when message parsing\n"
18610 "Input-Queue limit\n")
18612 bm
->inq_limit
= limit
;
18614 return CMD_SUCCESS
;
18617 DEFPY (no_bgp_inq_limit
,
18618 no_bgp_inq_limit_cmd
,
18619 "no bgp input-queue-limit [(1-4294967295)$limit]",
18622 "Set the BGP Input Queue limit for all peers when message parsing\n"
18623 "Input-Queue limit\n")
18625 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18627 return CMD_SUCCESS
;
18630 DEFPY (bgp_outq_limit
,
18631 bgp_outq_limit_cmd
,
18632 "bgp output-queue-limit (1-4294967295)$limit",
18634 "Set the BGP Output Queue limit for all peers when message parsing\n"
18635 "Output-Queue limit\n")
18637 bm
->outq_limit
= limit
;
18639 return CMD_SUCCESS
;
18642 DEFPY (no_bgp_outq_limit
,
18643 no_bgp_outq_limit_cmd
,
18644 "no bgp output-queue-limit [(1-4294967295)$limit]",
18647 "Set the BGP Output Queue limit for all peers when message parsing\n"
18648 "Output-Queue limit\n")
18650 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18652 return CMD_SUCCESS
;
18656 /* Initialization of BGP interface. */
18657 static void bgp_vty_if_init(void)
18659 /* Install interface node. */
18660 if_cmd_init(config_write_interface
);
18662 /* "mpls bgp forwarding" commands. */
18663 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18666 void bgp_vty_init(void)
18668 cmd_variable_handler_register(bgp_var_neighbor
);
18669 cmd_variable_handler_register(bgp_var_peergroup
);
18671 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18673 /* Install bgp top node. */
18674 install_node(&bgp_node
);
18675 install_node(&bgp_ipv4_unicast_node
);
18676 install_node(&bgp_ipv4_multicast_node
);
18677 install_node(&bgp_ipv4_labeled_unicast_node
);
18678 install_node(&bgp_ipv6_unicast_node
);
18679 install_node(&bgp_ipv6_multicast_node
);
18680 install_node(&bgp_ipv6_labeled_unicast_node
);
18681 install_node(&bgp_vpnv4_node
);
18682 install_node(&bgp_vpnv6_node
);
18683 install_node(&bgp_evpn_node
);
18684 install_node(&bgp_evpn_vni_node
);
18685 install_node(&bgp_flowspecv4_node
);
18686 install_node(&bgp_flowspecv6_node
);
18687 install_node(&bgp_srv6_node
);
18689 /* Install default VTY commands to new nodes. */
18690 install_default(BGP_NODE
);
18691 install_default(BGP_IPV4_NODE
);
18692 install_default(BGP_IPV4M_NODE
);
18693 install_default(BGP_IPV4L_NODE
);
18694 install_default(BGP_IPV6_NODE
);
18695 install_default(BGP_IPV6M_NODE
);
18696 install_default(BGP_IPV6L_NODE
);
18697 install_default(BGP_VPNV4_NODE
);
18698 install_default(BGP_VPNV6_NODE
);
18699 install_default(BGP_FLOWSPECV4_NODE
);
18700 install_default(BGP_FLOWSPECV6_NODE
);
18701 install_default(BGP_EVPN_NODE
);
18702 install_default(BGP_EVPN_VNI_NODE
);
18703 install_default(BGP_SRV6_NODE
);
18705 /* "global bgp inq-limit command */
18706 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18707 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18708 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18709 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18711 /* "bgp local-mac" hidden commands. */
18712 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18713 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18715 /* "bgp suppress-fib-pending" global */
18716 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18718 /* bgp route-map delay-timer commands. */
18719 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18720 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18722 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18724 /* bgp fast-convergence command */
18725 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18726 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18728 /* global bgp update-delay command */
18729 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18730 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18732 /* global bgp graceful-shutdown command */
18733 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18734 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18736 /* Dummy commands (Currently not supported) */
18737 install_element(BGP_NODE
, &no_synchronization_cmd
);
18738 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18740 /* "router bgp" commands. */
18741 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18743 /* "no router bgp" commands. */
18744 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18746 /* "bgp session-dscp command */
18747 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18748 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18750 /* "bgp router-id" commands. */
18751 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18752 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18754 /* "bgp suppress-fib-pending" command */
18755 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18757 /* "bgp cluster-id" commands. */
18758 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18759 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18761 /* "bgp no-rib" commands. */
18762 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18763 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18765 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18767 /* "bgp confederation" commands. */
18768 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18769 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18771 /* "bgp confederation peers" commands. */
18772 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18773 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18775 /* bgp max-med command */
18776 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18777 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18778 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18779 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18780 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18782 /* "neighbor role" commands. */
18783 install_element(BGP_NODE
, &neighbor_role_cmd
);
18784 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18785 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18787 /* "neighbor aigp" commands. */
18788 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18790 /* "neighbor graceful-shutdown" command */
18791 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18793 /* bgp disable-ebgp-connected-nh-check */
18794 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18795 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18797 /* bgp update-delay command */
18798 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18799 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18801 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18802 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18804 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18805 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18807 /* "maximum-paths" commands. */
18808 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18809 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18810 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18811 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18812 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18813 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18814 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18815 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18816 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18817 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18818 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18819 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18820 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18821 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18822 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18824 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18825 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18826 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18827 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18828 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18829 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18830 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18831 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18832 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18833 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18835 /* "timers bgp" commands. */
18836 install_element(BGP_NODE
, &bgp_timers_cmd
);
18837 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18839 /* "minimum-holdtime" commands. */
18840 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18841 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18843 /* route-map delay-timer commands - per instance for backwards compat.
18845 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18846 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18848 /* "bgp client-to-client reflection" commands */
18849 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18850 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18852 /* "bgp always-compare-med" commands */
18853 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18854 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18856 /* bgp ebgp-requires-policy */
18857 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18858 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18860 /* bgp suppress-duplicates */
18861 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18862 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18864 /* bgp reject-as-sets */
18865 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18866 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18868 /* "bgp deterministic-med" commands */
18869 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18870 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18872 /* "bgp graceful-restart" command */
18873 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18874 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18876 /* "bgp graceful-restart-disable" command */
18877 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18878 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18880 /* "neighbor a:b:c:d graceful-restart" command */
18881 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18882 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18884 /* "neighbor a:b:c:d graceful-restart-disable" command */
18885 install_element(BGP_NODE
,
18886 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18887 install_element(BGP_NODE
,
18888 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18890 /* "neighbor a:b:c:d graceful-restart-helper" command */
18891 install_element(BGP_NODE
,
18892 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18893 install_element(BGP_NODE
,
18894 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18896 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18897 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18898 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18899 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18900 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18901 install_element(BGP_NODE
,
18902 &no_bgp_graceful_restart_select_defer_time_cmd
);
18903 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18904 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18905 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18907 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18908 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18909 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18910 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18912 /* "bgp graceful-shutdown" commands */
18913 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18914 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18916 /* "bgp hard-administrative-reset" commands */
18917 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18919 /* "bgp long-lived-graceful-restart" commands */
18920 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18921 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18923 /* "bgp fast-external-failover" commands */
18924 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18925 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18927 /* "bgp bestpath aigp" commands */
18928 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
18930 /* "bgp bestpath compare-routerid" commands */
18931 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18932 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18934 /* "bgp bestpath as-path ignore" commands */
18935 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18936 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18938 /* "bgp bestpath as-path confed" commands */
18939 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18940 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18942 /* "bgp bestpath as-path multipath-relax" commands */
18943 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18944 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18946 /* "bgp bestpath peer-type multipath-relax" commands */
18947 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18948 install_element(BGP_NODE
,
18949 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18951 /* "bgp log-neighbor-changes" commands */
18952 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18953 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18955 /* "bgp bestpath med" commands */
18956 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18957 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18959 /* "bgp bestpath bandwidth" commands */
18960 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18961 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18963 /* "no bgp default <afi>-<safi>" commands. */
18964 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18966 /* "bgp network import-check" commands. */
18967 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18968 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18969 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18971 /* "bgp default local-preference" commands. */
18972 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18973 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18975 /* bgp default show-hostname */
18976 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18977 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18979 /* bgp default show-nexthop-hostname */
18980 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18981 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18983 /* "bgp default subgroup-pkt-queue-max" commands. */
18984 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18985 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18987 /* bgp ibgp-allow-policy-mods command */
18988 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18989 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18991 /* "bgp listen limit" commands. */
18992 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18993 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18995 /* "bgp listen range" commands. */
18996 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18997 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18999 /* "bgp default shutdown" command */
19000 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19002 /* "bgp shutdown" commands */
19003 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19004 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19005 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19006 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19008 /* "neighbor remote-as" commands. */
19009 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19010 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19011 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19012 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19013 install_element(BGP_NODE
,
19014 &neighbor_interface_v6only_config_remote_as_cmd
);
19015 install_element(BGP_NODE
, &no_neighbor_cmd
);
19016 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19018 /* "neighbor peer-group" commands. */
19019 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19020 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19021 install_element(BGP_NODE
,
19022 &no_neighbor_interface_peer_group_remote_as_cmd
);
19024 /* "neighbor local-as" commands. */
19025 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19026 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19027 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19028 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19030 /* "neighbor solo" commands. */
19031 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19032 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19034 /* "neighbor password" commands. */
19035 install_element(BGP_NODE
, &neighbor_password_cmd
);
19036 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19038 /* "neighbor activate" commands. */
19039 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19040 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19041 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19042 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19043 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19044 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19045 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19046 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19047 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19048 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19049 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19050 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19052 /* "no neighbor activate" commands. */
19053 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19054 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19055 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19056 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19057 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19058 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19059 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19060 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19061 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19062 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19063 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19064 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19066 /* "neighbor peer-group" set commands. */
19067 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19068 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19069 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19070 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19071 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19072 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19073 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19075 install_element(BGP_FLOWSPECV4_NODE
,
19076 &neighbor_set_peer_group_hidden_cmd
);
19077 install_element(BGP_FLOWSPECV6_NODE
,
19078 &neighbor_set_peer_group_hidden_cmd
);
19080 /* "no neighbor peer-group unset" commands. */
19081 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19082 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19083 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19084 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19085 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19086 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19087 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19088 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19089 install_element(BGP_FLOWSPECV4_NODE
,
19090 &no_neighbor_set_peer_group_hidden_cmd
);
19091 install_element(BGP_FLOWSPECV6_NODE
,
19092 &no_neighbor_set_peer_group_hidden_cmd
);
19094 /* "neighbor softreconfiguration inbound" commands.*/
19095 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19096 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19097 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19098 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19099 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19100 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19101 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19102 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19103 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19104 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19105 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19106 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19107 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19108 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19109 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19110 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19111 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19112 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19113 install_element(BGP_FLOWSPECV4_NODE
,
19114 &neighbor_soft_reconfiguration_cmd
);
19115 install_element(BGP_FLOWSPECV4_NODE
,
19116 &no_neighbor_soft_reconfiguration_cmd
);
19117 install_element(BGP_FLOWSPECV6_NODE
,
19118 &neighbor_soft_reconfiguration_cmd
);
19119 install_element(BGP_FLOWSPECV6_NODE
,
19120 &no_neighbor_soft_reconfiguration_cmd
);
19121 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19122 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19124 /* "neighbor attribute-unchanged" commands. */
19125 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19126 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19127 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19128 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19129 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19130 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19131 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19132 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19133 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19134 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19135 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19136 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19137 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19138 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19139 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19140 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19141 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19142 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19144 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19145 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19147 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19148 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19149 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19150 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19152 /* "nexthop-local unchanged" commands */
19153 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19154 install_element(BGP_IPV6_NODE
,
19155 &no_neighbor_nexthop_local_unchanged_cmd
);
19157 /* "neighbor next-hop-self" commands. */
19158 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19159 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19160 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19161 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19162 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19163 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19164 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19165 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19166 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19167 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19168 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19169 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19170 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19171 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19172 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19173 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19174 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19175 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19176 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19177 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19179 /* "neighbor next-hop-self force" commands. */
19180 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19181 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19182 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19183 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19184 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19185 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19186 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19187 install_element(BGP_IPV4_NODE
,
19188 &no_neighbor_nexthop_self_all_hidden_cmd
);
19189 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19190 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19191 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19192 install_element(BGP_IPV4M_NODE
,
19193 &no_neighbor_nexthop_self_all_hidden_cmd
);
19194 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19195 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19196 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19197 install_element(BGP_IPV4L_NODE
,
19198 &no_neighbor_nexthop_self_all_hidden_cmd
);
19199 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19200 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19201 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19202 install_element(BGP_IPV6_NODE
,
19203 &no_neighbor_nexthop_self_all_hidden_cmd
);
19204 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19205 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19206 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19207 install_element(BGP_IPV6M_NODE
,
19208 &no_neighbor_nexthop_self_all_hidden_cmd
);
19209 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19210 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19211 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19212 install_element(BGP_IPV6L_NODE
,
19213 &no_neighbor_nexthop_self_all_hidden_cmd
);
19214 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19215 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19216 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19217 install_element(BGP_VPNV4_NODE
,
19218 &no_neighbor_nexthop_self_all_hidden_cmd
);
19219 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19220 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19221 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19222 install_element(BGP_VPNV6_NODE
,
19223 &no_neighbor_nexthop_self_all_hidden_cmd
);
19224 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19225 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19227 /* "neighbor as-override" commands. */
19228 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19229 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19230 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19231 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19232 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19233 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19234 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19235 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19236 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19237 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19238 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19239 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19240 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19241 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19242 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19243 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19244 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19245 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19247 /* "neighbor remove-private-AS" commands. */
19248 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19249 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19250 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19251 install_element(BGP_NODE
,
19252 &no_neighbor_remove_private_as_all_hidden_cmd
);
19253 install_element(BGP_NODE
,
19254 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19255 install_element(BGP_NODE
,
19256 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19257 install_element(BGP_NODE
,
19258 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19261 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19262 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19263 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19264 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19265 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19266 install_element(BGP_IPV4_NODE
,
19267 &neighbor_remove_private_as_replace_as_cmd
);
19268 install_element(BGP_IPV4_NODE
,
19269 &no_neighbor_remove_private_as_replace_as_cmd
);
19270 install_element(BGP_IPV4_NODE
,
19271 &neighbor_remove_private_as_all_replace_as_cmd
);
19272 install_element(BGP_IPV4_NODE
,
19273 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19274 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19275 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19276 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19277 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19278 install_element(BGP_IPV4M_NODE
,
19279 &neighbor_remove_private_as_replace_as_cmd
);
19280 install_element(BGP_IPV4M_NODE
,
19281 &no_neighbor_remove_private_as_replace_as_cmd
);
19282 install_element(BGP_IPV4M_NODE
,
19283 &neighbor_remove_private_as_all_replace_as_cmd
);
19284 install_element(BGP_IPV4M_NODE
,
19285 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19286 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19287 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19288 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19289 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19290 install_element(BGP_IPV4L_NODE
,
19291 &neighbor_remove_private_as_replace_as_cmd
);
19292 install_element(BGP_IPV4L_NODE
,
19293 &no_neighbor_remove_private_as_replace_as_cmd
);
19294 install_element(BGP_IPV4L_NODE
,
19295 &neighbor_remove_private_as_all_replace_as_cmd
);
19296 install_element(BGP_IPV4L_NODE
,
19297 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19298 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19299 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19300 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19301 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19302 install_element(BGP_IPV6_NODE
,
19303 &neighbor_remove_private_as_replace_as_cmd
);
19304 install_element(BGP_IPV6_NODE
,
19305 &no_neighbor_remove_private_as_replace_as_cmd
);
19306 install_element(BGP_IPV6_NODE
,
19307 &neighbor_remove_private_as_all_replace_as_cmd
);
19308 install_element(BGP_IPV6_NODE
,
19309 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19310 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19311 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19312 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19313 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19314 install_element(BGP_IPV6M_NODE
,
19315 &neighbor_remove_private_as_replace_as_cmd
);
19316 install_element(BGP_IPV6M_NODE
,
19317 &no_neighbor_remove_private_as_replace_as_cmd
);
19318 install_element(BGP_IPV6M_NODE
,
19319 &neighbor_remove_private_as_all_replace_as_cmd
);
19320 install_element(BGP_IPV6M_NODE
,
19321 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19322 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19323 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19324 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19325 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19326 install_element(BGP_IPV6L_NODE
,
19327 &neighbor_remove_private_as_replace_as_cmd
);
19328 install_element(BGP_IPV6L_NODE
,
19329 &no_neighbor_remove_private_as_replace_as_cmd
);
19330 install_element(BGP_IPV6L_NODE
,
19331 &neighbor_remove_private_as_all_replace_as_cmd
);
19332 install_element(BGP_IPV6L_NODE
,
19333 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19334 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19335 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19336 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19337 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19338 install_element(BGP_VPNV4_NODE
,
19339 &neighbor_remove_private_as_replace_as_cmd
);
19340 install_element(BGP_VPNV4_NODE
,
19341 &no_neighbor_remove_private_as_replace_as_cmd
);
19342 install_element(BGP_VPNV4_NODE
,
19343 &neighbor_remove_private_as_all_replace_as_cmd
);
19344 install_element(BGP_VPNV4_NODE
,
19345 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19346 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19347 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19348 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19349 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19350 install_element(BGP_VPNV6_NODE
,
19351 &neighbor_remove_private_as_replace_as_cmd
);
19352 install_element(BGP_VPNV6_NODE
,
19353 &no_neighbor_remove_private_as_replace_as_cmd
);
19354 install_element(BGP_VPNV6_NODE
,
19355 &neighbor_remove_private_as_all_replace_as_cmd
);
19356 install_element(BGP_VPNV6_NODE
,
19357 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19359 /* "neighbor send-community" commands.*/
19360 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19361 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19362 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19363 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19364 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19365 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19366 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19367 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19368 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19369 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19370 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19371 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19372 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19373 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19374 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19375 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19376 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19377 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19378 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19379 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19380 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19381 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19382 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19383 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19384 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19385 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19386 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19387 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19388 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19389 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19390 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19391 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19392 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19393 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19394 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19395 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19397 /* "neighbor route-reflector" commands.*/
19398 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19399 install_element(BGP_NODE
,
19400 &no_neighbor_route_reflector_client_hidden_cmd
);
19401 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19402 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19403 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19404 install_element(BGP_IPV4M_NODE
,
19405 &no_neighbor_route_reflector_client_cmd
);
19406 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19407 install_element(BGP_IPV4L_NODE
,
19408 &no_neighbor_route_reflector_client_cmd
);
19409 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19410 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19411 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19412 install_element(BGP_IPV6M_NODE
,
19413 &no_neighbor_route_reflector_client_cmd
);
19414 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19415 install_element(BGP_IPV6L_NODE
,
19416 &no_neighbor_route_reflector_client_cmd
);
19417 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19418 install_element(BGP_VPNV4_NODE
,
19419 &no_neighbor_route_reflector_client_cmd
);
19420 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19421 install_element(BGP_VPNV6_NODE
,
19422 &no_neighbor_route_reflector_client_cmd
);
19423 install_element(BGP_FLOWSPECV4_NODE
,
19424 &neighbor_route_reflector_client_cmd
);
19425 install_element(BGP_FLOWSPECV4_NODE
,
19426 &no_neighbor_route_reflector_client_cmd
);
19427 install_element(BGP_FLOWSPECV6_NODE
,
19428 &neighbor_route_reflector_client_cmd
);
19429 install_element(BGP_FLOWSPECV6_NODE
,
19430 &no_neighbor_route_reflector_client_cmd
);
19431 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19432 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19434 /* "neighbor route-server" commands.*/
19435 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19436 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19437 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19438 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19439 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19440 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19441 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19442 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19443 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19444 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19445 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19446 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19447 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19448 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19449 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19450 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19451 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19452 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19453 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19454 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19455 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19456 install_element(BGP_FLOWSPECV4_NODE
,
19457 &no_neighbor_route_server_client_cmd
);
19458 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19459 install_element(BGP_FLOWSPECV6_NODE
,
19460 &no_neighbor_route_server_client_cmd
);
19462 /* "neighbor disable-addpath-rx" commands. */
19463 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19464 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19465 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19466 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19467 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19468 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19469 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19470 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19471 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19472 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19473 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19474 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19475 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19476 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19477 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19478 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19480 /* "neighbor addpath-tx-all-paths" commands.*/
19481 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19482 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19483 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19484 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19485 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19486 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19487 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19488 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19489 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19490 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19491 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19492 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19493 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19494 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19495 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19496 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19497 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19498 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19500 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19501 install_element(BGP_NODE
,
19502 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19503 install_element(BGP_NODE
,
19504 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19505 install_element(BGP_IPV4_NODE
,
19506 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19507 install_element(BGP_IPV4_NODE
,
19508 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19509 install_element(BGP_IPV4M_NODE
,
19510 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19511 install_element(BGP_IPV4M_NODE
,
19512 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19513 install_element(BGP_IPV4L_NODE
,
19514 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19515 install_element(BGP_IPV4L_NODE
,
19516 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19517 install_element(BGP_IPV6_NODE
,
19518 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19519 install_element(BGP_IPV6_NODE
,
19520 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19521 install_element(BGP_IPV6M_NODE
,
19522 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19523 install_element(BGP_IPV6M_NODE
,
19524 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19525 install_element(BGP_IPV6L_NODE
,
19526 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19527 install_element(BGP_IPV6L_NODE
,
19528 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19529 install_element(BGP_VPNV4_NODE
,
19530 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19531 install_element(BGP_VPNV4_NODE
,
19532 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19533 install_element(BGP_VPNV6_NODE
,
19534 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19535 install_element(BGP_VPNV6_NODE
,
19536 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19538 /* "neighbor sender-as-path-loop-detection" commands. */
19539 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19540 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19542 /* "neighbor path-attribute discard" commands. */
19543 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19545 /* "neighbor passive" commands. */
19546 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19547 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19550 /* "neighbor shutdown" commands. */
19551 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19552 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19553 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19554 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19555 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19556 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19558 /* "neighbor capability extended-nexthop" commands.*/
19559 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19560 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19562 /* "neighbor capability orf prefix-list" commands.*/
19563 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19564 install_element(BGP_NODE
,
19565 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19566 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19567 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19568 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19569 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19570 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19571 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19572 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19573 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19574 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19575 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19576 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19577 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19579 /* "neighbor capability dynamic" commands.*/
19580 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19581 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19583 /* "neighbor dont-capability-negotiate" commands. */
19584 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19585 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19587 /* "neighbor ebgp-multihop" commands. */
19588 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19589 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19590 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19592 /* "neighbor disable-connected-check" commands. */
19593 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19594 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19596 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19597 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19598 install_element(BGP_NODE
,
19599 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19601 /* "neighbor extended-optional-parameters" commands. */
19602 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19603 install_element(BGP_NODE
,
19604 &no_neighbor_extended_optional_parameters_cmd
);
19606 /* "neighbor enforce-first-as" commands. */
19607 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19608 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19610 /* "neighbor description" commands. */
19611 install_element(BGP_NODE
, &neighbor_description_cmd
);
19612 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19613 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19615 /* "neighbor update-source" commands. "*/
19616 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19617 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19619 /* "neighbor default-originate" commands. */
19620 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19621 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19622 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19623 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19624 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19625 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19626 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19627 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19628 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19629 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19630 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19631 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19632 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19633 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19634 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19635 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19636 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19637 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19638 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19639 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19640 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19642 /* "neighbor port" commands. */
19643 install_element(BGP_NODE
, &neighbor_port_cmd
);
19644 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19646 /* "neighbor weight" commands. */
19647 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19648 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19650 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19651 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19652 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19653 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19654 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19655 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19656 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19657 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19658 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19659 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19660 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19661 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19662 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19663 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19664 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19665 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19667 /* "neighbor override-capability" commands. */
19668 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19669 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19671 /* "neighbor strict-capability-match" commands. */
19672 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19673 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19675 /* "neighbor timers" commands. */
19676 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19677 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19679 /* "neighbor timers connect" commands. */
19680 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19681 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19683 /* "neighbor timers delayopen" commands. */
19684 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19685 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19687 /* "neighbor advertisement-interval" commands. */
19688 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19689 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19691 /* "neighbor interface" commands. */
19692 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19693 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19695 /* "neighbor distribute" commands. */
19696 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19697 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19698 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19699 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19700 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19701 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19702 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19703 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19704 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19705 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19706 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19707 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19708 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19709 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19710 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19711 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19712 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19713 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19715 /* "neighbor prefix-list" commands. */
19716 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19717 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19718 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19719 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19720 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19721 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19722 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19723 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19724 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19725 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19726 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19727 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19728 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19729 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19730 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19731 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19732 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19733 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19734 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19735 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19736 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19737 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19739 /* "neighbor filter-list" commands. */
19740 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19741 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19742 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19743 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19744 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19745 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19746 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19747 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19748 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19749 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19750 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19751 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19752 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19753 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19754 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19755 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19756 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19757 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19758 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19759 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19760 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19761 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19763 /* "neighbor route-map" commands. */
19764 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19765 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19766 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19767 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19768 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19769 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19770 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19771 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19772 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19773 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19774 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19775 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19776 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19777 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19778 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19779 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19780 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19781 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19782 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19783 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19784 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19785 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19786 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19787 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19789 /* "neighbor unsuppress-map" commands. */
19790 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19791 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19792 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19793 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19794 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19795 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19796 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19797 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19798 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19799 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19800 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19801 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19802 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19803 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19804 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19805 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19806 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19807 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19809 /* "neighbor advertise-map" commands. */
19810 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19811 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19812 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19813 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19814 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19815 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19816 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19817 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19818 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19819 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19821 /* neighbor maximum-prefix-out commands. */
19822 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19823 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19824 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19825 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19826 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19827 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19828 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19829 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19830 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19831 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19832 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19833 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19834 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19835 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19836 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19837 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19838 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19839 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19841 /* "neighbor maximum-prefix" commands. */
19842 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19843 install_element(BGP_NODE
,
19844 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19845 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19846 install_element(BGP_NODE
,
19847 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19848 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19849 install_element(BGP_NODE
,
19850 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19851 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19852 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19853 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19854 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19855 install_element(BGP_IPV4_NODE
,
19856 &neighbor_maximum_prefix_threshold_warning_cmd
);
19857 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19858 install_element(BGP_IPV4_NODE
,
19859 &neighbor_maximum_prefix_threshold_restart_cmd
);
19860 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19861 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19862 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19863 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19864 install_element(BGP_IPV4M_NODE
,
19865 &neighbor_maximum_prefix_threshold_warning_cmd
);
19866 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19867 install_element(BGP_IPV4M_NODE
,
19868 &neighbor_maximum_prefix_threshold_restart_cmd
);
19869 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19870 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19871 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19872 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19873 install_element(BGP_IPV4L_NODE
,
19874 &neighbor_maximum_prefix_threshold_warning_cmd
);
19875 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19876 install_element(BGP_IPV4L_NODE
,
19877 &neighbor_maximum_prefix_threshold_restart_cmd
);
19878 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19879 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19880 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19881 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19882 install_element(BGP_IPV6_NODE
,
19883 &neighbor_maximum_prefix_threshold_warning_cmd
);
19884 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19885 install_element(BGP_IPV6_NODE
,
19886 &neighbor_maximum_prefix_threshold_restart_cmd
);
19887 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19888 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19889 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19890 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19891 install_element(BGP_IPV6M_NODE
,
19892 &neighbor_maximum_prefix_threshold_warning_cmd
);
19893 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19894 install_element(BGP_IPV6M_NODE
,
19895 &neighbor_maximum_prefix_threshold_restart_cmd
);
19896 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19897 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19898 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19899 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19900 install_element(BGP_IPV6L_NODE
,
19901 &neighbor_maximum_prefix_threshold_warning_cmd
);
19902 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19903 install_element(BGP_IPV6L_NODE
,
19904 &neighbor_maximum_prefix_threshold_restart_cmd
);
19905 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19906 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19907 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19908 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19909 install_element(BGP_VPNV4_NODE
,
19910 &neighbor_maximum_prefix_threshold_warning_cmd
);
19911 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19912 install_element(BGP_VPNV4_NODE
,
19913 &neighbor_maximum_prefix_threshold_restart_cmd
);
19914 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19915 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19916 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19917 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19918 install_element(BGP_VPNV6_NODE
,
19919 &neighbor_maximum_prefix_threshold_warning_cmd
);
19920 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19921 install_element(BGP_VPNV6_NODE
,
19922 &neighbor_maximum_prefix_threshold_restart_cmd
);
19923 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19925 /* "neighbor allowas-in" */
19926 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19927 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19928 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19929 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19930 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19931 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19932 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19933 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19934 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19935 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19936 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19937 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19938 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19939 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19940 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19941 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19942 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19943 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19944 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19945 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19947 /* neighbor accept-own */
19948 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19949 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19951 /* "neighbor soo" */
19952 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19953 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19954 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19955 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19956 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19957 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19958 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19959 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19960 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19961 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19962 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19963 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19964 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19965 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19966 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19967 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19968 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19969 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19971 /* address-family commands. */
19972 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19973 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19974 #ifdef KEEP_OLD_VPN_COMMANDS
19975 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19976 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19977 #endif /* KEEP_OLD_VPN_COMMANDS */
19979 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19981 /* "exit-address-family" command. */
19982 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19983 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19984 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19985 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19986 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19987 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19988 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19989 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19990 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19991 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19992 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19994 /* BGP retain all route-target */
19995 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19996 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19998 /* "clear ip bgp commands" */
19999 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20001 /* clear ip bgp prefix */
20002 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20003 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20004 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20006 /* "show [ip] bgp summary" commands. */
20007 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20008 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20009 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20010 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20011 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20012 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20013 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20015 /* "show [ip] bgp neighbors" commands. */
20016 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20018 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20020 /* "show [ip] bgp peer-group" commands. */
20021 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20023 /* "show [ip] bgp paths" commands. */
20024 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20026 /* "show [ip] bgp community" commands. */
20027 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20029 /* "show ip bgp large-community" commands. */
20030 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20031 /* "show [ip] bgp attribute-info" commands. */
20032 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20033 /* "show [ip] bgp route-leak" command */
20034 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20036 /* "redistribute" commands. */
20037 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20038 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20039 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20040 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20041 install_element(BGP_NODE
,
20042 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20043 install_element(BGP_NODE
,
20044 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20045 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20046 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20047 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20048 install_element(BGP_NODE
,
20049 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20050 install_element(BGP_NODE
,
20051 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20052 install_element(BGP_NODE
,
20053 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20054 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20055 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20056 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20057 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20058 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20059 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20060 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20061 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20062 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20063 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20064 install_element(BGP_IPV4_NODE
,
20065 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20066 install_element(BGP_IPV4_NODE
,
20067 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20068 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20069 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20070 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20071 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20072 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20073 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20075 /* import|export vpn [route-map RMAP_NAME] */
20076 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20077 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20079 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20080 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20082 /* ttl_security commands */
20083 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20084 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20086 /* "bgp tcp-keepalive" commands */
20087 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20088 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20090 /* "show [ip] bgp memory" commands. */
20091 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20093 /* "show bgp martian next-hop" */
20094 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20096 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20098 /* "show [ip] bgp views" commands. */
20099 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20101 /* "show [ip] bgp vrfs" commands. */
20102 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20104 /* Community-list. */
20105 community_list_vty();
20107 community_alias_vty();
20109 /* vpn-policy commands */
20110 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20111 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20112 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20113 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20114 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20115 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20116 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20117 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20118 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20119 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20120 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20121 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20123 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20124 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20126 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20127 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20128 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20129 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20130 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20131 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20132 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20133 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20134 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20135 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20137 /* tcp-mss command */
20138 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20139 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20141 /* srv6 commands */
20142 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20143 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20144 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20145 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20146 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20147 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20148 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20149 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20150 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20155 #include "memory.h"
20156 #include "bgp_regex.h"
20157 #include "bgp_clist.h"
20158 #include "bgp_ecommunity.h"
20160 /* VTY functions. */
20162 /* Direction value to string conversion. */
20163 static const char *community_direct_str(int direct
)
20166 case COMMUNITY_DENY
:
20168 case COMMUNITY_PERMIT
:
20175 /* Display error string. */
20176 static void community_list_perror(struct vty
*vty
, int ret
)
20179 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20180 vty_out(vty
, "%% Can't find community-list\n");
20182 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20183 vty_out(vty
, "%% Malformed community-list value\n");
20185 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20187 "%% Community name conflict, previously defined as standard community\n");
20189 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20191 "%% Community name conflict, previously defined as expanded community\n");
20196 /* "community-list" keyword help string. */
20197 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20199 /*community-list standard */
20200 DEFUN (community_list_standard
,
20201 bgp_community_list_standard_cmd
,
20202 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20205 "Community list number (standard)\n"
20206 "Add an standard community-list entry\n"
20207 "Community list name\n"
20208 "Sequence number of an entry\n"
20209 "Sequence number\n"
20210 "Specify community to reject\n"
20211 "Specify community to accept\n"
20214 char *cl_name_or_number
= NULL
;
20217 int style
= COMMUNITY_LIST_STANDARD
;
20220 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20221 seq
= argv
[idx
]->arg
;
20224 argv_find(argv
, argc
, "(1-99)", &idx
);
20225 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20226 cl_name_or_number
= argv
[idx
]->arg
;
20227 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20229 argv_find(argv
, argc
, "AA:NN", &idx
);
20230 char *str
= argv_concat(argv
, argc
, idx
);
20232 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20235 XFREE(MTYPE_TMP
, str
);
20238 /* Display error string. */
20239 community_list_perror(vty
, ret
);
20240 return CMD_WARNING_CONFIG_FAILED
;
20243 return CMD_SUCCESS
;
20246 DEFUN (no_community_list_standard_all
,
20247 no_bgp_community_list_standard_all_cmd
,
20248 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20252 "Community list number (standard)\n"
20253 "Add an standard community-list entry\n"
20254 "Community list name\n"
20255 "Sequence number of an entry\n"
20256 "Sequence number\n"
20257 "Specify community to reject\n"
20258 "Specify community to accept\n"
20261 char *cl_name_or_number
= NULL
;
20264 int style
= COMMUNITY_LIST_STANDARD
;
20268 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20269 seq
= argv
[idx
]->arg
;
20272 argv_find(argv
, argc
, "permit", &idx
);
20273 argv_find(argv
, argc
, "deny", &idx
);
20276 direct
= argv_find(argv
, argc
, "permit", &idx
)
20281 argv_find(argv
, argc
, "AA:NN", &idx
);
20282 str
= argv_concat(argv
, argc
, idx
);
20286 argv_find(argv
, argc
, "(1-99)", &idx
);
20287 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20288 cl_name_or_number
= argv
[idx
]->arg
;
20290 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20293 XFREE(MTYPE_TMP
, str
);
20296 community_list_perror(vty
, ret
);
20297 return CMD_WARNING_CONFIG_FAILED
;
20300 return CMD_SUCCESS
;
20303 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20304 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20305 NO_STR BGP_STR COMMUNITY_LIST_STR
20306 "Community list number (standard)\n"
20307 "Add an standard community-list entry\n"
20308 "Community list name\n")
20310 /*community-list expanded */
20311 DEFUN (community_list_expanded_all
,
20312 bgp_community_list_expanded_all_cmd
,
20313 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20316 "Community list number (expanded)\n"
20317 "Add an expanded community-list entry\n"
20318 "Community list name\n"
20319 "Sequence number of an entry\n"
20320 "Sequence number\n"
20321 "Specify community to reject\n"
20322 "Specify community to accept\n"
20325 char *cl_name_or_number
= NULL
;
20328 int style
= COMMUNITY_LIST_EXPANDED
;
20331 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20332 seq
= argv
[idx
]->arg
;
20336 argv_find(argv
, argc
, "(100-500)", &idx
);
20337 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20338 cl_name_or_number
= argv
[idx
]->arg
;
20339 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20341 argv_find(argv
, argc
, "AA:NN", &idx
);
20342 char *str
= argv_concat(argv
, argc
, idx
);
20344 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20347 XFREE(MTYPE_TMP
, str
);
20350 /* Display error string. */
20351 community_list_perror(vty
, ret
);
20352 return CMD_WARNING_CONFIG_FAILED
;
20355 return CMD_SUCCESS
;
20358 DEFUN (no_community_list_expanded_all
,
20359 no_bgp_community_list_expanded_all_cmd
,
20360 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20364 "Community list number (expanded)\n"
20365 "Add an expanded community-list entry\n"
20366 "Community list name\n"
20367 "Sequence number of an entry\n"
20368 "Sequence number\n"
20369 "Specify community to reject\n"
20370 "Specify community to accept\n"
20373 char *cl_name_or_number
= NULL
;
20377 int style
= COMMUNITY_LIST_EXPANDED
;
20380 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20381 seq
= argv
[idx
]->arg
;
20384 argv_find(argv
, argc
, "permit", &idx
);
20385 argv_find(argv
, argc
, "deny", &idx
);
20388 direct
= argv_find(argv
, argc
, "permit", &idx
)
20393 argv_find(argv
, argc
, "AA:NN", &idx
);
20394 str
= argv_concat(argv
, argc
, idx
);
20398 argv_find(argv
, argc
, "(100-500)", &idx
);
20399 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20400 cl_name_or_number
= argv
[idx
]->arg
;
20402 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20405 XFREE(MTYPE_TMP
, str
);
20408 community_list_perror(vty
, ret
);
20409 return CMD_WARNING_CONFIG_FAILED
;
20412 return CMD_SUCCESS
;
20415 ALIAS(no_community_list_expanded_all
,
20416 no_bgp_community_list_expanded_all_list_cmd
,
20417 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20418 NO_STR BGP_STR COMMUNITY_LIST_STR
20419 "Community list number (expanded)\n"
20420 "Add an expanded community-list entry\n"
20421 "Community list name\n")
20423 /* Return configuration string of community-list entry. */
20424 static const char *community_list_config_str(struct community_entry
*entry
)
20431 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20432 str
= community_str(entry
->u
.com
, false, false);
20433 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20434 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20436 str
= entry
->config
;
20441 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20443 struct community_entry
*entry
;
20445 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20446 if (entry
== list
->head
) {
20447 if (all_digit(list
->name
))
20448 vty_out(vty
, "Community %s list %s\n",
20449 entry
->style
== COMMUNITY_LIST_STANDARD
20451 : "(expanded) access",
20454 vty_out(vty
, "Named Community %s list %s\n",
20455 entry
->style
== COMMUNITY_LIST_STANDARD
20461 vty_out(vty
, " %s\n",
20462 community_direct_str(entry
->direct
));
20464 vty_out(vty
, " %s %s\n",
20465 community_direct_str(entry
->direct
),
20466 community_list_config_str(entry
));
20470 DEFUN (show_community_list
,
20471 show_bgp_community_list_cmd
,
20472 "show bgp community-list",
20475 "List community-list\n")
20477 struct community_list
*list
;
20478 struct community_list_master
*cm
;
20480 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20482 return CMD_SUCCESS
;
20484 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20485 community_list_show(vty
, list
);
20487 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20488 community_list_show(vty
, list
);
20490 return CMD_SUCCESS
;
20493 DEFUN (show_community_list_arg
,
20494 show_bgp_community_list_arg_cmd
,
20495 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20498 "List community-list\n"
20499 "Community-list number\n"
20500 "Community-list name\n"
20501 "Detailed information on community-list\n")
20503 int idx_comm_list
= 3;
20504 struct community_list
*list
;
20506 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20507 COMMUNITY_LIST_MASTER
);
20509 vty_out(vty
, "%% Can't find community-list\n");
20510 return CMD_WARNING
;
20513 community_list_show(vty
, list
);
20515 return CMD_SUCCESS
;
20519 * Large Community code.
20521 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20522 struct cmd_token
**argv
, int style
,
20523 int reject_all_digit_name
)
20532 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20533 seq
= argv
[idx
]->arg
;
20536 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20539 /* All digit name check. */
20541 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20542 argv_find(argv
, argc
, "(1-99)", &idx
);
20543 argv_find(argv
, argc
, "(100-500)", &idx
);
20544 cl_name
= argv
[idx
]->arg
;
20545 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20546 vty_out(vty
, "%% Community name cannot have all digits\n");
20547 return CMD_WARNING_CONFIG_FAILED
;
20551 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20552 argv_find(argv
, argc
, "LINE", &idx
);
20553 /* Concat community string argument. */
20555 str
= argv_concat(argv
, argc
, idx
);
20559 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20561 /* Free temporary community list string allocated by
20563 XFREE(MTYPE_TMP
, str
);
20566 community_list_perror(vty
, ret
);
20567 return CMD_WARNING_CONFIG_FAILED
;
20569 return CMD_SUCCESS
;
20572 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20573 struct cmd_token
**argv
, int style
)
20581 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20582 seq
= argv
[idx
]->arg
;
20585 argv_find(argv
, argc
, "permit", &idx
);
20586 argv_find(argv
, argc
, "deny", &idx
);
20589 /* Check the list direct. */
20590 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20591 direct
= COMMUNITY_PERMIT
;
20593 direct
= COMMUNITY_DENY
;
20596 argv_find(argv
, argc
, "LINE", &idx
);
20597 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20598 /* Concat community string argument. */
20599 str
= argv_concat(argv
, argc
, idx
);
20603 argv_find(argv
, argc
, "(1-99)", &idx
);
20604 argv_find(argv
, argc
, "(100-500)", &idx
);
20605 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20607 /* Unset community list. */
20608 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20611 /* Free temporary community list string allocated by
20613 XFREE(MTYPE_TMP
, str
);
20616 community_list_perror(vty
, ret
);
20617 return CMD_WARNING_CONFIG_FAILED
;
20620 return CMD_SUCCESS
;
20623 /* "large-community-list" keyword help string. */
20624 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20625 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20627 DEFUN (lcommunity_list_standard
,
20628 bgp_lcommunity_list_standard_cmd
,
20629 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20631 LCOMMUNITY_LIST_STR
20632 "Large Community list number (standard)\n"
20633 "Sequence number of an entry\n"
20634 "Sequence number\n"
20635 "Specify large community to reject\n"
20636 "Specify large community to accept\n"
20637 LCOMMUNITY_VAL_STR
)
20639 return lcommunity_list_set_vty(vty
, argc
, argv
,
20640 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20643 DEFUN (lcommunity_list_expanded
,
20644 bgp_lcommunity_list_expanded_cmd
,
20645 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20647 LCOMMUNITY_LIST_STR
20648 "Large Community list number (expanded)\n"
20649 "Sequence number of an entry\n"
20650 "Sequence number\n"
20651 "Specify large community to reject\n"
20652 "Specify large community to accept\n"
20653 "An ordered list as a regular-expression\n")
20655 return lcommunity_list_set_vty(vty
, argc
, argv
,
20656 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20659 DEFUN (lcommunity_list_name_standard
,
20660 bgp_lcommunity_list_name_standard_cmd
,
20661 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20663 LCOMMUNITY_LIST_STR
20664 "Specify standard large-community-list\n"
20665 "Large Community list name\n"
20666 "Sequence number of an entry\n"
20667 "Sequence number\n"
20668 "Specify large community to reject\n"
20669 "Specify large community to accept\n"
20670 LCOMMUNITY_VAL_STR
)
20672 return lcommunity_list_set_vty(vty
, argc
, argv
,
20673 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20676 DEFUN (lcommunity_list_name_expanded
,
20677 bgp_lcommunity_list_name_expanded_cmd
,
20678 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20680 LCOMMUNITY_LIST_STR
20681 "Specify expanded large-community-list\n"
20682 "Large Community list name\n"
20683 "Sequence number of an entry\n"
20684 "Sequence number\n"
20685 "Specify large community to reject\n"
20686 "Specify large community to accept\n"
20687 "An ordered list as a regular-expression\n")
20689 return lcommunity_list_set_vty(vty
, argc
, argv
,
20690 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20693 DEFUN (no_lcommunity_list_all
,
20694 no_bgp_lcommunity_list_all_cmd
,
20695 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20698 LCOMMUNITY_LIST_STR
20699 "Large Community list number (standard)\n"
20700 "Large Community list number (expanded)\n"
20701 "Large Community list name\n")
20703 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20704 LARGE_COMMUNITY_LIST_STANDARD
);
20707 DEFUN (no_lcommunity_list_name_standard_all
,
20708 no_bgp_lcommunity_list_name_standard_all_cmd
,
20709 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20712 LCOMMUNITY_LIST_STR
20713 "Specify standard large-community-list\n"
20714 "Large Community list name\n")
20716 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20717 LARGE_COMMUNITY_LIST_STANDARD
);
20720 DEFUN (no_lcommunity_list_name_expanded_all
,
20721 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20722 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20725 LCOMMUNITY_LIST_STR
20726 "Specify expanded large-community-list\n"
20727 "Large Community list name\n")
20729 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20730 LARGE_COMMUNITY_LIST_EXPANDED
);
20733 DEFUN (no_lcommunity_list_standard
,
20734 no_bgp_lcommunity_list_standard_cmd
,
20735 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20738 LCOMMUNITY_LIST_STR
20739 "Large Community list number (standard)\n"
20740 "Sequence number of an entry\n"
20741 "Sequence number\n"
20742 "Specify large community to reject\n"
20743 "Specify large community to accept\n"
20744 LCOMMUNITY_VAL_STR
)
20746 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20747 LARGE_COMMUNITY_LIST_STANDARD
);
20750 DEFUN (no_lcommunity_list_expanded
,
20751 no_bgp_lcommunity_list_expanded_cmd
,
20752 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20755 LCOMMUNITY_LIST_STR
20756 "Large Community list number (expanded)\n"
20757 "Sequence number of an entry\n"
20758 "Sequence number\n"
20759 "Specify large community to reject\n"
20760 "Specify large community to accept\n"
20761 "An ordered list as a regular-expression\n")
20763 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20764 LARGE_COMMUNITY_LIST_EXPANDED
);
20767 DEFUN (no_lcommunity_list_name_standard
,
20768 no_bgp_lcommunity_list_name_standard_cmd
,
20769 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20772 LCOMMUNITY_LIST_STR
20773 "Specify standard large-community-list\n"
20774 "Large Community list name\n"
20775 "Sequence number of an entry\n"
20776 "Sequence number\n"
20777 "Specify large community to reject\n"
20778 "Specify large community to accept\n"
20779 LCOMMUNITY_VAL_STR
)
20781 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20782 LARGE_COMMUNITY_LIST_STANDARD
);
20785 DEFUN (no_lcommunity_list_name_expanded
,
20786 no_bgp_lcommunity_list_name_expanded_cmd
,
20787 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20790 LCOMMUNITY_LIST_STR
20791 "Specify expanded large-community-list\n"
20792 "Large community list name\n"
20793 "Sequence number of an entry\n"
20794 "Sequence number\n"
20795 "Specify large community to reject\n"
20796 "Specify large community to accept\n"
20797 "An ordered list as a regular-expression\n")
20799 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20800 LARGE_COMMUNITY_LIST_EXPANDED
);
20803 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20805 struct community_entry
*entry
;
20807 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20808 if (entry
== list
->head
) {
20809 if (all_digit(list
->name
))
20810 vty_out(vty
, "Large community %s list %s\n",
20812 LARGE_COMMUNITY_LIST_STANDARD
20814 : "(expanded) access",
20818 "Named large community %s list %s\n",
20820 LARGE_COMMUNITY_LIST_STANDARD
20826 vty_out(vty
, " %s\n",
20827 community_direct_str(entry
->direct
));
20829 vty_out(vty
, " %s %s\n",
20830 community_direct_str(entry
->direct
),
20831 community_list_config_str(entry
));
20835 DEFUN (show_lcommunity_list
,
20836 show_bgp_lcommunity_list_cmd
,
20837 "show bgp large-community-list",
20840 "List large-community list\n")
20842 struct community_list
*list
;
20843 struct community_list_master
*cm
;
20845 cm
= community_list_master_lookup(bgp_clist
,
20846 LARGE_COMMUNITY_LIST_MASTER
);
20848 return CMD_SUCCESS
;
20850 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20851 lcommunity_list_show(vty
, list
);
20853 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20854 lcommunity_list_show(vty
, list
);
20856 return CMD_SUCCESS
;
20859 DEFUN (show_lcommunity_list_arg
,
20860 show_bgp_lcommunity_list_arg_cmd
,
20861 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20864 "List large-community list\n"
20865 "Large-community-list number\n"
20866 "Large-community-list name\n"
20867 "Detailed information on large-community-list\n")
20869 struct community_list
*list
;
20871 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20872 LARGE_COMMUNITY_LIST_MASTER
);
20874 vty_out(vty
, "%% Can't find large-community-list\n");
20875 return CMD_WARNING
;
20878 lcommunity_list_show(vty
, list
);
20880 return CMD_SUCCESS
;
20883 /* "extcommunity-list" keyword help string. */
20884 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20885 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20887 DEFUN (extcommunity_list_standard
,
20888 bgp_extcommunity_list_standard_cmd
,
20889 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20891 EXTCOMMUNITY_LIST_STR
20892 "Extended Community list number (standard)\n"
20893 "Specify standard extcommunity-list\n"
20894 "Community list name\n"
20895 "Sequence number of an entry\n"
20896 "Sequence number\n"
20897 "Specify community to reject\n"
20898 "Specify community to accept\n"
20899 EXTCOMMUNITY_VAL_STR
)
20901 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20903 char *cl_number_or_name
= NULL
;
20908 argv_find(argv
, argc
, "(1-99)", &idx
);
20909 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20910 cl_number_or_name
= argv
[idx
]->arg
;
20912 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20913 seq
= argv
[idx
]->arg
;
20915 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20917 argv_find(argv
, argc
, "AA:NN", &idx
);
20918 char *str
= argv_concat(argv
, argc
, idx
);
20920 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20923 XFREE(MTYPE_TMP
, str
);
20926 community_list_perror(vty
, ret
);
20927 return CMD_WARNING_CONFIG_FAILED
;
20930 return CMD_SUCCESS
;
20933 DEFUN (extcommunity_list_name_expanded
,
20934 bgp_extcommunity_list_name_expanded_cmd
,
20935 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20937 EXTCOMMUNITY_LIST_STR
20938 "Extended Community list number (expanded)\n"
20939 "Specify expanded extcommunity-list\n"
20940 "Extended Community list name\n"
20941 "Sequence number of an entry\n"
20942 "Sequence number\n"
20943 "Specify community to reject\n"
20944 "Specify community to accept\n"
20945 "An ordered list as a regular-expression\n")
20947 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20949 char *cl_number_or_name
= NULL
;
20953 argv_find(argv
, argc
, "(100-500)", &idx
);
20954 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20955 cl_number_or_name
= argv
[idx
]->arg
;
20957 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20958 seq
= argv
[idx
]->arg
;
20960 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20962 argv_find(argv
, argc
, "LINE", &idx
);
20963 char *str
= argv_concat(argv
, argc
, idx
);
20965 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20968 XFREE(MTYPE_TMP
, str
);
20971 community_list_perror(vty
, ret
);
20972 return CMD_WARNING_CONFIG_FAILED
;
20975 return CMD_SUCCESS
;
20978 DEFUN (no_extcommunity_list_standard_all
,
20979 no_bgp_extcommunity_list_standard_all_cmd
,
20980 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20983 EXTCOMMUNITY_LIST_STR
20984 "Extended Community list number (standard)\n"
20985 "Specify standard extcommunity-list\n"
20986 "Community list name\n"
20987 "Sequence number of an entry\n"
20988 "Sequence number\n"
20989 "Specify community to reject\n"
20990 "Specify community to accept\n"
20991 EXTCOMMUNITY_VAL_STR
)
20993 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20995 char *cl_number_or_name
= NULL
;
21000 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21001 seq
= argv
[idx
]->arg
;
21004 argv_find(argv
, argc
, "permit", &idx
);
21005 argv_find(argv
, argc
, "deny", &idx
);
21007 direct
= argv_find(argv
, argc
, "permit", &idx
)
21012 argv_find(argv
, argc
, "AA:NN", &idx
);
21013 str
= argv_concat(argv
, argc
, idx
);
21017 argv_find(argv
, argc
, "(1-99)", &idx
);
21018 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21019 cl_number_or_name
= argv
[idx
]->arg
;
21021 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21022 seq
, direct
, style
);
21024 XFREE(MTYPE_TMP
, str
);
21027 community_list_perror(vty
, ret
);
21028 return CMD_WARNING_CONFIG_FAILED
;
21031 return CMD_SUCCESS
;
21034 ALIAS(no_extcommunity_list_standard_all
,
21035 no_bgp_extcommunity_list_standard_all_list_cmd
,
21036 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21037 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21038 "Extended Community list number (standard)\n"
21039 "Specify standard extcommunity-list\n"
21040 "Community list name\n")
21042 DEFUN (no_extcommunity_list_expanded_all
,
21043 no_bgp_extcommunity_list_expanded_all_cmd
,
21044 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21047 EXTCOMMUNITY_LIST_STR
21048 "Extended Community list number (expanded)\n"
21049 "Specify expanded extcommunity-list\n"
21050 "Extended Community list name\n"
21051 "Sequence number of an entry\n"
21052 "Sequence number\n"
21053 "Specify community to reject\n"
21054 "Specify community to accept\n"
21055 "An ordered list as a regular-expression\n")
21057 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21059 char *cl_number_or_name
= NULL
;
21064 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21065 seq
= argv
[idx
]->arg
;
21068 argv_find(argv
, argc
, "permit", &idx
);
21069 argv_find(argv
, argc
, "deny", &idx
);
21072 direct
= argv_find(argv
, argc
, "permit", &idx
)
21077 argv_find(argv
, argc
, "LINE", &idx
);
21078 str
= argv_concat(argv
, argc
, idx
);
21082 argv_find(argv
, argc
, "(100-500)", &idx
);
21083 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21084 cl_number_or_name
= argv
[idx
]->arg
;
21086 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21087 seq
, direct
, style
);
21089 XFREE(MTYPE_TMP
, str
);
21092 community_list_perror(vty
, ret
);
21093 return CMD_WARNING_CONFIG_FAILED
;
21096 return CMD_SUCCESS
;
21099 ALIAS(no_extcommunity_list_expanded_all
,
21100 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21101 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21102 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21103 "Extended Community list number (expanded)\n"
21104 "Specify expanded extcommunity-list\n"
21105 "Extended Community list name\n")
21107 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21109 struct community_entry
*entry
;
21111 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21112 if (entry
== list
->head
) {
21113 if (all_digit(list
->name
))
21114 vty_out(vty
, "Extended community %s list %s\n",
21115 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21117 : "(expanded) access",
21121 "Named extended community %s list %s\n",
21122 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21128 vty_out(vty
, " %s\n",
21129 community_direct_str(entry
->direct
));
21131 vty_out(vty
, " %s %s\n",
21132 community_direct_str(entry
->direct
),
21133 community_list_config_str(entry
));
21137 DEFUN (show_extcommunity_list
,
21138 show_bgp_extcommunity_list_cmd
,
21139 "show bgp extcommunity-list",
21142 "List extended-community list\n")
21144 struct community_list
*list
;
21145 struct community_list_master
*cm
;
21147 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21149 return CMD_SUCCESS
;
21151 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21152 extcommunity_list_show(vty
, list
);
21154 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21155 extcommunity_list_show(vty
, list
);
21157 return CMD_SUCCESS
;
21160 DEFUN (show_extcommunity_list_arg
,
21161 show_bgp_extcommunity_list_arg_cmd
,
21162 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21165 "List extended-community list\n"
21166 "Extcommunity-list number\n"
21167 "Extcommunity-list name\n"
21168 "Detailed information on extcommunity-list\n")
21170 int idx_comm_list
= 3;
21171 struct community_list
*list
;
21173 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21174 EXTCOMMUNITY_LIST_MASTER
);
21176 vty_out(vty
, "%% Can't find extcommunity-list\n");
21177 return CMD_WARNING
;
21180 extcommunity_list_show(vty
, list
);
21182 return CMD_SUCCESS
;
21185 /* Display community-list and extcommunity-list configuration. */
21186 static int community_list_config_write(struct vty
*vty
)
21188 struct community_list
*list
;
21189 struct community_entry
*entry
;
21190 struct community_list_master
*cm
;
21193 /* Community-list. */
21194 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21196 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21197 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21199 "bgp community-list %s seq %" PRId64
" %s %s\n",
21200 list
->name
, entry
->seq
,
21201 community_direct_str(entry
->direct
),
21202 community_list_config_str(entry
));
21205 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21206 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21208 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21209 entry
->style
== COMMUNITY_LIST_STANDARD
21212 list
->name
, entry
->seq
,
21213 community_direct_str(entry
->direct
),
21214 community_list_config_str(entry
));
21218 /* Extcommunity-list. */
21219 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21221 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21222 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21224 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21225 list
->name
, entry
->seq
,
21226 community_direct_str(entry
->direct
),
21227 community_list_config_str(entry
));
21230 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21231 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21233 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21234 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21237 list
->name
, entry
->seq
,
21238 community_direct_str(entry
->direct
),
21239 community_list_config_str(entry
));
21244 /* lcommunity-list. */
21245 cm
= community_list_master_lookup(bgp_clist
,
21246 LARGE_COMMUNITY_LIST_MASTER
);
21248 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21249 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21251 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21252 list
->name
, entry
->seq
,
21253 community_direct_str(entry
->direct
),
21254 community_list_config_str(entry
));
21257 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21258 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21260 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21262 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21265 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21266 community_list_config_str(entry
));
21273 static int community_list_config_write(struct vty
*vty
);
21274 static struct cmd_node community_list_node
= {
21275 .name
= "community list",
21276 .node
= COMMUNITY_LIST_NODE
,
21278 .config_write
= community_list_config_write
,
21281 static void community_list_vty(void)
21283 install_node(&community_list_node
);
21285 /* Community-list. */
21286 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21287 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21288 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21289 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21290 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21291 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21292 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21293 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21295 /* Extcommunity-list. */
21296 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21297 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21298 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21299 install_element(CONFIG_NODE
,
21300 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21301 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21302 install_element(CONFIG_NODE
,
21303 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21304 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21305 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21307 /* Large Community List */
21308 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21309 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21310 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21311 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21312 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21313 install_element(CONFIG_NODE
,
21314 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21315 install_element(CONFIG_NODE
,
21316 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21317 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21318 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21319 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21320 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21321 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21322 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21324 bgp_community_list_command_completion_setup();
21327 static struct cmd_node community_alias_node
= {
21328 .name
= "community alias",
21329 .node
= COMMUNITY_ALIAS_NODE
,
21331 .config_write
= bgp_community_alias_write
,
21334 void community_alias_vty(void)
21336 install_node(&community_alias_node
);
21338 /* Community-list. */
21339 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21341 bgp_community_alias_command_completion_setup();