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
, true);
8795 DEFPY(no_neighbor_path_attribute_discard
,
8796 no_neighbor_path_attribute_discard_cmd
,
8797 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]",
8801 "Manipulate path attributes from incoming UPDATE messages\n"
8802 "Drop specified attributes from incoming UPDATE messages\n"
8803 "Attribute number\n")
8807 const char *discard_attrs
= NULL
;
8809 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8811 return CMD_WARNING_CONFIG_FAILED
;
8813 argv_find(argv
, argc
, "(1-255)", &idx
);
8815 discard_attrs
= argv
[idx
]->arg
;
8817 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, false);
8822 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8823 struct ecommunity
**list
, bool is_rt6
)
8825 struct ecommunity
*ecom
= NULL
;
8826 struct ecommunity
*ecomadd
;
8828 for (; argc
; --argc
, ++argv
) {
8830 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8831 ECOMMUNITY_ROUTE_TARGET
,
8834 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8835 ECOMMUNITY_ROUTE_TARGET
,
8838 vty_out(vty
, "Malformed community-list value\n");
8840 ecommunity_free(&ecom
);
8841 return CMD_WARNING_CONFIG_FAILED
;
8845 ecommunity_merge(ecom
, ecomadd
);
8846 ecommunity_free(&ecomadd
);
8853 ecommunity_free(&*list
);
8861 * v2vimport is true if we are handling a `import vrf ...` command
8863 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8867 switch (vty
->node
) {
8876 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8881 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8882 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8883 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8884 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8886 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8890 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8891 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8892 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8893 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8895 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8902 DEFPY (af_rd_vpn_export
,
8903 af_rd_vpn_export_cmd
,
8904 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8906 "Specify route distinguisher\n"
8907 "Between current address-family and vpn\n"
8908 "For routes leaked from current address-family to vpn\n"
8909 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8912 struct prefix_rd prd
;
8918 if (argv_find(argv
, argc
, "no", &idx
))
8922 ret
= str2prefix_rd(rd_str
, &prd
);
8924 vty_out(vty
, "%% Malformed rd\n");
8925 return CMD_WARNING_CONFIG_FAILED
;
8929 afi
= vpn_policy_getafi(vty
, bgp
, false);
8931 return CMD_WARNING_CONFIG_FAILED
;
8934 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8936 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8937 bgp_get_default(), bgp
);
8940 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8941 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8942 BGP_VPN_POLICY_TOVPN_RD_SET
);
8944 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8945 BGP_VPN_POLICY_TOVPN_RD_SET
);
8948 /* post-change: re-export vpn routes */
8949 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8950 bgp_get_default(), bgp
);
8955 ALIAS (af_rd_vpn_export
,
8956 af_no_rd_vpn_export_cmd
,
8959 "Specify route distinguisher\n"
8960 "Between current address-family and vpn\n"
8961 "For routes leaked from current address-family to vpn\n")
8963 DEFPY (af_label_vpn_export
,
8964 af_label_vpn_export_cmd
,
8965 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8967 "label value for VRF\n"
8968 "Between current address-family and vpn\n"
8969 "For routes leaked from current address-family to vpn\n"
8970 "Label Value <0-1048575>\n"
8971 "Automatically assign a label\n")
8973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8974 mpls_label_t label
= MPLS_LABEL_NONE
;
8979 if (argv_find(argv
, argc
, "no", &idx
))
8982 /* If "no ...", squash trailing parameter */
8988 label
= label_val
; /* parser should force unsigned */
8991 afi
= vpn_policy_getafi(vty
, bgp
, false);
8993 return CMD_WARNING_CONFIG_FAILED
;
8996 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8997 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9002 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9004 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9005 bgp_get_default(), bgp
);
9007 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9008 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9010 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9013 * label has previously been automatically
9014 * assigned by labelpool: release it
9016 * NB if tovpn_label == MPLS_LABEL_NONE it
9017 * means the automatic assignment is in flight
9018 * and therefore the labelpool callback must
9019 * detect that the auto label is not needed.
9022 bgp_lp_release(LP_TYPE_VRF
,
9023 &bgp
->vpn_policy
[afi
],
9024 bgp
->vpn_policy
[afi
].tovpn_label
);
9026 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9027 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9030 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9032 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9033 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9034 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9035 vpn_leak_label_callback
);
9038 /* post-change: re-export vpn routes */
9039 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9040 bgp_get_default(), bgp
);
9042 hook_call(bgp_snmp_update_last_changed
, bgp
);
9046 DEFPY (af_sid_vpn_export
,
9047 af_sid_vpn_export_cmd
,
9048 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9050 "sid value for VRF\n"
9051 "Between current address-family and vpn\n"
9052 "For routes leaked from current address-family to vpn\n"
9053 "Sid allocation index\n"
9054 "Automatically assign a label\n")
9056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9062 if (argv_find(argv
, argc
, "no", &idx
))
9064 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9065 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9067 afi
= vpn_policy_getafi(vty
, bgp
, false);
9069 return CMD_WARNING_CONFIG_FAILED
;
9073 vty_out(vty
, "It's not implemented\n");
9074 return CMD_WARNING_CONFIG_FAILED
;
9077 if (bgp
->tovpn_sid_index
!= 0 ||
9078 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9080 "per-vrf sid and per-af sid are mutually exclusive\n"
9081 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9082 return CMD_WARNING_CONFIG_FAILED
;
9085 /* skip when it's already configured */
9086 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9087 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9088 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9092 * mode change between sid_idx and sid_auto isn't supported.
9093 * user must negate sid vpn export when they want to change the mode
9095 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9096 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9097 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9098 vty_out(vty
, "it's already configured as %s.\n",
9099 sid_auto
? "auto-mode" : "idx-mode");
9100 return CMD_WARNING_CONFIG_FAILED
;
9104 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9105 bgp_get_default(), bgp
);
9108 /* SID allocation auto-mode */
9110 zlog_debug("%s: auto sid alloc.", __func__
);
9111 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9112 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9114 /* SID allocation index-mode */
9116 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9117 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9121 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9122 bgp_get_default(), bgp
);
9126 DEFPY (bgp_sid_vpn_export
,
9127 bgp_sid_vpn_export_cmd
,
9128 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9130 "sid value for VRF\n"
9131 "Between current vrf and vpn\n"
9132 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9133 "For routes leaked from current vrf to vpn\n"
9134 "Sid allocation index\n"
9135 "Automatically assign a label\n")
9137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9140 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9141 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9144 /* when per-VRF SID is not set, do nothing */
9145 if (bgp
->tovpn_sid_index
== 0 &&
9146 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9151 bgp
->tovpn_sid_index
= 0;
9152 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9155 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9156 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9157 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9158 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9159 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9160 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9162 "per-vrf sid and per-af sid are mutually exclusive\n"
9163 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9164 return CMD_WARNING_CONFIG_FAILED
;
9167 /* skip when it's already configured */
9168 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9169 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9173 * mode change between sid_idx and sid_auto isn't supported.
9174 * user must negate sid vpn export when they want to change the mode
9176 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9178 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9179 vty_out(vty
, "it's already configured as %s.\n",
9180 sid_auto
? "auto-mode" : "idx-mode");
9181 return CMD_WARNING_CONFIG_FAILED
;
9185 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9187 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9191 /* SID allocation auto-mode */
9193 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9194 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9195 } else if (sid_idx
!= 0) {
9196 /* SID allocation index-mode */
9198 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9200 bgp
->tovpn_sid_index
= sid_idx
;
9204 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9206 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9207 bgp_get_default(), bgp
);
9212 ALIAS (af_label_vpn_export
,
9213 af_no_label_vpn_export_cmd
,
9214 "no label vpn export",
9216 "label value for VRF\n"
9217 "Between current address-family and vpn\n"
9218 "For routes leaked from current address-family to vpn\n")
9220 ALIAS (bgp_sid_vpn_export
,
9221 no_bgp_sid_vpn_export_cmd
,
9222 "no$no sid vpn per-vrf export",
9224 "sid value for VRF\n"
9225 "Between current vrf and vpn\n"
9226 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9227 "For routes leaked from current vrf to vpn\n")
9229 DEFPY (af_nexthop_vpn_export
,
9230 af_nexthop_vpn_export_cmd
,
9231 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9233 "Specify next hop to use for VRF advertised prefixes\n"
9234 "Between current address-family and vpn\n"
9235 "For routes leaked from current address-family to vpn\n"
9239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9245 vty_out(vty
, "%% Nexthop required\n");
9246 return CMD_WARNING_CONFIG_FAILED
;
9248 if (!sockunion2hostprefix(nexthop_su
, &p
))
9249 return CMD_WARNING_CONFIG_FAILED
;
9252 afi
= vpn_policy_getafi(vty
, bgp
, false);
9254 return CMD_WARNING_CONFIG_FAILED
;
9257 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9259 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9260 bgp_get_default(), bgp
);
9263 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9264 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9265 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9267 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9268 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9271 /* post-change: re-export vpn routes */
9272 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9273 bgp_get_default(), bgp
);
9278 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9280 if (!strcmp(dstr
, "import")) {
9281 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9282 } else if (!strcmp(dstr
, "export")) {
9283 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9284 } else if (!strcmp(dstr
, "both")) {
9285 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9286 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9288 vty_out(vty
, "%% direction parse error\n");
9289 return CMD_WARNING_CONFIG_FAILED
;
9294 DEFPY (af_rt_vpn_imexport
,
9295 af_rt_vpn_imexport_cmd
,
9296 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9298 "Specify route target list\n"
9299 "Specify route target list\n"
9300 "Between current address-family and vpn\n"
9301 "For routes leaked from vpn to current address-family: match any\n"
9302 "For routes leaked from current address-family to vpn: set\n"
9303 "both import: match any and export: set\n"
9304 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9308 struct ecommunity
*ecom
= NULL
;
9309 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9310 enum vpn_policy_direction dir
;
9315 if (argv_find(argv
, argc
, "no", &idx
))
9318 afi
= vpn_policy_getafi(vty
, bgp
, false);
9320 return CMD_WARNING_CONFIG_FAILED
;
9322 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9323 if (ret
!= CMD_SUCCESS
)
9327 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9328 vty_out(vty
, "%% Missing RTLIST\n");
9329 return CMD_WARNING_CONFIG_FAILED
;
9331 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9332 if (ret
!= CMD_SUCCESS
) {
9337 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9341 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9344 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9346 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9347 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9348 ecommunity_dup(ecom
);
9350 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9352 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9353 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9356 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9360 ecommunity_free(&ecom
);
9365 ALIAS (af_rt_vpn_imexport
,
9366 af_no_rt_vpn_imexport_cmd
,
9367 "no <rt|route-target> vpn <import|export|both>$direction_str",
9369 "Specify route target list\n"
9370 "Specify route target list\n"
9371 "Between current address-family and vpn\n"
9372 "For routes leaked from vpn to current address-family\n"
9373 "For routes leaked from current address-family to vpn\n"
9374 "both import and export\n")
9376 DEFPY (af_route_map_vpn_imexport
,
9377 af_route_map_vpn_imexport_cmd
,
9378 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9379 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9381 "Specify route map\n"
9382 "Between current address-family and vpn\n"
9383 "For routes leaked from vpn to current address-family\n"
9384 "For routes leaked from current address-family to vpn\n"
9385 "name of route-map\n")
9387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9389 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9390 enum vpn_policy_direction dir
;
9395 if (argv_find(argv
, argc
, "no", &idx
))
9398 afi
= vpn_policy_getafi(vty
, bgp
, false);
9400 return CMD_WARNING_CONFIG_FAILED
;
9402 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9403 if (ret
!= CMD_SUCCESS
)
9406 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9410 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9413 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9414 XFREE(MTYPE_ROUTE_MAP_NAME
,
9415 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9416 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9417 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9418 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9419 route_map_lookup_warn_noexist(vty
, rmap_str
);
9420 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9423 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9424 XFREE(MTYPE_ROUTE_MAP_NAME
,
9425 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9426 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9427 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9430 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9436 ALIAS (af_route_map_vpn_imexport
,
9437 af_no_route_map_vpn_imexport_cmd
,
9438 "no route-map vpn <import|export>$direction_str",
9440 "Specify route map\n"
9441 "Between current address-family and vpn\n"
9442 "For routes leaked from vpn to current address-family\n"
9443 "For routes leaked from current address-family to vpn\n")
9445 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9446 "import vrf route-map RMAP$rmap_str",
9447 "Import routes from another VRF\n"
9448 "Vrf routes being filtered\n"
9449 "Specify route map\n"
9450 "name of route-map\n")
9452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9453 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9455 struct bgp
*bgp_default
;
9457 afi
= vpn_policy_getafi(vty
, bgp
, true);
9459 return CMD_WARNING_CONFIG_FAILED
;
9461 bgp_default
= bgp_get_default();
9466 /* Auto-create assuming the same AS */
9467 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9468 BGP_INSTANCE_TYPE_DEFAULT
);
9472 "VRF default is not configured as a bgp instance\n");
9477 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9479 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9480 XFREE(MTYPE_ROUTE_MAP_NAME
,
9481 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9482 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9483 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9484 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9485 route_map_lookup_warn_noexist(vty
, rmap_str
);
9486 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9489 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9490 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9492 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9497 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9498 "no import vrf route-map [RMAP$rmap_str]",
9500 "Import routes from another VRF\n"
9501 "Vrf routes being filtered\n"
9502 "Specify route map\n"
9503 "name of route-map\n")
9505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9506 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9509 afi
= vpn_policy_getafi(vty
, bgp
, true);
9511 return CMD_WARNING_CONFIG_FAILED
;
9513 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9515 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9516 XFREE(MTYPE_ROUTE_MAP_NAME
,
9517 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9518 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9519 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9521 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9522 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9523 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9525 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9530 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9531 "[no] import vrf VIEWVRFNAME$import_name",
9533 "Import routes from another VRF\n"
9534 "VRF to import from\n"
9535 "The name of the VRF\n")
9537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9538 struct listnode
*node
;
9539 struct bgp
*vrf_bgp
, *bgp_default
;
9542 bool remove
= false;
9545 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9549 if (import_name
== NULL
) {
9550 vty_out(vty
, "%% Missing import name\n");
9554 if (strcmp(import_name
, "route-map") == 0) {
9555 vty_out(vty
, "%% Must include route-map name\n");
9559 if (argv_find(argv
, argc
, "no", &idx
))
9562 afi
= vpn_policy_getafi(vty
, bgp
, true);
9564 return CMD_WARNING_CONFIG_FAILED
;
9566 safi
= bgp_node_safi(vty
);
9568 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9569 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9570 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9571 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9572 remove
? "unimport" : "import", import_name
);
9576 bgp_default
= bgp_get_default();
9578 /* Auto-create assuming the same AS */
9579 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9580 BGP_INSTANCE_TYPE_DEFAULT
);
9584 "VRF default is not configured as a bgp instance\n");
9589 vrf_bgp
= bgp_lookup_by_name(import_name
);
9591 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9592 vrf_bgp
= bgp_default
;
9594 /* Auto-create assuming the same AS */
9595 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9599 "VRF %s is not configured as a bgp instance\n",
9606 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9608 /* Already importing from "import_vrf"? */
9609 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9611 if (strcmp(vname
, import_name
) == 0)
9615 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9621 /* This command is valid only in a bgp vrf instance or the default instance */
9622 DEFPY (bgp_imexport_vpn
,
9623 bgp_imexport_vpn_cmd
,
9624 "[no] <import|export>$direction_str vpn",
9626 "Import routes to this address-family\n"
9627 "Export routes from this address-family\n"
9628 "to/from default instance VPN RIB\n")
9630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9637 enum vpn_policy_direction dir
;
9639 if (argv_find(argv
, argc
, "no", &idx
))
9642 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9643 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9645 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9646 return CMD_WARNING_CONFIG_FAILED
;
9649 afi
= bgp_node_afi(vty
);
9650 safi
= bgp_node_safi(vty
);
9651 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9652 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9653 return CMD_WARNING_CONFIG_FAILED
;
9656 if (!strcmp(direction_str
, "import")) {
9657 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9658 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9659 } else if (!strcmp(direction_str
, "export")) {
9660 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9661 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9663 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9664 return CMD_WARNING_CONFIG_FAILED
;
9667 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9670 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9671 if (!previous_state
) {
9672 /* trigger export current vrf */
9673 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9676 if (previous_state
) {
9677 /* trigger un-export current vrf */
9678 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9680 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9683 hook_call(bgp_snmp_init_stats
, bgp
);
9688 DEFPY (af_routetarget_import
,
9689 af_routetarget_import_cmd
,
9690 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9692 "Specify route target list\n"
9693 "Specify route target list\n"
9694 "Specify route target list\n"
9695 "Specify route target list\n"
9696 "Flow-spec redirect type route target\n"
9697 "Import routes to this address-family\n"
9698 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9700 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9702 struct ecommunity
*ecom
= NULL
;
9704 int idx
= 0, idx_unused
= 0;
9708 if (argv_find(argv
, argc
, "no", &idx
))
9711 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9712 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9715 afi
= vpn_policy_getafi(vty
, bgp
, false);
9717 return CMD_WARNING_CONFIG_FAILED
;
9719 if (rt6
&& afi
!= AFI_IP6
)
9720 return CMD_WARNING_CONFIG_FAILED
;
9723 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9724 vty_out(vty
, "%% Missing RTLIST\n");
9725 return CMD_WARNING_CONFIG_FAILED
;
9727 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9728 if (ret
!= CMD_SUCCESS
)
9733 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9734 ecommunity_free(&bgp
->vpn_policy
[afi
]
9735 .import_redirect_rtlist
);
9736 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9737 ecommunity_dup(ecom
);
9739 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9740 ecommunity_free(&bgp
->vpn_policy
[afi
]
9741 .import_redirect_rtlist
);
9742 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9746 ecommunity_free(&ecom
);
9751 DEFUN_NOSH (address_family_ipv4_safi
,
9752 address_family_ipv4_safi_cmd
,
9753 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9754 "Enter Address Family command mode\n"
9756 BGP_SAFI_WITH_LABEL_HELP_STR
)
9760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9761 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9762 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9763 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9764 && safi
!= SAFI_EVPN
) {
9766 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9767 return CMD_WARNING_CONFIG_FAILED
;
9769 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9771 vty
->node
= BGP_IPV4_NODE
;
9776 DEFUN_NOSH (address_family_ipv6_safi
,
9777 address_family_ipv6_safi_cmd
,
9778 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9779 "Enter Address Family command mode\n"
9781 BGP_SAFI_WITH_LABEL_HELP_STR
)
9784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9785 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9786 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9787 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9788 && safi
!= SAFI_EVPN
) {
9790 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9791 return CMD_WARNING_CONFIG_FAILED
;
9793 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9795 vty
->node
= BGP_IPV6_NODE
;
9800 #ifdef KEEP_OLD_VPN_COMMANDS
9801 DEFUN_NOSH (address_family_vpnv4
,
9802 address_family_vpnv4_cmd
,
9803 "address-family vpnv4 [unicast]",
9804 "Enter Address Family command mode\n"
9806 BGP_AF_MODIFIER_STR
)
9808 vty
->node
= BGP_VPNV4_NODE
;
9812 DEFUN_NOSH (address_family_vpnv6
,
9813 address_family_vpnv6_cmd
,
9814 "address-family vpnv6 [unicast]",
9815 "Enter Address Family command mode\n"
9817 BGP_AF_MODIFIER_STR
)
9819 vty
->node
= BGP_VPNV6_NODE
;
9822 #endif /* KEEP_OLD_VPN_COMMANDS */
9824 DEFUN_NOSH (address_family_evpn
,
9825 address_family_evpn_cmd
,
9826 "address-family l2vpn evpn",
9827 "Enter Address Family command mode\n"
9829 BGP_AF_MODIFIER_STR
)
9831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9832 vty
->node
= BGP_EVPN_NODE
;
9836 DEFUN_NOSH (bgp_segment_routing_srv6
,
9837 bgp_segment_routing_srv6_cmd
,
9838 "segment-routing srv6",
9839 "Segment-Routing configuration\n"
9840 "Segment-Routing SRv6 configuration\n")
9842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9843 bgp
->srv6_enabled
= true;
9844 vty
->node
= BGP_SRV6_NODE
;
9848 DEFUN (no_bgp_segment_routing_srv6
,
9849 no_bgp_segment_routing_srv6_cmd
,
9850 "no segment-routing srv6",
9852 "Segment-Routing configuration\n"
9853 "Segment-Routing SRv6 configuration\n")
9855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9857 if (strlen(bgp
->srv6_locator_name
) > 0)
9858 if (bgp_srv6_locator_unset(bgp
) < 0)
9859 return CMD_WARNING_CONFIG_FAILED
;
9861 bgp
->srv6_enabled
= false;
9865 DEFPY (bgp_srv6_locator
,
9866 bgp_srv6_locator_cmd
,
9867 "locator NAME$name",
9868 "Specify SRv6 locator\n"
9869 "Specify SRv6 locator\n")
9871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9874 if (strlen(bgp
->srv6_locator_name
) > 0
9875 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9876 vty_out(vty
, "srv6 locator is already configured\n");
9877 return CMD_WARNING_CONFIG_FAILED
;
9880 snprintf(bgp
->srv6_locator_name
,
9881 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9883 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9885 return CMD_WARNING_CONFIG_FAILED
;
9890 DEFPY (no_bgp_srv6_locator
,
9891 no_bgp_srv6_locator_cmd
,
9892 "no locator NAME$name",
9894 "Specify SRv6 locator\n"
9895 "Specify SRv6 locator\n")
9897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9899 /* when locator isn't configured, do nothing */
9900 if (strlen(bgp
->srv6_locator_name
) < 1)
9903 /* name validation */
9904 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9905 vty_out(vty
, "%% No srv6 locator is configured\n");
9906 return CMD_WARNING_CONFIG_FAILED
;
9910 if (bgp_srv6_locator_unset(bgp
) < 0)
9911 return CMD_WARNING_CONFIG_FAILED
;
9916 DEFPY (show_bgp_srv6
,
9918 "show bgp segment-routing srv6",
9921 "BGP Segment Routing\n"
9922 "BGP Segment Routing SRv6\n")
9925 struct listnode
*node
;
9926 struct srv6_locator_chunk
*chunk
;
9927 struct bgp_srv6_function
*func
;
9929 bgp
= bgp_get_default();
9933 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9934 vty_out(vty
, "locator_chunks:\n");
9935 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9936 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9937 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9938 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9939 vty_out(vty
, " func-length: %d\n",
9940 chunk
->function_bits_length
);
9941 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9944 vty_out(vty
, "functions:\n");
9945 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9946 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
9947 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9950 vty_out(vty
, "bgps:\n");
9951 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9952 vty_out(vty
, "- name: %s\n",
9953 bgp
->name
? bgp
->name
: "default");
9955 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9956 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9957 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9958 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9959 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9965 DEFUN_NOSH (exit_address_family
,
9966 exit_address_family_cmd
,
9967 "exit-address-family",
9968 "Exit from Address Family configuration mode\n")
9970 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9971 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9972 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9973 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9974 || vty
->node
== BGP_EVPN_NODE
9975 || vty
->node
== BGP_FLOWSPECV4_NODE
9976 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9977 vty
->node
= BGP_NODE
;
9981 /* Recalculate bestpath and re-advertise a prefix */
9982 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9983 const char *ip_str
, afi_t afi
, safi_t safi
,
9984 struct prefix_rd
*prd
)
9987 struct prefix match
;
9988 struct bgp_dest
*dest
;
9989 struct bgp_dest
*rm
;
9991 struct bgp_table
*table
;
9992 struct bgp_table
*rib
;
9994 /* BGP structure lookup. */
9996 bgp
= bgp_lookup_by_name(view_name
);
9998 vty_out(vty
, "%% Can't find BGP instance %s\n",
10000 return CMD_WARNING
;
10003 bgp
= bgp_get_default();
10005 vty_out(vty
, "%% No BGP process is configured\n");
10006 return CMD_WARNING
;
10010 /* Check IP address argument. */
10011 ret
= str2prefix(ip_str
, &match
);
10013 vty_out(vty
, "%% address is malformed\n");
10014 return CMD_WARNING
;
10017 match
.family
= afi2family(afi
);
10018 rib
= bgp
->rib
[afi
][safi
];
10020 if (safi
== SAFI_MPLS_VPN
) {
10021 for (dest
= bgp_table_top(rib
); dest
;
10022 dest
= bgp_route_next(dest
)) {
10023 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10025 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10028 table
= bgp_dest_get_bgp_table_info(dest
);
10032 rm
= bgp_node_match(table
, &match
);
10034 const struct prefix
*rm_p
=
10035 bgp_dest_get_prefix(rm
);
10037 if (rm_p
->prefixlen
== match
.prefixlen
) {
10038 SET_FLAG(rm
->flags
,
10039 BGP_NODE_USER_CLEAR
);
10040 bgp_process(bgp
, rm
, afi
, safi
);
10042 bgp_dest_unlock_node(rm
);
10046 dest
= bgp_node_match(rib
, &match
);
10047 if (dest
!= NULL
) {
10048 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10050 if (dest_p
->prefixlen
== match
.prefixlen
) {
10051 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10052 bgp_process(bgp
, dest
, afi
, safi
);
10054 bgp_dest_unlock_node(dest
);
10058 return CMD_SUCCESS
;
10061 /* one clear bgp command to rule them all */
10062 DEFUN (clear_ip_bgp_all
,
10063 clear_ip_bgp_all_cmd
,
10064 "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>]",
10068 BGP_INSTANCE_HELP_STR
10071 BGP_SAFI_WITH_LABEL_HELP_STR
10072 BGP_AF_MODIFIER_STR
10073 "Clear all peers\n"
10074 "BGP IPv4 neighbor to clear\n"
10075 "BGP IPv6 neighbor to clear\n"
10076 "BGP neighbor on interface to clear\n"
10077 "Clear peers with the AS number\n"
10078 "Clear all external peers\n"
10079 "Clear all members of peer-group\n"
10080 "BGP peer-group name\n"
10085 "Push out prefix-list ORF and do inbound soft reconfig\n"
10087 "Reset message statistics\n")
10091 afi_t afi
= AFI_UNSPEC
;
10092 safi_t safi
= SAFI_UNSPEC
;
10093 enum clear_sort clr_sort
= clear_peer
;
10094 enum bgp_clear_type clr_type
;
10095 char *clr_arg
= NULL
;
10099 /* clear [ip] bgp */
10100 if (argv_find(argv
, argc
, "ip", &idx
))
10103 /* [<vrf> VIEWVRFNAME] */
10104 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10105 vrf
= argv
[idx
+ 1]->arg
;
10107 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10109 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10110 /* [<view> VIEWVRFNAME] */
10111 vrf
= argv
[idx
+ 1]->arg
;
10114 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10115 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10116 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10118 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10119 if (argv_find(argv
, argc
, "*", &idx
)) {
10120 clr_sort
= clear_all
;
10121 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10122 clr_sort
= clear_peer
;
10123 clr_arg
= argv
[idx
]->arg
;
10124 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10125 clr_sort
= clear_peer
;
10126 clr_arg
= argv
[idx
]->arg
;
10127 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10128 clr_sort
= clear_group
;
10130 clr_arg
= argv
[idx
]->arg
;
10131 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10132 clr_sort
= clear_peer
;
10133 clr_arg
= argv
[idx
]->arg
;
10134 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10135 clr_sort
= clear_peer
;
10136 clr_arg
= argv
[idx
]->arg
;
10137 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10138 clr_sort
= clear_as
;
10139 clr_arg
= argv
[idx
]->arg
;
10140 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10141 clr_sort
= clear_external
;
10144 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10145 if (argv_find(argv
, argc
, "soft", &idx
)) {
10146 if (argv_find(argv
, argc
, "in", &idx
)
10147 || argv_find(argv
, argc
, "out", &idx
))
10148 clr_type
= strmatch(argv
[idx
]->text
, "in")
10149 ? BGP_CLEAR_SOFT_IN
10150 : BGP_CLEAR_SOFT_OUT
;
10152 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10153 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10154 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10155 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10156 : BGP_CLEAR_SOFT_IN
;
10157 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10158 clr_type
= BGP_CLEAR_SOFT_OUT
;
10159 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10160 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10162 clr_type
= BGP_CLEAR_SOFT_NONE
;
10164 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10167 DEFUN (clear_ip_bgp_prefix
,
10168 clear_ip_bgp_prefix_cmd
,
10169 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10173 BGP_INSTANCE_HELP_STR
10174 "Clear bestpath and re-advertise\n"
10178 char *prefix
= NULL
;
10182 /* [<view|vrf> VIEWVRFNAME] */
10183 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10184 vrf
= argv
[idx
+ 1]->arg
;
10186 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10188 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10189 /* [<view> VIEWVRFNAME] */
10190 vrf
= argv
[idx
+ 1]->arg
;
10194 prefix
= argv
[argc
- 1]->arg
;
10196 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10199 DEFUN (clear_bgp_ipv6_safi_prefix
,
10200 clear_bgp_ipv6_safi_prefix_cmd
,
10201 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10207 "Clear bestpath and re-advertise\n"
10211 int idx_ipv6_prefix
= 0;
10212 safi_t safi
= SAFI_UNICAST
;
10213 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10214 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10216 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10217 return bgp_clear_prefix(
10218 vty
, NULL
, prefix
, AFI_IP6
,
10222 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10223 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10224 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10228 BGP_INSTANCE_HELP_STR
10231 "Clear bestpath and re-advertise\n"
10235 int idx_vrfview
= 0;
10236 int idx_ipv6_prefix
= 0;
10237 safi_t safi
= SAFI_UNICAST
;
10238 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10239 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10240 char *vrfview
= NULL
;
10242 /* [<view|vrf> VIEWVRFNAME] */
10243 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10244 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10245 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10247 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10248 /* [<view> VIEWVRFNAME] */
10249 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10251 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10253 return bgp_clear_prefix(
10254 vty
, vrfview
, prefix
,
10255 AFI_IP6
, safi
, NULL
);
10258 DEFUN (show_bgp_views
,
10259 show_bgp_views_cmd
,
10260 "show [ip] bgp views",
10264 "Show the defined BGP views\n")
10266 struct list
*inst
= bm
->bgp
;
10267 struct listnode
*node
;
10270 vty_out(vty
, "Defined BGP views:\n");
10271 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10273 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10275 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10279 return CMD_SUCCESS
;
10282 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10286 struct listnode
*node
;
10288 *peers_cfgd
= *peers_estbd
= 0;
10289 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10290 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10293 if (peer_established(peer
))
10298 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10301 int peers_cfg
, peers_estb
;
10303 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10306 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10308 : (int64_t)bgp
->vrf_id
;
10309 json_object_string_add(json
, "type", type
);
10310 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10311 json_object_string_addf(json
, "routerId", "%pI4",
10313 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10314 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10315 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10316 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10317 json_object_string_add(
10319 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10323 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10324 json_object
*json
, const char *name
,
10325 const char *type
, bool use_vrf
)
10327 int peers_cfg
, peers_estb
;
10329 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10333 print_bgp_vrfs(bgp
, vty
, json
, type
);
10335 vty_out(vty
, "BGP instance %s VRF id %d\n",
10337 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10338 : (int)bgp
->vrf_id
);
10339 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10341 "Num Configured Peers %d, Established %d\n",
10342 peers_cfg
, peers_estb
);
10345 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10347 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10354 print_bgp_vrfs(bgp
, vty
, json
, type
);
10356 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10358 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10359 : (int)bgp
->vrf_id
,
10360 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10361 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10362 bgp
->l3vni
, &bgp
->rmac
,
10363 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10368 return CMD_SUCCESS
;
10371 DEFPY (show_bgp_vrfs
,
10373 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10378 "Specific VRF name\n"
10381 struct list
*inst
= bm
->bgp
;
10382 struct listnode
*node
;
10384 bool uj
= use_json(argc
, argv
);
10385 json_object
*json
= NULL
;
10386 json_object
*json_vrfs
= NULL
;
10387 json_object
*json_vrf
= NULL
;
10389 const char *name
= vrf_name
;
10393 json
= json_object_new_object();
10396 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10397 bgp
= bgp_get_default();
10400 bgp
= bgp_lookup_by_name(name
);
10405 vty_json(vty
, json
);
10408 "%% Specified BGP instance not found\n");
10410 return CMD_WARNING
;
10416 json_vrf
= json_object_new_object();
10418 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10422 json_object_object_add(json
, name
, json_vrf
);
10423 vty_json(vty
, json
);
10426 return CMD_SUCCESS
;
10430 json_vrfs
= json_object_new_object();
10432 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10436 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10440 if (!uj
&& count
== 1) {
10442 "%4s %-5s %-16s %9s %10s %-37s\n",
10443 "Type", "Id", "routerId", "#PeersCfg",
10444 "#PeersEstb", "Name");
10445 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10446 "L3-VNI", "RouterMAC", "Interface");
10449 json_vrf
= json_object_new_object();
10451 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10452 name
= VRF_DEFAULT_NAME
;
10459 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10463 json_object_object_add(json_vrfs
, name
, json_vrf
);
10467 json_object_object_add(json
, "vrfs", json_vrfs
);
10468 json_object_int_add(json
, "totalVrfs", count
);
10469 vty_json(vty
, json
);
10473 "\nTotal number of VRFs (including default): %d\n",
10477 return CMD_SUCCESS
;
10480 DEFUN (show_bgp_mac_hash
,
10481 show_bgp_mac_hash_cmd
,
10482 "show bgp mac hash",
10486 "Mac Address database\n")
10488 bgp_mac_dump_table(vty
);
10490 return CMD_SUCCESS
;
10493 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10495 struct vty
*vty
= (struct vty
*)args
;
10496 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10498 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10501 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10503 vty_out(vty
, "self nexthop database:\n");
10504 bgp_nexthop_show_address_hash(vty
, bgp
);
10506 vty_out(vty
, "Tunnel-ip database:\n");
10507 hash_iterate(bgp
->tip_hash
,
10508 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10512 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10513 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10514 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10515 "martian next-hops\n"
10516 "martian next-hop database\n")
10518 struct bgp
*bgp
= NULL
;
10522 /* [<vrf> VIEWVRFNAME] */
10523 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10524 name
= argv
[idx
+ 1]->arg
;
10525 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10527 } else if (argv_find(argv
, argc
, "view", &idx
))
10528 /* [<view> VIEWVRFNAME] */
10529 name
= argv
[idx
+ 1]->arg
;
10531 bgp
= bgp_lookup_by_name(name
);
10533 bgp
= bgp_get_default();
10536 vty_out(vty
, "%% No BGP process is configured\n");
10537 return CMD_WARNING
;
10539 bgp_show_martian_nexthops(vty
, bgp
);
10541 return CMD_SUCCESS
;
10544 DEFUN (show_bgp_memory
,
10545 show_bgp_memory_cmd
,
10546 "show [ip] bgp memory",
10550 "Global BGP memory statistics\n")
10552 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10553 unsigned long count
;
10555 /* RIB related usage stats */
10556 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10557 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10558 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10559 count
* sizeof(struct bgp_dest
)));
10561 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10562 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10563 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10564 count
* sizeof(struct bgp_path_info
)));
10565 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10566 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10569 memstrbuf
, sizeof(memstrbuf
),
10570 count
* sizeof(struct bgp_path_info_extra
)));
10572 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10573 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10574 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10575 count
* sizeof(struct bgp_static
)));
10577 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10578 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10579 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10580 count
* sizeof(struct bpacket
)));
10583 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10584 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10585 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10586 count
* sizeof(struct bgp_adj_in
)));
10587 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10588 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10589 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10590 count
* sizeof(struct bgp_adj_out
)));
10592 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10593 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10595 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10596 count
* sizeof(struct bgp_nexthop_cache
)));
10598 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10599 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10601 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10602 count
* sizeof(struct bgp_damp_info
)));
10605 count
= attr_count();
10606 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10607 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10608 count
* sizeof(struct attr
)));
10610 if ((count
= attr_unknown_count()))
10611 vty_out(vty
, "%ld unknown attributes\n", count
);
10613 /* AS_PATH attributes */
10614 count
= aspath_count();
10615 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10616 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10617 count
* sizeof(struct aspath
)));
10619 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10620 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10621 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10622 count
* sizeof(struct assegment
)));
10624 /* Other attributes */
10625 if ((count
= community_count()))
10626 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10627 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10628 count
* sizeof(struct community
)));
10629 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10631 "%ld BGP ext-community entries, using %s of memory\n",
10633 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10634 count
* sizeof(struct ecommunity
)));
10635 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10637 "%ld BGP large-community entries, using %s of memory\n",
10638 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10639 count
* sizeof(struct lcommunity
)));
10641 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10642 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10643 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10644 count
* sizeof(struct cluster_list
)));
10646 /* Peer related usage */
10647 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10648 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10649 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10650 count
* sizeof(struct peer
)));
10652 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10653 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10654 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10655 count
* sizeof(struct peer_group
)));
10658 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10659 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10660 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10661 count
* sizeof(regex_t
)));
10662 return CMD_SUCCESS
;
10665 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10667 json_object
*bestpath
= json_object_new_object();
10669 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10670 json_object_string_add(bestpath
, "asPath", "ignore");
10672 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10673 json_object_string_add(bestpath
, "asPath", "confed");
10675 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10676 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10677 json_object_string_add(bestpath
, "multiPathRelax",
10680 json_object_string_add(bestpath
, "multiPathRelax",
10683 json_object_string_add(bestpath
, "multiPathRelax", "false");
10685 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10686 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10688 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10689 json_object_string_add(bestpath
, "compareRouterId", "true");
10690 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10691 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10692 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10693 json_object_string_add(bestpath
, "med", "confed");
10694 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10695 json_object_string_add(bestpath
, "med",
10696 "missing-as-worst");
10698 json_object_string_add(bestpath
, "med", "true");
10701 json_object_object_add(json
, "bestPath", bestpath
);
10704 /* Print the error code/subcode for why the peer is down */
10705 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10706 json_object
*json_peer
, bool use_json
)
10708 const char *code_str
;
10709 const char *subcode_str
;
10712 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10713 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10714 char errorcodesubcode_hexstr
[5];
10715 char errorcodesubcode_str
[256];
10717 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10718 subcode_str
= bgp_notify_subcode_str(
10720 peer
->notify
.subcode
);
10722 snprintf(errorcodesubcode_hexstr
,
10723 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10724 peer
->notify
.code
, peer
->notify
.subcode
);
10725 json_object_string_add(json_peer
,
10726 "lastErrorCodeSubcode",
10727 errorcodesubcode_hexstr
);
10728 snprintf(errorcodesubcode_str
, 255, "%s%s",
10729 code_str
, subcode_str
);
10730 json_object_string_add(json_peer
,
10731 "lastNotificationReason",
10732 errorcodesubcode_str
);
10733 json_object_boolean_add(json_peer
,
10734 "lastNotificationHardReset",
10735 peer
->notify
.hard_reset
);
10736 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10737 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10738 && (peer
->notify
.subcode
10739 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10740 || peer
->notify
.subcode
10741 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10742 && peer
->notify
.length
) {
10744 const char *msg_str
;
10746 msg_str
= bgp_notify_admin_message(
10747 msgbuf
, sizeof(msgbuf
),
10748 (uint8_t *)peer
->notify
.data
,
10749 peer
->notify
.length
);
10751 json_object_string_add(
10753 "lastShutdownDescription",
10758 json_object_string_add(json_peer
, "lastResetDueTo",
10759 peer_down_str
[(int)peer
->last_reset
]);
10760 json_object_int_add(json_peer
, "lastResetCode",
10763 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10764 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10765 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10767 bgp_notify_subcode_str(peer
->notify
.code
,
10768 peer
->notify
.subcode
);
10769 vty_out(vty
, " Notification %s (%s%s%s)\n",
10770 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10773 code_str
, subcode_str
,
10774 peer
->notify
.hard_reset
10775 ? bgp_notify_subcode_str(
10777 BGP_NOTIFY_CEASE_HARD_RESET
)
10780 vty_out(vty
, " %s\n",
10781 peer_down_str
[(int)peer
->last_reset
]);
10786 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10789 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10792 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10793 struct peer
*peer
, json_object
*json_peer
,
10794 int max_neighbor_width
, bool use_json
)
10796 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10800 if (peer_dynamic_neighbor(peer
))
10801 json_object_boolean_true_add(json_peer
,
10803 if (peer
->hostname
)
10804 json_object_string_add(json_peer
, "hostname",
10807 if (peer
->domainname
)
10808 json_object_string_add(json_peer
, "domainname",
10810 json_object_int_add(json_peer
, "connectionsEstablished",
10811 peer
->established
);
10812 json_object_int_add(json_peer
, "connectionsDropped",
10814 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10815 use_json
, json_peer
);
10816 if (peer_established(peer
))
10817 json_object_string_add(json_peer
, "lastResetDueTo",
10818 "AFI/SAFI Not Negotiated");
10820 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10823 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10825 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10826 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10827 peer
->hostname
, peer
->host
);
10829 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10831 /* pad the neighbor column with spaces */
10832 if (len
< max_neighbor_width
)
10833 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10835 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10837 peer_uptime(peer
->uptime
, timebuf
,
10838 BGP_UPTIME_LEN
, 0, NULL
));
10839 if (peer_established(peer
))
10840 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10842 bgp_show_peer_reset(vty
, peer
, NULL
,
10847 /* Strip peer's description to the given size. */
10848 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10850 static char stripped
[BUFSIZ
];
10852 uint32_t last_space
= 0;
10855 if (*(desc
+ i
) == 0) {
10856 stripped
[i
] = '\0';
10859 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10861 stripped
[i
] = *(desc
+ i
);
10865 if (last_space
> size
)
10866 stripped
[size
+ 1] = '\0';
10868 stripped
[last_space
] = '\0';
10873 /* Determine whether var peer should be filtered out of the summary. */
10874 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10875 struct peer
*fpeer
, int as_type
,
10879 /* filter neighbor XXXX */
10880 if (fpeer
&& fpeer
!= peer
)
10883 /* filter remote-as (internal|external) */
10884 if (as_type
!= AS_UNSPECIFIED
) {
10885 if (peer
->as_type
== AS_SPECIFIED
) {
10886 if (as_type
== AS_INTERNAL
) {
10887 if (peer
->as
!= peer
->local_as
)
10889 } else if (peer
->as
== peer
->local_as
)
10891 } else if (as_type
!= peer
->as_type
)
10893 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10899 /* Show BGP peer's summary information.
10901 * Peer's description is stripped according to if `wide` option is given
10904 * When adding new columns to `show bgp summary` output, please make
10905 * sure `Desc` is the lastest column to show because it can contain
10906 * whitespaces and the whole output will be tricky.
10908 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10909 struct peer
*fpeer
, int as_type
, as_t as
,
10910 uint16_t show_flags
)
10913 struct listnode
*node
, *nnode
;
10914 unsigned int count
= 0, dn_count
= 0;
10915 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10916 char neighbor_buf
[VTY_BUFSIZ
];
10917 int neighbor_col_default_width
= 16;
10918 int len
, failed_count
= 0;
10919 unsigned int filtered_count
= 0;
10920 int max_neighbor_width
= 0;
10922 json_object
*json
= NULL
;
10923 json_object
*json_peer
= NULL
;
10924 json_object
*json_peers
= NULL
;
10925 struct peer_af
*paf
;
10926 struct bgp_filter
*filter
;
10927 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10928 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10929 bool show_established
=
10930 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10931 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10932 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10934 /* labeled-unicast routes are installed in the unicast table so in order
10936 * display the correct PfxRcd value we must look at SAFI_UNICAST
10939 if (safi
== SAFI_LABELED_UNICAST
)
10940 pfx_rcd_safi
= SAFI_UNICAST
;
10942 pfx_rcd_safi
= safi
;
10945 json
= json_object_new_object();
10946 json_peers
= json_object_new_object();
10947 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10948 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10955 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10958 if (peer
->afc
[afi
][safi
]) {
10959 /* See if we have at least a single failed peer */
10960 if (bgp_has_peer_failed(peer
, afi
, safi
))
10964 if (peer_dynamic_neighbor(peer
))
10969 /* Loop over all neighbors that will be displayed to determine
10971 * characters are needed for the Neighbor column
10973 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10974 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10981 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10984 if (peer
->afc
[afi
][safi
]) {
10985 memset(dn_flag
, '\0', sizeof(dn_flag
));
10986 if (peer_dynamic_neighbor(peer
))
10990 && CHECK_FLAG(bgp
->flags
,
10991 BGP_FLAG_SHOW_HOSTNAME
))
10992 snprintf(neighbor_buf
,
10993 sizeof(neighbor_buf
),
10994 "%s%s(%s) ", dn_flag
,
10995 peer
->hostname
, peer
->host
);
10997 snprintf(neighbor_buf
,
10998 sizeof(neighbor_buf
), "%s%s ",
10999 dn_flag
, peer
->host
);
11001 len
= strlen(neighbor_buf
);
11003 if (len
> max_neighbor_width
)
11004 max_neighbor_width
= len
;
11006 /* See if we have at least a single failed peer */
11007 if (bgp_has_peer_failed(peer
, afi
, safi
))
11013 /* Originally we displayed the Neighbor column as 16
11014 * characters wide so make that the default
11016 if (max_neighbor_width
< neighbor_col_default_width
)
11017 max_neighbor_width
= neighbor_col_default_width
;
11020 if (show_failed
&& !failed_count
) {
11022 json_object_int_add(json
, "failedPeersCount", 0);
11023 json_object_int_add(json
, "dynamicPeers", dn_count
);
11024 json_object_int_add(json
, "totalPeers", count
);
11026 vty_json(vty
, json
);
11028 vty_out(vty
, "%% No failed BGP neighbors found\n");
11030 return CMD_SUCCESS
;
11033 count
= 0; /* Reset the value as its used again */
11034 filtered_count
= 0;
11036 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11037 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11040 if (!peer
->afc
[afi
][safi
])
11044 unsigned long ents
;
11045 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11048 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11050 : (int64_t)bgp
->vrf_id
;
11052 /* Usage summary and header */
11054 json_object_string_addf(json
, "routerId",
11057 json_object_int_add(json
, "as", bgp
->as
);
11058 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11059 json_object_string_add(
11062 == BGP_INSTANCE_TYPE_DEFAULT
)
11067 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11068 &bgp
->router_id
, bgp
->as
,
11069 bgp
->vrf_id
== VRF_UNKNOWN
11071 : (int)bgp
->vrf_id
);
11072 vty_out(vty
, "\n");
11075 if (bgp_update_delay_configured(bgp
)) {
11077 json_object_int_add(
11078 json
, "updateDelayLimit",
11079 bgp
->v_update_delay
);
11081 if (bgp
->v_update_delay
11082 != bgp
->v_establish_wait
)
11083 json_object_int_add(
11085 "updateDelayEstablishWait",
11086 bgp
->v_establish_wait
);
11088 if (bgp_update_delay_active(bgp
)) {
11089 json_object_string_add(
11091 "updateDelayFirstNeighbor",
11092 bgp
->update_delay_begin_time
);
11093 json_object_boolean_true_add(
11095 "updateDelayInProgress");
11097 if (bgp
->update_delay_over
) {
11098 json_object_string_add(
11100 "updateDelayFirstNeighbor",
11101 bgp
->update_delay_begin_time
);
11102 json_object_string_add(
11104 "updateDelayBestpathResumed",
11105 bgp
->update_delay_end_time
);
11106 json_object_string_add(
11108 "updateDelayZebraUpdateResume",
11109 bgp
->update_delay_zebra_resume_time
);
11110 json_object_string_add(
11112 "updateDelayPeerUpdateResume",
11113 bgp
->update_delay_peers_resume_time
);
11118 "Read-only mode update-delay limit: %d seconds\n",
11119 bgp
->v_update_delay
);
11120 if (bgp
->v_update_delay
11121 != bgp
->v_establish_wait
)
11123 " Establish wait: %d seconds\n",
11124 bgp
->v_establish_wait
);
11126 if (bgp_update_delay_active(bgp
)) {
11128 " First neighbor established: %s\n",
11129 bgp
->update_delay_begin_time
);
11131 " Delay in progress\n");
11133 if (bgp
->update_delay_over
) {
11135 " First neighbor established: %s\n",
11136 bgp
->update_delay_begin_time
);
11138 " Best-paths resumed: %s\n",
11139 bgp
->update_delay_end_time
);
11141 " zebra update resumed: %s\n",
11142 bgp
->update_delay_zebra_resume_time
);
11144 " peers update resumed: %s\n",
11145 bgp
->update_delay_peers_resume_time
);
11152 if (bgp_maxmed_onstartup_configured(bgp
)
11153 && bgp
->maxmed_active
)
11154 json_object_boolean_true_add(
11155 json
, "maxMedOnStartup");
11156 if (bgp
->v_maxmed_admin
)
11157 json_object_boolean_true_add(
11158 json
, "maxMedAdministrative");
11160 json_object_int_add(
11161 json
, "tableVersion",
11162 bgp_table_version(bgp
->rib
[afi
][safi
]));
11164 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11165 json_object_int_add(json
, "ribCount", ents
);
11166 json_object_int_add(
11168 ents
* sizeof(struct bgp_dest
));
11170 ents
= bgp
->af_peer_count
[afi
][safi
];
11171 json_object_int_add(json
, "peerCount", ents
);
11172 json_object_int_add(json
, "peerMemory",
11173 ents
* sizeof(struct peer
));
11175 if ((ents
= listcount(bgp
->group
))) {
11176 json_object_int_add(
11177 json
, "peerGroupCount", ents
);
11178 json_object_int_add(
11179 json
, "peerGroupMemory",
11180 ents
* sizeof(struct
11184 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11185 BGP_CONFIG_DAMPENING
))
11186 json_object_boolean_true_add(
11187 json
, "dampeningEnabled");
11190 if (bgp_maxmed_onstartup_configured(bgp
)
11191 && bgp
->maxmed_active
)
11193 "Max-med on-startup active\n");
11194 if (bgp
->v_maxmed_admin
)
11196 "Max-med administrative active\n");
11199 "BGP table version %" PRIu64
11202 bgp
->rib
[afi
][safi
]));
11204 ents
= bgp_table_count(
11205 bgp
->rib
[afi
][safi
]);
11207 "RIB entries %ld, using %s of memory\n",
11217 /* Peer related usage */
11218 ents
= bgp
->af_peer_count
[afi
][safi
];
11220 "Peers %ld, using %s of memory\n",
11230 if ((ents
= listcount(bgp
->group
)))
11232 "Peer groups %ld, using %s of memory\n",
11242 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11243 BGP_CONFIG_DAMPENING
))
11245 "Dampening enabled.\n");
11248 vty_out(vty
, "\n");
11250 /* Subtract 8 here because 'Neighbor' is
11252 vty_out(vty
, "Neighbor");
11253 vty_out(vty
, "%*s",
11254 max_neighbor_width
- 8, " ");
11256 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11261 paf
= peer_af_find(peer
, afi
, safi
);
11262 filter
= &peer
->filter
[afi
][safi
];
11265 /* Works for both failed & successful cases */
11266 if (peer_dynamic_neighbor(peer
))
11271 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11277 bgp_has_peer_failed(peer
, afi
, safi
)) {
11278 json_peer
= json_object_new_object();
11279 bgp_show_failed_summary(vty
, bgp
, peer
,
11280 json_peer
, 0, use_json
);
11281 } else if (!show_failed
) {
11282 if (show_established
11283 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11288 json_peer
= json_object_new_object();
11289 if (peer_dynamic_neighbor(peer
)) {
11290 json_object_boolean_true_add(json_peer
,
11294 if (peer
->hostname
)
11295 json_object_string_add(json_peer
, "hostname",
11298 if (peer
->domainname
)
11299 json_object_string_add(json_peer
, "domainname",
11302 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11303 json_object_int_add(
11304 json_peer
, "localAs",
11305 peer
->change_local_as
11306 ? peer
->change_local_as
11308 json_object_int_add(json_peer
, "version", 4);
11309 json_object_int_add(json_peer
, "msgRcvd",
11310 PEER_TOTAL_RX(peer
));
11311 json_object_int_add(json_peer
, "msgSent",
11312 PEER_TOTAL_TX(peer
));
11314 atomic_size_t outq_count
, inq_count
;
11315 outq_count
= atomic_load_explicit(
11316 &peer
->obuf
->count
,
11317 memory_order_relaxed
);
11318 inq_count
= atomic_load_explicit(
11319 &peer
->ibuf
->count
,
11320 memory_order_relaxed
);
11322 json_object_int_add(json_peer
, "tableVersion",
11323 peer
->version
[afi
][safi
]);
11324 json_object_int_add(json_peer
, "outq",
11326 json_object_int_add(json_peer
, "inq",
11328 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11329 use_json
, json_peer
);
11331 json_object_int_add(json_peer
, "pfxRcd",
11332 peer
->pcount
[afi
][pfx_rcd_safi
]);
11334 if (paf
&& PAF_SUBGRP(paf
))
11335 json_object_int_add(
11336 json_peer
, "pfxSnt",
11337 (PAF_SUBGRP(paf
))->scount
);
11339 json_object_int_add(json_peer
, "pfxSnt",
11342 /* BGP FSM state */
11343 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11344 || CHECK_FLAG(peer
->bgp
->flags
,
11345 BGP_FLAG_SHUTDOWN
))
11346 json_object_string_add(json_peer
,
11349 else if (peer
->afc_recv
[afi
][safi
])
11350 json_object_string_add(
11351 json_peer
, "state",
11352 lookup_msg(bgp_status_msg
,
11353 peer
->status
, NULL
));
11354 else if (CHECK_FLAG(
11356 PEER_STATUS_PREFIX_OVERFLOW
))
11357 json_object_string_add(json_peer
,
11361 json_object_string_add(
11362 json_peer
, "state",
11363 lookup_msg(bgp_status_msg
,
11364 peer
->status
, NULL
));
11366 /* BGP peer state */
11367 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11368 || CHECK_FLAG(peer
->bgp
->flags
,
11369 BGP_FLAG_SHUTDOWN
))
11370 json_object_string_add(json_peer
,
11373 else if (CHECK_FLAG(
11375 PEER_STATUS_PREFIX_OVERFLOW
))
11376 json_object_string_add(json_peer
,
11379 else if (CHECK_FLAG(peer
->flags
,
11380 PEER_FLAG_PASSIVE
))
11381 json_object_string_add(json_peer
,
11384 else if (CHECK_FLAG(peer
->sflags
,
11385 PEER_STATUS_NSF_WAIT
))
11386 json_object_string_add(json_peer
,
11389 else if (CHECK_FLAG(
11391 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11392 && (!bgp_inbound_policy_exists(peer
,
11394 || !bgp_outbound_policy_exists(
11396 json_object_string_add(json_peer
,
11400 json_object_string_add(
11401 json_peer
, "peerState", "OK");
11403 json_object_int_add(json_peer
, "connectionsEstablished",
11404 peer
->established
);
11405 json_object_int_add(json_peer
, "connectionsDropped",
11408 json_object_string_add(
11409 json_peer
, "desc", peer
->desc
);
11411 /* Avoid creating empty peer dicts in JSON */
11412 if (json_peer
== NULL
)
11416 json_object_string_add(json_peer
, "idType",
11418 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11419 json_object_string_add(json_peer
, "idType",
11421 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11422 json_object_string_add(json_peer
, "idType",
11424 json_object_object_add(json_peers
, peer
->host
,
11427 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11433 bgp_has_peer_failed(peer
, afi
, safi
)) {
11434 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11435 max_neighbor_width
,
11437 } else if (!show_failed
) {
11438 if (show_established
11439 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11444 if ((count
- filtered_count
) == 1) {
11445 /* display headline before the first
11447 vty_out(vty
, "\n");
11449 /* Subtract 8 here because 'Neighbor' is
11451 vty_out(vty
, "Neighbor");
11452 vty_out(vty
, "%*s",
11453 max_neighbor_width
- 8, " ");
11456 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11457 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11460 memset(dn_flag
, '\0', sizeof(dn_flag
));
11461 if (peer_dynamic_neighbor(peer
)) {
11466 && CHECK_FLAG(bgp
->flags
,
11467 BGP_FLAG_SHOW_HOSTNAME
))
11468 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11472 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11474 /* pad the neighbor column with spaces */
11475 if (len
< max_neighbor_width
)
11476 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11479 atomic_size_t outq_count
, inq_count
;
11480 outq_count
= atomic_load_explicit(
11481 &peer
->obuf
->count
,
11482 memory_order_relaxed
);
11483 inq_count
= atomic_load_explicit(
11484 &peer
->ibuf
->count
,
11485 memory_order_relaxed
);
11489 "4 %10u %10u %9u %9u %8" PRIu64
11492 peer
->change_local_as
11493 ? peer
->change_local_as
11495 PEER_TOTAL_RX(peer
),
11496 PEER_TOTAL_TX(peer
),
11497 peer
->version
[afi
][safi
],
11498 inq_count
, outq_count
,
11499 peer_uptime(peer
->uptime
,
11504 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11506 peer
->as
, PEER_TOTAL_RX(peer
),
11507 PEER_TOTAL_TX(peer
),
11508 peer
->version
[afi
][safi
],
11509 inq_count
, outq_count
,
11510 peer_uptime(peer
->uptime
,
11515 if (peer_established(peer
)) {
11516 if (peer
->afc_recv
[afi
][safi
]) {
11519 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11520 && !bgp_inbound_policy_exists(
11522 vty_out(vty
, " %12s",
11531 vty_out(vty
, " NoNeg");
11534 if (paf
&& PAF_SUBGRP(paf
)) {
11537 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11538 && !bgp_outbound_policy_exists(
11540 vty_out(vty
, " %8s",
11549 vty_out(vty
, " NoNeg");
11552 if (CHECK_FLAG(peer
->flags
,
11553 PEER_FLAG_SHUTDOWN
)
11554 || CHECK_FLAG(peer
->bgp
->flags
,
11555 BGP_FLAG_SHUTDOWN
))
11556 vty_out(vty
, " Idle (Admin)");
11557 else if (CHECK_FLAG(
11559 PEER_STATUS_PREFIX_OVERFLOW
))
11560 vty_out(vty
, " Idle (PfxCt)");
11562 vty_out(vty
, " %12s",
11563 lookup_msg(bgp_status_msg
,
11564 peer
->status
, NULL
));
11566 vty_out(vty
, " %8u", 0);
11568 /* Make sure `Desc` column is the lastest in
11572 vty_out(vty
, " %s",
11573 bgp_peer_description_stripped(
11575 show_wide
? 64 : 20));
11577 vty_out(vty
, " N/A");
11578 vty_out(vty
, "\n");
11585 json_object_object_add(json
, "peers", json_peers
);
11586 json_object_int_add(json
, "failedPeers", failed_count
);
11587 json_object_int_add(json
, "displayedPeers",
11588 count
- filtered_count
);
11589 json_object_int_add(json
, "totalPeers", count
);
11590 json_object_int_add(json
, "dynamicPeers", dn_count
);
11593 bgp_show_bestpath_json(bgp
, json
);
11595 vty_json(vty
, json
);
11598 if (filtered_count
== count
)
11599 vty_out(vty
, "\n%% No matching neighbor\n");
11602 vty_out(vty
, "\nDisplayed neighbors %d",
11604 else if (as_type
!= AS_UNSPECIFIED
|| as
11605 || fpeer
|| show_established
)
11606 vty_out(vty
, "\nDisplayed neighbors %d",
11607 count
- filtered_count
);
11609 vty_out(vty
, "\nTotal number of neighbors %d\n",
11613 vty_out(vty
, "No %s neighbor is configured\n",
11614 get_afi_safi_str(afi
, safi
, false));
11618 vty_out(vty
, "* - dynamic neighbor\n");
11619 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11620 dn_count
, bgp
->dynamic_neighbors_limit
);
11624 return CMD_SUCCESS
;
11627 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11628 int safi
, struct peer
*fpeer
, int as_type
,
11629 as_t as
, uint16_t show_flags
)
11632 int afi_wildcard
= (afi
== AFI_MAX
);
11633 int safi_wildcard
= (safi
== SAFI_MAX
);
11634 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11635 bool nbr_output
= false;
11636 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11638 if (use_json
&& is_wildcard
)
11639 vty_out(vty
, "{\n");
11641 afi
= 1; /* AFI_IP */
11642 while (afi
< AFI_MAX
) {
11644 safi
= 1; /* SAFI_UNICAST */
11645 while (safi
< SAFI_MAX
) {
11646 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11651 * So limit output to those afi/safi
11653 * actualy have something interesting in
11658 vty_out(vty
, ",\n");
11662 vty_out(vty
, "\"%s\":",
11663 get_afi_safi_str(afi
,
11668 "\n%s Summary (%s):\n",
11669 get_afi_safi_str(afi
,
11675 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11676 as_type
, as
, show_flags
);
11679 if (!safi_wildcard
)
11687 if (use_json
&& is_wildcard
)
11688 vty_out(vty
, "}\n");
11689 else if (!nbr_output
) {
11691 vty_out(vty
, "{}\n");
11693 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11698 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11700 const char *neighbor
,
11701 int as_type
, as_t as
,
11702 uint16_t show_flags
)
11704 struct listnode
*node
, *nnode
;
11706 struct peer
*fpeer
= NULL
;
11708 bool nbr_output
= false;
11709 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11712 vty_out(vty
, "{\n");
11714 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11718 vty_out(vty
, ",\n");
11722 vty_out(vty
, "\"%s\":",
11723 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11728 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11733 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11738 vty_out(vty
, "}\n");
11739 else if (!nbr_output
)
11740 vty_out(vty
, "%% BGP instance not found\n");
11743 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11744 safi_t safi
, const char *neighbor
, int as_type
,
11745 as_t as
, uint16_t show_flags
)
11748 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11749 struct peer
*fpeer
= NULL
;
11752 if (strmatch(name
, "all")) {
11753 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11756 return CMD_SUCCESS
;
11758 bgp
= bgp_lookup_by_name(name
);
11762 vty_out(vty
, "{}\n");
11765 "%% BGP instance not found\n");
11766 return CMD_WARNING
;
11770 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11773 return CMD_WARNING
;
11775 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11776 as_type
, as
, show_flags
);
11777 return CMD_SUCCESS
;
11781 bgp
= bgp_get_default();
11785 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11788 return CMD_WARNING
;
11790 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11794 vty_out(vty
, "{}\n");
11796 vty_out(vty
, "%% BGP instance not found\n");
11797 return CMD_WARNING
;
11800 return CMD_SUCCESS
;
11803 /* `show [ip] bgp summary' commands. */
11804 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11805 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11806 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11807 "]] [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]",
11808 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11809 BGP_SAFI_WITH_LABEL_HELP_STR
11810 "Display the entries for all address families\n"
11811 "Summary of BGP neighbor status\n"
11812 "Show only sessions in Established state\n"
11813 "Show only sessions not in Established state\n"
11814 "Show only the specified neighbor session\n"
11815 "Neighbor to display information about\n"
11816 "Neighbor to display information about\n"
11817 "Neighbor on BGP configured interface\n"
11818 "Show only the specified remote AS sessions\n"
11820 "Internal (iBGP) AS sessions\n"
11821 "External (eBGP) AS sessions\n"
11822 "Shorten the information on BGP instances\n"
11823 "Increase table width for longer output\n" JSON_STR
)
11826 afi_t afi
= AFI_MAX
;
11827 safi_t safi
= SAFI_MAX
;
11828 as_t as
= 0; /* 0 means AS filter not set */
11829 int as_type
= AS_UNSPECIFIED
;
11830 uint16_t show_flags
= 0;
11834 /* show [ip] bgp */
11835 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11837 /* [<vrf> VIEWVRFNAME] */
11838 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11839 vrf
= argv
[idx
+ 1]->arg
;
11840 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11842 } else if (argv_find(argv
, argc
, "view", &idx
))
11843 /* [<view> VIEWVRFNAME] */
11844 vrf
= argv
[idx
+ 1]->arg
;
11845 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11846 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11847 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11850 if (argv_find(argv
, argc
, "failed", &idx
))
11851 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11853 if (argv_find(argv
, argc
, "established", &idx
))
11854 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11856 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11857 if (argv
[idx
+ 1]->arg
[0] == 'i')
11858 as_type
= AS_INTERNAL
;
11859 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11860 as_type
= AS_EXTERNAL
;
11862 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11865 if (argv_find(argv
, argc
, "terse", &idx
))
11866 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11868 if (argv_find(argv
, argc
, "wide", &idx
))
11869 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11871 if (argv_find(argv
, argc
, "json", &idx
))
11872 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11874 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11878 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11881 return get_afi_safi_json_str(afi
, safi
);
11883 return get_afi_safi_vty_str(afi
, safi
);
11887 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11888 afi_t afi
, safi_t safi
,
11889 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11890 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11891 bool use_json
, json_object
*json_pref
)
11894 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11895 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11897 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11898 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11899 json_object_string_add(json_pref
, "sendMode",
11900 "advertisedAndReceived");
11901 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11902 json_object_string_add(json_pref
, "sendMode",
11904 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11905 json_object_string_add(json_pref
, "sendMode",
11908 vty_out(vty
, " Send-mode: ");
11909 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11910 vty_out(vty
, "advertised");
11911 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11912 vty_out(vty
, "%sreceived",
11913 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11917 vty_out(vty
, "\n");
11922 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11923 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11925 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11926 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11927 json_object_string_add(json_pref
, "recvMode",
11928 "advertisedAndReceived");
11929 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11930 json_object_string_add(json_pref
, "recvMode",
11932 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11933 json_object_string_add(json_pref
, "recvMode",
11936 vty_out(vty
, " Receive-mode: ");
11937 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11938 vty_out(vty
, "advertised");
11939 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11940 vty_out(vty
, "%sreceived",
11941 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11945 vty_out(vty
, "\n");
11950 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11957 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11958 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11959 && (peer_established(p
))) {
11960 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11961 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11965 json_object_boolean_add(json
, "rBit", rbit
);
11966 json_object_boolean_add(json
, "nBit", nbit
);
11968 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11969 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11973 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11977 const char *mode
= "NotApplicable";
11980 vty_out(vty
, "\n Remote GR Mode: ");
11982 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11983 && (peer_established(peer
))) {
11985 if ((peer
->nsf_af_count
== 0)
11986 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11990 } else if (peer
->nsf_af_count
== 0
11991 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11995 } else if (peer
->nsf_af_count
!= 0
11996 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12003 json_object_string_add(json
, "remoteGrMode", mode
);
12005 vty_out(vty
, mode
, "\n");
12008 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12012 const char *mode
= "Invalid";
12015 vty_out(vty
, " Local GR Mode: ");
12017 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12019 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12021 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12023 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12024 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12026 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12028 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12035 json_object_string_add(json
, "localGrMode", mode
);
12037 vty_out(vty
, mode
, "\n");
12040 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12041 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12045 json_object
*json_afi_safi
= NULL
;
12046 json_object
*json_timer
= NULL
;
12047 json_object
*json_endofrib_status
= NULL
;
12048 bool eor_flag
= false;
12050 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12051 if (!peer
->afc
[afi
][safi
])
12054 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12055 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12059 json_afi_safi
= json_object_new_object();
12060 json_endofrib_status
= json_object_new_object();
12061 json_timer
= json_object_new_object();
12064 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12070 vty_out(vty
, " %s:\n",
12071 get_afi_safi_str(afi
, safi
, false));
12073 vty_out(vty
, " F bit: ");
12076 if (peer
->nsf
[afi
][safi
] &&
12077 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12078 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12081 json_object_boolean_true_add(json_afi_safi
,
12084 vty_out(vty
, "True\n");
12087 json_object_boolean_false_add(json_afi_safi
,
12090 vty_out(vty
, "False\n");
12094 vty_out(vty
, " End-of-RIB sent: ");
12096 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12097 PEER_STATUS_EOR_SEND
)) {
12099 json_object_boolean_true_add(
12100 json_endofrib_status
, "endOfRibSend");
12102 PRINT_EOR_JSON(eor_flag
);
12104 vty_out(vty
, "Yes\n");
12106 " End-of-RIB sent after update: ");
12108 PRINT_EOR(eor_flag
);
12112 json_object_boolean_false_add(
12113 json_endofrib_status
, "endOfRibSend");
12114 json_object_boolean_false_add(
12115 json_endofrib_status
,
12116 "endOfRibSentAfterUpdate");
12118 vty_out(vty
, "No\n");
12120 " End-of-RIB sent after update: ");
12121 vty_out(vty
, "No\n");
12126 vty_out(vty
, " End-of-RIB received: ");
12128 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12129 PEER_STATUS_EOR_RECEIVED
)) {
12131 json_object_boolean_true_add(
12132 json_endofrib_status
, "endOfRibRecv");
12134 vty_out(vty
, "Yes\n");
12137 json_object_boolean_false_add(
12138 json_endofrib_status
, "endOfRibRecv");
12140 vty_out(vty
, "No\n");
12144 json_object_int_add(json_timer
, "stalePathTimer",
12145 peer
->bgp
->stalepath_time
);
12147 if (peer
->t_gr_stale
!= NULL
) {
12148 json_object_int_add(json_timer
,
12149 "stalePathTimerRemaining",
12150 thread_timer_remain_second(
12151 peer
->t_gr_stale
));
12154 /* Display Configured Selection
12155 * Deferral only when when
12156 * Gr mode is enabled.
12158 if (CHECK_FLAG(peer
->flags
,
12159 PEER_FLAG_GRACEFUL_RESTART
)) {
12160 json_object_int_add(json_timer
,
12161 "selectionDeferralTimer",
12162 peer
->bgp
->stalepath_time
);
12165 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12168 json_object_int_add(
12170 "selectionDeferralTimerRemaining",
12171 thread_timer_remain_second(
12172 peer
->bgp
->gr_info
[afi
][safi
]
12173 .t_select_deferral
));
12176 vty_out(vty
, " Timers:\n");
12178 " Configured Stale Path Time(sec): %u\n",
12179 peer
->bgp
->stalepath_time
);
12181 if (peer
->t_gr_stale
!= NULL
)
12183 " Stale Path Remaining(sec): %ld\n",
12184 thread_timer_remain_second(
12185 peer
->t_gr_stale
));
12186 /* Display Configured Selection
12187 * Deferral only when when
12188 * Gr mode is enabled.
12190 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12192 " Configured Selection Deferral Time(sec): %u\n",
12193 peer
->bgp
->select_defer_time
);
12195 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12198 " Selection Deferral Time Remaining(sec): %ld\n",
12199 thread_timer_remain_second(
12200 peer
->bgp
->gr_info
[afi
][safi
]
12201 .t_select_deferral
));
12204 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12205 json_endofrib_status
);
12206 json_object_object_add(json_afi_safi
, "timers",
12208 json_object_object_add(
12209 json
, get_afi_safi_str(afi
, safi
, true),
12215 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12220 json_object
*json_timer
= NULL
;
12222 json_timer
= json_object_new_object();
12224 json_object_int_add(json_timer
, "configuredRestartTimer",
12225 p
->bgp
->restart_time
);
12227 json_object_int_add(json_timer
, "receivedRestartTimer",
12230 if (p
->t_gr_restart
!= NULL
)
12231 json_object_int_add(
12232 json_timer
, "restartTimerRemaining",
12233 thread_timer_remain_second(p
->t_gr_restart
));
12235 json_object_object_add(json
, "timers", json_timer
);
12238 vty_out(vty
, " Timers:\n");
12239 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12240 p
->bgp
->restart_time
);
12242 vty_out(vty
, " Received Restart Time(sec): %u\n",
12244 if (p
->t_gr_restart
!= NULL
)
12245 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12246 thread_timer_remain_second(p
->t_gr_restart
));
12247 if (p
->t_gr_restart
!= NULL
) {
12248 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12249 thread_timer_remain_second(p
->t_gr_restart
));
12254 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12257 char dn_flag
[2] = {0};
12258 /* '*' + v6 address of neighbor */
12259 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12261 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12266 json_object_string_addf(json
, "neighborAddr", "%pSU",
12269 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12272 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12276 json_object_string_add(json
, "neighborAddr",
12279 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12282 /* more gr info in new format */
12283 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12286 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12287 safi_t safi
, bool use_json
,
12288 json_object
*json_neigh
)
12290 struct bgp_filter
*filter
;
12291 struct peer_af
*paf
;
12292 char orf_pfx_name
[BUFSIZ
];
12294 json_object
*json_af
= NULL
;
12295 json_object
*json_prefA
= NULL
;
12296 json_object
*json_prefB
= NULL
;
12297 json_object
*json_addr
= NULL
;
12298 json_object
*json_advmap
= NULL
;
12301 json_addr
= json_object_new_object();
12302 json_af
= json_object_new_object();
12303 filter
= &p
->filter
[afi
][safi
];
12305 if (peer_group_active(p
))
12306 json_object_string_add(json_addr
, "peerGroupMember",
12309 paf
= peer_af_find(p
, afi
, safi
);
12310 if (paf
&& PAF_SUBGRP(paf
)) {
12311 json_object_int_add(json_addr
, "updateGroupId",
12312 PAF_UPDGRP(paf
)->id
);
12313 json_object_int_add(json_addr
, "subGroupId",
12314 PAF_SUBGRP(paf
)->id
);
12315 json_object_int_add(json_addr
, "packetQueueLength",
12316 bpacket_queue_virtual_length(paf
));
12319 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12320 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12321 PEER_CAP_ORF_PREFIX_SM_RCV
)
12322 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12323 PEER_CAP_ORF_PREFIX_RM_ADV
)
12324 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12325 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12326 json_object_int_add(json_af
, "orfType",
12328 json_prefA
= json_object_new_object();
12329 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12330 PEER_CAP_ORF_PREFIX_SM_ADV
,
12331 PEER_CAP_ORF_PREFIX_RM_ADV
,
12332 PEER_CAP_ORF_PREFIX_SM_RCV
,
12333 PEER_CAP_ORF_PREFIX_RM_RCV
,
12334 use_json
, json_prefA
);
12335 json_object_object_add(json_af
, "orfPrefixList",
12339 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12340 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12341 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12342 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12343 PEER_CAP_ORF_PREFIX_RM_ADV
)
12344 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12345 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12346 json_object_int_add(json_af
, "orfOldType",
12347 ORF_TYPE_PREFIX_OLD
);
12348 json_prefB
= json_object_new_object();
12349 bgp_show_peer_afi_orf_cap(
12350 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12351 PEER_CAP_ORF_PREFIX_RM_ADV
,
12352 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12353 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12355 json_object_object_add(json_af
, "orfOldPrefixList",
12359 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12360 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12361 PEER_CAP_ORF_PREFIX_SM_RCV
)
12362 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12363 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12364 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12365 PEER_CAP_ORF_PREFIX_RM_ADV
)
12366 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12367 PEER_CAP_ORF_PREFIX_RM_RCV
)
12368 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12369 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12370 json_object_object_add(json_addr
, "afDependentCap",
12373 json_object_free(json_af
);
12375 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12376 p
->host
, afi
, safi
);
12377 orf_pfx_count
= prefix_bgp_show_prefix_list(
12378 NULL
, afi
, orf_pfx_name
, use_json
);
12380 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12381 PEER_STATUS_ORF_PREFIX_SEND
)
12382 || orf_pfx_count
) {
12383 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12384 PEER_STATUS_ORF_PREFIX_SEND
))
12385 json_object_boolean_true_add(json_neigh
,
12388 json_object_int_add(json_addr
, "orfRecvCounter",
12391 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12392 PEER_STATUS_ORF_WAIT_REFRESH
))
12393 json_object_string_add(
12394 json_addr
, "orfFirstUpdate",
12395 "deferredUntilORFOrRouteRefreshRecvd");
12397 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12398 PEER_FLAG_REFLECTOR_CLIENT
))
12399 json_object_boolean_true_add(json_addr
,
12400 "routeReflectorClient");
12401 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12402 PEER_FLAG_RSERVER_CLIENT
))
12403 json_object_boolean_true_add(json_addr
,
12404 "routeServerClient");
12405 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12406 json_object_boolean_true_add(json_addr
,
12407 "inboundSoftConfigPermit");
12409 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12410 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12411 json_object_boolean_true_add(
12413 "privateAsNumsAllReplacedInUpdatesToNbr");
12414 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12416 json_object_boolean_true_add(
12418 "privateAsNumsReplacedInUpdatesToNbr");
12419 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12420 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12421 json_object_boolean_true_add(
12423 "privateAsNumsAllRemovedInUpdatesToNbr");
12424 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12425 PEER_FLAG_REMOVE_PRIVATE_AS
))
12426 json_object_boolean_true_add(
12428 "privateAsNumsRemovedInUpdatesToNbr");
12430 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12431 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12432 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12433 json_object_boolean_true_add(json_addr
,
12434 "allowAsInOrigin");
12436 json_object_int_add(json_addr
, "allowAsInCount",
12437 p
->allowas_in
[afi
][safi
]);
12440 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12441 json_object_boolean_true_add(
12443 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12446 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12447 json_object_string_add(json_addr
,
12448 "overrideASNsInOutboundUpdates",
12449 "ifAspathEqualRemoteAs");
12451 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12452 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12453 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12454 json_object_boolean_true_add(json_addr
,
12455 "routerAlwaysNextHop");
12456 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12457 PEER_FLAG_AS_PATH_UNCHANGED
))
12458 json_object_boolean_true_add(
12459 json_addr
, "unchangedAsPathPropogatedToNbr");
12460 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12461 PEER_FLAG_NEXTHOP_UNCHANGED
))
12462 json_object_boolean_true_add(
12463 json_addr
, "unchangedNextHopPropogatedToNbr");
12464 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12465 json_object_boolean_true_add(
12466 json_addr
, "unchangedMedPropogatedToNbr");
12467 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12468 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12469 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12470 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12471 PEER_FLAG_SEND_COMMUNITY
)
12472 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12473 PEER_FLAG_SEND_EXT_COMMUNITY
))
12474 json_object_string_add(json_addr
,
12475 "commAttriSentToNbr",
12476 "extendedAndStandard");
12477 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12478 PEER_FLAG_SEND_EXT_COMMUNITY
))
12479 json_object_string_add(json_addr
,
12480 "commAttriSentToNbr",
12483 json_object_string_add(json_addr
,
12484 "commAttriSentToNbr",
12487 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12488 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12489 if (p
->default_rmap
[afi
][safi
].name
)
12490 json_object_string_add(
12491 json_addr
, "defaultRouteMap",
12492 p
->default_rmap
[afi
][safi
].name
);
12494 if (paf
&& PAF_SUBGRP(paf
)
12495 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12496 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12497 json_object_boolean_true_add(json_addr
,
12500 json_object_boolean_true_add(json_addr
,
12504 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12505 if (is_evpn_enabled())
12506 json_object_boolean_true_add(
12507 json_addr
, "advertiseAllVnis");
12510 if (filter
->plist
[FILTER_IN
].name
12511 || filter
->dlist
[FILTER_IN
].name
12512 || filter
->aslist
[FILTER_IN
].name
12513 || filter
->map
[RMAP_IN
].name
)
12514 json_object_boolean_true_add(json_addr
,
12515 "inboundPathPolicyConfig");
12516 if (filter
->plist
[FILTER_OUT
].name
12517 || filter
->dlist
[FILTER_OUT
].name
12518 || filter
->aslist
[FILTER_OUT
].name
12519 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12520 json_object_boolean_true_add(
12521 json_addr
, "outboundPathPolicyConfig");
12524 if (filter
->plist
[FILTER_IN
].name
)
12525 json_object_string_add(json_addr
,
12526 "incomingUpdatePrefixFilterList",
12527 filter
->plist
[FILTER_IN
].name
);
12528 if (filter
->plist
[FILTER_OUT
].name
)
12529 json_object_string_add(json_addr
,
12530 "outgoingUpdatePrefixFilterList",
12531 filter
->plist
[FILTER_OUT
].name
);
12533 /* distribute-list */
12534 if (filter
->dlist
[FILTER_IN
].name
)
12535 json_object_string_add(
12536 json_addr
, "incomingUpdateNetworkFilterList",
12537 filter
->dlist
[FILTER_IN
].name
);
12538 if (filter
->dlist
[FILTER_OUT
].name
)
12539 json_object_string_add(
12540 json_addr
, "outgoingUpdateNetworkFilterList",
12541 filter
->dlist
[FILTER_OUT
].name
);
12544 if (filter
->aslist
[FILTER_IN
].name
)
12545 json_object_string_add(json_addr
,
12546 "incomingUpdateAsPathFilterList",
12547 filter
->aslist
[FILTER_IN
].name
);
12548 if (filter
->aslist
[FILTER_OUT
].name
)
12549 json_object_string_add(json_addr
,
12550 "outgoingUpdateAsPathFilterList",
12551 filter
->aslist
[FILTER_OUT
].name
);
12554 if (filter
->map
[RMAP_IN
].name
)
12555 json_object_string_add(
12556 json_addr
, "routeMapForIncomingAdvertisements",
12557 filter
->map
[RMAP_IN
].name
);
12558 if (filter
->map
[RMAP_OUT
].name
)
12559 json_object_string_add(
12560 json_addr
, "routeMapForOutgoingAdvertisements",
12561 filter
->map
[RMAP_OUT
].name
);
12563 /* ebgp-requires-policy (inbound) */
12564 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12565 && !bgp_inbound_policy_exists(p
, filter
))
12566 json_object_string_add(
12567 json_addr
, "inboundEbgpRequiresPolicy",
12568 "Inbound updates discarded due to missing policy");
12570 /* ebgp-requires-policy (outbound) */
12571 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12572 && (!bgp_outbound_policy_exists(p
, filter
)))
12573 json_object_string_add(
12574 json_addr
, "outboundEbgpRequiresPolicy",
12575 "Outbound updates discarded due to missing policy");
12577 /* unsuppress-map */
12578 if (filter
->usmap
.name
)
12579 json_object_string_add(json_addr
,
12580 "selectiveUnsuppressRouteMap",
12581 filter
->usmap
.name
);
12583 /* advertise-map */
12584 if (filter
->advmap
.aname
) {
12585 json_advmap
= json_object_new_object();
12586 json_object_string_add(json_advmap
, "condition",
12587 filter
->advmap
.condition
12590 json_object_string_add(json_advmap
, "conditionMap",
12591 filter
->advmap
.cname
);
12592 json_object_string_add(json_advmap
, "advertiseMap",
12593 filter
->advmap
.aname
);
12594 json_object_string_add(
12595 json_advmap
, "advertiseStatus",
12596 filter
->advmap
.update_type
==
12597 UPDATE_TYPE_ADVERTISE
12600 json_object_object_add(json_addr
, "advertiseMap",
12604 /* Receive prefix count */
12605 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12606 p
->pcount
[afi
][safi
]);
12607 if (paf
&& PAF_SUBGRP(paf
))
12608 json_object_int_add(json_addr
, "sentPrefixCounter",
12609 (PAF_SUBGRP(paf
))->scount
);
12611 /* Maximum prefix */
12612 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12613 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12614 p
->pmax_out
[afi
][safi
]);
12616 /* Maximum prefix */
12617 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12618 json_object_int_add(json_addr
, "prefixAllowedMax",
12619 p
->pmax
[afi
][safi
]);
12620 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12621 PEER_FLAG_MAX_PREFIX_WARNING
))
12622 json_object_boolean_true_add(
12623 json_addr
, "prefixAllowedMaxWarning");
12624 json_object_int_add(json_addr
,
12625 "prefixAllowedWarningThresh",
12626 p
->pmax_threshold
[afi
][safi
]);
12627 if (p
->pmax_restart
[afi
][safi
])
12628 json_object_int_add(
12630 "prefixAllowedRestartIntervalMsecs",
12631 p
->pmax_restart
[afi
][safi
] * 60000);
12633 json_object_object_add(json_neigh
,
12634 get_afi_safi_str(afi
, safi
, true),
12638 filter
= &p
->filter
[afi
][safi
];
12640 vty_out(vty
, " For address family: %s\n",
12641 get_afi_safi_str(afi
, safi
, false));
12643 if (peer_group_active(p
))
12644 vty_out(vty
, " %s peer-group member\n",
12647 paf
= peer_af_find(p
, afi
, safi
);
12648 if (paf
&& PAF_SUBGRP(paf
)) {
12649 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12650 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12651 vty_out(vty
, " Packet Queue length %d\n",
12652 bpacket_queue_virtual_length(paf
));
12654 vty_out(vty
, " Not part of any update group\n");
12656 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12657 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12658 PEER_CAP_ORF_PREFIX_SM_RCV
)
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_RCV
)
12665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12666 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12667 vty_out(vty
, " AF-dependant capabilities:\n");
12669 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12670 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12671 PEER_CAP_ORF_PREFIX_SM_RCV
)
12672 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12673 PEER_CAP_ORF_PREFIX_RM_ADV
)
12674 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12675 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12677 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12679 bgp_show_peer_afi_orf_cap(
12680 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12681 PEER_CAP_ORF_PREFIX_RM_ADV
,
12682 PEER_CAP_ORF_PREFIX_SM_RCV
,
12683 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12685 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12687 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12688 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12689 PEER_CAP_ORF_PREFIX_RM_ADV
)
12690 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12691 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12693 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12694 ORF_TYPE_PREFIX_OLD
);
12695 bgp_show_peer_afi_orf_cap(
12696 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12697 PEER_CAP_ORF_PREFIX_RM_ADV
,
12698 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12699 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12702 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12703 p
->host
, afi
, safi
);
12704 orf_pfx_count
= prefix_bgp_show_prefix_list(
12705 NULL
, afi
, orf_pfx_name
, use_json
);
12707 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12708 PEER_STATUS_ORF_PREFIX_SEND
)
12709 || orf_pfx_count
) {
12710 vty_out(vty
, " Outbound Route Filter (ORF):");
12711 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12712 PEER_STATUS_ORF_PREFIX_SEND
))
12713 vty_out(vty
, " sent;");
12715 vty_out(vty
, " received (%d entries)",
12717 vty_out(vty
, "\n");
12719 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12720 PEER_STATUS_ORF_WAIT_REFRESH
))
12722 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12724 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12725 PEER_FLAG_REFLECTOR_CLIENT
))
12726 vty_out(vty
, " Route-Reflector Client\n");
12727 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12728 PEER_FLAG_RSERVER_CLIENT
))
12729 vty_out(vty
, " Route-Server Client\n");
12730 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12732 " Inbound soft reconfiguration allowed\n");
12734 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12735 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12737 " Private AS numbers (all) replaced in updates to this neighbor\n");
12738 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12739 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12741 " Private AS numbers replaced in updates to this neighbor\n");
12742 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12743 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12745 " Private AS numbers (all) removed in updates to this neighbor\n");
12746 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12747 PEER_FLAG_REMOVE_PRIVATE_AS
))
12749 " Private AS numbers removed in updates to this neighbor\n");
12751 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12753 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12755 " Local AS allowed as path origin\n");
12758 " Local AS allowed in path, %d occurrences\n",
12759 p
->allowas_in
[afi
][safi
]);
12762 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12763 vty_out(vty
, " %s\n",
12764 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12765 ->human_description
);
12767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12769 " Override ASNs in outbound updates if aspath equals remote-as\n");
12771 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12772 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12773 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12774 vty_out(vty
, " NEXT_HOP is always this router\n");
12775 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12776 PEER_FLAG_AS_PATH_UNCHANGED
))
12778 " AS_PATH is propagated unchanged to this neighbor\n");
12779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12780 PEER_FLAG_NEXTHOP_UNCHANGED
))
12782 " NEXT_HOP is propagated unchanged to this neighbor\n");
12783 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12785 " MED is propagated unchanged to this neighbor\n");
12786 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12787 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12788 PEER_FLAG_SEND_EXT_COMMUNITY
)
12789 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12790 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12792 " Community attribute sent to this neighbor");
12793 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12794 PEER_FLAG_SEND_COMMUNITY
)
12795 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12796 PEER_FLAG_SEND_EXT_COMMUNITY
)
12797 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12798 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12799 vty_out(vty
, "(all)\n");
12800 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12801 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12802 vty_out(vty
, "(large)\n");
12803 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12804 PEER_FLAG_SEND_EXT_COMMUNITY
))
12805 vty_out(vty
, "(extended)\n");
12807 vty_out(vty
, "(standard)\n");
12809 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12810 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12811 vty_out(vty
, " Default information originate,");
12813 if (p
->default_rmap
[afi
][safi
].name
)
12814 vty_out(vty
, " default route-map %s%s,",
12815 p
->default_rmap
[afi
][safi
].map
? "*"
12817 p
->default_rmap
[afi
][safi
].name
);
12818 if (paf
&& PAF_SUBGRP(paf
)
12819 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12820 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12821 vty_out(vty
, " default sent\n");
12823 vty_out(vty
, " default not sent\n");
12826 /* advertise-vni-all */
12827 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12828 if (is_evpn_enabled())
12829 vty_out(vty
, " advertise-all-vni\n");
12832 if (filter
->plist
[FILTER_IN
].name
12833 || filter
->dlist
[FILTER_IN
].name
12834 || filter
->aslist
[FILTER_IN
].name
12835 || filter
->map
[RMAP_IN
].name
)
12836 vty_out(vty
, " Inbound path policy configured\n");
12837 if (filter
->plist
[FILTER_OUT
].name
12838 || filter
->dlist
[FILTER_OUT
].name
12839 || filter
->aslist
[FILTER_OUT
].name
12840 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12841 vty_out(vty
, " Outbound path policy configured\n");
12844 if (filter
->plist
[FILTER_IN
].name
)
12846 " Incoming update prefix filter list is %s%s\n",
12847 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12848 filter
->plist
[FILTER_IN
].name
);
12849 if (filter
->plist
[FILTER_OUT
].name
)
12851 " Outgoing update prefix filter list is %s%s\n",
12852 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12853 filter
->plist
[FILTER_OUT
].name
);
12855 /* distribute-list */
12856 if (filter
->dlist
[FILTER_IN
].name
)
12858 " Incoming update network filter list is %s%s\n",
12859 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12860 filter
->dlist
[FILTER_IN
].name
);
12861 if (filter
->dlist
[FILTER_OUT
].name
)
12863 " Outgoing update network filter list is %s%s\n",
12864 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12865 filter
->dlist
[FILTER_OUT
].name
);
12868 if (filter
->aslist
[FILTER_IN
].name
)
12870 " Incoming update AS path filter list is %s%s\n",
12871 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12872 filter
->aslist
[FILTER_IN
].name
);
12873 if (filter
->aslist
[FILTER_OUT
].name
)
12875 " Outgoing update AS path filter list is %s%s\n",
12876 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12877 filter
->aslist
[FILTER_OUT
].name
);
12880 if (filter
->map
[RMAP_IN
].name
)
12882 " Route map for incoming advertisements is %s%s\n",
12883 filter
->map
[RMAP_IN
].map
? "*" : "",
12884 filter
->map
[RMAP_IN
].name
);
12885 if (filter
->map
[RMAP_OUT
].name
)
12887 " Route map for outgoing advertisements is %s%s\n",
12888 filter
->map
[RMAP_OUT
].map
? "*" : "",
12889 filter
->map
[RMAP_OUT
].name
);
12891 /* ebgp-requires-policy (inbound) */
12892 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12893 && !bgp_inbound_policy_exists(p
, filter
))
12895 " Inbound updates discarded due to missing policy\n");
12897 /* ebgp-requires-policy (outbound) */
12898 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12899 && !bgp_outbound_policy_exists(p
, filter
))
12901 " Outbound updates discarded due to missing policy\n");
12903 /* unsuppress-map */
12904 if (filter
->usmap
.name
)
12906 " Route map for selective unsuppress is %s%s\n",
12907 filter
->usmap
.map
? "*" : "",
12908 filter
->usmap
.name
);
12910 /* advertise-map */
12911 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12913 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12914 filter
->advmap
.condition
? "EXIST"
12916 filter
->advmap
.cmap
? "*" : "",
12917 filter
->advmap
.cname
,
12918 filter
->advmap
.amap
? "*" : "",
12919 filter
->advmap
.aname
,
12920 filter
->advmap
.update_type
==
12921 UPDATE_TYPE_ADVERTISE
12925 /* Receive prefix count */
12926 vty_out(vty
, " %u accepted prefixes\n",
12927 p
->pcount
[afi
][safi
]);
12929 /* maximum-prefix-out */
12930 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12931 PEER_FLAG_MAX_PREFIX_OUT
))
12933 " Maximum allowed prefixes sent %u\n",
12934 p
->pmax_out
[afi
][safi
]);
12936 /* Maximum prefix */
12937 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12939 " Maximum prefixes allowed %u%s\n",
12940 p
->pmax
[afi
][safi
],
12941 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12942 PEER_FLAG_MAX_PREFIX_WARNING
)
12943 ? " (warning-only)"
12945 vty_out(vty
, " Threshold for warning message %d%%",
12946 p
->pmax_threshold
[afi
][safi
]);
12947 if (p
->pmax_restart
[afi
][safi
])
12948 vty_out(vty
, ", restart interval %d min",
12949 p
->pmax_restart
[afi
][safi
]);
12950 vty_out(vty
, "\n");
12953 vty_out(vty
, "\n");
12957 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12961 char timebuf
[BGP_UPTIME_LEN
];
12967 json_object
*json_neigh
= NULL
;
12969 uint32_t sync_tcp_mss
;
12974 json_neigh
= json_object_new_object();
12976 memset(dn_flag
, '\0', sizeof(dn_flag
));
12977 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12981 if (p
->conf_if
) /* Configured interface name. */
12982 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12984 else /* Configured IP address. */
12985 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12990 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12991 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12993 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12994 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12997 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12999 if (p
->change_local_as
)
13000 json_object_int_add(json_neigh
, "localAs",
13001 p
->change_local_as
);
13003 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13005 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13006 json_object_boolean_true_add(json_neigh
,
13007 "localAsNoPrepend");
13009 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13010 json_object_boolean_true_add(json_neigh
,
13011 "localAsReplaceAs");
13013 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13014 || (p
->as_type
== AS_INTERNAL
))
13015 vty_out(vty
, "remote AS %u, ", p
->as
);
13017 vty_out(vty
, "remote AS Unspecified, ");
13018 vty_out(vty
, "local AS %u%s%s, ",
13019 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13020 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13023 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13027 /* peer type internal or confed-internal */
13028 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13030 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13031 json_object_boolean_true_add(
13032 json_neigh
, "nbrConfedInternalLink");
13034 json_object_boolean_true_add(json_neigh
,
13035 "nbrInternalLink");
13037 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13038 vty_out(vty
, "confed-internal link\n");
13040 vty_out(vty
, "internal link\n");
13042 /* peer type external or confed-external */
13043 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13045 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13046 json_object_boolean_true_add(
13047 json_neigh
, "nbrConfedExternalLink");
13049 json_object_boolean_true_add(json_neigh
,
13050 "nbrExternalLink");
13052 if (bgp_confederation_peers_check(bgp
, p
->as
))
13053 vty_out(vty
, "confed-external link\n");
13055 vty_out(vty
, "external link\n");
13059 json_object_boolean_true_add(json_neigh
,
13060 "nbrUnspecifiedLink");
13062 vty_out(vty
, "unspecified link\n");
13067 json_object_string_add(json_neigh
, "localRole",
13068 bgp_get_name_by_role(p
->local_role
));
13069 json_object_string_add(json_neigh
, "remoteRole",
13070 bgp_get_name_by_role(p
->remote_role
));
13072 vty_out(vty
, " Local Role: %s\n",
13073 bgp_get_name_by_role(p
->local_role
));
13074 vty_out(vty
, " Remote Role: %s\n",
13075 bgp_get_name_by_role(p
->remote_role
));
13082 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13084 vty_out(vty
, " Description: %s\n", p
->desc
);
13089 json_object_string_add(json_neigh
, "hostname",
13093 json_object_string_add(json_neigh
, "domainname",
13096 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13097 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13100 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13104 json_object_string_add(json_neigh
, "hostname",
13111 json_object_string_add(json_neigh
, "peerGroup",
13115 struct prefix prefix
, *range
= NULL
;
13117 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13118 range
= peer_group_lookup_dynamic_neighbor_range(
13119 p
->group
, &prefix
);
13122 json_object_string_addf(
13124 "peerSubnetRangeGroup", "%pFX",
13130 " Member of peer-group %s for session parameters\n",
13134 struct prefix prefix
, *range
= NULL
;
13136 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13137 range
= peer_group_lookup_dynamic_neighbor_range(
13138 p
->group
, &prefix
);
13142 " Belongs to the subnet range group: %pFX\n",
13150 /* Administrative shutdown. */
13151 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13152 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13153 json_object_boolean_true_add(json_neigh
,
13157 json_object_int_add(json_neigh
, "bgpVersion", 4);
13158 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13160 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13163 /* Confederation */
13164 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13165 && bgp_confederation_peers_check(bgp
, p
->as
))
13166 json_object_boolean_true_add(json_neigh
,
13170 json_object_string_add(
13171 json_neigh
, "bgpState",
13172 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13174 if (peer_established(p
)) {
13177 uptime
= monotime(NULL
);
13178 uptime
-= p
->uptime
;
13179 epoch_tbuf
= time(NULL
) - uptime
;
13181 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13183 json_object_string_add(json_neigh
, "bgpTimerUpString",
13184 peer_uptime(p
->uptime
, timebuf
,
13187 json_object_int_add(json_neigh
,
13188 "bgpTimerUpEstablishedEpoch",
13192 else if (p
->status
== Active
) {
13193 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13194 json_object_string_add(json_neigh
, "bgpStateIs",
13196 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13197 json_object_string_add(json_neigh
, "bgpStateIs",
13205 uptime
= monotime(NULL
);
13206 uptime
-= p
->readtime
;
13207 gmtime_r(&uptime
, &tm
);
13209 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13210 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13211 + (tm
.tm_hour
* 3600000));
13213 uptime
= monotime(NULL
);
13214 uptime
-= p
->last_write
;
13215 gmtime_r(&uptime
, &tm
);
13217 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13218 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13219 + (tm
.tm_hour
* 3600000));
13221 uptime
= monotime(NULL
);
13222 uptime
-= p
->update_time
;
13223 gmtime_r(&uptime
, &tm
);
13225 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13226 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13227 + (tm
.tm_hour
* 3600000));
13229 /* Configured timer values. */
13230 json_object_int_add(json_neigh
,
13231 "bgpTimerConfiguredHoldTimeMsecs",
13232 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13233 ? p
->holdtime
* 1000
13234 : bgp
->default_holdtime
* 1000);
13235 json_object_int_add(json_neigh
,
13236 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13237 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13238 ? p
->keepalive
* 1000
13239 : bgp
->default_keepalive
* 1000);
13240 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13241 p
->v_holdtime
* 1000);
13242 json_object_int_add(json_neigh
,
13243 "bgpTimerKeepAliveIntervalMsecs",
13244 p
->v_keepalive
* 1000);
13245 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13246 json_object_int_add(json_neigh
,
13247 "bgpTimerDelayOpenTimeMsecs",
13248 p
->v_delayopen
* 1000);
13251 /* Configured and Synced tcp-mss value for peer */
13252 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13253 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13254 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13256 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13260 /* Extended Optional Parameters Length for BGP OPEN Message */
13261 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13262 json_object_boolean_true_add(
13263 json_neigh
, "extendedOptionalParametersLength");
13265 json_object_boolean_false_add(
13266 json_neigh
, "extendedOptionalParametersLength");
13268 /* Conditional advertisements */
13269 json_object_int_add(
13271 "bgpTimerConfiguredConditionalAdvertisementsSec",
13272 bgp
->condition_check_period
);
13273 if (thread_is_scheduled(bgp
->t_condition_check
))
13274 json_object_int_add(
13276 "bgpTimerUntilConditionalAdvertisementsSec",
13277 thread_timer_remain_second(
13278 bgp
->t_condition_check
));
13280 /* Administrative shutdown. */
13281 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13282 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13283 vty_out(vty
, " Administratively shut down\n");
13286 vty_out(vty
, " BGP version 4");
13287 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13288 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13290 /* Confederation */
13291 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13292 && bgp_confederation_peers_check(bgp
, p
->as
))
13294 " Neighbor under common administration\n");
13297 vty_out(vty
, " BGP state = %s",
13298 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13300 if (peer_established(p
))
13301 vty_out(vty
, ", up for %8s",
13302 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13305 else if (p
->status
== Active
) {
13306 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13307 vty_out(vty
, " (passive)");
13308 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13309 vty_out(vty
, " (NSF passive)");
13311 vty_out(vty
, "\n");
13314 vty_out(vty
, " Last read %s",
13315 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13317 vty_out(vty
, ", Last write %s\n",
13318 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13321 /* Configured timer values. */
13323 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13324 p
->v_holdtime
, p
->v_keepalive
);
13325 vty_out(vty
, " Configured hold time is %d seconds",
13326 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13328 : bgp
->default_holdtime
);
13329 vty_out(vty
, ", keepalive interval is %d seconds\n",
13330 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13332 : bgp
->default_keepalive
);
13333 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13335 " Configured DelayOpenTime is %d seconds\n",
13338 /* Configured and synced tcp-mss value for peer */
13339 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13340 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13341 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13342 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13345 /* Extended Optional Parameters Length for BGP OPEN Message */
13346 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13348 " Extended Optional Parameters Length is enabled\n");
13350 /* Conditional advertisements */
13352 " Configured conditional advertisements interval is %d seconds\n",
13353 bgp
->condition_check_period
);
13354 if (thread_is_scheduled(bgp
->t_condition_check
))
13356 " Time until conditional advertisements begin is %lu seconds\n",
13357 thread_timer_remain_second(
13358 bgp
->t_condition_check
));
13361 if (peer_established(p
) &&
13362 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13364 json_object
*json_cap
= NULL
;
13366 json_cap
= json_object_new_object();
13369 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13370 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13371 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13372 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13373 json_object_string_add(
13374 json_cap
, "4byteAs",
13375 "advertisedAndReceived");
13376 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13377 json_object_string_add(json_cap
,
13380 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13381 json_object_string_add(json_cap
,
13386 /* Extended Message Support */
13387 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13388 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13389 json_object_string_add(json_cap
,
13391 "advertisedAndReceived");
13392 else if (CHECK_FLAG(p
->cap
,
13393 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13394 json_object_string_add(json_cap
,
13397 else if (CHECK_FLAG(p
->cap
,
13398 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13399 json_object_string_add(json_cap
,
13404 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13405 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13406 json_object
*json_add
= NULL
;
13407 const char *print_store
;
13409 json_add
= json_object_new_object();
13411 FOREACH_AFI_SAFI (afi
, safi
) {
13412 json_object
*json_sub
= NULL
;
13413 json_sub
= json_object_new_object();
13414 print_store
= get_afi_safi_str(
13418 p
->af_cap
[afi
][safi
],
13419 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13421 p
->af_cap
[afi
][safi
],
13422 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13426 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13430 PEER_CAP_ADDPATH_AF_TX_RCV
))
13431 json_object_boolean_true_add(
13433 "txAdvertisedAndReceived");
13438 PEER_CAP_ADDPATH_AF_TX_ADV
))
13439 json_object_boolean_true_add(
13446 PEER_CAP_ADDPATH_AF_TX_RCV
))
13447 json_object_boolean_true_add(
13453 p
->af_cap
[afi
][safi
],
13454 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13456 p
->af_cap
[afi
][safi
],
13457 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13461 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13465 PEER_CAP_ADDPATH_AF_RX_RCV
))
13466 json_object_boolean_true_add(
13468 "rxAdvertisedAndReceived");
13473 PEER_CAP_ADDPATH_AF_RX_ADV
))
13474 json_object_boolean_true_add(
13481 PEER_CAP_ADDPATH_AF_RX_RCV
))
13482 json_object_boolean_true_add(
13488 p
->af_cap
[afi
][safi
],
13489 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13491 p
->af_cap
[afi
][safi
],
13492 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13494 p
->af_cap
[afi
][safi
],
13495 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13497 p
->af_cap
[afi
][safi
],
13498 PEER_CAP_ADDPATH_AF_RX_RCV
))
13499 json_object_object_add(
13500 json_add
, print_store
,
13503 json_object_free(json_sub
);
13506 json_object_object_add(json_cap
, "addPath",
13511 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13512 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13513 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13514 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13515 json_object_string_add(
13516 json_cap
, "dynamic",
13517 "advertisedAndReceived");
13518 else if (CHECK_FLAG(p
->cap
,
13519 PEER_CAP_DYNAMIC_ADV
))
13520 json_object_string_add(json_cap
,
13523 else if (CHECK_FLAG(p
->cap
,
13524 PEER_CAP_DYNAMIC_RCV
))
13525 json_object_string_add(json_cap
,
13531 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13532 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13533 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13534 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13535 json_object_string_add(
13537 "advertisedAndReceived");
13538 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13539 json_object_string_add(json_cap
, "role",
13541 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13542 json_object_string_add(json_cap
, "role",
13546 /* Extended nexthop */
13547 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13548 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13549 json_object
*json_nxt
= NULL
;
13550 const char *print_store
;
13553 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13554 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13555 json_object_string_add(
13556 json_cap
, "extendedNexthop",
13557 "advertisedAndReceived");
13558 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13559 json_object_string_add(
13560 json_cap
, "extendedNexthop",
13562 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13563 json_object_string_add(
13564 json_cap
, "extendedNexthop",
13567 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13568 json_nxt
= json_object_new_object();
13570 for (safi
= SAFI_UNICAST
;
13571 safi
< SAFI_MAX
; safi
++) {
13575 PEER_CAP_ENHE_AF_RCV
)) {
13581 json_object_string_add(
13584 "recieved"); /* misspelled for compatibility */
13587 json_object_object_add(
13589 "extendedNexthopFamililesByPeer",
13594 /* Long-lived Graceful Restart */
13595 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13596 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13597 json_object
*json_llgr
= NULL
;
13598 const char *afi_safi_str
;
13600 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13601 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13602 json_object_string_add(
13604 "longLivedGracefulRestart",
13605 "advertisedAndReceived");
13606 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13607 json_object_string_add(
13609 "longLivedGracefulRestart",
13611 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13612 json_object_string_add(
13614 "longLivedGracefulRestart",
13617 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13618 json_llgr
= json_object_new_object();
13620 FOREACH_AFI_SAFI (afi
, safi
) {
13624 PEER_CAP_ENHE_AF_RCV
)) {
13630 json_object_string_add(
13636 json_object_object_add(
13638 "longLivedGracefulRestartByPeer",
13643 /* Route Refresh */
13644 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13645 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13646 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13647 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13648 (CHECK_FLAG(p
->cap
,
13649 PEER_CAP_REFRESH_NEW_RCV
) ||
13651 PEER_CAP_REFRESH_OLD_RCV
))) {
13654 PEER_CAP_REFRESH_OLD_RCV
) &&
13657 PEER_CAP_REFRESH_NEW_RCV
))
13658 json_object_string_add(
13661 "advertisedAndReceivedOldNew");
13665 PEER_CAP_REFRESH_OLD_RCV
))
13666 json_object_string_add(
13669 "advertisedAndReceivedOld");
13671 json_object_string_add(
13674 "advertisedAndReceivedNew");
13676 } else if (CHECK_FLAG(p
->cap
,
13677 PEER_CAP_REFRESH_ADV
))
13678 json_object_string_add(json_cap
,
13681 else if (CHECK_FLAG(p
->cap
,
13682 PEER_CAP_REFRESH_NEW_RCV
) ||
13684 PEER_CAP_REFRESH_OLD_RCV
))
13685 json_object_string_add(json_cap
,
13690 /* Enhanced Route Refresh */
13691 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13692 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13693 if (CHECK_FLAG(p
->cap
,
13694 PEER_CAP_ENHANCED_RR_ADV
) &&
13696 PEER_CAP_ENHANCED_RR_RCV
))
13697 json_object_string_add(
13699 "enhancedRouteRefresh",
13700 "advertisedAndReceived");
13701 else if (CHECK_FLAG(p
->cap
,
13702 PEER_CAP_ENHANCED_RR_ADV
))
13703 json_object_string_add(
13705 "enhancedRouteRefresh",
13707 else if (CHECK_FLAG(p
->cap
,
13708 PEER_CAP_ENHANCED_RR_RCV
))
13709 json_object_string_add(
13711 "enhancedRouteRefresh",
13715 /* Multiprotocol Extensions */
13716 json_object
*json_multi
= NULL
;
13718 json_multi
= json_object_new_object();
13720 FOREACH_AFI_SAFI (afi
, safi
) {
13721 if (p
->afc_adv
[afi
][safi
] ||
13722 p
->afc_recv
[afi
][safi
]) {
13723 json_object
*json_exten
= NULL
;
13724 json_exten
= json_object_new_object();
13726 if (p
->afc_adv
[afi
][safi
] &&
13727 p
->afc_recv
[afi
][safi
])
13728 json_object_boolean_true_add(
13730 "advertisedAndReceived");
13731 else if (p
->afc_adv
[afi
][safi
])
13732 json_object_boolean_true_add(
13735 else if (p
->afc_recv
[afi
][safi
])
13736 json_object_boolean_true_add(
13737 json_exten
, "received");
13739 json_object_object_add(
13741 get_afi_safi_str(afi
, safi
,
13746 json_object_object_add(json_cap
,
13747 "multiprotocolExtensions",
13750 /* Hostname capabilities */
13751 json_object
*json_hname
= NULL
;
13753 json_hname
= json_object_new_object();
13755 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13756 json_object_string_add(
13757 json_hname
, "advHostName",
13758 bgp
->peer_self
->hostname
13759 ? bgp
->peer_self
->hostname
13761 json_object_string_add(
13762 json_hname
, "advDomainName",
13763 bgp
->peer_self
->domainname
13764 ? bgp
->peer_self
->domainname
13769 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13770 json_object_string_add(
13771 json_hname
, "rcvHostName",
13772 p
->hostname
? p
->hostname
: "n/a");
13773 json_object_string_add(
13774 json_hname
, "rcvDomainName",
13775 p
->domainname
? p
->domainname
: "n/a");
13778 json_object_object_add(json_cap
, "hostName",
13781 /* Graceful Restart */
13782 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13783 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13784 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13785 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13786 json_object_string_add(
13787 json_cap
, "gracefulRestart",
13788 "advertisedAndReceived");
13789 else if (CHECK_FLAG(p
->cap
,
13790 PEER_CAP_RESTART_ADV
))
13791 json_object_string_add(
13793 "gracefulRestartCapability",
13795 else if (CHECK_FLAG(p
->cap
,
13796 PEER_CAP_RESTART_RCV
))
13797 json_object_string_add(
13799 "gracefulRestartCapability",
13802 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13803 int restart_af_count
= 0;
13804 json_object
*json_restart
= NULL
;
13805 json_restart
= json_object_new_object();
13807 json_object_int_add(
13809 "gracefulRestartRemoteTimerMsecs",
13810 p
->v_gr_restart
* 1000);
13812 FOREACH_AFI_SAFI (afi
, safi
) {
13816 PEER_CAP_RESTART_AF_RCV
)) {
13817 json_object
*json_sub
=
13820 json_object_new_object();
13826 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13827 json_object_boolean_true_add(
13830 restart_af_count
++;
13831 json_object_object_add(
13840 if (!restart_af_count
) {
13841 json_object_string_add(
13843 "addressFamiliesByPeer",
13845 json_object_free(json_restart
);
13847 json_object_object_add(
13849 "addressFamiliesByPeer",
13853 json_object_object_add(
13854 json_neigh
, "neighborCapabilities", json_cap
);
13856 vty_out(vty
, " Neighbor capabilities:\n");
13859 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13860 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13861 vty_out(vty
, " 4 Byte AS:");
13862 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13863 vty_out(vty
, " advertised");
13864 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13865 vty_out(vty
, " %sreceived",
13870 vty_out(vty
, "\n");
13873 /* Extended Message Support */
13874 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13875 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13876 vty_out(vty
, " Extended Message:");
13877 if (CHECK_FLAG(p
->cap
,
13878 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13879 vty_out(vty
, " advertised");
13880 if (CHECK_FLAG(p
->cap
,
13881 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13882 vty_out(vty
, " %sreceived",
13885 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13888 vty_out(vty
, "\n");
13892 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13893 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13894 vty_out(vty
, " AddPath:\n");
13896 FOREACH_AFI_SAFI (afi
, safi
) {
13898 p
->af_cap
[afi
][safi
],
13899 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13901 p
->af_cap
[afi
][safi
],
13902 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13903 vty_out(vty
, " %s: TX ",
13911 PEER_CAP_ADDPATH_AF_TX_ADV
))
13918 PEER_CAP_ADDPATH_AF_TX_RCV
))
13925 PEER_CAP_ADDPATH_AF_TX_ADV
)
13929 vty_out(vty
, "\n");
13933 p
->af_cap
[afi
][safi
],
13934 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13936 p
->af_cap
[afi
][safi
],
13937 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13938 vty_out(vty
, " %s: RX ",
13946 PEER_CAP_ADDPATH_AF_RX_ADV
))
13953 PEER_CAP_ADDPATH_AF_RX_RCV
))
13960 PEER_CAP_ADDPATH_AF_RX_ADV
)
13964 vty_out(vty
, "\n");
13970 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13971 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13972 vty_out(vty
, " Dynamic:");
13973 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13974 vty_out(vty
, " advertised");
13975 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13976 vty_out(vty
, " %sreceived",
13978 PEER_CAP_DYNAMIC_ADV
)
13981 vty_out(vty
, "\n");
13985 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13986 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13987 vty_out(vty
, " Role:");
13988 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13989 vty_out(vty
, " advertised");
13990 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13991 vty_out(vty
, " %sreceived",
13996 vty_out(vty
, "\n");
13999 /* Extended nexthop */
14000 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14001 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14002 vty_out(vty
, " Extended nexthop:");
14003 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14004 vty_out(vty
, " advertised");
14005 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14006 vty_out(vty
, " %sreceived",
14011 vty_out(vty
, "\n");
14013 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14015 " Address families by peer:\n ");
14016 for (safi
= SAFI_UNICAST
;
14017 safi
< SAFI_MAX
; safi
++)
14021 PEER_CAP_ENHE_AF_RCV
))
14031 /* Long-lived Graceful Restart */
14032 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14033 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14035 " Long-lived Graceful Restart:");
14036 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14037 vty_out(vty
, " advertised");
14038 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14039 vty_out(vty
, " %sreceived",
14044 vty_out(vty
, "\n");
14046 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14048 " Address families by peer:\n");
14049 FOREACH_AFI_SAFI (afi
, safi
)
14053 PEER_CAP_LLGR_AF_RCV
))
14063 /* Route Refresh */
14064 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14065 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14066 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14067 vty_out(vty
, " Route refresh:");
14068 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14069 vty_out(vty
, " advertised");
14070 if (CHECK_FLAG(p
->cap
,
14071 PEER_CAP_REFRESH_NEW_RCV
) ||
14073 PEER_CAP_REFRESH_OLD_RCV
))
14074 vty_out(vty
, " %sreceived(%s)",
14076 PEER_CAP_REFRESH_ADV
)
14081 PEER_CAP_REFRESH_OLD_RCV
) &&
14084 PEER_CAP_REFRESH_NEW_RCV
))
14088 PEER_CAP_REFRESH_OLD_RCV
)
14092 vty_out(vty
, "\n");
14095 /* Enhanced Route Refresh */
14096 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14097 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14098 vty_out(vty
, " Enhanced Route Refresh:");
14099 if (CHECK_FLAG(p
->cap
,
14100 PEER_CAP_ENHANCED_RR_ADV
))
14101 vty_out(vty
, " advertised");
14102 if (CHECK_FLAG(p
->cap
,
14103 PEER_CAP_ENHANCED_RR_RCV
))
14104 vty_out(vty
, " %sreceived",
14106 PEER_CAP_REFRESH_ADV
)
14109 vty_out(vty
, "\n");
14112 /* Multiprotocol Extensions */
14113 FOREACH_AFI_SAFI (afi
, safi
)
14114 if (p
->afc_adv
[afi
][safi
] ||
14115 p
->afc_recv
[afi
][safi
]) {
14116 vty_out(vty
, " Address Family %s:",
14117 get_afi_safi_str(afi
, safi
,
14119 if (p
->afc_adv
[afi
][safi
])
14120 vty_out(vty
, " advertised");
14121 if (p
->afc_recv
[afi
][safi
])
14122 vty_out(vty
, " %sreceived",
14123 p
->afc_adv
[afi
][safi
]
14126 vty_out(vty
, "\n");
14129 /* Hostname capability */
14130 vty_out(vty
, " Hostname Capability:");
14132 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14134 " advertised (name: %s,domain name: %s)",
14135 bgp
->peer_self
->hostname
14136 ? bgp
->peer_self
->hostname
14138 bgp
->peer_self
->domainname
14139 ? bgp
->peer_self
->domainname
14142 vty_out(vty
, " not advertised");
14145 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14147 " received (name: %s,domain name: %s)",
14148 p
->hostname
? p
->hostname
: "n/a",
14149 p
->domainname
? p
->domainname
: "n/a");
14151 vty_out(vty
, " not received");
14154 vty_out(vty
, "\n");
14156 /* Graceful Restart */
14157 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14158 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14160 " Graceful Restart Capability:");
14161 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14162 vty_out(vty
, " advertised");
14163 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14164 vty_out(vty
, " %sreceived",
14166 PEER_CAP_RESTART_ADV
)
14169 vty_out(vty
, "\n");
14171 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14172 int restart_af_count
= 0;
14175 " Remote Restart timer is %d seconds\n",
14178 " Address families by peer:\n ");
14180 FOREACH_AFI_SAFI (afi
, safi
)
14184 PEER_CAP_RESTART_AF_RCV
)) {
14185 vty_out(vty
, "%s%s(%s)",
14197 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14199 : "not preserved");
14200 restart_af_count
++;
14202 if (!restart_af_count
)
14203 vty_out(vty
, "none");
14204 vty_out(vty
, "\n");
14206 } /* Graceful Restart */
14210 /* graceful restart information */
14211 json_object
*json_grace
= NULL
;
14212 json_object
*json_grace_send
= NULL
;
14213 json_object
*json_grace_recv
= NULL
;
14214 int eor_send_af_count
= 0;
14215 int eor_receive_af_count
= 0;
14218 json_grace
= json_object_new_object();
14219 json_grace_send
= json_object_new_object();
14220 json_grace_recv
= json_object_new_object();
14222 if ((peer_established(p
)) &&
14223 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14224 FOREACH_AFI_SAFI (afi
, safi
) {
14225 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14226 PEER_STATUS_EOR_SEND
)) {
14227 json_object_boolean_true_add(
14229 get_afi_safi_str(afi
, safi
,
14231 eor_send_af_count
++;
14234 FOREACH_AFI_SAFI (afi
, safi
) {
14235 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14236 PEER_STATUS_EOR_RECEIVED
)) {
14237 json_object_boolean_true_add(
14239 get_afi_safi_str(afi
, safi
,
14241 eor_receive_af_count
++;
14245 json_object_object_add(json_grace
, "endOfRibSend",
14247 json_object_object_add(json_grace
, "endOfRibRecv",
14251 if (p
->t_gr_restart
)
14252 json_object_int_add(
14253 json_grace
, "gracefulRestartTimerMsecs",
14254 thread_timer_remain_second(p
->t_gr_restart
) *
14258 json_object_int_add(
14259 json_grace
, "gracefulStalepathTimerMsecs",
14260 thread_timer_remain_second(p
->t_gr_stale
) *
14262 /* more gr info in new format */
14263 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14264 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14267 vty_out(vty
, " Graceful restart information:\n");
14268 if ((peer_established(p
)) &&
14269 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14271 vty_out(vty
, " End-of-RIB send: ");
14272 FOREACH_AFI_SAFI (afi
, safi
) {
14273 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14274 PEER_STATUS_EOR_SEND
)) {
14275 vty_out(vty
, "%s%s",
14276 eor_send_af_count
? ", " : "",
14277 get_afi_safi_str(afi
, safi
,
14279 eor_send_af_count
++;
14282 vty_out(vty
, "\n");
14283 vty_out(vty
, " End-of-RIB received: ");
14284 FOREACH_AFI_SAFI (afi
, safi
) {
14285 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14286 PEER_STATUS_EOR_RECEIVED
)) {
14287 vty_out(vty
, "%s%s",
14288 eor_receive_af_count
? ", "
14290 get_afi_safi_str(afi
, safi
,
14292 eor_receive_af_count
++;
14295 vty_out(vty
, "\n");
14298 if (p
->t_gr_restart
)
14300 " The remaining time of restart timer is %ld\n",
14301 thread_timer_remain_second(p
->t_gr_restart
));
14305 " The remaining time of stalepath timer is %ld\n",
14306 thread_timer_remain_second(p
->t_gr_stale
));
14308 /* more gr info in new format */
14309 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14313 json_object
*json_stat
= NULL
;
14314 json_stat
= json_object_new_object();
14315 /* Packet counts. */
14317 atomic_size_t outq_count
, inq_count
;
14318 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14319 memory_order_relaxed
);
14320 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14321 memory_order_relaxed
);
14323 json_object_int_add(json_stat
, "depthInq",
14324 (unsigned long)inq_count
);
14325 json_object_int_add(json_stat
, "depthOutq",
14326 (unsigned long)outq_count
);
14327 json_object_int_add(json_stat
, "opensSent",
14328 atomic_load_explicit(&p
->open_out
,
14329 memory_order_relaxed
));
14330 json_object_int_add(json_stat
, "opensRecv",
14331 atomic_load_explicit(&p
->open_in
,
14332 memory_order_relaxed
));
14333 json_object_int_add(json_stat
, "notificationsSent",
14334 atomic_load_explicit(&p
->notify_out
,
14335 memory_order_relaxed
));
14336 json_object_int_add(json_stat
, "notificationsRecv",
14337 atomic_load_explicit(&p
->notify_in
,
14338 memory_order_relaxed
));
14339 json_object_int_add(json_stat
, "updatesSent",
14340 atomic_load_explicit(&p
->update_out
,
14341 memory_order_relaxed
));
14342 json_object_int_add(json_stat
, "updatesRecv",
14343 atomic_load_explicit(&p
->update_in
,
14344 memory_order_relaxed
));
14345 json_object_int_add(json_stat
, "keepalivesSent",
14346 atomic_load_explicit(&p
->keepalive_out
,
14347 memory_order_relaxed
));
14348 json_object_int_add(json_stat
, "keepalivesRecv",
14349 atomic_load_explicit(&p
->keepalive_in
,
14350 memory_order_relaxed
));
14351 json_object_int_add(json_stat
, "routeRefreshSent",
14352 atomic_load_explicit(&p
->refresh_out
,
14353 memory_order_relaxed
));
14354 json_object_int_add(json_stat
, "routeRefreshRecv",
14355 atomic_load_explicit(&p
->refresh_in
,
14356 memory_order_relaxed
));
14357 json_object_int_add(json_stat
, "capabilitySent",
14358 atomic_load_explicit(&p
->dynamic_cap_out
,
14359 memory_order_relaxed
));
14360 json_object_int_add(json_stat
, "capabilityRecv",
14361 atomic_load_explicit(&p
->dynamic_cap_in
,
14362 memory_order_relaxed
));
14363 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14364 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14365 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14367 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14368 notify_out
, notify_in
, update_out
, update_in
,
14369 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14370 dynamic_cap_out
, dynamic_cap_in
;
14371 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14372 memory_order_relaxed
);
14373 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14374 memory_order_relaxed
);
14375 open_out
= atomic_load_explicit(&p
->open_out
,
14376 memory_order_relaxed
);
14378 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14379 notify_out
= atomic_load_explicit(&p
->notify_out
,
14380 memory_order_relaxed
);
14381 notify_in
= atomic_load_explicit(&p
->notify_in
,
14382 memory_order_relaxed
);
14383 update_out
= atomic_load_explicit(&p
->update_out
,
14384 memory_order_relaxed
);
14385 update_in
= atomic_load_explicit(&p
->update_in
,
14386 memory_order_relaxed
);
14387 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14388 memory_order_relaxed
);
14389 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14390 memory_order_relaxed
);
14391 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14392 memory_order_relaxed
);
14393 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14394 memory_order_relaxed
);
14395 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14396 memory_order_relaxed
);
14397 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14398 memory_order_relaxed
);
14400 /* Packet counts. */
14401 vty_out(vty
, " Message statistics:\n");
14402 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14403 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14404 vty_out(vty
, " Sent Rcvd\n");
14405 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14407 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14409 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14411 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14413 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14415 vty_out(vty
, " Capability: %10zu %10zu\n",
14416 dynamic_cap_out
, dynamic_cap_in
);
14417 vty_out(vty
, " Total: %10u %10u\n",
14418 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14422 /* advertisement-interval */
14423 json_object_int_add(json_neigh
,
14424 "minBtwnAdvertisementRunsTimerMsecs",
14425 p
->v_routeadv
* 1000);
14427 /* Update-source. */
14428 if (p
->update_if
|| p
->update_source
) {
14430 json_object_string_add(json_neigh
,
14433 else if (p
->update_source
)
14434 json_object_string_addf(json_neigh
,
14435 "updateSource", "%pSU",
14439 /* advertisement-interval */
14441 " Minimum time between advertisement runs is %d seconds\n",
14444 /* Update-source. */
14445 if (p
->update_if
|| p
->update_source
) {
14446 vty_out(vty
, " Update source is ");
14448 vty_out(vty
, "%s", p
->update_if
);
14449 else if (p
->update_source
)
14450 vty_out(vty
, "%pSU", p
->update_source
);
14451 vty_out(vty
, "\n");
14454 vty_out(vty
, "\n");
14457 /* Address Family Information */
14458 json_object
*json_hold
= NULL
;
14461 json_hold
= json_object_new_object();
14463 FOREACH_AFI_SAFI (afi
, safi
)
14464 if (p
->afc
[afi
][safi
])
14465 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14469 json_object_object_add(json_neigh
, "addressFamilyInfo",
14471 json_object_int_add(json_neigh
, "connectionsEstablished",
14473 json_object_int_add(json_neigh
, "connectionsDropped",
14476 vty_out(vty
, " Connections established %d; dropped %d\n",
14477 p
->established
, p
->dropped
);
14479 if (!p
->last_reset
) {
14481 json_object_string_add(json_neigh
, "lastReset",
14484 vty_out(vty
, " Last reset never\n");
14490 uptime
= monotime(NULL
);
14491 uptime
-= p
->resettime
;
14492 gmtime_r(&uptime
, &tm
);
14494 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14496 + (tm
.tm_min
* 60000)
14497 + (tm
.tm_hour
* 3600000));
14498 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14500 vty_out(vty
, " Last reset %s, ",
14501 peer_uptime(p
->resettime
, timebuf
,
14502 BGP_UPTIME_LEN
, 0, NULL
));
14504 bgp_show_peer_reset(vty
, p
, NULL
, false);
14505 if (p
->last_reset_cause_size
) {
14506 msg
= p
->last_reset_cause
;
14508 " Message received that caused BGP to send a NOTIFICATION:\n ");
14509 for (i
= 1; i
<= p
->last_reset_cause_size
;
14511 vty_out(vty
, "%02X", *msg
++);
14513 if (i
!= p
->last_reset_cause_size
) {
14515 vty_out(vty
, "\n ");
14516 } else if (i
% 4 == 0) {
14521 vty_out(vty
, "\n");
14526 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14528 json_object_boolean_true_add(json_neigh
,
14529 "prefixesConfigExceedMax");
14532 " Peer had exceeded the max. no. of prefixes configured.\n");
14534 if (p
->t_pmax_restart
) {
14536 json_object_boolean_true_add(
14537 json_neigh
, "reducePrefixNumFrom");
14538 json_object_int_add(json_neigh
,
14539 "restartInTimerMsec",
14540 thread_timer_remain_second(
14545 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14546 p
->host
, thread_timer_remain_second(
14547 p
->t_pmax_restart
));
14550 json_object_boolean_true_add(
14552 "reducePrefixNumAndClearIpBgp");
14555 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14560 /* EBGP Multihop and GTSM */
14561 if (p
->sort
!= BGP_PEER_IBGP
) {
14563 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14564 json_object_int_add(json_neigh
,
14565 "externalBgpNbrMaxHopsAway",
14568 json_object_int_add(json_neigh
,
14569 "externalBgpNbrMaxHopsAway",
14572 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14574 " External BGP neighbor may be up to %d hops away.\n",
14578 " External BGP neighbor may be up to %d hops away.\n",
14583 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14584 json_object_int_add(json_neigh
,
14585 "internalBgpNbrMaxHopsAway",
14588 json_object_int_add(json_neigh
,
14589 "internalBgpNbrMaxHopsAway",
14592 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14594 " Internal BGP neighbor may be up to %d hops away.\n",
14598 " Internal BGP neighbor may be up to %d hops away.\n",
14603 /* Local address. */
14606 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14608 json_object_int_add(json_neigh
, "portLocal",
14609 ntohs(p
->su_local
->sin
.sin_port
));
14611 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14612 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14615 json_object_string_add(json_neigh
, "hostLocal",
14617 json_object_int_add(json_neigh
, "portLocal", -1);
14621 /* Remote address. */
14622 if (p
->su_remote
) {
14624 json_object_string_addf(json_neigh
, "hostForeign",
14625 "%pSU", p
->su_remote
);
14626 json_object_int_add(json_neigh
, "portForeign",
14627 ntohs(p
->su_remote
->sin
.sin_port
));
14629 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14631 ntohs(p
->su_remote
->sin
.sin_port
));
14634 json_object_string_add(json_neigh
, "hostForeign",
14636 json_object_int_add(json_neigh
, "portForeign", -1);
14640 /* Nexthop display. */
14643 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14645 json_object_string_addf(json_neigh
, "nexthopGlobal",
14646 "%pI6", &p
->nexthop
.v6_global
);
14647 json_object_string_addf(json_neigh
, "nexthopLocal",
14648 "%pI6", &p
->nexthop
.v6_local
);
14649 if (p
->shared_network
)
14650 json_object_string_add(json_neigh
,
14654 json_object_string_add(json_neigh
,
14656 "nonSharedNetwork");
14658 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14659 vty_out(vty
, "Nexthop global: %pI6\n",
14660 &p
->nexthop
.v6_global
);
14661 vty_out(vty
, "Nexthop local: %pI6\n",
14662 &p
->nexthop
.v6_local
);
14663 vty_out(vty
, "BGP connection: %s\n",
14664 p
->shared_network
? "shared network"
14665 : "non shared network");
14669 json_object_string_add(json_neigh
, "nexthop",
14671 json_object_string_add(json_neigh
, "nexthopGlobal",
14673 json_object_string_add(json_neigh
, "nexthopLocal",
14675 json_object_string_add(json_neigh
, "bgpConnection",
14680 /* Timer information. */
14682 json_object_int_add(json_neigh
, "connectRetryTimer",
14684 if (peer_established(p
)) {
14685 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14687 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14688 json_object_int_add(json_neigh
,
14689 "shutdownRttInMsecs",
14691 json_object_int_add(json_neigh
,
14692 "shutdownRttAfterCount",
14693 p
->rtt_keepalive_rcv
);
14697 json_object_int_add(
14698 json_neigh
, "nextStartTimerDueInMsecs",
14699 thread_timer_remain_second(p
->t_start
) * 1000);
14701 json_object_int_add(
14702 json_neigh
, "nextConnectTimerDueInMsecs",
14703 thread_timer_remain_second(p
->t_connect
)
14705 if (p
->t_routeadv
) {
14706 json_object_int_add(json_neigh
, "mraiInterval",
14708 json_object_int_add(
14709 json_neigh
, "mraiTimerExpireInMsecs",
14710 thread_timer_remain_second(p
->t_routeadv
)
14714 json_object_int_add(json_neigh
, "authenticationEnabled",
14718 json_object_string_add(json_neigh
, "readThread", "on");
14720 json_object_string_add(json_neigh
, "readThread", "off");
14722 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14723 json_object_string_add(json_neigh
, "writeThread", "on");
14725 json_object_string_add(json_neigh
, "writeThread",
14728 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14730 if (peer_established(p
)) {
14731 vty_out(vty
, "Estimated round trip time: %d ms\n",
14733 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14735 "Shutdown when RTT > %dms, count > %u\n",
14736 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14739 vty_out(vty
, "Next start timer due in %ld seconds\n",
14740 thread_timer_remain_second(p
->t_start
));
14742 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14743 thread_timer_remain_second(p
->t_connect
));
14746 "MRAI (interval %u) timer expires in %ld seconds\n",
14748 thread_timer_remain_second(p
->t_routeadv
));
14750 vty_out(vty
, "Peer Authentication Enabled\n");
14752 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14753 p
->t_read
? "on" : "off",
14754 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14759 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14760 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14761 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14764 vty_out(vty
, "\n");
14766 /* BFD information. */
14768 bgp_bfd_show_info(vty
, p
, json_neigh
);
14771 if (p
->conf_if
) /* Configured interface name. */
14772 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14773 else /* Configured IP address. */
14774 json_object_object_add(json
, p
->host
, json_neigh
);
14778 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14779 enum show_type type
,
14780 union sockunion
*su
,
14781 const char *conf_if
, afi_t afi
,
14784 struct listnode
*node
, *nnode
;
14786 bool found
= false;
14787 safi_t safi
= SAFI_UNICAST
;
14788 json_object
*json_neighbor
= NULL
;
14790 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14792 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14795 if ((peer
->afc
[afi
][safi
]) == 0)
14799 json_neighbor
= json_object_new_object();
14801 if (type
== show_all
) {
14802 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14805 json_object_object_add(json
, peer
->host
,
14808 } else if (type
== show_peer
) {
14811 && !strcmp(peer
->conf_if
, conf_if
))
14813 && !strcmp(peer
->hostname
, conf_if
))) {
14815 bgp_show_peer_gr_status(vty
, peer
,
14819 if (sockunion_same(&peer
->su
, su
)) {
14821 bgp_show_peer_gr_status(vty
, peer
,
14827 json_object_object_add(json
, peer
->host
,
14830 json_object_free(json_neighbor
);
14838 if (type
== show_peer
&& !found
) {
14840 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14842 vty_out(vty
, "%% No such neighbor\n");
14846 vty_out(vty
, "\n");
14848 return CMD_SUCCESS
;
14851 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14852 enum show_type type
, union sockunion
*su
,
14853 const char *conf_if
, bool use_json
,
14856 struct listnode
*node
, *nnode
;
14859 bool nbr_output
= false;
14860 afi_t afi
= AFI_MAX
;
14861 safi_t safi
= SAFI_MAX
;
14863 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14865 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14869 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14870 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14875 bgp_show_peer(vty
, peer
, use_json
, json
);
14881 && !strcmp(peer
->conf_if
, conf_if
))
14883 && !strcmp(peer
->hostname
, conf_if
))) {
14885 bgp_show_peer(vty
, peer
, use_json
,
14889 if (sockunion_same(&peer
->su
, su
)) {
14891 bgp_show_peer(vty
, peer
, use_json
,
14896 case show_ipv4_peer
:
14897 case show_ipv6_peer
:
14898 FOREACH_SAFI (safi
) {
14899 if (peer
->afc
[afi
][safi
]) {
14902 && !strcmp(peer
->conf_if
, conf_if
))
14904 && !strcmp(peer
->hostname
, conf_if
))) {
14906 bgp_show_peer(vty
, peer
, use_json
,
14911 if (sockunion_same(&peer
->su
, su
)) {
14913 bgp_show_peer(vty
, peer
, use_json
,
14921 case show_ipv4_all
:
14922 case show_ipv6_all
:
14923 FOREACH_SAFI (safi
) {
14924 if (peer
->afc
[afi
][safi
]) {
14925 bgp_show_peer(vty
, peer
, use_json
, json
);
14934 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14935 type
== show_ipv6_peer
) && !find
) {
14937 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14939 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14942 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14943 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14944 vty_out(vty
, "%% No BGP neighbors found\n");
14947 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14948 json
, JSON_C_TO_STRING_PRETTY
));
14950 vty_out(vty
, "\n");
14953 return CMD_SUCCESS
;
14956 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14957 enum show_type type
,
14958 const char *ip_str
,
14959 afi_t afi
, json_object
*json
)
14964 union sockunion su
;
14966 bgp
= bgp_get_default();
14972 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
14975 ret
= str2sockunion(ip_str
, &su
);
14977 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
14978 ip_str
, afi
, json
);
14980 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14983 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14987 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14988 enum show_type type
,
14989 const char *ip_str
,
14992 struct listnode
*node
, *nnode
;
14994 union sockunion su
;
14995 json_object
*json
= NULL
;
14996 int ret
, is_first
= 1;
14997 bool nbr_output
= false;
15000 vty_out(vty
, "{\n");
15002 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15005 if (!(json
= json_object_new_object())) {
15007 EC_BGP_JSON_MEM_ERROR
,
15008 "Unable to allocate memory for JSON object");
15010 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15014 json_object_int_add(json
, "vrfId",
15015 (bgp
->vrf_id
== VRF_UNKNOWN
)
15017 : (int64_t)bgp
->vrf_id
);
15018 json_object_string_add(
15020 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15025 vty_out(vty
, ",\n");
15029 vty_out(vty
, "\"%s\":",
15030 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15034 vty_out(vty
, "\nInstance %s:\n",
15035 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15040 if (type
== show_peer
|| type
== show_ipv4_peer
||
15041 type
== show_ipv6_peer
) {
15042 ret
= str2sockunion(ip_str
, &su
);
15044 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15047 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15050 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15053 json_object_free(json
);
15058 vty_out(vty
, "}\n");
15059 else if (!nbr_output
)
15060 vty_out(vty
, "%% BGP instance not found\n");
15063 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15064 enum show_type type
, const char *ip_str
,
15069 union sockunion su
;
15070 json_object
*json
= NULL
;
15073 if (strmatch(name
, "all")) {
15074 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15076 return CMD_SUCCESS
;
15078 bgp
= bgp_lookup_by_name(name
);
15081 json
= json_object_new_object();
15082 vty_json(vty
, json
);
15085 "%% BGP instance not found\n");
15087 return CMD_WARNING
;
15091 bgp
= bgp_get_default();
15095 json
= json_object_new_object();
15097 ret
= str2sockunion(ip_str
, &su
);
15099 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15102 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15105 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15108 json_object_free(json
);
15111 vty_out(vty
, "{}\n");
15113 vty_out(vty
, "%% BGP instance not found\n");
15116 return CMD_SUCCESS
;
15121 /* "show [ip] bgp neighbors graceful-restart" commands. */
15122 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15123 show_ip_bgp_neighbors_graceful_restart_cmd
,
15124 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15130 "Neighbor to display information about\n"
15131 "Neighbor to display information about\n"
15132 "Neighbor on BGP configured interface\n"
15136 char *sh_arg
= NULL
;
15137 enum show_type sh_type
;
15139 afi_t afi
= AFI_MAX
;
15140 bool uj
= use_json(argc
, argv
);
15142 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15147 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15148 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15149 || argv_find(argv
, argc
, "WORD", &idx
)) {
15150 sh_type
= show_peer
;
15151 sh_arg
= argv
[idx
]->arg
;
15153 sh_type
= show_all
;
15155 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15156 return CMD_SUCCESS
;
15159 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15163 /* "show [ip] bgp neighbors" commands. */
15164 DEFUN (show_ip_bgp_neighbors
,
15165 show_ip_bgp_neighbors_cmd
,
15166 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15170 BGP_INSTANCE_HELP_STR
15173 "Detailed information on TCP and BGP neighbor connections\n"
15174 "Neighbor to display information about\n"
15175 "Neighbor to display information about\n"
15176 "Neighbor on BGP configured interface\n"
15180 char *sh_arg
= NULL
;
15181 enum show_type sh_type
;
15182 afi_t afi
= AFI_MAX
;
15184 bool uj
= use_json(argc
, argv
);
15188 /* [<vrf> VIEWVRFNAME] */
15189 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15190 vrf
= argv
[idx
+ 1]->arg
;
15191 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15193 } else if (argv_find(argv
, argc
, "view", &idx
))
15194 /* [<view> VIEWVRFNAME] */
15195 vrf
= argv
[idx
+ 1]->arg
;
15199 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15200 sh_type
= show_ipv4_all
;
15202 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15203 sh_type
= show_ipv6_all
;
15206 sh_type
= show_all
;
15209 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15210 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15211 || argv_find(argv
, argc
, "WORD", &idx
)) {
15212 sh_type
= show_peer
;
15213 sh_arg
= argv
[idx
]->arg
;
15216 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15217 sh_type
= show_ipv4_peer
;
15218 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15219 sh_type
= show_ipv6_peer
;
15222 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15225 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15226 paths' and `show ip mbgp paths'. Those functions results are the
15228 DEFUN (show_ip_bgp_paths
,
15229 show_ip_bgp_paths_cmd
,
15230 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15235 "Path information\n")
15237 vty_out(vty
, "Address Refcnt Path\n");
15238 aspath_print_all_vty(vty
);
15239 return CMD_SUCCESS
;
15244 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15247 struct community
*com
;
15249 com
= (struct community
*)bucket
->data
;
15250 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15251 community_str(com
, false, false));
15254 /* Show BGP's community internal data. */
15255 DEFUN (show_ip_bgp_community_info
,
15256 show_ip_bgp_community_info_cmd
,
15257 "show [ip] bgp community-info",
15261 "List all bgp community information\n")
15263 vty_out(vty
, "Address Refcnt Community\n");
15265 hash_iterate(community_hash(),
15266 (void (*)(struct hash_bucket
*,
15267 void *))community_show_all_iterator
,
15270 return CMD_SUCCESS
;
15273 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15276 struct lcommunity
*lcom
;
15278 lcom
= (struct lcommunity
*)bucket
->data
;
15279 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15280 lcommunity_str(lcom
, false, false));
15283 /* Show BGP's community internal data. */
15284 DEFUN (show_ip_bgp_lcommunity_info
,
15285 show_ip_bgp_lcommunity_info_cmd
,
15286 "show ip bgp large-community-info",
15290 "List all bgp large-community information\n")
15292 vty_out(vty
, "Address Refcnt Large-community\n");
15294 hash_iterate(lcommunity_hash(),
15295 (void (*)(struct hash_bucket
*,
15296 void *))lcommunity_show_all_iterator
,
15299 return CMD_SUCCESS
;
15301 /* Graceful Restart */
15303 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15308 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15310 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15312 switch (bgp_global_gr_mode
) {
15314 case GLOBAL_HELPER
:
15315 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15319 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15322 case GLOBAL_DISABLE
:
15323 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15326 case GLOBAL_INVALID
:
15328 "Global BGP GR Mode Invalid\n");
15331 vty_out(vty
, "\n");
15334 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15335 enum show_type type
,
15336 const char *ip_str
,
15337 afi_t afi
, bool use_json
)
15339 json_object
*json
= NULL
;
15342 json
= json_object_new_object();
15344 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15347 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15349 bgp_show_neighbor_graceful_restart_vty(
15350 vty
, type
, ip_str
, afi
, json
);
15353 } else if (afi
!= AFI_MAX
) {
15354 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15358 json_object_free(json
);
15359 return CMD_ERR_INCOMPLETE
;
15363 vty_json(vty
, json
);
15365 return CMD_SUCCESS
;
15367 /* Graceful Restart */
15369 DEFUN (show_ip_bgp_attr_info
,
15370 show_ip_bgp_attr_info_cmd
,
15371 "show [ip] bgp attribute-info",
15375 "List all bgp attribute information\n")
15377 attr_show_all(vty
);
15378 return CMD_SUCCESS
;
15381 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15382 afi_t afi
, safi_t safi
,
15383 bool use_json
, json_object
*json
)
15386 struct listnode
*node
;
15389 enum vpn_policy_direction dir
;
15392 json_object
*json_import_vrfs
= NULL
;
15393 json_object
*json_export_vrfs
= NULL
;
15395 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15398 vty_json(vty
, json
);
15400 return CMD_WARNING
;
15403 /* Provide context for the block */
15404 json_object_string_add(json
, "vrf", name
? name
: "default");
15405 json_object_string_add(json
, "afiSafi",
15406 get_afi_safi_str(afi
, safi
, true));
15408 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15409 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15410 json_object_string_add(json
, "importFromVrfs", "none");
15411 json_object_string_add(json
, "importRts", "none");
15413 json_import_vrfs
= json_object_new_array();
15415 for (ALL_LIST_ELEMENTS_RO(
15416 bgp
->vpn_policy
[afi
].import_vrf
,
15418 json_object_array_add(json_import_vrfs
,
15419 json_object_new_string(vname
));
15421 json_object_object_add(json
, "importFromVrfs",
15423 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15424 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15425 ecom_str
= ecommunity_ecom2str(
15426 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15427 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15428 json_object_string_add(json
, "importRts",
15430 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15432 json_object_string_add(json
, "importRts",
15436 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15437 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15438 json_object_string_add(json
, "exportToVrfs", "none");
15439 json_object_string_add(json
, "routeDistinguisher",
15441 json_object_string_add(json
, "exportRts", "none");
15443 json_export_vrfs
= json_object_new_array();
15445 for (ALL_LIST_ELEMENTS_RO(
15446 bgp
->vpn_policy
[afi
].export_vrf
,
15448 json_object_array_add(json_export_vrfs
,
15449 json_object_new_string(vname
));
15450 json_object_object_add(json
, "exportToVrfs",
15452 json_object_string_addf(json
, "routeDistinguisher",
15454 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15456 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15457 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15458 ecom_str
= ecommunity_ecom2str(
15459 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15460 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15461 json_object_string_add(json
, "exportRts",
15463 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15465 json_object_string_add(json
, "exportRts",
15470 vty_json(vty
, json
);
15473 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15476 vty_out(vty
, "%% No such BGP instance exist\n");
15477 return CMD_WARNING
;
15480 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15481 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15483 "This VRF is not importing %s routes from any other VRF\n",
15484 get_afi_safi_str(afi
, safi
, false));
15487 "This VRF is importing %s routes from the following VRFs:\n",
15488 get_afi_safi_str(afi
, safi
, false));
15490 for (ALL_LIST_ELEMENTS_RO(
15491 bgp
->vpn_policy
[afi
].import_vrf
,
15493 vty_out(vty
, " %s\n", vname
);
15495 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15497 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15498 ecom_str
= ecommunity_ecom2str(
15499 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15500 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15501 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15503 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15505 vty_out(vty
, "Import RT(s):\n");
15508 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15509 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15511 "This VRF is not exporting %s routes to any other VRF\n",
15512 get_afi_safi_str(afi
, safi
, false));
15515 "This VRF is exporting %s routes to the following VRFs:\n",
15516 get_afi_safi_str(afi
, safi
, false));
15518 for (ALL_LIST_ELEMENTS_RO(
15519 bgp
->vpn_policy
[afi
].export_vrf
,
15521 vty_out(vty
, " %s\n", vname
);
15523 vty_out(vty
, "RD: %pRD\n",
15524 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15526 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15527 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15528 ecom_str
= ecommunity_ecom2str(
15529 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15530 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15531 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15532 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15534 vty_out(vty
, "Import RT(s):\n");
15538 return CMD_SUCCESS
;
15541 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15542 safi_t safi
, bool use_json
)
15544 struct listnode
*node
, *nnode
;
15546 char *vrf_name
= NULL
;
15547 json_object
*json
= NULL
;
15548 json_object
*json_vrf
= NULL
;
15549 json_object
*json_vrfs
= NULL
;
15552 json
= json_object_new_object();
15553 json_vrfs
= json_object_new_object();
15556 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15558 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15559 vrf_name
= bgp
->name
;
15562 json_vrf
= json_object_new_object();
15564 vty_out(vty
, "\nInstance %s:\n",
15565 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15566 ? VRF_DEFAULT_NAME
: bgp
->name
);
15568 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15570 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15571 json_object_object_add(json_vrfs
,
15572 VRF_DEFAULT_NAME
, json_vrf
);
15574 json_object_object_add(json_vrfs
, vrf_name
,
15580 json_object_object_add(json
, "vrfs", json_vrfs
);
15581 vty_json(vty
, json
);
15584 return CMD_SUCCESS
;
15587 /* "show [ip] bgp route-leak" command. */
15588 DEFUN (show_ip_bgp_route_leak
,
15589 show_ip_bgp_route_leak_cmd
,
15590 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15594 BGP_INSTANCE_HELP_STR
15597 "Route leaking information\n"
15601 afi_t afi
= AFI_MAX
;
15602 safi_t safi
= SAFI_MAX
;
15604 bool uj
= use_json(argc
, argv
);
15606 json_object
*json
= NULL
;
15608 /* show [ip] bgp */
15609 if (argv_find(argv
, argc
, "ip", &idx
)) {
15611 safi
= SAFI_UNICAST
;
15613 /* [vrf VIEWVRFNAME] */
15614 if (argv_find(argv
, argc
, "view", &idx
)) {
15616 "%% This command is not applicable to BGP views\n");
15617 return CMD_WARNING
;
15620 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15621 vrf
= argv
[idx
+ 1]->arg
;
15622 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15625 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15626 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15627 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15629 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15631 "%% This command is applicable only for unicast ipv4|ipv6\n");
15632 return CMD_WARNING
;
15635 if (vrf
&& strmatch(vrf
, "all"))
15636 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15639 json
= json_object_new_object();
15641 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15644 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15645 safi_t safi
, bool uj
)
15647 struct listnode
*node
, *nnode
;
15650 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15652 vty_out(vty
, "\nInstance %s:\n",
15653 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15657 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15661 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15662 int safi
, uint64_t subgrp_id
, bool uj
)
15667 if (strmatch(name
, "all")) {
15668 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15669 return CMD_SUCCESS
;
15671 bgp
= bgp_lookup_by_name(name
);
15674 bgp
= bgp_get_default();
15678 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15679 return CMD_SUCCESS
;
15682 DEFUN (show_ip_bgp_updgrps
,
15683 show_ip_bgp_updgrps_cmd
,
15684 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15688 BGP_INSTANCE_HELP_STR
15690 BGP_SAFI_WITH_LABEL_HELP_STR
15691 "Detailed info about dynamic update groups\n"
15692 "Specific subgroup to display detailed info for\n"
15696 afi_t afi
= AFI_IP6
;
15697 safi_t safi
= SAFI_UNICAST
;
15698 uint64_t subgrp_id
= 0;
15702 bool uj
= use_json(argc
, argv
);
15704 /* show [ip] bgp */
15705 if (argv_find(argv
, argc
, "ip", &idx
))
15707 /* [<vrf> VIEWVRFNAME] */
15708 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15709 vrf
= argv
[idx
+ 1]->arg
;
15710 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15712 } else if (argv_find(argv
, argc
, "view", &idx
))
15713 /* [<view> VIEWVRFNAME] */
15714 vrf
= argv
[idx
+ 1]->arg
;
15715 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15716 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15717 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15720 /* get subgroup id, if provided */
15722 if (argv
[idx
]->type
== VARIABLE_TKN
)
15723 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15725 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15728 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15729 show_bgp_instance_all_ipv6_updgrps_cmd
,
15730 "show [ip] bgp <view|vrf> all update-groups [json]",
15734 BGP_INSTANCE_ALL_HELP_STR
15735 "Detailed info about dynamic update groups\n"
15738 bool uj
= use_json(argc
, argv
);
15740 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15741 return CMD_SUCCESS
;
15744 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15745 show_bgp_l2vpn_evpn_updgrps_cmd
,
15746 "show [ip] bgp l2vpn evpn update-groups",
15750 "l2vpn address family\n"
15751 "evpn sub-address family\n"
15752 "Detailed info about dynamic update groups\n")
15755 uint64_t subgrp_id
= 0;
15757 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15758 return CMD_SUCCESS
;
15761 DEFUN (show_bgp_updgrps_stats
,
15762 show_bgp_updgrps_stats_cmd
,
15763 "show [ip] bgp update-groups statistics",
15767 "Detailed info about dynamic update groups\n"
15772 bgp
= bgp_get_default();
15774 update_group_show_stats(bgp
, vty
);
15776 return CMD_SUCCESS
;
15779 DEFUN (show_bgp_instance_updgrps_stats
,
15780 show_bgp_instance_updgrps_stats_cmd
,
15781 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15785 BGP_INSTANCE_HELP_STR
15786 "Detailed info about dynamic update groups\n"
15792 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15794 update_group_show_stats(bgp
, vty
);
15796 return CMD_SUCCESS
;
15799 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15800 afi_t afi
, safi_t safi
,
15801 const char *what
, uint64_t subgrp_id
)
15806 bgp
= bgp_lookup_by_name(name
);
15808 bgp
= bgp_get_default();
15811 if (!strcmp(what
, "advertise-queue"))
15812 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15814 else if (!strcmp(what
, "advertised-routes"))
15815 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15817 else if (!strcmp(what
, "packet-queue"))
15818 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15823 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15824 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15825 "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",
15826 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15828 "Detailed info about dynamic update groups\n"
15829 "Specific subgroup to display info for\n"
15830 "Advertisement queue\n"
15831 "Announced routes\n"
15834 uint64_t subgrp_id
= 0;
15838 subgrp_id
= strtoull(sgid
, NULL
, 10);
15843 afiz
= bgp_vty_afi_from_str(afi
);
15847 afiz
= bgp_vty_afi_from_str(afi
);
15848 if (afiz
!= AFI_IP
)
15850 "%% Cannot specify both 'ip' and 'ipv6'\n");
15851 return CMD_WARNING
;
15854 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15856 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15857 return CMD_SUCCESS
;
15860 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15863 struct listnode
*node
, *nnode
;
15864 struct prefix
*range
;
15869 const char *peer_status
;
15873 json_object
*json_peer_group
= NULL
;
15874 json_object
*json_peer_group_afc
= NULL
;
15875 json_object
*json_peer_group_members
= NULL
;
15876 json_object
*json_peer_group_dynamic
= NULL
;
15877 json_object
*json_peer_group_dynamic_af
= NULL
;
15878 json_object
*json_peer_group_ranges
= NULL
;
15880 conf
= group
->conf
;
15883 json_peer_group
= json_object_new_object();
15884 json_peer_group_afc
= json_object_new_array();
15887 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15889 json_object_int_add(json_peer_group
, "remoteAs",
15892 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15893 group
->name
, conf
->as
);
15894 } else if (conf
->as_type
== AS_INTERNAL
) {
15896 json_object_int_add(json_peer_group
, "remoteAs",
15899 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15900 group
->name
, group
->bgp
->as
);
15903 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15906 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15908 json_object_string_add(json_peer_group
, "type",
15911 vty_out(vty
, " Peer-group type is internal\n");
15914 json_object_string_add(json_peer_group
, "type",
15917 vty_out(vty
, " Peer-group type is external\n");
15920 /* Display AFs configured. */
15922 vty_out(vty
, " Configured address-families:");
15924 FOREACH_AFI_SAFI (afi
, safi
) {
15925 if (conf
->afc
[afi
][safi
]) {
15928 json_object_array_add(
15929 json_peer_group_afc
,
15930 json_object_new_string(get_afi_safi_str(
15931 afi
, safi
, false)));
15933 vty_out(vty
, " %s;",
15934 get_afi_safi_str(afi
, safi
, false));
15939 json_object_object_add(json_peer_group
,
15940 "addressFamiliesConfigured",
15941 json_peer_group_afc
);
15944 vty_out(vty
, " none\n");
15946 vty_out(vty
, "\n");
15949 /* Display listen ranges (for dynamic neighbors), if any */
15950 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15951 lr_count
= listcount(group
->listen_range
[afi
]);
15954 if (!json_peer_group_dynamic
)
15955 json_peer_group_dynamic
=
15956 json_object_new_object();
15958 json_peer_group_dynamic_af
=
15959 json_object_new_object();
15960 json_peer_group_ranges
=
15961 json_object_new_array();
15962 json_object_int_add(json_peer_group_dynamic_af
,
15963 "count", lr_count
);
15965 vty_out(vty
, " %d %s listen range(s)\n",
15966 lr_count
, afi2str(afi
));
15969 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15974 snprintfrr(buf
, sizeof(buf
), "%pFX",
15977 json_object_array_add(
15978 json_peer_group_ranges
,
15979 json_object_new_string(buf
));
15981 vty_out(vty
, " %pFX\n", range
);
15986 json_object_object_add(
15987 json_peer_group_dynamic_af
, "ranges",
15988 json_peer_group_ranges
);
15990 json_object_object_add(
15991 json_peer_group_dynamic
, afi2str(afi
),
15992 json_peer_group_dynamic_af
);
15997 if (json_peer_group_dynamic
)
15998 json_object_object_add(json_peer_group
, "dynamicRanges",
15999 json_peer_group_dynamic
);
16001 /* Display group members and their status */
16002 if (listcount(group
->peer
)) {
16004 json_peer_group_members
= json_object_new_object();
16006 vty_out(vty
, " Peer-group members:\n");
16007 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16008 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16009 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16010 peer_status
= "Idle (Admin)";
16011 else if (CHECK_FLAG(peer
->sflags
,
16012 PEER_STATUS_PREFIX_OVERFLOW
))
16013 peer_status
= "Idle (PfxCt)";
16015 peer_status
= lookup_msg(bgp_status_msg
,
16016 peer
->status
, NULL
);
16018 dynamic
= peer_dynamic_neighbor(peer
);
16021 json_object
*json_peer_group_member
=
16022 json_object_new_object();
16024 json_object_string_add(json_peer_group_member
,
16025 "status", peer_status
);
16028 json_object_boolean_true_add(
16029 json_peer_group_member
,
16032 json_object_object_add(json_peer_group_members
,
16034 json_peer_group_member
);
16036 vty_out(vty
, " %s %s %s \n", peer
->host
,
16037 dynamic
? "(dynamic)" : "",
16042 json_object_object_add(json_peer_group
, "members",
16043 json_peer_group_members
);
16047 json_object_object_add(json
, group
->name
, json_peer_group
);
16049 return CMD_SUCCESS
;
16052 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16053 const char *group_name
, bool uj
)
16056 struct listnode
*node
, *nnode
;
16057 struct peer_group
*group
;
16058 bool found
= false;
16059 json_object
*json
= NULL
;
16062 json
= json_object_new_object();
16064 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16068 vty_json(vty
, json
);
16070 vty_out(vty
, "%% BGP instance not found\n");
16072 return CMD_WARNING
;
16075 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16077 if (strmatch(group
->name
, group_name
)) {
16078 bgp_show_one_peer_group(vty
, group
, json
);
16083 bgp_show_one_peer_group(vty
, group
, json
);
16087 if (group_name
&& !found
&& !uj
)
16088 vty_out(vty
, "%% No such peer-group\n");
16091 vty_json(vty
, json
);
16093 return CMD_SUCCESS
;
16096 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16097 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16098 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16099 "Detailed information on BGP peer groups\n"
16100 "Peer group name\n" JSON_STR
)
16104 bool uj
= use_json(argc
, argv
);
16106 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16108 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16110 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16114 /* Redistribute VTY commands. */
16116 DEFUN (bgp_redistribute_ipv4
,
16117 bgp_redistribute_ipv4_cmd
,
16118 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16119 "Redistribute information from another routing protocol\n"
16120 FRR_IP_REDIST_HELP_STR_BGPD
)
16122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16123 int idx_protocol
= 1;
16126 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16128 vty_out(vty
, "%% Invalid route type\n");
16129 return CMD_WARNING_CONFIG_FAILED
;
16132 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16133 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16137 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16138 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16139 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16141 DEFUN (bgp_redistribute_ipv4_rmap
,
16142 bgp_redistribute_ipv4_rmap_cmd
,
16143 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16144 "Redistribute information from another routing protocol\n"
16145 FRR_IP_REDIST_HELP_STR_BGPD
16146 "Route map reference\n"
16147 "Pointer to route-map entries\n")
16149 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16150 int idx_protocol
= 1;
16153 struct bgp_redist
*red
;
16155 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16156 vty
, argv
[idx_word
]->arg
);
16158 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16160 vty_out(vty
, "%% Invalid route type\n");
16161 return CMD_WARNING_CONFIG_FAILED
;
16164 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16166 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16167 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16171 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16172 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16173 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16174 "Route map reference\n"
16175 "Pointer to route-map entries\n")
16177 DEFUN (bgp_redistribute_ipv4_metric
,
16178 bgp_redistribute_ipv4_metric_cmd
,
16179 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16180 "Redistribute information from another routing protocol\n"
16181 FRR_IP_REDIST_HELP_STR_BGPD
16182 "Metric for redistributed routes\n"
16183 "Default metric\n")
16185 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16186 int idx_protocol
= 1;
16187 int idx_number
= 3;
16190 struct bgp_redist
*red
;
16193 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16195 vty_out(vty
, "%% Invalid route type\n");
16196 return CMD_WARNING_CONFIG_FAILED
;
16198 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16200 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16201 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16202 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16206 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16207 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16208 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16209 "Metric for redistributed routes\n"
16210 "Default metric\n")
16212 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16213 bgp_redistribute_ipv4_rmap_metric_cmd
,
16214 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16215 "Redistribute information from another routing protocol\n"
16216 FRR_IP_REDIST_HELP_STR_BGPD
16217 "Route map reference\n"
16218 "Pointer to route-map entries\n"
16219 "Metric for redistributed routes\n"
16220 "Default metric\n")
16222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16223 int idx_protocol
= 1;
16225 int idx_number
= 5;
16228 struct bgp_redist
*red
;
16230 struct route_map
*route_map
=
16231 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16233 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16235 vty_out(vty
, "%% Invalid route type\n");
16236 return CMD_WARNING_CONFIG_FAILED
;
16238 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16240 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16242 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16243 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16244 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16248 bgp_redistribute_ipv4_rmap_metric
,
16249 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16250 "redistribute " FRR_IP_REDIST_STR_BGPD
16251 " route-map RMAP_NAME metric (0-4294967295)",
16252 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16253 "Route map reference\n"
16254 "Pointer to route-map entries\n"
16255 "Metric for redistributed routes\n"
16256 "Default metric\n")
16258 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16259 bgp_redistribute_ipv4_metric_rmap_cmd
,
16260 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16261 "Redistribute information from another routing protocol\n"
16262 FRR_IP_REDIST_HELP_STR_BGPD
16263 "Metric for redistributed routes\n"
16265 "Route map reference\n"
16266 "Pointer to route-map entries\n")
16268 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16269 int idx_protocol
= 1;
16270 int idx_number
= 3;
16274 struct bgp_redist
*red
;
16276 struct route_map
*route_map
=
16277 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16279 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16281 vty_out(vty
, "%% Invalid route type\n");
16282 return CMD_WARNING_CONFIG_FAILED
;
16284 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16286 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16287 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16289 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16290 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16294 bgp_redistribute_ipv4_metric_rmap
,
16295 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16296 "redistribute " FRR_IP_REDIST_STR_BGPD
16297 " metric (0-4294967295) route-map RMAP_NAME",
16298 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16299 "Metric for redistributed routes\n"
16301 "Route map reference\n"
16302 "Pointer to route-map entries\n")
16304 DEFUN (bgp_redistribute_ipv4_ospf
,
16305 bgp_redistribute_ipv4_ospf_cmd
,
16306 "redistribute <ospf|table> (1-65535)",
16307 "Redistribute information from another routing protocol\n"
16308 "Open Shortest Path First (OSPFv2)\n"
16309 "Non-main Kernel Routing Table\n"
16310 "Instance ID/Table ID\n")
16312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16313 int idx_ospf_table
= 1;
16314 int idx_number
= 2;
16315 unsigned short instance
;
16316 unsigned short protocol
;
16318 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16320 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16321 protocol
= ZEBRA_ROUTE_OSPF
;
16323 protocol
= ZEBRA_ROUTE_TABLE
;
16325 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16326 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16329 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16330 "redistribute <ospf|table> (1-65535)",
16331 "Redistribute information from another routing protocol\n"
16332 "Open Shortest Path First (OSPFv2)\n"
16333 "Non-main Kernel Routing Table\n"
16334 "Instance ID/Table ID\n")
16336 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16337 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16338 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16339 "Redistribute information from another routing protocol\n"
16340 "Open Shortest Path First (OSPFv2)\n"
16341 "Non-main Kernel Routing Table\n"
16342 "Instance ID/Table ID\n"
16343 "Route map reference\n"
16344 "Pointer to route-map entries\n")
16346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16347 int idx_ospf_table
= 1;
16348 int idx_number
= 2;
16350 struct bgp_redist
*red
;
16351 unsigned short instance
;
16354 struct route_map
*route_map
=
16355 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16357 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16358 protocol
= ZEBRA_ROUTE_OSPF
;
16360 protocol
= ZEBRA_ROUTE_TABLE
;
16362 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16363 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16365 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16366 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16369 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16370 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16371 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16372 "Redistribute information from another routing protocol\n"
16373 "Open Shortest Path First (OSPFv2)\n"
16374 "Non-main Kernel Routing Table\n"
16375 "Instance ID/Table ID\n"
16376 "Route map reference\n"
16377 "Pointer to route-map entries\n")
16379 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16380 bgp_redistribute_ipv4_ospf_metric_cmd
,
16381 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16382 "Redistribute information from another routing protocol\n"
16383 "Open Shortest Path First (OSPFv2)\n"
16384 "Non-main Kernel Routing Table\n"
16385 "Instance ID/Table ID\n"
16386 "Metric for redistributed routes\n"
16387 "Default metric\n")
16389 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16390 int idx_ospf_table
= 1;
16391 int idx_number
= 2;
16392 int idx_number_2
= 4;
16394 struct bgp_redist
*red
;
16395 unsigned short instance
;
16399 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16400 protocol
= ZEBRA_ROUTE_OSPF
;
16402 protocol
= ZEBRA_ROUTE_TABLE
;
16404 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16405 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16407 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16408 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16410 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16413 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16414 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16415 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16416 "Redistribute information from another routing protocol\n"
16417 "Open Shortest Path First (OSPFv2)\n"
16418 "Non-main Kernel Routing Table\n"
16419 "Instance ID/Table ID\n"
16420 "Metric for redistributed routes\n"
16421 "Default metric\n")
16423 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16424 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16425 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16426 "Redistribute information from another routing protocol\n"
16427 "Open Shortest Path First (OSPFv2)\n"
16428 "Non-main Kernel Routing Table\n"
16429 "Instance ID/Table ID\n"
16430 "Route map reference\n"
16431 "Pointer to route-map entries\n"
16432 "Metric for redistributed routes\n"
16433 "Default metric\n")
16435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16436 int idx_ospf_table
= 1;
16437 int idx_number
= 2;
16439 int idx_number_2
= 6;
16441 struct bgp_redist
*red
;
16442 unsigned short instance
;
16445 struct route_map
*route_map
=
16446 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16448 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16449 protocol
= ZEBRA_ROUTE_OSPF
;
16451 protocol
= ZEBRA_ROUTE_TABLE
;
16453 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16454 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16456 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16458 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16459 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16461 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16465 bgp_redistribute_ipv4_ospf_rmap_metric
,
16466 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16467 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16468 "Redistribute information from another routing protocol\n"
16469 "Open Shortest Path First (OSPFv2)\n"
16470 "Non-main Kernel Routing Table\n"
16471 "Instance ID/Table ID\n"
16472 "Route map reference\n"
16473 "Pointer to route-map entries\n"
16474 "Metric for redistributed routes\n"
16475 "Default metric\n")
16477 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16478 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16479 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16480 "Redistribute information from another routing protocol\n"
16481 "Open Shortest Path First (OSPFv2)\n"
16482 "Non-main Kernel Routing Table\n"
16483 "Instance ID/Table ID\n"
16484 "Metric for redistributed routes\n"
16486 "Route map reference\n"
16487 "Pointer to route-map entries\n")
16489 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16490 int idx_ospf_table
= 1;
16491 int idx_number
= 2;
16492 int idx_number_2
= 4;
16495 struct bgp_redist
*red
;
16496 unsigned short instance
;
16499 struct route_map
*route_map
=
16500 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16502 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16503 protocol
= ZEBRA_ROUTE_OSPF
;
16505 protocol
= ZEBRA_ROUTE_TABLE
;
16507 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16508 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16510 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16511 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16514 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16515 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16519 bgp_redistribute_ipv4_ospf_metric_rmap
,
16520 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16521 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16522 "Redistribute information from another routing protocol\n"
16523 "Open Shortest Path First (OSPFv2)\n"
16524 "Non-main Kernel Routing Table\n"
16525 "Instance ID/Table ID\n"
16526 "Metric for redistributed routes\n"
16528 "Route map reference\n"
16529 "Pointer to route-map entries\n")
16531 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16532 no_bgp_redistribute_ipv4_ospf_cmd
,
16533 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16535 "Redistribute information from another routing protocol\n"
16536 "Open Shortest Path First (OSPFv2)\n"
16537 "Non-main Kernel Routing Table\n"
16538 "Instance ID/Table ID\n"
16539 "Metric for redistributed routes\n"
16541 "Route map reference\n"
16542 "Pointer to route-map entries\n")
16544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16545 int idx_ospf_table
= 2;
16546 int idx_number
= 3;
16547 unsigned short instance
;
16550 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16551 protocol
= ZEBRA_ROUTE_OSPF
;
16553 protocol
= ZEBRA_ROUTE_TABLE
;
16555 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16556 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16560 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16561 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16563 "Redistribute information from another routing protocol\n"
16564 "Open Shortest Path First (OSPFv2)\n"
16565 "Non-main Kernel Routing Table\n"
16566 "Instance ID/Table ID\n"
16567 "Metric for redistributed routes\n"
16569 "Route map reference\n"
16570 "Pointer to route-map entries\n")
16572 DEFUN (no_bgp_redistribute_ipv4
,
16573 no_bgp_redistribute_ipv4_cmd
,
16574 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16576 "Redistribute information from another routing protocol\n"
16577 FRR_IP_REDIST_HELP_STR_BGPD
16578 "Metric for redistributed routes\n"
16580 "Route map reference\n"
16581 "Pointer to route-map entries\n")
16583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16584 int idx_protocol
= 2;
16587 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16589 vty_out(vty
, "%% Invalid route type\n");
16590 return CMD_WARNING_CONFIG_FAILED
;
16592 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16596 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16597 "no redistribute " FRR_IP_REDIST_STR_BGPD
16598 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16600 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16601 "Metric for redistributed routes\n"
16603 "Route map reference\n"
16604 "Pointer to route-map entries\n")
16606 DEFUN (bgp_redistribute_ipv6
,
16607 bgp_redistribute_ipv6_cmd
,
16608 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16609 "Redistribute information from another routing protocol\n"
16610 FRR_IP6_REDIST_HELP_STR_BGPD
)
16612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16613 int idx_protocol
= 1;
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 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16623 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16626 DEFUN (bgp_redistribute_ipv6_rmap
,
16627 bgp_redistribute_ipv6_rmap_cmd
,
16628 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16629 "Redistribute information from another routing protocol\n"
16630 FRR_IP6_REDIST_HELP_STR_BGPD
16631 "Route map reference\n"
16632 "Pointer to route-map entries\n")
16634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16635 int idx_protocol
= 1;
16638 struct bgp_redist
*red
;
16640 struct route_map
*route_map
=
16641 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16643 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16645 vty_out(vty
, "%% Invalid route type\n");
16646 return CMD_WARNING_CONFIG_FAILED
;
16649 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16651 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16652 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16655 DEFUN (bgp_redistribute_ipv6_metric
,
16656 bgp_redistribute_ipv6_metric_cmd
,
16657 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16658 "Redistribute information from another routing protocol\n"
16659 FRR_IP6_REDIST_HELP_STR_BGPD
16660 "Metric for redistributed routes\n"
16661 "Default metric\n")
16663 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16664 int idx_protocol
= 1;
16665 int idx_number
= 3;
16668 struct bgp_redist
*red
;
16671 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16673 vty_out(vty
, "%% Invalid route type\n");
16674 return CMD_WARNING_CONFIG_FAILED
;
16676 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16678 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16679 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16680 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16683 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16684 bgp_redistribute_ipv6_rmap_metric_cmd
,
16685 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16686 "Redistribute information from another routing protocol\n"
16687 FRR_IP6_REDIST_HELP_STR_BGPD
16688 "Route map reference\n"
16689 "Pointer to route-map entries\n"
16690 "Metric for redistributed routes\n"
16691 "Default metric\n")
16693 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16694 int idx_protocol
= 1;
16696 int idx_number
= 5;
16699 struct bgp_redist
*red
;
16701 struct route_map
*route_map
=
16702 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16704 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16706 vty_out(vty
, "%% Invalid route type\n");
16707 return CMD_WARNING_CONFIG_FAILED
;
16709 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16711 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16713 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16714 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16716 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16719 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16720 bgp_redistribute_ipv6_metric_rmap_cmd
,
16721 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16722 "Redistribute information from another routing protocol\n"
16723 FRR_IP6_REDIST_HELP_STR_BGPD
16724 "Metric for redistributed routes\n"
16726 "Route map reference\n"
16727 "Pointer to route-map entries\n")
16729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16730 int idx_protocol
= 1;
16731 int idx_number
= 3;
16735 struct bgp_redist
*red
;
16737 struct route_map
*route_map
=
16738 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16740 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16742 vty_out(vty
, "%% Invalid route type\n");
16743 return CMD_WARNING_CONFIG_FAILED
;
16745 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16747 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16748 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16751 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16752 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16755 DEFUN (no_bgp_redistribute_ipv6
,
16756 no_bgp_redistribute_ipv6_cmd
,
16757 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16759 "Redistribute information from another routing protocol\n"
16760 FRR_IP6_REDIST_HELP_STR_BGPD
16761 "Metric for redistributed routes\n"
16763 "Route map reference\n"
16764 "Pointer to route-map entries\n")
16766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16767 int idx_protocol
= 2;
16770 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16772 vty_out(vty
, "%% Invalid route type\n");
16773 return CMD_WARNING_CONFIG_FAILED
;
16776 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16779 /* Neighbor update tcp-mss. */
16780 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16781 const char *tcp_mss_str
)
16784 uint32_t tcp_mss_val
= 0;
16786 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16788 return CMD_WARNING_CONFIG_FAILED
;
16791 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16792 peer_tcp_mss_set(peer
, tcp_mss_val
);
16794 peer_tcp_mss_unset(peer
);
16797 return CMD_SUCCESS
;
16800 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16801 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16803 "TCP max segment size\n"
16806 int peer_index
= 1;
16810 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16811 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16812 argv
[mss_index
]->arg
);
16815 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16816 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16817 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16818 "TCP max segment size\n"
16821 int peer_index
= 2;
16824 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16825 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16828 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16829 "[no$no] bgp retain route-target all",
16831 "Retain BGP updates\n"
16832 "Retain BGP updates based on route-target values\n"
16833 "Retain all BGP updates\n")
16836 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16838 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16839 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16840 if (check
!= !no
) {
16842 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16843 [bgp_node_safi(vty
)],
16844 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16846 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16847 [bgp_node_safi(vty
)],
16848 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16849 /* trigger a flush to re-sync with ADJ-RIB-in */
16850 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16851 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16853 return CMD_SUCCESS
;
16856 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16857 afi_t afi
, safi_t safi
)
16861 /* Unicast redistribution only. */
16862 if (safi
!= SAFI_UNICAST
)
16865 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16866 /* Redistribute BGP does not make sense. */
16867 if (i
!= ZEBRA_ROUTE_BGP
) {
16868 struct list
*red_list
;
16869 struct listnode
*node
;
16870 struct bgp_redist
*red
;
16872 red_list
= bgp
->redist
[afi
][i
];
16876 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16877 /* "redistribute" configuration. */
16878 vty_out(vty
, " redistribute %s",
16879 zebra_route_string(i
));
16881 vty_out(vty
, " %d", red
->instance
);
16882 if (red
->redist_metric_flag
)
16883 vty_out(vty
, " metric %u",
16884 red
->redist_metric
);
16885 if (red
->rmap
.name
)
16886 vty_out(vty
, " route-map %s",
16888 vty_out(vty
, "\n");
16894 /* peer-group helpers for config-write */
16896 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16898 if (!peer_group_active(peer
)) {
16899 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16900 return !CHECK_FLAG(peer
->flags
, flag
);
16902 return !!CHECK_FLAG(peer
->flags
, flag
);
16905 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16908 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16911 if (!peer_group_active(peer
)) {
16912 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16913 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16915 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16918 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16921 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16922 uint8_t type
, int direct
)
16924 struct bgp_filter
*filter
;
16926 if (peer_group_active(peer
))
16927 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16930 filter
= &peer
->filter
[afi
][safi
];
16932 case PEER_FT_DISTRIBUTE_LIST
:
16933 return !!(filter
->dlist
[direct
].name
);
16934 case PEER_FT_FILTER_LIST
:
16935 return !!(filter
->aslist
[direct
].name
);
16936 case PEER_FT_PREFIX_LIST
:
16937 return !!(filter
->plist
[direct
].name
);
16938 case PEER_FT_ROUTE_MAP
:
16939 return !!(filter
->map
[direct
].name
);
16940 case PEER_FT_UNSUPPRESS_MAP
:
16941 return !!(filter
->usmap
.name
);
16942 case PEER_FT_ADVERTISE_MAP
:
16943 return !!(filter
->advmap
.aname
16944 && ((filter
->advmap
.condition
== direct
)
16945 && filter
->advmap
.cname
));
16951 /* Return true if the addpath type is set for peer and different from
16954 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16957 enum bgp_addpath_strat type
, g_type
;
16959 type
= peer
->addpath_type
[afi
][safi
];
16961 if (type
!= BGP_ADDPATH_NONE
) {
16962 if (peer_group_active(peer
)) {
16963 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16965 if (type
!= g_type
)
16977 /* This is part of the address-family block (unicast only) */
16978 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16982 uint32_t tovpn_sid_index
= 0;
16984 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16985 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16986 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16987 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16988 bgp
->vpn_policy
[afi
]
16989 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16991 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16992 bgp
->vpn_policy
[afi
]
16993 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16995 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16996 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16997 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16998 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17001 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17002 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17004 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17007 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17008 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17009 bgp
->vpn_policy
[afi
].tovpn_label
);
17013 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17014 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17015 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17016 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17017 } else if (tovpn_sid_index
!= 0) {
17018 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17022 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17023 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
17024 &bgp
->vpn_policy
[afi
].tovpn_rd
);
17026 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17027 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17029 char buf
[PREFIX_STRLEN
];
17030 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17031 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17034 vty_out(vty
, "%*snexthop vpn export %s\n",
17038 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17039 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17041 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17042 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17044 char *b
= ecommunity_ecom2str(
17045 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17046 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17047 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17048 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17050 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17051 char *b
= ecommunity_ecom2str(
17052 bgp
->vpn_policy
[afi
]
17053 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17054 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17055 ECOMMUNITY_ROUTE_TARGET
);
17056 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17057 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17059 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17060 char *b
= ecommunity_ecom2str(
17061 bgp
->vpn_policy
[afi
]
17062 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17063 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17064 ECOMMUNITY_ROUTE_TARGET
);
17065 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17066 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17070 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17071 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17072 bgp
->vpn_policy
[afi
]
17073 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17075 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17076 char *b
= ecommunity_ecom2str(
17077 bgp
->vpn_policy
[afi
]
17078 .import_redirect_rtlist
,
17079 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17080 ECOMMUNITY_ROUTE_TARGET
);
17082 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17083 != ECOMMUNITY_SIZE
)
17084 vty_out(vty
, "%*srt6 redirect import %s\n",
17087 vty_out(vty
, "%*srt redirect import %s\n",
17089 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17093 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17094 afi_t afi
, safi_t safi
)
17096 struct bgp_filter
*filter
;
17100 filter
= &peer
->filter
[afi
][safi
];
17102 /* distribute-list. */
17103 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17105 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17106 filter
->dlist
[FILTER_IN
].name
);
17108 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17110 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17111 filter
->dlist
[FILTER_OUT
].name
);
17114 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17116 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17117 filter
->plist
[FILTER_IN
].name
);
17119 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17121 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17122 filter
->plist
[FILTER_OUT
].name
);
17125 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17126 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17127 filter
->map
[RMAP_IN
].name
);
17129 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17131 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17132 filter
->map
[RMAP_OUT
].name
);
17134 /* unsuppress-map */
17135 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17136 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17137 filter
->usmap
.name
);
17139 /* advertise-map : always applied in OUT direction*/
17140 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17141 CONDITION_NON_EXIST
))
17143 " neighbor %s advertise-map %s non-exist-map %s\n",
17144 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17146 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17148 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17149 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17152 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17154 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17155 filter
->aslist
[FILTER_IN
].name
);
17157 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17159 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17160 filter
->aslist
[FILTER_OUT
].name
);
17163 /* BGP peer configuration display function. */
17164 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17167 struct peer
*g_peer
= NULL
;
17169 int if_pg_printed
= false;
17170 int if_ras_printed
= false;
17172 /* Skip dynamic neighbors. */
17173 if (peer_dynamic_neighbor(peer
))
17177 addr
= peer
->conf_if
;
17181 /************************************
17182 ****** Global to the neighbor ******
17183 ************************************/
17184 if (peer
->conf_if
) {
17185 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17186 vty_out(vty
, " neighbor %s interface v6only", addr
);
17188 vty_out(vty
, " neighbor %s interface", addr
);
17190 if (peer_group_active(peer
)) {
17191 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17192 if_pg_printed
= true;
17193 } else if (peer
->as_type
== AS_SPECIFIED
) {
17194 vty_out(vty
, " remote-as %u", peer
->as
);
17195 if_ras_printed
= true;
17196 } else if (peer
->as_type
== AS_INTERNAL
) {
17197 vty_out(vty
, " remote-as internal");
17198 if_ras_printed
= true;
17199 } else if (peer
->as_type
== AS_EXTERNAL
) {
17200 vty_out(vty
, " remote-as external");
17201 if_ras_printed
= true;
17204 vty_out(vty
, "\n");
17207 /* remote-as and peer-group */
17208 /* peer is a member of a peer-group */
17209 if (peer_group_active(peer
)) {
17210 g_peer
= peer
->group
->conf
;
17212 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17213 if (peer
->as_type
== AS_SPECIFIED
) {
17214 vty_out(vty
, " neighbor %s remote-as %u\n",
17216 } else if (peer
->as_type
== AS_INTERNAL
) {
17218 " neighbor %s remote-as internal\n",
17220 } else if (peer
->as_type
== AS_EXTERNAL
) {
17222 " neighbor %s remote-as external\n",
17227 /* For swpX peers we displayed the peer-group
17228 * via 'neighbor swpX interface peer-group PGNAME' */
17229 if (!if_pg_printed
)
17230 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17231 peer
->group
->name
);
17234 /* peer is NOT a member of a peer-group */
17236 /* peer is a peer-group, declare the peer-group */
17237 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17238 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17241 if (!if_ras_printed
) {
17242 if (peer
->as_type
== AS_SPECIFIED
) {
17243 vty_out(vty
, " neighbor %s remote-as %u\n",
17245 } else if (peer
->as_type
== AS_INTERNAL
) {
17247 " neighbor %s remote-as internal\n",
17249 } else if (peer
->as_type
== AS_EXTERNAL
) {
17251 " neighbor %s remote-as external\n",
17258 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17259 vty_out(vty
, " neighbor %s local-as %u", addr
,
17260 peer
->change_local_as
);
17261 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17262 vty_out(vty
, " no-prepend");
17263 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17264 vty_out(vty
, " replace-as");
17265 vty_out(vty
, "\n");
17270 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17274 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17275 if (peer
->tx_shutdown_message
)
17276 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17277 peer
->tx_shutdown_message
);
17279 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17282 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17283 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17284 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17287 if (peer
->bfd_config
)
17288 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17291 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17292 vty_out(vty
, " neighbor %s password %s\n", addr
,
17295 /* neighbor solo */
17296 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17297 if (!peer_group_active(peer
)) {
17298 vty_out(vty
, " neighbor %s solo\n", addr
);
17303 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17304 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17307 /* Local interface name */
17308 if (peer
->ifname
) {
17309 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17312 /* TCP max segment size */
17313 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17314 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17317 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17318 vty_out(vty
, " neighbor %s passive\n", addr
);
17320 /* ebgp-multihop */
17321 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17322 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17323 && peer
->ttl
== MAXTTL
)) {
17324 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17325 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17331 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17332 vty_out(vty
, " neighbor %s aigp\n", addr
);
17334 /* graceful-shutdown */
17335 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17336 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17339 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17340 peer
->local_role
!= ROLE_UNDEFINED
)
17341 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17342 bgp_get_name_by_role(peer
->local_role
),
17343 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17347 /* ttl-security hops */
17348 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17349 if (!peer_group_active(peer
)
17350 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17351 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17352 addr
, peer
->gtsm_hops
);
17356 /* disable-connected-check */
17357 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17358 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17360 /* link-bw-encoding-ieee */
17361 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17362 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17365 /* extended-optional-parameters */
17366 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17367 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17370 /* enforce-first-as */
17371 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17372 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17374 /* update-source */
17375 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17376 if (peer
->update_source
)
17377 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17378 peer
->update_source
);
17379 else if (peer
->update_if
)
17380 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17384 /* advertisement-interval */
17385 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17386 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17390 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17391 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17392 peer
->keepalive
, peer
->holdtime
);
17394 /* timers connect */
17395 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17396 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17398 /* need special-case handling for changed default values due to
17399 * config profile / version (because there is no "timers bgp connect"
17400 * command, we need to save this per-peer :/)
17402 else if (!peer_group_active(peer
) && !peer
->connect
&&
17403 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17404 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17405 peer
->bgp
->default_connect_retry
);
17407 /* timers delayopen */
17408 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17409 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17411 /* Save config even though flag is not set if default values have been
17414 else if (!peer_group_active(peer
) && !peer
->delayopen
17415 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17416 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17417 peer
->bgp
->default_delayopen
);
17419 /* capability dynamic */
17420 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17421 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17423 /* capability extended-nexthop */
17424 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17425 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17428 " no neighbor %s capability extended-nexthop\n",
17430 else if (!peer
->conf_if
)
17432 " neighbor %s capability extended-nexthop\n",
17436 /* dont-capability-negotiation */
17437 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17438 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17440 /* override-capability */
17441 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17442 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17444 /* strict-capability-match */
17445 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17446 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17448 /* Sender side AS path loop detection. */
17449 if (peer
->as_path_loop_detection
)
17450 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17453 /* path-attribute discard */
17454 char discard_attrs_str
[BUFSIZ
] = {0};
17455 bool discard_attrs
= bgp_path_attribute_discard(
17456 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17459 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17460 discard_attrs_str
);
17462 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17463 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17465 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17466 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17468 " neighbor %s graceful-restart-helper\n", addr
);
17469 } else if (CHECK_FLAG(
17470 peer
->peer_gr_new_status_flag
,
17471 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17473 " neighbor %s graceful-restart\n", addr
);
17475 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17476 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17478 peer
->peer_gr_new_status_flag
,
17479 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17480 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17486 /* BGP peer configuration display function. */
17487 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17488 struct peer
*peer
, afi_t afi
, safi_t safi
)
17490 struct peer
*g_peer
= NULL
;
17492 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17494 /* Skip dynamic neighbors. */
17495 if (peer_dynamic_neighbor(peer
))
17499 addr
= peer
->conf_if
;
17503 /************************************
17504 ****** Per AF to the neighbor ******
17505 ************************************/
17506 if (peer_group_active(peer
)) {
17507 g_peer
= peer
->group
->conf
;
17509 /* If the peer-group is active but peer is not, print a 'no
17511 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17512 vty_out(vty
, " no neighbor %s activate\n", addr
);
17515 /* If the peer-group is not active but peer is, print an
17517 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17518 vty_out(vty
, " neighbor %s activate\n", addr
);
17521 if (peer
->afc
[afi
][safi
]) {
17522 if (safi
== SAFI_ENCAP
)
17523 vty_out(vty
, " neighbor %s activate\n", addr
);
17524 else if (!bgp
->default_af
[afi
][safi
])
17525 vty_out(vty
, " neighbor %s activate\n", addr
);
17527 if (bgp
->default_af
[afi
][safi
])
17528 vty_out(vty
, " no neighbor %s activate\n",
17533 /* addpath TX knobs */
17534 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17535 switch (peer
->addpath_type
[afi
][safi
]) {
17536 case BGP_ADDPATH_ALL
:
17537 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17540 case BGP_ADDPATH_BEST_PER_AS
:
17542 " neighbor %s addpath-tx-bestpath-per-AS\n",
17545 case BGP_ADDPATH_MAX
:
17546 case BGP_ADDPATH_NONE
:
17551 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17552 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17554 /* ORF capability. */
17555 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17556 || peergroup_af_flag_check(peer
, afi
, safi
,
17557 PEER_FLAG_ORF_PREFIX_RM
)) {
17558 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17560 if (peergroup_af_flag_check(peer
, afi
, safi
,
17561 PEER_FLAG_ORF_PREFIX_SM
)
17562 && peergroup_af_flag_check(peer
, afi
, safi
,
17563 PEER_FLAG_ORF_PREFIX_RM
))
17564 vty_out(vty
, " both");
17565 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17566 PEER_FLAG_ORF_PREFIX_SM
))
17567 vty_out(vty
, " send");
17569 vty_out(vty
, " receive");
17570 vty_out(vty
, "\n");
17573 /* Route reflector client. */
17574 if (peergroup_af_flag_check(peer
, afi
, safi
,
17575 PEER_FLAG_REFLECTOR_CLIENT
)) {
17576 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17579 /* next-hop-self force */
17580 if (peergroup_af_flag_check(peer
, afi
, safi
,
17581 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17582 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17585 /* next-hop-self */
17586 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17587 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17590 /* remove-private-AS */
17591 if (peergroup_af_flag_check(peer
, afi
, safi
,
17592 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17593 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17597 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17598 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17599 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17603 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17604 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17605 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17608 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17609 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17610 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17614 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17615 vty_out(vty
, " neighbor %s as-override\n", addr
);
17618 /* send-community print. */
17619 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17620 PEER_FLAG_SEND_COMMUNITY
);
17621 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17622 PEER_FLAG_SEND_EXT_COMMUNITY
);
17623 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17624 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17626 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17627 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17630 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17633 " no neighbor %s send-community extended\n",
17637 vty_out(vty
, " no neighbor %s send-community large\n",
17641 /* Default information */
17642 if (peergroup_af_flag_check(peer
, afi
, safi
,
17643 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17644 vty_out(vty
, " neighbor %s default-originate", addr
);
17646 if (peer
->default_rmap
[afi
][safi
].name
)
17647 vty_out(vty
, " route-map %s",
17648 peer
->default_rmap
[afi
][safi
].name
);
17650 vty_out(vty
, "\n");
17653 /* Soft reconfiguration inbound. */
17654 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17655 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17659 /* maximum-prefix. */
17660 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17661 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17662 peer
->pmax
[afi
][safi
]);
17664 if (peer
->pmax_threshold
[afi
][safi
]
17665 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17666 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17667 if (peer_af_flag_check(peer
, afi
, safi
,
17668 PEER_FLAG_MAX_PREFIX_WARNING
))
17669 vty_out(vty
, " warning-only");
17670 if (peer
->pmax_restart
[afi
][safi
])
17671 vty_out(vty
, " restart %u",
17672 peer
->pmax_restart
[afi
][safi
]);
17673 if (peer_af_flag_check(peer
, afi
, safi
,
17674 PEER_FLAG_MAX_PREFIX_FORCE
))
17675 vty_out(vty
, " force");
17677 vty_out(vty
, "\n");
17680 /* maximum-prefix-out */
17681 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17682 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17683 addr
, peer
->pmax_out
[afi
][safi
]);
17685 /* Route server client. */
17686 if (peergroup_af_flag_check(peer
, afi
, safi
,
17687 PEER_FLAG_RSERVER_CLIENT
)) {
17688 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17691 /* Nexthop-local unchanged. */
17692 if (peergroup_af_flag_check(peer
, afi
, safi
,
17693 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17694 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17697 /* allowas-in <1-10> */
17698 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17699 if (peer_af_flag_check(peer
, afi
, safi
,
17700 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17701 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17702 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17703 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17705 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17706 peer
->allowas_in
[afi
][safi
]);
17711 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17712 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17715 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17716 char *soo_str
= ecommunity_ecom2str(
17717 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17719 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17720 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17724 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17725 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17726 peer
->weight
[afi
][safi
]);
17729 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17731 /* atribute-unchanged. */
17732 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17733 || (safi
!= SAFI_EVPN
17734 && peer_af_flag_check(peer
, afi
, safi
,
17735 PEER_FLAG_NEXTHOP_UNCHANGED
))
17736 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17738 if (!peer_group_active(peer
)
17739 || peergroup_af_flag_check(peer
, afi
, safi
,
17740 PEER_FLAG_AS_PATH_UNCHANGED
)
17741 || peergroup_af_flag_check(peer
, afi
, safi
,
17742 PEER_FLAG_NEXTHOP_UNCHANGED
)
17743 || peergroup_af_flag_check(peer
, afi
, safi
,
17744 PEER_FLAG_MED_UNCHANGED
)) {
17747 " neighbor %s attribute-unchanged%s%s%s\n",
17749 peer_af_flag_check(peer
, afi
, safi
,
17750 PEER_FLAG_AS_PATH_UNCHANGED
)
17753 peer_af_flag_check(peer
, afi
, safi
,
17754 PEER_FLAG_NEXTHOP_UNCHANGED
)
17757 peer_af_flag_check(peer
, afi
, safi
,
17758 PEER_FLAG_MED_UNCHANGED
)
17765 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17768 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17769 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17770 vty_out(vty
, " no bgp retain route-target all\n");
17773 /* Address family based peer configuration display. */
17774 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17778 struct peer_group
*group
;
17779 struct listnode
*node
, *nnode
;
17782 vty_frame(vty
, " !\n address-family ");
17783 if (afi
== AFI_IP
) {
17784 if (safi
== SAFI_UNICAST
)
17785 vty_frame(vty
, "ipv4 unicast");
17786 else if (safi
== SAFI_LABELED_UNICAST
)
17787 vty_frame(vty
, "ipv4 labeled-unicast");
17788 else if (safi
== SAFI_MULTICAST
)
17789 vty_frame(vty
, "ipv4 multicast");
17790 else if (safi
== SAFI_MPLS_VPN
)
17791 vty_frame(vty
, "ipv4 vpn");
17792 else if (safi
== SAFI_ENCAP
)
17793 vty_frame(vty
, "ipv4 encap");
17794 else if (safi
== SAFI_FLOWSPEC
)
17795 vty_frame(vty
, "ipv4 flowspec");
17796 } else if (afi
== AFI_IP6
) {
17797 if (safi
== SAFI_UNICAST
)
17798 vty_frame(vty
, "ipv6 unicast");
17799 else if (safi
== SAFI_LABELED_UNICAST
)
17800 vty_frame(vty
, "ipv6 labeled-unicast");
17801 else if (safi
== SAFI_MULTICAST
)
17802 vty_frame(vty
, "ipv6 multicast");
17803 else if (safi
== SAFI_MPLS_VPN
)
17804 vty_frame(vty
, "ipv6 vpn");
17805 else if (safi
== SAFI_ENCAP
)
17806 vty_frame(vty
, "ipv6 encap");
17807 else if (safi
== SAFI_FLOWSPEC
)
17808 vty_frame(vty
, "ipv6 flowspec");
17809 } else if (afi
== AFI_L2VPN
) {
17810 if (safi
== SAFI_EVPN
)
17811 vty_frame(vty
, "l2vpn evpn");
17813 vty_frame(vty
, "\n");
17815 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17817 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17819 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17821 /* BGP flag dampening. */
17822 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17823 bgp_config_write_damp(vty
, afi
, safi
);
17825 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17826 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17828 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17829 /* Do not display doppelganger peers */
17830 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17831 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17834 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17835 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17837 if (safi
== SAFI_EVPN
)
17838 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17840 if (safi
== SAFI_FLOWSPEC
)
17841 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17843 if (safi
== SAFI_MPLS_VPN
)
17844 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17846 if (safi
== SAFI_UNICAST
) {
17847 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17848 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17849 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17851 vty_out(vty
, " export vpn\n");
17853 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17854 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17856 vty_out(vty
, " import vpn\n");
17858 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17859 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17862 for (ALL_LIST_ELEMENTS_RO(
17863 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17865 vty_out(vty
, " import vrf %s\n", name
);
17869 vty_endframe(vty
, " exit-address-family\n");
17872 int bgp_config_write(struct vty
*vty
)
17875 struct peer_group
*group
;
17877 struct listnode
*node
, *nnode
;
17878 struct listnode
*mnode
, *mnnode
;
17881 uint32_t tovpn_sid_index
= 0;
17883 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17884 vty_out(vty
, "bgp route-map delay-timer %u\n",
17885 bm
->rmap_update_timer
);
17887 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17888 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17889 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17890 vty_out(vty
, " %d", bm
->v_establish_wait
);
17891 vty_out(vty
, "\n");
17894 if (bm
->wait_for_fib
)
17895 vty_out(vty
, "bgp suppress-fib-pending\n");
17897 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17898 vty_out(vty
, "bgp graceful-shutdown\n");
17900 /* No-RIB (Zebra) option flag configuration */
17901 if (bgp_option_check(BGP_OPT_NO_FIB
))
17902 vty_out(vty
, "bgp no-rib\n");
17904 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17905 vty_out(vty
, "bgp send-extra-data zebra\n");
17907 /* BGP session DSCP value */
17908 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17909 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17911 /* BGP InQ limit */
17912 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
17913 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17915 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
17916 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
17918 /* BGP configuration. */
17919 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17921 /* skip all auto created vrf as they dont have user config */
17922 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17925 /* Router bgp ASN */
17926 vty_out(vty
, "router bgp %u", bgp
->as
);
17929 vty_out(vty
, " %s %s",
17930 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17931 ? "view" : "vrf", bgp
->name
);
17932 vty_out(vty
, "\n");
17934 /* BGP fast-external-failover. */
17935 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17936 vty_out(vty
, " no bgp fast-external-failover\n");
17938 /* BGP router ID. */
17939 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17940 vty_out(vty
, " bgp router-id %pI4\n",
17941 &bgp
->router_id_static
);
17943 /* Suppress fib pending */
17944 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17945 vty_out(vty
, " bgp suppress-fib-pending\n");
17947 /* BGP log-neighbor-changes. */
17948 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17949 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17950 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17951 CHECK_FLAG(bgp
->flags
,
17952 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17956 /* BGP configuration. */
17957 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17958 vty_out(vty
, " bgp always-compare-med\n");
17960 /* RFC8212 default eBGP policy. */
17961 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17962 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17963 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17964 CHECK_FLAG(bgp
->flags
,
17965 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17969 /* draft-ietf-idr-deprecate-as-set-confed-set */
17970 if (bgp
->reject_as_sets
)
17971 vty_out(vty
, " bgp reject-as-sets\n");
17973 /* Suppress duplicate updates if the route actually not changed
17975 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17976 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17977 vty_out(vty
, " %sbgp suppress-duplicates\n",
17978 CHECK_FLAG(bgp
->flags
,
17979 BGP_FLAG_SUPPRESS_DUPLICATES
)
17983 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17985 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17986 SAVE_BGP_HARD_ADMIN_RESET
)
17987 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17988 CHECK_FLAG(bgp
->flags
,
17989 BGP_FLAG_HARD_ADMIN_RESET
)
17993 /* BGP default <afi>-<safi> */
17994 FOREACH_AFI_SAFI (afi
, safi
) {
17995 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17996 if (!bgp
->default_af
[afi
][safi
])
17997 vty_out(vty
, " no bgp default %s\n",
17998 get_bgp_default_af_flag(afi
,
18000 } else if (bgp
->default_af
[afi
][safi
])
18001 vty_out(vty
, " bgp default %s\n",
18002 get_bgp_default_af_flag(afi
, safi
));
18005 /* BGP default local-preference. */
18006 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18007 vty_out(vty
, " bgp default local-preference %u\n",
18008 bgp
->default_local_pref
);
18010 /* BGP default show-hostname */
18011 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18012 != SAVE_BGP_SHOW_HOSTNAME
)
18013 vty_out(vty
, " %sbgp default show-hostname\n",
18014 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18018 /* BGP default show-nexthop-hostname */
18019 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18020 != SAVE_BGP_SHOW_HOSTNAME
)
18021 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18022 CHECK_FLAG(bgp
->flags
,
18023 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18027 /* BGP default subgroup-pkt-queue-max. */
18028 if (bgp
->default_subgroup_pkt_queue_max
18029 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18030 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18031 bgp
->default_subgroup_pkt_queue_max
);
18033 /* BGP client-to-client reflection. */
18034 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18035 vty_out(vty
, " no bgp client-to-client reflection\n");
18037 /* BGP cluster ID. */
18038 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18039 vty_out(vty
, " bgp cluster-id %pI4\n",
18042 /* Disable ebgp connected nexthop check */
18043 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18045 " bgp disable-ebgp-connected-route-check\n");
18047 /* Confederation identifier*/
18048 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18049 vty_out(vty
, " bgp confederation identifier %u\n",
18052 /* Confederation peer */
18053 if (bgp
->confed_peers_cnt
> 0) {
18056 vty_out(vty
, " bgp confederation peers");
18058 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18059 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18061 vty_out(vty
, "\n");
18064 /* BGP deterministic-med. */
18065 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18066 != SAVE_BGP_DETERMINISTIC_MED
)
18067 vty_out(vty
, " %sbgp deterministic-med\n",
18068 CHECK_FLAG(bgp
->flags
,
18069 BGP_FLAG_DETERMINISTIC_MED
)
18073 /* BGP update-delay. */
18074 bgp_config_write_update_delay(vty
, bgp
);
18076 if (bgp
->v_maxmed_onstartup
18077 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18078 vty_out(vty
, " bgp max-med on-startup %u",
18079 bgp
->v_maxmed_onstartup
);
18080 if (bgp
->maxmed_onstartup_value
18081 != BGP_MAXMED_VALUE_DEFAULT
)
18082 vty_out(vty
, " %u",
18083 bgp
->maxmed_onstartup_value
);
18084 vty_out(vty
, "\n");
18086 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18087 vty_out(vty
, " bgp max-med administrative");
18088 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18089 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18090 vty_out(vty
, "\n");
18094 bgp_config_write_wpkt_quanta(vty
, bgp
);
18096 bgp_config_write_rpkt_quanta(vty
, bgp
);
18098 /* coalesce time */
18099 bgp_config_write_coalesce_time(vty
, bgp
);
18101 /* BGP per-instance graceful-shutdown */
18102 /* BGP-wide settings and per-instance settings are mutually
18105 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18106 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18107 vty_out(vty
, " bgp graceful-shutdown\n");
18109 /* Long-lived Graceful Restart */
18110 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18112 " bgp long-lived-graceful-restart stale-time %u\n",
18113 bgp
->llgr_stale_time
);
18115 /* BGP graceful-restart. */
18116 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18118 " bgp graceful-restart stalepath-time %u\n",
18119 bgp
->stalepath_time
);
18121 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18122 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18123 bgp
->restart_time
);
18125 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18126 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18127 vty_out(vty
, " %sbgp graceful-restart notification\n",
18128 CHECK_FLAG(bgp
->flags
,
18129 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18133 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18135 " bgp graceful-restart select-defer-time %u\n",
18136 bgp
->select_defer_time
);
18138 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18139 vty_out(vty
, " bgp graceful-restart\n");
18141 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18142 vty_out(vty
, " bgp graceful-restart-disable\n");
18144 /* BGP graceful-restart Preserve State F bit. */
18145 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18147 " bgp graceful-restart preserve-fw-state\n");
18149 /* BGP TCP keepalive */
18150 bgp_config_tcp_keepalive(vty
, bgp
);
18152 /* Stale timer for RIB */
18153 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18155 " bgp graceful-restart rib-stale-time %u\n",
18156 bgp
->rib_stale_time
);
18158 /* BGP bestpath method. */
18159 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18160 vty_out(vty
, " bgp bestpath as-path ignore\n");
18161 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18162 vty_out(vty
, " bgp bestpath as-path confed\n");
18164 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18165 if (CHECK_FLAG(bgp
->flags
,
18166 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18168 " bgp bestpath as-path multipath-relax as-set\n");
18171 " bgp bestpath as-path multipath-relax\n");
18175 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18177 " bgp route-reflector allow-outbound-policy\n");
18179 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18180 vty_out(vty
, " bgp bestpath compare-routerid\n");
18181 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18182 vty_out(vty
, " bgp bestpath aigp\n");
18183 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18184 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18185 vty_out(vty
, " bgp bestpath med");
18186 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18187 vty_out(vty
, " confed");
18188 if (CHECK_FLAG(bgp
->flags
,
18189 BGP_FLAG_MED_MISSING_AS_WORST
))
18190 vty_out(vty
, " missing-as-worst");
18191 vty_out(vty
, "\n");
18194 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18196 " bgp bestpath peer-type multipath-relax\n");
18198 /* Link bandwidth handling. */
18199 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18200 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18201 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18202 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18203 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18204 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18206 /* BGP network import check. */
18207 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18208 != SAVE_BGP_IMPORT_CHECK
)
18209 vty_out(vty
, " %sbgp network import-check\n",
18210 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18214 /* BGP timers configuration. */
18215 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18216 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18217 vty_out(vty
, " timers bgp %u %u\n",
18218 bgp
->default_keepalive
, bgp
->default_holdtime
);
18220 /* BGP minimum holdtime configuration. */
18221 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18222 && bgp
->default_min_holdtime
!= 0)
18223 vty_out(vty
, " bgp minimum-holdtime %u\n",
18224 bgp
->default_min_holdtime
);
18226 /* Conditional advertisement timer configuration */
18227 if (bgp
->condition_check_period
18228 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18230 " bgp conditional-advertisement timer %u\n",
18231 bgp
->condition_check_period
);
18234 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18235 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18238 /* Normal neighbor configuration. */
18239 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18240 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18241 bgp_config_write_peer_global(vty
, bgp
, peer
);
18244 /* listen range and limit for dynamic BGP neighbors */
18245 bgp_config_write_listen(vty
, bgp
);
18248 * BGP default autoshutdown neighbors
18250 * This must be placed after any peer and peer-group
18251 * configuration, to avoid setting all peers to shutdown after
18252 * a daemon restart, which is undesired behavior. (see #2286)
18254 if (bgp
->autoshutdown
)
18255 vty_out(vty
, " bgp default shutdown\n");
18257 /* BGP instance administrative shutdown */
18258 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18259 vty_out(vty
, " bgp shutdown\n");
18261 if (bgp
->allow_martian
)
18262 vty_out(vty
, " bgp allow-martian-nexthop\n");
18264 if (bgp
->fast_convergence
)
18265 vty_out(vty
, " bgp fast-convergence\n");
18267 if (bgp
->srv6_enabled
) {
18268 vty_frame(vty
, " !\n segment-routing srv6\n");
18269 if (strlen(bgp
->srv6_locator_name
))
18270 vty_out(vty
, " locator %s\n",
18271 bgp
->srv6_locator_name
);
18272 vty_endframe(vty
, " exit\n");
18275 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18276 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18277 vty_out(vty
, " sid vpn per-vrf export auto\n");
18278 } else if (tovpn_sid_index
!= 0) {
18279 vty_out(vty
, " sid vpn per-vrf export %d\n",
18283 /* IPv4 unicast configuration. */
18284 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18286 /* IPv4 multicast configuration. */
18287 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18289 /* IPv4 labeled-unicast configuration. */
18290 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18292 /* IPv4 VPN configuration. */
18293 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18295 /* ENCAPv4 configuration. */
18296 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18298 /* FLOWSPEC v4 configuration. */
18299 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18301 /* IPv6 unicast configuration. */
18302 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18304 /* IPv6 multicast configuration. */
18305 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18307 /* IPv6 labeled-unicast configuration. */
18308 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18309 SAFI_LABELED_UNICAST
);
18311 /* IPv6 VPN configuration. */
18312 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18314 /* ENCAPv6 configuration. */
18315 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18317 /* FLOWSPEC v6 configuration. */
18318 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18320 /* EVPN configuration. */
18321 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18323 hook_call(bgp_inst_config_write
, bgp
, vty
);
18325 #ifdef ENABLE_BGP_VNC
18326 bgp_rfapi_cfg_write(vty
, bgp
);
18329 vty_out(vty
, "exit\n");
18330 vty_out(vty
, "!\n");
18336 /* BGP node structure. */
18337 static struct cmd_node bgp_node
= {
18340 .parent_node
= CONFIG_NODE
,
18341 .prompt
= "%s(config-router)# ",
18342 .config_write
= bgp_config_write
,
18345 static struct cmd_node bgp_ipv4_unicast_node
= {
18346 .name
= "bgp ipv4 unicast",
18347 .node
= BGP_IPV4_NODE
,
18348 .parent_node
= BGP_NODE
,
18349 .prompt
= "%s(config-router-af)# ",
18353 static struct cmd_node bgp_ipv4_multicast_node
= {
18354 .name
= "bgp ipv4 multicast",
18355 .node
= BGP_IPV4M_NODE
,
18356 .parent_node
= BGP_NODE
,
18357 .prompt
= "%s(config-router-af)# ",
18361 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18362 .name
= "bgp ipv4 labeled unicast",
18363 .node
= BGP_IPV4L_NODE
,
18364 .parent_node
= BGP_NODE
,
18365 .prompt
= "%s(config-router-af)# ",
18369 static struct cmd_node bgp_ipv6_unicast_node
= {
18370 .name
= "bgp ipv6 unicast",
18371 .node
= BGP_IPV6_NODE
,
18372 .parent_node
= BGP_NODE
,
18373 .prompt
= "%s(config-router-af)# ",
18377 static struct cmd_node bgp_ipv6_multicast_node
= {
18378 .name
= "bgp ipv6 multicast",
18379 .node
= BGP_IPV6M_NODE
,
18380 .parent_node
= BGP_NODE
,
18381 .prompt
= "%s(config-router-af)# ",
18385 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18386 .name
= "bgp ipv6 labeled unicast",
18387 .node
= BGP_IPV6L_NODE
,
18388 .parent_node
= BGP_NODE
,
18389 .prompt
= "%s(config-router-af)# ",
18393 static struct cmd_node bgp_vpnv4_node
= {
18394 .name
= "bgp vpnv4",
18395 .node
= BGP_VPNV4_NODE
,
18396 .parent_node
= BGP_NODE
,
18397 .prompt
= "%s(config-router-af)# ",
18401 static struct cmd_node bgp_vpnv6_node
= {
18402 .name
= "bgp vpnv6",
18403 .node
= BGP_VPNV6_NODE
,
18404 .parent_node
= BGP_NODE
,
18405 .prompt
= "%s(config-router-af-vpnv6)# ",
18409 static struct cmd_node bgp_evpn_node
= {
18410 .name
= "bgp evpn",
18411 .node
= BGP_EVPN_NODE
,
18412 .parent_node
= BGP_NODE
,
18413 .prompt
= "%s(config-router-evpn)# ",
18417 static struct cmd_node bgp_evpn_vni_node
= {
18418 .name
= "bgp evpn vni",
18419 .node
= BGP_EVPN_VNI_NODE
,
18420 .parent_node
= BGP_EVPN_NODE
,
18421 .prompt
= "%s(config-router-af-vni)# ",
18424 static struct cmd_node bgp_flowspecv4_node
= {
18425 .name
= "bgp ipv4 flowspec",
18426 .node
= BGP_FLOWSPECV4_NODE
,
18427 .parent_node
= BGP_NODE
,
18428 .prompt
= "%s(config-router-af)# ",
18432 static struct cmd_node bgp_flowspecv6_node
= {
18433 .name
= "bgp ipv6 flowspec",
18434 .node
= BGP_FLOWSPECV6_NODE
,
18435 .parent_node
= BGP_NODE
,
18436 .prompt
= "%s(config-router-af-vpnv6)# ",
18440 static struct cmd_node bgp_srv6_node
= {
18441 .name
= "bgp srv6",
18442 .node
= BGP_SRV6_NODE
,
18443 .parent_node
= BGP_NODE
,
18444 .prompt
= "%s(config-router-srv6)# ",
18447 static void community_list_vty(void);
18449 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18452 struct peer_group
*group
;
18453 struct listnode
*lnbgp
, *lnpeer
;
18455 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18456 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18458 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18462 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18466 struct listnode
*lnbgp
, *lnpeer
;
18468 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18469 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18470 /* only provide suggestions on the appropriate input
18472 * they'll otherwise show up multiple times */
18473 enum cmd_token_type match_type
;
18474 char *name
= peer
->host
;
18476 if (peer
->conf_if
) {
18477 match_type
= VARIABLE_TKN
;
18478 name
= peer
->conf_if
;
18479 } else if (strchr(peer
->host
, ':'))
18480 match_type
= IPV6_TKN
;
18482 match_type
= IPV4_TKN
;
18484 if (token
->type
!= match_type
)
18487 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18492 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18494 bgp_ac_peer(comps
, token
);
18496 if (token
->type
== VARIABLE_TKN
)
18497 bgp_ac_peergroup(comps
, token
);
18500 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18501 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18502 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18503 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18504 {.completions
= NULL
}};
18506 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18507 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18508 {.completions
= NULL
} };
18510 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18512 static struct thread
*t_bgp_cfg
;
18514 bool bgp_config_inprocess(void)
18516 return thread_is_scheduled(t_bgp_cfg
);
18519 static void bgp_config_finish(struct thread
*t
)
18521 struct listnode
*node
;
18524 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18525 hook_call(bgp_config_end
, bgp
);
18528 static void bgp_config_start(void)
18530 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18531 THREAD_OFF(t_bgp_cfg
);
18532 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18533 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18536 /* When we receive a hook the configuration is read,
18537 * we start a timer to make sure we postpone sending
18538 * EoR before route-maps are processed.
18539 * This is especially valid if using `bgp route-map delay-timer`.
18541 static void bgp_config_end(void)
18543 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18544 uint32_t bgp_post_config_delay
=
18545 thread_is_scheduled(bm
->t_rmap_update
)
18546 ? thread_timer_remain_second(bm
->t_rmap_update
)
18547 : BGP_POST_CONFIG_DELAY_SECONDS
;
18549 /* If BGP config processing thread isn't running, then
18550 * we can return and rely it's properly handled.
18552 if (!bgp_config_inprocess())
18555 THREAD_OFF(t_bgp_cfg
);
18557 /* Start a new timer to make sure we don't send EoR
18558 * before route-maps are processed.
18560 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18561 bgp_post_config_delay
, &t_bgp_cfg
);
18564 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18567 struct interface
*ifp
;
18568 struct bgp_interface
*iifp
;
18570 FOR_ALL_INTERFACES (vrf
, ifp
) {
18575 if_vty_config_start(vty
, ifp
);
18577 if (CHECK_FLAG(iifp
->flags
,
18578 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18579 vty_out(vty
, " mpls bgp forwarding\n");
18583 if_vty_config_end(vty
);
18589 /* Configuration write function for bgpd. */
18590 static int config_write_interface(struct vty
*vty
)
18593 struct vrf
*vrf
= NULL
;
18595 /* Display all VRF aware OSPF interface configuration */
18596 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18597 write
+= config_write_interface_one(vty
, vrf
);
18603 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18604 "[no$no] mpls bgp forwarding",
18605 NO_STR MPLS_STR BGP_STR
18606 "Enable MPLS forwarding for eBGP directly connected peers\n")
18609 struct bgp_interface
*iifp
;
18611 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18614 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18615 return CMD_WARNING_CONFIG_FAILED
;
18617 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18618 if (check
!= !no
) {
18620 UNSET_FLAG(iifp
->flags
,
18621 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18623 SET_FLAG(iifp
->flags
,
18624 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18625 /* trigger a nht update on eBGP sessions */
18626 if (if_is_operative(ifp
))
18627 bgp_nht_ifp_up(ifp
);
18629 return CMD_SUCCESS
;
18632 DEFPY (bgp_inq_limit
,
18634 "bgp input-queue-limit (1-4294967295)$limit",
18636 "Set the BGP Input Queue limit for all peers when message parsing\n"
18637 "Input-Queue limit\n")
18639 bm
->inq_limit
= limit
;
18641 return CMD_SUCCESS
;
18644 DEFPY (no_bgp_inq_limit
,
18645 no_bgp_inq_limit_cmd
,
18646 "no bgp input-queue-limit [(1-4294967295)$limit]",
18649 "Set the BGP Input Queue limit for all peers when message parsing\n"
18650 "Input-Queue limit\n")
18652 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18654 return CMD_SUCCESS
;
18657 DEFPY (bgp_outq_limit
,
18658 bgp_outq_limit_cmd
,
18659 "bgp output-queue-limit (1-4294967295)$limit",
18661 "Set the BGP Output Queue limit for all peers when message parsing\n"
18662 "Output-Queue limit\n")
18664 bm
->outq_limit
= limit
;
18666 return CMD_SUCCESS
;
18669 DEFPY (no_bgp_outq_limit
,
18670 no_bgp_outq_limit_cmd
,
18671 "no bgp output-queue-limit [(1-4294967295)$limit]",
18674 "Set the BGP Output Queue limit for all peers when message parsing\n"
18675 "Output-Queue limit\n")
18677 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18679 return CMD_SUCCESS
;
18683 /* Initialization of BGP interface. */
18684 static void bgp_vty_if_init(void)
18686 /* Install interface node. */
18687 if_cmd_init(config_write_interface
);
18689 /* "mpls bgp forwarding" commands. */
18690 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18693 void bgp_vty_init(void)
18695 cmd_variable_handler_register(bgp_var_neighbor
);
18696 cmd_variable_handler_register(bgp_var_peergroup
);
18698 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18700 /* Install bgp top node. */
18701 install_node(&bgp_node
);
18702 install_node(&bgp_ipv4_unicast_node
);
18703 install_node(&bgp_ipv4_multicast_node
);
18704 install_node(&bgp_ipv4_labeled_unicast_node
);
18705 install_node(&bgp_ipv6_unicast_node
);
18706 install_node(&bgp_ipv6_multicast_node
);
18707 install_node(&bgp_ipv6_labeled_unicast_node
);
18708 install_node(&bgp_vpnv4_node
);
18709 install_node(&bgp_vpnv6_node
);
18710 install_node(&bgp_evpn_node
);
18711 install_node(&bgp_evpn_vni_node
);
18712 install_node(&bgp_flowspecv4_node
);
18713 install_node(&bgp_flowspecv6_node
);
18714 install_node(&bgp_srv6_node
);
18716 /* Install default VTY commands to new nodes. */
18717 install_default(BGP_NODE
);
18718 install_default(BGP_IPV4_NODE
);
18719 install_default(BGP_IPV4M_NODE
);
18720 install_default(BGP_IPV4L_NODE
);
18721 install_default(BGP_IPV6_NODE
);
18722 install_default(BGP_IPV6M_NODE
);
18723 install_default(BGP_IPV6L_NODE
);
18724 install_default(BGP_VPNV4_NODE
);
18725 install_default(BGP_VPNV6_NODE
);
18726 install_default(BGP_FLOWSPECV4_NODE
);
18727 install_default(BGP_FLOWSPECV6_NODE
);
18728 install_default(BGP_EVPN_NODE
);
18729 install_default(BGP_EVPN_VNI_NODE
);
18730 install_default(BGP_SRV6_NODE
);
18732 /* "global bgp inq-limit command */
18733 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18734 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18735 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18736 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18738 /* "bgp local-mac" hidden commands. */
18739 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18740 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18742 /* "bgp suppress-fib-pending" global */
18743 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18745 /* bgp route-map delay-timer commands. */
18746 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18747 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18749 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18751 /* bgp fast-convergence command */
18752 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18753 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18755 /* global bgp update-delay command */
18756 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18757 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18759 /* global bgp graceful-shutdown command */
18760 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18761 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18763 /* Dummy commands (Currently not supported) */
18764 install_element(BGP_NODE
, &no_synchronization_cmd
);
18765 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18767 /* "router bgp" commands. */
18768 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18770 /* "no router bgp" commands. */
18771 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18773 /* "bgp session-dscp command */
18774 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18775 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18777 /* "bgp router-id" commands. */
18778 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18779 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18781 /* "bgp suppress-fib-pending" command */
18782 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18784 /* "bgp cluster-id" commands. */
18785 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18786 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18788 /* "bgp no-rib" commands. */
18789 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18790 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18792 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18794 /* "bgp confederation" commands. */
18795 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18796 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18798 /* "bgp confederation peers" commands. */
18799 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18800 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18802 /* bgp max-med command */
18803 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18804 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18805 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18806 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18807 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18809 /* "neighbor role" commands. */
18810 install_element(BGP_NODE
, &neighbor_role_cmd
);
18811 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18812 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18814 /* "neighbor aigp" commands. */
18815 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18817 /* "neighbor graceful-shutdown" command */
18818 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18820 /* bgp disable-ebgp-connected-nh-check */
18821 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18822 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18824 /* bgp update-delay command */
18825 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18826 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18828 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18829 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18831 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18832 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18834 /* "maximum-paths" commands. */
18835 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18836 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18837 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18838 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18839 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18840 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18841 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18842 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18843 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18844 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18845 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18846 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18847 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18848 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18849 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18851 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18852 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18853 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18854 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18855 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18856 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18857 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18858 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18859 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18860 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18862 /* "timers bgp" commands. */
18863 install_element(BGP_NODE
, &bgp_timers_cmd
);
18864 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18866 /* "minimum-holdtime" commands. */
18867 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18868 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18870 /* route-map delay-timer commands - per instance for backwards compat.
18872 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18873 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18875 /* "bgp client-to-client reflection" commands */
18876 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18877 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18879 /* "bgp always-compare-med" commands */
18880 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18881 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18883 /* bgp ebgp-requires-policy */
18884 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18885 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18887 /* bgp suppress-duplicates */
18888 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18889 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18891 /* bgp reject-as-sets */
18892 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18893 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18895 /* "bgp deterministic-med" commands */
18896 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18897 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18899 /* "bgp graceful-restart" command */
18900 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18901 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18903 /* "bgp graceful-restart-disable" command */
18904 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18905 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18907 /* "neighbor a:b:c:d graceful-restart" command */
18908 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18909 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18911 /* "neighbor a:b:c:d graceful-restart-disable" command */
18912 install_element(BGP_NODE
,
18913 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18914 install_element(BGP_NODE
,
18915 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18917 /* "neighbor a:b:c:d graceful-restart-helper" command */
18918 install_element(BGP_NODE
,
18919 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18920 install_element(BGP_NODE
,
18921 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18923 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18924 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18925 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18926 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18927 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18928 install_element(BGP_NODE
,
18929 &no_bgp_graceful_restart_select_defer_time_cmd
);
18930 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18931 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18932 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18934 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18935 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18936 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18937 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18939 /* "bgp graceful-shutdown" commands */
18940 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18941 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18943 /* "bgp hard-administrative-reset" commands */
18944 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18946 /* "bgp long-lived-graceful-restart" commands */
18947 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18948 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18950 /* "bgp fast-external-failover" commands */
18951 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18952 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18954 /* "bgp bestpath aigp" commands */
18955 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
18957 /* "bgp bestpath compare-routerid" commands */
18958 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18959 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18961 /* "bgp bestpath as-path ignore" commands */
18962 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18963 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18965 /* "bgp bestpath as-path confed" commands */
18966 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18967 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18969 /* "bgp bestpath as-path multipath-relax" commands */
18970 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18971 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18973 /* "bgp bestpath peer-type multipath-relax" commands */
18974 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18975 install_element(BGP_NODE
,
18976 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18978 /* "bgp log-neighbor-changes" commands */
18979 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18980 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18982 /* "bgp bestpath med" commands */
18983 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18984 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18986 /* "bgp bestpath bandwidth" commands */
18987 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18988 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18990 /* "no bgp default <afi>-<safi>" commands. */
18991 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18993 /* "bgp network import-check" commands. */
18994 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18995 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18996 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18998 /* "bgp default local-preference" commands. */
18999 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19000 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19002 /* bgp default show-hostname */
19003 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19004 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19006 /* bgp default show-nexthop-hostname */
19007 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19008 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19010 /* "bgp default subgroup-pkt-queue-max" commands. */
19011 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19012 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19014 /* bgp ibgp-allow-policy-mods command */
19015 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19016 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19018 /* "bgp listen limit" commands. */
19019 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19020 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19022 /* "bgp listen range" commands. */
19023 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19024 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19026 /* "bgp default shutdown" command */
19027 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19029 /* "bgp shutdown" commands */
19030 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19031 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19032 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19033 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19035 /* "neighbor remote-as" commands. */
19036 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19037 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19038 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19039 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19040 install_element(BGP_NODE
,
19041 &neighbor_interface_v6only_config_remote_as_cmd
);
19042 install_element(BGP_NODE
, &no_neighbor_cmd
);
19043 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19045 /* "neighbor peer-group" commands. */
19046 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19047 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19048 install_element(BGP_NODE
,
19049 &no_neighbor_interface_peer_group_remote_as_cmd
);
19051 /* "neighbor local-as" commands. */
19052 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19053 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19054 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19055 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19057 /* "neighbor solo" commands. */
19058 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19059 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19061 /* "neighbor password" commands. */
19062 install_element(BGP_NODE
, &neighbor_password_cmd
);
19063 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19065 /* "neighbor activate" commands. */
19066 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19067 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19068 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19069 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19070 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19071 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19072 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19073 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19075 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19076 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19077 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19079 /* "no neighbor activate" commands. */
19080 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19081 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19082 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19083 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19084 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19085 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19086 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19087 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19088 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19089 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19090 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19091 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19093 /* "neighbor peer-group" set commands. */
19094 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19095 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19096 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19097 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19098 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19099 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19100 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19101 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19102 install_element(BGP_FLOWSPECV4_NODE
,
19103 &neighbor_set_peer_group_hidden_cmd
);
19104 install_element(BGP_FLOWSPECV6_NODE
,
19105 &neighbor_set_peer_group_hidden_cmd
);
19107 /* "no neighbor peer-group unset" commands. */
19108 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19109 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19110 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19111 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19112 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19113 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19114 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19115 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19116 install_element(BGP_FLOWSPECV4_NODE
,
19117 &no_neighbor_set_peer_group_hidden_cmd
);
19118 install_element(BGP_FLOWSPECV6_NODE
,
19119 &no_neighbor_set_peer_group_hidden_cmd
);
19121 /* "neighbor softreconfiguration inbound" commands.*/
19122 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19123 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19124 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19125 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19126 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19127 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19128 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19129 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19130 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19131 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19132 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19133 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19134 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19135 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19136 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19137 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19138 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19139 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19140 install_element(BGP_FLOWSPECV4_NODE
,
19141 &neighbor_soft_reconfiguration_cmd
);
19142 install_element(BGP_FLOWSPECV4_NODE
,
19143 &no_neighbor_soft_reconfiguration_cmd
);
19144 install_element(BGP_FLOWSPECV6_NODE
,
19145 &neighbor_soft_reconfiguration_cmd
);
19146 install_element(BGP_FLOWSPECV6_NODE
,
19147 &no_neighbor_soft_reconfiguration_cmd
);
19148 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19149 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19151 /* "neighbor attribute-unchanged" commands. */
19152 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19153 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19154 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19155 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19156 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19157 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19158 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19159 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19160 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19161 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19162 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19163 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19164 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19165 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19166 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19167 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19168 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19169 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19171 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19172 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19174 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19175 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19176 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19177 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19179 /* "nexthop-local unchanged" commands */
19180 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19181 install_element(BGP_IPV6_NODE
,
19182 &no_neighbor_nexthop_local_unchanged_cmd
);
19184 /* "neighbor next-hop-self" commands. */
19185 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19186 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19187 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19188 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19189 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19190 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19191 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19192 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19193 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19194 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19195 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19196 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19197 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19198 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19199 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19200 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19201 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19202 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19203 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19204 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19206 /* "neighbor next-hop-self force" commands. */
19207 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19208 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19209 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19210 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19211 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19212 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19213 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19214 install_element(BGP_IPV4_NODE
,
19215 &no_neighbor_nexthop_self_all_hidden_cmd
);
19216 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19217 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19218 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19219 install_element(BGP_IPV4M_NODE
,
19220 &no_neighbor_nexthop_self_all_hidden_cmd
);
19221 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19222 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19223 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19224 install_element(BGP_IPV4L_NODE
,
19225 &no_neighbor_nexthop_self_all_hidden_cmd
);
19226 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19227 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19228 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19229 install_element(BGP_IPV6_NODE
,
19230 &no_neighbor_nexthop_self_all_hidden_cmd
);
19231 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19232 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19233 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19234 install_element(BGP_IPV6M_NODE
,
19235 &no_neighbor_nexthop_self_all_hidden_cmd
);
19236 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19237 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19238 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19239 install_element(BGP_IPV6L_NODE
,
19240 &no_neighbor_nexthop_self_all_hidden_cmd
);
19241 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19242 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19243 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19244 install_element(BGP_VPNV4_NODE
,
19245 &no_neighbor_nexthop_self_all_hidden_cmd
);
19246 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19247 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19248 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19249 install_element(BGP_VPNV6_NODE
,
19250 &no_neighbor_nexthop_self_all_hidden_cmd
);
19251 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19252 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19254 /* "neighbor as-override" commands. */
19255 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19256 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19257 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19258 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19259 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19260 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19261 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19262 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19263 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19264 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19265 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19266 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19267 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19268 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19269 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19270 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19271 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19272 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19274 /* "neighbor remove-private-AS" commands. */
19275 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19276 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19277 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19278 install_element(BGP_NODE
,
19279 &no_neighbor_remove_private_as_all_hidden_cmd
);
19280 install_element(BGP_NODE
,
19281 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19282 install_element(BGP_NODE
,
19283 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19284 install_element(BGP_NODE
,
19285 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19288 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19289 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19290 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19291 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19292 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19293 install_element(BGP_IPV4_NODE
,
19294 &neighbor_remove_private_as_replace_as_cmd
);
19295 install_element(BGP_IPV4_NODE
,
19296 &no_neighbor_remove_private_as_replace_as_cmd
);
19297 install_element(BGP_IPV4_NODE
,
19298 &neighbor_remove_private_as_all_replace_as_cmd
);
19299 install_element(BGP_IPV4_NODE
,
19300 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19301 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19302 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19303 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19304 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19305 install_element(BGP_IPV4M_NODE
,
19306 &neighbor_remove_private_as_replace_as_cmd
);
19307 install_element(BGP_IPV4M_NODE
,
19308 &no_neighbor_remove_private_as_replace_as_cmd
);
19309 install_element(BGP_IPV4M_NODE
,
19310 &neighbor_remove_private_as_all_replace_as_cmd
);
19311 install_element(BGP_IPV4M_NODE
,
19312 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19313 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19314 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19315 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19316 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19317 install_element(BGP_IPV4L_NODE
,
19318 &neighbor_remove_private_as_replace_as_cmd
);
19319 install_element(BGP_IPV4L_NODE
,
19320 &no_neighbor_remove_private_as_replace_as_cmd
);
19321 install_element(BGP_IPV4L_NODE
,
19322 &neighbor_remove_private_as_all_replace_as_cmd
);
19323 install_element(BGP_IPV4L_NODE
,
19324 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19325 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19326 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19327 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19328 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19329 install_element(BGP_IPV6_NODE
,
19330 &neighbor_remove_private_as_replace_as_cmd
);
19331 install_element(BGP_IPV6_NODE
,
19332 &no_neighbor_remove_private_as_replace_as_cmd
);
19333 install_element(BGP_IPV6_NODE
,
19334 &neighbor_remove_private_as_all_replace_as_cmd
);
19335 install_element(BGP_IPV6_NODE
,
19336 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19337 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19338 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19339 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19340 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19341 install_element(BGP_IPV6M_NODE
,
19342 &neighbor_remove_private_as_replace_as_cmd
);
19343 install_element(BGP_IPV6M_NODE
,
19344 &no_neighbor_remove_private_as_replace_as_cmd
);
19345 install_element(BGP_IPV6M_NODE
,
19346 &neighbor_remove_private_as_all_replace_as_cmd
);
19347 install_element(BGP_IPV6M_NODE
,
19348 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19349 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19350 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19351 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19352 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19353 install_element(BGP_IPV6L_NODE
,
19354 &neighbor_remove_private_as_replace_as_cmd
);
19355 install_element(BGP_IPV6L_NODE
,
19356 &no_neighbor_remove_private_as_replace_as_cmd
);
19357 install_element(BGP_IPV6L_NODE
,
19358 &neighbor_remove_private_as_all_replace_as_cmd
);
19359 install_element(BGP_IPV6L_NODE
,
19360 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19361 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19362 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19363 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19364 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19365 install_element(BGP_VPNV4_NODE
,
19366 &neighbor_remove_private_as_replace_as_cmd
);
19367 install_element(BGP_VPNV4_NODE
,
19368 &no_neighbor_remove_private_as_replace_as_cmd
);
19369 install_element(BGP_VPNV4_NODE
,
19370 &neighbor_remove_private_as_all_replace_as_cmd
);
19371 install_element(BGP_VPNV4_NODE
,
19372 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19373 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19374 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19375 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19376 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19377 install_element(BGP_VPNV6_NODE
,
19378 &neighbor_remove_private_as_replace_as_cmd
);
19379 install_element(BGP_VPNV6_NODE
,
19380 &no_neighbor_remove_private_as_replace_as_cmd
);
19381 install_element(BGP_VPNV6_NODE
,
19382 &neighbor_remove_private_as_all_replace_as_cmd
);
19383 install_element(BGP_VPNV6_NODE
,
19384 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19386 /* "neighbor send-community" commands.*/
19387 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19388 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19389 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19390 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19391 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19392 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19393 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19394 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19395 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19396 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19397 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19398 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19399 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19400 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19401 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19402 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19403 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19404 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19405 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19406 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19407 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19408 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19409 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19410 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19411 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19412 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19413 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19414 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19415 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19416 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19417 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19418 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19419 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19420 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19421 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19422 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19424 /* "neighbor route-reflector" commands.*/
19425 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19426 install_element(BGP_NODE
,
19427 &no_neighbor_route_reflector_client_hidden_cmd
);
19428 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19429 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19430 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19431 install_element(BGP_IPV4M_NODE
,
19432 &no_neighbor_route_reflector_client_cmd
);
19433 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19434 install_element(BGP_IPV4L_NODE
,
19435 &no_neighbor_route_reflector_client_cmd
);
19436 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19437 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19438 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19439 install_element(BGP_IPV6M_NODE
,
19440 &no_neighbor_route_reflector_client_cmd
);
19441 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19442 install_element(BGP_IPV6L_NODE
,
19443 &no_neighbor_route_reflector_client_cmd
);
19444 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19445 install_element(BGP_VPNV4_NODE
,
19446 &no_neighbor_route_reflector_client_cmd
);
19447 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19448 install_element(BGP_VPNV6_NODE
,
19449 &no_neighbor_route_reflector_client_cmd
);
19450 install_element(BGP_FLOWSPECV4_NODE
,
19451 &neighbor_route_reflector_client_cmd
);
19452 install_element(BGP_FLOWSPECV4_NODE
,
19453 &no_neighbor_route_reflector_client_cmd
);
19454 install_element(BGP_FLOWSPECV6_NODE
,
19455 &neighbor_route_reflector_client_cmd
);
19456 install_element(BGP_FLOWSPECV6_NODE
,
19457 &no_neighbor_route_reflector_client_cmd
);
19458 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19459 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19461 /* "neighbor route-server" commands.*/
19462 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19463 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19464 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19465 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19466 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19467 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19468 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19469 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19470 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19471 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19472 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19473 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19474 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19475 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19476 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19477 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19478 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19479 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19480 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19481 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19482 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19483 install_element(BGP_FLOWSPECV4_NODE
,
19484 &no_neighbor_route_server_client_cmd
);
19485 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19486 install_element(BGP_FLOWSPECV6_NODE
,
19487 &no_neighbor_route_server_client_cmd
);
19489 /* "neighbor disable-addpath-rx" commands. */
19490 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19491 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19492 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19493 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19494 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19495 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19496 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19497 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19498 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19499 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19500 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19501 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19502 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19503 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19504 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19505 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19507 /* "neighbor addpath-tx-all-paths" commands.*/
19508 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19509 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19510 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19511 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19512 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19513 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19514 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19515 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19516 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19517 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19518 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19519 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19520 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19521 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19522 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19523 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19524 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19525 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19527 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19528 install_element(BGP_NODE
,
19529 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19530 install_element(BGP_NODE
,
19531 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19532 install_element(BGP_IPV4_NODE
,
19533 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19534 install_element(BGP_IPV4_NODE
,
19535 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19536 install_element(BGP_IPV4M_NODE
,
19537 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19538 install_element(BGP_IPV4M_NODE
,
19539 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19540 install_element(BGP_IPV4L_NODE
,
19541 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19542 install_element(BGP_IPV4L_NODE
,
19543 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19544 install_element(BGP_IPV6_NODE
,
19545 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19546 install_element(BGP_IPV6_NODE
,
19547 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19548 install_element(BGP_IPV6M_NODE
,
19549 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19550 install_element(BGP_IPV6M_NODE
,
19551 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19552 install_element(BGP_IPV6L_NODE
,
19553 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19554 install_element(BGP_IPV6L_NODE
,
19555 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19556 install_element(BGP_VPNV4_NODE
,
19557 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19558 install_element(BGP_VPNV4_NODE
,
19559 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19560 install_element(BGP_VPNV6_NODE
,
19561 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19562 install_element(BGP_VPNV6_NODE
,
19563 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19565 /* "neighbor sender-as-path-loop-detection" commands. */
19566 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19567 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19569 /* "neighbor path-attribute discard" commands. */
19570 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19571 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19573 /* "neighbor passive" commands. */
19574 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19575 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19578 /* "neighbor shutdown" commands. */
19579 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19580 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19581 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19582 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19583 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19584 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19586 /* "neighbor capability extended-nexthop" commands.*/
19587 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19588 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19590 /* "neighbor capability orf prefix-list" commands.*/
19591 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19592 install_element(BGP_NODE
,
19593 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19594 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19595 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19596 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19597 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19598 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19599 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19600 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19601 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19602 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19603 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19604 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19605 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19607 /* "neighbor capability dynamic" commands.*/
19608 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19609 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19611 /* "neighbor dont-capability-negotiate" commands. */
19612 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19613 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19615 /* "neighbor ebgp-multihop" commands. */
19616 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19617 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19618 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19620 /* "neighbor disable-connected-check" commands. */
19621 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19622 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19624 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19625 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19626 install_element(BGP_NODE
,
19627 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19629 /* "neighbor extended-optional-parameters" commands. */
19630 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19631 install_element(BGP_NODE
,
19632 &no_neighbor_extended_optional_parameters_cmd
);
19634 /* "neighbor enforce-first-as" commands. */
19635 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19636 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19638 /* "neighbor description" commands. */
19639 install_element(BGP_NODE
, &neighbor_description_cmd
);
19640 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19641 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19643 /* "neighbor update-source" commands. "*/
19644 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19645 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19647 /* "neighbor default-originate" commands. */
19648 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19649 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19650 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19651 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19652 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19653 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19654 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19655 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19656 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19657 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19658 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19659 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19660 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19661 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19662 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19663 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19664 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19665 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19666 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19667 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19668 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19670 /* "neighbor port" commands. */
19671 install_element(BGP_NODE
, &neighbor_port_cmd
);
19672 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19674 /* "neighbor weight" commands. */
19675 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19676 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19678 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19679 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19680 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19681 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19682 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19683 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19684 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19685 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19686 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19687 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19688 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19689 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19690 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19691 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19692 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19693 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19695 /* "neighbor override-capability" commands. */
19696 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19697 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19699 /* "neighbor strict-capability-match" commands. */
19700 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19701 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19703 /* "neighbor timers" commands. */
19704 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19705 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19707 /* "neighbor timers connect" commands. */
19708 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19709 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19711 /* "neighbor timers delayopen" commands. */
19712 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19713 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19715 /* "neighbor advertisement-interval" commands. */
19716 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19717 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19719 /* "neighbor interface" commands. */
19720 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19721 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19723 /* "neighbor distribute" commands. */
19724 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19725 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19726 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19727 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19728 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19729 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19730 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19731 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19732 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19733 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19734 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19735 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19736 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19737 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19738 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19739 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19740 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19741 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19743 /* "neighbor prefix-list" commands. */
19744 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19745 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19746 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19747 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19748 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19749 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19750 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19751 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19752 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19753 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19754 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19755 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19756 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19757 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19758 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19759 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19760 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19761 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19762 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19763 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19764 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19765 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19767 /* "neighbor filter-list" commands. */
19768 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19769 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19770 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19771 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19772 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19773 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19774 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19775 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19776 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19777 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19778 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19779 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19780 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19781 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19782 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19783 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19784 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19785 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19786 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19787 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19788 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19789 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19791 /* "neighbor route-map" commands. */
19792 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19793 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19794 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19795 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19796 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19797 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19798 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19799 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19800 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19801 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19802 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19803 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19804 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19805 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19806 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19807 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19808 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19809 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19810 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19811 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19812 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19813 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19814 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19815 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19817 /* "neighbor unsuppress-map" commands. */
19818 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19819 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19820 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19821 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19822 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19823 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19824 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19825 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19826 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19827 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19828 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19829 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19830 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19831 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19832 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19833 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19834 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19835 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19837 /* "neighbor advertise-map" commands. */
19838 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19839 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19840 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19841 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19842 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19843 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19844 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19845 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19846 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19847 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19849 /* neighbor maximum-prefix-out commands. */
19850 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19851 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19852 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19853 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19854 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19855 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19856 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19857 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19858 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19859 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19860 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19861 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19862 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19863 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19864 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19865 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19866 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19867 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19869 /* "neighbor maximum-prefix" commands. */
19870 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19871 install_element(BGP_NODE
,
19872 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19873 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19874 install_element(BGP_NODE
,
19875 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19876 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19877 install_element(BGP_NODE
,
19878 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19879 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19880 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19881 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19882 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19883 install_element(BGP_IPV4_NODE
,
19884 &neighbor_maximum_prefix_threshold_warning_cmd
);
19885 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19886 install_element(BGP_IPV4_NODE
,
19887 &neighbor_maximum_prefix_threshold_restart_cmd
);
19888 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19889 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19890 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19891 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19892 install_element(BGP_IPV4M_NODE
,
19893 &neighbor_maximum_prefix_threshold_warning_cmd
);
19894 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19895 install_element(BGP_IPV4M_NODE
,
19896 &neighbor_maximum_prefix_threshold_restart_cmd
);
19897 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19898 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19899 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19900 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19901 install_element(BGP_IPV4L_NODE
,
19902 &neighbor_maximum_prefix_threshold_warning_cmd
);
19903 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19904 install_element(BGP_IPV4L_NODE
,
19905 &neighbor_maximum_prefix_threshold_restart_cmd
);
19906 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19907 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19908 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19909 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19910 install_element(BGP_IPV6_NODE
,
19911 &neighbor_maximum_prefix_threshold_warning_cmd
);
19912 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19913 install_element(BGP_IPV6_NODE
,
19914 &neighbor_maximum_prefix_threshold_restart_cmd
);
19915 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19916 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19917 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19918 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19919 install_element(BGP_IPV6M_NODE
,
19920 &neighbor_maximum_prefix_threshold_warning_cmd
);
19921 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19922 install_element(BGP_IPV6M_NODE
,
19923 &neighbor_maximum_prefix_threshold_restart_cmd
);
19924 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19925 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19926 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19927 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19928 install_element(BGP_IPV6L_NODE
,
19929 &neighbor_maximum_prefix_threshold_warning_cmd
);
19930 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19931 install_element(BGP_IPV6L_NODE
,
19932 &neighbor_maximum_prefix_threshold_restart_cmd
);
19933 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19934 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19935 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19936 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19937 install_element(BGP_VPNV4_NODE
,
19938 &neighbor_maximum_prefix_threshold_warning_cmd
);
19939 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19940 install_element(BGP_VPNV4_NODE
,
19941 &neighbor_maximum_prefix_threshold_restart_cmd
);
19942 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19943 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19944 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19945 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19946 install_element(BGP_VPNV6_NODE
,
19947 &neighbor_maximum_prefix_threshold_warning_cmd
);
19948 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19949 install_element(BGP_VPNV6_NODE
,
19950 &neighbor_maximum_prefix_threshold_restart_cmd
);
19951 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19953 /* "neighbor allowas-in" */
19954 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19955 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19956 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19957 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19958 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19959 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19960 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19961 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19962 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19963 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19964 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19965 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19966 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19967 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19968 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19969 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19970 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19971 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19972 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19973 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19975 /* neighbor accept-own */
19976 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19977 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19979 /* "neighbor soo" */
19980 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19981 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19982 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19983 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19984 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19985 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19986 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19987 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19988 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19989 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19990 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19991 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19992 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19993 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19994 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19995 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19996 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19997 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19999 /* address-family commands. */
20000 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20001 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20002 #ifdef KEEP_OLD_VPN_COMMANDS
20003 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20004 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20005 #endif /* KEEP_OLD_VPN_COMMANDS */
20007 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20009 /* "exit-address-family" command. */
20010 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20011 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20012 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20013 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20014 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20015 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20016 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20017 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20018 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20019 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20020 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20022 /* BGP retain all route-target */
20023 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20024 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20026 /* "clear ip bgp commands" */
20027 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20029 /* clear ip bgp prefix */
20030 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20031 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20032 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20034 /* "show [ip] bgp summary" commands. */
20035 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20036 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20037 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20038 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20039 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20040 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20041 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20043 /* "show [ip] bgp neighbors" commands. */
20044 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20046 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20048 /* "show [ip] bgp peer-group" commands. */
20049 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20051 /* "show [ip] bgp paths" commands. */
20052 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20054 /* "show [ip] bgp community" commands. */
20055 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20057 /* "show ip bgp large-community" commands. */
20058 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20059 /* "show [ip] bgp attribute-info" commands. */
20060 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20061 /* "show [ip] bgp route-leak" command */
20062 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20064 /* "redistribute" commands. */
20065 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20066 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20067 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20068 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20069 install_element(BGP_NODE
,
20070 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20071 install_element(BGP_NODE
,
20072 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20073 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20074 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20075 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20076 install_element(BGP_NODE
,
20077 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20078 install_element(BGP_NODE
,
20079 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20080 install_element(BGP_NODE
,
20081 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20082 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20083 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20084 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20085 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20086 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20087 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20088 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20089 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20090 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20091 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20092 install_element(BGP_IPV4_NODE
,
20093 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20094 install_element(BGP_IPV4_NODE
,
20095 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20096 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20097 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20098 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20099 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20100 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20101 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20103 /* import|export vpn [route-map RMAP_NAME] */
20104 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20105 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20107 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20108 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20110 /* ttl_security commands */
20111 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20112 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20114 /* "bgp tcp-keepalive" commands */
20115 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20116 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20118 /* "show [ip] bgp memory" commands. */
20119 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20121 /* "show bgp martian next-hop" */
20122 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20124 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20126 /* "show [ip] bgp views" commands. */
20127 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20129 /* "show [ip] bgp vrfs" commands. */
20130 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20132 /* Community-list. */
20133 community_list_vty();
20135 community_alias_vty();
20137 /* vpn-policy commands */
20138 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20139 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20140 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20141 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20142 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20143 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20144 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20145 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20146 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20147 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20148 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20149 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20151 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20152 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20154 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20155 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20156 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20157 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20158 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20159 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20160 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20161 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20162 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20163 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20165 /* tcp-mss command */
20166 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20167 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20169 /* srv6 commands */
20170 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20171 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20172 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20173 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20174 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20175 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20176 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20177 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20178 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20183 #include "memory.h"
20184 #include "bgp_regex.h"
20185 #include "bgp_clist.h"
20186 #include "bgp_ecommunity.h"
20188 /* VTY functions. */
20190 /* Direction value to string conversion. */
20191 static const char *community_direct_str(int direct
)
20194 case COMMUNITY_DENY
:
20196 case COMMUNITY_PERMIT
:
20203 /* Display error string. */
20204 static void community_list_perror(struct vty
*vty
, int ret
)
20207 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20208 vty_out(vty
, "%% Can't find community-list\n");
20210 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20211 vty_out(vty
, "%% Malformed community-list value\n");
20213 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20215 "%% Community name conflict, previously defined as standard community\n");
20217 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20219 "%% Community name conflict, previously defined as expanded community\n");
20224 /* "community-list" keyword help string. */
20225 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20227 /*community-list standard */
20228 DEFUN (community_list_standard
,
20229 bgp_community_list_standard_cmd
,
20230 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20233 "Community list number (standard)\n"
20234 "Add an standard community-list entry\n"
20235 "Community list name\n"
20236 "Sequence number of an entry\n"
20237 "Sequence number\n"
20238 "Specify community to reject\n"
20239 "Specify community to accept\n"
20242 char *cl_name_or_number
= NULL
;
20245 int style
= COMMUNITY_LIST_STANDARD
;
20248 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20249 seq
= argv
[idx
]->arg
;
20252 argv_find(argv
, argc
, "(1-99)", &idx
);
20253 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20254 cl_name_or_number
= argv
[idx
]->arg
;
20255 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20257 argv_find(argv
, argc
, "AA:NN", &idx
);
20258 char *str
= argv_concat(argv
, argc
, idx
);
20260 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20263 XFREE(MTYPE_TMP
, str
);
20266 /* Display error string. */
20267 community_list_perror(vty
, ret
);
20268 return CMD_WARNING_CONFIG_FAILED
;
20271 return CMD_SUCCESS
;
20274 DEFUN (no_community_list_standard_all
,
20275 no_bgp_community_list_standard_all_cmd
,
20276 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20280 "Community list number (standard)\n"
20281 "Add an standard community-list entry\n"
20282 "Community list name\n"
20283 "Sequence number of an entry\n"
20284 "Sequence number\n"
20285 "Specify community to reject\n"
20286 "Specify community to accept\n"
20289 char *cl_name_or_number
= NULL
;
20292 int style
= COMMUNITY_LIST_STANDARD
;
20296 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20297 seq
= argv
[idx
]->arg
;
20300 argv_find(argv
, argc
, "permit", &idx
);
20301 argv_find(argv
, argc
, "deny", &idx
);
20304 direct
= argv_find(argv
, argc
, "permit", &idx
)
20309 argv_find(argv
, argc
, "AA:NN", &idx
);
20310 str
= argv_concat(argv
, argc
, idx
);
20314 argv_find(argv
, argc
, "(1-99)", &idx
);
20315 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20316 cl_name_or_number
= argv
[idx
]->arg
;
20318 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20321 XFREE(MTYPE_TMP
, str
);
20324 community_list_perror(vty
, ret
);
20325 return CMD_WARNING_CONFIG_FAILED
;
20328 return CMD_SUCCESS
;
20331 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20332 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20333 NO_STR BGP_STR COMMUNITY_LIST_STR
20334 "Community list number (standard)\n"
20335 "Add an standard community-list entry\n"
20336 "Community list name\n")
20338 /*community-list expanded */
20339 DEFUN (community_list_expanded_all
,
20340 bgp_community_list_expanded_all_cmd
,
20341 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20344 "Community list number (expanded)\n"
20345 "Add an expanded community-list entry\n"
20346 "Community list name\n"
20347 "Sequence number of an entry\n"
20348 "Sequence number\n"
20349 "Specify community to reject\n"
20350 "Specify community to accept\n"
20353 char *cl_name_or_number
= NULL
;
20356 int style
= COMMUNITY_LIST_EXPANDED
;
20359 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20360 seq
= argv
[idx
]->arg
;
20364 argv_find(argv
, argc
, "(100-500)", &idx
);
20365 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20366 cl_name_or_number
= argv
[idx
]->arg
;
20367 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20369 argv_find(argv
, argc
, "AA:NN", &idx
);
20370 char *str
= argv_concat(argv
, argc
, idx
);
20372 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20375 XFREE(MTYPE_TMP
, str
);
20378 /* Display error string. */
20379 community_list_perror(vty
, ret
);
20380 return CMD_WARNING_CONFIG_FAILED
;
20383 return CMD_SUCCESS
;
20386 DEFUN (no_community_list_expanded_all
,
20387 no_bgp_community_list_expanded_all_cmd
,
20388 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20392 "Community list number (expanded)\n"
20393 "Add an expanded community-list entry\n"
20394 "Community list name\n"
20395 "Sequence number of an entry\n"
20396 "Sequence number\n"
20397 "Specify community to reject\n"
20398 "Specify community to accept\n"
20401 char *cl_name_or_number
= NULL
;
20405 int style
= COMMUNITY_LIST_EXPANDED
;
20408 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20409 seq
= argv
[idx
]->arg
;
20412 argv_find(argv
, argc
, "permit", &idx
);
20413 argv_find(argv
, argc
, "deny", &idx
);
20416 direct
= argv_find(argv
, argc
, "permit", &idx
)
20421 argv_find(argv
, argc
, "AA:NN", &idx
);
20422 str
= argv_concat(argv
, argc
, idx
);
20426 argv_find(argv
, argc
, "(100-500)", &idx
);
20427 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20428 cl_name_or_number
= argv
[idx
]->arg
;
20430 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20433 XFREE(MTYPE_TMP
, str
);
20436 community_list_perror(vty
, ret
);
20437 return CMD_WARNING_CONFIG_FAILED
;
20440 return CMD_SUCCESS
;
20443 ALIAS(no_community_list_expanded_all
,
20444 no_bgp_community_list_expanded_all_list_cmd
,
20445 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20446 NO_STR BGP_STR COMMUNITY_LIST_STR
20447 "Community list number (expanded)\n"
20448 "Add an expanded community-list entry\n"
20449 "Community list name\n")
20451 /* Return configuration string of community-list entry. */
20452 static const char *community_list_config_str(struct community_entry
*entry
)
20459 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20460 str
= community_str(entry
->u
.com
, false, false);
20461 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20462 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20464 str
= entry
->config
;
20469 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20471 struct community_entry
*entry
;
20473 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20474 if (entry
== list
->head
) {
20475 if (all_digit(list
->name
))
20476 vty_out(vty
, "Community %s list %s\n",
20477 entry
->style
== COMMUNITY_LIST_STANDARD
20479 : "(expanded) access",
20482 vty_out(vty
, "Named Community %s list %s\n",
20483 entry
->style
== COMMUNITY_LIST_STANDARD
20489 vty_out(vty
, " %s\n",
20490 community_direct_str(entry
->direct
));
20492 vty_out(vty
, " %s %s\n",
20493 community_direct_str(entry
->direct
),
20494 community_list_config_str(entry
));
20498 DEFUN (show_community_list
,
20499 show_bgp_community_list_cmd
,
20500 "show bgp community-list",
20503 "List community-list\n")
20505 struct community_list
*list
;
20506 struct community_list_master
*cm
;
20508 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20510 return CMD_SUCCESS
;
20512 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20513 community_list_show(vty
, list
);
20515 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20516 community_list_show(vty
, list
);
20518 return CMD_SUCCESS
;
20521 DEFUN (show_community_list_arg
,
20522 show_bgp_community_list_arg_cmd
,
20523 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20526 "List community-list\n"
20527 "Community-list number\n"
20528 "Community-list name\n"
20529 "Detailed information on community-list\n")
20531 int idx_comm_list
= 3;
20532 struct community_list
*list
;
20534 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20535 COMMUNITY_LIST_MASTER
);
20537 vty_out(vty
, "%% Can't find community-list\n");
20538 return CMD_WARNING
;
20541 community_list_show(vty
, list
);
20543 return CMD_SUCCESS
;
20547 * Large Community code.
20549 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20550 struct cmd_token
**argv
, int style
,
20551 int reject_all_digit_name
)
20560 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20561 seq
= argv
[idx
]->arg
;
20564 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20567 /* All digit name check. */
20569 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20570 argv_find(argv
, argc
, "(1-99)", &idx
);
20571 argv_find(argv
, argc
, "(100-500)", &idx
);
20572 cl_name
= argv
[idx
]->arg
;
20573 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20574 vty_out(vty
, "%% Community name cannot have all digits\n");
20575 return CMD_WARNING_CONFIG_FAILED
;
20579 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20580 argv_find(argv
, argc
, "LINE", &idx
);
20581 /* Concat community string argument. */
20583 str
= argv_concat(argv
, argc
, idx
);
20587 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20589 /* Free temporary community list string allocated by
20591 XFREE(MTYPE_TMP
, str
);
20594 community_list_perror(vty
, ret
);
20595 return CMD_WARNING_CONFIG_FAILED
;
20597 return CMD_SUCCESS
;
20600 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20601 struct cmd_token
**argv
, int style
)
20609 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20610 seq
= argv
[idx
]->arg
;
20613 argv_find(argv
, argc
, "permit", &idx
);
20614 argv_find(argv
, argc
, "deny", &idx
);
20617 /* Check the list direct. */
20618 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20619 direct
= COMMUNITY_PERMIT
;
20621 direct
= COMMUNITY_DENY
;
20624 argv_find(argv
, argc
, "LINE", &idx
);
20625 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20626 /* Concat community string argument. */
20627 str
= argv_concat(argv
, argc
, idx
);
20631 argv_find(argv
, argc
, "(1-99)", &idx
);
20632 argv_find(argv
, argc
, "(100-500)", &idx
);
20633 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20635 /* Unset community list. */
20636 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20639 /* Free temporary community list string allocated by
20641 XFREE(MTYPE_TMP
, str
);
20644 community_list_perror(vty
, ret
);
20645 return CMD_WARNING_CONFIG_FAILED
;
20648 return CMD_SUCCESS
;
20651 /* "large-community-list" keyword help string. */
20652 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20653 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20655 DEFUN (lcommunity_list_standard
,
20656 bgp_lcommunity_list_standard_cmd
,
20657 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20659 LCOMMUNITY_LIST_STR
20660 "Large Community list number (standard)\n"
20661 "Sequence number of an entry\n"
20662 "Sequence number\n"
20663 "Specify large community to reject\n"
20664 "Specify large community to accept\n"
20665 LCOMMUNITY_VAL_STR
)
20667 return lcommunity_list_set_vty(vty
, argc
, argv
,
20668 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20671 DEFUN (lcommunity_list_expanded
,
20672 bgp_lcommunity_list_expanded_cmd
,
20673 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20675 LCOMMUNITY_LIST_STR
20676 "Large Community list number (expanded)\n"
20677 "Sequence number of an entry\n"
20678 "Sequence number\n"
20679 "Specify large community to reject\n"
20680 "Specify large community to accept\n"
20681 "An ordered list as a regular-expression\n")
20683 return lcommunity_list_set_vty(vty
, argc
, argv
,
20684 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20687 DEFUN (lcommunity_list_name_standard
,
20688 bgp_lcommunity_list_name_standard_cmd
,
20689 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20691 LCOMMUNITY_LIST_STR
20692 "Specify standard large-community-list\n"
20693 "Large Community list name\n"
20694 "Sequence number of an entry\n"
20695 "Sequence number\n"
20696 "Specify large community to reject\n"
20697 "Specify large community to accept\n"
20698 LCOMMUNITY_VAL_STR
)
20700 return lcommunity_list_set_vty(vty
, argc
, argv
,
20701 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20704 DEFUN (lcommunity_list_name_expanded
,
20705 bgp_lcommunity_list_name_expanded_cmd
,
20706 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20708 LCOMMUNITY_LIST_STR
20709 "Specify expanded large-community-list\n"
20710 "Large Community list name\n"
20711 "Sequence number of an entry\n"
20712 "Sequence number\n"
20713 "Specify large community to reject\n"
20714 "Specify large community to accept\n"
20715 "An ordered list as a regular-expression\n")
20717 return lcommunity_list_set_vty(vty
, argc
, argv
,
20718 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20721 DEFUN (no_lcommunity_list_all
,
20722 no_bgp_lcommunity_list_all_cmd
,
20723 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20726 LCOMMUNITY_LIST_STR
20727 "Large Community list number (standard)\n"
20728 "Large Community list number (expanded)\n"
20729 "Large Community list name\n")
20731 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20732 LARGE_COMMUNITY_LIST_STANDARD
);
20735 DEFUN (no_lcommunity_list_name_standard_all
,
20736 no_bgp_lcommunity_list_name_standard_all_cmd
,
20737 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20740 LCOMMUNITY_LIST_STR
20741 "Specify standard large-community-list\n"
20742 "Large Community list name\n")
20744 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20745 LARGE_COMMUNITY_LIST_STANDARD
);
20748 DEFUN (no_lcommunity_list_name_expanded_all
,
20749 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20750 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20753 LCOMMUNITY_LIST_STR
20754 "Specify expanded large-community-list\n"
20755 "Large Community list name\n")
20757 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20758 LARGE_COMMUNITY_LIST_EXPANDED
);
20761 DEFUN (no_lcommunity_list_standard
,
20762 no_bgp_lcommunity_list_standard_cmd
,
20763 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20766 LCOMMUNITY_LIST_STR
20767 "Large Community list number (standard)\n"
20768 "Sequence number of an entry\n"
20769 "Sequence number\n"
20770 "Specify large community to reject\n"
20771 "Specify large community to accept\n"
20772 LCOMMUNITY_VAL_STR
)
20774 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20775 LARGE_COMMUNITY_LIST_STANDARD
);
20778 DEFUN (no_lcommunity_list_expanded
,
20779 no_bgp_lcommunity_list_expanded_cmd
,
20780 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20783 LCOMMUNITY_LIST_STR
20784 "Large Community list number (expanded)\n"
20785 "Sequence number of an entry\n"
20786 "Sequence number\n"
20787 "Specify large community to reject\n"
20788 "Specify large community to accept\n"
20789 "An ordered list as a regular-expression\n")
20791 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20792 LARGE_COMMUNITY_LIST_EXPANDED
);
20795 DEFUN (no_lcommunity_list_name_standard
,
20796 no_bgp_lcommunity_list_name_standard_cmd
,
20797 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20800 LCOMMUNITY_LIST_STR
20801 "Specify standard large-community-list\n"
20802 "Large Community list name\n"
20803 "Sequence number of an entry\n"
20804 "Sequence number\n"
20805 "Specify large community to reject\n"
20806 "Specify large community to accept\n"
20807 LCOMMUNITY_VAL_STR
)
20809 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20810 LARGE_COMMUNITY_LIST_STANDARD
);
20813 DEFUN (no_lcommunity_list_name_expanded
,
20814 no_bgp_lcommunity_list_name_expanded_cmd
,
20815 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20818 LCOMMUNITY_LIST_STR
20819 "Specify expanded large-community-list\n"
20820 "Large community list name\n"
20821 "Sequence number of an entry\n"
20822 "Sequence number\n"
20823 "Specify large community to reject\n"
20824 "Specify large community to accept\n"
20825 "An ordered list as a regular-expression\n")
20827 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20828 LARGE_COMMUNITY_LIST_EXPANDED
);
20831 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20833 struct community_entry
*entry
;
20835 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20836 if (entry
== list
->head
) {
20837 if (all_digit(list
->name
))
20838 vty_out(vty
, "Large community %s list %s\n",
20840 LARGE_COMMUNITY_LIST_STANDARD
20842 : "(expanded) access",
20846 "Named large community %s list %s\n",
20848 LARGE_COMMUNITY_LIST_STANDARD
20854 vty_out(vty
, " %s\n",
20855 community_direct_str(entry
->direct
));
20857 vty_out(vty
, " %s %s\n",
20858 community_direct_str(entry
->direct
),
20859 community_list_config_str(entry
));
20863 DEFUN (show_lcommunity_list
,
20864 show_bgp_lcommunity_list_cmd
,
20865 "show bgp large-community-list",
20868 "List large-community list\n")
20870 struct community_list
*list
;
20871 struct community_list_master
*cm
;
20873 cm
= community_list_master_lookup(bgp_clist
,
20874 LARGE_COMMUNITY_LIST_MASTER
);
20876 return CMD_SUCCESS
;
20878 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20879 lcommunity_list_show(vty
, list
);
20881 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20882 lcommunity_list_show(vty
, list
);
20884 return CMD_SUCCESS
;
20887 DEFUN (show_lcommunity_list_arg
,
20888 show_bgp_lcommunity_list_arg_cmd
,
20889 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20892 "List large-community list\n"
20893 "Large-community-list number\n"
20894 "Large-community-list name\n"
20895 "Detailed information on large-community-list\n")
20897 struct community_list
*list
;
20899 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20900 LARGE_COMMUNITY_LIST_MASTER
);
20902 vty_out(vty
, "%% Can't find large-community-list\n");
20903 return CMD_WARNING
;
20906 lcommunity_list_show(vty
, list
);
20908 return CMD_SUCCESS
;
20911 /* "extcommunity-list" keyword help string. */
20912 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20913 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20915 DEFUN (extcommunity_list_standard
,
20916 bgp_extcommunity_list_standard_cmd
,
20917 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20919 EXTCOMMUNITY_LIST_STR
20920 "Extended Community list number (standard)\n"
20921 "Specify standard extcommunity-list\n"
20922 "Community list name\n"
20923 "Sequence number of an entry\n"
20924 "Sequence number\n"
20925 "Specify community to reject\n"
20926 "Specify community to accept\n"
20927 EXTCOMMUNITY_VAL_STR
)
20929 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20931 char *cl_number_or_name
= NULL
;
20936 argv_find(argv
, argc
, "(1-99)", &idx
);
20937 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20938 cl_number_or_name
= argv
[idx
]->arg
;
20940 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20941 seq
= argv
[idx
]->arg
;
20943 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20945 argv_find(argv
, argc
, "AA:NN", &idx
);
20946 char *str
= argv_concat(argv
, argc
, idx
);
20948 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20951 XFREE(MTYPE_TMP
, str
);
20954 community_list_perror(vty
, ret
);
20955 return CMD_WARNING_CONFIG_FAILED
;
20958 return CMD_SUCCESS
;
20961 DEFUN (extcommunity_list_name_expanded
,
20962 bgp_extcommunity_list_name_expanded_cmd
,
20963 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20965 EXTCOMMUNITY_LIST_STR
20966 "Extended Community list number (expanded)\n"
20967 "Specify expanded extcommunity-list\n"
20968 "Extended Community list name\n"
20969 "Sequence number of an entry\n"
20970 "Sequence number\n"
20971 "Specify community to reject\n"
20972 "Specify community to accept\n"
20973 "An ordered list as a regular-expression\n")
20975 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20977 char *cl_number_or_name
= NULL
;
20981 argv_find(argv
, argc
, "(100-500)", &idx
);
20982 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20983 cl_number_or_name
= argv
[idx
]->arg
;
20985 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20986 seq
= argv
[idx
]->arg
;
20988 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20990 argv_find(argv
, argc
, "LINE", &idx
);
20991 char *str
= argv_concat(argv
, argc
, idx
);
20993 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20996 XFREE(MTYPE_TMP
, str
);
20999 community_list_perror(vty
, ret
);
21000 return CMD_WARNING_CONFIG_FAILED
;
21003 return CMD_SUCCESS
;
21006 DEFUN (no_extcommunity_list_standard_all
,
21007 no_bgp_extcommunity_list_standard_all_cmd
,
21008 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21011 EXTCOMMUNITY_LIST_STR
21012 "Extended Community list number (standard)\n"
21013 "Specify standard extcommunity-list\n"
21014 "Community list name\n"
21015 "Sequence number of an entry\n"
21016 "Sequence number\n"
21017 "Specify community to reject\n"
21018 "Specify community to accept\n"
21019 EXTCOMMUNITY_VAL_STR
)
21021 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21023 char *cl_number_or_name
= NULL
;
21028 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21029 seq
= argv
[idx
]->arg
;
21032 argv_find(argv
, argc
, "permit", &idx
);
21033 argv_find(argv
, argc
, "deny", &idx
);
21035 direct
= argv_find(argv
, argc
, "permit", &idx
)
21040 argv_find(argv
, argc
, "AA:NN", &idx
);
21041 str
= argv_concat(argv
, argc
, idx
);
21045 argv_find(argv
, argc
, "(1-99)", &idx
);
21046 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21047 cl_number_or_name
= argv
[idx
]->arg
;
21049 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21050 seq
, direct
, style
);
21052 XFREE(MTYPE_TMP
, str
);
21055 community_list_perror(vty
, ret
);
21056 return CMD_WARNING_CONFIG_FAILED
;
21059 return CMD_SUCCESS
;
21062 ALIAS(no_extcommunity_list_standard_all
,
21063 no_bgp_extcommunity_list_standard_all_list_cmd
,
21064 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21065 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21066 "Extended Community list number (standard)\n"
21067 "Specify standard extcommunity-list\n"
21068 "Community list name\n")
21070 DEFUN (no_extcommunity_list_expanded_all
,
21071 no_bgp_extcommunity_list_expanded_all_cmd
,
21072 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21075 EXTCOMMUNITY_LIST_STR
21076 "Extended Community list number (expanded)\n"
21077 "Specify expanded extcommunity-list\n"
21078 "Extended Community list name\n"
21079 "Sequence number of an entry\n"
21080 "Sequence number\n"
21081 "Specify community to reject\n"
21082 "Specify community to accept\n"
21083 "An ordered list as a regular-expression\n")
21085 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21087 char *cl_number_or_name
= NULL
;
21092 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21093 seq
= argv
[idx
]->arg
;
21096 argv_find(argv
, argc
, "permit", &idx
);
21097 argv_find(argv
, argc
, "deny", &idx
);
21100 direct
= argv_find(argv
, argc
, "permit", &idx
)
21105 argv_find(argv
, argc
, "LINE", &idx
);
21106 str
= argv_concat(argv
, argc
, idx
);
21110 argv_find(argv
, argc
, "(100-500)", &idx
);
21111 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21112 cl_number_or_name
= argv
[idx
]->arg
;
21114 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21115 seq
, direct
, style
);
21117 XFREE(MTYPE_TMP
, str
);
21120 community_list_perror(vty
, ret
);
21121 return CMD_WARNING_CONFIG_FAILED
;
21124 return CMD_SUCCESS
;
21127 ALIAS(no_extcommunity_list_expanded_all
,
21128 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21129 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21130 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21131 "Extended Community list number (expanded)\n"
21132 "Specify expanded extcommunity-list\n"
21133 "Extended Community list name\n")
21135 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21137 struct community_entry
*entry
;
21139 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21140 if (entry
== list
->head
) {
21141 if (all_digit(list
->name
))
21142 vty_out(vty
, "Extended community %s list %s\n",
21143 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21145 : "(expanded) access",
21149 "Named extended community %s list %s\n",
21150 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21156 vty_out(vty
, " %s\n",
21157 community_direct_str(entry
->direct
));
21159 vty_out(vty
, " %s %s\n",
21160 community_direct_str(entry
->direct
),
21161 community_list_config_str(entry
));
21165 DEFUN (show_extcommunity_list
,
21166 show_bgp_extcommunity_list_cmd
,
21167 "show bgp extcommunity-list",
21170 "List extended-community list\n")
21172 struct community_list
*list
;
21173 struct community_list_master
*cm
;
21175 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21177 return CMD_SUCCESS
;
21179 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21180 extcommunity_list_show(vty
, list
);
21182 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21183 extcommunity_list_show(vty
, list
);
21185 return CMD_SUCCESS
;
21188 DEFUN (show_extcommunity_list_arg
,
21189 show_bgp_extcommunity_list_arg_cmd
,
21190 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21193 "List extended-community list\n"
21194 "Extcommunity-list number\n"
21195 "Extcommunity-list name\n"
21196 "Detailed information on extcommunity-list\n")
21198 int idx_comm_list
= 3;
21199 struct community_list
*list
;
21201 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21202 EXTCOMMUNITY_LIST_MASTER
);
21204 vty_out(vty
, "%% Can't find extcommunity-list\n");
21205 return CMD_WARNING
;
21208 extcommunity_list_show(vty
, list
);
21210 return CMD_SUCCESS
;
21213 /* Display community-list and extcommunity-list configuration. */
21214 static int community_list_config_write(struct vty
*vty
)
21216 struct community_list
*list
;
21217 struct community_entry
*entry
;
21218 struct community_list_master
*cm
;
21221 /* Community-list. */
21222 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21224 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21225 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21227 "bgp community-list %s seq %" PRId64
" %s %s\n",
21228 list
->name
, entry
->seq
,
21229 community_direct_str(entry
->direct
),
21230 community_list_config_str(entry
));
21233 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21234 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21236 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21237 entry
->style
== COMMUNITY_LIST_STANDARD
21240 list
->name
, entry
->seq
,
21241 community_direct_str(entry
->direct
),
21242 community_list_config_str(entry
));
21246 /* Extcommunity-list. */
21247 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21249 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21250 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21252 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21253 list
->name
, entry
->seq
,
21254 community_direct_str(entry
->direct
),
21255 community_list_config_str(entry
));
21258 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21259 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21261 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21262 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21265 list
->name
, entry
->seq
,
21266 community_direct_str(entry
->direct
),
21267 community_list_config_str(entry
));
21272 /* lcommunity-list. */
21273 cm
= community_list_master_lookup(bgp_clist
,
21274 LARGE_COMMUNITY_LIST_MASTER
);
21276 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21277 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21279 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21280 list
->name
, entry
->seq
,
21281 community_direct_str(entry
->direct
),
21282 community_list_config_str(entry
));
21285 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21286 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21288 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21290 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21293 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21294 community_list_config_str(entry
));
21301 static int community_list_config_write(struct vty
*vty
);
21302 static struct cmd_node community_list_node
= {
21303 .name
= "community list",
21304 .node
= COMMUNITY_LIST_NODE
,
21306 .config_write
= community_list_config_write
,
21309 static void community_list_vty(void)
21311 install_node(&community_list_node
);
21313 /* Community-list. */
21314 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21315 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21316 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21317 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21318 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21319 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21320 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21321 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21323 /* Extcommunity-list. */
21324 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21325 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21326 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21327 install_element(CONFIG_NODE
,
21328 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21329 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21330 install_element(CONFIG_NODE
,
21331 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21332 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21333 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21335 /* Large Community List */
21336 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21337 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21338 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21339 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21340 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21341 install_element(CONFIG_NODE
,
21342 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21343 install_element(CONFIG_NODE
,
21344 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21345 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21346 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21347 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21348 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21349 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21350 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21352 bgp_community_list_command_completion_setup();
21355 static struct cmd_node community_alias_node
= {
21356 .name
= "community alias",
21357 .node
= COMMUNITY_ALIAS_NODE
,
21359 .config_write
= bgp_community_alias_write
,
21362 void community_alias_vty(void)
21364 install_node(&community_alias_node
);
21366 /* Community-list. */
21367 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21369 bgp_community_alias_command_completion_setup();