2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
81 #include "bgpd/bgp_orr.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
129 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
130 { .val_bool
= false, .match_version
= "< 8.3", },
131 { .val_bool
= true },
133 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
134 { .val_bool
= false, .match_version
= "< 8.3", },
135 { .val_bool
= true },
138 DEFINE_HOOK(bgp_inst_config_write
,
139 (struct bgp
*bgp
, struct vty
*vty
),
141 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
142 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 /* Show BGP peer's information. */
157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
158 struct prefix
*range
, int exact
);
160 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
165 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
168 afi_t afi
, bool use_json
);
170 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
176 return BGP_IPV4_NODE
;
178 return BGP_IPV4M_NODE
;
179 case SAFI_LABELED_UNICAST
:
180 return BGP_IPV4L_NODE
;
182 return BGP_VPNV4_NODE
;
184 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
192 return BGP_IPV6_NODE
;
194 return BGP_IPV6M_NODE
;
195 case SAFI_LABELED_UNICAST
:
196 return BGP_IPV6L_NODE
;
198 return BGP_VPNV6_NODE
;
200 return BGP_FLOWSPECV6_NODE
;
203 return BGP_IPV4_NODE
;
206 return BGP_EVPN_NODE
;
209 // We should never be here but to clarify the switch statement..
210 return BGP_IPV4_NODE
;
213 // Impossible to happen
214 return BGP_IPV4_NODE
;
217 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
220 if (safi
== SAFI_UNICAST
)
221 return "IPv4 Unicast";
222 if (safi
== SAFI_MULTICAST
)
223 return "IPv4 Multicast";
224 if (safi
== SAFI_LABELED_UNICAST
)
225 return "IPv4 Labeled Unicast";
226 if (safi
== SAFI_MPLS_VPN
)
228 if (safi
== SAFI_ENCAP
)
230 if (safi
== SAFI_FLOWSPEC
)
231 return "IPv4 Flowspec";
232 } else if (afi
== AFI_IP6
) {
233 if (safi
== SAFI_UNICAST
)
234 return "IPv6 Unicast";
235 if (safi
== SAFI_MULTICAST
)
236 return "IPv6 Multicast";
237 if (safi
== SAFI_LABELED_UNICAST
)
238 return "IPv6 Labeled Unicast";
239 if (safi
== SAFI_MPLS_VPN
)
241 if (safi
== SAFI_ENCAP
)
243 if (safi
== SAFI_FLOWSPEC
)
244 return "IPv6 Flowspec";
245 } else if (afi
== AFI_L2VPN
) {
246 if (safi
== SAFI_EVPN
)
254 * Please note that we have intentionally camelCased
255 * the return strings here. So if you want
256 * to use this function, please ensure you
257 * are doing this within json output
259 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
262 if (safi
== SAFI_UNICAST
)
263 return "ipv4Unicast";
264 if (safi
== SAFI_MULTICAST
)
265 return "ipv4Multicast";
266 if (safi
== SAFI_LABELED_UNICAST
)
267 return "ipv4LabeledUnicast";
268 if (safi
== SAFI_MPLS_VPN
)
270 if (safi
== SAFI_ENCAP
)
272 if (safi
== SAFI_FLOWSPEC
)
273 return "ipv4Flowspec";
274 } else if (afi
== AFI_IP6
) {
275 if (safi
== SAFI_UNICAST
)
276 return "ipv6Unicast";
277 if (safi
== SAFI_MULTICAST
)
278 return "ipv6Multicast";
279 if (safi
== SAFI_LABELED_UNICAST
)
280 return "ipv6LabeledUnicast";
281 if (safi
== SAFI_MPLS_VPN
)
283 if (safi
== SAFI_ENCAP
)
285 if (safi
== SAFI_FLOWSPEC
)
286 return "ipv6Flowspec";
287 } else if (afi
== AFI_L2VPN
) {
288 if (safi
== SAFI_EVPN
)
295 /* unset srv6 locator */
296 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
299 struct listnode
*node
, *nnode
;
300 struct srv6_locator_chunk
*chunk
;
301 struct bgp_srv6_function
*func
;
304 /* release chunk notification via ZAPI */
305 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
306 bgp
->srv6_locator_name
);
311 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
312 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
313 srv6_locator_chunk_free(&chunk
);
316 /* refresh functions */
317 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
318 listnode_delete(bgp
->srv6_functions
, func
);
319 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
322 /* refresh tovpn_sid */
323 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
324 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
327 /* refresh vpnv4 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
331 /* refresh vpnv6 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
335 /* refresh per-vrf tovpn_sid */
336 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
339 /* update vpn bgp processes */
340 vpn_leak_postchange_all();
342 /* refresh tovpn_sid_locator */
343 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
344 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
347 /* refresh vpnv4 tovpn_sid_locator */
348 srv6_locator_chunk_free(
349 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
351 /* refresh vpnv6 tovpn_sid_locator */
352 srv6_locator_chunk_free(
353 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
355 /* refresh per-vrf tovpn_sid_locator */
356 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
359 /* clear locator name */
360 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
365 /* Utility function to get address family from current node. */
366 afi_t
bgp_node_afi(struct vty
*vty
)
374 case BGP_FLOWSPECV6_NODE
:
387 /* Utility function to get subsequent address family from current
389 safi_t
bgp_node_safi(struct vty
*vty
)
395 safi
= SAFI_MPLS_VPN
;
399 safi
= SAFI_MULTICAST
;
406 safi
= SAFI_LABELED_UNICAST
;
408 case BGP_FLOWSPECV4_NODE
:
409 case BGP_FLOWSPECV6_NODE
:
410 safi
= SAFI_FLOWSPEC
;
420 * Converts an AFI in string form to afi_t
422 * @param afi string, one of
426 * @return the corresponding afi_t
428 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
430 afi_t afi
= AFI_MAX
; /* unknown */
431 if (strmatch(afi_str
, "ipv4"))
433 else if (strmatch(afi_str
, "ipv6"))
435 else if (strmatch(afi_str
, "l2vpn"))
440 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
444 if (argv_find(argv
, argc
, "ipv4", index
)) {
448 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
452 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
460 /* supports <unicast|multicast|vpn|labeled-unicast> */
461 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
463 safi_t safi
= SAFI_MAX
; /* unknown */
464 if (strmatch(safi_str
, "multicast"))
465 safi
= SAFI_MULTICAST
;
466 else if (strmatch(safi_str
, "unicast"))
468 else if (strmatch(safi_str
, "vpn"))
469 safi
= SAFI_MPLS_VPN
;
470 else if (strmatch(safi_str
, "evpn"))
472 else if (strmatch(safi_str
, "labeled-unicast"))
473 safi
= SAFI_LABELED_UNICAST
;
474 else if (strmatch(safi_str
, "flowspec"))
475 safi
= SAFI_FLOWSPEC
;
479 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
483 if (argv_find(argv
, argc
, "unicast", index
)) {
486 *safi
= SAFI_UNICAST
;
487 } else if (argv_find(argv
, argc
, "multicast", index
)) {
490 *safi
= SAFI_MULTICAST
;
491 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
494 *safi
= SAFI_LABELED_UNICAST
;
495 } else if (argv_find(argv
, argc
, "vpn", index
)) {
498 *safi
= SAFI_MPLS_VPN
;
499 } else if (argv_find(argv
, argc
, "evpn", index
)) {
503 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
506 *safi
= SAFI_FLOWSPEC
;
512 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
515 * address-family identifier
518 * subsequent address-family identifier
521 * default_af string corresponding to the supplied afi/safi pair.
522 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
525 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
531 return "ipv4-unicast";
533 return "ipv4-multicast";
538 case SAFI_LABELED_UNICAST
:
539 return "ipv4-labeled-unicast";
541 return "ipv4-flowspec";
543 return "unknown-afi/safi";
549 return "ipv6-unicast";
551 return "ipv6-multicast";
556 case SAFI_LABELED_UNICAST
:
557 return "ipv6-labeled-unicast";
559 return "ipv6-flowspec";
561 return "unknown-afi/safi";
569 return "unknown-afi/safi";
573 return "unknown-afi/safi";
575 /* all AFIs are accounted for above, so this shouldn't happen */
576 return "unknown-afi/safi";
579 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
580 enum bgp_instance_type inst_type
)
582 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
584 if (ret
== BGP_CREATED
) {
585 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
586 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
588 if (DFLT_BGP_IMPORT_CHECK
)
589 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
590 if (DFLT_BGP_SHOW_HOSTNAME
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
592 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
594 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
596 if (DFLT_BGP_DETERMINISTIC_MED
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
598 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
600 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
602 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
604 if (DFLT_BGP_HARD_ADMIN_RESET
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
613 * bgp_vty_find_and_parse_afi_safi_bgp
615 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
616 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
617 * to appropriate values for the calling function. This is to allow the
618 * calling function to make decisions appropriate for the show command
619 * that is being parsed.
621 * The show commands are generally of the form:
622 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
623 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
625 * Since we use argv_find if the show command in particular doesn't have:
627 * [<view|vrf> VIEWVRFNAME]
628 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
629 * The command parsing should still be ok.
631 * vty -> The vty for the command so we can output some useful data in
632 * the event of a parse error in the vrf.
633 * argv -> The command tokens
634 * argc -> How many command tokens we have
635 * idx -> The current place in the command, generally should be 0 for this
637 * afi -> The parsed afi if it was included in the show command, returned here
638 * safi -> The parsed safi if it was included in the show command, returned here
639 * bgp -> Pointer to the bgp data structure we need to fill in.
640 * use_json -> json is configured or not
642 * The function returns the correct location in the parse tree for the
645 * Returns 0 for failure to parse correctly, else the idx position of where
646 * it found the last token.
648 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
649 struct cmd_token
**argv
, int argc
,
650 int *idx
, afi_t
*afi
, safi_t
*safi
,
651 struct bgp
**bgp
, bool use_json
)
653 char *vrf_name
= NULL
;
659 if (argv_find(argv
, argc
, "ip", idx
))
662 if (argv_find(argv
, argc
, "view", idx
))
663 vrf_name
= argv
[*idx
+ 1]->arg
;
664 else if (argv_find(argv
, argc
, "vrf", idx
)) {
665 vrf_name
= argv
[*idx
+ 1]->arg
;
666 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
670 if (strmatch(vrf_name
, "all"))
673 *bgp
= bgp_lookup_by_name(vrf_name
);
676 json_object
*json
= NULL
;
677 json
= json_object_new_object();
678 json_object_string_add(
680 "View/Vrf is unknown");
684 vty_out(vty
, "View/Vrf %s is unknown\n",
691 *bgp
= bgp_get_default();
694 json_object
*json
= NULL
;
695 json
= json_object_new_object();
696 json_object_string_add(
698 "Default BGP instance not found");
703 "Default BGP instance not found\n");
709 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
710 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
716 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
718 struct interface
*ifp
= NULL
;
719 struct listnode
*node
;
720 struct bgp_listener
*listener
;
721 union sockunion all_su
;
723 if (su
->sa
.sa_family
== AF_INET
) {
724 (void)str2sockunion("0.0.0.0", &all_su
);
725 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
726 } else if (su
->sa
.sa_family
== AF_INET6
) {
727 (void)str2sockunion("::", &all_su
);
728 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
729 su
->sin6
.sin6_scope_id
,
734 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
735 if (sockunion_family(su
) !=
736 sockunion_family(&listener
->su
))
739 /* If 0.0.0.0/:: is a listener, then treat as self and
742 if (!sockunion_cmp(&listener
->su
, su
) ||
743 !sockunion_cmp(&listener
->su
, &all_su
))
751 /* Utility function for looking up peer from VTY. */
752 /* This is used only for configuration, so disallow if attempted on
753 * a dynamic neighbor.
755 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
757 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
766 ret
= str2sockunion(ip_str
, &su
);
768 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
770 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
773 "%% Malformed address or name: %s\n",
779 peer
= peer_lookup(bgp
, &su
);
782 "%% Specify remote-as or peer-group commands first\n");
785 if (peer_dynamic_neighbor(peer
)) {
787 "%% Operation not allowed on a dynamic neighbor\n");
794 /* Utility function for looking up peer or peer group. */
795 /* This is used only for configuration, so disallow if attempted on
796 * a dynamic neighbor.
798 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
800 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
803 struct peer
*peer
= NULL
;
804 struct peer_group
*group
= NULL
;
810 ret
= str2sockunion(peer_str
, &su
);
812 /* IP address, locate peer. */
813 peer
= peer_lookup(bgp
, &su
);
815 /* Not IP, could match either peer configured on interface or a
817 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
819 group
= peer_group_lookup(bgp
, peer_str
);
823 if (peer_dynamic_neighbor(peer
)) {
825 "%% Operation not allowed on a dynamic neighbor\n");
835 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
840 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
842 const char *str
= NULL
;
847 case BGP_GR_NO_OPERATION
:
849 case BGP_ERR_INVALID_VALUE
:
850 str
= "Invalid value";
852 case BGP_ERR_INVALID_FLAG
:
853 str
= "Invalid flag";
855 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
856 str
= "Peer-group has been shutdown. Activate the peer-group first";
858 case BGP_ERR_PEER_FLAG_CONFLICT
:
859 str
= "Can't set override-capability and strict-capability-match at the same time";
861 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
862 str
= "Specify remote-as or peer-group remote AS first";
864 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
865 str
= "Cannot change the peer-group. Deconfigure first";
867 case BGP_ERR_PEER_GROUP_MISMATCH
:
868 str
= "Peer is not a member of this peer-group";
870 case BGP_ERR_PEER_FILTER_CONFLICT
:
871 str
= "Prefix/distribute list can not co-exist";
873 case BGP_ERR_NOT_INTERNAL_PEER
:
874 str
= "Invalid command. Not an internal neighbor";
876 case BGP_ERR_REMOVE_PRIVATE_AS
:
877 str
= "remove-private-AS cannot be configured for IBGP peers";
879 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
880 str
= "Cannot have local-as same as BGP AS number";
882 case BGP_ERR_TCPSIG_FAILED
:
883 str
= "Error while applying TCP-Sig to session(s)";
885 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
886 str
= "ebgp-multihop and ttl-security cannot be configured together";
888 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
889 str
= "ttl-security only allowed for EBGP peers";
891 case BGP_ERR_AS_OVERRIDE
:
892 str
= "as-override cannot be configured for IBGP peers";
894 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
895 str
= "Invalid limit for number of dynamic neighbors";
897 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
898 str
= "Dynamic neighbor listen range already exists";
900 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
901 str
= "Operation not allowed on a dynamic neighbor";
903 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
904 str
= "Operation not allowed on a directly connected neighbor";
906 case BGP_ERR_PEER_SAFI_CONFLICT
:
907 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
909 case BGP_ERR_GR_INVALID_CMD
:
910 str
= "The Graceful Restart command used is not valid at this moment.";
912 case BGP_ERR_GR_OPERATION_FAILED
:
913 str
= "The Graceful Restart Operation failed due to an err.";
915 case BGP_ERR_PEER_GROUP_MEMBER
:
916 str
= "Peer-group member cannot override remote-as of peer-group.";
918 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
919 str
= "Peer-group members must be all internal or all external.";
921 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
922 str
= "Range specified cannot be deleted because it is not part of current config.";
924 case BGP_ERR_INSTANCE_MISMATCH
:
925 str
= "Instance specified does not match the current instance.";
927 case BGP_ERR_NO_INTERFACE_CONFIG
:
928 str
= "Interface specified is not being used for interface based peer.";
930 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
931 str
= "No configuration already specified for soft reconfiguration.";
933 case BGP_ERR_AS_MISMATCH
:
934 str
= "BGP is already running.";
936 case BGP_ERR_AF_UNCONFIGURED
:
937 str
= "AFI/SAFI specified is not currently configured.";
939 case BGP_ERR_INVALID_AS
:
940 str
= "Confederation AS specified is the same AS as our AS.";
942 case BGP_ERR_INVALID_ROLE_NAME
:
943 str
= "Invalid role name";
945 case BGP_ERR_INVALID_INTERNAL_ROLE
:
946 str
= "External roles can be set only on eBGP session";
948 case BGP_ERR_PEER_ORR_CONFIGURED
:
949 str
= "Deconfigure optimal-route-reflection on this peer first";
953 vty_out(vty
, "%% %s\n", str
);
954 return CMD_WARNING_CONFIG_FAILED
;
959 /* BGP clear sort. */
968 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
969 safi_t safi
, int error
)
972 case BGP_ERR_AF_UNCONFIGURED
:
975 "%% BGP: Enable %s address family for the neighbor %s\n",
976 get_afi_safi_str(afi
, safi
, false), peer
->host
);
979 "%% BGP: Enable %s address family for the neighbor %s",
980 get_afi_safi_str(afi
, safi
, false), peer
->host
);
982 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
985 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
989 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
997 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
998 struct listnode
**nnode
, enum bgp_clear_type stype
)
1001 struct peer_af
*paf
;
1003 /* if afi/.safi not specified, spin thru all of them */
1004 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1007 enum bgp_af_index index
;
1009 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1010 paf
= peer
->peer_af_array
[index
];
1014 if (paf
&& paf
->subgroup
)
1015 SET_FLAG(paf
->subgroup
->sflags
,
1016 SUBGRP_STATUS_FORCE_UPDATES
);
1019 tmp_safi
= paf
->safi
;
1020 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1023 if (stype
== BGP_CLEAR_SOFT_NONE
)
1024 ret
= peer_clear(peer
, nnode
);
1026 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1029 /* if afi specified and safi not, spin thru safis on this afi */
1030 } else if (safi
== SAFI_UNSPEC
) {
1033 for (tmp_safi
= SAFI_UNICAST
;
1034 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1035 if (!peer
->afc
[afi
][tmp_safi
])
1038 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1039 if (paf
&& paf
->subgroup
)
1040 SET_FLAG(paf
->subgroup
->sflags
,
1041 SUBGRP_STATUS_FORCE_UPDATES
);
1043 if (stype
== BGP_CLEAR_SOFT_NONE
)
1044 ret
= peer_clear(peer
, nnode
);
1046 ret
= peer_clear_soft(peer
, afi
,
1049 /* both afi/safi specified, let the caller know if not defined */
1051 if (!peer
->afc
[afi
][safi
])
1054 paf
= peer_af_find(peer
, afi
, safi
);
1055 if (paf
&& paf
->subgroup
)
1056 SET_FLAG(paf
->subgroup
->sflags
,
1057 SUBGRP_STATUS_FORCE_UPDATES
);
1059 if (stype
== BGP_CLEAR_SOFT_NONE
)
1060 ret
= peer_clear(peer
, nnode
);
1062 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1068 /* `clear ip bgp' functions. */
1069 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1070 enum clear_sort sort
, enum bgp_clear_type stype
,
1077 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1079 /* Clear all neighbors. */
1081 * Pass along pointer to next node to peer_clear() when walking all
1082 * nodes on the BGP instance as that may get freed if it is a
1085 if (sort
== clear_all
) {
1086 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1088 bgp_peer_gr_flags_update(peer
);
1090 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1091 gr_router_detected
= true;
1093 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1097 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1100 if (gr_router_detected
1101 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1102 bgp_zebra_send_capabilities(bgp
, false);
1103 } else if (!gr_router_detected
1104 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1105 bgp_zebra_send_capabilities(bgp
, true);
1108 /* This is to apply read-only mode on this clear. */
1109 if (stype
== BGP_CLEAR_SOFT_NONE
)
1110 bgp
->update_delay_over
= 0;
1115 /* Clear specified neighbor. */
1116 if (sort
== clear_peer
) {
1119 /* Make sockunion for lookup. */
1120 ret
= str2sockunion(arg
, &su
);
1122 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1124 peer
= peer_lookup_by_hostname(bgp
, arg
);
1127 "Malformed address or name: %s\n",
1133 peer
= peer_lookup(bgp
, &su
);
1136 "%% BGP: Unknown neighbor - \"%s\"\n",
1142 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1143 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1145 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1147 /* if afi/safi not defined for this peer, let caller know */
1149 ret
= BGP_ERR_AF_UNCONFIGURED
;
1152 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1157 /* Clear all neighbors belonging to a specific peer-group. */
1158 if (sort
== clear_group
) {
1159 struct peer_group
*group
;
1161 group
= peer_group_lookup(bgp
, arg
);
1163 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1167 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1168 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1171 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1178 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1179 get_afi_safi_str(afi
, safi
, false), arg
);
1184 /* Clear all external (eBGP) neighbors. */
1185 if (sort
== clear_external
) {
1186 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1187 if (peer
->sort
== BGP_PEER_IBGP
)
1190 bgp_peer_gr_flags_update(peer
);
1192 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1193 gr_router_detected
= true;
1195 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1198 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1203 if (gr_router_detected
1204 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1205 bgp_zebra_send_capabilities(bgp
, false);
1206 } else if (!gr_router_detected
1207 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1208 bgp_zebra_send_capabilities(bgp
, true);
1213 "%% BGP: No external %s peer is configured\n",
1214 get_afi_safi_str(afi
, safi
, false));
1219 /* Clear all neighbors belonging to a specific AS. */
1220 if (sort
== clear_as
) {
1221 as_t as
= strtoul(arg
, NULL
, 10);
1223 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1227 bgp_peer_gr_flags_update(peer
);
1229 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1230 gr_router_detected
= true;
1232 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1235 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1240 if (gr_router_detected
1241 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1242 bgp_zebra_send_capabilities(bgp
, false);
1243 } else if (!gr_router_detected
1244 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1245 bgp_zebra_send_capabilities(bgp
, true);
1250 "%% BGP: No %s peer is configured with AS %s\n",
1251 get_afi_safi_str(afi
, safi
, false), arg
);
1259 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1260 safi_t safi
, enum clear_sort sort
,
1261 enum bgp_clear_type stype
, const char *arg
)
1265 /* BGP structure lookup. */
1267 bgp
= bgp_lookup_by_name(name
);
1269 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1273 bgp
= bgp_get_default();
1275 vty_out(vty
, "No BGP process is configured\n");
1280 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1283 /* clear soft inbound */
1284 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1289 FOREACH_AFI_SAFI (afi
, safi
)
1290 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1291 BGP_CLEAR_SOFT_IN
, NULL
);
1294 /* clear soft outbound */
1295 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1300 FOREACH_AFI_SAFI (afi
, safi
)
1301 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1302 BGP_CLEAR_SOFT_OUT
, NULL
);
1306 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1308 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1311 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1312 uint64_t flag
, int set
)
1317 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1319 return CMD_WARNING_CONFIG_FAILED
;
1322 * If 'neighbor <interface>', then this is for directly connected peers,
1323 * we should not accept disable-connected-check.
1325 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1327 "%s is directly connected peer, cannot accept disable-connected-check\n",
1329 return CMD_WARNING_CONFIG_FAILED
;
1332 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1333 peer_tx_shutdown_message_unset(peer
);
1336 ret
= peer_flag_set(peer
, flag
);
1338 ret
= peer_flag_unset(peer
, flag
);
1340 return bgp_vty_return(vty
, ret
);
1343 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1345 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1348 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1351 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1354 #include "bgpd/bgp_vty_clippy.c"
1356 DEFUN_HIDDEN (bgp_local_mac
,
1358 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1360 "Local MAC config\n"
1361 "VxLAN Network Identifier\n"
1365 "mac-mobility sequence\n"
1375 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1376 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1377 vty_out(vty
, "%% Malformed MAC address\n");
1380 memset(&ip
, 0, sizeof(ip
));
1381 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1383 bgp
= bgp_get_default();
1385 vty_out(vty
, "Default BGP instance is not there\n");
1389 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1392 vty_out(vty
, "Internal error\n");
1399 DEFUN_HIDDEN (no_bgp_local_mac
,
1400 no_bgp_local_mac_cmd
,
1401 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1404 "Local MAC config\n"
1405 "VxLAN Network Identifier\n"
1416 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1417 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1418 vty_out(vty
, "%% Malformed MAC address\n");
1421 memset(&ip
, 0, sizeof(ip
));
1423 bgp
= bgp_get_default();
1425 vty_out(vty
, "Default BGP instance is not there\n");
1429 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1431 vty_out(vty
, "Internal error\n");
1438 DEFUN (no_synchronization
,
1439 no_synchronization_cmd
,
1440 "no synchronization",
1442 "Perform IGP synchronization\n")
1447 DEFUN (no_auto_summary
,
1448 no_auto_summary_cmd
,
1451 "Enable automatic network number summarization\n")
1456 /* "router bgp" commands. */
1457 DEFUN_NOSH (router_bgp
,
1459 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1463 BGP_INSTANCE_HELP_STR
)
1466 int idx_view_vrf
= 3;
1472 const char *name
= NULL
;
1473 enum bgp_instance_type inst_type
;
1475 // "router bgp" without an ASN
1477 // Pending: Make VRF option available for ASN less config
1478 bgp
= bgp_get_default();
1481 vty_out(vty
, "%% No BGP process is configured\n");
1482 return CMD_WARNING_CONFIG_FAILED
;
1485 if (listcount(bm
->bgp
) > 1) {
1486 vty_out(vty
, "%% Please specify ASN and VRF\n");
1487 return CMD_WARNING_CONFIG_FAILED
;
1493 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1495 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1496 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1497 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1499 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1501 name
= argv
[idx_vrf
]->arg
;
1503 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1504 if (strmatch(name
, VRF_DEFAULT_NAME
))
1507 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1508 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1509 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1512 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1513 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1515 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1517 case BGP_ERR_AS_MISMATCH
:
1518 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1519 return CMD_WARNING_CONFIG_FAILED
;
1520 case BGP_ERR_INSTANCE_MISMATCH
:
1522 "BGP instance name and AS number mismatch\n");
1524 "BGP instance is already running; AS is %u\n",
1526 return CMD_WARNING_CONFIG_FAILED
;
1530 * If we just instantiated the default instance, complete
1531 * any pending VRF-VPN leaking that was configured via
1532 * earlier "router bgp X vrf FOO" blocks.
1534 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1535 vpn_leak_postchange_all();
1537 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1538 bgp_vpn_leak_export(bgp
);
1539 /* Pending: handle when user tries to change a view to vrf n vv.
1543 /* unset the auto created flag as the user config is now present */
1544 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1545 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1550 /* "no router bgp" commands. */
1551 DEFUN (no_router_bgp
,
1553 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1558 BGP_INSTANCE_HELP_STR
)
1564 const char *name
= NULL
;
1566 // "no router bgp" without an ASN
1568 // Pending: Make VRF option available for ASN less config
1569 bgp
= bgp_get_default();
1572 vty_out(vty
, "%% No BGP process is configured\n");
1573 return CMD_WARNING_CONFIG_FAILED
;
1576 if (listcount(bm
->bgp
) > 1) {
1577 vty_out(vty
, "%% Please specify ASN and VRF\n");
1578 return CMD_WARNING_CONFIG_FAILED
;
1582 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1584 return CMD_WARNING_CONFIG_FAILED
;
1587 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1590 name
= argv
[idx_vrf
]->arg
;
1591 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1592 && strmatch(name
, VRF_DEFAULT_NAME
))
1596 /* Lookup bgp structure. */
1597 bgp
= bgp_lookup(as
, name
);
1599 vty_out(vty
, "%% Can't find BGP instance\n");
1600 return CMD_WARNING_CONFIG_FAILED
;
1604 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1606 return CMD_WARNING_CONFIG_FAILED
;
1609 /* Cannot delete default instance if vrf instances exist */
1610 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1611 struct listnode
*node
;
1612 struct bgp
*tmp_bgp
;
1614 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1615 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1617 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1618 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1619 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1620 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1621 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1622 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1623 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1624 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1625 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1626 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1627 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1628 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1629 (bgp
== bgp_get_evpn() &&
1630 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1631 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1632 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1633 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1634 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1635 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1636 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1637 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1638 (hashcount(tmp_bgp
->vnihash
))) {
1640 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1641 return CMD_WARNING_CONFIG_FAILED
;
1652 /* bgp session-dscp */
1654 DEFPY (bgp_session_dscp
,
1655 bgp_session_dscp_cmd
,
1656 "bgp session-dscp (0-63)$dscp",
1658 "Override default (C6) bgp TCP session DSCP value\n"
1659 "Manually configured dscp parameter\n")
1661 bm
->tcp_dscp
= dscp
<< 2;
1666 DEFPY (no_bgp_session_dscp
,
1667 no_bgp_session_dscp_cmd
,
1668 "no bgp session-dscp [(0-63)]",
1671 "Override default (C6) bgp TCP session DSCP value\n"
1672 "Manually configured dscp parameter\n")
1674 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1679 /* BGP router-id. */
1681 DEFPY (bgp_router_id
,
1683 "bgp router-id A.B.C.D",
1685 "Override configured router identifier\n"
1686 "Manually configured router identifier\n")
1688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1689 bgp_router_id_static_set(bgp
, router_id
);
1693 DEFPY (no_bgp_router_id
,
1694 no_bgp_router_id_cmd
,
1695 "no bgp router-id [A.B.C.D]",
1698 "Override configured router identifier\n"
1699 "Manually configured router identifier\n")
1701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1703 if (router_id_str
) {
1704 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1705 vty_out(vty
, "%% BGP router-id doesn't match\n");
1706 return CMD_WARNING_CONFIG_FAILED
;
1710 router_id
.s_addr
= 0;
1711 bgp_router_id_static_set(bgp
, router_id
);
1716 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1717 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1719 "Add community specific parameters\n"
1720 "Create an alias for a community\n"
1721 "Community (AA:BB or AA:BB:CC)\n"
1724 struct community_alias ca
= {};
1725 struct community_alias
*lookup_community
;
1726 struct community_alias
*lookup_alias
;
1727 struct community
*comm
;
1728 struct lcommunity
*lcomm
;
1729 uint8_t invalid
= 0;
1731 comm
= community_str2com(community
);
1734 community_free(&comm
);
1736 lcomm
= lcommunity_str2com(community
);
1739 lcommunity_free(&lcomm
);
1742 vty_out(vty
, "Invalid community format\n");
1746 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1747 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1749 lookup_community
= bgp_ca_community_lookup(&ca
);
1750 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1753 bgp_ca_alias_delete(&ca
);
1754 bgp_ca_community_delete(&ca
);
1757 /* Lookup if community hash table has an item
1758 * with the same alias name.
1760 strlcpy(ca
.community
, lookup_alias
->community
,
1761 sizeof(ca
.community
));
1762 if (bgp_ca_community_lookup(&ca
)) {
1764 "community (%s) already has this alias (%s)\n",
1765 lookup_alias
->community
,
1766 lookup_alias
->alias
);
1769 bgp_ca_alias_delete(&ca
);
1772 if (lookup_community
) {
1773 /* Lookup if alias hash table has an item
1774 * with the same community.
1776 strlcpy(ca
.alias
, lookup_community
->alias
,
1778 if (bgp_ca_alias_lookup(&ca
)) {
1780 "alias (%s) already has this community (%s)\n",
1781 lookup_community
->alias
,
1782 lookup_community
->community
);
1785 bgp_ca_community_delete(&ca
);
1788 bgp_ca_alias_insert(&ca
);
1789 bgp_ca_community_insert(&ca
);
1795 DEFPY (bgp_global_suppress_fib_pending
,
1796 bgp_global_suppress_fib_pending_cmd
,
1797 "[no] bgp suppress-fib-pending",
1800 "Advertise only routes that are programmed in kernel to peers globally\n")
1802 bm_wait_for_fib_set(!no
);
1807 DEFPY (bgp_suppress_fib_pending
,
1808 bgp_suppress_fib_pending_cmd
,
1809 "[no] bgp suppress-fib-pending",
1812 "Advertise only routes that are programmed in kernel to peers\n")
1814 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1816 bgp_suppress_fib_pending_set(bgp
, !no
);
1821 /* BGP Cluster ID. */
1822 DEFUN (bgp_cluster_id
,
1824 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1826 "Configure Route-Reflector Cluster-id\n"
1827 "Route-Reflector Cluster-id in IP address format\n"
1828 "Route-Reflector Cluster-id as 32 bit quantity\n")
1830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1833 struct in_addr cluster
;
1835 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1837 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1838 return CMD_WARNING_CONFIG_FAILED
;
1841 bgp_cluster_id_set(bgp
, &cluster
);
1842 bgp_clear_star_soft_out(vty
, bgp
->name
);
1847 DEFUN (no_bgp_cluster_id
,
1848 no_bgp_cluster_id_cmd
,
1849 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1852 "Configure Route-Reflector Cluster-id\n"
1853 "Route-Reflector Cluster-id in IP address format\n"
1854 "Route-Reflector Cluster-id as 32 bit quantity\n")
1856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 bgp_cluster_id_unset(bgp
);
1858 bgp_clear_star_soft_out(vty
, bgp
->name
);
1867 "Disable BGP route installation to RIB (Zebra)\n")
1869 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1871 "%% No-RIB option is already set, nothing to do here.\n");
1875 bgp_option_norib_set_runtime();
1880 DEFPY (no_bgp_norib
,
1885 "Disable BGP route installation to RIB (Zebra)\n")
1887 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1889 "%% No-RIB option is not set, nothing to do here.\n");
1893 bgp_option_norib_unset_runtime();
1898 DEFPY (no_bgp_send_extra_data
,
1899 no_bgp_send_extra_data_cmd
,
1900 "[no] bgp send-extra-data zebra",
1903 "Extra data to Zebra for display/use\n"
1907 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1909 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1914 DEFUN (bgp_confederation_identifier
,
1915 bgp_confederation_identifier_cmd
,
1916 "bgp confederation identifier (1-4294967295)",
1918 "AS confederation parameters\n"
1920 "Set routing domain confederation AS\n")
1922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1926 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1928 bgp_confederation_id_set(bgp
, as
);
1933 DEFUN (no_bgp_confederation_identifier
,
1934 no_bgp_confederation_identifier_cmd
,
1935 "no bgp confederation identifier [(1-4294967295)]",
1938 "AS confederation parameters\n"
1940 "Set routing domain confederation AS\n")
1942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1943 bgp_confederation_id_unset(bgp
);
1948 DEFUN (bgp_confederation_peers
,
1949 bgp_confederation_peers_cmd
,
1950 "bgp confederation peers (1-4294967295)...",
1952 "AS confederation parameters\n"
1953 "Peer ASs in BGP confederation\n"
1956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1961 for (i
= idx_asn
; i
< argc
; i
++) {
1962 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1963 bgp_confederation_peers_add(bgp
, as
);
1968 DEFUN (no_bgp_confederation_peers
,
1969 no_bgp_confederation_peers_cmd
,
1970 "no bgp confederation peers (1-4294967295)...",
1973 "AS confederation parameters\n"
1974 "Peer ASs in BGP confederation\n"
1977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1982 for (i
= idx_asn
; i
< argc
; i
++) {
1983 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1985 bgp_confederation_peers_remove(bgp
, as
);
1991 * Central routine for maximum-paths configuration.
1992 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1993 * @set: 1 for setting values, 0 for removing the max-paths config.
1995 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1996 const char *mpaths
, uint16_t options
,
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2000 uint16_t maxpaths
= 0;
2005 afi
= bgp_node_afi(vty
);
2006 safi
= bgp_node_safi(vty
);
2009 maxpaths
= strtol(mpaths
, NULL
, 10);
2010 if (maxpaths
> multipath_num
) {
2012 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2013 maxpaths
, multipath_num
);
2014 return CMD_WARNING_CONFIG_FAILED
;
2016 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2019 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2023 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2024 (set
== 1) ? "" : "un",
2025 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2026 maxpaths
, afi
, safi
);
2027 return CMD_WARNING_CONFIG_FAILED
;
2030 bgp_recalculate_all_bestpaths(bgp
);
2035 DEFUN (bgp_maxmed_admin
,
2036 bgp_maxmed_admin_cmd
,
2037 "bgp max-med administrative ",
2039 "Advertise routes with max-med\n"
2040 "Administratively applied, for an indefinite period\n")
2042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2044 bgp
->v_maxmed_admin
= 1;
2045 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2047 bgp_maxmed_update(bgp
);
2052 DEFUN (bgp_maxmed_admin_medv
,
2053 bgp_maxmed_admin_medv_cmd
,
2054 "bgp max-med administrative (0-4294967295)",
2056 "Advertise routes with max-med\n"
2057 "Administratively applied, for an indefinite period\n"
2058 "Max MED value to be used\n")
2060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 bgp
->v_maxmed_admin
= 1;
2064 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2066 bgp_maxmed_update(bgp
);
2071 DEFUN (no_bgp_maxmed_admin
,
2072 no_bgp_maxmed_admin_cmd
,
2073 "no bgp max-med administrative [(0-4294967295)]",
2076 "Advertise routes with max-med\n"
2077 "Administratively applied, for an indefinite period\n"
2078 "Max MED value to be used\n")
2080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2081 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2082 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2083 bgp_maxmed_update(bgp
);
2088 DEFUN (bgp_maxmed_onstartup
,
2089 bgp_maxmed_onstartup_cmd
,
2090 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2092 "Advertise routes with max-med\n"
2093 "Effective on a startup\n"
2094 "Time (seconds) period for max-med\n"
2095 "Max MED value to be used\n")
2097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2100 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2101 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2102 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2103 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2105 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2107 bgp_maxmed_update(bgp
);
2112 DEFUN (no_bgp_maxmed_onstartup
,
2113 no_bgp_maxmed_onstartup_cmd
,
2114 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2117 "Advertise routes with max-med\n"
2118 "Effective on a startup\n"
2119 "Time (seconds) period for max-med\n"
2120 "Max MED value to be used\n")
2122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2124 /* Cancel max-med onstartup if its on */
2125 if (bgp
->t_maxmed_onstartup
) {
2126 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2127 bgp
->maxmed_onstartup_over
= 1;
2130 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2131 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2133 bgp_maxmed_update(bgp
);
2138 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2139 uint16_t update_delay
,
2140 uint16_t establish_wait
)
2142 struct listnode
*node
, *nnode
;
2144 bool vrf_cfg
= false;
2147 * See if update-delay is set per-vrf and warn user to delete it
2148 * Note that we only need to check this if this is the first time
2149 * setting the global config.
2151 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2152 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2153 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2155 "%% update-delay configuration found in vrf %s\n",
2156 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2166 "%%Failed: global update-delay config not permitted\n");
2170 if (!establish_wait
) { /* update-delay <delay> */
2171 bm
->v_update_delay
= update_delay
;
2172 bm
->v_establish_wait
= bm
->v_update_delay
;
2174 /* update-delay <delay> <establish-wait> */
2175 if (update_delay
< establish_wait
) {
2177 "%%Failed: update-delay less than the establish-wait!\n");
2178 return CMD_WARNING_CONFIG_FAILED
;
2181 bm
->v_update_delay
= update_delay
;
2182 bm
->v_establish_wait
= establish_wait
;
2185 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2186 bgp
->v_update_delay
= bm
->v_update_delay
;
2187 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2193 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2195 struct listnode
*node
, *nnode
;
2198 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2199 bm
->v_establish_wait
= bm
->v_update_delay
;
2201 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2202 bgp
->v_update_delay
= bm
->v_update_delay
;
2203 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2209 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2210 uint16_t establish_wait
)
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2214 /* if configured globally, per-instance config is not allowed */
2215 if (bm
->v_update_delay
) {
2217 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2218 return CMD_WARNING_CONFIG_FAILED
;
2222 if (!establish_wait
) /* update-delay <delay> */
2224 bgp
->v_update_delay
= update_delay
;
2225 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2229 /* update-delay <delay> <establish-wait> */
2230 if (update_delay
< establish_wait
) {
2232 "%%Failed: update-delay less than the establish-wait!\n");
2233 return CMD_WARNING_CONFIG_FAILED
;
2236 bgp
->v_update_delay
= update_delay
;
2237 bgp
->v_establish_wait
= establish_wait
;
2242 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2246 /* If configured globally, cannot remove from one bgp instance */
2247 if (bm
->v_update_delay
) {
2249 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2250 return CMD_WARNING_CONFIG_FAILED
;
2252 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2253 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2258 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2260 /* If configured globally, no need to display per-instance value */
2261 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2262 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2263 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2264 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2269 /* Global update-delay configuration */
2270 DEFPY (bgp_global_update_delay
,
2271 bgp_global_update_delay_cmd
,
2272 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2274 "Force initial delay for best-path and updates for all bgp instances\n"
2275 "Max delay in seconds\n"
2276 "Establish wait in seconds\n")
2278 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2281 /* Global update-delay deconfiguration */
2282 DEFPY (no_bgp_global_update_delay
,
2283 no_bgp_global_update_delay_cmd
,
2284 "no bgp update-delay [(0-3600) [(1-3600)]]",
2287 "Force initial delay for best-path and updates\n"
2288 "Max delay in seconds\n"
2289 "Establish wait in seconds\n")
2291 return bgp_global_update_delay_deconfig_vty(vty
);
2294 /* Update-delay configuration */
2296 DEFPY (bgp_update_delay
,
2297 bgp_update_delay_cmd
,
2298 "update-delay (0-3600)$delay [(1-3600)$wait]",
2299 "Force initial delay for best-path and updates\n"
2300 "Max delay in seconds\n"
2301 "Establish wait in seconds\n")
2303 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2306 /* Update-delay deconfiguration */
2307 DEFPY (no_bgp_update_delay
,
2308 no_bgp_update_delay_cmd
,
2309 "no update-delay [(0-3600) [(1-3600)]]",
2311 "Force initial delay for best-path and updates\n"
2312 "Max delay in seconds\n"
2313 "Establish wait in seconds\n")
2315 return bgp_update_delay_deconfig_vty(vty
);
2319 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2324 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2325 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2330 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2335 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2336 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2341 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2344 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2345 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2346 vty_out(vty
, " write-quanta %d\n", quanta
);
2349 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2352 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2353 if (quanta
!= BGP_READ_PACKET_MAX
)
2354 vty_out(vty
, " read-quanta %d\n", quanta
);
2357 /* Packet quanta configuration
2359 * XXX: The value set here controls the size of a stack buffer in the IO
2360 * thread. When changing these limits be careful to prevent stack overflow.
2362 * Furthermore, the maximums used here should correspond to
2363 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2365 DEFPY (bgp_wpkt_quanta
,
2366 bgp_wpkt_quanta_cmd
,
2367 "[no] write-quanta (1-64)$quanta",
2369 "How many packets to write to peer socket per run\n"
2370 "Number of packets\n")
2372 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2375 DEFPY (bgp_rpkt_quanta
,
2376 bgp_rpkt_quanta_cmd
,
2377 "[no] read-quanta (1-10)$quanta",
2379 "How many packets to read from peer socket per I/O cycle\n"
2380 "Number of packets\n")
2382 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2385 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2387 if (!bgp
->heuristic_coalesce
)
2388 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2391 /* BGP TCP keepalive */
2392 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2394 if (bgp
->tcp_keepalive_idle
) {
2395 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2396 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2397 bgp
->tcp_keepalive_probes
);
2401 DEFUN (bgp_coalesce_time
,
2402 bgp_coalesce_time_cmd
,
2403 "coalesce-time (0-4294967295)",
2404 "Subgroup coalesce timer\n"
2405 "Subgroup coalesce timer value (in ms)\n")
2407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2411 bgp
->heuristic_coalesce
= false;
2413 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2414 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2419 DEFUN (no_bgp_coalesce_time
,
2420 no_bgp_coalesce_time_cmd
,
2421 "no coalesce-time (0-4294967295)",
2423 "Subgroup coalesce timer\n"
2424 "Subgroup coalesce timer value (in ms)\n")
2426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2428 bgp
->heuristic_coalesce
= true;
2429 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2433 /* Maximum-paths configuration */
2434 DEFUN (bgp_maxpaths
,
2436 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2437 "Forward packets over multiple paths\n"
2438 "Number of paths\n")
2441 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2442 argv
[idx_number
]->arg
, 0, 1);
2445 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2446 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2447 "Forward packets over multiple paths\n"
2448 "Number of paths\n")
2450 DEFUN (bgp_maxpaths_ibgp
,
2451 bgp_maxpaths_ibgp_cmd
,
2452 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2453 "Forward packets over multiple paths\n"
2455 "Number of paths\n")
2458 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2459 argv
[idx_number
]->arg
, 0, 1);
2462 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2463 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2464 "Forward packets over multiple paths\n"
2466 "Number of paths\n")
2468 DEFUN (bgp_maxpaths_ibgp_cluster
,
2469 bgp_maxpaths_ibgp_cluster_cmd
,
2470 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2471 "Forward packets over multiple paths\n"
2474 "Match the cluster length\n")
2477 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2478 argv
[idx_number
]->arg
, true, 1);
2481 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2482 "maximum-paths ibgp " CMD_RANGE_STR(
2483 1, MULTIPATH_NUM
) " equal-cluster-length",
2484 "Forward packets over multiple paths\n"
2487 "Match the cluster length\n")
2489 DEFUN (no_bgp_maxpaths
,
2490 no_bgp_maxpaths_cmd
,
2491 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2493 "Forward packets over multiple paths\n"
2494 "Number of paths\n")
2496 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2499 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2500 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2501 "Forward packets over multiple paths\n"
2502 "Number of paths\n")
2504 DEFUN (no_bgp_maxpaths_ibgp
,
2505 no_bgp_maxpaths_ibgp_cmd
,
2506 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2508 "Forward packets over multiple paths\n"
2511 "Match the cluster length\n")
2513 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2516 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2517 "no maximum-paths ibgp [" CMD_RANGE_STR(
2518 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2520 "Forward packets over multiple paths\n"
2523 "Match the cluster length\n")
2525 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2526 afi_t afi
, safi_t safi
)
2528 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2529 vty_out(vty
, " maximum-paths %d\n",
2530 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2533 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2534 vty_out(vty
, " maximum-paths ibgp %d",
2535 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2536 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2537 vty_out(vty
, " equal-cluster-length");
2546 "timers bgp (0-65535) (0-65535)",
2547 "Adjust routing timers\n"
2549 "Keepalive interval\n"
2552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2554 int idx_number_2
= 3;
2555 unsigned long keepalive
= 0;
2556 unsigned long holdtime
= 0;
2558 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2559 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2561 /* Holdtime value check. */
2562 if (holdtime
< 3 && holdtime
!= 0) {
2564 "%% hold time value must be either 0 or greater than 3\n");
2565 return CMD_WARNING_CONFIG_FAILED
;
2568 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2569 BGP_DEFAULT_DELAYOPEN
);
2574 DEFUN (no_bgp_timers
,
2576 "no timers bgp [(0-65535) (0-65535)]",
2578 "Adjust routing timers\n"
2580 "Keepalive interval\n"
2583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2584 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2585 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2590 /* BGP minimum holdtime. */
2592 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2593 "bgp minimum-holdtime (1-65535)",
2594 "BGP specific commands\n"
2595 "BGP minimum holdtime\n"
2598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2600 unsigned long min_holdtime
;
2602 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2604 bgp
->default_min_holdtime
= min_holdtime
;
2609 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2610 "no bgp minimum-holdtime [(1-65535)]",
2612 "BGP specific commands\n"
2613 "BGP minimum holdtime\n"
2616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2618 bgp
->default_min_holdtime
= 0;
2623 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2624 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2626 "TCP keepalive parameters\n"
2627 "TCP keepalive idle time (seconds)\n"
2628 "TCP keepalive interval (seconds)\n"
2629 "TCP keepalive maximum probes\n")
2631 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2633 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2639 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2640 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2643 "TCP keepalive parameters\n"
2644 "TCP keepalive idle time (seconds)\n"
2645 "TCP keepalive interval (seconds)\n"
2646 "TCP keepalive maximum probes\n")
2648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2650 bgp_tcp_keepalive_unset(bgp
);
2655 DEFUN (bgp_client_to_client_reflection
,
2656 bgp_client_to_client_reflection_cmd
,
2657 "bgp client-to-client reflection",
2659 "Configure client to client route reflection\n"
2660 "reflection of routes allowed\n")
2662 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2663 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2664 bgp_clear_star_soft_out(vty
, bgp
->name
);
2669 DEFUN (no_bgp_client_to_client_reflection
,
2670 no_bgp_client_to_client_reflection_cmd
,
2671 "no bgp client-to-client reflection",
2674 "Configure client to client route reflection\n"
2675 "reflection of routes allowed\n")
2677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2678 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2679 bgp_clear_star_soft_out(vty
, bgp
->name
);
2684 /* "bgp always-compare-med" configuration. */
2685 DEFUN (bgp_always_compare_med
,
2686 bgp_always_compare_med_cmd
,
2687 "bgp always-compare-med",
2689 "Allow comparing MED from different neighbors\n")
2691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2692 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2693 bgp_recalculate_all_bestpaths(bgp
);
2698 DEFUN (no_bgp_always_compare_med
,
2699 no_bgp_always_compare_med_cmd
,
2700 "no bgp always-compare-med",
2703 "Allow comparing MED from different neighbors\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2707 bgp_recalculate_all_bestpaths(bgp
);
2713 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2714 "bgp ebgp-requires-policy",
2716 "Require in and out policy for eBGP peers (RFC8212)\n")
2718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2719 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2723 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2724 "no bgp ebgp-requires-policy",
2727 "Require in and out policy for eBGP peers (RFC8212)\n")
2729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2730 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2734 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2735 "bgp suppress-duplicates",
2737 "Suppress duplicate updates if the route actually not changed\n")
2739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2740 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2744 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2745 "no bgp suppress-duplicates",
2748 "Suppress duplicate updates if the route actually not changed\n")
2750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2751 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2755 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2756 "bgp reject-as-sets",
2758 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2761 struct listnode
*node
, *nnode
;
2764 bgp
->reject_as_sets
= true;
2766 /* Reset existing BGP sessions to reject routes
2767 * with aspath containing AS_SET or AS_CONFED_SET.
2769 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2770 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2771 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2772 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2773 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2780 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2781 "no bgp reject-as-sets",
2784 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2786 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2787 struct listnode
*node
, *nnode
;
2790 bgp
->reject_as_sets
= false;
2792 /* Reset existing BGP sessions to reject routes
2793 * with aspath containing AS_SET or AS_CONFED_SET.
2795 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2796 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2797 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2798 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2799 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2806 /* "bgp deterministic-med" configuration. */
2807 DEFUN (bgp_deterministic_med
,
2808 bgp_deterministic_med_cmd
,
2809 "bgp deterministic-med",
2811 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2815 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2816 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2817 bgp_recalculate_all_bestpaths(bgp
);
2823 DEFUN (no_bgp_deterministic_med
,
2824 no_bgp_deterministic_med_cmd
,
2825 "no bgp deterministic-med",
2828 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2831 int bestpath_per_as_used
;
2835 struct listnode
*node
, *nnode
;
2837 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2838 bestpath_per_as_used
= 0;
2840 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2841 FOREACH_AFI_SAFI (afi
, safi
)
2842 if (bgp_addpath_dmed_required(
2843 peer
->addpath_type
[afi
][safi
])) {
2844 bestpath_per_as_used
= 1;
2848 if (bestpath_per_as_used
)
2852 if (bestpath_per_as_used
) {
2854 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2855 return CMD_WARNING_CONFIG_FAILED
;
2857 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2858 bgp_recalculate_all_bestpaths(bgp
);
2865 /* "bgp graceful-restart mode" configuration. */
2866 DEFUN (bgp_graceful_restart
,
2867 bgp_graceful_restart_cmd
,
2868 "bgp graceful-restart",
2873 int ret
= BGP_GR_FAILURE
;
2875 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2876 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2878 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2880 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2882 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2885 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2886 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2888 "Graceful restart configuration changed, reset all peers to take effect\n");
2889 return bgp_vty_return(vty
, ret
);
2892 DEFUN (no_bgp_graceful_restart
,
2893 no_bgp_graceful_restart_cmd
,
2894 "no bgp graceful-restart",
2900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2902 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2903 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2905 int ret
= BGP_GR_FAILURE
;
2907 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2909 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2912 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2913 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2915 "Graceful restart configuration changed, reset all peers to take effect\n");
2917 return bgp_vty_return(vty
, ret
);
2920 DEFUN (bgp_graceful_restart_stalepath_time
,
2921 bgp_graceful_restart_stalepath_time_cmd
,
2922 "bgp graceful-restart stalepath-time (1-4095)",
2924 "Graceful restart capability parameters\n"
2925 "Set the max time to hold onto restarting peer's stale paths\n"
2926 "Delay value (seconds)\n")
2928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2932 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2933 bgp
->stalepath_time
= stalepath
;
2937 DEFUN (bgp_graceful_restart_restart_time
,
2938 bgp_graceful_restart_restart_time_cmd
,
2939 "bgp graceful-restart restart-time (0-4095)",
2941 "Graceful restart capability parameters\n"
2942 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2943 "Delay value (seconds)\n")
2945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2949 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2950 bgp
->restart_time
= restart
;
2954 DEFUN (bgp_graceful_restart_select_defer_time
,
2955 bgp_graceful_restart_select_defer_time_cmd
,
2956 "bgp graceful-restart select-defer-time (0-3600)",
2958 "Graceful restart capability parameters\n"
2959 "Set the time to defer the BGP route selection after restart\n"
2960 "Delay value (seconds, 0 - disable)\n")
2962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2964 uint32_t defer_time
;
2966 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2967 bgp
->select_defer_time
= defer_time
;
2968 if (defer_time
== 0)
2969 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2971 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2976 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2977 no_bgp_graceful_restart_stalepath_time_cmd
,
2978 "no bgp graceful-restart stalepath-time [(1-4095)]",
2981 "Graceful restart capability parameters\n"
2982 "Set the max time to hold onto restarting peer's stale paths\n"
2983 "Delay value (seconds)\n")
2985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2987 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2991 DEFUN (no_bgp_graceful_restart_restart_time
,
2992 no_bgp_graceful_restart_restart_time_cmd
,
2993 "no bgp graceful-restart restart-time [(0-4095)]",
2996 "Graceful restart capability parameters\n"
2997 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2998 "Delay value (seconds)\n")
3000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3002 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3006 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3007 no_bgp_graceful_restart_select_defer_time_cmd
,
3008 "no bgp graceful-restart select-defer-time [(0-3600)]",
3011 "Graceful restart capability parameters\n"
3012 "Set the time to defer the BGP route selection after restart\n"
3013 "Delay value (seconds)\n")
3015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3017 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3018 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3023 DEFUN (bgp_graceful_restart_preserve_fw
,
3024 bgp_graceful_restart_preserve_fw_cmd
,
3025 "bgp graceful-restart preserve-fw-state",
3027 "Graceful restart capability parameters\n"
3028 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3031 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3035 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3036 no_bgp_graceful_restart_preserve_fw_cmd
,
3037 "no bgp graceful-restart preserve-fw-state",
3040 "Graceful restart capability parameters\n"
3041 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3044 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3048 DEFPY (bgp_graceful_restart_notification
,
3049 bgp_graceful_restart_notification_cmd
,
3050 "[no$no] bgp graceful-restart notification",
3053 "Graceful restart capability parameters\n"
3054 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3059 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3061 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3066 DEFPY (bgp_administrative_reset
,
3067 bgp_administrative_reset_cmd
,
3068 "[no$no] bgp hard-administrative-reset",
3071 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3073 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3076 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3078 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3083 DEFUN (bgp_graceful_restart_disable
,
3084 bgp_graceful_restart_disable_cmd
,
3085 "bgp graceful-restart-disable",
3089 int ret
= BGP_GR_FAILURE
;
3091 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3093 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3097 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3099 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3102 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3104 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3106 "Graceful restart configuration changed, reset all peers to take effect\n");
3108 return bgp_vty_return(vty
, ret
);
3111 DEFUN (no_bgp_graceful_restart_disable
,
3112 no_bgp_graceful_restart_disable_cmd
,
3113 "no bgp graceful-restart-disable",
3119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3121 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3123 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3125 int ret
= BGP_GR_FAILURE
;
3127 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3129 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3132 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3134 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3136 "Graceful restart configuration changed, reset all peers to take effect\n");
3138 return bgp_vty_return(vty
, ret
);
3141 DEFUN (bgp_neighbor_graceful_restart_set
,
3142 bgp_neighbor_graceful_restart_set_cmd
,
3143 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3151 int ret
= BGP_GR_FAILURE
;
3153 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3155 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3157 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3159 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3161 return CMD_WARNING_CONFIG_FAILED
;
3163 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3165 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3166 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3168 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3170 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3172 "Graceful restart configuration changed, reset this peer to take effect\n");
3174 return bgp_vty_return(vty
, ret
);
3177 DEFUN (no_bgp_neighbor_graceful_restart
,
3178 no_bgp_neighbor_graceful_restart_set_cmd
,
3179 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3187 int ret
= BGP_GR_FAILURE
;
3190 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3192 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3194 return CMD_WARNING_CONFIG_FAILED
;
3196 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3198 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3200 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3202 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3203 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3205 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3207 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3209 "Graceful restart configuration changed, reset this peer to take effect\n");
3211 return bgp_vty_return(vty
, ret
);
3214 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3215 bgp_neighbor_graceful_restart_helper_set_cmd
,
3216 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3219 GR_NEIGHBOR_HELPER_CMD
3224 int ret
= BGP_GR_FAILURE
;
3226 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3228 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3230 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3232 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3235 return CMD_WARNING_CONFIG_FAILED
;
3238 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3240 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3241 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3243 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3245 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3247 "Graceful restart configuration changed, reset this peer to take effect\n");
3249 return bgp_vty_return(vty
, ret
);
3252 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3253 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3254 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3258 NO_GR_NEIGHBOR_HELPER_CMD
3262 int ret
= BGP_GR_FAILURE
;
3265 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3267 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3269 return CMD_WARNING_CONFIG_FAILED
;
3271 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3273 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3275 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3277 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3278 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3280 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3282 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3284 "Graceful restart configuration changed, reset this peer to take effect\n");
3286 return bgp_vty_return(vty
, ret
);
3289 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3290 bgp_neighbor_graceful_restart_disable_set_cmd
,
3291 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3294 GR_NEIGHBOR_DISABLE_CMD
3299 int ret
= BGP_GR_FAILURE
;
3301 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3303 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3305 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3307 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3309 return CMD_WARNING_CONFIG_FAILED
;
3311 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3313 if (peer
->bgp
->t_startup
)
3314 bgp_peer_gr_flags_update(peer
);
3316 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3317 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3319 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3321 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3323 "Graceful restart configuration changed, reset this peer to take effect\n");
3325 return bgp_vty_return(vty
, ret
);
3328 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3329 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3330 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3334 NO_GR_NEIGHBOR_DISABLE_CMD
3338 int ret
= BGP_GR_FAILURE
;
3341 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3343 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3345 return CMD_WARNING_CONFIG_FAILED
;
3347 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3349 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3351 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3353 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3354 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3356 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3358 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3360 "Graceful restart configuration changed, reset this peer to take effect\n");
3362 return bgp_vty_return(vty
, ret
);
3365 DEFPY (neighbor_graceful_shutdown
,
3366 neighbor_graceful_shutdown_cmd
,
3367 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3371 "Graceful shutdown\n")
3376 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3379 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3381 return CMD_WARNING_CONFIG_FAILED
;
3384 ret
= peer_flag_unset_vty(vty
, neighbor
,
3385 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3387 ret
= peer_flag_set_vty(vty
, neighbor
,
3388 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3390 FOREACH_AFI_SAFI (afi
, safi
) {
3391 if (!peer
->afc
[afi
][safi
])
3394 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3401 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3402 bgp_graceful_restart_disable_eor_cmd
,
3403 "bgp graceful-restart disable-eor",
3405 "Graceful restart configuration parameters\n"
3406 "Disable EOR Check\n")
3408 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3409 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3414 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3415 no_bgp_graceful_restart_disable_eor_cmd
,
3416 "no bgp graceful-restart disable-eor",
3419 "Graceful restart configuration parameters\n"
3420 "Disable EOR Check\n")
3422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3423 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3428 DEFUN (bgp_graceful_restart_rib_stale_time
,
3429 bgp_graceful_restart_rib_stale_time_cmd
,
3430 "bgp graceful-restart rib-stale-time (1-3600)",
3432 "Graceful restart configuration parameters\n"
3433 "Specify the stale route removal timer in rib\n"
3434 "Delay value (seconds)\n")
3436 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3438 uint32_t stale_time
;
3440 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3441 bgp
->rib_stale_time
= stale_time
;
3442 /* Send the stale timer update message to RIB */
3443 if (bgp_zebra_stale_timer_update(bgp
))
3449 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3450 no_bgp_graceful_restart_rib_stale_time_cmd
,
3451 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3454 "Graceful restart configuration parameters\n"
3455 "Specify the stale route removal timer in rib\n"
3456 "Delay value (seconds)\n")
3458 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3460 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3461 /* Send the stale timer update message to RIB */
3462 if (bgp_zebra_stale_timer_update(bgp
))
3468 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3469 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3471 "Enable Long-lived Graceful Restart\n"
3472 "Specifies maximum time to wait before purging long-lived stale routes\n"
3473 "Stale time value (seconds)\n")
3475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3477 uint32_t llgr_stale_time
;
3479 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3480 bgp
->llgr_stale_time
= llgr_stale_time
;
3485 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3486 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3488 "Enable Long-lived Graceful Restart\n"
3489 "Specifies maximum time to wait before purging long-lived stale routes\n"
3490 "Stale time value (seconds)\n")
3492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3494 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3499 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3502 bgp_static_redo_import_check(bgp
);
3503 bgp_redistribute_redo(bgp
);
3504 bgp_clear_star_soft_out(vty
, bgp
->name
);
3505 bgp_clear_star_soft_in(vty
, bgp
->name
);
3508 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3510 struct listnode
*node
, *nnode
;
3512 bool vrf_cfg
= false;
3514 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3517 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3518 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3519 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3521 "%% graceful-shutdown configuration found in vrf %s\n",
3522 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3523 VRF_DEFAULT_NAME
: bgp
->name
);
3530 "%%Failed: global graceful-shutdown not permitted\n");
3534 /* Set flag globally */
3535 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3537 /* Initiate processing for all BGP instances. */
3538 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3539 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3544 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3546 struct listnode
*node
, *nnode
;
3549 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3552 /* Unset flag globally */
3553 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3555 /* Initiate processing for all BGP instances. */
3556 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3557 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3562 /* "bgp graceful-shutdown" configuration */
3563 DEFUN (bgp_graceful_shutdown
,
3564 bgp_graceful_shutdown_cmd
,
3565 "bgp graceful-shutdown",
3567 "Graceful shutdown parameters\n")
3569 if (vty
->node
== CONFIG_NODE
)
3570 return bgp_global_graceful_shutdown_config_vty(vty
);
3572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3574 /* if configured globally, per-instance config is not allowed */
3575 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3577 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3578 return CMD_WARNING_CONFIG_FAILED
;
3581 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3582 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3583 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3589 DEFUN (no_bgp_graceful_shutdown
,
3590 no_bgp_graceful_shutdown_cmd
,
3591 "no bgp graceful-shutdown",
3594 "Graceful shutdown parameters\n")
3596 if (vty
->node
== CONFIG_NODE
)
3597 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3601 /* If configured globally, cannot remove from one bgp instance */
3602 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3604 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3605 return CMD_WARNING_CONFIG_FAILED
;
3608 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3609 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3610 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3616 /* "bgp fast-external-failover" configuration. */
3617 DEFUN (bgp_fast_external_failover
,
3618 bgp_fast_external_failover_cmd
,
3619 "bgp fast-external-failover",
3621 "Immediately reset session if a link to a directly connected external peer goes down\n")
3623 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3624 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3628 DEFUN (no_bgp_fast_external_failover
,
3629 no_bgp_fast_external_failover_cmd
,
3630 "no bgp fast-external-failover",
3633 "Immediately reset session if a link to a directly connected external peer goes down\n")
3635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3636 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3640 DEFPY (bgp_bestpath_aigp
,
3641 bgp_bestpath_aigp_cmd
,
3642 "[no$no] bgp bestpath aigp",
3645 "Change the default bestpath selection\n"
3646 "Evaluate the AIGP attribute during the best path selection process\n")
3648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3651 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3653 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3655 bgp_recalculate_all_bestpaths(bgp
);
3660 /* "bgp bestpath compare-routerid" configuration. */
3661 DEFUN (bgp_bestpath_compare_router_id
,
3662 bgp_bestpath_compare_router_id_cmd
,
3663 "bgp bestpath compare-routerid",
3665 "Change the default bestpath selection\n"
3666 "Compare router-id for identical EBGP paths\n")
3668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3669 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3670 bgp_recalculate_all_bestpaths(bgp
);
3675 DEFUN (no_bgp_bestpath_compare_router_id
,
3676 no_bgp_bestpath_compare_router_id_cmd
,
3677 "no bgp bestpath compare-routerid",
3680 "Change the default bestpath selection\n"
3681 "Compare router-id for identical EBGP paths\n")
3683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3684 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3685 bgp_recalculate_all_bestpaths(bgp
);
3690 /* "bgp bestpath as-path ignore" configuration. */
3691 DEFUN (bgp_bestpath_aspath_ignore
,
3692 bgp_bestpath_aspath_ignore_cmd
,
3693 "bgp bestpath as-path ignore",
3695 "Change the default bestpath selection\n"
3696 "AS-path attribute\n"
3697 "Ignore as-path length in selecting a route\n")
3699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3700 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3701 bgp_recalculate_all_bestpaths(bgp
);
3706 DEFUN (no_bgp_bestpath_aspath_ignore
,
3707 no_bgp_bestpath_aspath_ignore_cmd
,
3708 "no bgp bestpath as-path ignore",
3711 "Change the default bestpath selection\n"
3712 "AS-path attribute\n"
3713 "Ignore as-path length in selecting a route\n")
3715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3716 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3717 bgp_recalculate_all_bestpaths(bgp
);
3722 /* "bgp bestpath as-path confed" configuration. */
3723 DEFUN (bgp_bestpath_aspath_confed
,
3724 bgp_bestpath_aspath_confed_cmd
,
3725 "bgp bestpath as-path confed",
3727 "Change the default bestpath selection\n"
3728 "AS-path attribute\n"
3729 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3732 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3733 bgp_recalculate_all_bestpaths(bgp
);
3738 DEFUN (no_bgp_bestpath_aspath_confed
,
3739 no_bgp_bestpath_aspath_confed_cmd
,
3740 "no bgp bestpath as-path confed",
3743 "Change the default bestpath selection\n"
3744 "AS-path attribute\n"
3745 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3747 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3748 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3749 bgp_recalculate_all_bestpaths(bgp
);
3754 /* "bgp bestpath as-path multipath-relax" configuration. */
3755 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3756 bgp_bestpath_aspath_multipath_relax_cmd
,
3757 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3759 "Change the default bestpath selection\n"
3760 "AS-path attribute\n"
3761 "Allow load sharing across routes that have different AS paths (but same length)\n"
3762 "Generate an AS_SET\n"
3763 "Do not generate an AS_SET\n")
3765 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3767 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3769 /* no-as-set is now the default behavior so we can silently
3771 if (argv_find(argv
, argc
, "as-set", &idx
))
3772 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3774 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3776 bgp_recalculate_all_bestpaths(bgp
);
3781 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3782 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3783 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3786 "Change the default bestpath selection\n"
3787 "AS-path attribute\n"
3788 "Allow load sharing across routes that have different AS paths (but same length)\n"
3789 "Generate an AS_SET\n"
3790 "Do not generate an AS_SET\n")
3792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3793 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3794 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3795 bgp_recalculate_all_bestpaths(bgp
);
3800 /* "bgp bestpath peer-type multipath-relax" configuration. */
3801 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3802 bgp_bestpath_peer_type_multipath_relax_cmd
,
3803 "bgp bestpath peer-type multipath-relax",
3805 "Change the default bestpath selection\n"
3807 "Allow load sharing across routes learned from different peer types\n")
3809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3810 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3811 bgp_recalculate_all_bestpaths(bgp
);
3816 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3817 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3818 "no bgp bestpath peer-type multipath-relax",
3820 "Change the default bestpath selection\n"
3822 "Allow load sharing across routes learned from different peer types\n")
3824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3825 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3826 bgp_recalculate_all_bestpaths(bgp
);
3831 /* "bgp log-neighbor-changes" configuration. */
3832 DEFUN (bgp_log_neighbor_changes
,
3833 bgp_log_neighbor_changes_cmd
,
3834 "bgp log-neighbor-changes",
3836 "Log neighbor up/down and reset reason\n")
3838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3839 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3843 DEFUN (no_bgp_log_neighbor_changes
,
3844 no_bgp_log_neighbor_changes_cmd
,
3845 "no bgp log-neighbor-changes",
3848 "Log neighbor up/down and reset reason\n")
3850 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3851 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3855 /* "bgp bestpath med" configuration. */
3856 DEFUN (bgp_bestpath_med
,
3857 bgp_bestpath_med_cmd
,
3858 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3860 "Change the default bestpath selection\n"
3862 "Compare MED among confederation paths\n"
3863 "Treat missing MED as the least preferred one\n"
3864 "Treat missing MED as the least preferred one\n"
3865 "Compare MED among confederation paths\n")
3867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3870 if (argv_find(argv
, argc
, "confed", &idx
))
3871 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3873 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3874 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3876 bgp_recalculate_all_bestpaths(bgp
);
3881 DEFUN (no_bgp_bestpath_med
,
3882 no_bgp_bestpath_med_cmd
,
3883 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3886 "Change the default bestpath selection\n"
3888 "Compare MED among confederation paths\n"
3889 "Treat missing MED as the least preferred one\n"
3890 "Treat missing MED as the least preferred one\n"
3891 "Compare MED among confederation paths\n")
3893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3896 if (argv_find(argv
, argc
, "confed", &idx
))
3897 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3899 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3900 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3902 bgp_recalculate_all_bestpaths(bgp
);
3907 /* "bgp bestpath bandwidth" configuration. */
3908 DEFPY (bgp_bestpath_bw
,
3909 bgp_bestpath_bw_cmd
,
3910 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3912 "Change the default bestpath selection\n"
3913 "Link Bandwidth attribute\n"
3914 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3915 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3916 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3923 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3924 return CMD_ERR_INCOMPLETE
;
3926 if (!strcmp(bw_cfg
, "ignore"))
3927 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3928 else if (!strcmp(bw_cfg
, "skip-missing"))
3929 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3930 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3931 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3933 return CMD_ERR_NO_MATCH
;
3935 /* This config is used in route install, so redo that. */
3936 FOREACH_AFI_SAFI (afi
, safi
) {
3937 if (!bgp_fibupd_safi(safi
))
3939 bgp_zebra_announce_table(bgp
, afi
, safi
);
3945 DEFPY (no_bgp_bestpath_bw
,
3946 no_bgp_bestpath_bw_cmd
,
3947 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3950 "Change the default bestpath selection\n"
3951 "Link Bandwidth attribute\n"
3952 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3953 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3954 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3960 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3962 /* This config is used in route install, so redo that. */
3963 FOREACH_AFI_SAFI (afi
, safi
) {
3964 if (!bgp_fibupd_safi(safi
))
3966 bgp_zebra_announce_table(bgp
, afi
, safi
);
3971 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3972 "[no] bgp default <ipv4-unicast|"
3975 "ipv4-labeled-unicast|"
3980 "ipv6-labeled-unicast|"
3982 "l2vpn-evpn>$afi_safi",
3985 "Configure BGP defaults\n"
3986 "Activate ipv4-unicast for a peer by default\n"
3987 "Activate ipv4-multicast for a peer by default\n"
3988 "Activate ipv4-vpn for a peer by default\n"
3989 "Activate ipv4-labeled-unicast for a peer by default\n"
3990 "Activate ipv4-flowspec for a peer by default\n"
3991 "Activate ipv6-unicast for a peer by default\n"
3992 "Activate ipv6-multicast for a peer by default\n"
3993 "Activate ipv6-vpn for a peer by default\n"
3994 "Activate ipv6-labeled-unicast for a peer by default\n"
3995 "Activate ipv6-flowspec for a peer by default\n"
3996 "Activate l2vpn-evpn for a peer by default\n")
3998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3999 char afi_safi_str
[strlen(afi_safi
) + 1];
4000 char *afi_safi_str_tok
;
4002 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4003 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4004 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4005 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4009 * Impossible situation but making coverity happy
4011 assert(afi
!= AFI_MAX
);
4013 if (strmatch(safi_str
, "labeled"))
4014 safi
= bgp_vty_safi_from_str("labeled-unicast");
4016 safi
= bgp_vty_safi_from_str(safi_str
);
4018 assert(safi
!= SAFI_MAX
);
4020 bgp
->default_af
[afi
][safi
] = false;
4022 if ((safi
== SAFI_LABELED_UNICAST
4023 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4024 || (safi
== SAFI_UNICAST
4025 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4026 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4028 bgp
->default_af
[afi
][safi
] = true;
4034 /* Display hostname in certain command outputs */
4035 DEFUN (bgp_default_show_hostname
,
4036 bgp_default_show_hostname_cmd
,
4037 "bgp default show-hostname",
4039 "Configure BGP defaults\n"
4040 "Show hostname in certain command outputs\n")
4042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4043 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4047 DEFUN (no_bgp_default_show_hostname
,
4048 no_bgp_default_show_hostname_cmd
,
4049 "no bgp default show-hostname",
4052 "Configure BGP defaults\n"
4053 "Show hostname in certain command outputs\n")
4055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4056 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4060 /* Display hostname in certain command outputs */
4061 DEFUN (bgp_default_show_nexthop_hostname
,
4062 bgp_default_show_nexthop_hostname_cmd
,
4063 "bgp default show-nexthop-hostname",
4065 "Configure BGP defaults\n"
4066 "Show hostname for nexthop in certain command outputs\n")
4068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4069 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4073 DEFUN (no_bgp_default_show_nexthop_hostname
,
4074 no_bgp_default_show_nexthop_hostname_cmd
,
4075 "no bgp default show-nexthop-hostname",
4078 "Configure BGP defaults\n"
4079 "Show hostname for nexthop in certain command outputs\n")
4081 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4082 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4086 /* "bgp network import-check" configuration. */
4087 DEFUN (bgp_network_import_check
,
4088 bgp_network_import_check_cmd
,
4089 "bgp network import-check",
4091 "BGP network command\n"
4092 "Check BGP network route exists in IGP\n")
4094 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4095 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4096 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4097 bgp_static_redo_import_check(bgp
);
4103 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4104 "bgp network import-check exact",
4106 "BGP network command\n"
4107 "Check BGP network route exists in IGP\n"
4108 "Match route precisely\n")
4110 DEFUN (no_bgp_network_import_check
,
4111 no_bgp_network_import_check_cmd
,
4112 "no bgp network import-check",
4115 "BGP network command\n"
4116 "Check BGP network route exists in IGP\n")
4118 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4119 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4120 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4121 bgp_static_redo_import_check(bgp
);
4127 DEFUN (bgp_default_local_preference
,
4128 bgp_default_local_preference_cmd
,
4129 "bgp default local-preference (0-4294967295)",
4131 "Configure BGP defaults\n"
4132 "local preference (higher=more preferred)\n"
4133 "Configure default local preference value\n")
4135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4137 uint32_t local_pref
;
4139 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4141 bgp_default_local_preference_set(bgp
, local_pref
);
4142 bgp_clear_star_soft_in(vty
, bgp
->name
);
4147 DEFUN (no_bgp_default_local_preference
,
4148 no_bgp_default_local_preference_cmd
,
4149 "no bgp default local-preference [(0-4294967295)]",
4152 "Configure BGP defaults\n"
4153 "local preference (higher=more preferred)\n"
4154 "Configure default local preference value\n")
4156 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4157 bgp_default_local_preference_unset(bgp
);
4158 bgp_clear_star_soft_in(vty
, bgp
->name
);
4164 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4165 bgp_default_subgroup_pkt_queue_max_cmd
,
4166 "bgp default subgroup-pkt-queue-max (20-100)",
4168 "Configure BGP defaults\n"
4169 "subgroup-pkt-queue-max\n"
4170 "Configure subgroup packet queue max\n")
4172 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4176 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4178 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4183 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4184 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4185 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4188 "Configure BGP defaults\n"
4189 "subgroup-pkt-queue-max\n"
4190 "Configure subgroup packet queue max\n")
4192 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4193 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4198 DEFUN (bgp_rr_allow_outbound_policy
,
4199 bgp_rr_allow_outbound_policy_cmd
,
4200 "bgp route-reflector allow-outbound-policy",
4202 "Allow modifications made by out route-map\n"
4203 "on ibgp neighbors\n")
4205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4207 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4208 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4209 update_group_announce_rrclients(bgp
);
4210 bgp_clear_star_soft_out(vty
, bgp
->name
);
4216 DEFUN (no_bgp_rr_allow_outbound_policy
,
4217 no_bgp_rr_allow_outbound_policy_cmd
,
4218 "no bgp route-reflector allow-outbound-policy",
4221 "Allow modifications made by out route-map\n"
4222 "on ibgp neighbors\n")
4224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4226 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4227 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4228 update_group_announce_rrclients(bgp
);
4229 bgp_clear_star_soft_out(vty
, bgp
->name
);
4235 DEFUN (bgp_listen_limit
,
4236 bgp_listen_limit_cmd
,
4237 "bgp listen limit (1-65535)",
4239 "BGP Dynamic Neighbors listen commands\n"
4240 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4241 "Configure Dynamic Neighbors listen limit value\n")
4243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4247 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4249 bgp_listen_limit_set(bgp
, listen_limit
);
4254 DEFUN (no_bgp_listen_limit
,
4255 no_bgp_listen_limit_cmd
,
4256 "no bgp listen limit [(1-65535)]",
4259 "BGP Dynamic Neighbors listen commands\n"
4260 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4261 "Configure Dynamic Neighbors listen limit value\n")
4263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4264 bgp_listen_limit_unset(bgp
);
4270 * Check if this listen range is already configured. Check for exact
4271 * match or overlap based on input.
4273 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4274 struct prefix
*range
, int exact
)
4276 struct listnode
*node
, *nnode
;
4277 struct listnode
*node1
, *nnode1
;
4278 struct peer_group
*group
;
4283 afi
= family2afi(range
->family
);
4284 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4285 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4288 match
= prefix_same(range
, lr
);
4290 match
= (prefix_match(range
, lr
)
4291 || prefix_match(lr
, range
));
4300 DEFUN (bgp_listen_range
,
4301 bgp_listen_range_cmd
,
4302 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4304 "Configure BGP dynamic neighbors listen range\n"
4305 "Configure BGP dynamic neighbors listen range\n"
4307 "Member of the peer-group\n"
4308 "Peer-group name\n")
4310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4311 struct prefix range
;
4312 struct peer_group
*group
, *existing_group
;
4317 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4318 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4319 char *prefix
= argv
[idx
]->arg
;
4320 argv_find(argv
, argc
, "PGNAME", &idx
);
4321 char *peergroup
= argv
[idx
]->arg
;
4323 /* Convert IP prefix string to struct prefix. */
4324 ret
= str2prefix(prefix
, &range
);
4326 vty_out(vty
, "%% Malformed listen range\n");
4327 return CMD_WARNING_CONFIG_FAILED
;
4330 afi
= family2afi(range
.family
);
4332 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4334 "%% Malformed listen range (link-local address)\n");
4335 return CMD_WARNING_CONFIG_FAILED
;
4340 /* Check if same listen range is already configured. */
4341 existing_group
= listen_range_exists(bgp
, &range
, 1);
4342 if (existing_group
) {
4343 if (strcmp(existing_group
->name
, peergroup
) == 0)
4347 "%% Same listen range is attached to peer-group %s\n",
4348 existing_group
->name
);
4349 return CMD_WARNING_CONFIG_FAILED
;
4353 /* Check if an overlapping listen range exists. */
4354 if (listen_range_exists(bgp
, &range
, 0)) {
4356 "%% Listen range overlaps with existing listen range\n");
4357 return CMD_WARNING_CONFIG_FAILED
;
4360 group
= peer_group_lookup(bgp
, peergroup
);
4362 vty_out(vty
, "%% Configure the peer-group first\n");
4363 return CMD_WARNING_CONFIG_FAILED
;
4366 ret
= peer_group_listen_range_add(group
, &range
);
4367 return bgp_vty_return(vty
, ret
);
4370 DEFUN (no_bgp_listen_range
,
4371 no_bgp_listen_range_cmd
,
4372 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4375 "Unconfigure BGP dynamic neighbors listen range\n"
4376 "Unconfigure BGP dynamic neighbors listen range\n"
4378 "Member of the peer-group\n"
4379 "Peer-group name\n")
4381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4382 struct prefix range
;
4383 struct peer_group
*group
;
4388 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4389 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4390 char *prefix
= argv
[idx
]->arg
;
4391 argv_find(argv
, argc
, "PGNAME", &idx
);
4392 char *peergroup
= argv
[idx
]->arg
;
4394 /* Convert IP prefix string to struct prefix. */
4395 ret
= str2prefix(prefix
, &range
);
4397 vty_out(vty
, "%% Malformed listen range\n");
4398 return CMD_WARNING_CONFIG_FAILED
;
4401 afi
= family2afi(range
.family
);
4403 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4405 "%% Malformed listen range (link-local address)\n");
4406 return CMD_WARNING_CONFIG_FAILED
;
4411 group
= peer_group_lookup(bgp
, peergroup
);
4413 vty_out(vty
, "%% Peer-group does not exist\n");
4414 return CMD_WARNING_CONFIG_FAILED
;
4417 ret
= peer_group_listen_range_del(group
, &range
);
4418 return bgp_vty_return(vty
, ret
);
4421 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4423 struct peer_group
*group
;
4424 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4425 struct prefix
*range
;
4428 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4429 vty_out(vty
, " bgp listen limit %d\n",
4430 bgp
->dynamic_neighbors_limit
);
4432 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4433 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4434 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4437 " bgp listen range %pFX peer-group %s\n",
4438 range
, group
->name
);
4445 DEFUN (bgp_disable_connected_route_check
,
4446 bgp_disable_connected_route_check_cmd
,
4447 "bgp disable-ebgp-connected-route-check",
4449 "Disable checking if nexthop is connected on ebgp sessions\n")
4451 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4452 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4453 bgp_clear_star_soft_in(vty
, bgp
->name
);
4458 DEFUN (no_bgp_disable_connected_route_check
,
4459 no_bgp_disable_connected_route_check_cmd
,
4460 "no bgp disable-ebgp-connected-route-check",
4463 "Disable checking if nexthop is connected on ebgp sessions\n")
4465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4466 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4467 bgp_clear_star_soft_in(vty
, bgp
->name
);
4473 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4476 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4479 int as_type
= AS_SPECIFIED
;
4482 if (as_str
[0] == 'i') {
4484 as_type
= AS_INTERNAL
;
4485 } else if (as_str
[0] == 'e') {
4487 as_type
= AS_EXTERNAL
;
4489 /* Get AS number. */
4490 as
= strtoul(as_str
, NULL
, 10);
4493 /* If peer is peer group or interface peer, call proper function. */
4494 ret
= str2sockunion(peer_str
, &su
);
4498 /* Check if existing interface peer */
4499 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4501 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4503 /* if not interface peer, check peer-group settings */
4504 if (ret
< 0 && !peer
) {
4505 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4508 "%% Create the peer-group or interface first\n");
4509 return CMD_WARNING_CONFIG_FAILED
;
4514 if (peer_address_self_check(bgp
, &su
)) {
4516 "%% Can not configure the local system as neighbor\n");
4517 return CMD_WARNING_CONFIG_FAILED
;
4519 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4522 return bgp_vty_return(vty
, ret
);
4525 DEFUN (bgp_default_shutdown
,
4526 bgp_default_shutdown_cmd
,
4527 "[no] bgp default shutdown",
4530 "Configure BGP defaults\n"
4531 "Apply administrative shutdown to newly configured peers\n")
4533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4534 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4538 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4540 "Administrative shutdown of the BGP instance\n"
4541 "Add a shutdown message (RFC 8203)\n"
4542 "Shutdown message\n")
4544 char *msgstr
= NULL
;
4546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4549 msgstr
= argv_concat(argv
, argc
, 3);
4551 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4552 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4553 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4554 return CMD_WARNING_CONFIG_FAILED
;
4557 bgp_shutdown_enable(bgp
, msgstr
);
4558 XFREE(MTYPE_TMP
, msgstr
);
4563 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4564 BGP_STR
"Administrative shutdown of the BGP instance\n")
4566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4568 bgp_shutdown_enable(bgp
, NULL
);
4573 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4574 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4578 bgp_shutdown_disable(bgp
);
4583 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4584 "no bgp shutdown message MSG...", NO_STR BGP_STR
4585 "Administrative shutdown of the BGP instance\n"
4586 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4588 DEFUN (neighbor_remote_as
,
4589 neighbor_remote_as_cmd
,
4590 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4593 "Specify a BGP neighbor\n"
4595 "Internal BGP peer\n"
4596 "External BGP peer\n")
4599 int idx_remote_as
= 3;
4600 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4601 argv
[idx_remote_as
]->arg
);
4604 DEFPY (bgp_allow_martian
,
4605 bgp_allow_martian_cmd
,
4606 "[no]$no bgp allow-martian-nexthop",
4609 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4614 bgp
->allow_martian
= false;
4616 bgp
->allow_martian
= true;
4621 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4622 * sessions do not wait for hold timer expiry to bring down the sessions
4623 * when nexthop becomes unreachable
4625 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4626 BGP_STR
"Fast convergence for bgp sessions\n")
4628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4629 bgp
->fast_convergence
= true;
4634 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4635 "no bgp fast-convergence",
4636 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4639 bgp
->fast_convergence
= false;
4644 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4646 const char *peer_group_name
,
4649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4651 int as_type
= AS_UNSPECIFIED
;
4653 struct peer_group
*group
;
4656 group
= peer_group_lookup(bgp
, conf_if
);
4659 vty_out(vty
, "%% Name conflict with peer-group \n");
4660 return CMD_WARNING_CONFIG_FAILED
;
4664 if (as_str
[0] == 'i') {
4665 as_type
= AS_INTERNAL
;
4666 } else if (as_str
[0] == 'e') {
4667 as_type
= AS_EXTERNAL
;
4669 /* Get AS number. */
4670 as
= strtoul(as_str
, NULL
, 10);
4671 as_type
= AS_SPECIFIED
;
4675 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4678 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4680 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4684 vty_out(vty
, "%% BGP failed to create peer\n");
4685 return CMD_WARNING_CONFIG_FAILED
;
4689 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4691 /* Request zebra to initiate IPv6 RAs on this interface. We do
4693 * any unnumbered peer in order to not worry about run-time
4695 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4697 * gets deleted later etc.)
4700 bgp_zebra_initiate_radv(bgp
, peer
);
4703 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4704 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4706 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4708 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4710 /* v6only flag changed. Reset bgp seesion */
4711 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4712 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4713 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4714 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4716 bgp_session_reset(peer
);
4719 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4720 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4721 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4722 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4725 if (peer_group_name
) {
4726 group
= peer_group_lookup(bgp
, peer_group_name
);
4728 vty_out(vty
, "%% Configure the peer-group first\n");
4729 return CMD_WARNING_CONFIG_FAILED
;
4732 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4735 return bgp_vty_return(vty
, ret
);
4738 DEFUN (neighbor_interface_config
,
4739 neighbor_interface_config_cmd
,
4740 "neighbor WORD interface [peer-group PGNAME]",
4742 "Interface name or neighbor tag\n"
4743 "Enable BGP on interface\n"
4744 "Member of the peer-group\n"
4745 "Peer-group name\n")
4748 int idx_peer_group_word
= 4;
4750 if (argc
> idx_peer_group_word
)
4751 return peer_conf_interface_get(
4752 vty
, argv
[idx_word
]->arg
, 0,
4753 argv
[idx_peer_group_word
]->arg
, NULL
);
4755 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4759 DEFUN (neighbor_interface_config_v6only
,
4760 neighbor_interface_config_v6only_cmd
,
4761 "neighbor WORD interface v6only [peer-group PGNAME]",
4763 "Interface name or neighbor tag\n"
4764 "Enable BGP on interface\n"
4765 "Enable BGP with v6 link-local only\n"
4766 "Member of the peer-group\n"
4767 "Peer-group name\n")
4770 int idx_peer_group_word
= 5;
4772 if (argc
> idx_peer_group_word
)
4773 return peer_conf_interface_get(
4774 vty
, argv
[idx_word
]->arg
, 1,
4775 argv
[idx_peer_group_word
]->arg
, NULL
);
4777 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4781 DEFUN (neighbor_interface_config_remote_as
,
4782 neighbor_interface_config_remote_as_cmd
,
4783 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4785 "Interface name or neighbor tag\n"
4786 "Enable BGP on interface\n"
4787 "Specify a BGP neighbor\n"
4789 "Internal BGP peer\n"
4790 "External BGP peer\n")
4793 int idx_remote_as
= 4;
4794 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4795 argv
[idx_remote_as
]->arg
);
4798 DEFUN (neighbor_interface_v6only_config_remote_as
,
4799 neighbor_interface_v6only_config_remote_as_cmd
,
4800 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4802 "Interface name or neighbor tag\n"
4803 "Enable BGP with v6 link-local only\n"
4804 "Enable BGP on interface\n"
4805 "Specify a BGP neighbor\n"
4807 "Internal BGP peer\n"
4808 "External BGP peer\n")
4811 int idx_remote_as
= 5;
4812 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4813 argv
[idx_remote_as
]->arg
);
4816 DEFUN (neighbor_peer_group
,
4817 neighbor_peer_group_cmd
,
4818 "neighbor WORD peer-group",
4820 "Interface name or neighbor tag\n"
4821 "Configure peer-group\n")
4823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4826 struct peer_group
*group
;
4828 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4830 vty_out(vty
, "%% Name conflict with interface: \n");
4831 return CMD_WARNING_CONFIG_FAILED
;
4834 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4836 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4837 return CMD_WARNING_CONFIG_FAILED
;
4845 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4849 "Specify a BGP neighbor\n"
4851 "Internal BGP peer\n"
4852 "External BGP peer\n")
4854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4858 struct peer_group
*group
;
4862 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4864 /* look up for neighbor by interface name config. */
4865 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4867 /* Request zebra to terminate IPv6 RAs on this
4870 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4871 peer_notify_unconfig(peer
);
4876 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4878 peer_group_notify_unconfig(group
);
4879 peer_group_delete(group
);
4881 vty_out(vty
, "%% Create the peer-group first\n");
4882 return CMD_WARNING_CONFIG_FAILED
;
4885 peer
= peer_lookup(bgp
, &su
);
4887 if (peer_dynamic_neighbor(peer
)) {
4889 "%% Operation not allowed on a dynamic neighbor\n");
4890 return CMD_WARNING_CONFIG_FAILED
;
4893 other
= peer
->doppelganger
;
4895 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4896 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4898 peer_notify_unconfig(peer
);
4900 if (other
&& other
->status
!= Deleted
) {
4901 peer_notify_unconfig(other
);
4910 DEFUN (no_neighbor_interface_config
,
4911 no_neighbor_interface_config_cmd
,
4912 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4916 "Configure BGP on interface\n"
4917 "Enable BGP with v6 link-local only\n"
4918 "Member of the peer-group\n"
4920 "Specify a BGP neighbor\n"
4922 "Internal BGP peer\n"
4923 "External BGP peer\n")
4925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4929 /* look up for neighbor by interface name config. */
4930 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4932 /* Request zebra to terminate IPv6 RAs on this interface. */
4934 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4935 peer_notify_unconfig(peer
);
4938 vty_out(vty
, "%% Create the bgp interface first\n");
4939 return CMD_WARNING_CONFIG_FAILED
;
4944 DEFUN (no_neighbor_peer_group
,
4945 no_neighbor_peer_group_cmd
,
4946 "no neighbor WORD peer-group",
4950 "Configure peer-group\n")
4952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4954 struct peer_group
*group
;
4956 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4958 peer_group_notify_unconfig(group
);
4959 peer_group_delete(group
);
4961 vty_out(vty
, "%% Create the peer-group first\n");
4962 return CMD_WARNING_CONFIG_FAILED
;
4967 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4968 no_neighbor_interface_peer_group_remote_as_cmd
,
4969 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4972 "Interface name or neighbor tag\n"
4973 "Specify a BGP neighbor\n"
4975 "Internal BGP peer\n"
4976 "External BGP peer\n")
4978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4980 struct peer_group
*group
;
4983 /* look up for neighbor by interface name config. */
4984 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4986 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4990 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4992 peer_group_remote_as_delete(group
);
4994 vty_out(vty
, "%% Create the peer-group or interface first\n");
4995 return CMD_WARNING_CONFIG_FAILED
;
5000 DEFUN (neighbor_local_as
,
5001 neighbor_local_as_cmd
,
5002 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
5005 "Specify a local-as number\n"
5006 "AS number used as local AS\n")
5014 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5016 return CMD_WARNING_CONFIG_FAILED
;
5018 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5019 ret
= peer_local_as_set(peer
, as
, 0, 0);
5020 return bgp_vty_return(vty
, ret
);
5023 DEFUN (neighbor_local_as_no_prepend
,
5024 neighbor_local_as_no_prepend_cmd
,
5025 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
5028 "Specify a local-as number\n"
5029 "AS number used as local AS\n"
5030 "Do not prepend local-as to updates from ebgp peers\n")
5038 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5040 return CMD_WARNING_CONFIG_FAILED
;
5042 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5043 ret
= peer_local_as_set(peer
, as
, 1, 0);
5044 return bgp_vty_return(vty
, ret
);
5047 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5048 neighbor_local_as_no_prepend_replace_as_cmd
,
5049 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
5052 "Specify a local-as number\n"
5053 "AS number used as local AS\n"
5054 "Do not prepend local-as to updates from ebgp peers\n"
5055 "Do not prepend local-as to updates from ibgp peers\n")
5063 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5065 return CMD_WARNING_CONFIG_FAILED
;
5067 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5068 ret
= peer_local_as_set(peer
, as
, 1, 1);
5069 return bgp_vty_return(vty
, ret
);
5072 DEFUN (no_neighbor_local_as
,
5073 no_neighbor_local_as_cmd
,
5074 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
5078 "Specify a local-as number\n"
5079 "AS number used as local AS\n"
5080 "Do not prepend local-as to updates from ebgp peers\n"
5081 "Do not prepend local-as to updates from ibgp peers\n")
5087 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5089 return CMD_WARNING_CONFIG_FAILED
;
5091 ret
= peer_local_as_unset(peer
);
5092 return bgp_vty_return(vty
, ret
);
5096 DEFUN (neighbor_solo
,
5098 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5101 "Solo peer - part of its own update group\n")
5107 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5109 return CMD_WARNING_CONFIG_FAILED
;
5111 ret
= update_group_adjust_soloness(peer
, 1);
5112 return bgp_vty_return(vty
, ret
);
5115 DEFUN (no_neighbor_solo
,
5116 no_neighbor_solo_cmd
,
5117 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5121 "Solo peer - part of its own update group\n")
5127 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5129 return CMD_WARNING_CONFIG_FAILED
;
5131 ret
= update_group_adjust_soloness(peer
, 0);
5132 return bgp_vty_return(vty
, ret
);
5135 DEFUN (neighbor_password
,
5136 neighbor_password_cmd
,
5137 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5148 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5150 return CMD_WARNING_CONFIG_FAILED
;
5152 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5153 return bgp_vty_return(vty
, ret
);
5156 DEFUN (no_neighbor_password
,
5157 no_neighbor_password_cmd
,
5158 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5169 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5171 return CMD_WARNING_CONFIG_FAILED
;
5173 ret
= peer_password_unset(peer
);
5174 return bgp_vty_return(vty
, ret
);
5177 DEFUN (neighbor_activate
,
5178 neighbor_activate_cmd
,
5179 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5182 "Enable the Address Family for this Neighbor\n")
5188 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5190 return CMD_WARNING_CONFIG_FAILED
;
5192 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5193 return bgp_vty_return(vty
, ret
);
5196 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5197 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5198 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5199 "Enable the Address Family for this Neighbor\n")
5201 DEFUN (no_neighbor_activate
,
5202 no_neighbor_activate_cmd
,
5203 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5207 "Enable the Address Family for this Neighbor\n")
5214 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5216 return CMD_WARNING_CONFIG_FAILED
;
5218 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5219 return bgp_vty_return(vty
, ret
);
5222 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5223 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5224 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5225 "Enable the Address Family for this Neighbor\n")
5227 DEFUN (neighbor_set_peer_group
,
5228 neighbor_set_peer_group_cmd
,
5229 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5232 "Member of the peer-group\n"
5233 "Peer-group name\n")
5235 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5242 struct peer_group
*group
;
5244 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5246 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5248 vty_out(vty
, "%% Malformed address or name: %s\n",
5249 argv
[idx_peer
]->arg
);
5250 return CMD_WARNING_CONFIG_FAILED
;
5253 if (peer_address_self_check(bgp
, &su
)) {
5255 "%% Can not configure the local system as neighbor\n");
5256 return CMD_WARNING_CONFIG_FAILED
;
5259 /* Disallow for dynamic neighbor. */
5260 peer
= peer_lookup(bgp
, &su
);
5261 if (peer
&& peer_dynamic_neighbor(peer
)) {
5263 "%% Operation not allowed on a dynamic neighbor\n");
5264 return CMD_WARNING_CONFIG_FAILED
;
5268 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5270 vty_out(vty
, "%% Configure the peer-group first\n");
5271 return CMD_WARNING_CONFIG_FAILED
;
5274 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5276 return bgp_vty_return(vty
, ret
);
5279 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5280 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5281 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5282 "Member of the peer-group\n"
5283 "Peer-group name\n")
5285 DEFUN (no_neighbor_set_peer_group
,
5286 no_neighbor_set_peer_group_cmd
,
5287 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5291 "Member of the peer-group\n"
5292 "Peer-group name\n")
5294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5299 struct peer_group
*group
;
5301 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5303 return CMD_WARNING_CONFIG_FAILED
;
5305 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5307 vty_out(vty
, "%% Configure the peer-group first\n");
5308 return CMD_WARNING_CONFIG_FAILED
;
5311 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5312 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5314 peer_notify_unconfig(peer
);
5315 ret
= peer_delete(peer
);
5317 return bgp_vty_return(vty
, ret
);
5320 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5321 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5322 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5323 "Member of the peer-group\n"
5324 "Peer-group name\n")
5326 /* neighbor passive. */
5327 DEFUN (neighbor_passive
,
5328 neighbor_passive_cmd
,
5329 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5332 "Don't send open messages to this neighbor\n")
5335 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5338 DEFUN (no_neighbor_passive
,
5339 no_neighbor_passive_cmd
,
5340 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5344 "Don't send open messages to this neighbor\n")
5347 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5350 /* neighbor shutdown. */
5351 DEFUN (neighbor_shutdown_msg
,
5352 neighbor_shutdown_msg_cmd
,
5353 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5356 "Administratively shut down this neighbor\n"
5357 "Add a shutdown message (RFC 8203)\n"
5358 "Shutdown message\n")
5364 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5368 return CMD_WARNING_CONFIG_FAILED
;
5369 message
= argv_concat(argv
, argc
, 4);
5370 peer_tx_shutdown_message_set(peer
, message
);
5371 XFREE(MTYPE_TMP
, message
);
5374 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5377 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5378 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5379 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5380 "Administratively shut down this neighbor\n")
5382 DEFUN (no_neighbor_shutdown_msg
,
5383 no_neighbor_shutdown_msg_cmd
,
5384 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5388 "Administratively shut down this neighbor\n"
5389 "Remove a shutdown message (RFC 8203)\n"
5390 "Shutdown message\n")
5394 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5395 PEER_FLAG_SHUTDOWN
);
5398 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5399 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5400 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5401 "Administratively shut down this neighbor\n")
5403 DEFUN(neighbor_shutdown_rtt
,
5404 neighbor_shutdown_rtt_cmd
,
5405 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5408 "Administratively shut down this neighbor\n"
5409 "Shutdown if round-trip-time is higher than expected\n"
5410 "Round-trip-time in milliseconds\n"
5411 "Specify the number of keepalives before shutdown\n"
5412 "The number of keepalives with higher RTT to shutdown\n")
5419 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5422 return CMD_WARNING_CONFIG_FAILED
;
5424 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5426 if (argv_find(argv
, argc
, "count", &idx_count
))
5427 peer
->rtt_keepalive_conf
=
5428 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5430 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5431 PEER_FLAG_RTT_SHUTDOWN
);
5434 DEFUN(no_neighbor_shutdown_rtt
,
5435 no_neighbor_shutdown_rtt_cmd
,
5436 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5440 "Administratively shut down this neighbor\n"
5441 "Shutdown if round-trip-time is higher than expected\n"
5442 "Round-trip-time in milliseconds\n"
5443 "Specify the number of keepalives before shutdown\n"
5444 "The number of keepalives with higher RTT to shutdown\n")
5449 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5452 return CMD_WARNING_CONFIG_FAILED
;
5454 peer
->rtt_expected
= 0;
5455 peer
->rtt_keepalive_conf
= 1;
5457 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5458 PEER_FLAG_RTT_SHUTDOWN
);
5461 /* neighbor capability dynamic. */
5462 DEFUN (neighbor_capability_dynamic
,
5463 neighbor_capability_dynamic_cmd
,
5464 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5467 "Advertise capability to the peer\n"
5468 "Advertise dynamic capability to this neighbor\n")
5471 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5472 PEER_FLAG_DYNAMIC_CAPABILITY
);
5475 DEFUN (no_neighbor_capability_dynamic
,
5476 no_neighbor_capability_dynamic_cmd
,
5477 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5481 "Advertise capability to the peer\n"
5482 "Advertise dynamic capability to this neighbor\n")
5485 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5486 PEER_FLAG_DYNAMIC_CAPABILITY
);
5489 /* neighbor dont-capability-negotiate */
5490 DEFUN (neighbor_dont_capability_negotiate
,
5491 neighbor_dont_capability_negotiate_cmd
,
5492 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5495 "Do not perform capability negotiation\n")
5498 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5499 PEER_FLAG_DONT_CAPABILITY
);
5502 DEFUN (no_neighbor_dont_capability_negotiate
,
5503 no_neighbor_dont_capability_negotiate_cmd
,
5504 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5508 "Do not perform capability negotiation\n")
5511 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5512 PEER_FLAG_DONT_CAPABILITY
);
5515 /* neighbor capability extended next hop encoding */
5516 DEFUN (neighbor_capability_enhe
,
5517 neighbor_capability_enhe_cmd
,
5518 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5521 "Advertise capability to the peer\n"
5522 "Advertise extended next-hop capability to the peer\n")
5527 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5528 if (peer
&& peer
->conf_if
)
5531 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5532 PEER_FLAG_CAPABILITY_ENHE
);
5535 DEFUN (no_neighbor_capability_enhe
,
5536 no_neighbor_capability_enhe_cmd
,
5537 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5541 "Advertise capability to the peer\n"
5542 "Advertise extended next-hop capability to the peer\n")
5547 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5548 if (peer
&& peer
->conf_if
) {
5550 "Peer %s cannot have capability extended-nexthop turned off\n",
5551 argv
[idx_peer
]->arg
);
5552 return CMD_WARNING_CONFIG_FAILED
;
5555 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5556 PEER_FLAG_CAPABILITY_ENHE
);
5559 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5560 afi_t afi
, safi_t safi
, uint32_t flag
,
5566 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5568 return CMD_WARNING_CONFIG_FAILED
;
5571 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5573 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5575 return bgp_vty_return(vty
, ret
);
5578 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5579 afi_t afi
, safi_t safi
, uint32_t flag
)
5581 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5584 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5585 afi_t afi
, safi_t safi
, uint32_t flag
)
5587 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5590 /* neighbor capability orf prefix-list. */
5591 DEFUN (neighbor_capability_orf_prefix
,
5592 neighbor_capability_orf_prefix_cmd
,
5593 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5596 "Advertise capability to the peer\n"
5597 "Advertise ORF capability to the peer\n"
5598 "Advertise prefixlist ORF capability to this neighbor\n"
5599 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5600 "Capability to RECEIVE the ORF from this neighbor\n"
5601 "Capability to SEND the ORF to this neighbor\n")
5603 int idx_send_recv
= 5;
5604 char *peer_str
= argv
[1]->arg
;
5606 afi_t afi
= bgp_node_afi(vty
);
5607 safi_t safi
= bgp_node_safi(vty
);
5609 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5611 return CMD_WARNING_CONFIG_FAILED
;
5613 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5614 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5615 PEER_FLAG_ORF_PREFIX_SM
);
5617 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5618 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5619 PEER_FLAG_ORF_PREFIX_RM
);
5621 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5622 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5623 PEER_FLAG_ORF_PREFIX_SM
)
5624 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5625 PEER_FLAG_ORF_PREFIX_RM
);
5627 return CMD_WARNING_CONFIG_FAILED
;
5631 neighbor_capability_orf_prefix
,
5632 neighbor_capability_orf_prefix_hidden_cmd
,
5633 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5634 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5635 "Advertise capability to the peer\n"
5636 "Advertise ORF capability to the peer\n"
5637 "Advertise prefixlist ORF capability to this neighbor\n"
5638 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5639 "Capability to RECEIVE the ORF from this neighbor\n"
5640 "Capability to SEND the ORF to this neighbor\n")
5642 DEFUN (no_neighbor_capability_orf_prefix
,
5643 no_neighbor_capability_orf_prefix_cmd
,
5644 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5648 "Advertise capability to the peer\n"
5649 "Advertise ORF capability to the peer\n"
5650 "Advertise prefixlist ORF capability to this neighbor\n"
5651 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5652 "Capability to RECEIVE the ORF from this neighbor\n"
5653 "Capability to SEND the ORF to this neighbor\n")
5655 int idx_send_recv
= 6;
5656 char *peer_str
= argv
[2]->arg
;
5658 afi_t afi
= bgp_node_afi(vty
);
5659 safi_t safi
= bgp_node_safi(vty
);
5661 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5663 return CMD_WARNING_CONFIG_FAILED
;
5665 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5666 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5667 PEER_FLAG_ORF_PREFIX_SM
);
5669 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5670 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5671 PEER_FLAG_ORF_PREFIX_RM
);
5673 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5674 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5675 PEER_FLAG_ORF_PREFIX_SM
)
5676 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5677 PEER_FLAG_ORF_PREFIX_RM
);
5679 return CMD_WARNING_CONFIG_FAILED
;
5683 no_neighbor_capability_orf_prefix
,
5684 no_neighbor_capability_orf_prefix_hidden_cmd
,
5685 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5686 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5687 "Advertise capability to the peer\n"
5688 "Advertise ORF capability to the peer\n"
5689 "Advertise prefixlist ORF capability to this neighbor\n"
5690 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5691 "Capability to RECEIVE the ORF from this neighbor\n"
5692 "Capability to SEND the ORF to this neighbor\n")
5694 /* neighbor next-hop-self. */
5695 DEFUN (neighbor_nexthop_self
,
5696 neighbor_nexthop_self_cmd
,
5697 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5700 "Disable the next hop calculation for this neighbor\n")
5703 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5704 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5707 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5708 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5709 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5710 "Disable the next hop calculation for this neighbor\n")
5712 /* neighbor next-hop-self. */
5713 DEFUN (neighbor_nexthop_self_force
,
5714 neighbor_nexthop_self_force_cmd
,
5715 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5718 "Disable the next hop calculation for this neighbor\n"
5719 "Set the next hop to self for reflected routes\n")
5722 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5724 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5727 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5728 neighbor_nexthop_self_force_hidden_cmd
,
5729 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5730 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5731 "Disable the next hop calculation for this neighbor\n"
5732 "Set the next hop to self for reflected routes\n")
5734 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5735 neighbor_nexthop_self_all_hidden_cmd
,
5736 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5737 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5738 "Disable the next hop calculation for this neighbor\n"
5739 "Set the next hop to self for reflected routes\n")
5741 DEFUN (no_neighbor_nexthop_self
,
5742 no_neighbor_nexthop_self_cmd
,
5743 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5747 "Disable the next hop calculation for this neighbor\n")
5750 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5751 bgp_node_afi(vty
), bgp_node_safi(vty
),
5752 PEER_FLAG_NEXTHOP_SELF
);
5755 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5756 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5757 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5758 "Disable the next hop calculation for this neighbor\n")
5760 DEFUN (no_neighbor_nexthop_self_force
,
5761 no_neighbor_nexthop_self_force_cmd
,
5762 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5766 "Disable the next hop calculation for this neighbor\n"
5767 "Set the next hop to self for reflected routes\n")
5770 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5771 bgp_node_afi(vty
), bgp_node_safi(vty
),
5772 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5775 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5776 no_neighbor_nexthop_self_force_hidden_cmd
,
5777 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5778 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5779 "Disable the next hop calculation for this neighbor\n"
5780 "Set the next hop to self for reflected routes\n")
5782 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5783 no_neighbor_nexthop_self_all_hidden_cmd
,
5784 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5785 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5786 "Disable the next hop calculation for this neighbor\n"
5787 "Set the next hop to self for reflected routes\n")
5789 /* neighbor as-override */
5790 DEFUN (neighbor_as_override
,
5791 neighbor_as_override_cmd
,
5792 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5795 "Override ASNs in outbound updates if aspath equals remote-as\n")
5798 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5799 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5802 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5803 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5804 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5805 "Override ASNs in outbound updates if aspath equals remote-as\n")
5807 DEFUN (no_neighbor_as_override
,
5808 no_neighbor_as_override_cmd
,
5809 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5813 "Override ASNs in outbound updates if aspath equals remote-as\n")
5816 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5817 bgp_node_afi(vty
), bgp_node_safi(vty
),
5818 PEER_FLAG_AS_OVERRIDE
);
5821 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5822 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5823 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5824 "Override ASNs in outbound updates if aspath equals remote-as\n")
5826 /* neighbor remove-private-AS. */
5827 DEFUN (neighbor_remove_private_as
,
5828 neighbor_remove_private_as_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5832 "Remove private ASNs in outbound updates\n")
5835 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5837 PEER_FLAG_REMOVE_PRIVATE_AS
);
5840 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5841 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5842 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5843 "Remove private ASNs in outbound updates\n")
5845 DEFUN (neighbor_remove_private_as_all
,
5846 neighbor_remove_private_as_all_cmd
,
5847 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5850 "Remove private ASNs in outbound updates\n"
5851 "Apply to all AS numbers\n")
5854 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5856 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5859 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5860 neighbor_remove_private_as_all_hidden_cmd
,
5861 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5862 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5863 "Remove private ASNs in outbound updates\n"
5864 "Apply to all AS numbers\n")
5866 DEFUN (neighbor_remove_private_as_replace_as
,
5867 neighbor_remove_private_as_replace_as_cmd
,
5868 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5871 "Remove private ASNs in outbound updates\n"
5872 "Replace private ASNs with our ASN in outbound updates\n")
5875 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5877 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5880 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5881 neighbor_remove_private_as_replace_as_hidden_cmd
,
5882 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5883 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5884 "Remove private ASNs in outbound updates\n"
5885 "Replace private ASNs with our ASN in outbound updates\n")
5887 DEFUN (neighbor_remove_private_as_all_replace_as
,
5888 neighbor_remove_private_as_all_replace_as_cmd
,
5889 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5892 "Remove private ASNs in outbound updates\n"
5893 "Apply to all AS numbers\n"
5894 "Replace private ASNs with our ASN in outbound updates\n")
5897 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5899 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5903 neighbor_remove_private_as_all_replace_as
,
5904 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5905 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5906 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5907 "Remove private ASNs in outbound updates\n"
5908 "Apply to all AS numbers\n"
5909 "Replace private ASNs with our ASN in outbound updates\n")
5911 DEFUN (no_neighbor_remove_private_as
,
5912 no_neighbor_remove_private_as_cmd
,
5913 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5917 "Remove private ASNs in outbound updates\n")
5920 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5921 bgp_node_afi(vty
), bgp_node_safi(vty
),
5922 PEER_FLAG_REMOVE_PRIVATE_AS
);
5925 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5926 no_neighbor_remove_private_as_hidden_cmd
,
5927 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5928 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5929 "Remove private ASNs in outbound updates\n")
5931 DEFUN (no_neighbor_remove_private_as_all
,
5932 no_neighbor_remove_private_as_all_cmd
,
5933 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5937 "Remove private ASNs in outbound updates\n"
5938 "Apply to all AS numbers\n")
5941 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5942 bgp_node_afi(vty
), bgp_node_safi(vty
),
5943 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5946 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5947 no_neighbor_remove_private_as_all_hidden_cmd
,
5948 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5949 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5950 "Remove private ASNs in outbound updates\n"
5951 "Apply to all AS numbers\n")
5953 DEFUN (no_neighbor_remove_private_as_replace_as
,
5954 no_neighbor_remove_private_as_replace_as_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5959 "Remove private ASNs in outbound updates\n"
5960 "Replace private ASNs with our ASN in outbound updates\n")
5963 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5964 bgp_node_afi(vty
), bgp_node_safi(vty
),
5965 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5968 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5969 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5970 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5971 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5972 "Remove private ASNs in outbound updates\n"
5973 "Replace private ASNs with our ASN in outbound updates\n")
5975 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5976 no_neighbor_remove_private_as_all_replace_as_cmd
,
5977 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5981 "Remove private ASNs in outbound updates\n"
5982 "Apply to all AS numbers\n"
5983 "Replace private ASNs with our ASN in outbound updates\n")
5986 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5987 bgp_node_afi(vty
), bgp_node_safi(vty
),
5988 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5992 no_neighbor_remove_private_as_all_replace_as
,
5993 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5994 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5995 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5996 "Remove private ASNs in outbound updates\n"
5997 "Apply to all AS numbers\n"
5998 "Replace private ASNs with our ASN in outbound updates\n")
6001 /* neighbor send-community. */
6002 DEFUN (neighbor_send_community
,
6003 neighbor_send_community_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6007 "Send Community attribute to this neighbor\n")
6011 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6013 PEER_FLAG_SEND_COMMUNITY
);
6016 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6017 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6018 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6019 "Send Community attribute to this neighbor\n")
6021 DEFUN (no_neighbor_send_community
,
6022 no_neighbor_send_community_cmd
,
6023 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6027 "Send Community attribute to this neighbor\n")
6031 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6032 bgp_node_afi(vty
), bgp_node_safi(vty
),
6033 PEER_FLAG_SEND_COMMUNITY
);
6036 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6037 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6038 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6039 "Send Community attribute to this neighbor\n")
6041 /* neighbor send-community extended. */
6042 DEFUN (neighbor_send_community_type
,
6043 neighbor_send_community_type_cmd
,
6044 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6047 "Send Community attribute to this neighbor\n"
6048 "Send Standard and Extended Community attributes\n"
6049 "Send Standard, Large and Extended Community attributes\n"
6050 "Send Extended Community attributes\n"
6051 "Send Standard Community attributes\n"
6052 "Send Large Community attributes\n")
6054 const char *type
= argv
[argc
- 1]->text
;
6055 char *peer_str
= argv
[1]->arg
;
6057 afi_t afi
= bgp_node_afi(vty
);
6058 safi_t safi
= bgp_node_safi(vty
);
6060 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6062 return CMD_WARNING_CONFIG_FAILED
;
6064 if (strmatch(type
, "standard"))
6065 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6066 PEER_FLAG_SEND_COMMUNITY
);
6068 if (strmatch(type
, "extended"))
6069 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6070 PEER_FLAG_SEND_EXT_COMMUNITY
);
6072 if (strmatch(type
, "large"))
6073 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6074 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6076 if (strmatch(type
, "both")) {
6077 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6078 PEER_FLAG_SEND_COMMUNITY
)
6079 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6080 PEER_FLAG_SEND_EXT_COMMUNITY
);
6082 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6083 PEER_FLAG_SEND_COMMUNITY
)
6084 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6085 PEER_FLAG_SEND_EXT_COMMUNITY
)
6086 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6087 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6091 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6092 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6094 "Send Community attribute to this neighbor\n"
6095 "Send Standard and Extended Community attributes\n"
6096 "Send Standard, Large and Extended Community attributes\n"
6097 "Send Extended Community attributes\n"
6098 "Send Standard Community attributes\n"
6099 "Send Large Community attributes\n")
6101 DEFUN (no_neighbor_send_community_type
,
6102 no_neighbor_send_community_type_cmd
,
6103 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6107 "Send Community attribute to this neighbor\n"
6108 "Send Standard and Extended Community attributes\n"
6109 "Send Standard, Large and Extended Community attributes\n"
6110 "Send Extended Community attributes\n"
6111 "Send Standard Community attributes\n"
6112 "Send Large Community attributes\n")
6114 const char *type
= argv
[argc
- 1]->text
;
6115 char *peer_str
= argv
[2]->arg
;
6117 afi_t afi
= bgp_node_afi(vty
);
6118 safi_t safi
= bgp_node_safi(vty
);
6120 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6122 return CMD_WARNING_CONFIG_FAILED
;
6124 if (strmatch(type
, "standard"))
6125 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6126 PEER_FLAG_SEND_COMMUNITY
);
6128 if (strmatch(type
, "extended"))
6129 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6130 PEER_FLAG_SEND_EXT_COMMUNITY
);
6132 if (strmatch(type
, "large"))
6133 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6134 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6136 if (strmatch(type
, "both")) {
6138 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6139 PEER_FLAG_SEND_COMMUNITY
)
6140 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6141 PEER_FLAG_SEND_EXT_COMMUNITY
);
6144 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6145 PEER_FLAG_SEND_COMMUNITY
)
6146 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6147 PEER_FLAG_SEND_EXT_COMMUNITY
)
6148 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6149 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6153 no_neighbor_send_community_type
,
6154 no_neighbor_send_community_type_hidden_cmd
,
6155 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6156 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6157 "Send Community attribute to this neighbor\n"
6158 "Send Standard and Extended Community attributes\n"
6159 "Send Standard, Large and Extended Community attributes\n"
6160 "Send Extended Community attributes\n"
6161 "Send Standard Community attributes\n"
6162 "Send Large Community attributes\n")
6164 /* neighbor soft-reconfig. */
6165 DEFUN (neighbor_soft_reconfiguration
,
6166 neighbor_soft_reconfiguration_cmd
,
6167 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6170 "Per neighbor soft reconfiguration\n"
6171 "Allow inbound soft reconfiguration for this neighbor\n")
6174 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6176 PEER_FLAG_SOFT_RECONFIG
);
6179 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6180 neighbor_soft_reconfiguration_hidden_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6183 "Per neighbor soft reconfiguration\n"
6184 "Allow inbound soft reconfiguration for this neighbor\n")
6186 DEFUN (no_neighbor_soft_reconfiguration
,
6187 no_neighbor_soft_reconfiguration_cmd
,
6188 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6192 "Per neighbor soft reconfiguration\n"
6193 "Allow inbound soft reconfiguration for this neighbor\n")
6196 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6197 bgp_node_afi(vty
), bgp_node_safi(vty
),
6198 PEER_FLAG_SOFT_RECONFIG
);
6201 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6202 no_neighbor_soft_reconfiguration_hidden_cmd
,
6203 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6204 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6205 "Per neighbor soft reconfiguration\n"
6206 "Allow inbound soft reconfiguration for this neighbor\n")
6208 DEFUN (neighbor_route_reflector_client
,
6209 neighbor_route_reflector_client_cmd
,
6210 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6213 "Configure a neighbor as Route Reflector client\n")
6219 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6221 return CMD_WARNING_CONFIG_FAILED
;
6223 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6225 PEER_FLAG_REFLECTOR_CLIENT
);
6228 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6229 neighbor_route_reflector_client_hidden_cmd
,
6230 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6231 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6232 "Configure a neighbor as Route Reflector client\n")
6234 DEFUN (no_neighbor_route_reflector_client
,
6235 no_neighbor_route_reflector_client_cmd
,
6236 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6240 "Configure a neighbor as Route Reflector client\n")
6243 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6244 bgp_node_afi(vty
), bgp_node_safi(vty
),
6245 PEER_FLAG_REFLECTOR_CLIENT
);
6248 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6249 no_neighbor_route_reflector_client_hidden_cmd
,
6250 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6252 "Configure a neighbor as Route Reflector client\n")
6254 /* optimal-route-reflection Root Routers configuration */
6255 DEFPY (optimal_route_reflection
,
6256 optimal_route_reflection_cmd
,
6257 "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]",
6259 "Create ORR group and assign root router(s)\n"
6261 "Primary Root address\n"
6262 "Primary Root IPv6 address\n"
6263 "Secondary Root address\n"
6264 "Secondary Root IPv6 address\n"
6265 "Tertiary Root address\n"
6266 "Tertiary Root IPv6 address\n")
6268 if (!no
&& !primary
) {
6269 vty_out(vty
, "%% Specify Primary Root address\n");
6270 return CMD_WARNING_CONFIG_FAILED
;
6272 return bgp_afi_safi_orr_group_set_vty(
6273 vty
, bgp_node_afi(vty
), bgp_node_safi(vty
), orr_group
,
6274 primary_str
, secondary_str
, tertiary_str
, !!no
);
6277 /* neighbor optimal-route-reflection group*/
6278 DEFPY (neighbor_optimal_route_reflection
,
6279 neighbor_optimal_route_reflection_cmd
,
6280 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group",
6284 "Apply ORR group configuration to the neighbor\n"
6287 return peer_orr_group_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
6288 bgp_node_safi(vty
), orr_group
, !!no
);
6291 /* neighbor route-server-client. */
6292 DEFUN (neighbor_route_server_client
,
6293 neighbor_route_server_client_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6297 "Configure a neighbor as Route Server client\n")
6302 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6304 return CMD_WARNING_CONFIG_FAILED
;
6305 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6307 PEER_FLAG_RSERVER_CLIENT
);
6310 ALIAS_HIDDEN(neighbor_route_server_client
,
6311 neighbor_route_server_client_hidden_cmd
,
6312 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6313 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6314 "Configure a neighbor as Route Server client\n")
6316 DEFUN (no_neighbor_route_server_client
,
6317 no_neighbor_route_server_client_cmd
,
6318 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6322 "Configure a neighbor as Route Server client\n")
6325 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6326 bgp_node_afi(vty
), bgp_node_safi(vty
),
6327 PEER_FLAG_RSERVER_CLIENT
);
6330 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6331 no_neighbor_route_server_client_hidden_cmd
,
6332 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6333 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6334 "Configure a neighbor as Route Server client\n")
6336 DEFUN (neighbor_nexthop_local_unchanged
,
6337 neighbor_nexthop_local_unchanged_cmd
,
6338 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6341 "Configure treatment of outgoing link-local nexthop attribute\n"
6342 "Leave link-local nexthop unchanged for this peer\n")
6345 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6347 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6350 DEFUN (no_neighbor_nexthop_local_unchanged
,
6351 no_neighbor_nexthop_local_unchanged_cmd
,
6352 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6356 "Configure treatment of outgoing link-local-nexthop attribute\n"
6357 "Leave link-local nexthop unchanged for this peer\n")
6360 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6361 bgp_node_afi(vty
), bgp_node_safi(vty
),
6362 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6365 DEFUN (neighbor_attr_unchanged
,
6366 neighbor_attr_unchanged_cmd
,
6367 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6370 "BGP attribute is propagated unchanged to this neighbor\n"
6371 "As-path attribute\n"
6372 "Nexthop attribute\n"
6376 char *peer_str
= argv
[1]->arg
;
6378 bool aspath
= false;
6379 bool nexthop
= false;
6381 afi_t afi
= bgp_node_afi(vty
);
6382 safi_t safi
= bgp_node_safi(vty
);
6385 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6387 return CMD_WARNING_CONFIG_FAILED
;
6389 if (argv_find(argv
, argc
, "as-path", &idx
))
6393 if (argv_find(argv
, argc
, "next-hop", &idx
))
6397 if (argv_find(argv
, argc
, "med", &idx
))
6400 /* no flags means all of them! */
6401 if (!aspath
&& !nexthop
&& !med
) {
6402 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6403 PEER_FLAG_AS_PATH_UNCHANGED
);
6404 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6405 PEER_FLAG_NEXTHOP_UNCHANGED
);
6406 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6407 PEER_FLAG_MED_UNCHANGED
);
6410 if (peer_af_flag_check(peer
, afi
, safi
,
6411 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6412 ret
|= peer_af_flag_unset_vty(
6413 vty
, peer_str
, afi
, safi
,
6414 PEER_FLAG_AS_PATH_UNCHANGED
);
6417 ret
|= peer_af_flag_set_vty(
6418 vty
, peer_str
, afi
, safi
,
6419 PEER_FLAG_AS_PATH_UNCHANGED
);
6422 if (peer_af_flag_check(peer
, afi
, safi
,
6423 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6424 ret
|= peer_af_flag_unset_vty(
6425 vty
, peer_str
, afi
, safi
,
6426 PEER_FLAG_NEXTHOP_UNCHANGED
);
6429 ret
|= peer_af_flag_set_vty(
6430 vty
, peer_str
, afi
, safi
,
6431 PEER_FLAG_NEXTHOP_UNCHANGED
);
6434 if (peer_af_flag_check(peer
, afi
, safi
,
6435 PEER_FLAG_MED_UNCHANGED
)) {
6436 ret
|= peer_af_flag_unset_vty(
6437 vty
, peer_str
, afi
, safi
,
6438 PEER_FLAG_MED_UNCHANGED
);
6441 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6442 PEER_FLAG_MED_UNCHANGED
);
6449 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6450 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6451 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6452 "BGP attribute is propagated unchanged to this neighbor\n"
6453 "As-path attribute\n"
6454 "Nexthop attribute\n"
6457 DEFUN (no_neighbor_attr_unchanged
,
6458 no_neighbor_attr_unchanged_cmd
,
6459 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6463 "BGP attribute is propagated unchanged to this neighbor\n"
6464 "As-path attribute\n"
6465 "Nexthop attribute\n"
6469 char *peer_str
= argv
[2]->arg
;
6471 bool aspath
= false;
6472 bool nexthop
= false;
6474 afi_t afi
= bgp_node_afi(vty
);
6475 safi_t safi
= bgp_node_safi(vty
);
6478 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6480 return CMD_WARNING_CONFIG_FAILED
;
6482 if (argv_find(argv
, argc
, "as-path", &idx
))
6486 if (argv_find(argv
, argc
, "next-hop", &idx
))
6490 if (argv_find(argv
, argc
, "med", &idx
))
6493 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6494 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6495 PEER_FLAG_AS_PATH_UNCHANGED
)
6496 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6497 PEER_FLAG_NEXTHOP_UNCHANGED
)
6498 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6499 PEER_FLAG_MED_UNCHANGED
);
6502 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6503 PEER_FLAG_AS_PATH_UNCHANGED
);
6506 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6507 PEER_FLAG_NEXTHOP_UNCHANGED
);
6510 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6511 PEER_FLAG_MED_UNCHANGED
);
6517 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6518 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6519 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6520 "BGP attribute is propagated unchanged to this neighbor\n"
6521 "As-path attribute\n"
6522 "Nexthop attribute\n"
6525 /* EBGP multihop configuration. */
6526 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6527 const char *ttl_str
)
6532 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6534 return CMD_WARNING_CONFIG_FAILED
;
6537 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6542 ttl
= strtoul(ttl_str
, NULL
, 10);
6544 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6547 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6551 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6553 return CMD_WARNING_CONFIG_FAILED
;
6555 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6558 /* neighbor ebgp-multihop. */
6559 DEFUN (neighbor_ebgp_multihop
,
6560 neighbor_ebgp_multihop_cmd
,
6561 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6564 "Allow EBGP neighbors not on directly connected networks\n")
6567 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6570 DEFUN (neighbor_ebgp_multihop_ttl
,
6571 neighbor_ebgp_multihop_ttl_cmd
,
6572 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6575 "Allow EBGP neighbors not on directly connected networks\n"
6576 "maximum hop count\n")
6580 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6581 argv
[idx_number
]->arg
);
6584 DEFUN (no_neighbor_ebgp_multihop
,
6585 no_neighbor_ebgp_multihop_cmd
,
6586 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6590 "Allow EBGP neighbors not on directly connected networks\n"
6591 "maximum hop count\n")
6594 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6597 DEFPY (neighbor_aigp
,
6599 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6603 "Enable send and receive of the AIGP attribute per neighbor\n")
6607 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6609 return CMD_WARNING_CONFIG_FAILED
;
6612 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6614 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6617 static uint8_t get_role_by_name(const char *role_str
)
6619 if (strncmp(role_str
, "peer", 2) == 0)
6621 if (strncmp(role_str
, "provider", 2) == 0)
6622 return ROLE_PROVIDER
;
6623 if (strncmp(role_str
, "customer", 2) == 0)
6624 return ROLE_CUSTOMER
;
6625 if (strncmp(role_str
, "rs-server", 4) == 0)
6626 return ROLE_RS_SERVER
;
6627 if (strncmp(role_str
, "rs-client", 4) == 0)
6628 return ROLE_RS_CLIENT
;
6629 return ROLE_UNDEFINED
;
6632 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6633 const char *role_str
, bool strict_mode
)
6637 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6639 return CMD_WARNING_CONFIG_FAILED
;
6640 uint8_t role
= get_role_by_name(role_str
);
6642 if (role
== ROLE_UNDEFINED
)
6643 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6644 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6647 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6651 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6653 return CMD_WARNING_CONFIG_FAILED
;
6654 return bgp_vty_return(vty
, peer_role_unset(peer
));
6657 DEFPY(neighbor_role
,
6659 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6662 "Set session role\n"
6668 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6672 DEFPY(neighbor_role_strict
,
6673 neighbor_role_strict_cmd
,
6674 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6677 "Set session role\n"
6679 "Use additional restriction on peer\n")
6684 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6688 DEFPY(no_neighbor_role
,
6689 no_neighbor_role_cmd
,
6690 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6694 "Set session role\n"
6696 "Use additional restriction on peer\n")
6700 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6703 /* disable-connected-check */
6704 DEFUN (neighbor_disable_connected_check
,
6705 neighbor_disable_connected_check_cmd
,
6706 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6709 "one-hop away EBGP peer using loopback address\n"
6710 "Enforce EBGP neighbors perform multihop\n")
6713 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6714 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6717 DEFUN (no_neighbor_disable_connected_check
,
6718 no_neighbor_disable_connected_check_cmd
,
6719 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6723 "one-hop away EBGP peer using loopback address\n"
6724 "Enforce EBGP neighbors perform multihop\n")
6727 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6728 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6731 /* disable-link-bw-encoding-ieee */
6732 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6733 neighbor_disable_link_bw_encoding_ieee_cmd
,
6734 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6735 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6736 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6740 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6741 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6744 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6745 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6746 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6747 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6748 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6752 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6753 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6756 /* extended-optional-parameters */
6757 DEFUN(neighbor_extended_optional_parameters
,
6758 neighbor_extended_optional_parameters_cmd
,
6759 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6760 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6761 "Force the extended optional parameters format for OPEN messages\n")
6765 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6766 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6769 DEFUN(no_neighbor_extended_optional_parameters
,
6770 no_neighbor_extended_optional_parameters_cmd
,
6771 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6772 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6773 "Force the extended optional parameters format for OPEN messages\n")
6777 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6778 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6781 /* enforce-first-as */
6782 DEFUN (neighbor_enforce_first_as
,
6783 neighbor_enforce_first_as_cmd
,
6784 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6787 "Enforce the first AS for EBGP routes\n")
6791 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6792 PEER_FLAG_ENFORCE_FIRST_AS
);
6795 DEFUN (no_neighbor_enforce_first_as
,
6796 no_neighbor_enforce_first_as_cmd
,
6797 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6801 "Enforce the first AS for EBGP routes\n")
6805 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6806 PEER_FLAG_ENFORCE_FIRST_AS
);
6810 DEFUN (neighbor_description
,
6811 neighbor_description_cmd
,
6812 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6815 "Neighbor specific description\n"
6816 "Up to 80 characters describing this neighbor\n")
6823 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6825 return CMD_WARNING_CONFIG_FAILED
;
6827 str
= argv_concat(argv
, argc
, idx_line
);
6829 peer_description_set(peer
, str
);
6831 XFREE(MTYPE_TMP
, str
);
6836 DEFUN (no_neighbor_description
,
6837 no_neighbor_description_cmd
,
6838 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6842 "Neighbor specific description\n")
6847 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6849 return CMD_WARNING_CONFIG_FAILED
;
6851 peer_description_unset(peer
);
6856 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6857 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6858 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6859 "Neighbor specific description\n"
6860 "Up to 80 characters describing this neighbor\n")
6862 /* Neighbor update-source. */
6863 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6864 const char *source_str
)
6870 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6872 return CMD_WARNING_CONFIG_FAILED
;
6878 if (str2sockunion(source_str
, &su
) == 0)
6879 peer_update_source_addr_set(peer
, &su
);
6881 if (str2prefix(source_str
, &p
)) {
6883 "%% Invalid update-source, remove prefix length \n");
6884 return CMD_WARNING_CONFIG_FAILED
;
6886 peer_update_source_if_set(peer
, source_str
);
6889 peer_update_source_unset(peer
);
6894 #define BGP_UPDATE_SOURCE_HELP_STR \
6897 "Interface name (requires zebra to be running)\n"
6899 DEFUN (neighbor_update_source
,
6900 neighbor_update_source_cmd
,
6901 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6904 "Source of routing updates\n"
6905 BGP_UPDATE_SOURCE_HELP_STR
)
6909 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6910 argv
[idx_peer_2
]->arg
);
6913 DEFUN (no_neighbor_update_source
,
6914 no_neighbor_update_source_cmd
,
6915 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6919 "Source of routing updates\n"
6920 BGP_UPDATE_SOURCE_HELP_STR
)
6923 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6926 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6927 afi_t afi
, safi_t safi
,
6928 const char *rmap
, int set
)
6932 struct route_map
*route_map
= NULL
;
6934 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6936 return CMD_WARNING_CONFIG_FAILED
;
6940 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6941 ret
= peer_default_originate_set(peer
, afi
, safi
,
6944 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6946 return bgp_vty_return(vty
, ret
);
6949 /* neighbor default-originate. */
6950 DEFUN (neighbor_default_originate
,
6951 neighbor_default_originate_cmd
,
6952 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6955 "Originate default route to this neighbor\n")
6958 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6960 bgp_node_safi(vty
), NULL
, 1);
6963 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6964 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6966 "Originate default route to this neighbor\n")
6968 DEFUN (neighbor_default_originate_rmap
,
6969 neighbor_default_originate_rmap_cmd
,
6970 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6973 "Originate default route to this neighbor\n"
6974 "Route-map to specify criteria to originate default\n"
6979 return peer_default_originate_set_vty(
6980 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6981 argv
[idx_word
]->arg
, 1);
6985 neighbor_default_originate_rmap
,
6986 neighbor_default_originate_rmap_hidden_cmd
,
6987 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6988 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6989 "Originate default route to this neighbor\n"
6990 "Route-map to specify criteria to originate default\n"
6993 DEFUN (no_neighbor_default_originate
,
6994 no_neighbor_default_originate_cmd
,
6995 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6999 "Originate default route to this neighbor\n"
7000 "Route-map to specify criteria to originate default\n"
7004 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7006 bgp_node_safi(vty
), NULL
, 0);
7010 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7011 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7012 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7013 "Originate default route to this neighbor\n"
7014 "Route-map to specify criteria to originate default\n"
7018 /* Set neighbor's BGP port. */
7019 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
7020 const char *port_str
)
7026 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7028 return CMD_WARNING_CONFIG_FAILED
;
7031 sp
= getservbyname("bgp", "tcp");
7032 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
7034 port
= strtoul(port_str
, NULL
, 10);
7037 peer_port_set(peer
, port
);
7042 /* Set specified peer's BGP port. */
7043 DEFUN (neighbor_port
,
7045 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7048 "Neighbor's BGP port\n"
7049 "TCP port number\n")
7053 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7054 argv
[idx_number
]->arg
);
7057 DEFUN (no_neighbor_port
,
7058 no_neighbor_port_cmd
,
7059 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7063 "Neighbor's BGP port\n"
7064 "TCP port number\n")
7067 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7071 /* neighbor weight. */
7072 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7073 safi_t safi
, const char *weight_str
)
7077 unsigned long weight
;
7079 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7081 return CMD_WARNING_CONFIG_FAILED
;
7083 weight
= strtoul(weight_str
, NULL
, 10);
7085 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7086 return bgp_vty_return(vty
, ret
);
7089 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7095 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7097 return CMD_WARNING_CONFIG_FAILED
;
7099 ret
= peer_weight_unset(peer
, afi
, safi
);
7100 return bgp_vty_return(vty
, ret
);
7103 DEFUN (neighbor_weight
,
7104 neighbor_weight_cmd
,
7105 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7108 "Set default weight for routes from this neighbor\n"
7113 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7114 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7117 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7118 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7119 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7120 "Set default weight for routes from this neighbor\n"
7123 DEFUN (no_neighbor_weight
,
7124 no_neighbor_weight_cmd
,
7125 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7129 "Set default weight for routes from this neighbor\n"
7133 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7134 bgp_node_afi(vty
), bgp_node_safi(vty
));
7137 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7138 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7139 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7140 "Set default weight for routes from this neighbor\n"
7144 /* Override capability negotiation. */
7145 DEFUN (neighbor_override_capability
,
7146 neighbor_override_capability_cmd
,
7147 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7150 "Override capability negotiation result\n")
7153 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7154 PEER_FLAG_OVERRIDE_CAPABILITY
);
7157 DEFUN (no_neighbor_override_capability
,
7158 no_neighbor_override_capability_cmd
,
7159 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7163 "Override capability negotiation result\n")
7166 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7167 PEER_FLAG_OVERRIDE_CAPABILITY
);
7170 DEFUN (neighbor_strict_capability
,
7171 neighbor_strict_capability_cmd
,
7172 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7175 "Strict capability negotiation match\n")
7179 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7180 PEER_FLAG_STRICT_CAP_MATCH
);
7183 DEFUN (no_neighbor_strict_capability
,
7184 no_neighbor_strict_capability_cmd
,
7185 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7189 "Strict capability negotiation match\n")
7193 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7194 PEER_FLAG_STRICT_CAP_MATCH
);
7197 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7198 const char *keep_str
, const char *hold_str
)
7205 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7207 return CMD_WARNING_CONFIG_FAILED
;
7209 keepalive
= strtoul(keep_str
, NULL
, 10);
7210 holdtime
= strtoul(hold_str
, NULL
, 10);
7212 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7214 return bgp_vty_return(vty
, ret
);
7217 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7222 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7224 return CMD_WARNING_CONFIG_FAILED
;
7226 ret
= peer_timers_unset(peer
);
7228 return bgp_vty_return(vty
, ret
);
7231 DEFUN (neighbor_timers
,
7232 neighbor_timers_cmd
,
7233 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7236 "BGP per neighbor timers\n"
7237 "Keepalive interval\n"
7242 int idx_number_2
= 4;
7243 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7244 argv
[idx_number
]->arg
,
7245 argv
[idx_number_2
]->arg
);
7248 DEFUN (no_neighbor_timers
,
7249 no_neighbor_timers_cmd
,
7250 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7254 "BGP per neighbor timers\n"
7255 "Keepalive interval\n"
7259 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7263 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7264 const char *time_str
)
7270 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7272 return CMD_WARNING_CONFIG_FAILED
;
7274 connect
= strtoul(time_str
, NULL
, 10);
7276 ret
= peer_timers_connect_set(peer
, connect
);
7278 return bgp_vty_return(vty
, ret
);
7281 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7286 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7288 return CMD_WARNING_CONFIG_FAILED
;
7290 ret
= peer_timers_connect_unset(peer
);
7292 return bgp_vty_return(vty
, ret
);
7295 DEFUN (neighbor_timers_connect
,
7296 neighbor_timers_connect_cmd
,
7297 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7300 "BGP per neighbor timers\n"
7301 "BGP connect timer\n"
7306 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7307 argv
[idx_number
]->arg
);
7310 DEFUN (no_neighbor_timers_connect
,
7311 no_neighbor_timers_connect_cmd
,
7312 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7316 "BGP per neighbor timers\n"
7317 "BGP connect timer\n"
7321 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7324 DEFPY (neighbor_timers_delayopen
,
7325 neighbor_timers_delayopen_cmd
,
7326 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7329 "BGP per neighbor timers\n"
7330 "RFC 4271 DelayOpenTimer\n"
7331 "DelayOpenTime timer interval\n")
7335 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7337 return CMD_WARNING_CONFIG_FAILED
;
7340 if (peer_timers_delayopen_unset(peer
))
7341 return CMD_WARNING_CONFIG_FAILED
;
7343 if (peer_timers_delayopen_set(peer
, interval
))
7344 return CMD_WARNING_CONFIG_FAILED
;
7350 DEFPY (no_neighbor_timers_delayopen
,
7351 no_neighbor_timers_delayopen_cmd
,
7352 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7356 "BGP per neighbor timers\n"
7357 "RFC 4271 DelayOpenTimer\n"
7358 "DelayOpenTime timer interval\n")
7362 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7364 return CMD_WARNING_CONFIG_FAILED
;
7366 if (peer_timers_delayopen_unset(peer
))
7367 return CMD_WARNING_CONFIG_FAILED
;
7372 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7373 const char *time_str
, int set
)
7377 uint32_t routeadv
= 0;
7379 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7381 return CMD_WARNING_CONFIG_FAILED
;
7384 routeadv
= strtoul(time_str
, NULL
, 10);
7387 ret
= peer_advertise_interval_set(peer
, routeadv
);
7389 ret
= peer_advertise_interval_unset(peer
);
7391 return bgp_vty_return(vty
, ret
);
7394 DEFUN (neighbor_advertise_interval
,
7395 neighbor_advertise_interval_cmd
,
7396 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7399 "Minimum interval between sending BGP routing updates\n"
7400 "time in seconds\n")
7404 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7405 argv
[idx_number
]->arg
, 1);
7408 DEFUN (no_neighbor_advertise_interval
,
7409 no_neighbor_advertise_interval_cmd
,
7410 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7414 "Minimum interval between sending BGP routing updates\n"
7415 "time in seconds\n")
7418 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7422 /* Time to wait before processing route-map updates */
7423 DEFUN (bgp_set_route_map_delay_timer
,
7424 bgp_set_route_map_delay_timer_cmd
,
7425 "bgp route-map delay-timer (0-600)",
7427 "BGP route-map delay timer\n"
7428 "Time in secs to wait before processing route-map changes\n"
7429 "0 disables the timer, no route updates happen when route-maps change\n")
7432 uint32_t rmap_delay_timer
;
7434 if (argv
[idx_number
]->arg
) {
7435 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7436 bm
->rmap_update_timer
= rmap_delay_timer
;
7438 /* if the dynamic update handling is being disabled, and a timer
7440 * running, stop the timer and act as if the timer has already
7443 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7444 THREAD_OFF(bm
->t_rmap_update
);
7445 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7450 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7451 return CMD_WARNING_CONFIG_FAILED
;
7455 DEFUN (no_bgp_set_route_map_delay_timer
,
7456 no_bgp_set_route_map_delay_timer_cmd
,
7457 "no bgp route-map delay-timer [(0-600)]",
7460 "Default BGP route-map delay timer\n"
7461 "Reset to default time to wait for processing route-map changes\n"
7462 "0 disables the timer, no route updates happen when route-maps change\n")
7465 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7470 /* neighbor interface */
7471 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7476 peer
= peer_lookup_vty(vty
, ip_str
);
7477 if (!peer
|| peer
->conf_if
) {
7478 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7479 return CMD_WARNING_CONFIG_FAILED
;
7483 peer_interface_set(peer
, str
);
7485 peer_interface_unset(peer
);
7490 DEFUN (neighbor_interface
,
7491 neighbor_interface_cmd
,
7492 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7501 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7504 DEFUN (no_neighbor_interface
,
7505 no_neighbor_interface_cmd
,
7506 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7515 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7518 DEFUN (neighbor_distribute_list
,
7519 neighbor_distribute_list_cmd
,
7520 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7523 "Filter updates to/from this neighbor\n"
7524 "IP Access-list name\n"
7525 "Filter incoming updates\n"
7526 "Filter outgoing updates\n")
7533 const char *pstr
= argv
[idx_peer
]->arg
;
7534 const char *acl
= argv
[idx_acl
]->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_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7546 return bgp_vty_return(vty
, ret
);
7550 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7551 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7552 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 DEFUN (no_neighbor_distribute_list
,
7559 no_neighbor_distribute_list_cmd
,
7560 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7564 "Filter updates to/from this neighbor\n"
7565 "IP Access-list name\n"
7566 "Filter incoming updates\n"
7567 "Filter outgoing updates\n")
7573 const char *pstr
= argv
[idx_peer
]->arg
;
7574 const char *inout
= argv
[argc
- 1]->text
;
7576 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7578 return CMD_WARNING_CONFIG_FAILED
;
7580 /* Check filter direction. */
7581 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7582 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7585 return bgp_vty_return(vty
, ret
);
7589 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7590 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7591 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7592 "Filter updates to/from this neighbor\n"
7593 "IP Access-list name\n"
7594 "Filter incoming updates\n"
7595 "Filter outgoing updates\n")
7597 /* Set prefix list to the peer. */
7598 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7599 afi_t afi
, safi_t safi
,
7600 const char *name_str
,
7601 const char *direct_str
)
7604 int direct
= FILTER_IN
;
7607 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7609 return CMD_WARNING_CONFIG_FAILED
;
7611 /* Check filter direction. */
7612 if (strncmp(direct_str
, "i", 1) == 0)
7614 else if (strncmp(direct_str
, "o", 1) == 0)
7615 direct
= FILTER_OUT
;
7617 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7619 return bgp_vty_return(vty
, ret
);
7622 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7623 afi_t afi
, safi_t safi
,
7624 const char *direct_str
)
7628 int direct
= FILTER_IN
;
7630 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7632 return CMD_WARNING_CONFIG_FAILED
;
7634 /* Check filter direction. */
7635 if (strncmp(direct_str
, "i", 1) == 0)
7637 else if (strncmp(direct_str
, "o", 1) == 0)
7638 direct
= FILTER_OUT
;
7640 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7642 return bgp_vty_return(vty
, ret
);
7645 DEFUN (neighbor_prefix_list
,
7646 neighbor_prefix_list_cmd
,
7647 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7650 "Filter updates to/from this neighbor\n"
7651 "Name of a prefix list\n"
7652 "Filter incoming updates\n"
7653 "Filter outgoing updates\n")
7658 return peer_prefix_list_set_vty(
7659 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7660 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7663 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7664 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7665 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7666 "Filter updates to/from this neighbor\n"
7667 "Name of a prefix list\n"
7668 "Filter incoming updates\n"
7669 "Filter outgoing updates\n")
7671 DEFUN (no_neighbor_prefix_list
,
7672 no_neighbor_prefix_list_cmd
,
7673 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7677 "Filter updates to/from this neighbor\n"
7678 "Name of a prefix list\n"
7679 "Filter incoming updates\n"
7680 "Filter outgoing updates\n")
7684 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7685 bgp_node_afi(vty
), bgp_node_safi(vty
),
7686 argv
[idx_in_out
]->arg
);
7689 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7690 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7691 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7692 "Filter updates to/from this neighbor\n"
7693 "Name of a prefix list\n"
7694 "Filter incoming updates\n"
7695 "Filter outgoing updates\n")
7697 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7698 safi_t safi
, const char *name_str
,
7699 const char *direct_str
)
7703 int direct
= FILTER_IN
;
7705 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7707 return CMD_WARNING_CONFIG_FAILED
;
7709 /* Check filter direction. */
7710 if (strncmp(direct_str
, "i", 1) == 0)
7712 else if (strncmp(direct_str
, "o", 1) == 0)
7713 direct
= FILTER_OUT
;
7715 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7717 return bgp_vty_return(vty
, ret
);
7720 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7721 safi_t safi
, const char *direct_str
)
7725 int direct
= FILTER_IN
;
7727 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7729 return CMD_WARNING_CONFIG_FAILED
;
7731 /* Check filter direction. */
7732 if (strncmp(direct_str
, "i", 1) == 0)
7734 else if (strncmp(direct_str
, "o", 1) == 0)
7735 direct
= FILTER_OUT
;
7737 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7739 return bgp_vty_return(vty
, ret
);
7742 DEFUN (neighbor_filter_list
,
7743 neighbor_filter_list_cmd
,
7744 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7747 "Establish BGP filters\n"
7748 "AS path access-list name\n"
7749 "Filter incoming routes\n"
7750 "Filter outgoing routes\n")
7755 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7756 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7757 argv
[idx_in_out
]->arg
);
7760 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7761 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7762 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7763 "Establish BGP filters\n"
7764 "AS path access-list name\n"
7765 "Filter incoming routes\n"
7766 "Filter outgoing routes\n")
7768 DEFUN (no_neighbor_filter_list
,
7769 no_neighbor_filter_list_cmd
,
7770 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7774 "Establish BGP filters\n"
7775 "AS path access-list name\n"
7776 "Filter incoming routes\n"
7777 "Filter outgoing routes\n")
7781 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7782 bgp_node_afi(vty
), bgp_node_safi(vty
),
7783 argv
[idx_in_out
]->arg
);
7786 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7787 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7788 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7789 "Establish BGP filters\n"
7790 "AS path access-list name\n"
7791 "Filter incoming routes\n"
7792 "Filter outgoing routes\n")
7794 /* Set advertise-map to the peer. */
7795 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7796 afi_t afi
, safi_t safi
,
7797 const char *advertise_str
,
7798 const char *condition_str
, bool condition
,
7801 int ret
= CMD_WARNING_CONFIG_FAILED
;
7803 struct route_map
*advertise_map
;
7804 struct route_map
*condition_map
;
7806 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7810 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7811 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7814 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7815 advertise_map
, condition_str
,
7816 condition_map
, condition
);
7818 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7819 advertise_map
, condition_str
,
7820 condition_map
, condition
);
7822 return bgp_vty_return(vty
, ret
);
7825 DEFPY (bgp_condadv_period
,
7826 bgp_condadv_period_cmd
,
7827 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7830 "Conditional advertisement settings\n"
7831 "Set period to rescan BGP table to check if condition is met\n"
7832 "Period between BGP table scans, in seconds; default 60\n")
7834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7836 bgp
->condition_check_period
=
7837 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7842 DEFPY (neighbor_advertise_map
,
7843 neighbor_advertise_map_cmd
,
7844 "[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",
7848 "Route-map to conditionally advertise routes\n"
7849 "Name of advertise map\n"
7850 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7851 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7852 "Name of the exist or non exist map\n")
7854 bool condition
= CONDITION_EXIST
;
7856 if (!strcmp(exist
, "non-exist-map"))
7857 condition
= CONDITION_NON_EXIST
;
7859 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7860 bgp_node_safi(vty
), advertise_str
,
7861 condition_str
, condition
, !no
);
7864 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7865 "[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",
7866 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7867 "Route-map to conditionally advertise routes\n"
7868 "Name of advertise map\n"
7869 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7870 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7871 "Name of the exist or non exist map\n")
7873 /* Set route-map to the peer. */
7874 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7875 afi_t afi
, safi_t safi
, const char *name_str
,
7876 const char *direct_str
)
7880 int direct
= RMAP_IN
;
7881 struct route_map
*route_map
;
7883 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7885 return CMD_WARNING_CONFIG_FAILED
;
7887 /* Check filter direction. */
7888 if (strncmp(direct_str
, "in", 2) == 0)
7890 else if (strncmp(direct_str
, "o", 1) == 0)
7893 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7894 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7896 return bgp_vty_return(vty
, ret
);
7899 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7900 afi_t afi
, safi_t safi
,
7901 const char *direct_str
)
7905 int direct
= RMAP_IN
;
7907 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7909 return CMD_WARNING_CONFIG_FAILED
;
7911 /* Check filter direction. */
7912 if (strncmp(direct_str
, "in", 2) == 0)
7914 else if (strncmp(direct_str
, "o", 1) == 0)
7917 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7919 return bgp_vty_return(vty
, ret
);
7922 DEFUN (neighbor_route_map
,
7923 neighbor_route_map_cmd
,
7924 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7927 "Apply route map to neighbor\n"
7928 "Name of route map\n"
7929 "Apply map to incoming routes\n"
7930 "Apply map to outbound routes\n")
7935 return peer_route_map_set_vty(
7936 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7937 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7940 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7941 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7942 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7943 "Apply route map to neighbor\n"
7944 "Name of route map\n"
7945 "Apply map to incoming routes\n"
7946 "Apply map to outbound routes\n")
7948 DEFUN (no_neighbor_route_map
,
7949 no_neighbor_route_map_cmd
,
7950 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7954 "Apply route map to neighbor\n"
7955 "Name of route map\n"
7956 "Apply map to incoming routes\n"
7957 "Apply map to outbound routes\n")
7961 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7962 bgp_node_afi(vty
), bgp_node_safi(vty
),
7963 argv
[idx_in_out
]->arg
);
7966 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7967 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7968 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7969 "Apply route map to neighbor\n"
7970 "Name of route map\n"
7971 "Apply map to incoming routes\n"
7972 "Apply map to outbound routes\n")
7974 /* Set unsuppress-map to the peer. */
7975 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7976 afi_t afi
, safi_t safi
,
7977 const char *name_str
)
7981 struct route_map
*route_map
;
7983 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7985 return CMD_WARNING_CONFIG_FAILED
;
7987 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7988 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7990 return bgp_vty_return(vty
, ret
);
7993 /* Unset route-map from the peer. */
7994 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7995 afi_t afi
, safi_t safi
)
8000 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8002 return CMD_WARNING_CONFIG_FAILED
;
8004 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8006 return bgp_vty_return(vty
, ret
);
8009 DEFUN (neighbor_unsuppress_map
,
8010 neighbor_unsuppress_map_cmd
,
8011 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8014 "Route-map to selectively unsuppress suppressed routes\n"
8015 "Name of route map\n")
8019 return peer_unsuppress_map_set_vty(
8020 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8021 argv
[idx_word
]->arg
);
8024 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8025 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8026 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8027 "Route-map to selectively unsuppress suppressed routes\n"
8028 "Name of route map\n")
8030 DEFUN (no_neighbor_unsuppress_map
,
8031 no_neighbor_unsuppress_map_cmd
,
8032 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8036 "Route-map to selectively unsuppress suppressed routes\n"
8037 "Name of route map\n")
8040 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8042 bgp_node_safi(vty
));
8045 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8046 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8047 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8048 "Route-map to selectively unsuppress suppressed routes\n"
8049 "Name of route map\n")
8051 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8052 afi_t afi
, safi_t safi
,
8053 const char *num_str
,
8054 const char *threshold_str
, int warning
,
8055 const char *restart_str
,
8056 const char *force_str
)
8064 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8066 return CMD_WARNING_CONFIG_FAILED
;
8068 max
= strtoul(num_str
, NULL
, 10);
8070 threshold
= atoi(threshold_str
);
8072 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8075 restart
= atoi(restart_str
);
8079 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8080 restart
, force_str
? true : false);
8082 return bgp_vty_return(vty
, ret
);
8085 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8086 afi_t afi
, safi_t safi
)
8091 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8093 return CMD_WARNING_CONFIG_FAILED
;
8095 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8097 return bgp_vty_return(vty
, ret
);
8100 /* Maximum number of prefix to be sent to the neighbor. */
8101 DEFUN(neighbor_maximum_prefix_out
,
8102 neighbor_maximum_prefix_out_cmd
,
8103 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8106 "Maximum number of prefixes to be sent to this peer\n"
8107 "Maximum no. of prefix limit\n")
8114 afi_t afi
= bgp_node_afi(vty
);
8115 safi_t safi
= bgp_node_safi(vty
);
8117 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8119 return CMD_WARNING_CONFIG_FAILED
;
8121 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8123 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8125 return bgp_vty_return(vty
, ret
);
8128 DEFUN(no_neighbor_maximum_prefix_out
,
8129 no_neighbor_maximum_prefix_out_cmd
,
8130 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8134 "Maximum number of prefixes to be sent to this peer\n"
8135 "Maximum no. of prefix limit\n")
8140 afi_t afi
= bgp_node_afi(vty
);
8141 safi_t safi
= bgp_node_safi(vty
);
8143 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8145 return CMD_WARNING_CONFIG_FAILED
;
8147 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8149 return bgp_vty_return(vty
, ret
);
8152 /* Maximum number of prefix configuration. Prefix count is different
8153 for each peer configuration. So this configuration can be set for
8154 each peer configuration. */
8155 DEFUN (neighbor_maximum_prefix
,
8156 neighbor_maximum_prefix_cmd
,
8157 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8160 "Maximum number of prefix accept from this peer\n"
8161 "maximum no. of prefix limit\n"
8162 "Force checking all received routes not only accepted\n")
8169 if (argv_find(argv
, argc
, "force", &idx_force
))
8170 force
= argv
[idx_force
]->arg
;
8172 return peer_maximum_prefix_set_vty(
8173 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8174 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8177 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8178 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8179 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8180 "Maximum number of prefix accept from this peer\n"
8181 "maximum no. of prefix limit\n"
8182 "Force checking all received routes not only accepted\n")
8184 DEFUN (neighbor_maximum_prefix_threshold
,
8185 neighbor_maximum_prefix_threshold_cmd
,
8186 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8189 "Maximum number of prefix accept from this peer\n"
8190 "maximum no. of prefix limit\n"
8191 "Threshold value (%) at which to generate a warning msg\n"
8192 "Force checking all received routes not only accepted\n")
8196 int idx_number_2
= 4;
8200 if (argv_find(argv
, argc
, "force", &idx_force
))
8201 force
= argv
[idx_force
]->arg
;
8203 return peer_maximum_prefix_set_vty(
8204 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8205 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8209 neighbor_maximum_prefix_threshold
,
8210 neighbor_maximum_prefix_threshold_hidden_cmd
,
8211 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8212 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8213 "Maximum number of prefix accept from this peer\n"
8214 "maximum no. of prefix limit\n"
8215 "Threshold value (%) at which to generate a warning msg\n"
8216 "Force checking all received routes not only accepted\n")
8218 DEFUN (neighbor_maximum_prefix_warning
,
8219 neighbor_maximum_prefix_warning_cmd
,
8220 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8223 "Maximum number of prefix accept from this peer\n"
8224 "maximum no. of prefix limit\n"
8225 "Only give warning message when limit is exceeded\n"
8226 "Force checking all received routes not only accepted\n")
8233 if (argv_find(argv
, argc
, "force", &idx_force
))
8234 force
= argv
[idx_force
]->arg
;
8236 return peer_maximum_prefix_set_vty(
8237 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8238 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8242 neighbor_maximum_prefix_warning
,
8243 neighbor_maximum_prefix_warning_hidden_cmd
,
8244 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8245 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8246 "Maximum number of prefix accept from this peer\n"
8247 "maximum no. of prefix limit\n"
8248 "Only give warning message when limit is exceeded\n"
8249 "Force checking all received routes not only accepted\n")
8251 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8252 neighbor_maximum_prefix_threshold_warning_cmd
,
8253 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8256 "Maximum number of prefix accept from this peer\n"
8257 "maximum no. of prefix limit\n"
8258 "Threshold value (%) at which to generate a warning msg\n"
8259 "Only give warning message when limit is exceeded\n"
8260 "Force checking all received routes not only accepted\n")
8264 int idx_number_2
= 4;
8268 if (argv_find(argv
, argc
, "force", &idx_force
))
8269 force
= argv
[idx_force
]->arg
;
8271 return peer_maximum_prefix_set_vty(
8272 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8273 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8277 neighbor_maximum_prefix_threshold_warning
,
8278 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8279 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8280 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8281 "Maximum number of prefix accept from this peer\n"
8282 "maximum no. of prefix limit\n"
8283 "Threshold value (%) at which to generate a warning msg\n"
8284 "Only give warning message when limit is exceeded\n"
8285 "Force checking all received routes not only accepted\n")
8287 DEFUN (neighbor_maximum_prefix_restart
,
8288 neighbor_maximum_prefix_restart_cmd
,
8289 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8292 "Maximum number of prefix accept from this peer\n"
8293 "maximum no. of prefix limit\n"
8294 "Restart bgp connection after limit is exceeded\n"
8295 "Restart interval in minutes\n"
8296 "Force checking all received routes not only accepted\n")
8300 int idx_number_2
= 5;
8304 if (argv_find(argv
, argc
, "force", &idx_force
))
8305 force
= argv
[idx_force
]->arg
;
8307 return peer_maximum_prefix_set_vty(
8308 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8309 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8313 neighbor_maximum_prefix_restart
,
8314 neighbor_maximum_prefix_restart_hidden_cmd
,
8315 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8316 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8317 "Maximum number of prefix accept from this peer\n"
8318 "maximum no. of prefix limit\n"
8319 "Restart bgp connection after limit is exceeded\n"
8320 "Restart interval in minutes\n"
8321 "Force checking all received routes not only accepted\n")
8323 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8324 neighbor_maximum_prefix_threshold_restart_cmd
,
8325 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8328 "Maximum number of prefixes to accept from this peer\n"
8329 "maximum no. of prefix limit\n"
8330 "Threshold value (%) at which to generate a warning msg\n"
8331 "Restart bgp connection after limit is exceeded\n"
8332 "Restart interval in minutes\n"
8333 "Force checking all received routes not only accepted\n")
8337 int idx_number_2
= 4;
8338 int idx_number_3
= 6;
8342 if (argv_find(argv
, argc
, "force", &idx_force
))
8343 force
= argv
[idx_force
]->arg
;
8345 return peer_maximum_prefix_set_vty(
8346 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8347 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8348 argv
[idx_number_3
]->arg
, force
);
8352 neighbor_maximum_prefix_threshold_restart
,
8353 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8354 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8355 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8356 "Maximum number of prefixes to accept from this peer\n"
8357 "maximum no. of prefix limit\n"
8358 "Threshold value (%) at which to generate a warning msg\n"
8359 "Restart bgp connection after limit is exceeded\n"
8360 "Restart interval in minutes\n"
8361 "Force checking all received routes not only accepted\n")
8363 DEFUN (no_neighbor_maximum_prefix
,
8364 no_neighbor_maximum_prefix_cmd
,
8365 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8369 "Maximum number of prefixes to accept from this peer\n"
8370 "maximum no. of prefix limit\n"
8371 "Threshold value (%) at which to generate a warning msg\n"
8372 "Restart bgp connection after limit is exceeded\n"
8373 "Restart interval in minutes\n"
8374 "Only give warning message when limit is exceeded\n"
8375 "Force checking all received routes not only accepted\n")
8378 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8380 bgp_node_safi(vty
));
8384 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8385 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8386 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8387 "Maximum number of prefixes to accept from this peer\n"
8388 "maximum no. of prefix limit\n"
8389 "Threshold value (%) at which to generate a warning msg\n"
8390 "Restart bgp connection after limit is exceeded\n"
8391 "Restart interval in minutes\n"
8392 "Only give warning message when limit is exceeded\n"
8393 "Force checking all received routes not only accepted\n")
8395 /* "neighbor accept-own" */
8396 DEFPY (neighbor_accept_own
,
8397 neighbor_accept_own_cmd
,
8398 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8402 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8405 afi_t afi
= bgp_node_afi(vty
);
8406 safi_t safi
= bgp_node_safi(vty
);
8409 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8411 return CMD_WARNING_CONFIG_FAILED
;
8414 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8416 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8418 return bgp_vty_return(vty
, ret
);
8421 /* "neighbor soo" */
8422 DEFPY (neighbor_soo
,
8424 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8427 "Set the Site-of-Origin (SoO) extended community\n"
8428 "VPN extended community\n")
8431 afi_t afi
= bgp_node_afi(vty
);
8432 safi_t safi
= bgp_node_safi(vty
);
8433 struct ecommunity
*ecomm_soo
;
8435 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8437 return CMD_WARNING_CONFIG_FAILED
;
8439 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8441 vty_out(vty
, "%% Malformed SoO extended community\n");
8444 ecommunity_str(ecomm_soo
);
8446 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8447 ecommunity_free(&peer
->soo
[afi
][safi
]);
8448 peer
->soo
[afi
][safi
] = ecomm_soo
;
8449 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8452 return bgp_vty_return(vty
,
8453 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8456 DEFPY (no_neighbor_soo
,
8457 no_neighbor_soo_cmd
,
8458 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8462 "Set the Site-of-Origin (SoO) extended community\n"
8463 "VPN extended community\n")
8466 afi_t afi
= bgp_node_afi(vty
);
8467 safi_t safi
= bgp_node_safi(vty
);
8469 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8471 return CMD_WARNING_CONFIG_FAILED
;
8473 ecommunity_free(&peer
->soo
[afi
][safi
]);
8475 return bgp_vty_return(
8476 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8479 /* "neighbor allowas-in" */
8480 DEFUN (neighbor_allowas_in
,
8481 neighbor_allowas_in_cmd
,
8482 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8485 "Accept as-path with my AS present in it\n"
8486 "Number of occurrences of AS number\n"
8487 "Only accept my AS in the as-path if the route was originated in my AS\n")
8490 int idx_number_origin
= 3;
8496 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8498 return CMD_WARNING_CONFIG_FAILED
;
8500 if (argc
<= idx_number_origin
)
8503 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8506 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8509 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8512 return bgp_vty_return(vty
, ret
);
8516 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8517 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8518 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8519 "Accept as-path with my AS present in it\n"
8520 "Number of occurrences of AS number\n"
8521 "Only accept my AS in the as-path if the route was originated in my AS\n")
8523 DEFUN (no_neighbor_allowas_in
,
8524 no_neighbor_allowas_in_cmd
,
8525 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8529 "allow local ASN appears in aspath attribute\n"
8530 "Number of occurrences of AS number\n"
8531 "Only accept my AS in the as-path if the route was originated in my AS\n")
8537 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8539 return CMD_WARNING_CONFIG_FAILED
;
8541 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8542 bgp_node_safi(vty
));
8544 return bgp_vty_return(vty
, ret
);
8548 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8549 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8550 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8551 "allow local ASN appears in aspath attribute\n"
8552 "Number of occurrences of AS number\n"
8553 "Only accept my AS in the as-path if the route was originated in my AS\n")
8555 DEFUN (neighbor_ttl_security
,
8556 neighbor_ttl_security_cmd
,
8557 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8560 "BGP ttl-security parameters\n"
8561 "Specify the maximum number of hops to the BGP peer\n"
8562 "Number of hops to BGP peer\n")
8569 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8571 return CMD_WARNING_CONFIG_FAILED
;
8573 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8576 * If 'neighbor swpX', then this is for directly connected peers,
8577 * we should not accept a ttl-security hops value greater than 1.
8579 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8581 "%s is directly connected peer, hops cannot exceed 1\n",
8582 argv
[idx_peer
]->arg
);
8583 return CMD_WARNING_CONFIG_FAILED
;
8586 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8589 DEFUN (no_neighbor_ttl_security
,
8590 no_neighbor_ttl_security_cmd
,
8591 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8595 "BGP ttl-security parameters\n"
8596 "Specify the maximum number of hops to the BGP peer\n"
8597 "Number of hops to BGP peer\n")
8602 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8604 return CMD_WARNING_CONFIG_FAILED
;
8606 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8609 /* disable-addpath-rx */
8610 DEFUN(neighbor_disable_addpath_rx
,
8611 neighbor_disable_addpath_rx_cmd
,
8612 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8615 "Do not accept additional paths\n")
8617 char *peer_str
= argv
[1]->arg
;
8619 afi_t afi
= bgp_node_afi(vty
);
8620 safi_t safi
= bgp_node_safi(vty
);
8622 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8624 return CMD_WARNING_CONFIG_FAILED
;
8626 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8627 PEER_FLAG_DISABLE_ADDPATH_RX
);
8630 DEFUN(no_neighbor_disable_addpath_rx
,
8631 no_neighbor_disable_addpath_rx_cmd
,
8632 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8636 "Do not accept additional paths\n")
8638 char *peer_str
= argv
[2]->arg
;
8640 afi_t afi
= bgp_node_afi(vty
);
8641 safi_t safi
= bgp_node_safi(vty
);
8643 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8645 return CMD_WARNING_CONFIG_FAILED
;
8647 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8648 PEER_FLAG_DISABLE_ADDPATH_RX
);
8651 DEFUN (neighbor_addpath_tx_all_paths
,
8652 neighbor_addpath_tx_all_paths_cmd
,
8653 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8656 "Use addpath to advertise all paths to a neighbor\n")
8661 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8663 return CMD_WARNING_CONFIG_FAILED
;
8665 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8670 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8671 neighbor_addpath_tx_all_paths_hidden_cmd
,
8672 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8673 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8674 "Use addpath to advertise all paths to a neighbor\n")
8676 DEFUN (no_neighbor_addpath_tx_all_paths
,
8677 no_neighbor_addpath_tx_all_paths_cmd
,
8678 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8682 "Use addpath to advertise all paths to a neighbor\n")
8687 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8689 return CMD_WARNING_CONFIG_FAILED
;
8691 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8692 != BGP_ADDPATH_ALL
) {
8694 "%% Peer not currently configured to transmit all paths.");
8695 return CMD_WARNING_CONFIG_FAILED
;
8698 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8704 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8705 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8706 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8708 "Use addpath to advertise all paths to a neighbor\n")
8710 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8711 neighbor_addpath_tx_bestpath_per_as_cmd
,
8712 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8715 "Use addpath to advertise the bestpath per each neighboring AS\n")
8720 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8722 return CMD_WARNING_CONFIG_FAILED
;
8724 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8725 BGP_ADDPATH_BEST_PER_AS
);
8730 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8731 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8732 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8733 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8734 "Use addpath to advertise the bestpath per each neighboring AS\n")
8736 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8737 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8738 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8742 "Use addpath to advertise the bestpath per each neighboring AS\n")
8747 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8749 return CMD_WARNING_CONFIG_FAILED
;
8751 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8752 != BGP_ADDPATH_BEST_PER_AS
) {
8754 "%% Peer not currently configured to transmit all best path per as.");
8755 return CMD_WARNING_CONFIG_FAILED
;
8758 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8764 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8765 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8766 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8767 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8768 "Use addpath to advertise the bestpath per each neighboring AS\n")
8771 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8772 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8775 "Detect AS loops before sending to neighbor\n")
8779 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8781 return CMD_WARNING_CONFIG_FAILED
;
8783 peer
->as_path_loop_detection
= true;
8789 no_neighbor_aspath_loop_detection
,
8790 no_neighbor_aspath_loop_detection_cmd
,
8791 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8795 "Detect AS loops before sending to neighbor\n")
8799 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8801 return CMD_WARNING_CONFIG_FAILED
;
8803 peer
->as_path_loop_detection
= false;
8808 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8809 struct ecommunity
**list
, bool is_rt6
)
8811 struct ecommunity
*ecom
= NULL
;
8812 struct ecommunity
*ecomadd
;
8814 for (; argc
; --argc
, ++argv
) {
8816 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8817 ECOMMUNITY_ROUTE_TARGET
,
8820 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8821 ECOMMUNITY_ROUTE_TARGET
,
8824 vty_out(vty
, "Malformed community-list value\n");
8826 ecommunity_free(&ecom
);
8827 return CMD_WARNING_CONFIG_FAILED
;
8831 ecommunity_merge(ecom
, ecomadd
);
8832 ecommunity_free(&ecomadd
);
8839 ecommunity_free(&*list
);
8847 * v2vimport is true if we are handling a `import vrf ...` command
8849 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8853 switch (vty
->node
) {
8862 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8867 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8868 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8869 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8870 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8872 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8876 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8877 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8878 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8879 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8881 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8888 DEFPY (af_rd_vpn_export
,
8889 af_rd_vpn_export_cmd
,
8890 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8892 "Specify route distinguisher\n"
8893 "Between current address-family and vpn\n"
8894 "For routes leaked from current address-family to vpn\n"
8895 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8898 struct prefix_rd prd
;
8904 if (argv_find(argv
, argc
, "no", &idx
))
8908 ret
= str2prefix_rd(rd_str
, &prd
);
8910 vty_out(vty
, "%% Malformed rd\n");
8911 return CMD_WARNING_CONFIG_FAILED
;
8915 afi
= vpn_policy_getafi(vty
, bgp
, false);
8917 return CMD_WARNING_CONFIG_FAILED
;
8920 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8922 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8923 bgp_get_default(), bgp
);
8926 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8927 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8928 BGP_VPN_POLICY_TOVPN_RD_SET
);
8930 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8931 BGP_VPN_POLICY_TOVPN_RD_SET
);
8934 /* post-change: re-export vpn routes */
8935 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8936 bgp_get_default(), bgp
);
8941 ALIAS (af_rd_vpn_export
,
8942 af_no_rd_vpn_export_cmd
,
8945 "Specify route distinguisher\n"
8946 "Between current address-family and vpn\n"
8947 "For routes leaked from current address-family to vpn\n")
8949 DEFPY (af_label_vpn_export
,
8950 af_label_vpn_export_cmd
,
8951 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8953 "label value for VRF\n"
8954 "Between current address-family and vpn\n"
8955 "For routes leaked from current address-family to vpn\n"
8956 "Label Value <0-1048575>\n"
8957 "Automatically assign a label\n")
8959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8960 mpls_label_t label
= MPLS_LABEL_NONE
;
8965 if (argv_find(argv
, argc
, "no", &idx
))
8968 /* If "no ...", squash trailing parameter */
8974 label
= label_val
; /* parser should force unsigned */
8977 afi
= vpn_policy_getafi(vty
, bgp
, false);
8979 return CMD_WARNING_CONFIG_FAILED
;
8982 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8983 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8988 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8990 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8991 bgp_get_default(), bgp
);
8993 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8994 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8996 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8999 * label has previously been automatically
9000 * assigned by labelpool: release it
9002 * NB if tovpn_label == MPLS_LABEL_NONE it
9003 * means the automatic assignment is in flight
9004 * and therefore the labelpool callback must
9005 * detect that the auto label is not needed.
9008 bgp_lp_release(LP_TYPE_VRF
,
9009 &bgp
->vpn_policy
[afi
],
9010 bgp
->vpn_policy
[afi
].tovpn_label
);
9012 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9013 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9016 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9018 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9019 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9020 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9021 vpn_leak_label_callback
);
9024 /* post-change: re-export vpn routes */
9025 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9026 bgp_get_default(), bgp
);
9028 hook_call(bgp_snmp_update_last_changed
, bgp
);
9032 DEFPY (af_sid_vpn_export
,
9033 af_sid_vpn_export_cmd
,
9034 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9036 "sid value for VRF\n"
9037 "Between current address-family and vpn\n"
9038 "For routes leaked from current address-family to vpn\n"
9039 "Sid allocation index\n"
9040 "Automatically assign a label\n")
9042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9048 if (argv_find(argv
, argc
, "no", &idx
))
9050 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9051 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9053 afi
= vpn_policy_getafi(vty
, bgp
, false);
9055 return CMD_WARNING_CONFIG_FAILED
;
9059 vty_out(vty
, "It's not implemented\n");
9060 return CMD_WARNING_CONFIG_FAILED
;
9063 if (bgp
->tovpn_sid_index
!= 0 ||
9064 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9066 "per-vrf sid and per-af sid are mutually exclusive\n"
9067 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9068 return CMD_WARNING_CONFIG_FAILED
;
9071 /* skip when it's already configured */
9072 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9073 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9074 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9078 * mode change between sid_idx and sid_auto isn't supported.
9079 * user must negate sid vpn export when they want to change the mode
9081 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9082 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9083 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9084 vty_out(vty
, "it's already configured as %s.\n",
9085 sid_auto
? "auto-mode" : "idx-mode");
9086 return CMD_WARNING_CONFIG_FAILED
;
9090 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9091 bgp_get_default(), bgp
);
9094 /* SID allocation auto-mode */
9096 zlog_debug("%s: auto sid alloc.", __func__
);
9097 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9098 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9100 /* SID allocation index-mode */
9102 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9103 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9107 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9108 bgp_get_default(), bgp
);
9112 DEFPY (bgp_sid_vpn_export
,
9113 bgp_sid_vpn_export_cmd
,
9114 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9116 "sid value for VRF\n"
9117 "Between current vrf and vpn\n"
9118 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9119 "For routes leaked from current vrf to vpn\n"
9120 "Sid allocation index\n"
9121 "Automatically assign a label\n")
9123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9126 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9127 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9130 /* when per-VRF SID is not set, do nothing */
9131 if (bgp
->tovpn_sid_index
== 0 &&
9132 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9137 bgp
->tovpn_sid_index
= 0;
9138 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9141 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9142 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9143 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9144 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9145 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9146 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9148 "per-vrf sid and per-af sid are mutually exclusive\n"
9149 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9150 return CMD_WARNING_CONFIG_FAILED
;
9153 /* skip when it's already configured */
9154 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9155 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9159 * mode change between sid_idx and sid_auto isn't supported.
9160 * user must negate sid vpn export when they want to change the mode
9162 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9164 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9165 vty_out(vty
, "it's already configured as %s.\n",
9166 sid_auto
? "auto-mode" : "idx-mode");
9167 return CMD_WARNING_CONFIG_FAILED
;
9171 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9173 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9177 /* SID allocation auto-mode */
9179 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9180 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9181 } else if (sid_idx
!= 0) {
9182 /* SID allocation index-mode */
9184 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9186 bgp
->tovpn_sid_index
= sid_idx
;
9190 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9192 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9193 bgp_get_default(), bgp
);
9198 ALIAS (af_label_vpn_export
,
9199 af_no_label_vpn_export_cmd
,
9200 "no label vpn export",
9202 "label value for VRF\n"
9203 "Between current address-family and vpn\n"
9204 "For routes leaked from current address-family to vpn\n")
9206 ALIAS (bgp_sid_vpn_export
,
9207 no_bgp_sid_vpn_export_cmd
,
9208 "no$no sid vpn per-vrf export",
9210 "sid value for VRF\n"
9211 "Between current vrf and vpn\n"
9212 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9213 "For routes leaked from current vrf to vpn\n")
9215 DEFPY (af_nexthop_vpn_export
,
9216 af_nexthop_vpn_export_cmd
,
9217 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9219 "Specify next hop to use for VRF advertised prefixes\n"
9220 "Between current address-family and vpn\n"
9221 "For routes leaked from current address-family to vpn\n"
9225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9231 vty_out(vty
, "%% Nexthop required\n");
9232 return CMD_WARNING_CONFIG_FAILED
;
9234 if (!sockunion2hostprefix(nexthop_su
, &p
))
9235 return CMD_WARNING_CONFIG_FAILED
;
9238 afi
= vpn_policy_getafi(vty
, bgp
, false);
9240 return CMD_WARNING_CONFIG_FAILED
;
9243 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9245 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9246 bgp_get_default(), bgp
);
9249 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9250 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9251 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9253 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9254 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9257 /* post-change: re-export vpn routes */
9258 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9259 bgp_get_default(), bgp
);
9264 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9266 if (!strcmp(dstr
, "import")) {
9267 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9268 } else if (!strcmp(dstr
, "export")) {
9269 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9270 } else if (!strcmp(dstr
, "both")) {
9271 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9272 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9274 vty_out(vty
, "%% direction parse error\n");
9275 return CMD_WARNING_CONFIG_FAILED
;
9280 DEFPY (af_rt_vpn_imexport
,
9281 af_rt_vpn_imexport_cmd
,
9282 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9284 "Specify route target list\n"
9285 "Specify route target list\n"
9286 "Between current address-family and vpn\n"
9287 "For routes leaked from vpn to current address-family: match any\n"
9288 "For routes leaked from current address-family to vpn: set\n"
9289 "both import: match any and export: set\n"
9290 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9294 struct ecommunity
*ecom
= NULL
;
9295 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9296 enum vpn_policy_direction dir
;
9301 if (argv_find(argv
, argc
, "no", &idx
))
9304 afi
= vpn_policy_getafi(vty
, bgp
, false);
9306 return CMD_WARNING_CONFIG_FAILED
;
9308 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9309 if (ret
!= CMD_SUCCESS
)
9313 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9314 vty_out(vty
, "%% Missing RTLIST\n");
9315 return CMD_WARNING_CONFIG_FAILED
;
9317 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9318 if (ret
!= CMD_SUCCESS
) {
9323 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9327 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9330 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9332 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9333 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9334 ecommunity_dup(ecom
);
9336 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9338 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9339 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9342 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9346 ecommunity_free(&ecom
);
9351 ALIAS (af_rt_vpn_imexport
,
9352 af_no_rt_vpn_imexport_cmd
,
9353 "no <rt|route-target> vpn <import|export|both>$direction_str",
9355 "Specify route target list\n"
9356 "Specify route target list\n"
9357 "Between current address-family and vpn\n"
9358 "For routes leaked from vpn to current address-family\n"
9359 "For routes leaked from current address-family to vpn\n"
9360 "both import and export\n")
9362 DEFPY (af_route_map_vpn_imexport
,
9363 af_route_map_vpn_imexport_cmd
,
9364 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9365 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9367 "Specify route map\n"
9368 "Between current address-family and vpn\n"
9369 "For routes leaked from vpn to current address-family\n"
9370 "For routes leaked from current address-family to vpn\n"
9371 "name of route-map\n")
9373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9375 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9376 enum vpn_policy_direction dir
;
9381 if (argv_find(argv
, argc
, "no", &idx
))
9384 afi
= vpn_policy_getafi(vty
, bgp
, false);
9386 return CMD_WARNING_CONFIG_FAILED
;
9388 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9389 if (ret
!= CMD_SUCCESS
)
9392 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9396 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9399 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9400 XFREE(MTYPE_ROUTE_MAP_NAME
,
9401 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9402 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9403 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9404 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9405 route_map_lookup_warn_noexist(vty
, rmap_str
);
9406 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9409 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9410 XFREE(MTYPE_ROUTE_MAP_NAME
,
9411 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9412 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9413 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9416 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9422 ALIAS (af_route_map_vpn_imexport
,
9423 af_no_route_map_vpn_imexport_cmd
,
9424 "no route-map vpn <import|export>$direction_str",
9426 "Specify route map\n"
9427 "Between current address-family and vpn\n"
9428 "For routes leaked from vpn to current address-family\n"
9429 "For routes leaked from current address-family to vpn\n")
9431 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9432 "import vrf route-map RMAP$rmap_str",
9433 "Import routes from another VRF\n"
9434 "Vrf routes being filtered\n"
9435 "Specify route map\n"
9436 "name of route-map\n")
9438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9439 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9441 struct bgp
*bgp_default
;
9443 afi
= vpn_policy_getafi(vty
, bgp
, true);
9445 return CMD_WARNING_CONFIG_FAILED
;
9447 bgp_default
= bgp_get_default();
9452 /* Auto-create assuming the same AS */
9453 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9454 BGP_INSTANCE_TYPE_DEFAULT
);
9458 "VRF default is not configured as a bgp instance\n");
9463 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9465 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9466 XFREE(MTYPE_ROUTE_MAP_NAME
,
9467 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9468 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9469 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9470 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9471 route_map_lookup_warn_noexist(vty
, rmap_str
);
9472 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9475 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9476 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9478 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9483 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9484 "no import vrf route-map [RMAP$rmap_str]",
9486 "Import routes from another VRF\n"
9487 "Vrf routes being filtered\n"
9488 "Specify route map\n"
9489 "name of route-map\n")
9491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9492 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9495 afi
= vpn_policy_getafi(vty
, bgp
, true);
9497 return CMD_WARNING_CONFIG_FAILED
;
9499 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9501 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9502 XFREE(MTYPE_ROUTE_MAP_NAME
,
9503 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9504 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9505 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9507 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9508 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9509 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9511 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9516 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9517 "[no] import vrf VIEWVRFNAME$import_name",
9519 "Import routes from another VRF\n"
9520 "VRF to import from\n"
9521 "The name of the VRF\n")
9523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9524 struct listnode
*node
;
9525 struct bgp
*vrf_bgp
, *bgp_default
;
9528 bool remove
= false;
9531 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9535 if (import_name
== NULL
) {
9536 vty_out(vty
, "%% Missing import name\n");
9540 if (strcmp(import_name
, "route-map") == 0) {
9541 vty_out(vty
, "%% Must include route-map name\n");
9545 if (argv_find(argv
, argc
, "no", &idx
))
9548 afi
= vpn_policy_getafi(vty
, bgp
, true);
9550 return CMD_WARNING_CONFIG_FAILED
;
9552 safi
= bgp_node_safi(vty
);
9554 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9555 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9556 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9557 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9558 remove
? "unimport" : "import", import_name
);
9562 bgp_default
= bgp_get_default();
9564 /* Auto-create assuming the same AS */
9565 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9566 BGP_INSTANCE_TYPE_DEFAULT
);
9570 "VRF default is not configured as a bgp instance\n");
9575 vrf_bgp
= bgp_lookup_by_name(import_name
);
9577 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9578 vrf_bgp
= bgp_default
;
9580 /* Auto-create assuming the same AS */
9581 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9585 "VRF %s is not configured as a bgp instance\n",
9592 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9594 /* Already importing from "import_vrf"? */
9595 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9597 if (strcmp(vname
, import_name
) == 0)
9601 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9607 /* This command is valid only in a bgp vrf instance or the default instance */
9608 DEFPY (bgp_imexport_vpn
,
9609 bgp_imexport_vpn_cmd
,
9610 "[no] <import|export>$direction_str vpn",
9612 "Import routes to this address-family\n"
9613 "Export routes from this address-family\n"
9614 "to/from default instance VPN RIB\n")
9616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9623 enum vpn_policy_direction dir
;
9625 if (argv_find(argv
, argc
, "no", &idx
))
9628 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9629 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9631 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9632 return CMD_WARNING_CONFIG_FAILED
;
9635 afi
= bgp_node_afi(vty
);
9636 safi
= bgp_node_safi(vty
);
9637 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9638 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9639 return CMD_WARNING_CONFIG_FAILED
;
9642 if (!strcmp(direction_str
, "import")) {
9643 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9644 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9645 } else if (!strcmp(direction_str
, "export")) {
9646 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9647 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9649 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9650 return CMD_WARNING_CONFIG_FAILED
;
9653 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9656 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9657 if (!previous_state
) {
9658 /* trigger export current vrf */
9659 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9662 if (previous_state
) {
9663 /* trigger un-export current vrf */
9664 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9666 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9669 hook_call(bgp_snmp_init_stats
, bgp
);
9674 DEFPY (af_routetarget_import
,
9675 af_routetarget_import_cmd
,
9676 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9678 "Specify route target list\n"
9679 "Specify route target list\n"
9680 "Specify route target list\n"
9681 "Specify route target list\n"
9682 "Flow-spec redirect type route target\n"
9683 "Import routes to this address-family\n"
9684 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9688 struct ecommunity
*ecom
= NULL
;
9690 int idx
= 0, idx_unused
= 0;
9694 if (argv_find(argv
, argc
, "no", &idx
))
9697 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9698 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9701 afi
= vpn_policy_getafi(vty
, bgp
, false);
9703 return CMD_WARNING_CONFIG_FAILED
;
9705 if (rt6
&& afi
!= AFI_IP6
)
9706 return CMD_WARNING_CONFIG_FAILED
;
9709 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9710 vty_out(vty
, "%% Missing RTLIST\n");
9711 return CMD_WARNING_CONFIG_FAILED
;
9713 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9714 if (ret
!= CMD_SUCCESS
)
9719 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9720 ecommunity_free(&bgp
->vpn_policy
[afi
]
9721 .import_redirect_rtlist
);
9722 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9723 ecommunity_dup(ecom
);
9725 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9726 ecommunity_free(&bgp
->vpn_policy
[afi
]
9727 .import_redirect_rtlist
);
9728 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9732 ecommunity_free(&ecom
);
9737 DEFUN_NOSH (address_family_ipv4_safi
,
9738 address_family_ipv4_safi_cmd
,
9739 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9740 "Enter Address Family command mode\n"
9742 BGP_SAFI_WITH_LABEL_HELP_STR
)
9746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9747 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9748 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9749 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9750 && safi
!= SAFI_EVPN
) {
9752 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9753 return CMD_WARNING_CONFIG_FAILED
;
9755 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9757 vty
->node
= BGP_IPV4_NODE
;
9762 DEFUN_NOSH (address_family_ipv6_safi
,
9763 address_family_ipv6_safi_cmd
,
9764 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9765 "Enter Address Family command mode\n"
9767 BGP_SAFI_WITH_LABEL_HELP_STR
)
9770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9771 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9772 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9773 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9774 && safi
!= SAFI_EVPN
) {
9776 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9777 return CMD_WARNING_CONFIG_FAILED
;
9779 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9781 vty
->node
= BGP_IPV6_NODE
;
9786 #ifdef KEEP_OLD_VPN_COMMANDS
9787 DEFUN_NOSH (address_family_vpnv4
,
9788 address_family_vpnv4_cmd
,
9789 "address-family vpnv4 [unicast]",
9790 "Enter Address Family command mode\n"
9792 BGP_AF_MODIFIER_STR
)
9794 vty
->node
= BGP_VPNV4_NODE
;
9798 DEFUN_NOSH (address_family_vpnv6
,
9799 address_family_vpnv6_cmd
,
9800 "address-family vpnv6 [unicast]",
9801 "Enter Address Family command mode\n"
9803 BGP_AF_MODIFIER_STR
)
9805 vty
->node
= BGP_VPNV6_NODE
;
9808 #endif /* KEEP_OLD_VPN_COMMANDS */
9810 DEFUN_NOSH (address_family_evpn
,
9811 address_family_evpn_cmd
,
9812 "address-family l2vpn evpn",
9813 "Enter Address Family command mode\n"
9815 BGP_AF_MODIFIER_STR
)
9817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9818 vty
->node
= BGP_EVPN_NODE
;
9822 DEFUN_NOSH (bgp_segment_routing_srv6
,
9823 bgp_segment_routing_srv6_cmd
,
9824 "segment-routing srv6",
9825 "Segment-Routing configuration\n"
9826 "Segment-Routing SRv6 configuration\n")
9828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9829 bgp
->srv6_enabled
= true;
9830 vty
->node
= BGP_SRV6_NODE
;
9834 DEFUN (no_bgp_segment_routing_srv6
,
9835 no_bgp_segment_routing_srv6_cmd
,
9836 "no segment-routing srv6",
9838 "Segment-Routing configuration\n"
9839 "Segment-Routing SRv6 configuration\n")
9841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9843 if (strlen(bgp
->srv6_locator_name
) > 0)
9844 if (bgp_srv6_locator_unset(bgp
) < 0)
9845 return CMD_WARNING_CONFIG_FAILED
;
9847 bgp
->srv6_enabled
= false;
9851 DEFPY (bgp_srv6_locator
,
9852 bgp_srv6_locator_cmd
,
9853 "locator NAME$name",
9854 "Specify SRv6 locator\n"
9855 "Specify SRv6 locator\n")
9857 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9860 if (strlen(bgp
->srv6_locator_name
) > 0
9861 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9862 vty_out(vty
, "srv6 locator is already configured\n");
9863 return CMD_WARNING_CONFIG_FAILED
;
9866 snprintf(bgp
->srv6_locator_name
,
9867 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9869 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9871 return CMD_WARNING_CONFIG_FAILED
;
9876 DEFPY (no_bgp_srv6_locator
,
9877 no_bgp_srv6_locator_cmd
,
9878 "no locator NAME$name",
9880 "Specify SRv6 locator\n"
9881 "Specify SRv6 locator\n")
9883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9885 /* when locator isn't configured, do nothing */
9886 if (strlen(bgp
->srv6_locator_name
) < 1)
9889 /* name validation */
9890 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9891 vty_out(vty
, "%% No srv6 locator is configured\n");
9892 return CMD_WARNING_CONFIG_FAILED
;
9896 if (bgp_srv6_locator_unset(bgp
) < 0)
9897 return CMD_WARNING_CONFIG_FAILED
;
9902 DEFPY (show_bgp_srv6
,
9904 "show bgp segment-routing srv6",
9907 "BGP Segment Routing\n"
9908 "BGP Segment Routing SRv6\n")
9911 struct listnode
*node
;
9912 struct srv6_locator_chunk
*chunk
;
9913 struct bgp_srv6_function
*func
;
9915 bgp
= bgp_get_default();
9919 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9920 vty_out(vty
, "locator_chunks:\n");
9921 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9922 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9923 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9924 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9925 vty_out(vty
, " func-length: %d\n",
9926 chunk
->function_bits_length
);
9927 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9930 vty_out(vty
, "functions:\n");
9931 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9932 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
9933 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9936 vty_out(vty
, "bgps:\n");
9937 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9938 vty_out(vty
, "- name: %s\n",
9939 bgp
->name
? bgp
->name
: "default");
9941 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9942 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9943 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9944 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9945 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9951 DEFUN_NOSH (exit_address_family
,
9952 exit_address_family_cmd
,
9953 "exit-address-family",
9954 "Exit from Address Family configuration mode\n")
9956 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9957 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9958 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9959 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9960 || vty
->node
== BGP_EVPN_NODE
9961 || vty
->node
== BGP_FLOWSPECV4_NODE
9962 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9963 vty
->node
= BGP_NODE
;
9967 /* Recalculate bestpath and re-advertise a prefix */
9968 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9969 const char *ip_str
, afi_t afi
, safi_t safi
,
9970 struct prefix_rd
*prd
)
9973 struct prefix match
;
9974 struct bgp_dest
*dest
;
9975 struct bgp_dest
*rm
;
9977 struct bgp_table
*table
;
9978 struct bgp_table
*rib
;
9980 /* BGP structure lookup. */
9982 bgp
= bgp_lookup_by_name(view_name
);
9984 vty_out(vty
, "%% Can't find BGP instance %s\n",
9989 bgp
= bgp_get_default();
9991 vty_out(vty
, "%% No BGP process is configured\n");
9996 /* Check IP address argument. */
9997 ret
= str2prefix(ip_str
, &match
);
9999 vty_out(vty
, "%% address is malformed\n");
10000 return CMD_WARNING
;
10003 match
.family
= afi2family(afi
);
10004 rib
= bgp
->rib
[afi
][safi
];
10006 if (safi
== SAFI_MPLS_VPN
) {
10007 for (dest
= bgp_table_top(rib
); dest
;
10008 dest
= bgp_route_next(dest
)) {
10009 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10011 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10014 table
= bgp_dest_get_bgp_table_info(dest
);
10018 rm
= bgp_node_match(table
, &match
);
10020 const struct prefix
*rm_p
=
10021 bgp_dest_get_prefix(rm
);
10023 if (rm_p
->prefixlen
== match
.prefixlen
) {
10024 SET_FLAG(rm
->flags
,
10025 BGP_NODE_USER_CLEAR
);
10026 bgp_process(bgp
, rm
, afi
, safi
);
10028 bgp_dest_unlock_node(rm
);
10032 dest
= bgp_node_match(rib
, &match
);
10033 if (dest
!= NULL
) {
10034 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10036 if (dest_p
->prefixlen
== match
.prefixlen
) {
10037 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10038 bgp_process(bgp
, dest
, afi
, safi
);
10040 bgp_dest_unlock_node(dest
);
10044 return CMD_SUCCESS
;
10047 /* one clear bgp command to rule them all */
10048 DEFUN (clear_ip_bgp_all
,
10049 clear_ip_bgp_all_cmd
,
10050 "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>]",
10054 BGP_INSTANCE_HELP_STR
10057 BGP_SAFI_WITH_LABEL_HELP_STR
10058 BGP_AF_MODIFIER_STR
10059 "Clear all peers\n"
10060 "BGP IPv4 neighbor to clear\n"
10061 "BGP IPv6 neighbor to clear\n"
10062 "BGP neighbor on interface to clear\n"
10063 "Clear peers with the AS number\n"
10064 "Clear all external peers\n"
10065 "Clear all members of peer-group\n"
10066 "BGP peer-group name\n"
10071 "Push out prefix-list ORF and do inbound soft reconfig\n"
10073 "Reset message statistics\n")
10077 afi_t afi
= AFI_UNSPEC
;
10078 safi_t safi
= SAFI_UNSPEC
;
10079 enum clear_sort clr_sort
= clear_peer
;
10080 enum bgp_clear_type clr_type
;
10081 char *clr_arg
= NULL
;
10085 /* clear [ip] bgp */
10086 if (argv_find(argv
, argc
, "ip", &idx
))
10089 /* [<vrf> VIEWVRFNAME] */
10090 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10091 vrf
= argv
[idx
+ 1]->arg
;
10093 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10095 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10096 /* [<view> VIEWVRFNAME] */
10097 vrf
= argv
[idx
+ 1]->arg
;
10100 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10101 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10102 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10104 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10105 if (argv_find(argv
, argc
, "*", &idx
)) {
10106 clr_sort
= clear_all
;
10107 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10108 clr_sort
= clear_peer
;
10109 clr_arg
= argv
[idx
]->arg
;
10110 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10111 clr_sort
= clear_peer
;
10112 clr_arg
= argv
[idx
]->arg
;
10113 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10114 clr_sort
= clear_group
;
10116 clr_arg
= argv
[idx
]->arg
;
10117 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10118 clr_sort
= clear_peer
;
10119 clr_arg
= argv
[idx
]->arg
;
10120 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10121 clr_sort
= clear_peer
;
10122 clr_arg
= argv
[idx
]->arg
;
10123 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10124 clr_sort
= clear_as
;
10125 clr_arg
= argv
[idx
]->arg
;
10126 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10127 clr_sort
= clear_external
;
10130 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10131 if (argv_find(argv
, argc
, "soft", &idx
)) {
10132 if (argv_find(argv
, argc
, "in", &idx
)
10133 || argv_find(argv
, argc
, "out", &idx
))
10134 clr_type
= strmatch(argv
[idx
]->text
, "in")
10135 ? BGP_CLEAR_SOFT_IN
10136 : BGP_CLEAR_SOFT_OUT
;
10138 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10139 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10140 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10141 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10142 : BGP_CLEAR_SOFT_IN
;
10143 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10144 clr_type
= BGP_CLEAR_SOFT_OUT
;
10145 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10146 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10148 clr_type
= BGP_CLEAR_SOFT_NONE
;
10150 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10153 DEFUN (clear_ip_bgp_prefix
,
10154 clear_ip_bgp_prefix_cmd
,
10155 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10159 BGP_INSTANCE_HELP_STR
10160 "Clear bestpath and re-advertise\n"
10164 char *prefix
= NULL
;
10168 /* [<view|vrf> VIEWVRFNAME] */
10169 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10170 vrf
= argv
[idx
+ 1]->arg
;
10172 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10174 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10175 /* [<view> VIEWVRFNAME] */
10176 vrf
= argv
[idx
+ 1]->arg
;
10180 prefix
= argv
[argc
- 1]->arg
;
10182 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10185 DEFUN (clear_bgp_ipv6_safi_prefix
,
10186 clear_bgp_ipv6_safi_prefix_cmd
,
10187 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10193 "Clear bestpath and re-advertise\n"
10197 int idx_ipv6_prefix
= 0;
10198 safi_t safi
= SAFI_UNICAST
;
10199 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10200 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10202 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10203 return bgp_clear_prefix(
10204 vty
, NULL
, prefix
, AFI_IP6
,
10208 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10209 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10210 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10214 BGP_INSTANCE_HELP_STR
10217 "Clear bestpath and re-advertise\n"
10221 int idx_vrfview
= 0;
10222 int idx_ipv6_prefix
= 0;
10223 safi_t safi
= SAFI_UNICAST
;
10224 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10225 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10226 char *vrfview
= NULL
;
10228 /* [<view|vrf> VIEWVRFNAME] */
10229 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10230 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10231 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10233 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10234 /* [<view> VIEWVRFNAME] */
10235 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10237 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10239 return bgp_clear_prefix(
10240 vty
, vrfview
, prefix
,
10241 AFI_IP6
, safi
, NULL
);
10244 DEFUN (show_bgp_views
,
10245 show_bgp_views_cmd
,
10246 "show [ip] bgp views",
10250 "Show the defined BGP views\n")
10252 struct list
*inst
= bm
->bgp
;
10253 struct listnode
*node
;
10256 vty_out(vty
, "Defined BGP views:\n");
10257 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10259 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10261 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10265 return CMD_SUCCESS
;
10268 DEFUN (show_bgp_vrfs
,
10270 "show [ip] bgp vrfs [json]",
10277 char buf
[ETHER_ADDR_STRLEN
];
10278 struct list
*inst
= bm
->bgp
;
10279 struct listnode
*node
;
10281 bool uj
= use_json(argc
, argv
);
10282 json_object
*json
= NULL
;
10283 json_object
*json_vrfs
= NULL
;
10287 json
= json_object_new_object();
10288 json_vrfs
= json_object_new_object();
10291 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10292 const char *name
, *type
;
10294 struct listnode
*node2
, *nnode2
;
10295 int peers_cfg
, peers_estb
;
10296 json_object
*json_vrf
= NULL
;
10299 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10303 if (!uj
&& count
== 1) {
10305 "%4s %-5s %-16s %9s %10s %-37s\n",
10306 "Type", "Id", "routerId", "#PeersCfg",
10307 "#PeersEstb", "Name");
10308 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10309 "L3-VNI", "RouterMAC", "Interface");
10312 peers_cfg
= peers_estb
= 0;
10314 json_vrf
= json_object_new_object();
10317 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10318 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10321 if (peer_established(peer
))
10325 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10326 name
= VRF_DEFAULT_NAME
;
10335 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10337 : (int64_t)bgp
->vrf_id
;
10338 char buf
[BUFSIZ
] = {0};
10340 json_object_string_add(json_vrf
, "type", type
);
10341 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10342 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10344 json_object_int_add(json_vrf
, "numConfiguredPeers",
10346 json_object_int_add(json_vrf
, "numEstablishedPeers",
10349 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10350 json_object_string_add(
10352 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10353 json_object_string_add(json_vrf
, "interface",
10354 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10356 json_object_object_add(json_vrfs
, name
, json_vrf
);
10358 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10360 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10361 : (int)bgp
->vrf_id
,
10362 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10363 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10365 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10366 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10372 json_object_object_add(json
, "vrfs", json_vrfs
);
10374 json_object_int_add(json
, "totalVrfs", count
);
10376 vty_json(vty
, json
);
10380 "\nTotal number of VRFs (including default): %d\n",
10384 return CMD_SUCCESS
;
10387 DEFUN (show_bgp_mac_hash
,
10388 show_bgp_mac_hash_cmd
,
10389 "show bgp mac hash",
10393 "Mac Address database\n")
10395 bgp_mac_dump_table(vty
);
10397 return CMD_SUCCESS
;
10400 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10402 struct vty
*vty
= (struct vty
*)args
;
10403 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10405 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10408 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10410 vty_out(vty
, "self nexthop database:\n");
10411 bgp_nexthop_show_address_hash(vty
, bgp
);
10413 vty_out(vty
, "Tunnel-ip database:\n");
10414 hash_iterate(bgp
->tip_hash
,
10415 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10419 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10420 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10421 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10422 "martian next-hops\n"
10423 "martian next-hop database\n")
10425 struct bgp
*bgp
= NULL
;
10429 /* [<vrf> VIEWVRFNAME] */
10430 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10431 name
= argv
[idx
+ 1]->arg
;
10432 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10434 } else if (argv_find(argv
, argc
, "view", &idx
))
10435 /* [<view> VIEWVRFNAME] */
10436 name
= argv
[idx
+ 1]->arg
;
10438 bgp
= bgp_lookup_by_name(name
);
10440 bgp
= bgp_get_default();
10443 vty_out(vty
, "%% No BGP process is configured\n");
10444 return CMD_WARNING
;
10446 bgp_show_martian_nexthops(vty
, bgp
);
10448 return CMD_SUCCESS
;
10451 DEFUN (show_bgp_memory
,
10452 show_bgp_memory_cmd
,
10453 "show [ip] bgp memory",
10457 "Global BGP memory statistics\n")
10459 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10460 unsigned long count
;
10462 /* RIB related usage stats */
10463 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10464 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10465 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10466 count
* sizeof(struct bgp_dest
)));
10468 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10469 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10470 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10471 count
* sizeof(struct bgp_path_info
)));
10472 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10473 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10476 memstrbuf
, sizeof(memstrbuf
),
10477 count
* sizeof(struct bgp_path_info_extra
)));
10479 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10480 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10481 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10482 count
* sizeof(struct bgp_static
)));
10484 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10485 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10486 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10487 count
* sizeof(struct bpacket
)));
10490 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10491 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10492 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10493 count
* sizeof(struct bgp_adj_in
)));
10494 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10495 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10497 count
* sizeof(struct bgp_adj_out
)));
10499 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10500 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10502 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10503 count
* sizeof(struct bgp_nexthop_cache
)));
10505 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10506 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10508 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10509 count
* sizeof(struct bgp_damp_info
)));
10512 count
= attr_count();
10513 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10514 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10515 count
* sizeof(struct attr
)));
10517 if ((count
= attr_unknown_count()))
10518 vty_out(vty
, "%ld unknown attributes\n", count
);
10520 /* AS_PATH attributes */
10521 count
= aspath_count();
10522 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10523 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10524 count
* sizeof(struct aspath
)));
10526 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10527 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10528 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10529 count
* sizeof(struct assegment
)));
10531 /* Other attributes */
10532 if ((count
= community_count()))
10533 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10534 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10535 count
* sizeof(struct community
)));
10536 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10538 "%ld BGP ext-community entries, using %s of memory\n",
10540 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10541 count
* sizeof(struct ecommunity
)));
10542 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10544 "%ld BGP large-community entries, using %s of memory\n",
10545 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10546 count
* sizeof(struct lcommunity
)));
10548 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10549 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10550 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10551 count
* sizeof(struct cluster_list
)));
10553 /* Peer related usage */
10554 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10555 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10556 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10557 count
* sizeof(struct peer
)));
10559 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10560 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10561 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10562 count
* sizeof(struct peer_group
)));
10565 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10566 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10567 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10568 count
* sizeof(regex_t
)));
10569 return CMD_SUCCESS
;
10572 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10574 json_object
*bestpath
= json_object_new_object();
10576 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10577 json_object_string_add(bestpath
, "asPath", "ignore");
10579 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10580 json_object_string_add(bestpath
, "asPath", "confed");
10582 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10583 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10584 json_object_string_add(bestpath
, "multiPathRelax",
10587 json_object_string_add(bestpath
, "multiPathRelax",
10590 json_object_string_add(bestpath
, "multiPathRelax", "false");
10592 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10593 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10595 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10596 json_object_string_add(bestpath
, "compareRouterId", "true");
10597 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10598 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10599 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10600 json_object_string_add(bestpath
, "med", "confed");
10601 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10602 json_object_string_add(bestpath
, "med",
10603 "missing-as-worst");
10605 json_object_string_add(bestpath
, "med", "true");
10608 json_object_object_add(json
, "bestPath", bestpath
);
10611 /* Print the error code/subcode for why the peer is down */
10612 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10613 json_object
*json_peer
, bool use_json
)
10615 const char *code_str
;
10616 const char *subcode_str
;
10619 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10620 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10621 char errorcodesubcode_hexstr
[5];
10622 char errorcodesubcode_str
[256];
10624 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10625 subcode_str
= bgp_notify_subcode_str(
10627 peer
->notify
.subcode
);
10629 snprintf(errorcodesubcode_hexstr
,
10630 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10631 peer
->notify
.code
, peer
->notify
.subcode
);
10632 json_object_string_add(json_peer
,
10633 "lastErrorCodeSubcode",
10634 errorcodesubcode_hexstr
);
10635 snprintf(errorcodesubcode_str
, 255, "%s%s",
10636 code_str
, subcode_str
);
10637 json_object_string_add(json_peer
,
10638 "lastNotificationReason",
10639 errorcodesubcode_str
);
10640 json_object_boolean_add(json_peer
,
10641 "lastNotificationHardReset",
10642 peer
->notify
.hard_reset
);
10643 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10644 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10645 && (peer
->notify
.subcode
10646 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10647 || peer
->notify
.subcode
10648 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10649 && peer
->notify
.length
) {
10651 const char *msg_str
;
10653 msg_str
= bgp_notify_admin_message(
10654 msgbuf
, sizeof(msgbuf
),
10655 (uint8_t *)peer
->notify
.data
,
10656 peer
->notify
.length
);
10658 json_object_string_add(
10660 "lastShutdownDescription",
10665 json_object_string_add(json_peer
, "lastResetDueTo",
10666 peer_down_str
[(int)peer
->last_reset
]);
10667 json_object_int_add(json_peer
, "lastResetCode",
10670 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10671 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10672 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10674 bgp_notify_subcode_str(peer
->notify
.code
,
10675 peer
->notify
.subcode
);
10676 vty_out(vty
, " Notification %s (%s%s%s)\n",
10677 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10680 code_str
, subcode_str
,
10681 peer
->notify
.hard_reset
10682 ? bgp_notify_subcode_str(
10684 BGP_NOTIFY_CEASE_HARD_RESET
)
10687 vty_out(vty
, " %s\n",
10688 peer_down_str
[(int)peer
->last_reset
]);
10693 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10696 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10699 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10700 struct peer
*peer
, json_object
*json_peer
,
10701 int max_neighbor_width
, bool use_json
)
10703 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10707 if (peer_dynamic_neighbor(peer
))
10708 json_object_boolean_true_add(json_peer
,
10710 if (peer
->hostname
)
10711 json_object_string_add(json_peer
, "hostname",
10714 if (peer
->domainname
)
10715 json_object_string_add(json_peer
, "domainname",
10717 json_object_int_add(json_peer
, "connectionsEstablished",
10718 peer
->established
);
10719 json_object_int_add(json_peer
, "connectionsDropped",
10721 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10722 use_json
, json_peer
);
10723 if (peer_established(peer
))
10724 json_object_string_add(json_peer
, "lastResetDueTo",
10725 "AFI/SAFI Not Negotiated");
10727 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10730 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10732 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10733 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10734 peer
->hostname
, peer
->host
);
10736 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10738 /* pad the neighbor column with spaces */
10739 if (len
< max_neighbor_width
)
10740 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10742 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10744 peer_uptime(peer
->uptime
, timebuf
,
10745 BGP_UPTIME_LEN
, 0, NULL
));
10746 if (peer_established(peer
))
10747 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10749 bgp_show_peer_reset(vty
, peer
, NULL
,
10754 /* Strip peer's description to the given size. */
10755 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10757 static char stripped
[BUFSIZ
];
10759 uint32_t last_space
= 0;
10762 if (*(desc
+ i
) == 0) {
10763 stripped
[i
] = '\0';
10766 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10768 stripped
[i
] = *(desc
+ i
);
10772 if (last_space
> size
)
10773 stripped
[size
+ 1] = '\0';
10775 stripped
[last_space
] = '\0';
10780 /* Determine whether var peer should be filtered out of the summary. */
10781 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10782 struct peer
*fpeer
, int as_type
,
10786 /* filter neighbor XXXX */
10787 if (fpeer
&& fpeer
!= peer
)
10790 /* filter remote-as (internal|external) */
10791 if (as_type
!= AS_UNSPECIFIED
) {
10792 if (peer
->as_type
== AS_SPECIFIED
) {
10793 if (as_type
== AS_INTERNAL
) {
10794 if (peer
->as
!= peer
->local_as
)
10796 } else if (peer
->as
== peer
->local_as
)
10798 } else if (as_type
!= peer
->as_type
)
10800 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10806 /* Show BGP peer's summary information.
10808 * Peer's description is stripped according to if `wide` option is given
10811 * When adding new columns to `show bgp summary` output, please make
10812 * sure `Desc` is the lastest column to show because it can contain
10813 * whitespaces and the whole output will be tricky.
10815 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10816 struct peer
*fpeer
, int as_type
, as_t as
,
10817 uint16_t show_flags
)
10820 struct listnode
*node
, *nnode
;
10821 unsigned int count
= 0, dn_count
= 0;
10822 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10823 char neighbor_buf
[VTY_BUFSIZ
];
10824 int neighbor_col_default_width
= 16;
10825 int len
, failed_count
= 0;
10826 unsigned int filtered_count
= 0;
10827 int max_neighbor_width
= 0;
10829 json_object
*json
= NULL
;
10830 json_object
*json_peer
= NULL
;
10831 json_object
*json_peers
= NULL
;
10832 struct peer_af
*paf
;
10833 struct bgp_filter
*filter
;
10834 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10835 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10836 bool show_established
=
10837 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10838 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10839 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10841 /* labeled-unicast routes are installed in the unicast table so in order
10843 * display the correct PfxRcd value we must look at SAFI_UNICAST
10846 if (safi
== SAFI_LABELED_UNICAST
)
10847 pfx_rcd_safi
= SAFI_UNICAST
;
10849 pfx_rcd_safi
= safi
;
10852 json
= json_object_new_object();
10853 json_peers
= json_object_new_object();
10854 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10855 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10862 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10865 if (peer
->afc
[afi
][safi
]) {
10866 /* See if we have at least a single failed peer */
10867 if (bgp_has_peer_failed(peer
, afi
, safi
))
10871 if (peer_dynamic_neighbor(peer
))
10876 /* Loop over all neighbors that will be displayed to determine
10878 * characters are needed for the Neighbor column
10880 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10881 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10888 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10891 if (peer
->afc
[afi
][safi
]) {
10892 memset(dn_flag
, '\0', sizeof(dn_flag
));
10893 if (peer_dynamic_neighbor(peer
))
10897 && CHECK_FLAG(bgp
->flags
,
10898 BGP_FLAG_SHOW_HOSTNAME
))
10899 snprintf(neighbor_buf
,
10900 sizeof(neighbor_buf
),
10901 "%s%s(%s) ", dn_flag
,
10902 peer
->hostname
, peer
->host
);
10904 snprintf(neighbor_buf
,
10905 sizeof(neighbor_buf
), "%s%s ",
10906 dn_flag
, peer
->host
);
10908 len
= strlen(neighbor_buf
);
10910 if (len
> max_neighbor_width
)
10911 max_neighbor_width
= len
;
10913 /* See if we have at least a single failed peer */
10914 if (bgp_has_peer_failed(peer
, afi
, safi
))
10920 /* Originally we displayed the Neighbor column as 16
10921 * characters wide so make that the default
10923 if (max_neighbor_width
< neighbor_col_default_width
)
10924 max_neighbor_width
= neighbor_col_default_width
;
10927 if (show_failed
&& !failed_count
) {
10929 json_object_int_add(json
, "failedPeersCount", 0);
10930 json_object_int_add(json
, "dynamicPeers", dn_count
);
10931 json_object_int_add(json
, "totalPeers", count
);
10933 vty_json(vty
, json
);
10935 vty_out(vty
, "%% No failed BGP neighbors found\n");
10937 return CMD_SUCCESS
;
10940 count
= 0; /* Reset the value as its used again */
10941 filtered_count
= 0;
10943 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10944 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10947 if (!peer
->afc
[afi
][safi
])
10951 unsigned long ents
;
10952 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10955 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10957 : (int64_t)bgp
->vrf_id
;
10959 /* Usage summary and header */
10961 json_object_string_addf(json
, "routerId",
10964 json_object_int_add(json
, "as", bgp
->as
);
10965 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10966 json_object_string_add(
10969 == BGP_INSTANCE_TYPE_DEFAULT
)
10974 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10975 &bgp
->router_id
, bgp
->as
,
10976 bgp
->vrf_id
== VRF_UNKNOWN
10978 : (int)bgp
->vrf_id
);
10979 vty_out(vty
, "\n");
10982 if (bgp_update_delay_configured(bgp
)) {
10984 json_object_int_add(
10985 json
, "updateDelayLimit",
10986 bgp
->v_update_delay
);
10988 if (bgp
->v_update_delay
10989 != bgp
->v_establish_wait
)
10990 json_object_int_add(
10992 "updateDelayEstablishWait",
10993 bgp
->v_establish_wait
);
10995 if (bgp_update_delay_active(bgp
)) {
10996 json_object_string_add(
10998 "updateDelayFirstNeighbor",
10999 bgp
->update_delay_begin_time
);
11000 json_object_boolean_true_add(
11002 "updateDelayInProgress");
11004 if (bgp
->update_delay_over
) {
11005 json_object_string_add(
11007 "updateDelayFirstNeighbor",
11008 bgp
->update_delay_begin_time
);
11009 json_object_string_add(
11011 "updateDelayBestpathResumed",
11012 bgp
->update_delay_end_time
);
11013 json_object_string_add(
11015 "updateDelayZebraUpdateResume",
11016 bgp
->update_delay_zebra_resume_time
);
11017 json_object_string_add(
11019 "updateDelayPeerUpdateResume",
11020 bgp
->update_delay_peers_resume_time
);
11025 "Read-only mode update-delay limit: %d seconds\n",
11026 bgp
->v_update_delay
);
11027 if (bgp
->v_update_delay
11028 != bgp
->v_establish_wait
)
11030 " Establish wait: %d seconds\n",
11031 bgp
->v_establish_wait
);
11033 if (bgp_update_delay_active(bgp
)) {
11035 " First neighbor established: %s\n",
11036 bgp
->update_delay_begin_time
);
11038 " Delay in progress\n");
11040 if (bgp
->update_delay_over
) {
11042 " First neighbor established: %s\n",
11043 bgp
->update_delay_begin_time
);
11045 " Best-paths resumed: %s\n",
11046 bgp
->update_delay_end_time
);
11048 " zebra update resumed: %s\n",
11049 bgp
->update_delay_zebra_resume_time
);
11051 " peers update resumed: %s\n",
11052 bgp
->update_delay_peers_resume_time
);
11059 if (bgp_maxmed_onstartup_configured(bgp
)
11060 && bgp
->maxmed_active
)
11061 json_object_boolean_true_add(
11062 json
, "maxMedOnStartup");
11063 if (bgp
->v_maxmed_admin
)
11064 json_object_boolean_true_add(
11065 json
, "maxMedAdministrative");
11067 json_object_int_add(
11068 json
, "tableVersion",
11069 bgp_table_version(bgp
->rib
[afi
][safi
]));
11071 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11072 json_object_int_add(json
, "ribCount", ents
);
11073 json_object_int_add(
11075 ents
* sizeof(struct bgp_dest
));
11077 ents
= bgp
->af_peer_count
[afi
][safi
];
11078 json_object_int_add(json
, "peerCount", ents
);
11079 json_object_int_add(json
, "peerMemory",
11080 ents
* sizeof(struct peer
));
11082 if ((ents
= listcount(bgp
->group
))) {
11083 json_object_int_add(
11084 json
, "peerGroupCount", ents
);
11085 json_object_int_add(
11086 json
, "peerGroupMemory",
11087 ents
* sizeof(struct
11091 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11092 BGP_CONFIG_DAMPENING
))
11093 json_object_boolean_true_add(
11094 json
, "dampeningEnabled");
11097 if (bgp_maxmed_onstartup_configured(bgp
)
11098 && bgp
->maxmed_active
)
11100 "Max-med on-startup active\n");
11101 if (bgp
->v_maxmed_admin
)
11103 "Max-med administrative active\n");
11106 "BGP table version %" PRIu64
11109 bgp
->rib
[afi
][safi
]));
11111 ents
= bgp_table_count(
11112 bgp
->rib
[afi
][safi
]);
11114 "RIB entries %ld, using %s of memory\n",
11124 /* Peer related usage */
11125 ents
= bgp
->af_peer_count
[afi
][safi
];
11127 "Peers %ld, using %s of memory\n",
11137 if ((ents
= listcount(bgp
->group
)))
11139 "Peer groups %ld, using %s of memory\n",
11149 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11150 BGP_CONFIG_DAMPENING
))
11152 "Dampening enabled.\n");
11155 vty_out(vty
, "\n");
11157 /* Subtract 8 here because 'Neighbor' is
11159 vty_out(vty
, "Neighbor");
11160 vty_out(vty
, "%*s",
11161 max_neighbor_width
- 8, " ");
11163 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11168 paf
= peer_af_find(peer
, afi
, safi
);
11169 filter
= &peer
->filter
[afi
][safi
];
11172 /* Works for both failed & successful cases */
11173 if (peer_dynamic_neighbor(peer
))
11178 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11184 bgp_has_peer_failed(peer
, afi
, safi
)) {
11185 json_peer
= json_object_new_object();
11186 bgp_show_failed_summary(vty
, bgp
, peer
,
11187 json_peer
, 0, use_json
);
11188 } else if (!show_failed
) {
11189 if (show_established
11190 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11195 json_peer
= json_object_new_object();
11196 if (peer_dynamic_neighbor(peer
)) {
11197 json_object_boolean_true_add(json_peer
,
11201 if (peer
->hostname
)
11202 json_object_string_add(json_peer
, "hostname",
11205 if (peer
->domainname
)
11206 json_object_string_add(json_peer
, "domainname",
11209 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11210 json_object_int_add(
11211 json_peer
, "localAs",
11212 peer
->change_local_as
11213 ? peer
->change_local_as
11215 json_object_int_add(json_peer
, "version", 4);
11216 json_object_int_add(json_peer
, "msgRcvd",
11217 PEER_TOTAL_RX(peer
));
11218 json_object_int_add(json_peer
, "msgSent",
11219 PEER_TOTAL_TX(peer
));
11221 atomic_size_t outq_count
, inq_count
;
11222 outq_count
= atomic_load_explicit(
11223 &peer
->obuf
->count
,
11224 memory_order_relaxed
);
11225 inq_count
= atomic_load_explicit(
11226 &peer
->ibuf
->count
,
11227 memory_order_relaxed
);
11229 json_object_int_add(json_peer
, "tableVersion",
11230 peer
->version
[afi
][safi
]);
11231 json_object_int_add(json_peer
, "outq",
11233 json_object_int_add(json_peer
, "inq",
11235 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11236 use_json
, json_peer
);
11238 json_object_int_add(json_peer
, "pfxRcd",
11239 peer
->pcount
[afi
][pfx_rcd_safi
]);
11241 if (paf
&& PAF_SUBGRP(paf
))
11242 json_object_int_add(
11243 json_peer
, "pfxSnt",
11244 (PAF_SUBGRP(paf
))->scount
);
11246 json_object_int_add(json_peer
, "pfxSnt",
11249 /* BGP FSM state */
11250 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11251 || CHECK_FLAG(peer
->bgp
->flags
,
11252 BGP_FLAG_SHUTDOWN
))
11253 json_object_string_add(json_peer
,
11256 else if (peer
->afc_recv
[afi
][safi
])
11257 json_object_string_add(
11258 json_peer
, "state",
11259 lookup_msg(bgp_status_msg
,
11260 peer
->status
, NULL
));
11261 else if (CHECK_FLAG(
11263 PEER_STATUS_PREFIX_OVERFLOW
))
11264 json_object_string_add(json_peer
,
11268 json_object_string_add(
11269 json_peer
, "state",
11270 lookup_msg(bgp_status_msg
,
11271 peer
->status
, NULL
));
11273 /* BGP peer state */
11274 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11275 || CHECK_FLAG(peer
->bgp
->flags
,
11276 BGP_FLAG_SHUTDOWN
))
11277 json_object_string_add(json_peer
,
11280 else if (CHECK_FLAG(
11282 PEER_STATUS_PREFIX_OVERFLOW
))
11283 json_object_string_add(json_peer
,
11286 else if (CHECK_FLAG(peer
->flags
,
11287 PEER_FLAG_PASSIVE
))
11288 json_object_string_add(json_peer
,
11291 else if (CHECK_FLAG(peer
->sflags
,
11292 PEER_STATUS_NSF_WAIT
))
11293 json_object_string_add(json_peer
,
11296 else if (CHECK_FLAG(
11298 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11299 && (!bgp_inbound_policy_exists(peer
,
11301 || !bgp_outbound_policy_exists(
11303 json_object_string_add(json_peer
,
11307 json_object_string_add(
11308 json_peer
, "peerState", "OK");
11310 json_object_int_add(json_peer
, "connectionsEstablished",
11311 peer
->established
);
11312 json_object_int_add(json_peer
, "connectionsDropped",
11315 json_object_string_add(
11316 json_peer
, "desc", peer
->desc
);
11318 /* Avoid creating empty peer dicts in JSON */
11319 if (json_peer
== NULL
)
11323 json_object_string_add(json_peer
, "idType",
11325 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11326 json_object_string_add(json_peer
, "idType",
11328 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11329 json_object_string_add(json_peer
, "idType",
11331 json_object_object_add(json_peers
, peer
->host
,
11334 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11340 bgp_has_peer_failed(peer
, afi
, safi
)) {
11341 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11342 max_neighbor_width
,
11344 } else if (!show_failed
) {
11345 if (show_established
11346 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11351 if ((count
- filtered_count
) == 1) {
11352 /* display headline before the first
11354 vty_out(vty
, "\n");
11356 /* Subtract 8 here because 'Neighbor' is
11358 vty_out(vty
, "Neighbor");
11359 vty_out(vty
, "%*s",
11360 max_neighbor_width
- 8, " ");
11363 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11364 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11367 memset(dn_flag
, '\0', sizeof(dn_flag
));
11368 if (peer_dynamic_neighbor(peer
)) {
11373 && CHECK_FLAG(bgp
->flags
,
11374 BGP_FLAG_SHOW_HOSTNAME
))
11375 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11379 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11381 /* pad the neighbor column with spaces */
11382 if (len
< max_neighbor_width
)
11383 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11386 atomic_size_t outq_count
, inq_count
;
11387 outq_count
= atomic_load_explicit(
11388 &peer
->obuf
->count
,
11389 memory_order_relaxed
);
11390 inq_count
= atomic_load_explicit(
11391 &peer
->ibuf
->count
,
11392 memory_order_relaxed
);
11396 "4 %10u %10u %9u %9u %8" PRIu64
11399 peer
->change_local_as
11400 ? peer
->change_local_as
11402 PEER_TOTAL_RX(peer
),
11403 PEER_TOTAL_TX(peer
),
11404 peer
->version
[afi
][safi
],
11405 inq_count
, outq_count
,
11406 peer_uptime(peer
->uptime
,
11411 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11413 peer
->as
, PEER_TOTAL_RX(peer
),
11414 PEER_TOTAL_TX(peer
),
11415 peer
->version
[afi
][safi
],
11416 inq_count
, outq_count
,
11417 peer_uptime(peer
->uptime
,
11422 if (peer_established(peer
)) {
11423 if (peer
->afc_recv
[afi
][safi
]) {
11426 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11427 && !bgp_inbound_policy_exists(
11429 vty_out(vty
, " %12s",
11438 vty_out(vty
, " NoNeg");
11441 if (paf
&& PAF_SUBGRP(paf
)) {
11444 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11445 && !bgp_outbound_policy_exists(
11447 vty_out(vty
, " %8s",
11456 vty_out(vty
, " NoNeg");
11459 if (CHECK_FLAG(peer
->flags
,
11460 PEER_FLAG_SHUTDOWN
)
11461 || CHECK_FLAG(peer
->bgp
->flags
,
11462 BGP_FLAG_SHUTDOWN
))
11463 vty_out(vty
, " Idle (Admin)");
11464 else if (CHECK_FLAG(
11466 PEER_STATUS_PREFIX_OVERFLOW
))
11467 vty_out(vty
, " Idle (PfxCt)");
11469 vty_out(vty
, " %12s",
11470 lookup_msg(bgp_status_msg
,
11471 peer
->status
, NULL
));
11473 vty_out(vty
, " %8u", 0);
11475 /* Make sure `Desc` column is the lastest in
11479 vty_out(vty
, " %s",
11480 bgp_peer_description_stripped(
11482 show_wide
? 64 : 20));
11484 vty_out(vty
, " N/A");
11485 vty_out(vty
, "\n");
11492 json_object_object_add(json
, "peers", json_peers
);
11493 json_object_int_add(json
, "failedPeers", failed_count
);
11494 json_object_int_add(json
, "displayedPeers",
11495 count
- filtered_count
);
11496 json_object_int_add(json
, "totalPeers", count
);
11497 json_object_int_add(json
, "dynamicPeers", dn_count
);
11500 bgp_show_bestpath_json(bgp
, json
);
11502 vty_json(vty
, json
);
11505 if (filtered_count
== count
)
11506 vty_out(vty
, "\n%% No matching neighbor\n");
11509 vty_out(vty
, "\nDisplayed neighbors %d",
11511 else if (as_type
!= AS_UNSPECIFIED
|| as
11512 || fpeer
|| show_established
)
11513 vty_out(vty
, "\nDisplayed neighbors %d",
11514 count
- filtered_count
);
11516 vty_out(vty
, "\nTotal number of neighbors %d\n",
11520 vty_out(vty
, "No %s neighbor is configured\n",
11521 get_afi_safi_str(afi
, safi
, false));
11525 vty_out(vty
, "* - dynamic neighbor\n");
11526 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11527 dn_count
, bgp
->dynamic_neighbors_limit
);
11531 return CMD_SUCCESS
;
11534 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11535 int safi
, struct peer
*fpeer
, int as_type
,
11536 as_t as
, uint16_t show_flags
)
11539 int afi_wildcard
= (afi
== AFI_MAX
);
11540 int safi_wildcard
= (safi
== SAFI_MAX
);
11541 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11542 bool nbr_output
= false;
11543 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11545 if (use_json
&& is_wildcard
)
11546 vty_out(vty
, "{\n");
11548 afi
= 1; /* AFI_IP */
11549 while (afi
< AFI_MAX
) {
11551 safi
= 1; /* SAFI_UNICAST */
11552 while (safi
< SAFI_MAX
) {
11553 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11558 * So limit output to those afi/safi
11560 * actualy have something interesting in
11565 vty_out(vty
, ",\n");
11569 vty_out(vty
, "\"%s\":",
11570 get_afi_safi_str(afi
,
11575 "\n%s Summary (%s):\n",
11576 get_afi_safi_str(afi
,
11582 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11583 as_type
, as
, show_flags
);
11586 if (!safi_wildcard
)
11594 if (use_json
&& is_wildcard
)
11595 vty_out(vty
, "}\n");
11596 else if (!nbr_output
) {
11598 vty_out(vty
, "{}\n");
11600 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11605 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11607 const char *neighbor
,
11608 int as_type
, as_t as
,
11609 uint16_t show_flags
)
11611 struct listnode
*node
, *nnode
;
11613 struct peer
*fpeer
= NULL
;
11615 bool nbr_output
= false;
11616 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11619 vty_out(vty
, "{\n");
11621 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11625 vty_out(vty
, ",\n");
11629 vty_out(vty
, "\"%s\":",
11630 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11635 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11640 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11645 vty_out(vty
, "}\n");
11646 else if (!nbr_output
)
11647 vty_out(vty
, "%% BGP instance not found\n");
11650 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11651 safi_t safi
, const char *neighbor
, int as_type
,
11652 as_t as
, uint16_t show_flags
)
11655 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11656 struct peer
*fpeer
= NULL
;
11659 if (strmatch(name
, "all")) {
11660 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11663 return CMD_SUCCESS
;
11665 bgp
= bgp_lookup_by_name(name
);
11669 vty_out(vty
, "{}\n");
11672 "%% BGP instance not found\n");
11673 return CMD_WARNING
;
11677 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11680 return CMD_WARNING
;
11682 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11683 as_type
, as
, show_flags
);
11684 return CMD_SUCCESS
;
11688 bgp
= bgp_get_default();
11692 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11695 return CMD_WARNING
;
11697 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11701 vty_out(vty
, "{}\n");
11703 vty_out(vty
, "%% BGP instance not found\n");
11704 return CMD_WARNING
;
11707 return CMD_SUCCESS
;
11710 /* `show [ip] bgp summary' commands. */
11711 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11712 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11713 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11714 "]] [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]",
11715 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11716 BGP_SAFI_WITH_LABEL_HELP_STR
11717 "Display the entries for all address families\n"
11718 "Summary of BGP neighbor status\n"
11719 "Show only sessions in Established state\n"
11720 "Show only sessions not in Established state\n"
11721 "Show only the specified neighbor session\n"
11722 "Neighbor to display information about\n"
11723 "Neighbor to display information about\n"
11724 "Neighbor on BGP configured interface\n"
11725 "Show only the specified remote AS sessions\n"
11727 "Internal (iBGP) AS sessions\n"
11728 "External (eBGP) AS sessions\n"
11729 "Shorten the information on BGP instances\n"
11730 "Increase table width for longer output\n" JSON_STR
)
11733 afi_t afi
= AFI_MAX
;
11734 safi_t safi
= SAFI_MAX
;
11735 as_t as
= 0; /* 0 means AS filter not set */
11736 int as_type
= AS_UNSPECIFIED
;
11737 uint16_t show_flags
= 0;
11741 /* show [ip] bgp */
11742 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11744 /* [<vrf> VIEWVRFNAME] */
11745 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11746 vrf
= argv
[idx
+ 1]->arg
;
11747 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11749 } else if (argv_find(argv
, argc
, "view", &idx
))
11750 /* [<view> VIEWVRFNAME] */
11751 vrf
= argv
[idx
+ 1]->arg
;
11752 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11753 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11754 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11757 if (argv_find(argv
, argc
, "failed", &idx
))
11758 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11760 if (argv_find(argv
, argc
, "established", &idx
))
11761 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11763 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11764 if (argv
[idx
+ 1]->arg
[0] == 'i')
11765 as_type
= AS_INTERNAL
;
11766 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11767 as_type
= AS_EXTERNAL
;
11769 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11772 if (argv_find(argv
, argc
, "terse", &idx
))
11773 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11775 if (argv_find(argv
, argc
, "wide", &idx
))
11776 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11778 if (argv_find(argv
, argc
, "json", &idx
))
11779 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11781 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11785 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11788 return get_afi_safi_json_str(afi
, safi
);
11790 return get_afi_safi_vty_str(afi
, safi
);
11794 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11795 afi_t afi
, safi_t safi
,
11796 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11797 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11798 bool use_json
, json_object
*json_pref
)
11801 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11802 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11804 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11805 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11806 json_object_string_add(json_pref
, "sendMode",
11807 "advertisedAndReceived");
11808 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11809 json_object_string_add(json_pref
, "sendMode",
11811 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11812 json_object_string_add(json_pref
, "sendMode",
11815 vty_out(vty
, " Send-mode: ");
11816 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11817 vty_out(vty
, "advertised");
11818 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11819 vty_out(vty
, "%sreceived",
11820 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11824 vty_out(vty
, "\n");
11829 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11830 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11832 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11833 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11834 json_object_string_add(json_pref
, "recvMode",
11835 "advertisedAndReceived");
11836 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11837 json_object_string_add(json_pref
, "recvMode",
11839 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11840 json_object_string_add(json_pref
, "recvMode",
11843 vty_out(vty
, " Receive-mode: ");
11844 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11845 vty_out(vty
, "advertised");
11846 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11847 vty_out(vty
, "%sreceived",
11848 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11852 vty_out(vty
, "\n");
11857 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11865 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11866 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11867 && (peer_established(p
))) {
11868 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11869 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11873 json_object_boolean_add(json
, "rBit", rbit
);
11874 json_object_boolean_add(json
, "nBit", nbit
);
11876 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11877 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11881 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11886 const char *mode
= "NotApplicable";
11889 vty_out(vty
, "\n Remote GR Mode: ");
11891 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11892 && (peer_established(peer
))) {
11894 if ((peer
->nsf_af_count
== 0)
11895 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11899 } else if (peer
->nsf_af_count
== 0
11900 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11904 } else if (peer
->nsf_af_count
!= 0
11905 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11912 json_object_string_add(json
, "remoteGrMode", mode
);
11914 vty_out(vty
, mode
, "\n");
11917 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11922 const char *mode
= "Invalid";
11925 vty_out(vty
, " Local GR Mode: ");
11927 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11929 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11931 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11933 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11934 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11936 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11938 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11945 json_object_string_add(json
, "localGrMode", mode
);
11947 vty_out(vty
, mode
, "\n");
11951 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11952 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11956 json_object
*json_afi_safi
= NULL
;
11957 json_object
*json_timer
= NULL
;
11958 json_object
*json_endofrib_status
= NULL
;
11959 bool eor_flag
= false;
11961 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11962 if (!peer
->afc
[afi
][safi
])
11965 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11966 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11970 json_afi_safi
= json_object_new_object();
11971 json_endofrib_status
= json_object_new_object();
11972 json_timer
= json_object_new_object();
11975 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11981 vty_out(vty
, " %s:\n",
11982 get_afi_safi_str(afi
, safi
, false));
11984 vty_out(vty
, " F bit: ");
11987 if (peer
->nsf
[afi
][safi
] &&
11988 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11989 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11992 json_object_boolean_true_add(json_afi_safi
,
11995 vty_out(vty
, "True\n");
11998 json_object_boolean_false_add(json_afi_safi
,
12001 vty_out(vty
, "False\n");
12005 vty_out(vty
, " End-of-RIB sent: ");
12007 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12008 PEER_STATUS_EOR_SEND
)) {
12010 json_object_boolean_true_add(
12011 json_endofrib_status
, "endOfRibSend");
12013 PRINT_EOR_JSON(eor_flag
);
12015 vty_out(vty
, "Yes\n");
12017 " End-of-RIB sent after update: ");
12019 PRINT_EOR(eor_flag
);
12023 json_object_boolean_false_add(
12024 json_endofrib_status
, "endOfRibSend");
12025 json_object_boolean_false_add(
12026 json_endofrib_status
,
12027 "endOfRibSentAfterUpdate");
12029 vty_out(vty
, "No\n");
12031 " End-of-RIB sent after update: ");
12032 vty_out(vty
, "No\n");
12037 vty_out(vty
, " End-of-RIB received: ");
12039 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12040 PEER_STATUS_EOR_RECEIVED
)) {
12042 json_object_boolean_true_add(
12043 json_endofrib_status
, "endOfRibRecv");
12045 vty_out(vty
, "Yes\n");
12048 json_object_boolean_false_add(
12049 json_endofrib_status
, "endOfRibRecv");
12051 vty_out(vty
, "No\n");
12055 json_object_int_add(json_timer
, "stalePathTimer",
12056 peer
->bgp
->stalepath_time
);
12058 if (peer
->t_gr_stale
!= NULL
) {
12059 json_object_int_add(json_timer
,
12060 "stalePathTimerRemaining",
12061 thread_timer_remain_second(
12062 peer
->t_gr_stale
));
12065 /* Display Configured Selection
12066 * Deferral only when when
12067 * Gr mode is enabled.
12069 if (CHECK_FLAG(peer
->flags
,
12070 PEER_FLAG_GRACEFUL_RESTART
)) {
12071 json_object_int_add(json_timer
,
12072 "selectionDeferralTimer",
12073 peer
->bgp
->stalepath_time
);
12076 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12079 json_object_int_add(
12081 "selectionDeferralTimerRemaining",
12082 thread_timer_remain_second(
12083 peer
->bgp
->gr_info
[afi
][safi
]
12084 .t_select_deferral
));
12087 vty_out(vty
, " Timers:\n");
12089 " Configured Stale Path Time(sec): %u\n",
12090 peer
->bgp
->stalepath_time
);
12092 if (peer
->t_gr_stale
!= NULL
)
12094 " Stale Path Remaining(sec): %ld\n",
12095 thread_timer_remain_second(
12096 peer
->t_gr_stale
));
12097 /* Display Configured Selection
12098 * Deferral only when when
12099 * Gr mode is enabled.
12101 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12103 " Configured Selection Deferral Time(sec): %u\n",
12104 peer
->bgp
->select_defer_time
);
12106 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12109 " Selection Deferral Time Remaining(sec): %ld\n",
12110 thread_timer_remain_second(
12111 peer
->bgp
->gr_info
[afi
][safi
]
12112 .t_select_deferral
));
12115 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12116 json_endofrib_status
);
12117 json_object_object_add(json_afi_safi
, "timers",
12119 json_object_object_add(
12120 json
, get_afi_safi_str(afi
, safi
, true),
12126 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12132 json_object
*json_timer
= NULL
;
12134 json_timer
= json_object_new_object();
12136 json_object_int_add(json_timer
, "configuredRestartTimer",
12137 p
->bgp
->restart_time
);
12139 json_object_int_add(json_timer
, "receivedRestartTimer",
12142 if (p
->t_gr_restart
!= NULL
)
12143 json_object_int_add(
12144 json_timer
, "restartTimerRemaining",
12145 thread_timer_remain_second(p
->t_gr_restart
));
12147 json_object_object_add(json
, "timers", json_timer
);
12150 vty_out(vty
, " Timers:\n");
12151 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12152 p
->bgp
->restart_time
);
12154 vty_out(vty
, " Received Restart Time(sec): %u\n",
12156 if (p
->t_gr_restart
!= NULL
)
12157 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12158 thread_timer_remain_second(p
->t_gr_restart
));
12159 if (p
->t_gr_restart
!= NULL
) {
12160 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12161 thread_timer_remain_second(p
->t_gr_restart
));
12166 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12167 bool use_json
, json_object
*json
)
12169 char dn_flag
[2] = {0};
12170 /* '*' + v6 address of neighbor */
12171 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12173 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12178 json_object_string_addf(json
, "neighborAddr", "%pSU",
12181 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12184 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12188 json_object_string_add(json
, "neighborAddr",
12191 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12194 /* more gr info in new format */
12195 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12198 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12199 safi_t safi
, bool use_json
,
12200 json_object
*json_neigh
)
12202 struct bgp_filter
*filter
;
12203 struct peer_af
*paf
;
12204 char orf_pfx_name
[BUFSIZ
];
12206 json_object
*json_af
= NULL
;
12207 json_object
*json_prefA
= NULL
;
12208 json_object
*json_prefB
= NULL
;
12209 json_object
*json_addr
= NULL
;
12210 json_object
*json_advmap
= NULL
;
12213 json_addr
= json_object_new_object();
12214 json_af
= json_object_new_object();
12215 filter
= &p
->filter
[afi
][safi
];
12217 if (peer_group_active(p
))
12218 json_object_string_add(json_addr
, "peerGroupMember",
12221 paf
= peer_af_find(p
, afi
, safi
);
12222 if (paf
&& PAF_SUBGRP(paf
)) {
12223 json_object_int_add(json_addr
, "updateGroupId",
12224 PAF_UPDGRP(paf
)->id
);
12225 json_object_int_add(json_addr
, "subGroupId",
12226 PAF_SUBGRP(paf
)->id
);
12227 json_object_int_add(json_addr
, "packetQueueLength",
12228 bpacket_queue_virtual_length(paf
));
12231 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12232 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12233 PEER_CAP_ORF_PREFIX_SM_RCV
)
12234 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12235 PEER_CAP_ORF_PREFIX_RM_ADV
)
12236 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12237 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12238 json_object_int_add(json_af
, "orfType",
12240 json_prefA
= json_object_new_object();
12241 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12242 PEER_CAP_ORF_PREFIX_SM_ADV
,
12243 PEER_CAP_ORF_PREFIX_RM_ADV
,
12244 PEER_CAP_ORF_PREFIX_SM_RCV
,
12245 PEER_CAP_ORF_PREFIX_RM_RCV
,
12246 use_json
, json_prefA
);
12247 json_object_object_add(json_af
, "orfPrefixList",
12251 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12252 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12253 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12254 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12255 PEER_CAP_ORF_PREFIX_RM_ADV
)
12256 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12257 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12258 json_object_int_add(json_af
, "orfOldType",
12259 ORF_TYPE_PREFIX_OLD
);
12260 json_prefB
= json_object_new_object();
12261 bgp_show_peer_afi_orf_cap(
12262 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12263 PEER_CAP_ORF_PREFIX_RM_ADV
,
12264 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12265 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12267 json_object_object_add(json_af
, "orfOldPrefixList",
12271 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12272 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12273 PEER_CAP_ORF_PREFIX_SM_RCV
)
12274 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12275 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12276 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12277 PEER_CAP_ORF_PREFIX_RM_ADV
)
12278 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12279 PEER_CAP_ORF_PREFIX_RM_RCV
)
12280 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12281 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12282 json_object_object_add(json_addr
, "afDependentCap",
12285 json_object_free(json_af
);
12287 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12288 p
->host
, afi
, safi
);
12289 orf_pfx_count
= prefix_bgp_show_prefix_list(
12290 NULL
, afi
, orf_pfx_name
, use_json
);
12292 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12293 PEER_STATUS_ORF_PREFIX_SEND
)
12294 || orf_pfx_count
) {
12295 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12296 PEER_STATUS_ORF_PREFIX_SEND
))
12297 json_object_boolean_true_add(json_neigh
,
12300 json_object_int_add(json_addr
, "orfRecvCounter",
12303 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12304 PEER_STATUS_ORF_WAIT_REFRESH
))
12305 json_object_string_add(
12306 json_addr
, "orfFirstUpdate",
12307 "deferredUntilORFOrRouteRefreshRecvd");
12309 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12310 PEER_FLAG_REFLECTOR_CLIENT
))
12311 json_object_boolean_true_add(json_addr
,
12312 "routeReflectorClient");
12313 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12314 PEER_FLAG_RSERVER_CLIENT
))
12315 json_object_boolean_true_add(json_addr
,
12316 "routeServerClient");
12317 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12318 json_object_boolean_true_add(json_addr
,
12319 "inboundSoftConfigPermit");
12321 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12322 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12323 json_object_boolean_true_add(
12325 "privateAsNumsAllReplacedInUpdatesToNbr");
12326 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12327 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12328 json_object_boolean_true_add(
12330 "privateAsNumsReplacedInUpdatesToNbr");
12331 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12332 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12333 json_object_boolean_true_add(
12335 "privateAsNumsAllRemovedInUpdatesToNbr");
12336 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12337 PEER_FLAG_REMOVE_PRIVATE_AS
))
12338 json_object_boolean_true_add(
12340 "privateAsNumsRemovedInUpdatesToNbr");
12342 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12343 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12344 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12345 json_object_boolean_true_add(json_addr
,
12346 "allowAsInOrigin");
12348 json_object_int_add(json_addr
, "allowAsInCount",
12349 p
->allowas_in
[afi
][safi
]);
12352 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12353 json_object_boolean_true_add(
12355 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12358 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12359 json_object_string_add(json_addr
,
12360 "overrideASNsInOutboundUpdates",
12361 "ifAspathEqualRemoteAs");
12363 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12364 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12365 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12366 json_object_boolean_true_add(json_addr
,
12367 "routerAlwaysNextHop");
12368 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12369 PEER_FLAG_AS_PATH_UNCHANGED
))
12370 json_object_boolean_true_add(
12371 json_addr
, "unchangedAsPathPropogatedToNbr");
12372 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12373 PEER_FLAG_NEXTHOP_UNCHANGED
))
12374 json_object_boolean_true_add(
12375 json_addr
, "unchangedNextHopPropogatedToNbr");
12376 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12377 json_object_boolean_true_add(
12378 json_addr
, "unchangedMedPropogatedToNbr");
12379 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12380 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12381 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12382 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12383 PEER_FLAG_SEND_COMMUNITY
)
12384 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12385 PEER_FLAG_SEND_EXT_COMMUNITY
))
12386 json_object_string_add(json_addr
,
12387 "commAttriSentToNbr",
12388 "extendedAndStandard");
12389 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12390 PEER_FLAG_SEND_EXT_COMMUNITY
))
12391 json_object_string_add(json_addr
,
12392 "commAttriSentToNbr",
12395 json_object_string_add(json_addr
,
12396 "commAttriSentToNbr",
12399 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12400 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12401 if (p
->default_rmap
[afi
][safi
].name
)
12402 json_object_string_add(
12403 json_addr
, "defaultRouteMap",
12404 p
->default_rmap
[afi
][safi
].name
);
12406 if (paf
&& PAF_SUBGRP(paf
)
12407 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12408 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12409 json_object_boolean_true_add(json_addr
,
12412 json_object_boolean_true_add(json_addr
,
12416 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12417 if (is_evpn_enabled())
12418 json_object_boolean_true_add(
12419 json_addr
, "advertiseAllVnis");
12422 if (filter
->plist
[FILTER_IN
].name
12423 || filter
->dlist
[FILTER_IN
].name
12424 || filter
->aslist
[FILTER_IN
].name
12425 || filter
->map
[RMAP_IN
].name
)
12426 json_object_boolean_true_add(json_addr
,
12427 "inboundPathPolicyConfig");
12428 if (filter
->plist
[FILTER_OUT
].name
12429 || filter
->dlist
[FILTER_OUT
].name
12430 || filter
->aslist
[FILTER_OUT
].name
12431 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12432 json_object_boolean_true_add(
12433 json_addr
, "outboundPathPolicyConfig");
12436 if (filter
->plist
[FILTER_IN
].name
)
12437 json_object_string_add(json_addr
,
12438 "incomingUpdatePrefixFilterList",
12439 filter
->plist
[FILTER_IN
].name
);
12440 if (filter
->plist
[FILTER_OUT
].name
)
12441 json_object_string_add(json_addr
,
12442 "outgoingUpdatePrefixFilterList",
12443 filter
->plist
[FILTER_OUT
].name
);
12445 /* distribute-list */
12446 if (filter
->dlist
[FILTER_IN
].name
)
12447 json_object_string_add(
12448 json_addr
, "incomingUpdateNetworkFilterList",
12449 filter
->dlist
[FILTER_IN
].name
);
12450 if (filter
->dlist
[FILTER_OUT
].name
)
12451 json_object_string_add(
12452 json_addr
, "outgoingUpdateNetworkFilterList",
12453 filter
->dlist
[FILTER_OUT
].name
);
12456 if (filter
->aslist
[FILTER_IN
].name
)
12457 json_object_string_add(json_addr
,
12458 "incomingUpdateAsPathFilterList",
12459 filter
->aslist
[FILTER_IN
].name
);
12460 if (filter
->aslist
[FILTER_OUT
].name
)
12461 json_object_string_add(json_addr
,
12462 "outgoingUpdateAsPathFilterList",
12463 filter
->aslist
[FILTER_OUT
].name
);
12466 if (filter
->map
[RMAP_IN
].name
)
12467 json_object_string_add(
12468 json_addr
, "routeMapForIncomingAdvertisements",
12469 filter
->map
[RMAP_IN
].name
);
12470 if (filter
->map
[RMAP_OUT
].name
)
12471 json_object_string_add(
12472 json_addr
, "routeMapForOutgoingAdvertisements",
12473 filter
->map
[RMAP_OUT
].name
);
12475 /* ebgp-requires-policy (inbound) */
12476 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12477 && !bgp_inbound_policy_exists(p
, filter
))
12478 json_object_string_add(
12479 json_addr
, "inboundEbgpRequiresPolicy",
12480 "Inbound updates discarded due to missing policy");
12482 /* ebgp-requires-policy (outbound) */
12483 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12484 && (!bgp_outbound_policy_exists(p
, filter
)))
12485 json_object_string_add(
12486 json_addr
, "outboundEbgpRequiresPolicy",
12487 "Outbound updates discarded due to missing policy");
12489 /* unsuppress-map */
12490 if (filter
->usmap
.name
)
12491 json_object_string_add(json_addr
,
12492 "selectiveUnsuppressRouteMap",
12493 filter
->usmap
.name
);
12495 /* advertise-map */
12496 if (filter
->advmap
.aname
) {
12497 json_advmap
= json_object_new_object();
12498 json_object_string_add(json_advmap
, "condition",
12499 filter
->advmap
.condition
12502 json_object_string_add(json_advmap
, "conditionMap",
12503 filter
->advmap
.cname
);
12504 json_object_string_add(json_advmap
, "advertiseMap",
12505 filter
->advmap
.aname
);
12506 json_object_string_add(
12507 json_advmap
, "advertiseStatus",
12508 filter
->advmap
.update_type
==
12509 UPDATE_TYPE_ADVERTISE
12512 json_object_object_add(json_addr
, "advertiseMap",
12516 /* Receive prefix count */
12517 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12518 p
->pcount
[afi
][safi
]);
12519 if (paf
&& PAF_SUBGRP(paf
))
12520 json_object_int_add(json_addr
, "sentPrefixCounter",
12521 (PAF_SUBGRP(paf
))->scount
);
12523 /* Maximum prefix */
12524 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12525 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12526 p
->pmax_out
[afi
][safi
]);
12528 /* Maximum prefix */
12529 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12530 json_object_int_add(json_addr
, "prefixAllowedMax",
12531 p
->pmax
[afi
][safi
]);
12532 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12533 PEER_FLAG_MAX_PREFIX_WARNING
))
12534 json_object_boolean_true_add(
12535 json_addr
, "prefixAllowedMaxWarning");
12536 json_object_int_add(json_addr
,
12537 "prefixAllowedWarningThresh",
12538 p
->pmax_threshold
[afi
][safi
]);
12539 if (p
->pmax_restart
[afi
][safi
])
12540 json_object_int_add(
12542 "prefixAllowedRestartIntervalMsecs",
12543 p
->pmax_restart
[afi
][safi
] * 60000);
12545 json_object_object_add(json_neigh
,
12546 get_afi_safi_str(afi
, safi
, true),
12550 filter
= &p
->filter
[afi
][safi
];
12552 vty_out(vty
, " For address family: %s\n",
12553 get_afi_safi_str(afi
, safi
, false));
12555 if (peer_group_active(p
))
12556 vty_out(vty
, " %s peer-group member\n",
12559 paf
= peer_af_find(p
, afi
, safi
);
12560 if (paf
&& PAF_SUBGRP(paf
)) {
12561 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12562 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12563 vty_out(vty
, " Packet Queue length %d\n",
12564 bpacket_queue_virtual_length(paf
));
12566 vty_out(vty
, " Not part of any update group\n");
12568 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12569 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12570 PEER_CAP_ORF_PREFIX_SM_RCV
)
12571 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12572 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12573 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12574 PEER_CAP_ORF_PREFIX_RM_ADV
)
12575 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12576 PEER_CAP_ORF_PREFIX_RM_RCV
)
12577 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12578 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12579 vty_out(vty
, " AF-dependant capabilities:\n");
12581 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12582 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12583 PEER_CAP_ORF_PREFIX_SM_RCV
)
12584 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12585 PEER_CAP_ORF_PREFIX_RM_ADV
)
12586 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12587 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12589 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12591 bgp_show_peer_afi_orf_cap(
12592 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12593 PEER_CAP_ORF_PREFIX_RM_ADV
,
12594 PEER_CAP_ORF_PREFIX_SM_RCV
,
12595 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12597 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12598 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12599 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12600 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12601 PEER_CAP_ORF_PREFIX_RM_ADV
)
12602 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12603 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12605 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12606 ORF_TYPE_PREFIX_OLD
);
12607 bgp_show_peer_afi_orf_cap(
12608 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12609 PEER_CAP_ORF_PREFIX_RM_ADV
,
12610 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12611 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12614 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12615 p
->host
, afi
, safi
);
12616 orf_pfx_count
= prefix_bgp_show_prefix_list(
12617 NULL
, afi
, orf_pfx_name
, use_json
);
12619 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12620 PEER_STATUS_ORF_PREFIX_SEND
)
12621 || orf_pfx_count
) {
12622 vty_out(vty
, " Outbound Route Filter (ORF):");
12623 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12624 PEER_STATUS_ORF_PREFIX_SEND
))
12625 vty_out(vty
, " sent;");
12627 vty_out(vty
, " received (%d entries)",
12629 vty_out(vty
, "\n");
12631 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12632 PEER_STATUS_ORF_WAIT_REFRESH
))
12634 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12636 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12637 PEER_FLAG_REFLECTOR_CLIENT
))
12638 vty_out(vty
, " Route-Reflector Client\n");
12639 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12640 PEER_FLAG_RSERVER_CLIENT
))
12641 vty_out(vty
, " Route-Server Client\n");
12643 if (peer_af_flag_check(p
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
12644 vty_out(vty
, " ORR group (configured) : %s\n",
12645 p
->orr_group_name
[afi
][safi
]);
12647 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12649 " Inbound soft reconfiguration allowed\n");
12651 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12652 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12654 " Private AS numbers (all) replaced in updates to this neighbor\n");
12655 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12656 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12658 " Private AS numbers replaced in updates to this neighbor\n");
12659 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12660 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12662 " Private AS numbers (all) removed in updates to this neighbor\n");
12663 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12664 PEER_FLAG_REMOVE_PRIVATE_AS
))
12666 " Private AS numbers removed in updates to this neighbor\n");
12668 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12669 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12670 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12672 " Local AS allowed as path origin\n");
12675 " Local AS allowed in path, %d occurrences\n",
12676 p
->allowas_in
[afi
][safi
]);
12679 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12680 vty_out(vty
, " %s\n",
12681 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12682 ->human_description
);
12684 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12686 " Override ASNs in outbound updates if aspath equals remote-as\n");
12688 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12689 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12690 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12691 vty_out(vty
, " NEXT_HOP is always this router\n");
12692 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12693 PEER_FLAG_AS_PATH_UNCHANGED
))
12695 " AS_PATH is propagated unchanged to this neighbor\n");
12696 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12697 PEER_FLAG_NEXTHOP_UNCHANGED
))
12699 " NEXT_HOP is propagated unchanged to this neighbor\n");
12700 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12702 " MED is propagated unchanged to this neighbor\n");
12703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12704 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12705 PEER_FLAG_SEND_EXT_COMMUNITY
)
12706 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12707 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12709 " Community attribute sent to this neighbor");
12710 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12711 PEER_FLAG_SEND_COMMUNITY
)
12712 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12713 PEER_FLAG_SEND_EXT_COMMUNITY
)
12714 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12715 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12716 vty_out(vty
, "(all)\n");
12717 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12718 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12719 vty_out(vty
, "(large)\n");
12720 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12721 PEER_FLAG_SEND_EXT_COMMUNITY
))
12722 vty_out(vty
, "(extended)\n");
12724 vty_out(vty
, "(standard)\n");
12726 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12727 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12728 vty_out(vty
, " Default information originate,");
12730 if (p
->default_rmap
[afi
][safi
].name
)
12731 vty_out(vty
, " default route-map %s%s,",
12732 p
->default_rmap
[afi
][safi
].map
? "*"
12734 p
->default_rmap
[afi
][safi
].name
);
12735 if (paf
&& PAF_SUBGRP(paf
)
12736 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12737 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12738 vty_out(vty
, " default sent\n");
12740 vty_out(vty
, " default not sent\n");
12743 /* advertise-vni-all */
12744 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12745 if (is_evpn_enabled())
12746 vty_out(vty
, " advertise-all-vni\n");
12749 if (filter
->plist
[FILTER_IN
].name
12750 || filter
->dlist
[FILTER_IN
].name
12751 || filter
->aslist
[FILTER_IN
].name
12752 || filter
->map
[RMAP_IN
].name
)
12753 vty_out(vty
, " Inbound path policy configured\n");
12754 if (filter
->plist
[FILTER_OUT
].name
12755 || filter
->dlist
[FILTER_OUT
].name
12756 || filter
->aslist
[FILTER_OUT
].name
12757 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12758 vty_out(vty
, " Outbound path policy configured\n");
12761 if (filter
->plist
[FILTER_IN
].name
)
12763 " Incoming update prefix filter list is %s%s\n",
12764 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12765 filter
->plist
[FILTER_IN
].name
);
12766 if (filter
->plist
[FILTER_OUT
].name
)
12768 " Outgoing update prefix filter list is %s%s\n",
12769 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12770 filter
->plist
[FILTER_OUT
].name
);
12772 /* distribute-list */
12773 if (filter
->dlist
[FILTER_IN
].name
)
12775 " Incoming update network filter list is %s%s\n",
12776 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12777 filter
->dlist
[FILTER_IN
].name
);
12778 if (filter
->dlist
[FILTER_OUT
].name
)
12780 " Outgoing update network filter list is %s%s\n",
12781 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12782 filter
->dlist
[FILTER_OUT
].name
);
12785 if (filter
->aslist
[FILTER_IN
].name
)
12787 " Incoming update AS path filter list is %s%s\n",
12788 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12789 filter
->aslist
[FILTER_IN
].name
);
12790 if (filter
->aslist
[FILTER_OUT
].name
)
12792 " Outgoing update AS path filter list is %s%s\n",
12793 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12794 filter
->aslist
[FILTER_OUT
].name
);
12797 if (filter
->map
[RMAP_IN
].name
)
12799 " Route map for incoming advertisements is %s%s\n",
12800 filter
->map
[RMAP_IN
].map
? "*" : "",
12801 filter
->map
[RMAP_IN
].name
);
12802 if (filter
->map
[RMAP_OUT
].name
)
12804 " Route map for outgoing advertisements is %s%s\n",
12805 filter
->map
[RMAP_OUT
].map
? "*" : "",
12806 filter
->map
[RMAP_OUT
].name
);
12808 /* ebgp-requires-policy (inbound) */
12809 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12810 && !bgp_inbound_policy_exists(p
, filter
))
12812 " Inbound updates discarded due to missing policy\n");
12814 /* ebgp-requires-policy (outbound) */
12815 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12816 && !bgp_outbound_policy_exists(p
, filter
))
12818 " Outbound updates discarded due to missing policy\n");
12820 /* unsuppress-map */
12821 if (filter
->usmap
.name
)
12823 " Route map for selective unsuppress is %s%s\n",
12824 filter
->usmap
.map
? "*" : "",
12825 filter
->usmap
.name
);
12827 /* advertise-map */
12828 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12830 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12831 filter
->advmap
.condition
? "EXIST"
12833 filter
->advmap
.cmap
? "*" : "",
12834 filter
->advmap
.cname
,
12835 filter
->advmap
.amap
? "*" : "",
12836 filter
->advmap
.aname
,
12837 filter
->advmap
.update_type
==
12838 UPDATE_TYPE_ADVERTISE
12842 /* Receive prefix count */
12843 vty_out(vty
, " %u accepted prefixes\n",
12844 p
->pcount
[afi
][safi
]);
12846 /* maximum-prefix-out */
12847 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12848 PEER_FLAG_MAX_PREFIX_OUT
))
12850 " Maximum allowed prefixes sent %u\n",
12851 p
->pmax_out
[afi
][safi
]);
12853 /* Maximum prefix */
12854 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12856 " Maximum prefixes allowed %u%s\n",
12857 p
->pmax
[afi
][safi
],
12858 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12859 PEER_FLAG_MAX_PREFIX_WARNING
)
12860 ? " (warning-only)"
12862 vty_out(vty
, " Threshold for warning message %d%%",
12863 p
->pmax_threshold
[afi
][safi
]);
12864 if (p
->pmax_restart
[afi
][safi
])
12865 vty_out(vty
, ", restart interval %d min",
12866 p
->pmax_restart
[afi
][safi
]);
12867 vty_out(vty
, "\n");
12870 vty_out(vty
, "\n");
12874 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12878 char timebuf
[BGP_UPTIME_LEN
];
12884 json_object
*json_neigh
= NULL
;
12886 uint32_t sync_tcp_mss
;
12891 json_neigh
= json_object_new_object();
12893 memset(dn_flag
, '\0', sizeof(dn_flag
));
12894 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12898 if (p
->conf_if
) /* Configured interface name. */
12899 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12901 else /* Configured IP address. */
12902 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12907 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12908 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12910 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12911 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12914 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12916 if (p
->change_local_as
)
12917 json_object_int_add(json_neigh
, "localAs",
12918 p
->change_local_as
);
12920 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12922 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12923 json_object_boolean_true_add(json_neigh
,
12924 "localAsNoPrepend");
12926 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12927 json_object_boolean_true_add(json_neigh
,
12928 "localAsReplaceAs");
12930 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12931 || (p
->as_type
== AS_INTERNAL
))
12932 vty_out(vty
, "remote AS %u, ", p
->as
);
12934 vty_out(vty
, "remote AS Unspecified, ");
12935 vty_out(vty
, "local AS %u%s%s, ",
12936 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12937 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12940 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12944 /* peer type internal or confed-internal */
12945 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12947 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12948 json_object_boolean_true_add(
12949 json_neigh
, "nbrConfedInternalLink");
12951 json_object_boolean_true_add(json_neigh
,
12952 "nbrInternalLink");
12954 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12955 vty_out(vty
, "confed-internal link\n");
12957 vty_out(vty
, "internal link\n");
12959 /* peer type external or confed-external */
12960 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12962 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12963 json_object_boolean_true_add(
12964 json_neigh
, "nbrConfedExternalLink");
12966 json_object_boolean_true_add(json_neigh
,
12967 "nbrExternalLink");
12969 if (bgp_confederation_peers_check(bgp
, p
->as
))
12970 vty_out(vty
, "confed-external link\n");
12972 vty_out(vty
, "external link\n");
12976 json_object_boolean_true_add(json_neigh
,
12977 "nbrUnspecifiedLink");
12979 vty_out(vty
, "unspecified link\n");
12984 json_object_string_add(json_neigh
, "localRole",
12985 bgp_get_name_by_role(p
->local_role
));
12986 json_object_string_add(json_neigh
, "remoteRole",
12987 bgp_get_name_by_role(p
->remote_role
));
12989 vty_out(vty
, " Local Role: %s\n",
12990 bgp_get_name_by_role(p
->local_role
));
12991 vty_out(vty
, " Remote Role: %s\n",
12992 bgp_get_name_by_role(p
->remote_role
));
12999 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13001 vty_out(vty
, " Description: %s\n", p
->desc
);
13007 json_object_string_add(json_neigh
, "hostname",
13011 json_object_string_add(json_neigh
, "domainname",
13014 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13015 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13018 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13025 json_object_string_add(json_neigh
, "peerGroup",
13029 struct prefix prefix
, *range
= NULL
;
13031 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13032 range
= peer_group_lookup_dynamic_neighbor_range(
13033 p
->group
, &prefix
);
13036 json_object_string_addf(
13038 "peerSubnetRangeGroup", "%pFX",
13044 " Member of peer-group %s for session parameters\n",
13048 struct prefix prefix
, *range
= NULL
;
13050 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13051 range
= peer_group_lookup_dynamic_neighbor_range(
13052 p
->group
, &prefix
);
13056 " Belongs to the subnet range group: %pFX\n",
13064 /* Administrative shutdown. */
13065 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13066 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13067 json_object_boolean_true_add(json_neigh
,
13071 json_object_int_add(json_neigh
, "bgpVersion", 4);
13072 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13074 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13077 /* Confederation */
13078 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13079 && bgp_confederation_peers_check(bgp
, p
->as
))
13080 json_object_boolean_true_add(json_neigh
,
13084 json_object_string_add(
13085 json_neigh
, "bgpState",
13086 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13088 if (peer_established(p
)) {
13091 uptime
= monotime(NULL
);
13092 uptime
-= p
->uptime
;
13093 epoch_tbuf
= time(NULL
) - uptime
;
13095 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13097 json_object_string_add(json_neigh
, "bgpTimerUpString",
13098 peer_uptime(p
->uptime
, timebuf
,
13101 json_object_int_add(json_neigh
,
13102 "bgpTimerUpEstablishedEpoch",
13106 else if (p
->status
== Active
) {
13107 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13108 json_object_string_add(json_neigh
, "bgpStateIs",
13110 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13111 json_object_string_add(json_neigh
, "bgpStateIs",
13119 uptime
= monotime(NULL
);
13120 uptime
-= p
->readtime
;
13121 gmtime_r(&uptime
, &tm
);
13123 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13124 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13125 + (tm
.tm_hour
* 3600000));
13127 uptime
= monotime(NULL
);
13128 uptime
-= p
->last_write
;
13129 gmtime_r(&uptime
, &tm
);
13131 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13132 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13133 + (tm
.tm_hour
* 3600000));
13135 uptime
= monotime(NULL
);
13136 uptime
-= p
->update_time
;
13137 gmtime_r(&uptime
, &tm
);
13139 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13140 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13141 + (tm
.tm_hour
* 3600000));
13143 /* Configured timer values. */
13144 json_object_int_add(json_neigh
,
13145 "bgpTimerConfiguredHoldTimeMsecs",
13146 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13147 ? p
->holdtime
* 1000
13148 : bgp
->default_holdtime
* 1000);
13149 json_object_int_add(json_neigh
,
13150 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13151 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13152 ? p
->keepalive
* 1000
13153 : bgp
->default_keepalive
* 1000);
13154 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13155 p
->v_holdtime
* 1000);
13156 json_object_int_add(json_neigh
,
13157 "bgpTimerKeepAliveIntervalMsecs",
13158 p
->v_keepalive
* 1000);
13159 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13160 json_object_int_add(json_neigh
,
13161 "bgpTimerDelayOpenTimeMsecs",
13162 p
->v_delayopen
* 1000);
13165 /* Configured and Synced tcp-mss value for peer */
13166 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13167 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13168 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13170 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13174 /* Extended Optional Parameters Length for BGP OPEN Message */
13175 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13176 json_object_boolean_true_add(
13177 json_neigh
, "extendedOptionalParametersLength");
13179 json_object_boolean_false_add(
13180 json_neigh
, "extendedOptionalParametersLength");
13182 /* Conditional advertisements */
13183 json_object_int_add(
13185 "bgpTimerConfiguredConditionalAdvertisementsSec",
13186 bgp
->condition_check_period
);
13187 if (thread_is_scheduled(bgp
->t_condition_check
))
13188 json_object_int_add(
13190 "bgpTimerUntilConditionalAdvertisementsSec",
13191 thread_timer_remain_second(
13192 bgp
->t_condition_check
));
13194 /* Administrative shutdown. */
13195 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13196 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13197 vty_out(vty
, " Administratively shut down\n");
13200 vty_out(vty
, " BGP version 4");
13201 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13202 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13204 /* Confederation */
13205 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13206 && bgp_confederation_peers_check(bgp
, p
->as
))
13208 " Neighbor under common administration\n");
13211 vty_out(vty
, " BGP state = %s",
13212 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13214 if (peer_established(p
))
13215 vty_out(vty
, ", up for %8s",
13216 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13219 else if (p
->status
== Active
) {
13220 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13221 vty_out(vty
, " (passive)");
13222 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13223 vty_out(vty
, " (NSF passive)");
13225 vty_out(vty
, "\n");
13228 vty_out(vty
, " Last read %s",
13229 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13231 vty_out(vty
, ", Last write %s\n",
13232 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13235 /* Configured timer values. */
13237 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13238 p
->v_holdtime
, p
->v_keepalive
);
13239 vty_out(vty
, " Configured hold time is %d seconds",
13240 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13242 : bgp
->default_holdtime
);
13243 vty_out(vty
, ", keepalive interval is %d seconds\n",
13244 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13246 : bgp
->default_keepalive
);
13247 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13249 " Configured DelayOpenTime is %d seconds\n",
13252 /* Configured and synced tcp-mss value for peer */
13253 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13254 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13255 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13256 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13259 /* Extended Optional Parameters Length for BGP OPEN Message */
13260 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13262 " Extended Optional Parameters Length is enabled\n");
13264 /* Conditional advertisements */
13266 " Configured conditional advertisements interval is %d seconds\n",
13267 bgp
->condition_check_period
);
13268 if (thread_is_scheduled(bgp
->t_condition_check
))
13270 " Time until conditional advertisements begin is %lu seconds\n",
13271 thread_timer_remain_second(
13272 bgp
->t_condition_check
));
13275 if (peer_established(p
) &&
13276 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13278 json_object
*json_cap
= NULL
;
13280 json_cap
= json_object_new_object();
13283 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13284 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13285 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13286 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13287 json_object_string_add(
13288 json_cap
, "4byteAs",
13289 "advertisedAndReceived");
13290 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13291 json_object_string_add(json_cap
,
13294 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13295 json_object_string_add(json_cap
,
13300 /* Extended Message Support */
13301 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13302 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13303 json_object_string_add(json_cap
,
13305 "advertisedAndReceived");
13306 else if (CHECK_FLAG(p
->cap
,
13307 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13308 json_object_string_add(json_cap
,
13311 else if (CHECK_FLAG(p
->cap
,
13312 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13313 json_object_string_add(json_cap
,
13318 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13319 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13320 json_object
*json_add
= NULL
;
13321 const char *print_store
;
13323 json_add
= json_object_new_object();
13325 FOREACH_AFI_SAFI (afi
, safi
) {
13326 json_object
*json_sub
= NULL
;
13327 json_sub
= json_object_new_object();
13328 print_store
= get_afi_safi_str(
13332 p
->af_cap
[afi
][safi
],
13333 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13335 p
->af_cap
[afi
][safi
],
13336 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13340 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13344 PEER_CAP_ADDPATH_AF_TX_RCV
))
13345 json_object_boolean_true_add(
13347 "txAdvertisedAndReceived");
13352 PEER_CAP_ADDPATH_AF_TX_ADV
))
13353 json_object_boolean_true_add(
13360 PEER_CAP_ADDPATH_AF_TX_RCV
))
13361 json_object_boolean_true_add(
13367 p
->af_cap
[afi
][safi
],
13368 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13370 p
->af_cap
[afi
][safi
],
13371 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13375 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13379 PEER_CAP_ADDPATH_AF_RX_RCV
))
13380 json_object_boolean_true_add(
13382 "rxAdvertisedAndReceived");
13387 PEER_CAP_ADDPATH_AF_RX_ADV
))
13388 json_object_boolean_true_add(
13395 PEER_CAP_ADDPATH_AF_RX_RCV
))
13396 json_object_boolean_true_add(
13402 p
->af_cap
[afi
][safi
],
13403 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13405 p
->af_cap
[afi
][safi
],
13406 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13408 p
->af_cap
[afi
][safi
],
13409 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13411 p
->af_cap
[afi
][safi
],
13412 PEER_CAP_ADDPATH_AF_RX_RCV
))
13413 json_object_object_add(
13414 json_add
, print_store
,
13417 json_object_free(json_sub
);
13420 json_object_object_add(json_cap
, "addPath",
13425 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13426 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13427 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13428 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13429 json_object_string_add(
13430 json_cap
, "dynamic",
13431 "advertisedAndReceived");
13432 else if (CHECK_FLAG(p
->cap
,
13433 PEER_CAP_DYNAMIC_ADV
))
13434 json_object_string_add(json_cap
,
13437 else if (CHECK_FLAG(p
->cap
,
13438 PEER_CAP_DYNAMIC_RCV
))
13439 json_object_string_add(json_cap
,
13445 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13446 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13447 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13448 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13449 json_object_string_add(
13451 "advertisedAndReceived");
13452 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13453 json_object_string_add(json_cap
, "role",
13455 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13456 json_object_string_add(json_cap
, "role",
13460 /* Extended nexthop */
13461 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13462 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13463 json_object
*json_nxt
= NULL
;
13464 const char *print_store
;
13467 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13468 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13469 json_object_string_add(
13470 json_cap
, "extendedNexthop",
13471 "advertisedAndReceived");
13472 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13473 json_object_string_add(
13474 json_cap
, "extendedNexthop",
13476 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13477 json_object_string_add(
13478 json_cap
, "extendedNexthop",
13481 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13482 json_nxt
= json_object_new_object();
13484 for (safi
= SAFI_UNICAST
;
13485 safi
< SAFI_MAX
; safi
++) {
13489 PEER_CAP_ENHE_AF_RCV
)) {
13495 json_object_string_add(
13498 "recieved"); /* misspelled for compatibility */
13501 json_object_object_add(
13503 "extendedNexthopFamililesByPeer",
13508 /* Long-lived Graceful Restart */
13509 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13510 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13511 json_object
*json_llgr
= NULL
;
13512 const char *afi_safi_str
;
13514 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13515 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13516 json_object_string_add(
13518 "longLivedGracefulRestart",
13519 "advertisedAndReceived");
13520 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13521 json_object_string_add(
13523 "longLivedGracefulRestart",
13525 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13526 json_object_string_add(
13528 "longLivedGracefulRestart",
13531 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13532 json_llgr
= json_object_new_object();
13534 FOREACH_AFI_SAFI (afi
, safi
) {
13538 PEER_CAP_ENHE_AF_RCV
)) {
13544 json_object_string_add(
13550 json_object_object_add(
13552 "longLivedGracefulRestartByPeer",
13557 /* Route Refresh */
13558 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13559 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13560 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13561 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13562 (CHECK_FLAG(p
->cap
,
13563 PEER_CAP_REFRESH_NEW_RCV
) ||
13565 PEER_CAP_REFRESH_OLD_RCV
))) {
13568 PEER_CAP_REFRESH_OLD_RCV
) &&
13571 PEER_CAP_REFRESH_NEW_RCV
))
13572 json_object_string_add(
13575 "advertisedAndReceivedOldNew");
13579 PEER_CAP_REFRESH_OLD_RCV
))
13580 json_object_string_add(
13583 "advertisedAndReceivedOld");
13585 json_object_string_add(
13588 "advertisedAndReceivedNew");
13590 } else if (CHECK_FLAG(p
->cap
,
13591 PEER_CAP_REFRESH_ADV
))
13592 json_object_string_add(json_cap
,
13595 else if (CHECK_FLAG(p
->cap
,
13596 PEER_CAP_REFRESH_NEW_RCV
) ||
13598 PEER_CAP_REFRESH_OLD_RCV
))
13599 json_object_string_add(json_cap
,
13604 /* Enhanced Route Refresh */
13605 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13606 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13607 if (CHECK_FLAG(p
->cap
,
13608 PEER_CAP_ENHANCED_RR_ADV
) &&
13610 PEER_CAP_ENHANCED_RR_RCV
))
13611 json_object_string_add(
13613 "enhancedRouteRefresh",
13614 "advertisedAndReceived");
13615 else if (CHECK_FLAG(p
->cap
,
13616 PEER_CAP_ENHANCED_RR_ADV
))
13617 json_object_string_add(
13619 "enhancedRouteRefresh",
13621 else if (CHECK_FLAG(p
->cap
,
13622 PEER_CAP_ENHANCED_RR_RCV
))
13623 json_object_string_add(
13625 "enhancedRouteRefresh",
13629 /* Multiprotocol Extensions */
13630 json_object
*json_multi
= NULL
;
13632 json_multi
= json_object_new_object();
13634 FOREACH_AFI_SAFI (afi
, safi
) {
13635 if (p
->afc_adv
[afi
][safi
] ||
13636 p
->afc_recv
[afi
][safi
]) {
13637 json_object
*json_exten
= NULL
;
13638 json_exten
= json_object_new_object();
13640 if (p
->afc_adv
[afi
][safi
] &&
13641 p
->afc_recv
[afi
][safi
])
13642 json_object_boolean_true_add(
13644 "advertisedAndReceived");
13645 else if (p
->afc_adv
[afi
][safi
])
13646 json_object_boolean_true_add(
13649 else if (p
->afc_recv
[afi
][safi
])
13650 json_object_boolean_true_add(
13651 json_exten
, "received");
13653 json_object_object_add(
13655 get_afi_safi_str(afi
, safi
,
13660 json_object_object_add(json_cap
,
13661 "multiprotocolExtensions",
13664 /* Hostname capabilities */
13665 json_object
*json_hname
= NULL
;
13667 json_hname
= json_object_new_object();
13669 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13670 json_object_string_add(
13671 json_hname
, "advHostName",
13672 bgp
->peer_self
->hostname
13673 ? bgp
->peer_self
->hostname
13675 json_object_string_add(
13676 json_hname
, "advDomainName",
13677 bgp
->peer_self
->domainname
13678 ? bgp
->peer_self
->domainname
13683 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13684 json_object_string_add(
13685 json_hname
, "rcvHostName",
13686 p
->hostname
? p
->hostname
: "n/a");
13687 json_object_string_add(
13688 json_hname
, "rcvDomainName",
13689 p
->domainname
? p
->domainname
: "n/a");
13692 json_object_object_add(json_cap
, "hostName",
13695 /* Graceful Restart */
13696 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13697 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13698 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13699 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13700 json_object_string_add(
13701 json_cap
, "gracefulRestart",
13702 "advertisedAndReceived");
13703 else if (CHECK_FLAG(p
->cap
,
13704 PEER_CAP_RESTART_ADV
))
13705 json_object_string_add(
13707 "gracefulRestartCapability",
13709 else if (CHECK_FLAG(p
->cap
,
13710 PEER_CAP_RESTART_RCV
))
13711 json_object_string_add(
13713 "gracefulRestartCapability",
13716 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13717 int restart_af_count
= 0;
13718 json_object
*json_restart
= NULL
;
13719 json_restart
= json_object_new_object();
13721 json_object_int_add(
13723 "gracefulRestartRemoteTimerMsecs",
13724 p
->v_gr_restart
* 1000);
13726 FOREACH_AFI_SAFI (afi
, safi
) {
13730 PEER_CAP_RESTART_AF_RCV
)) {
13731 json_object
*json_sub
=
13734 json_object_new_object();
13740 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13741 json_object_boolean_true_add(
13744 restart_af_count
++;
13745 json_object_object_add(
13754 if (!restart_af_count
) {
13755 json_object_string_add(
13757 "addressFamiliesByPeer",
13759 json_object_free(json_restart
);
13761 json_object_object_add(
13763 "addressFamiliesByPeer",
13767 json_object_object_add(
13768 json_neigh
, "neighborCapabilities", json_cap
);
13770 vty_out(vty
, " Neighbor capabilities:\n");
13773 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13774 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13775 vty_out(vty
, " 4 Byte AS:");
13776 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13777 vty_out(vty
, " advertised");
13778 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13779 vty_out(vty
, " %sreceived",
13784 vty_out(vty
, "\n");
13787 /* Extended Message Support */
13788 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13789 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13790 vty_out(vty
, " Extended Message:");
13791 if (CHECK_FLAG(p
->cap
,
13792 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13793 vty_out(vty
, " advertised");
13794 if (CHECK_FLAG(p
->cap
,
13795 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13796 vty_out(vty
, " %sreceived",
13799 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13802 vty_out(vty
, "\n");
13806 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13807 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13808 vty_out(vty
, " AddPath:\n");
13810 FOREACH_AFI_SAFI (afi
, safi
) {
13812 p
->af_cap
[afi
][safi
],
13813 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13815 p
->af_cap
[afi
][safi
],
13816 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13817 vty_out(vty
, " %s: TX ",
13825 PEER_CAP_ADDPATH_AF_TX_ADV
))
13832 PEER_CAP_ADDPATH_AF_TX_RCV
))
13839 PEER_CAP_ADDPATH_AF_TX_ADV
)
13843 vty_out(vty
, "\n");
13847 p
->af_cap
[afi
][safi
],
13848 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13850 p
->af_cap
[afi
][safi
],
13851 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13852 vty_out(vty
, " %s: RX ",
13860 PEER_CAP_ADDPATH_AF_RX_ADV
))
13867 PEER_CAP_ADDPATH_AF_RX_RCV
))
13874 PEER_CAP_ADDPATH_AF_RX_ADV
)
13878 vty_out(vty
, "\n");
13884 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13885 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13886 vty_out(vty
, " Dynamic:");
13887 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13888 vty_out(vty
, " advertised");
13889 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13890 vty_out(vty
, " %sreceived",
13892 PEER_CAP_DYNAMIC_ADV
)
13895 vty_out(vty
, "\n");
13899 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13900 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13901 vty_out(vty
, " Role:");
13902 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13903 vty_out(vty
, " advertised");
13904 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13905 vty_out(vty
, " %sreceived",
13910 vty_out(vty
, "\n");
13913 /* Extended nexthop */
13914 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13915 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13916 vty_out(vty
, " Extended nexthop:");
13917 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13918 vty_out(vty
, " advertised");
13919 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13920 vty_out(vty
, " %sreceived",
13925 vty_out(vty
, "\n");
13927 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13929 " Address families by peer:\n ");
13930 for (safi
= SAFI_UNICAST
;
13931 safi
< SAFI_MAX
; safi
++)
13935 PEER_CAP_ENHE_AF_RCV
))
13945 /* Long-lived Graceful Restart */
13946 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13947 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13949 " Long-lived Graceful Restart:");
13950 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13951 vty_out(vty
, " advertised");
13952 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13953 vty_out(vty
, " %sreceived",
13958 vty_out(vty
, "\n");
13960 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13962 " Address families by peer:\n");
13963 FOREACH_AFI_SAFI (afi
, safi
)
13967 PEER_CAP_LLGR_AF_RCV
))
13977 /* Route Refresh */
13978 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13979 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13980 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13981 vty_out(vty
, " Route refresh:");
13982 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13983 vty_out(vty
, " advertised");
13984 if (CHECK_FLAG(p
->cap
,
13985 PEER_CAP_REFRESH_NEW_RCV
) ||
13987 PEER_CAP_REFRESH_OLD_RCV
))
13988 vty_out(vty
, " %sreceived(%s)",
13990 PEER_CAP_REFRESH_ADV
)
13995 PEER_CAP_REFRESH_OLD_RCV
) &&
13998 PEER_CAP_REFRESH_NEW_RCV
))
14002 PEER_CAP_REFRESH_OLD_RCV
)
14006 vty_out(vty
, "\n");
14009 /* Enhanced Route Refresh */
14010 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14011 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14012 vty_out(vty
, " Enhanced Route Refresh:");
14013 if (CHECK_FLAG(p
->cap
,
14014 PEER_CAP_ENHANCED_RR_ADV
))
14015 vty_out(vty
, " advertised");
14016 if (CHECK_FLAG(p
->cap
,
14017 PEER_CAP_ENHANCED_RR_RCV
))
14018 vty_out(vty
, " %sreceived",
14020 PEER_CAP_REFRESH_ADV
)
14023 vty_out(vty
, "\n");
14026 /* Multiprotocol Extensions */
14027 FOREACH_AFI_SAFI (afi
, safi
)
14028 if (p
->afc_adv
[afi
][safi
] ||
14029 p
->afc_recv
[afi
][safi
]) {
14030 vty_out(vty
, " Address Family %s:",
14031 get_afi_safi_str(afi
, safi
,
14033 if (p
->afc_adv
[afi
][safi
])
14034 vty_out(vty
, " advertised");
14035 if (p
->afc_recv
[afi
][safi
])
14036 vty_out(vty
, " %sreceived",
14037 p
->afc_adv
[afi
][safi
]
14040 vty_out(vty
, "\n");
14043 /* Hostname capability */
14044 vty_out(vty
, " Hostname Capability:");
14046 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14048 " advertised (name: %s,domain name: %s)",
14049 bgp
->peer_self
->hostname
14050 ? bgp
->peer_self
->hostname
14052 bgp
->peer_self
->domainname
14053 ? bgp
->peer_self
->domainname
14056 vty_out(vty
, " not advertised");
14059 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14061 " received (name: %s,domain name: %s)",
14062 p
->hostname
? p
->hostname
: "n/a",
14063 p
->domainname
? p
->domainname
: "n/a");
14065 vty_out(vty
, " not received");
14068 vty_out(vty
, "\n");
14070 /* Graceful Restart */
14071 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14072 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14074 " Graceful Restart Capability:");
14075 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14076 vty_out(vty
, " advertised");
14077 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14078 vty_out(vty
, " %sreceived",
14080 PEER_CAP_RESTART_ADV
)
14083 vty_out(vty
, "\n");
14085 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14086 int restart_af_count
= 0;
14089 " Remote Restart timer is %d seconds\n",
14092 " Address families by peer:\n ");
14094 FOREACH_AFI_SAFI (afi
, safi
)
14098 PEER_CAP_RESTART_AF_RCV
)) {
14099 vty_out(vty
, "%s%s(%s)",
14111 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14113 : "not preserved");
14114 restart_af_count
++;
14116 if (!restart_af_count
)
14117 vty_out(vty
, "none");
14118 vty_out(vty
, "\n");
14120 } /* Graceful Restart */
14124 /* graceful restart information */
14125 json_object
*json_grace
= NULL
;
14126 json_object
*json_grace_send
= NULL
;
14127 json_object
*json_grace_recv
= NULL
;
14128 int eor_send_af_count
= 0;
14129 int eor_receive_af_count
= 0;
14132 json_grace
= json_object_new_object();
14133 json_grace_send
= json_object_new_object();
14134 json_grace_recv
= json_object_new_object();
14136 if ((peer_established(p
)) &&
14137 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14138 FOREACH_AFI_SAFI (afi
, safi
) {
14139 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14140 PEER_STATUS_EOR_SEND
)) {
14141 json_object_boolean_true_add(
14143 get_afi_safi_str(afi
, safi
,
14145 eor_send_af_count
++;
14148 FOREACH_AFI_SAFI (afi
, safi
) {
14149 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14150 PEER_STATUS_EOR_RECEIVED
)) {
14151 json_object_boolean_true_add(
14153 get_afi_safi_str(afi
, safi
,
14155 eor_receive_af_count
++;
14159 json_object_object_add(json_grace
, "endOfRibSend",
14161 json_object_object_add(json_grace
, "endOfRibRecv",
14165 if (p
->t_gr_restart
)
14166 json_object_int_add(
14167 json_grace
, "gracefulRestartTimerMsecs",
14168 thread_timer_remain_second(p
->t_gr_restart
) *
14172 json_object_int_add(
14173 json_grace
, "gracefulStalepathTimerMsecs",
14174 thread_timer_remain_second(p
->t_gr_stale
) *
14176 /* more gr info in new format */
14177 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
14178 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14181 vty_out(vty
, " Graceful restart information:\n");
14182 if ((peer_established(p
)) &&
14183 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14185 vty_out(vty
, " End-of-RIB send: ");
14186 FOREACH_AFI_SAFI (afi
, safi
) {
14187 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14188 PEER_STATUS_EOR_SEND
)) {
14189 vty_out(vty
, "%s%s",
14190 eor_send_af_count
? ", " : "",
14191 get_afi_safi_str(afi
, safi
,
14193 eor_send_af_count
++;
14196 vty_out(vty
, "\n");
14197 vty_out(vty
, " End-of-RIB received: ");
14198 FOREACH_AFI_SAFI (afi
, safi
) {
14199 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14200 PEER_STATUS_EOR_RECEIVED
)) {
14201 vty_out(vty
, "%s%s",
14202 eor_receive_af_count
? ", "
14204 get_afi_safi_str(afi
, safi
,
14206 eor_receive_af_count
++;
14209 vty_out(vty
, "\n");
14212 if (p
->t_gr_restart
)
14214 " The remaining time of restart timer is %ld\n",
14215 thread_timer_remain_second(p
->t_gr_restart
));
14219 " The remaining time of stalepath timer is %ld\n",
14220 thread_timer_remain_second(p
->t_gr_stale
));
14222 /* more gr info in new format */
14223 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14227 json_object
*json_stat
= NULL
;
14228 json_stat
= json_object_new_object();
14229 /* Packet counts. */
14231 atomic_size_t outq_count
, inq_count
;
14232 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14233 memory_order_relaxed
);
14234 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14235 memory_order_relaxed
);
14237 json_object_int_add(json_stat
, "depthInq",
14238 (unsigned long)inq_count
);
14239 json_object_int_add(json_stat
, "depthOutq",
14240 (unsigned long)outq_count
);
14241 json_object_int_add(json_stat
, "opensSent",
14242 atomic_load_explicit(&p
->open_out
,
14243 memory_order_relaxed
));
14244 json_object_int_add(json_stat
, "opensRecv",
14245 atomic_load_explicit(&p
->open_in
,
14246 memory_order_relaxed
));
14247 json_object_int_add(json_stat
, "notificationsSent",
14248 atomic_load_explicit(&p
->notify_out
,
14249 memory_order_relaxed
));
14250 json_object_int_add(json_stat
, "notificationsRecv",
14251 atomic_load_explicit(&p
->notify_in
,
14252 memory_order_relaxed
));
14253 json_object_int_add(json_stat
, "updatesSent",
14254 atomic_load_explicit(&p
->update_out
,
14255 memory_order_relaxed
));
14256 json_object_int_add(json_stat
, "updatesRecv",
14257 atomic_load_explicit(&p
->update_in
,
14258 memory_order_relaxed
));
14259 json_object_int_add(json_stat
, "keepalivesSent",
14260 atomic_load_explicit(&p
->keepalive_out
,
14261 memory_order_relaxed
));
14262 json_object_int_add(json_stat
, "keepalivesRecv",
14263 atomic_load_explicit(&p
->keepalive_in
,
14264 memory_order_relaxed
));
14265 json_object_int_add(json_stat
, "routeRefreshSent",
14266 atomic_load_explicit(&p
->refresh_out
,
14267 memory_order_relaxed
));
14268 json_object_int_add(json_stat
, "routeRefreshRecv",
14269 atomic_load_explicit(&p
->refresh_in
,
14270 memory_order_relaxed
));
14271 json_object_int_add(json_stat
, "capabilitySent",
14272 atomic_load_explicit(&p
->dynamic_cap_out
,
14273 memory_order_relaxed
));
14274 json_object_int_add(json_stat
, "capabilityRecv",
14275 atomic_load_explicit(&p
->dynamic_cap_in
,
14276 memory_order_relaxed
));
14277 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14278 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14279 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14281 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14282 notify_out
, notify_in
, update_out
, update_in
,
14283 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14284 dynamic_cap_out
, dynamic_cap_in
;
14285 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14286 memory_order_relaxed
);
14287 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14288 memory_order_relaxed
);
14289 open_out
= atomic_load_explicit(&p
->open_out
,
14290 memory_order_relaxed
);
14292 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14293 notify_out
= atomic_load_explicit(&p
->notify_out
,
14294 memory_order_relaxed
);
14295 notify_in
= atomic_load_explicit(&p
->notify_in
,
14296 memory_order_relaxed
);
14297 update_out
= atomic_load_explicit(&p
->update_out
,
14298 memory_order_relaxed
);
14299 update_in
= atomic_load_explicit(&p
->update_in
,
14300 memory_order_relaxed
);
14301 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14302 memory_order_relaxed
);
14303 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14304 memory_order_relaxed
);
14305 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14306 memory_order_relaxed
);
14307 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14308 memory_order_relaxed
);
14309 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14310 memory_order_relaxed
);
14311 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14312 memory_order_relaxed
);
14314 /* Packet counts. */
14315 vty_out(vty
, " Message statistics:\n");
14316 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14317 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14318 vty_out(vty
, " Sent Rcvd\n");
14319 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14321 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14323 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14325 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14327 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14329 vty_out(vty
, " Capability: %10zu %10zu\n",
14330 dynamic_cap_out
, dynamic_cap_in
);
14331 vty_out(vty
, " Total: %10u %10u\n",
14332 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14336 /* advertisement-interval */
14337 json_object_int_add(json_neigh
,
14338 "minBtwnAdvertisementRunsTimerMsecs",
14339 p
->v_routeadv
* 1000);
14341 /* Update-source. */
14342 if (p
->update_if
|| p
->update_source
) {
14344 json_object_string_add(json_neigh
,
14347 else if (p
->update_source
)
14348 json_object_string_addf(json_neigh
,
14349 "updateSource", "%pSU",
14353 /* advertisement-interval */
14355 " Minimum time between advertisement runs is %d seconds\n",
14358 /* Update-source. */
14359 if (p
->update_if
|| p
->update_source
) {
14360 vty_out(vty
, " Update source is ");
14362 vty_out(vty
, "%s", p
->update_if
);
14363 else if (p
->update_source
)
14364 vty_out(vty
, "%pSU", p
->update_source
);
14365 vty_out(vty
, "\n");
14368 vty_out(vty
, "\n");
14371 /* Address Family Information */
14372 json_object
*json_hold
= NULL
;
14375 json_hold
= json_object_new_object();
14377 FOREACH_AFI_SAFI (afi
, safi
)
14378 if (p
->afc
[afi
][safi
])
14379 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14383 json_object_object_add(json_neigh
, "addressFamilyInfo",
14385 json_object_int_add(json_neigh
, "connectionsEstablished",
14387 json_object_int_add(json_neigh
, "connectionsDropped",
14390 vty_out(vty
, " Connections established %d; dropped %d\n",
14391 p
->established
, p
->dropped
);
14393 if (!p
->last_reset
) {
14395 json_object_string_add(json_neigh
, "lastReset",
14398 vty_out(vty
, " Last reset never\n");
14404 uptime
= monotime(NULL
);
14405 uptime
-= p
->resettime
;
14406 gmtime_r(&uptime
, &tm
);
14408 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14410 + (tm
.tm_min
* 60000)
14411 + (tm
.tm_hour
* 3600000));
14412 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14414 vty_out(vty
, " Last reset %s, ",
14415 peer_uptime(p
->resettime
, timebuf
,
14416 BGP_UPTIME_LEN
, 0, NULL
));
14418 bgp_show_peer_reset(vty
, p
, NULL
, false);
14419 if (p
->last_reset_cause_size
) {
14420 msg
= p
->last_reset_cause
;
14422 " Message received that caused BGP to send a NOTIFICATION:\n ");
14423 for (i
= 1; i
<= p
->last_reset_cause_size
;
14425 vty_out(vty
, "%02X", *msg
++);
14427 if (i
!= p
->last_reset_cause_size
) {
14429 vty_out(vty
, "\n ");
14430 } else if (i
% 4 == 0) {
14435 vty_out(vty
, "\n");
14440 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14442 json_object_boolean_true_add(json_neigh
,
14443 "prefixesConfigExceedMax");
14446 " Peer had exceeded the max. no. of prefixes configured.\n");
14448 if (p
->t_pmax_restart
) {
14450 json_object_boolean_true_add(
14451 json_neigh
, "reducePrefixNumFrom");
14452 json_object_int_add(json_neigh
,
14453 "restartInTimerMsec",
14454 thread_timer_remain_second(
14459 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14460 p
->host
, thread_timer_remain_second(
14461 p
->t_pmax_restart
));
14464 json_object_boolean_true_add(
14466 "reducePrefixNumAndClearIpBgp");
14469 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14474 /* EBGP Multihop and GTSM */
14475 if (p
->sort
!= BGP_PEER_IBGP
) {
14477 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14478 json_object_int_add(json_neigh
,
14479 "externalBgpNbrMaxHopsAway",
14482 json_object_int_add(json_neigh
,
14483 "externalBgpNbrMaxHopsAway",
14486 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14488 " External BGP neighbor may be up to %d hops away.\n",
14492 " External BGP neighbor may be up to %d hops away.\n",
14497 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14498 json_object_int_add(json_neigh
,
14499 "internalBgpNbrMaxHopsAway",
14502 json_object_int_add(json_neigh
,
14503 "internalBgpNbrMaxHopsAway",
14506 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14508 " Internal BGP neighbor may be up to %d hops away.\n",
14512 " Internal BGP neighbor may be up to %d hops away.\n",
14517 /* Local address. */
14520 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14522 json_object_int_add(json_neigh
, "portLocal",
14523 ntohs(p
->su_local
->sin
.sin_port
));
14525 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14526 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14529 json_object_string_add(json_neigh
, "hostLocal",
14531 json_object_int_add(json_neigh
, "portLocal", -1);
14535 /* Remote address. */
14536 if (p
->su_remote
) {
14538 json_object_string_addf(json_neigh
, "hostForeign",
14539 "%pSU", p
->su_remote
);
14540 json_object_int_add(json_neigh
, "portForeign",
14541 ntohs(p
->su_remote
->sin
.sin_port
));
14543 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14545 ntohs(p
->su_remote
->sin
.sin_port
));
14548 json_object_string_add(json_neigh
, "hostForeign",
14550 json_object_int_add(json_neigh
, "portForeign", -1);
14554 /* Nexthop display. */
14557 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14559 json_object_string_addf(json_neigh
, "nexthopGlobal",
14560 "%pI6", &p
->nexthop
.v6_global
);
14561 json_object_string_addf(json_neigh
, "nexthopLocal",
14562 "%pI6", &p
->nexthop
.v6_local
);
14563 if (p
->shared_network
)
14564 json_object_string_add(json_neigh
,
14568 json_object_string_add(json_neigh
,
14570 "nonSharedNetwork");
14572 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14573 vty_out(vty
, "Nexthop global: %pI6\n",
14574 &p
->nexthop
.v6_global
);
14575 vty_out(vty
, "Nexthop local: %pI6\n",
14576 &p
->nexthop
.v6_local
);
14577 vty_out(vty
, "BGP connection: %s\n",
14578 p
->shared_network
? "shared network"
14579 : "non shared network");
14583 /* Timer information. */
14585 json_object_int_add(json_neigh
, "connectRetryTimer",
14587 if (peer_established(p
)) {
14588 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14590 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14591 json_object_int_add(json_neigh
,
14592 "shutdownRttInMsecs",
14594 json_object_int_add(json_neigh
,
14595 "shutdownRttAfterCount",
14596 p
->rtt_keepalive_rcv
);
14600 json_object_int_add(
14601 json_neigh
, "nextStartTimerDueInMsecs",
14602 thread_timer_remain_second(p
->t_start
) * 1000);
14604 json_object_int_add(
14605 json_neigh
, "nextConnectTimerDueInMsecs",
14606 thread_timer_remain_second(p
->t_connect
)
14608 if (p
->t_routeadv
) {
14609 json_object_int_add(json_neigh
, "mraiInterval",
14611 json_object_int_add(
14612 json_neigh
, "mraiTimerExpireInMsecs",
14613 thread_timer_remain_second(p
->t_routeadv
)
14617 json_object_int_add(json_neigh
, "authenticationEnabled",
14621 json_object_string_add(json_neigh
, "readThread", "on");
14623 json_object_string_add(json_neigh
, "readThread", "off");
14625 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14626 json_object_string_add(json_neigh
, "writeThread", "on");
14628 json_object_string_add(json_neigh
, "writeThread",
14631 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14633 if (peer_established(p
)) {
14634 vty_out(vty
, "Estimated round trip time: %d ms\n",
14636 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14638 "Shutdown when RTT > %dms, count > %u\n",
14639 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14642 vty_out(vty
, "Next start timer due in %ld seconds\n",
14643 thread_timer_remain_second(p
->t_start
));
14645 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14646 thread_timer_remain_second(p
->t_connect
));
14649 "MRAI (interval %u) timer expires in %ld seconds\n",
14651 thread_timer_remain_second(p
->t_routeadv
));
14653 vty_out(vty
, "Peer Authentication Enabled\n");
14655 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14656 p
->t_read
? "on" : "off",
14657 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14662 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14663 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14664 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14667 vty_out(vty
, "\n");
14669 /* BFD information. */
14671 bgp_bfd_show_info(vty
, p
, json_neigh
);
14674 if (p
->conf_if
) /* Configured interface name. */
14675 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14676 else /* Configured IP address. */
14677 json_object_object_add(json
, p
->host
, json_neigh
);
14681 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14682 enum show_type type
,
14683 union sockunion
*su
,
14684 const char *conf_if
, afi_t afi
,
14687 struct listnode
*node
, *nnode
;
14690 safi_t safi
= SAFI_UNICAST
;
14691 json_object
*json
= NULL
;
14692 json_object
*json_neighbor
= NULL
;
14695 json
= json_object_new_object();
14696 json_neighbor
= json_object_new_object();
14699 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14701 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14704 if ((peer
->afc
[afi
][safi
]) == 0)
14707 if (type
== show_all
) {
14708 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14712 json_object_object_add(json
, peer
->host
,
14714 json_neighbor
= NULL
;
14717 } else if (type
== show_peer
) {
14720 && !strcmp(peer
->conf_if
, conf_if
))
14722 && !strcmp(peer
->hostname
, conf_if
))) {
14724 bgp_show_peer_gr_status(vty
, peer
,
14729 if (sockunion_same(&peer
->su
, su
)) {
14731 bgp_show_peer_gr_status(vty
, peer
,
14736 if (use_json
&& find
)
14737 json_object_object_add(json
, peer
->host
,
14742 json_neighbor
= NULL
;
14747 if (type
== show_peer
&& !find
) {
14749 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14751 vty_out(vty
, "%% No such neighbor\n");
14755 json_object_free(json_neighbor
);
14756 vty_json(vty
, json
);
14758 vty_out(vty
, "\n");
14761 return CMD_SUCCESS
;
14764 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14765 enum show_type type
, union sockunion
*su
,
14766 const char *conf_if
, bool use_json
,
14769 struct listnode
*node
, *nnode
;
14772 bool nbr_output
= false;
14773 afi_t afi
= AFI_MAX
;
14774 safi_t safi
= SAFI_MAX
;
14776 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14778 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14782 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14783 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14788 bgp_show_peer(vty
, peer
, use_json
, json
);
14794 && !strcmp(peer
->conf_if
, conf_if
))
14796 && !strcmp(peer
->hostname
, conf_if
))) {
14798 bgp_show_peer(vty
, peer
, use_json
,
14802 if (sockunion_same(&peer
->su
, su
)) {
14804 bgp_show_peer(vty
, peer
, use_json
,
14809 case show_ipv4_peer
:
14810 case show_ipv6_peer
:
14811 FOREACH_SAFI (safi
) {
14812 if (peer
->afc
[afi
][safi
]) {
14815 && !strcmp(peer
->conf_if
, conf_if
))
14817 && !strcmp(peer
->hostname
, conf_if
))) {
14819 bgp_show_peer(vty
, peer
, use_json
,
14824 if (sockunion_same(&peer
->su
, su
)) {
14826 bgp_show_peer(vty
, peer
, use_json
,
14834 case show_ipv4_all
:
14835 case show_ipv6_all
:
14836 FOREACH_SAFI (safi
) {
14837 if (peer
->afc
[afi
][safi
]) {
14838 bgp_show_peer(vty
, peer
, use_json
, json
);
14847 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14848 type
== show_ipv6_peer
) && !find
) {
14850 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14852 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14855 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14856 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14857 vty_out(vty
, "%% No BGP neighbors found\n");
14860 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14861 json
, JSON_C_TO_STRING_PRETTY
));
14863 vty_out(vty
, "\n");
14866 return CMD_SUCCESS
;
14869 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14870 enum show_type type
,
14871 const char *ip_str
,
14872 afi_t afi
, bool use_json
)
14877 union sockunion su
;
14879 bgp
= bgp_get_default();
14885 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14889 ret
= str2sockunion(ip_str
, &su
);
14891 bgp_show_neighbor_graceful_restart(
14892 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14894 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14895 NULL
, afi
, use_json
);
14897 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14901 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14902 enum show_type type
,
14903 const char *ip_str
,
14906 struct listnode
*node
, *nnode
;
14908 union sockunion su
;
14909 json_object
*json
= NULL
;
14910 int ret
, is_first
= 1;
14911 bool nbr_output
= false;
14914 vty_out(vty
, "{\n");
14916 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14919 if (!(json
= json_object_new_object())) {
14921 EC_BGP_JSON_MEM_ERROR
,
14922 "Unable to allocate memory for JSON object");
14924 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14928 json_object_int_add(json
, "vrfId",
14929 (bgp
->vrf_id
== VRF_UNKNOWN
)
14931 : (int64_t)bgp
->vrf_id
);
14932 json_object_string_add(
14934 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14939 vty_out(vty
, ",\n");
14943 vty_out(vty
, "\"%s\":",
14944 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14948 vty_out(vty
, "\nInstance %s:\n",
14949 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14954 if (type
== show_peer
|| type
== show_ipv4_peer
||
14955 type
== show_ipv6_peer
) {
14956 ret
= str2sockunion(ip_str
, &su
);
14958 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14961 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14964 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14967 json_object_free(json
);
14972 vty_out(vty
, "}\n");
14973 else if (!nbr_output
)
14974 vty_out(vty
, "%% BGP instance not found\n");
14977 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14978 enum show_type type
, const char *ip_str
,
14983 union sockunion su
;
14984 json_object
*json
= NULL
;
14987 if (strmatch(name
, "all")) {
14988 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14990 return CMD_SUCCESS
;
14992 bgp
= bgp_lookup_by_name(name
);
14995 json
= json_object_new_object();
14996 vty_json(vty
, json
);
14999 "%% BGP instance not found\n");
15001 return CMD_WARNING
;
15005 bgp
= bgp_get_default();
15009 json
= json_object_new_object();
15011 ret
= str2sockunion(ip_str
, &su
);
15013 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15016 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15019 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15022 json_object_free(json
);
15025 vty_out(vty
, "{}\n");
15027 vty_out(vty
, "%% BGP instance not found\n");
15030 return CMD_SUCCESS
;
15035 /* "show [ip] bgp neighbors graceful-restart" commands. */
15036 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15037 show_ip_bgp_neighbors_graceful_restart_cmd
,
15038 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15044 "Neighbor to display information about\n"
15045 "Neighbor to display information about\n"
15046 "Neighbor on BGP configured interface\n"
15050 char *sh_arg
= NULL
;
15051 enum show_type sh_type
;
15053 afi_t afi
= AFI_MAX
;
15054 bool uj
= use_json(argc
, argv
);
15056 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15061 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15062 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15063 || argv_find(argv
, argc
, "WORD", &idx
)) {
15064 sh_type
= show_peer
;
15065 sh_arg
= argv
[idx
]->arg
;
15067 sh_type
= show_all
;
15069 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15070 return CMD_SUCCESS
;
15073 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15077 /* "show [ip] bgp neighbors" commands. */
15078 DEFUN (show_ip_bgp_neighbors
,
15079 show_ip_bgp_neighbors_cmd
,
15080 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15084 BGP_INSTANCE_HELP_STR
15087 "Detailed information on TCP and BGP neighbor connections\n"
15088 "Neighbor to display information about\n"
15089 "Neighbor to display information about\n"
15090 "Neighbor on BGP configured interface\n"
15094 char *sh_arg
= NULL
;
15095 enum show_type sh_type
;
15096 afi_t afi
= AFI_MAX
;
15098 bool uj
= use_json(argc
, argv
);
15102 /* [<vrf> VIEWVRFNAME] */
15103 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15104 vrf
= argv
[idx
+ 1]->arg
;
15105 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15107 } else if (argv_find(argv
, argc
, "view", &idx
))
15108 /* [<view> VIEWVRFNAME] */
15109 vrf
= argv
[idx
+ 1]->arg
;
15113 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15114 sh_type
= show_ipv4_all
;
15116 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15117 sh_type
= show_ipv6_all
;
15120 sh_type
= show_all
;
15123 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15124 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15125 || argv_find(argv
, argc
, "WORD", &idx
)) {
15126 sh_type
= show_peer
;
15127 sh_arg
= argv
[idx
]->arg
;
15130 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15131 sh_type
= show_ipv4_peer
;
15132 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15133 sh_type
= show_ipv6_peer
;
15136 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15139 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15140 paths' and `show ip mbgp paths'. Those functions results are the
15142 DEFUN (show_ip_bgp_paths
,
15143 show_ip_bgp_paths_cmd
,
15144 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15149 "Path information\n")
15151 vty_out(vty
, "Address Refcnt Path\n");
15152 aspath_print_all_vty(vty
);
15153 return CMD_SUCCESS
;
15158 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15161 struct community
*com
;
15163 com
= (struct community
*)bucket
->data
;
15164 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15165 community_str(com
, false, false));
15168 /* Show BGP's community internal data. */
15169 DEFUN (show_ip_bgp_community_info
,
15170 show_ip_bgp_community_info_cmd
,
15171 "show [ip] bgp community-info",
15175 "List all bgp community information\n")
15177 vty_out(vty
, "Address Refcnt Community\n");
15179 hash_iterate(community_hash(),
15180 (void (*)(struct hash_bucket
*,
15181 void *))community_show_all_iterator
,
15184 return CMD_SUCCESS
;
15187 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15190 struct lcommunity
*lcom
;
15192 lcom
= (struct lcommunity
*)bucket
->data
;
15193 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15194 lcommunity_str(lcom
, false, false));
15197 /* Show BGP's community internal data. */
15198 DEFUN (show_ip_bgp_lcommunity_info
,
15199 show_ip_bgp_lcommunity_info_cmd
,
15200 "show ip bgp large-community-info",
15204 "List all bgp large-community information\n")
15206 vty_out(vty
, "Address Refcnt Large-community\n");
15208 hash_iterate(lcommunity_hash(),
15209 (void (*)(struct hash_bucket
*,
15210 void *))lcommunity_show_all_iterator
,
15213 return CMD_SUCCESS
;
15215 /* Graceful Restart */
15217 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15224 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15226 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15228 switch (bgp_global_gr_mode
) {
15230 case GLOBAL_HELPER
:
15231 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15235 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15238 case GLOBAL_DISABLE
:
15239 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15242 case GLOBAL_INVALID
:
15244 "Global BGP GR Mode Invalid\n");
15247 vty_out(vty
, "\n");
15250 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15251 enum show_type type
,
15252 const char *ip_str
,
15253 afi_t afi
, bool use_json
)
15255 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15258 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15260 bgp_show_neighbor_graceful_restart_vty(
15261 vty
, type
, ip_str
, afi
, use_json
);
15264 } else if (afi
!= AFI_MAX
) {
15265 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15268 return CMD_ERR_INCOMPLETE
;
15271 return CMD_SUCCESS
;
15273 /* Graceful Restart */
15275 DEFUN (show_ip_bgp_attr_info
,
15276 show_ip_bgp_attr_info_cmd
,
15277 "show [ip] bgp attribute-info",
15281 "List all bgp attribute information\n")
15283 attr_show_all(vty
);
15284 return CMD_SUCCESS
;
15287 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15288 afi_t afi
, safi_t safi
,
15289 bool use_json
, json_object
*json
)
15292 struct listnode
*node
;
15295 enum vpn_policy_direction dir
;
15298 json_object
*json_import_vrfs
= NULL
;
15299 json_object
*json_export_vrfs
= NULL
;
15301 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15304 vty_json(vty
, json
);
15306 return CMD_WARNING
;
15309 /* Provide context for the block */
15310 json_object_string_add(json
, "vrf", name
? name
: "default");
15311 json_object_string_add(json
, "afiSafi",
15312 get_afi_safi_str(afi
, safi
, true));
15314 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15315 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15316 json_object_string_add(json
, "importFromVrfs", "none");
15317 json_object_string_add(json
, "importRts", "none");
15319 json_import_vrfs
= json_object_new_array();
15321 for (ALL_LIST_ELEMENTS_RO(
15322 bgp
->vpn_policy
[afi
].import_vrf
,
15324 json_object_array_add(json_import_vrfs
,
15325 json_object_new_string(vname
));
15327 json_object_object_add(json
, "importFromVrfs",
15329 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15330 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15331 ecom_str
= ecommunity_ecom2str(
15332 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15333 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15334 json_object_string_add(json
, "importRts",
15336 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15338 json_object_string_add(json
, "importRts",
15342 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15343 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15344 json_object_string_add(json
, "exportToVrfs", "none");
15345 json_object_string_add(json
, "routeDistinguisher",
15347 json_object_string_add(json
, "exportRts", "none");
15349 json_export_vrfs
= json_object_new_array();
15351 for (ALL_LIST_ELEMENTS_RO(
15352 bgp
->vpn_policy
[afi
].export_vrf
,
15354 json_object_array_add(json_export_vrfs
,
15355 json_object_new_string(vname
));
15356 json_object_object_add(json
, "exportToVrfs",
15358 json_object_string_addf(json
, "routeDistinguisher",
15360 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15362 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15363 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15364 ecom_str
= ecommunity_ecom2str(
15365 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15366 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15367 json_object_string_add(json
, "exportRts",
15369 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15371 json_object_string_add(json
, "exportRts",
15376 vty_json(vty
, json
);
15379 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15382 vty_out(vty
, "%% No such BGP instance exist\n");
15383 return CMD_WARNING
;
15386 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15387 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15389 "This VRF is not importing %s routes from any other VRF\n",
15390 get_afi_safi_str(afi
, safi
, false));
15393 "This VRF is importing %s routes from the following VRFs:\n",
15394 get_afi_safi_str(afi
, safi
, false));
15396 for (ALL_LIST_ELEMENTS_RO(
15397 bgp
->vpn_policy
[afi
].import_vrf
,
15399 vty_out(vty
, " %s\n", vname
);
15401 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15403 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15404 ecom_str
= ecommunity_ecom2str(
15405 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15406 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15407 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15409 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15411 vty_out(vty
, "Import RT(s):\n");
15414 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15415 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15417 "This VRF is not exporting %s routes to any other VRF\n",
15418 get_afi_safi_str(afi
, safi
, false));
15421 "This VRF is exporting %s routes to the following VRFs:\n",
15422 get_afi_safi_str(afi
, safi
, false));
15424 for (ALL_LIST_ELEMENTS_RO(
15425 bgp
->vpn_policy
[afi
].export_vrf
,
15427 vty_out(vty
, " %s\n", vname
);
15429 vty_out(vty
, "RD: %pRD\n",
15430 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15432 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15433 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15434 ecom_str
= ecommunity_ecom2str(
15435 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15436 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15437 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15438 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15440 vty_out(vty
, "Import RT(s):\n");
15444 return CMD_SUCCESS
;
15447 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15448 safi_t safi
, bool use_json
)
15450 struct listnode
*node
, *nnode
;
15452 char *vrf_name
= NULL
;
15453 json_object
*json
= NULL
;
15454 json_object
*json_vrf
= NULL
;
15455 json_object
*json_vrfs
= NULL
;
15458 json
= json_object_new_object();
15459 json_vrfs
= json_object_new_object();
15462 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15464 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15465 vrf_name
= bgp
->name
;
15468 json_vrf
= json_object_new_object();
15470 vty_out(vty
, "\nInstance %s:\n",
15471 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15472 ? VRF_DEFAULT_NAME
: bgp
->name
);
15474 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15476 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15477 json_object_object_add(json_vrfs
,
15478 VRF_DEFAULT_NAME
, json_vrf
);
15480 json_object_object_add(json_vrfs
, vrf_name
,
15486 json_object_object_add(json
, "vrfs", json_vrfs
);
15487 vty_json(vty
, json
);
15490 return CMD_SUCCESS
;
15493 /* "show [ip] bgp route-leak" command. */
15494 DEFUN (show_ip_bgp_route_leak
,
15495 show_ip_bgp_route_leak_cmd
,
15496 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15500 BGP_INSTANCE_HELP_STR
15503 "Route leaking information\n"
15507 afi_t afi
= AFI_MAX
;
15508 safi_t safi
= SAFI_MAX
;
15510 bool uj
= use_json(argc
, argv
);
15512 json_object
*json
= NULL
;
15514 /* show [ip] bgp */
15515 if (argv_find(argv
, argc
, "ip", &idx
)) {
15517 safi
= SAFI_UNICAST
;
15519 /* [vrf VIEWVRFNAME] */
15520 if (argv_find(argv
, argc
, "view", &idx
)) {
15522 "%% This command is not applicable to BGP views\n");
15523 return CMD_WARNING
;
15526 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15527 vrf
= argv
[idx
+ 1]->arg
;
15528 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15531 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15532 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15533 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15535 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15537 "%% This command is applicable only for unicast ipv4|ipv6\n");
15538 return CMD_WARNING
;
15541 if (vrf
&& strmatch(vrf
, "all"))
15542 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15545 json
= json_object_new_object();
15547 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15550 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15551 safi_t safi
, bool uj
)
15553 struct listnode
*node
, *nnode
;
15556 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15558 vty_out(vty
, "\nInstance %s:\n",
15559 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15563 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15567 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15568 int safi
, uint64_t subgrp_id
, bool uj
)
15573 if (strmatch(name
, "all")) {
15574 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15575 return CMD_SUCCESS
;
15577 bgp
= bgp_lookup_by_name(name
);
15580 bgp
= bgp_get_default();
15584 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15585 return CMD_SUCCESS
;
15588 DEFUN (show_ip_bgp_updgrps
,
15589 show_ip_bgp_updgrps_cmd
,
15590 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15594 BGP_INSTANCE_HELP_STR
15596 BGP_SAFI_WITH_LABEL_HELP_STR
15597 "Detailed info about dynamic update groups\n"
15598 "Specific subgroup to display detailed info for\n"
15602 afi_t afi
= AFI_IP6
;
15603 safi_t safi
= SAFI_UNICAST
;
15604 uint64_t subgrp_id
= 0;
15608 bool uj
= use_json(argc
, argv
);
15610 /* show [ip] bgp */
15611 if (argv_find(argv
, argc
, "ip", &idx
))
15613 /* [<vrf> VIEWVRFNAME] */
15614 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15615 vrf
= argv
[idx
+ 1]->arg
;
15616 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15618 } else if (argv_find(argv
, argc
, "view", &idx
))
15619 /* [<view> VIEWVRFNAME] */
15620 vrf
= argv
[idx
+ 1]->arg
;
15621 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15622 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15623 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15626 /* get subgroup id, if provided */
15628 if (argv
[idx
]->type
== VARIABLE_TKN
)
15629 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15631 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15634 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15635 show_bgp_instance_all_ipv6_updgrps_cmd
,
15636 "show [ip] bgp <view|vrf> all update-groups [json]",
15640 BGP_INSTANCE_ALL_HELP_STR
15641 "Detailed info about dynamic update groups\n"
15644 bool uj
= use_json(argc
, argv
);
15646 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15647 return CMD_SUCCESS
;
15650 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15651 show_bgp_l2vpn_evpn_updgrps_cmd
,
15652 "show [ip] bgp l2vpn evpn update-groups",
15656 "l2vpn address family\n"
15657 "evpn sub-address family\n"
15658 "Detailed info about dynamic update groups\n")
15661 uint64_t subgrp_id
= 0;
15663 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15664 return CMD_SUCCESS
;
15667 DEFUN (show_bgp_updgrps_stats
,
15668 show_bgp_updgrps_stats_cmd
,
15669 "show [ip] bgp update-groups statistics",
15673 "Detailed info about dynamic update groups\n"
15678 bgp
= bgp_get_default();
15680 update_group_show_stats(bgp
, vty
);
15682 return CMD_SUCCESS
;
15685 DEFUN (show_bgp_instance_updgrps_stats
,
15686 show_bgp_instance_updgrps_stats_cmd
,
15687 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15691 BGP_INSTANCE_HELP_STR
15692 "Detailed info about dynamic update groups\n"
15698 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15700 update_group_show_stats(bgp
, vty
);
15702 return CMD_SUCCESS
;
15705 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15706 afi_t afi
, safi_t safi
,
15707 const char *what
, uint64_t subgrp_id
)
15712 bgp
= bgp_lookup_by_name(name
);
15714 bgp
= bgp_get_default();
15717 if (!strcmp(what
, "advertise-queue"))
15718 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15720 else if (!strcmp(what
, "advertised-routes"))
15721 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15723 else if (!strcmp(what
, "packet-queue"))
15724 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15729 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15730 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15731 "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",
15732 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15734 "Detailed info about dynamic update groups\n"
15735 "Specific subgroup to display info for\n"
15736 "Advertisement queue\n"
15737 "Announced routes\n"
15740 uint64_t subgrp_id
= 0;
15744 subgrp_id
= strtoull(sgid
, NULL
, 10);
15749 afiz
= bgp_vty_afi_from_str(afi
);
15753 afiz
= bgp_vty_afi_from_str(afi
);
15754 if (afiz
!= AFI_IP
)
15756 "%% Cannot specify both 'ip' and 'ipv6'\n");
15757 return CMD_WARNING
;
15760 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15762 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15763 return CMD_SUCCESS
;
15766 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15769 struct listnode
*node
, *nnode
;
15770 struct prefix
*range
;
15775 const char *peer_status
;
15779 json_object
*json_peer_group
= NULL
;
15780 json_object
*json_peer_group_afc
= NULL
;
15781 json_object
*json_peer_group_members
= NULL
;
15782 json_object
*json_peer_group_dynamic
= NULL
;
15783 json_object
*json_peer_group_dynamic_af
= NULL
;
15784 json_object
*json_peer_group_ranges
= NULL
;
15786 conf
= group
->conf
;
15789 json_peer_group
= json_object_new_object();
15790 json_peer_group_afc
= json_object_new_array();
15793 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15795 json_object_int_add(json_peer_group
, "remoteAs",
15798 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15799 group
->name
, conf
->as
);
15800 } else if (conf
->as_type
== AS_INTERNAL
) {
15802 json_object_int_add(json_peer_group
, "remoteAs",
15805 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15806 group
->name
, group
->bgp
->as
);
15809 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15812 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15814 json_object_string_add(json_peer_group
, "type",
15817 vty_out(vty
, " Peer-group type is internal\n");
15820 json_object_string_add(json_peer_group
, "type",
15823 vty_out(vty
, " Peer-group type is external\n");
15826 /* Display AFs configured. */
15828 vty_out(vty
, " Configured address-families:");
15830 FOREACH_AFI_SAFI (afi
, safi
) {
15831 if (conf
->afc
[afi
][safi
]) {
15834 json_object_array_add(
15835 json_peer_group_afc
,
15836 json_object_new_string(get_afi_safi_str(
15837 afi
, safi
, false)));
15839 vty_out(vty
, " %s;",
15840 get_afi_safi_str(afi
, safi
, false));
15845 json_object_object_add(json_peer_group
,
15846 "addressFamiliesConfigured",
15847 json_peer_group_afc
);
15850 vty_out(vty
, " none\n");
15852 vty_out(vty
, "\n");
15855 /* Display listen ranges (for dynamic neighbors), if any */
15856 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15857 lr_count
= listcount(group
->listen_range
[afi
]);
15860 if (!json_peer_group_dynamic
)
15861 json_peer_group_dynamic
=
15862 json_object_new_object();
15864 json_peer_group_dynamic_af
=
15865 json_object_new_object();
15866 json_peer_group_ranges
=
15867 json_object_new_array();
15868 json_object_int_add(json_peer_group_dynamic_af
,
15869 "count", lr_count
);
15871 vty_out(vty
, " %d %s listen range(s)\n",
15872 lr_count
, afi2str(afi
));
15875 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15880 snprintfrr(buf
, sizeof(buf
), "%pFX",
15883 json_object_array_add(
15884 json_peer_group_ranges
,
15885 json_object_new_string(buf
));
15887 vty_out(vty
, " %pFX\n", range
);
15892 json_object_object_add(
15893 json_peer_group_dynamic_af
, "ranges",
15894 json_peer_group_ranges
);
15896 json_object_object_add(
15897 json_peer_group_dynamic
, afi2str(afi
),
15898 json_peer_group_dynamic_af
);
15903 if (json_peer_group_dynamic
)
15904 json_object_object_add(json_peer_group
, "dynamicRanges",
15905 json_peer_group_dynamic
);
15907 /* Display group members and their status */
15908 if (listcount(group
->peer
)) {
15910 json_peer_group_members
= json_object_new_object();
15912 vty_out(vty
, " Peer-group members:\n");
15913 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15914 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15915 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15916 peer_status
= "Idle (Admin)";
15917 else if (CHECK_FLAG(peer
->sflags
,
15918 PEER_STATUS_PREFIX_OVERFLOW
))
15919 peer_status
= "Idle (PfxCt)";
15921 peer_status
= lookup_msg(bgp_status_msg
,
15922 peer
->status
, NULL
);
15924 dynamic
= peer_dynamic_neighbor(peer
);
15927 json_object
*json_peer_group_member
=
15928 json_object_new_object();
15930 json_object_string_add(json_peer_group_member
,
15931 "status", peer_status
);
15934 json_object_boolean_true_add(
15935 json_peer_group_member
,
15938 json_object_object_add(json_peer_group_members
,
15940 json_peer_group_member
);
15942 vty_out(vty
, " %s %s %s \n", peer
->host
,
15943 dynamic
? "(dynamic)" : "",
15948 json_object_object_add(json_peer_group
, "members",
15949 json_peer_group_members
);
15953 json_object_object_add(json
, group
->name
, json_peer_group
);
15955 return CMD_SUCCESS
;
15958 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15959 const char *group_name
, bool uj
)
15962 struct listnode
*node
, *nnode
;
15963 struct peer_group
*group
;
15964 bool found
= false;
15965 json_object
*json
= NULL
;
15968 json
= json_object_new_object();
15970 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15974 vty_json(vty
, json
);
15976 vty_out(vty
, "%% BGP instance not found\n");
15978 return CMD_WARNING
;
15981 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15983 if (strmatch(group
->name
, group_name
)) {
15984 bgp_show_one_peer_group(vty
, group
, json
);
15989 bgp_show_one_peer_group(vty
, group
, json
);
15993 if (group_name
&& !found
&& !uj
)
15994 vty_out(vty
, "%% No such peer-group\n");
15997 vty_json(vty
, json
);
15999 return CMD_SUCCESS
;
16002 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16003 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16004 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16005 "Detailed information on BGP peer groups\n"
16006 "Peer group name\n" JSON_STR
)
16010 bool uj
= use_json(argc
, argv
);
16012 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16014 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16016 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16020 /* Redistribute VTY commands. */
16022 DEFUN (bgp_redistribute_ipv4
,
16023 bgp_redistribute_ipv4_cmd
,
16024 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16025 "Redistribute information from another routing protocol\n"
16026 FRR_IP_REDIST_HELP_STR_BGPD
)
16028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16029 int idx_protocol
= 1;
16032 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16034 vty_out(vty
, "%% Invalid route type\n");
16035 return CMD_WARNING_CONFIG_FAILED
;
16038 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16039 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16043 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16044 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16045 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16047 DEFUN (bgp_redistribute_ipv4_rmap
,
16048 bgp_redistribute_ipv4_rmap_cmd
,
16049 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16050 "Redistribute information from another routing protocol\n"
16051 FRR_IP_REDIST_HELP_STR_BGPD
16052 "Route map reference\n"
16053 "Pointer to route-map entries\n")
16055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16056 int idx_protocol
= 1;
16059 struct bgp_redist
*red
;
16061 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16062 vty
, argv
[idx_word
]->arg
);
16064 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16066 vty_out(vty
, "%% Invalid route type\n");
16067 return CMD_WARNING_CONFIG_FAILED
;
16070 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16072 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16073 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16077 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16078 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16079 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16080 "Route map reference\n"
16081 "Pointer to route-map entries\n")
16083 DEFUN (bgp_redistribute_ipv4_metric
,
16084 bgp_redistribute_ipv4_metric_cmd
,
16085 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16086 "Redistribute information from another routing protocol\n"
16087 FRR_IP_REDIST_HELP_STR_BGPD
16088 "Metric for redistributed routes\n"
16089 "Default metric\n")
16091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16092 int idx_protocol
= 1;
16093 int idx_number
= 3;
16096 struct bgp_redist
*red
;
16099 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16101 vty_out(vty
, "%% Invalid route type\n");
16102 return CMD_WARNING_CONFIG_FAILED
;
16104 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16106 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16107 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16108 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16112 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16113 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16114 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16115 "Metric for redistributed routes\n"
16116 "Default metric\n")
16118 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16119 bgp_redistribute_ipv4_rmap_metric_cmd
,
16120 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16121 "Redistribute information from another routing protocol\n"
16122 FRR_IP_REDIST_HELP_STR_BGPD
16123 "Route map reference\n"
16124 "Pointer to route-map entries\n"
16125 "Metric for redistributed routes\n"
16126 "Default metric\n")
16128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16129 int idx_protocol
= 1;
16131 int idx_number
= 5;
16134 struct bgp_redist
*red
;
16136 struct route_map
*route_map
=
16137 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16139 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16141 vty_out(vty
, "%% Invalid route type\n");
16142 return CMD_WARNING_CONFIG_FAILED
;
16144 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16146 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16148 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16149 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16150 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16154 bgp_redistribute_ipv4_rmap_metric
,
16155 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16156 "redistribute " FRR_IP_REDIST_STR_BGPD
16157 " route-map RMAP_NAME metric (0-4294967295)",
16158 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16159 "Route map reference\n"
16160 "Pointer to route-map entries\n"
16161 "Metric for redistributed routes\n"
16162 "Default metric\n")
16164 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16165 bgp_redistribute_ipv4_metric_rmap_cmd
,
16166 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16167 "Redistribute information from another routing protocol\n"
16168 FRR_IP_REDIST_HELP_STR_BGPD
16169 "Metric for redistributed routes\n"
16171 "Route map reference\n"
16172 "Pointer to route-map entries\n")
16174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16175 int idx_protocol
= 1;
16176 int idx_number
= 3;
16180 struct bgp_redist
*red
;
16182 struct route_map
*route_map
=
16183 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16185 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16187 vty_out(vty
, "%% Invalid route type\n");
16188 return CMD_WARNING_CONFIG_FAILED
;
16190 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16192 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16193 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16195 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16196 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16200 bgp_redistribute_ipv4_metric_rmap
,
16201 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16202 "redistribute " FRR_IP_REDIST_STR_BGPD
16203 " metric (0-4294967295) route-map RMAP_NAME",
16204 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16205 "Metric for redistributed routes\n"
16207 "Route map reference\n"
16208 "Pointer to route-map entries\n")
16210 DEFUN (bgp_redistribute_ipv4_ospf
,
16211 bgp_redistribute_ipv4_ospf_cmd
,
16212 "redistribute <ospf|table> (1-65535)",
16213 "Redistribute information from another routing protocol\n"
16214 "Open Shortest Path First (OSPFv2)\n"
16215 "Non-main Kernel Routing Table\n"
16216 "Instance ID/Table ID\n")
16218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16219 int idx_ospf_table
= 1;
16220 int idx_number
= 2;
16221 unsigned short instance
;
16222 unsigned short protocol
;
16224 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16226 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16227 protocol
= ZEBRA_ROUTE_OSPF
;
16229 protocol
= ZEBRA_ROUTE_TABLE
;
16231 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16232 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16235 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16236 "redistribute <ospf|table> (1-65535)",
16237 "Redistribute information from another routing protocol\n"
16238 "Open Shortest Path First (OSPFv2)\n"
16239 "Non-main Kernel Routing Table\n"
16240 "Instance ID/Table ID\n")
16242 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16243 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16244 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16245 "Redistribute information from another routing protocol\n"
16246 "Open Shortest Path First (OSPFv2)\n"
16247 "Non-main Kernel Routing Table\n"
16248 "Instance ID/Table ID\n"
16249 "Route map reference\n"
16250 "Pointer to route-map entries\n")
16252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16253 int idx_ospf_table
= 1;
16254 int idx_number
= 2;
16256 struct bgp_redist
*red
;
16257 unsigned short instance
;
16260 struct route_map
*route_map
=
16261 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16263 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16264 protocol
= ZEBRA_ROUTE_OSPF
;
16266 protocol
= ZEBRA_ROUTE_TABLE
;
16268 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16269 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16271 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16272 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16275 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16276 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16277 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16278 "Redistribute information from another routing protocol\n"
16279 "Open Shortest Path First (OSPFv2)\n"
16280 "Non-main Kernel Routing Table\n"
16281 "Instance ID/Table ID\n"
16282 "Route map reference\n"
16283 "Pointer to route-map entries\n")
16285 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16286 bgp_redistribute_ipv4_ospf_metric_cmd
,
16287 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16288 "Redistribute information from another routing protocol\n"
16289 "Open Shortest Path First (OSPFv2)\n"
16290 "Non-main Kernel Routing Table\n"
16291 "Instance ID/Table ID\n"
16292 "Metric for redistributed routes\n"
16293 "Default metric\n")
16295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16296 int idx_ospf_table
= 1;
16297 int idx_number
= 2;
16298 int idx_number_2
= 4;
16300 struct bgp_redist
*red
;
16301 unsigned short instance
;
16305 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16306 protocol
= ZEBRA_ROUTE_OSPF
;
16308 protocol
= ZEBRA_ROUTE_TABLE
;
16310 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16311 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16313 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16314 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16316 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16319 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16320 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16321 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16322 "Redistribute information from another routing protocol\n"
16323 "Open Shortest Path First (OSPFv2)\n"
16324 "Non-main Kernel Routing Table\n"
16325 "Instance ID/Table ID\n"
16326 "Metric for redistributed routes\n"
16327 "Default metric\n")
16329 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16330 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16331 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16332 "Redistribute information from another routing protocol\n"
16333 "Open Shortest Path First (OSPFv2)\n"
16334 "Non-main Kernel Routing Table\n"
16335 "Instance ID/Table ID\n"
16336 "Route map reference\n"
16337 "Pointer to route-map entries\n"
16338 "Metric for redistributed routes\n"
16339 "Default metric\n")
16341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16342 int idx_ospf_table
= 1;
16343 int idx_number
= 2;
16345 int idx_number_2
= 6;
16347 struct bgp_redist
*red
;
16348 unsigned short instance
;
16351 struct route_map
*route_map
=
16352 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16354 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16355 protocol
= ZEBRA_ROUTE_OSPF
;
16357 protocol
= ZEBRA_ROUTE_TABLE
;
16359 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16360 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16362 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16364 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16365 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16367 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16371 bgp_redistribute_ipv4_ospf_rmap_metric
,
16372 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16373 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16374 "Redistribute information from another routing protocol\n"
16375 "Open Shortest Path First (OSPFv2)\n"
16376 "Non-main Kernel Routing Table\n"
16377 "Instance ID/Table ID\n"
16378 "Route map reference\n"
16379 "Pointer to route-map entries\n"
16380 "Metric for redistributed routes\n"
16381 "Default metric\n")
16383 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16384 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16385 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16386 "Redistribute information from another routing protocol\n"
16387 "Open Shortest Path First (OSPFv2)\n"
16388 "Non-main Kernel Routing Table\n"
16389 "Instance ID/Table ID\n"
16390 "Metric for redistributed routes\n"
16392 "Route map reference\n"
16393 "Pointer to route-map entries\n")
16395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16396 int idx_ospf_table
= 1;
16397 int idx_number
= 2;
16398 int idx_number_2
= 4;
16401 struct bgp_redist
*red
;
16402 unsigned short instance
;
16405 struct route_map
*route_map
=
16406 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16408 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16409 protocol
= ZEBRA_ROUTE_OSPF
;
16411 protocol
= ZEBRA_ROUTE_TABLE
;
16413 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16414 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16416 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16417 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16420 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16421 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16425 bgp_redistribute_ipv4_ospf_metric_rmap
,
16426 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16427 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16428 "Redistribute information from another routing protocol\n"
16429 "Open Shortest Path First (OSPFv2)\n"
16430 "Non-main Kernel Routing Table\n"
16431 "Instance ID/Table ID\n"
16432 "Metric for redistributed routes\n"
16434 "Route map reference\n"
16435 "Pointer to route-map entries\n")
16437 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16438 no_bgp_redistribute_ipv4_ospf_cmd
,
16439 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16441 "Redistribute information from another routing protocol\n"
16442 "Open Shortest Path First (OSPFv2)\n"
16443 "Non-main Kernel Routing Table\n"
16444 "Instance ID/Table ID\n"
16445 "Metric for redistributed routes\n"
16447 "Route map reference\n"
16448 "Pointer to route-map entries\n")
16450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16451 int idx_ospf_table
= 2;
16452 int idx_number
= 3;
16453 unsigned short instance
;
16456 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16457 protocol
= ZEBRA_ROUTE_OSPF
;
16459 protocol
= ZEBRA_ROUTE_TABLE
;
16461 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16462 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16466 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16467 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16469 "Redistribute information from another routing protocol\n"
16470 "Open Shortest Path First (OSPFv2)\n"
16471 "Non-main Kernel Routing Table\n"
16472 "Instance ID/Table ID\n"
16473 "Metric for redistributed routes\n"
16475 "Route map reference\n"
16476 "Pointer to route-map entries\n")
16478 DEFUN (no_bgp_redistribute_ipv4
,
16479 no_bgp_redistribute_ipv4_cmd
,
16480 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16482 "Redistribute information from another routing protocol\n"
16483 FRR_IP_REDIST_HELP_STR_BGPD
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_protocol
= 2;
16493 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16495 vty_out(vty
, "%% Invalid route type\n");
16496 return CMD_WARNING_CONFIG_FAILED
;
16498 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16502 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16503 "no redistribute " FRR_IP_REDIST_STR_BGPD
16504 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16506 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16507 "Metric for redistributed routes\n"
16509 "Route map reference\n"
16510 "Pointer to route-map entries\n")
16512 DEFUN (bgp_redistribute_ipv6
,
16513 bgp_redistribute_ipv6_cmd
,
16514 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16515 "Redistribute information from another routing protocol\n"
16516 FRR_IP6_REDIST_HELP_STR_BGPD
)
16518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16519 int idx_protocol
= 1;
16522 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16524 vty_out(vty
, "%% Invalid route type\n");
16525 return CMD_WARNING_CONFIG_FAILED
;
16528 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16529 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16532 DEFUN (bgp_redistribute_ipv6_rmap
,
16533 bgp_redistribute_ipv6_rmap_cmd
,
16534 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16535 "Redistribute information from another routing protocol\n"
16536 FRR_IP6_REDIST_HELP_STR_BGPD
16537 "Route map reference\n"
16538 "Pointer to route-map entries\n")
16540 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16541 int idx_protocol
= 1;
16544 struct bgp_redist
*red
;
16546 struct route_map
*route_map
=
16547 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16549 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16551 vty_out(vty
, "%% Invalid route type\n");
16552 return CMD_WARNING_CONFIG_FAILED
;
16555 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16557 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16558 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16561 DEFUN (bgp_redistribute_ipv6_metric
,
16562 bgp_redistribute_ipv6_metric_cmd
,
16563 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16564 "Redistribute information from another routing protocol\n"
16565 FRR_IP6_REDIST_HELP_STR_BGPD
16566 "Metric for redistributed routes\n"
16567 "Default metric\n")
16569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16570 int idx_protocol
= 1;
16571 int idx_number
= 3;
16574 struct bgp_redist
*red
;
16577 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16579 vty_out(vty
, "%% Invalid route type\n");
16580 return CMD_WARNING_CONFIG_FAILED
;
16582 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16584 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16585 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16586 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16589 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16590 bgp_redistribute_ipv6_rmap_metric_cmd
,
16591 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16592 "Redistribute information from another routing protocol\n"
16593 FRR_IP6_REDIST_HELP_STR_BGPD
16594 "Route map reference\n"
16595 "Pointer to route-map entries\n"
16596 "Metric for redistributed routes\n"
16597 "Default metric\n")
16599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16600 int idx_protocol
= 1;
16602 int idx_number
= 5;
16605 struct bgp_redist
*red
;
16607 struct route_map
*route_map
=
16608 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16610 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16612 vty_out(vty
, "%% Invalid route type\n");
16613 return CMD_WARNING_CONFIG_FAILED
;
16615 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16617 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16619 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16620 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16622 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16625 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16626 bgp_redistribute_ipv6_metric_rmap_cmd
,
16627 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16628 "Redistribute information from another routing protocol\n"
16629 FRR_IP6_REDIST_HELP_STR_BGPD
16630 "Metric for redistributed routes\n"
16632 "Route map reference\n"
16633 "Pointer to route-map entries\n")
16635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16636 int idx_protocol
= 1;
16637 int idx_number
= 3;
16641 struct bgp_redist
*red
;
16643 struct route_map
*route_map
=
16644 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16646 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16648 vty_out(vty
, "%% Invalid route type\n");
16649 return CMD_WARNING_CONFIG_FAILED
;
16651 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16653 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16654 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16657 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16658 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16661 DEFUN (no_bgp_redistribute_ipv6
,
16662 no_bgp_redistribute_ipv6_cmd
,
16663 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16665 "Redistribute information from another routing protocol\n"
16666 FRR_IP6_REDIST_HELP_STR_BGPD
16667 "Metric for redistributed routes\n"
16669 "Route map reference\n"
16670 "Pointer to route-map entries\n")
16672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16673 int idx_protocol
= 2;
16676 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16678 vty_out(vty
, "%% Invalid route type\n");
16679 return CMD_WARNING_CONFIG_FAILED
;
16682 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16685 /* Neighbor update tcp-mss. */
16686 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16687 const char *tcp_mss_str
)
16690 uint32_t tcp_mss_val
= 0;
16692 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16694 return CMD_WARNING_CONFIG_FAILED
;
16697 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16698 peer_tcp_mss_set(peer
, tcp_mss_val
);
16700 peer_tcp_mss_unset(peer
);
16703 return CMD_SUCCESS
;
16706 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16707 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16708 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16709 "TCP max segment size\n"
16712 int peer_index
= 1;
16716 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16717 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16718 argv
[mss_index
]->arg
);
16721 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16722 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16723 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16724 "TCP max segment size\n"
16727 int peer_index
= 2;
16730 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16731 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16734 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16735 "[no$no] bgp retain route-target all",
16737 "Retain BGP updates\n"
16738 "Retain BGP updates based on route-target values\n"
16739 "Retain all BGP updates\n")
16742 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16744 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16745 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16746 if (check
!= !no
) {
16748 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16749 [bgp_node_safi(vty
)],
16750 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16752 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16753 [bgp_node_safi(vty
)],
16754 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16755 /* trigger a flush to re-sync with ADJ-RIB-in */
16756 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16757 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16759 return CMD_SUCCESS
;
16762 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16763 afi_t afi
, safi_t safi
)
16767 /* Unicast redistribution only. */
16768 if (safi
!= SAFI_UNICAST
)
16771 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16772 /* Redistribute BGP does not make sense. */
16773 if (i
!= ZEBRA_ROUTE_BGP
) {
16774 struct list
*red_list
;
16775 struct listnode
*node
;
16776 struct bgp_redist
*red
;
16778 red_list
= bgp
->redist
[afi
][i
];
16782 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16783 /* "redistribute" configuration. */
16784 vty_out(vty
, " redistribute %s",
16785 zebra_route_string(i
));
16787 vty_out(vty
, " %d", red
->instance
);
16788 if (red
->redist_metric_flag
)
16789 vty_out(vty
, " metric %u",
16790 red
->redist_metric
);
16791 if (red
->rmap
.name
)
16792 vty_out(vty
, " route-map %s",
16794 vty_out(vty
, "\n");
16800 /* peer-group helpers for config-write */
16802 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16804 if (!peer_group_active(peer
)) {
16805 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16806 return !CHECK_FLAG(peer
->flags
, flag
);
16808 return !!CHECK_FLAG(peer
->flags
, flag
);
16811 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16814 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16817 if (!peer_group_active(peer
)) {
16818 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16819 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16821 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16824 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16827 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16828 uint8_t type
, int direct
)
16830 struct bgp_filter
*filter
;
16832 if (peer_group_active(peer
))
16833 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16836 filter
= &peer
->filter
[afi
][safi
];
16838 case PEER_FT_DISTRIBUTE_LIST
:
16839 return !!(filter
->dlist
[direct
].name
);
16840 case PEER_FT_FILTER_LIST
:
16841 return !!(filter
->aslist
[direct
].name
);
16842 case PEER_FT_PREFIX_LIST
:
16843 return !!(filter
->plist
[direct
].name
);
16844 case PEER_FT_ROUTE_MAP
:
16845 return !!(filter
->map
[direct
].name
);
16846 case PEER_FT_UNSUPPRESS_MAP
:
16847 return !!(filter
->usmap
.name
);
16848 case PEER_FT_ADVERTISE_MAP
:
16849 return !!(filter
->advmap
.aname
16850 && ((filter
->advmap
.condition
== direct
)
16851 && filter
->advmap
.cname
));
16857 /* Return true if the addpath type is set for peer and different from
16860 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16863 enum bgp_addpath_strat type
, g_type
;
16865 type
= peer
->addpath_type
[afi
][safi
];
16867 if (type
!= BGP_ADDPATH_NONE
) {
16868 if (peer_group_active(peer
)) {
16869 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16871 if (type
!= g_type
)
16883 /* This is part of the address-family block (unicast only) */
16884 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16888 uint32_t tovpn_sid_index
= 0;
16890 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16891 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16892 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16893 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16894 bgp
->vpn_policy
[afi
]
16895 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16897 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16898 bgp
->vpn_policy
[afi
]
16899 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16901 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16902 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16903 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16904 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16907 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16908 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16910 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16913 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16914 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16915 bgp
->vpn_policy
[afi
].tovpn_label
);
16919 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16920 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16921 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16922 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16923 } else if (tovpn_sid_index
!= 0) {
16924 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16928 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16929 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16930 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16932 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16933 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16935 char buf
[PREFIX_STRLEN
];
16936 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16937 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16940 vty_out(vty
, "%*snexthop vpn export %s\n",
16944 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16945 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16947 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16948 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16950 char *b
= ecommunity_ecom2str(
16951 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16952 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16953 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16954 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16956 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16957 char *b
= ecommunity_ecom2str(
16958 bgp
->vpn_policy
[afi
]
16959 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16960 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16961 ECOMMUNITY_ROUTE_TARGET
);
16962 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16963 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16965 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16966 char *b
= ecommunity_ecom2str(
16967 bgp
->vpn_policy
[afi
]
16968 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16969 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16970 ECOMMUNITY_ROUTE_TARGET
);
16971 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16972 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16976 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16977 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16978 bgp
->vpn_policy
[afi
]
16979 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16981 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16982 char *b
= ecommunity_ecom2str(
16983 bgp
->vpn_policy
[afi
]
16984 .import_redirect_rtlist
,
16985 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16986 ECOMMUNITY_ROUTE_TARGET
);
16988 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16989 != ECOMMUNITY_SIZE
)
16990 vty_out(vty
, "%*srt6 redirect import %s\n",
16993 vty_out(vty
, "%*srt redirect import %s\n",
16995 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16999 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17000 afi_t afi
, safi_t safi
)
17002 struct bgp_filter
*filter
;
17006 filter
= &peer
->filter
[afi
][safi
];
17008 /* distribute-list. */
17009 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17011 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17012 filter
->dlist
[FILTER_IN
].name
);
17014 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17016 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17017 filter
->dlist
[FILTER_OUT
].name
);
17020 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17022 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17023 filter
->plist
[FILTER_IN
].name
);
17025 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17027 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17028 filter
->plist
[FILTER_OUT
].name
);
17031 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17032 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17033 filter
->map
[RMAP_IN
].name
);
17035 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17037 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17038 filter
->map
[RMAP_OUT
].name
);
17040 /* unsuppress-map */
17041 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17042 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17043 filter
->usmap
.name
);
17045 /* advertise-map : always applied in OUT direction*/
17046 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17047 CONDITION_NON_EXIST
))
17049 " neighbor %s advertise-map %s non-exist-map %s\n",
17050 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17052 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17054 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17055 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17058 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17060 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17061 filter
->aslist
[FILTER_IN
].name
);
17063 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17065 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17066 filter
->aslist
[FILTER_OUT
].name
);
17069 /* BGP peer configuration display function. */
17070 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17073 struct peer
*g_peer
= NULL
;
17075 int if_pg_printed
= false;
17076 int if_ras_printed
= false;
17078 /* Skip dynamic neighbors. */
17079 if (peer_dynamic_neighbor(peer
))
17083 addr
= peer
->conf_if
;
17087 /************************************
17088 ****** Global to the neighbor ******
17089 ************************************/
17090 if (peer
->conf_if
) {
17091 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17092 vty_out(vty
, " neighbor %s interface v6only", addr
);
17094 vty_out(vty
, " neighbor %s interface", addr
);
17096 if (peer_group_active(peer
)) {
17097 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17098 if_pg_printed
= true;
17099 } else if (peer
->as_type
== AS_SPECIFIED
) {
17100 vty_out(vty
, " remote-as %u", peer
->as
);
17101 if_ras_printed
= true;
17102 } else if (peer
->as_type
== AS_INTERNAL
) {
17103 vty_out(vty
, " remote-as internal");
17104 if_ras_printed
= true;
17105 } else if (peer
->as_type
== AS_EXTERNAL
) {
17106 vty_out(vty
, " remote-as external");
17107 if_ras_printed
= true;
17110 vty_out(vty
, "\n");
17113 /* remote-as and peer-group */
17114 /* peer is a member of a peer-group */
17115 if (peer_group_active(peer
)) {
17116 g_peer
= peer
->group
->conf
;
17118 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17119 if (peer
->as_type
== AS_SPECIFIED
) {
17120 vty_out(vty
, " neighbor %s remote-as %u\n",
17122 } else if (peer
->as_type
== AS_INTERNAL
) {
17124 " neighbor %s remote-as internal\n",
17126 } else if (peer
->as_type
== AS_EXTERNAL
) {
17128 " neighbor %s remote-as external\n",
17133 /* For swpX peers we displayed the peer-group
17134 * via 'neighbor swpX interface peer-group PGNAME' */
17135 if (!if_pg_printed
)
17136 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17137 peer
->group
->name
);
17140 /* peer is NOT a member of a peer-group */
17142 /* peer is a peer-group, declare the peer-group */
17143 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17144 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17147 if (!if_ras_printed
) {
17148 if (peer
->as_type
== AS_SPECIFIED
) {
17149 vty_out(vty
, " neighbor %s remote-as %u\n",
17151 } else if (peer
->as_type
== AS_INTERNAL
) {
17153 " neighbor %s remote-as internal\n",
17155 } else if (peer
->as_type
== AS_EXTERNAL
) {
17157 " neighbor %s remote-as external\n",
17164 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17165 vty_out(vty
, " neighbor %s local-as %u", addr
,
17166 peer
->change_local_as
);
17167 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17168 vty_out(vty
, " no-prepend");
17169 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17170 vty_out(vty
, " replace-as");
17171 vty_out(vty
, "\n");
17176 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17180 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17181 if (peer
->tx_shutdown_message
)
17182 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17183 peer
->tx_shutdown_message
);
17185 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17188 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17189 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17190 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17193 if (peer
->bfd_config
)
17194 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17197 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17198 vty_out(vty
, " neighbor %s password %s\n", addr
,
17201 /* neighbor solo */
17202 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17203 if (!peer_group_active(peer
)) {
17204 vty_out(vty
, " neighbor %s solo\n", addr
);
17209 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17210 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17213 /* Local interface name */
17214 if (peer
->ifname
) {
17215 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17218 /* TCP max segment size */
17219 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17220 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17223 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17224 vty_out(vty
, " neighbor %s passive\n", addr
);
17226 /* ebgp-multihop */
17227 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17228 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17229 && peer
->ttl
== MAXTTL
)) {
17230 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17231 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17237 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17238 vty_out(vty
, " neighbor %s aigp\n", addr
);
17240 /* graceful-shutdown */
17241 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17242 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17245 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17246 peer
->local_role
!= ROLE_UNDEFINED
)
17247 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17248 bgp_get_name_by_role(peer
->local_role
),
17249 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17253 /* ttl-security hops */
17254 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17255 if (!peer_group_active(peer
)
17256 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17257 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17258 addr
, peer
->gtsm_hops
);
17262 /* disable-connected-check */
17263 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17264 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17266 /* link-bw-encoding-ieee */
17267 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17268 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17271 /* extended-optional-parameters */
17272 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17273 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17276 /* enforce-first-as */
17277 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17278 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17280 /* update-source */
17281 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17282 if (peer
->update_source
)
17283 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17284 peer
->update_source
);
17285 else if (peer
->update_if
)
17286 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17290 /* advertisement-interval */
17291 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17292 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17296 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17297 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17298 peer
->keepalive
, peer
->holdtime
);
17300 /* timers connect */
17301 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17302 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17304 /* need special-case handling for changed default values due to
17305 * config profile / version (because there is no "timers bgp connect"
17306 * command, we need to save this per-peer :/)
17308 else if (!peer_group_active(peer
) && !peer
->connect
&&
17309 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17310 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17311 peer
->bgp
->default_connect_retry
);
17313 /* timers delayopen */
17314 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17315 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17317 /* Save config even though flag is not set if default values have been
17320 else if (!peer_group_active(peer
) && !peer
->delayopen
17321 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17322 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17323 peer
->bgp
->default_delayopen
);
17325 /* capability dynamic */
17326 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17327 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17329 /* capability extended-nexthop */
17330 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17331 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17334 " no neighbor %s capability extended-nexthop\n",
17336 else if (!peer
->conf_if
)
17338 " neighbor %s capability extended-nexthop\n",
17342 /* dont-capability-negotiation */
17343 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17344 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17346 /* override-capability */
17347 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17348 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17350 /* strict-capability-match */
17351 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17352 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17354 /* Sender side AS path loop detection. */
17355 if (peer
->as_path_loop_detection
)
17356 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17359 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17360 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17362 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17363 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17365 " neighbor %s graceful-restart-helper\n", addr
);
17366 } else if (CHECK_FLAG(
17367 peer
->peer_gr_new_status_flag
,
17368 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17370 " neighbor %s graceful-restart\n", addr
);
17372 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17373 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17375 peer
->peer_gr_new_status_flag
,
17376 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17377 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17383 /* BGP peer configuration display function. */
17384 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17385 struct peer
*peer
, afi_t afi
, safi_t safi
)
17387 struct peer
*g_peer
= NULL
;
17389 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17391 /* Skip dynamic neighbors. */
17392 if (peer_dynamic_neighbor(peer
))
17396 addr
= peer
->conf_if
;
17400 /************************************
17401 ****** Per AF to the neighbor ******
17402 ************************************/
17403 if (peer_group_active(peer
)) {
17404 g_peer
= peer
->group
->conf
;
17406 /* If the peer-group is active but peer is not, print a 'no
17408 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17409 vty_out(vty
, " no neighbor %s activate\n", addr
);
17412 /* If the peer-group is not active but peer is, print an
17414 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17415 vty_out(vty
, " neighbor %s activate\n", addr
);
17418 if (peer
->afc
[afi
][safi
]) {
17419 if (safi
== SAFI_ENCAP
)
17420 vty_out(vty
, " neighbor %s activate\n", addr
);
17421 else if (!bgp
->default_af
[afi
][safi
])
17422 vty_out(vty
, " neighbor %s activate\n", addr
);
17424 if (bgp
->default_af
[afi
][safi
])
17425 vty_out(vty
, " no neighbor %s activate\n",
17430 /* addpath TX knobs */
17431 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17432 switch (peer
->addpath_type
[afi
][safi
]) {
17433 case BGP_ADDPATH_ALL
:
17434 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17437 case BGP_ADDPATH_BEST_PER_AS
:
17439 " neighbor %s addpath-tx-bestpath-per-AS\n",
17442 case BGP_ADDPATH_MAX
:
17443 case BGP_ADDPATH_NONE
:
17448 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17449 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17451 /* ORF capability. */
17452 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17453 || peergroup_af_flag_check(peer
, afi
, safi
,
17454 PEER_FLAG_ORF_PREFIX_RM
)) {
17455 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17457 if (peergroup_af_flag_check(peer
, afi
, safi
,
17458 PEER_FLAG_ORF_PREFIX_SM
)
17459 && peergroup_af_flag_check(peer
, afi
, safi
,
17460 PEER_FLAG_ORF_PREFIX_RM
))
17461 vty_out(vty
, " both");
17462 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17463 PEER_FLAG_ORF_PREFIX_SM
))
17464 vty_out(vty
, " send");
17466 vty_out(vty
, " receive");
17467 vty_out(vty
, "\n");
17470 /* Route reflector client. */
17471 if (peergroup_af_flag_check(peer
, afi
, safi
,
17472 PEER_FLAG_REFLECTOR_CLIENT
)) {
17473 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17476 /* next-hop-self force */
17477 if (peergroup_af_flag_check(peer
, afi
, safi
,
17478 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17479 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17482 /* next-hop-self */
17483 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17484 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17487 /* remove-private-AS */
17488 if (peergroup_af_flag_check(peer
, afi
, safi
,
17489 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17490 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17494 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17495 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17496 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17500 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17501 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17502 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17505 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17506 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17507 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17511 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17512 vty_out(vty
, " neighbor %s as-override\n", addr
);
17515 /* send-community print. */
17516 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17517 PEER_FLAG_SEND_COMMUNITY
);
17518 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17519 PEER_FLAG_SEND_EXT_COMMUNITY
);
17520 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17521 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17523 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17524 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17527 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17530 " no neighbor %s send-community extended\n",
17534 vty_out(vty
, " no neighbor %s send-community large\n",
17538 /* Default information */
17539 if (peergroup_af_flag_check(peer
, afi
, safi
,
17540 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17541 vty_out(vty
, " neighbor %s default-originate", addr
);
17543 if (peer
->default_rmap
[afi
][safi
].name
)
17544 vty_out(vty
, " route-map %s",
17545 peer
->default_rmap
[afi
][safi
].name
);
17547 vty_out(vty
, "\n");
17550 /* Soft reconfiguration inbound. */
17551 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17552 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17556 /* maximum-prefix. */
17557 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17558 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17559 peer
->pmax
[afi
][safi
]);
17561 if (peer
->pmax_threshold
[afi
][safi
]
17562 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17563 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17564 if (peer_af_flag_check(peer
, afi
, safi
,
17565 PEER_FLAG_MAX_PREFIX_WARNING
))
17566 vty_out(vty
, " warning-only");
17567 if (peer
->pmax_restart
[afi
][safi
])
17568 vty_out(vty
, " restart %u",
17569 peer
->pmax_restart
[afi
][safi
]);
17570 if (peer_af_flag_check(peer
, afi
, safi
,
17571 PEER_FLAG_MAX_PREFIX_FORCE
))
17572 vty_out(vty
, " force");
17574 vty_out(vty
, "\n");
17577 /* maximum-prefix-out */
17578 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17579 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17580 addr
, peer
->pmax_out
[afi
][safi
]);
17582 /* Route server client. */
17583 if (peergroup_af_flag_check(peer
, afi
, safi
,
17584 PEER_FLAG_RSERVER_CLIENT
)) {
17585 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17588 /* Nexthop-local unchanged. */
17589 if (peergroup_af_flag_check(peer
, afi
, safi
,
17590 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17591 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17594 /* allowas-in <1-10> */
17595 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17596 if (peer_af_flag_check(peer
, afi
, safi
,
17597 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17598 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17599 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17600 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17602 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17603 peer
->allowas_in
[afi
][safi
]);
17608 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17609 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17612 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17613 char *soo_str
= ecommunity_ecom2str(
17614 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17616 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17617 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17621 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17622 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17623 peer
->weight
[afi
][safi
]);
17626 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17628 /* atribute-unchanged. */
17629 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17630 || (safi
!= SAFI_EVPN
17631 && peer_af_flag_check(peer
, afi
, safi
,
17632 PEER_FLAG_NEXTHOP_UNCHANGED
))
17633 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17635 if (!peer_group_active(peer
)
17636 || peergroup_af_flag_check(peer
, afi
, safi
,
17637 PEER_FLAG_AS_PATH_UNCHANGED
)
17638 || peergroup_af_flag_check(peer
, afi
, safi
,
17639 PEER_FLAG_NEXTHOP_UNCHANGED
)
17640 || peergroup_af_flag_check(peer
, afi
, safi
,
17641 PEER_FLAG_MED_UNCHANGED
)) {
17644 " neighbor %s attribute-unchanged%s%s%s\n",
17646 peer_af_flag_check(peer
, afi
, safi
,
17647 PEER_FLAG_AS_PATH_UNCHANGED
)
17650 peer_af_flag_check(peer
, afi
, safi
,
17651 PEER_FLAG_NEXTHOP_UNCHANGED
)
17654 peer_af_flag_check(peer
, afi
, safi
,
17655 PEER_FLAG_MED_UNCHANGED
)
17661 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
17662 vty_out(vty
, " neighbor %s optimal-route-reflection %s\n",
17663 addr
, peer
->orr_group_name
[afi
][safi
]);
17666 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17669 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17670 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17671 vty_out(vty
, " no bgp retain route-target all\n");
17674 /* Address family based peer configuration display. */
17675 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17679 struct peer_group
*group
;
17680 struct listnode
*node
, *nnode
;
17683 vty_frame(vty
, " !\n address-family ");
17684 if (afi
== AFI_IP
) {
17685 if (safi
== SAFI_UNICAST
)
17686 vty_frame(vty
, "ipv4 unicast");
17687 else if (safi
== SAFI_LABELED_UNICAST
)
17688 vty_frame(vty
, "ipv4 labeled-unicast");
17689 else if (safi
== SAFI_MULTICAST
)
17690 vty_frame(vty
, "ipv4 multicast");
17691 else if (safi
== SAFI_MPLS_VPN
)
17692 vty_frame(vty
, "ipv4 vpn");
17693 else if (safi
== SAFI_ENCAP
)
17694 vty_frame(vty
, "ipv4 encap");
17695 else if (safi
== SAFI_FLOWSPEC
)
17696 vty_frame(vty
, "ipv4 flowspec");
17697 } else if (afi
== AFI_IP6
) {
17698 if (safi
== SAFI_UNICAST
)
17699 vty_frame(vty
, "ipv6 unicast");
17700 else if (safi
== SAFI_LABELED_UNICAST
)
17701 vty_frame(vty
, "ipv6 labeled-unicast");
17702 else if (safi
== SAFI_MULTICAST
)
17703 vty_frame(vty
, "ipv6 multicast");
17704 else if (safi
== SAFI_MPLS_VPN
)
17705 vty_frame(vty
, "ipv6 vpn");
17706 else if (safi
== SAFI_ENCAP
)
17707 vty_frame(vty
, "ipv6 encap");
17708 else if (safi
== SAFI_FLOWSPEC
)
17709 vty_frame(vty
, "ipv6 flowspec");
17710 } else if (afi
== AFI_L2VPN
) {
17711 if (safi
== SAFI_EVPN
)
17712 vty_frame(vty
, "l2vpn evpn");
17714 vty_frame(vty
, "\n");
17716 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17718 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17720 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17722 /* BGP flag dampening. */
17723 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17724 bgp_config_write_damp(vty
, afi
, safi
);
17726 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17727 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17729 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17730 /* Do not display doppelganger peers */
17731 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17732 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17735 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17736 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17738 if (safi
== SAFI_EVPN
)
17739 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17741 if (safi
== SAFI_FLOWSPEC
)
17742 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17744 if (safi
== SAFI_MPLS_VPN
)
17745 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17747 if (safi
== SAFI_UNICAST
) {
17748 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17749 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17750 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17752 vty_out(vty
, " export vpn\n");
17754 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17755 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17757 vty_out(vty
, " import vpn\n");
17759 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17760 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17763 for (ALL_LIST_ELEMENTS_RO(
17764 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17766 vty_out(vty
, " import vrf %s\n", name
);
17770 /* Optimal Route Reflection */
17771 bgp_config_write_orr(vty
, bgp
, afi
, safi
);
17773 vty_endframe(vty
, " exit-address-family\n");
17776 int bgp_config_write(struct vty
*vty
)
17779 struct peer_group
*group
;
17781 struct listnode
*node
, *nnode
;
17782 struct listnode
*mnode
, *mnnode
;
17785 uint32_t tovpn_sid_index
= 0;
17787 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17788 vty_out(vty
, "bgp route-map delay-timer %u\n",
17789 bm
->rmap_update_timer
);
17791 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17792 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17793 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17794 vty_out(vty
, " %d", bm
->v_establish_wait
);
17795 vty_out(vty
, "\n");
17798 if (bm
->wait_for_fib
)
17799 vty_out(vty
, "bgp suppress-fib-pending\n");
17801 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17802 vty_out(vty
, "bgp graceful-shutdown\n");
17804 /* No-RIB (Zebra) option flag configuration */
17805 if (bgp_option_check(BGP_OPT_NO_FIB
))
17806 vty_out(vty
, "bgp no-rib\n");
17808 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17809 vty_out(vty
, "bgp send-extra-data zebra\n");
17811 /* BGP session DSCP value */
17812 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17813 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17815 /* BGP InQ limit */
17816 if (bm
->inq_limit
!= BM_DEFAULT_INQ_LIMIT
)
17817 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17819 /* BGP configuration. */
17820 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17822 /* skip all auto created vrf as they dont have user config */
17823 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17826 /* Router bgp ASN */
17827 vty_out(vty
, "router bgp %u", bgp
->as
);
17830 vty_out(vty
, " %s %s",
17831 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17832 ? "view" : "vrf", bgp
->name
);
17833 vty_out(vty
, "\n");
17835 /* BGP fast-external-failover. */
17836 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17837 vty_out(vty
, " no bgp fast-external-failover\n");
17839 /* BGP router ID. */
17840 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17841 vty_out(vty
, " bgp router-id %pI4\n",
17842 &bgp
->router_id_static
);
17844 /* Suppress fib pending */
17845 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17846 vty_out(vty
, " bgp suppress-fib-pending\n");
17848 /* BGP log-neighbor-changes. */
17849 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17850 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17851 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17852 CHECK_FLAG(bgp
->flags
,
17853 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17857 /* BGP configuration. */
17858 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17859 vty_out(vty
, " bgp always-compare-med\n");
17861 /* RFC8212 default eBGP policy. */
17862 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17863 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17864 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17865 CHECK_FLAG(bgp
->flags
,
17866 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17870 /* draft-ietf-idr-deprecate-as-set-confed-set */
17871 if (bgp
->reject_as_sets
)
17872 vty_out(vty
, " bgp reject-as-sets\n");
17874 /* Suppress duplicate updates if the route actually not changed
17876 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17877 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17878 vty_out(vty
, " %sbgp suppress-duplicates\n",
17879 CHECK_FLAG(bgp
->flags
,
17880 BGP_FLAG_SUPPRESS_DUPLICATES
)
17884 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17886 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17887 SAVE_BGP_HARD_ADMIN_RESET
)
17888 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17889 CHECK_FLAG(bgp
->flags
,
17890 BGP_FLAG_HARD_ADMIN_RESET
)
17894 /* BGP default <afi>-<safi> */
17895 FOREACH_AFI_SAFI (afi
, safi
) {
17896 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17897 if (!bgp
->default_af
[afi
][safi
])
17898 vty_out(vty
, " no bgp default %s\n",
17899 get_bgp_default_af_flag(afi
,
17901 } else if (bgp
->default_af
[afi
][safi
])
17902 vty_out(vty
, " bgp default %s\n",
17903 get_bgp_default_af_flag(afi
, safi
));
17906 /* BGP default local-preference. */
17907 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17908 vty_out(vty
, " bgp default local-preference %u\n",
17909 bgp
->default_local_pref
);
17911 /* BGP default show-hostname */
17912 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17913 != SAVE_BGP_SHOW_HOSTNAME
)
17914 vty_out(vty
, " %sbgp default show-hostname\n",
17915 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17919 /* BGP default show-nexthop-hostname */
17920 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17921 != SAVE_BGP_SHOW_HOSTNAME
)
17922 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17923 CHECK_FLAG(bgp
->flags
,
17924 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17928 /* BGP default subgroup-pkt-queue-max. */
17929 if (bgp
->default_subgroup_pkt_queue_max
17930 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17931 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17932 bgp
->default_subgroup_pkt_queue_max
);
17934 /* BGP client-to-client reflection. */
17935 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17936 vty_out(vty
, " no bgp client-to-client reflection\n");
17938 /* BGP cluster ID. */
17939 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17940 vty_out(vty
, " bgp cluster-id %pI4\n",
17943 /* Disable ebgp connected nexthop check */
17944 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17946 " bgp disable-ebgp-connected-route-check\n");
17948 /* Confederation identifier*/
17949 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17950 vty_out(vty
, " bgp confederation identifier %u\n",
17953 /* Confederation peer */
17954 if (bgp
->confed_peers_cnt
> 0) {
17957 vty_out(vty
, " bgp confederation peers");
17959 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17960 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17962 vty_out(vty
, "\n");
17965 /* BGP deterministic-med. */
17966 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17967 != SAVE_BGP_DETERMINISTIC_MED
)
17968 vty_out(vty
, " %sbgp deterministic-med\n",
17969 CHECK_FLAG(bgp
->flags
,
17970 BGP_FLAG_DETERMINISTIC_MED
)
17974 /* BGP update-delay. */
17975 bgp_config_write_update_delay(vty
, bgp
);
17977 if (bgp
->v_maxmed_onstartup
17978 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17979 vty_out(vty
, " bgp max-med on-startup %u",
17980 bgp
->v_maxmed_onstartup
);
17981 if (bgp
->maxmed_onstartup_value
17982 != BGP_MAXMED_VALUE_DEFAULT
)
17983 vty_out(vty
, " %u",
17984 bgp
->maxmed_onstartup_value
);
17985 vty_out(vty
, "\n");
17987 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17988 vty_out(vty
, " bgp max-med administrative");
17989 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17990 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17991 vty_out(vty
, "\n");
17995 bgp_config_write_wpkt_quanta(vty
, bgp
);
17997 bgp_config_write_rpkt_quanta(vty
, bgp
);
17999 /* coalesce time */
18000 bgp_config_write_coalesce_time(vty
, bgp
);
18002 /* BGP per-instance graceful-shutdown */
18003 /* BGP-wide settings and per-instance settings are mutually
18006 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18007 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18008 vty_out(vty
, " bgp graceful-shutdown\n");
18010 /* Long-lived Graceful Restart */
18011 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18013 " bgp long-lived-graceful-restart stale-time %u\n",
18014 bgp
->llgr_stale_time
);
18016 /* BGP graceful-restart. */
18017 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18019 " bgp graceful-restart stalepath-time %u\n",
18020 bgp
->stalepath_time
);
18022 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18023 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18024 bgp
->restart_time
);
18026 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18027 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18028 vty_out(vty
, " %sbgp graceful-restart notification\n",
18029 CHECK_FLAG(bgp
->flags
,
18030 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18034 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18036 " bgp graceful-restart select-defer-time %u\n",
18037 bgp
->select_defer_time
);
18039 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18040 vty_out(vty
, " bgp graceful-restart\n");
18042 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18043 vty_out(vty
, " bgp graceful-restart-disable\n");
18045 /* BGP graceful-restart Preserve State F bit. */
18046 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18048 " bgp graceful-restart preserve-fw-state\n");
18050 /* BGP TCP keepalive */
18051 bgp_config_tcp_keepalive(vty
, bgp
);
18053 /* Stale timer for RIB */
18054 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18056 " bgp graceful-restart rib-stale-time %u\n",
18057 bgp
->rib_stale_time
);
18059 /* BGP bestpath method. */
18060 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18061 vty_out(vty
, " bgp bestpath as-path ignore\n");
18062 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18063 vty_out(vty
, " bgp bestpath as-path confed\n");
18065 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18066 if (CHECK_FLAG(bgp
->flags
,
18067 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18069 " bgp bestpath as-path multipath-relax as-set\n");
18072 " bgp bestpath as-path multipath-relax\n");
18076 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18078 " bgp route-reflector allow-outbound-policy\n");
18080 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18081 vty_out(vty
, " bgp bestpath compare-routerid\n");
18082 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18083 vty_out(vty
, " bgp bestpath aigp\n");
18084 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18085 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18086 vty_out(vty
, " bgp bestpath med");
18087 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18088 vty_out(vty
, " confed");
18089 if (CHECK_FLAG(bgp
->flags
,
18090 BGP_FLAG_MED_MISSING_AS_WORST
))
18091 vty_out(vty
, " missing-as-worst");
18092 vty_out(vty
, "\n");
18095 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18097 " bgp bestpath peer-type multipath-relax\n");
18099 /* Link bandwidth handling. */
18100 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18101 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18102 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18103 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18104 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18105 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18107 /* BGP network import check. */
18108 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18109 != SAVE_BGP_IMPORT_CHECK
)
18110 vty_out(vty
, " %sbgp network import-check\n",
18111 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18115 /* BGP timers configuration. */
18116 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18117 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18118 vty_out(vty
, " timers bgp %u %u\n",
18119 bgp
->default_keepalive
, bgp
->default_holdtime
);
18121 /* BGP minimum holdtime configuration. */
18122 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18123 && bgp
->default_min_holdtime
!= 0)
18124 vty_out(vty
, " bgp minimum-holdtime %u\n",
18125 bgp
->default_min_holdtime
);
18127 /* Conditional advertisement timer configuration */
18128 if (bgp
->condition_check_period
18129 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18131 " bgp conditional-advertisement timer %u\n",
18132 bgp
->condition_check_period
);
18135 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18136 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18139 /* Normal neighbor configuration. */
18140 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18141 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18142 bgp_config_write_peer_global(vty
, bgp
, peer
);
18145 /* listen range and limit for dynamic BGP neighbors */
18146 bgp_config_write_listen(vty
, bgp
);
18149 * BGP default autoshutdown neighbors
18151 * This must be placed after any peer and peer-group
18152 * configuration, to avoid setting all peers to shutdown after
18153 * a daemon restart, which is undesired behavior. (see #2286)
18155 if (bgp
->autoshutdown
)
18156 vty_out(vty
, " bgp default shutdown\n");
18158 /* BGP instance administrative shutdown */
18159 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18160 vty_out(vty
, " bgp shutdown\n");
18162 if (bgp
->allow_martian
)
18163 vty_out(vty
, " bgp allow-martian-nexthop\n");
18165 if (bgp
->fast_convergence
)
18166 vty_out(vty
, " bgp fast-convergence\n");
18168 if (bgp
->srv6_enabled
) {
18169 vty_frame(vty
, " !\n segment-routing srv6\n");
18170 if (strlen(bgp
->srv6_locator_name
))
18171 vty_out(vty
, " locator %s\n",
18172 bgp
->srv6_locator_name
);
18173 vty_endframe(vty
, " exit\n");
18176 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18177 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18178 vty_out(vty
, " sid vpn per-vrf export auto\n");
18179 } else if (tovpn_sid_index
!= 0) {
18180 vty_out(vty
, " sid vpn per-vrf export %d\n",
18184 /* IPv4 unicast configuration. */
18185 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18187 /* IPv4 multicast configuration. */
18188 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18190 /* IPv4 labeled-unicast configuration. */
18191 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18193 /* IPv4 VPN configuration. */
18194 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18196 /* ENCAPv4 configuration. */
18197 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18199 /* FLOWSPEC v4 configuration. */
18200 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18202 /* IPv6 unicast configuration. */
18203 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18205 /* IPv6 multicast configuration. */
18206 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18208 /* IPv6 labeled-unicast configuration. */
18209 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18210 SAFI_LABELED_UNICAST
);
18212 /* IPv6 VPN configuration. */
18213 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18215 /* ENCAPv6 configuration. */
18216 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18218 /* FLOWSPEC v6 configuration. */
18219 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18221 /* EVPN configuration. */
18222 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18224 hook_call(bgp_inst_config_write
, bgp
, vty
);
18226 #ifdef ENABLE_BGP_VNC
18227 bgp_rfapi_cfg_write(vty
, bgp
);
18230 vty_out(vty
, "exit\n");
18231 vty_out(vty
, "!\n");
18237 /* BGP node structure. */
18238 static struct cmd_node bgp_node
= {
18241 .parent_node
= CONFIG_NODE
,
18242 .prompt
= "%s(config-router)# ",
18243 .config_write
= bgp_config_write
,
18246 static struct cmd_node bgp_ipv4_unicast_node
= {
18247 .name
= "bgp ipv4 unicast",
18248 .node
= BGP_IPV4_NODE
,
18249 .parent_node
= BGP_NODE
,
18250 .prompt
= "%s(config-router-af)# ",
18254 static struct cmd_node bgp_ipv4_multicast_node
= {
18255 .name
= "bgp ipv4 multicast",
18256 .node
= BGP_IPV4M_NODE
,
18257 .parent_node
= BGP_NODE
,
18258 .prompt
= "%s(config-router-af)# ",
18262 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18263 .name
= "bgp ipv4 labeled unicast",
18264 .node
= BGP_IPV4L_NODE
,
18265 .parent_node
= BGP_NODE
,
18266 .prompt
= "%s(config-router-af)# ",
18270 static struct cmd_node bgp_ipv6_unicast_node
= {
18271 .name
= "bgp ipv6 unicast",
18272 .node
= BGP_IPV6_NODE
,
18273 .parent_node
= BGP_NODE
,
18274 .prompt
= "%s(config-router-af)# ",
18278 static struct cmd_node bgp_ipv6_multicast_node
= {
18279 .name
= "bgp ipv6 multicast",
18280 .node
= BGP_IPV6M_NODE
,
18281 .parent_node
= BGP_NODE
,
18282 .prompt
= "%s(config-router-af)# ",
18286 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18287 .name
= "bgp ipv6 labeled unicast",
18288 .node
= BGP_IPV6L_NODE
,
18289 .parent_node
= BGP_NODE
,
18290 .prompt
= "%s(config-router-af)# ",
18294 static struct cmd_node bgp_vpnv4_node
= {
18295 .name
= "bgp vpnv4",
18296 .node
= BGP_VPNV4_NODE
,
18297 .parent_node
= BGP_NODE
,
18298 .prompt
= "%s(config-router-af)# ",
18302 static struct cmd_node bgp_vpnv6_node
= {
18303 .name
= "bgp vpnv6",
18304 .node
= BGP_VPNV6_NODE
,
18305 .parent_node
= BGP_NODE
,
18306 .prompt
= "%s(config-router-af-vpnv6)# ",
18310 static struct cmd_node bgp_evpn_node
= {
18311 .name
= "bgp evpn",
18312 .node
= BGP_EVPN_NODE
,
18313 .parent_node
= BGP_NODE
,
18314 .prompt
= "%s(config-router-evpn)# ",
18318 static struct cmd_node bgp_evpn_vni_node
= {
18319 .name
= "bgp evpn vni",
18320 .node
= BGP_EVPN_VNI_NODE
,
18321 .parent_node
= BGP_EVPN_NODE
,
18322 .prompt
= "%s(config-router-af-vni)# ",
18325 static struct cmd_node bgp_flowspecv4_node
= {
18326 .name
= "bgp ipv4 flowspec",
18327 .node
= BGP_FLOWSPECV4_NODE
,
18328 .parent_node
= BGP_NODE
,
18329 .prompt
= "%s(config-router-af)# ",
18333 static struct cmd_node bgp_flowspecv6_node
= {
18334 .name
= "bgp ipv6 flowspec",
18335 .node
= BGP_FLOWSPECV6_NODE
,
18336 .parent_node
= BGP_NODE
,
18337 .prompt
= "%s(config-router-af-vpnv6)# ",
18341 static struct cmd_node bgp_srv6_node
= {
18342 .name
= "bgp srv6",
18343 .node
= BGP_SRV6_NODE
,
18344 .parent_node
= BGP_NODE
,
18345 .prompt
= "%s(config-router-srv6)# ",
18348 static void community_list_vty(void);
18350 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18353 struct peer_group
*group
;
18354 struct listnode
*lnbgp
, *lnpeer
;
18356 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18357 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18359 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18363 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18367 struct listnode
*lnbgp
, *lnpeer
;
18369 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18370 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18371 /* only provide suggestions on the appropriate input
18373 * they'll otherwise show up multiple times */
18374 enum cmd_token_type match_type
;
18375 char *name
= peer
->host
;
18377 if (peer
->conf_if
) {
18378 match_type
= VARIABLE_TKN
;
18379 name
= peer
->conf_if
;
18380 } else if (strchr(peer
->host
, ':'))
18381 match_type
= IPV6_TKN
;
18383 match_type
= IPV4_TKN
;
18385 if (token
->type
!= match_type
)
18388 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18393 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18395 bgp_ac_peer(comps
, token
);
18397 if (token
->type
== VARIABLE_TKN
)
18398 bgp_ac_peergroup(comps
, token
);
18401 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18402 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18403 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18404 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18405 {.completions
= NULL
}};
18407 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18408 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18409 {.completions
= NULL
} };
18411 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18413 static struct thread
*t_bgp_cfg
;
18415 bool bgp_config_inprocess(void)
18417 return thread_is_scheduled(t_bgp_cfg
);
18420 static void bgp_config_finish(struct thread
*t
)
18422 struct listnode
*node
;
18425 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18426 hook_call(bgp_config_end
, bgp
);
18429 static void bgp_config_start(void)
18431 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18432 THREAD_OFF(t_bgp_cfg
);
18433 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18434 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18437 /* When we receive a hook the configuration is read,
18438 * we start a timer to make sure we postpone sending
18439 * EoR before route-maps are processed.
18440 * This is especially valid if using `bgp route-map delay-timer`.
18442 static void bgp_config_end(void)
18444 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18445 uint32_t bgp_post_config_delay
=
18446 thread_is_scheduled(bm
->t_rmap_update
)
18447 ? thread_timer_remain_second(bm
->t_rmap_update
)
18448 : BGP_POST_CONFIG_DELAY_SECONDS
;
18450 /* If BGP config processing thread isn't running, then
18451 * we can return and rely it's properly handled.
18453 if (!bgp_config_inprocess())
18456 THREAD_OFF(t_bgp_cfg
);
18458 /* Start a new timer to make sure we don't send EoR
18459 * before route-maps are processed.
18461 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18462 bgp_post_config_delay
, &t_bgp_cfg
);
18465 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18468 struct interface
*ifp
;
18469 struct bgp_interface
*iifp
;
18471 FOR_ALL_INTERFACES (vrf
, ifp
) {
18476 if_vty_config_start(vty
, ifp
);
18478 if (CHECK_FLAG(iifp
->flags
,
18479 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18480 vty_out(vty
, " mpls bgp forwarding\n");
18484 if_vty_config_end(vty
);
18490 /* Configuration write function for bgpd. */
18491 static int config_write_interface(struct vty
*vty
)
18494 struct vrf
*vrf
= NULL
;
18496 /* Display all VRF aware OSPF interface configuration */
18497 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18498 write
+= config_write_interface_one(vty
, vrf
);
18504 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18505 "[no$no] mpls bgp forwarding",
18506 NO_STR MPLS_STR BGP_STR
18507 "Enable MPLS forwarding for eBGP directly connected peers\n")
18510 struct bgp_interface
*iifp
;
18512 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18515 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18516 return CMD_WARNING_CONFIG_FAILED
;
18518 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18519 if (check
!= !no
) {
18521 UNSET_FLAG(iifp
->flags
,
18522 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18524 SET_FLAG(iifp
->flags
,
18525 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18526 /* trigger a nht update on eBGP sessions */
18527 if (if_is_operative(ifp
))
18528 bgp_nht_ifp_up(ifp
);
18530 return CMD_SUCCESS
;
18533 DEFPY (bgp_inq_limit
,
18535 "bgp input-queue-limit (1-4294967295)$limit",
18537 "Set the BGP Input Queue limit for all peers when message parsing\n"
18538 "Input-Queue limit\n")
18540 bm
->inq_limit
= limit
;
18542 return CMD_SUCCESS
;
18545 DEFPY (no_bgp_inq_limit
,
18546 no_bgp_inq_limit_cmd
,
18547 "no bgp input-queue-limit [(1-4294967295)$limit]",
18550 "Set the BGP Input Queue limit for all peers when message parsing\n"
18551 "Input-Queue limit\n")
18553 bm
->inq_limit
= BM_DEFAULT_INQ_LIMIT
;
18555 return CMD_SUCCESS
;
18558 /* Initialization of BGP interface. */
18559 static void bgp_vty_if_init(void)
18561 /* Install interface node. */
18562 if_cmd_init(config_write_interface
);
18564 /* "mpls bgp forwarding" commands. */
18565 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18568 void bgp_vty_init(void)
18570 cmd_variable_handler_register(bgp_var_neighbor
);
18571 cmd_variable_handler_register(bgp_var_peergroup
);
18573 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18575 /* Install bgp top node. */
18576 install_node(&bgp_node
);
18577 install_node(&bgp_ipv4_unicast_node
);
18578 install_node(&bgp_ipv4_multicast_node
);
18579 install_node(&bgp_ipv4_labeled_unicast_node
);
18580 install_node(&bgp_ipv6_unicast_node
);
18581 install_node(&bgp_ipv6_multicast_node
);
18582 install_node(&bgp_ipv6_labeled_unicast_node
);
18583 install_node(&bgp_vpnv4_node
);
18584 install_node(&bgp_vpnv6_node
);
18585 install_node(&bgp_evpn_node
);
18586 install_node(&bgp_evpn_vni_node
);
18587 install_node(&bgp_flowspecv4_node
);
18588 install_node(&bgp_flowspecv6_node
);
18589 install_node(&bgp_srv6_node
);
18591 /* Install default VTY commands to new nodes. */
18592 install_default(BGP_NODE
);
18593 install_default(BGP_IPV4_NODE
);
18594 install_default(BGP_IPV4M_NODE
);
18595 install_default(BGP_IPV4L_NODE
);
18596 install_default(BGP_IPV6_NODE
);
18597 install_default(BGP_IPV6M_NODE
);
18598 install_default(BGP_IPV6L_NODE
);
18599 install_default(BGP_VPNV4_NODE
);
18600 install_default(BGP_VPNV6_NODE
);
18601 install_default(BGP_FLOWSPECV4_NODE
);
18602 install_default(BGP_FLOWSPECV6_NODE
);
18603 install_default(BGP_EVPN_NODE
);
18604 install_default(BGP_EVPN_VNI_NODE
);
18605 install_default(BGP_SRV6_NODE
);
18607 /* "global bgp inq-limit command */
18608 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18609 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18611 /* "bgp local-mac" hidden commands. */
18612 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18613 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18615 /* "bgp suppress-fib-pending" global */
18616 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18618 /* bgp route-map delay-timer commands. */
18619 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18620 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18622 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18624 /* bgp fast-convergence command */
18625 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18626 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18628 /* global bgp update-delay command */
18629 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18630 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18632 /* global bgp graceful-shutdown command */
18633 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18634 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18636 /* Dummy commands (Currently not supported) */
18637 install_element(BGP_NODE
, &no_synchronization_cmd
);
18638 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18640 /* "router bgp" commands. */
18641 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18643 /* "no router bgp" commands. */
18644 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18646 /* "bgp session-dscp command */
18647 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18648 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18650 /* "bgp router-id" commands. */
18651 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18652 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18654 /* "bgp suppress-fib-pending" command */
18655 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18657 /* "bgp cluster-id" commands. */
18658 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18659 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18661 /* "bgp no-rib" commands. */
18662 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18663 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18665 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18667 /* "bgp confederation" commands. */
18668 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18669 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18671 /* "bgp confederation peers" commands. */
18672 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18673 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18675 /* bgp max-med command */
18676 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18677 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18678 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18679 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18680 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18682 /* "neighbor role" commands. */
18683 install_element(BGP_NODE
, &neighbor_role_cmd
);
18684 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18685 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18687 /* "neighbor aigp" commands. */
18688 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18690 /* "neighbor graceful-shutdown" command */
18691 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18693 /* bgp disable-ebgp-connected-nh-check */
18694 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18695 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18697 /* bgp update-delay command */
18698 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18699 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18701 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18702 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18704 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18705 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18707 /* "maximum-paths" commands. */
18708 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18709 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18710 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18711 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18712 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18713 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18714 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18715 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18716 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18717 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18718 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18719 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18720 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18721 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18722 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18724 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18725 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18726 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18727 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18728 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18729 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18730 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18731 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18732 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18733 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18735 /* "timers bgp" commands. */
18736 install_element(BGP_NODE
, &bgp_timers_cmd
);
18737 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18739 /* "minimum-holdtime" commands. */
18740 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18741 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18743 /* route-map delay-timer commands - per instance for backwards compat.
18745 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18746 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18748 /* "bgp client-to-client reflection" commands */
18749 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18750 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18752 /* "bgp always-compare-med" commands */
18753 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18754 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18756 /* bgp ebgp-requires-policy */
18757 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18758 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18760 /* bgp suppress-duplicates */
18761 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18762 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18764 /* bgp reject-as-sets */
18765 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18766 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18768 /* "bgp deterministic-med" commands */
18769 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18770 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18772 /* "bgp graceful-restart" command */
18773 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18774 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18776 /* "bgp graceful-restart-disable" command */
18777 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18778 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18780 /* "neighbor a:b:c:d graceful-restart" command */
18781 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18782 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18784 /* "neighbor a:b:c:d graceful-restart-disable" command */
18785 install_element(BGP_NODE
,
18786 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18787 install_element(BGP_NODE
,
18788 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18790 /* "neighbor a:b:c:d graceful-restart-helper" command */
18791 install_element(BGP_NODE
,
18792 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18793 install_element(BGP_NODE
,
18794 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18796 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18797 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18798 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18799 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18800 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18801 install_element(BGP_NODE
,
18802 &no_bgp_graceful_restart_select_defer_time_cmd
);
18803 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18804 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18805 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18807 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18808 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18809 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18810 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18812 /* "bgp inq-limit command */
18813 install_element(BGP_NODE
, &bgp_inq_limit_cmd
);
18814 install_element(BGP_NODE
, &no_bgp_inq_limit_cmd
);
18816 /* "bgp graceful-shutdown" commands */
18817 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18818 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18820 /* "bgp hard-administrative-reset" commands */
18821 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18823 /* "bgp long-lived-graceful-restart" commands */
18824 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18825 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18827 /* "bgp fast-external-failover" commands */
18828 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18829 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18831 /* "bgp bestpath aigp" commands */
18832 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
18834 /* "bgp bestpath compare-routerid" commands */
18835 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18836 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18838 /* "bgp bestpath as-path ignore" commands */
18839 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18840 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18842 /* "bgp bestpath as-path confed" commands */
18843 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18844 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18846 /* "bgp bestpath as-path multipath-relax" commands */
18847 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18848 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18850 /* "bgp bestpath peer-type multipath-relax" commands */
18851 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18852 install_element(BGP_NODE
,
18853 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18855 /* "bgp log-neighbor-changes" commands */
18856 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18857 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18859 /* "bgp bestpath med" commands */
18860 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18861 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18863 /* "bgp bestpath bandwidth" commands */
18864 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18865 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18867 /* "no bgp default <afi>-<safi>" commands. */
18868 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18870 /* "bgp network import-check" commands. */
18871 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18872 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18873 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18875 /* "bgp default local-preference" commands. */
18876 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18877 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18879 /* bgp default show-hostname */
18880 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18881 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18883 /* bgp default show-nexthop-hostname */
18884 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18885 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18887 /* "bgp default subgroup-pkt-queue-max" commands. */
18888 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18889 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18891 /* bgp ibgp-allow-policy-mods command */
18892 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18893 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18895 /* "bgp listen limit" commands. */
18896 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18897 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18899 /* "bgp listen range" commands. */
18900 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18901 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18903 /* "bgp default shutdown" command */
18904 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18906 /* "bgp shutdown" commands */
18907 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18908 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18909 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18910 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18912 /* "neighbor remote-as" commands. */
18913 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18914 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18915 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18916 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18917 install_element(BGP_NODE
,
18918 &neighbor_interface_v6only_config_remote_as_cmd
);
18919 install_element(BGP_NODE
, &no_neighbor_cmd
);
18920 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18922 /* "neighbor peer-group" commands. */
18923 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18924 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18925 install_element(BGP_NODE
,
18926 &no_neighbor_interface_peer_group_remote_as_cmd
);
18928 /* "neighbor local-as" commands. */
18929 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18930 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18931 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18932 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18934 /* "neighbor solo" commands. */
18935 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18936 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18938 /* "neighbor password" commands. */
18939 install_element(BGP_NODE
, &neighbor_password_cmd
);
18940 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18942 /* "neighbor activate" commands. */
18943 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18944 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18945 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18946 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18947 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18948 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18949 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18950 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18951 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18952 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18953 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18954 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18956 /* "no neighbor activate" commands. */
18957 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18958 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18959 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18960 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18961 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18962 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18963 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18964 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18965 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18966 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18967 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18968 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18970 /* "neighbor peer-group" set commands. */
18971 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18972 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18973 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18974 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18975 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18976 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18977 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18978 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18979 install_element(BGP_FLOWSPECV4_NODE
,
18980 &neighbor_set_peer_group_hidden_cmd
);
18981 install_element(BGP_FLOWSPECV6_NODE
,
18982 &neighbor_set_peer_group_hidden_cmd
);
18984 /* "no neighbor peer-group unset" commands. */
18985 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18986 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18987 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18988 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18989 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18990 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18991 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18992 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18993 install_element(BGP_FLOWSPECV4_NODE
,
18994 &no_neighbor_set_peer_group_hidden_cmd
);
18995 install_element(BGP_FLOWSPECV6_NODE
,
18996 &no_neighbor_set_peer_group_hidden_cmd
);
18998 /* "neighbor softreconfiguration inbound" commands.*/
18999 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19000 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19001 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19002 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19003 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19004 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19005 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19006 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19007 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19008 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19009 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19010 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19011 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19012 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19013 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19014 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19015 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19016 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19017 install_element(BGP_FLOWSPECV4_NODE
,
19018 &neighbor_soft_reconfiguration_cmd
);
19019 install_element(BGP_FLOWSPECV4_NODE
,
19020 &no_neighbor_soft_reconfiguration_cmd
);
19021 install_element(BGP_FLOWSPECV6_NODE
,
19022 &neighbor_soft_reconfiguration_cmd
);
19023 install_element(BGP_FLOWSPECV6_NODE
,
19024 &no_neighbor_soft_reconfiguration_cmd
);
19025 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19026 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19028 /* "neighbor attribute-unchanged" commands. */
19029 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19030 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19031 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19032 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19033 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19034 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19035 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19036 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19037 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19038 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19039 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19040 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19041 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19042 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19043 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19044 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19045 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19046 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19048 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19049 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19051 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19052 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19053 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19054 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19056 /* "nexthop-local unchanged" commands */
19057 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19058 install_element(BGP_IPV6_NODE
,
19059 &no_neighbor_nexthop_local_unchanged_cmd
);
19061 /* "neighbor next-hop-self" commands. */
19062 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19063 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19064 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19065 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19066 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19067 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19068 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19069 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19070 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19071 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19072 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19073 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19074 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19075 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19076 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19077 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19078 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19079 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19080 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19081 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19083 /* "neighbor next-hop-self force" commands. */
19084 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19085 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19086 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19087 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19088 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19089 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19090 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19091 install_element(BGP_IPV4_NODE
,
19092 &no_neighbor_nexthop_self_all_hidden_cmd
);
19093 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19094 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19095 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19096 install_element(BGP_IPV4M_NODE
,
19097 &no_neighbor_nexthop_self_all_hidden_cmd
);
19098 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19099 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19100 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19101 install_element(BGP_IPV4L_NODE
,
19102 &no_neighbor_nexthop_self_all_hidden_cmd
);
19103 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19104 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19105 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19106 install_element(BGP_IPV6_NODE
,
19107 &no_neighbor_nexthop_self_all_hidden_cmd
);
19108 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19109 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19110 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19111 install_element(BGP_IPV6M_NODE
,
19112 &no_neighbor_nexthop_self_all_hidden_cmd
);
19113 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19114 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19115 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19116 install_element(BGP_IPV6L_NODE
,
19117 &no_neighbor_nexthop_self_all_hidden_cmd
);
19118 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19119 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19120 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19121 install_element(BGP_VPNV4_NODE
,
19122 &no_neighbor_nexthop_self_all_hidden_cmd
);
19123 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19124 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19125 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19126 install_element(BGP_VPNV6_NODE
,
19127 &no_neighbor_nexthop_self_all_hidden_cmd
);
19128 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19129 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19131 /* "neighbor as-override" commands. */
19132 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19133 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19134 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19135 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19136 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19137 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19138 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19139 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19140 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19141 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19142 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19143 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19144 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19145 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19146 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19147 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19148 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19149 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19151 /* "neighbor remove-private-AS" commands. */
19152 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19153 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19154 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19155 install_element(BGP_NODE
,
19156 &no_neighbor_remove_private_as_all_hidden_cmd
);
19157 install_element(BGP_NODE
,
19158 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19159 install_element(BGP_NODE
,
19160 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19161 install_element(BGP_NODE
,
19162 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19165 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19166 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19167 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19168 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19169 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19170 install_element(BGP_IPV4_NODE
,
19171 &neighbor_remove_private_as_replace_as_cmd
);
19172 install_element(BGP_IPV4_NODE
,
19173 &no_neighbor_remove_private_as_replace_as_cmd
);
19174 install_element(BGP_IPV4_NODE
,
19175 &neighbor_remove_private_as_all_replace_as_cmd
);
19176 install_element(BGP_IPV4_NODE
,
19177 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19178 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19179 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19180 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19181 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19182 install_element(BGP_IPV4M_NODE
,
19183 &neighbor_remove_private_as_replace_as_cmd
);
19184 install_element(BGP_IPV4M_NODE
,
19185 &no_neighbor_remove_private_as_replace_as_cmd
);
19186 install_element(BGP_IPV4M_NODE
,
19187 &neighbor_remove_private_as_all_replace_as_cmd
);
19188 install_element(BGP_IPV4M_NODE
,
19189 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19190 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19191 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19192 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19193 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19194 install_element(BGP_IPV4L_NODE
,
19195 &neighbor_remove_private_as_replace_as_cmd
);
19196 install_element(BGP_IPV4L_NODE
,
19197 &no_neighbor_remove_private_as_replace_as_cmd
);
19198 install_element(BGP_IPV4L_NODE
,
19199 &neighbor_remove_private_as_all_replace_as_cmd
);
19200 install_element(BGP_IPV4L_NODE
,
19201 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19202 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19203 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19204 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19205 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19206 install_element(BGP_IPV6_NODE
,
19207 &neighbor_remove_private_as_replace_as_cmd
);
19208 install_element(BGP_IPV6_NODE
,
19209 &no_neighbor_remove_private_as_replace_as_cmd
);
19210 install_element(BGP_IPV6_NODE
,
19211 &neighbor_remove_private_as_all_replace_as_cmd
);
19212 install_element(BGP_IPV6_NODE
,
19213 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19214 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19215 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19216 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19217 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19218 install_element(BGP_IPV6M_NODE
,
19219 &neighbor_remove_private_as_replace_as_cmd
);
19220 install_element(BGP_IPV6M_NODE
,
19221 &no_neighbor_remove_private_as_replace_as_cmd
);
19222 install_element(BGP_IPV6M_NODE
,
19223 &neighbor_remove_private_as_all_replace_as_cmd
);
19224 install_element(BGP_IPV6M_NODE
,
19225 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19226 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19227 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19228 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19229 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19230 install_element(BGP_IPV6L_NODE
,
19231 &neighbor_remove_private_as_replace_as_cmd
);
19232 install_element(BGP_IPV6L_NODE
,
19233 &no_neighbor_remove_private_as_replace_as_cmd
);
19234 install_element(BGP_IPV6L_NODE
,
19235 &neighbor_remove_private_as_all_replace_as_cmd
);
19236 install_element(BGP_IPV6L_NODE
,
19237 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19238 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19239 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19240 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19241 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19242 install_element(BGP_VPNV4_NODE
,
19243 &neighbor_remove_private_as_replace_as_cmd
);
19244 install_element(BGP_VPNV4_NODE
,
19245 &no_neighbor_remove_private_as_replace_as_cmd
);
19246 install_element(BGP_VPNV4_NODE
,
19247 &neighbor_remove_private_as_all_replace_as_cmd
);
19248 install_element(BGP_VPNV4_NODE
,
19249 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19250 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19251 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19252 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19253 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19254 install_element(BGP_VPNV6_NODE
,
19255 &neighbor_remove_private_as_replace_as_cmd
);
19256 install_element(BGP_VPNV6_NODE
,
19257 &no_neighbor_remove_private_as_replace_as_cmd
);
19258 install_element(BGP_VPNV6_NODE
,
19259 &neighbor_remove_private_as_all_replace_as_cmd
);
19260 install_element(BGP_VPNV6_NODE
,
19261 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19263 /* "neighbor send-community" commands.*/
19264 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19265 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19266 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19267 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19268 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19269 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19270 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19271 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19272 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19273 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19274 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19275 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19276 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19277 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19278 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19279 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19280 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19281 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19282 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19283 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19284 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19285 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19286 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19287 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19288 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19289 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19290 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19291 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19292 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19293 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19294 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19295 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19296 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19297 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19298 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19299 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19301 /* "neighbor route-reflector" commands.*/
19302 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19303 install_element(BGP_NODE
,
19304 &no_neighbor_route_reflector_client_hidden_cmd
);
19305 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19306 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19307 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19308 install_element(BGP_IPV4M_NODE
,
19309 &no_neighbor_route_reflector_client_cmd
);
19310 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19311 install_element(BGP_IPV4L_NODE
,
19312 &no_neighbor_route_reflector_client_cmd
);
19313 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19314 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19315 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19316 install_element(BGP_IPV6M_NODE
,
19317 &no_neighbor_route_reflector_client_cmd
);
19318 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19319 install_element(BGP_IPV6L_NODE
,
19320 &no_neighbor_route_reflector_client_cmd
);
19321 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19322 install_element(BGP_VPNV4_NODE
,
19323 &no_neighbor_route_reflector_client_cmd
);
19324 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19325 install_element(BGP_VPNV6_NODE
,
19326 &no_neighbor_route_reflector_client_cmd
);
19327 install_element(BGP_FLOWSPECV4_NODE
,
19328 &neighbor_route_reflector_client_cmd
);
19329 install_element(BGP_FLOWSPECV4_NODE
,
19330 &no_neighbor_route_reflector_client_cmd
);
19331 install_element(BGP_FLOWSPECV6_NODE
,
19332 &neighbor_route_reflector_client_cmd
);
19333 install_element(BGP_FLOWSPECV6_NODE
,
19334 &no_neighbor_route_reflector_client_cmd
);
19335 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19336 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19338 /* "optimal-route-reflection" commands */
19339 install_element(BGP_IPV4_NODE
, &optimal_route_reflection_cmd
);
19340 install_element(BGP_IPV4M_NODE
, &optimal_route_reflection_cmd
);
19341 install_element(BGP_IPV4L_NODE
, &optimal_route_reflection_cmd
);
19342 install_element(BGP_IPV6_NODE
, &optimal_route_reflection_cmd
);
19343 install_element(BGP_IPV6M_NODE
, &optimal_route_reflection_cmd
);
19344 install_element(BGP_IPV6L_NODE
, &optimal_route_reflection_cmd
);
19345 install_element(BGP_VPNV4_NODE
, &optimal_route_reflection_cmd
);
19346 install_element(BGP_VPNV6_NODE
, &optimal_route_reflection_cmd
);
19347 install_element(BGP_FLOWSPECV4_NODE
, &optimal_route_reflection_cmd
);
19348 install_element(BGP_FLOWSPECV6_NODE
, &optimal_route_reflection_cmd
);
19349 install_element(BGP_EVPN_NODE
, &optimal_route_reflection_cmd
);
19351 /* "neighbor optimal-route-reflection" commands */
19352 install_element(BGP_IPV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19353 install_element(BGP_IPV4M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19354 install_element(BGP_IPV4L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19355 install_element(BGP_IPV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19356 install_element(BGP_IPV6M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19357 install_element(BGP_IPV6L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19358 install_element(BGP_VPNV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19359 install_element(BGP_VPNV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19360 install_element(BGP_FLOWSPECV4_NODE
,
19361 &neighbor_optimal_route_reflection_cmd
);
19362 install_element(BGP_FLOWSPECV6_NODE
,
19363 &neighbor_optimal_route_reflection_cmd
);
19364 install_element(BGP_EVPN_NODE
, &neighbor_optimal_route_reflection_cmd
);
19366 /* "neighbor route-server" commands.*/
19367 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19368 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19369 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19370 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19371 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19372 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19373 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19374 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19375 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19376 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19377 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19378 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19379 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19380 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19381 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19382 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19383 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19384 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19385 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19386 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19387 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19388 install_element(BGP_FLOWSPECV4_NODE
,
19389 &no_neighbor_route_server_client_cmd
);
19390 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19391 install_element(BGP_FLOWSPECV6_NODE
,
19392 &no_neighbor_route_server_client_cmd
);
19394 /* "neighbor disable-addpath-rx" commands. */
19395 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19396 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19397 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19398 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19399 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19400 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19401 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19402 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19403 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19404 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19405 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19406 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19407 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19408 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19409 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19410 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19412 /* "neighbor addpath-tx-all-paths" commands.*/
19413 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19414 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19415 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19416 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19417 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19418 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19419 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19420 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19421 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19422 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19423 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19424 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19425 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19426 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19427 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19428 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19429 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19430 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19432 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19433 install_element(BGP_NODE
,
19434 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19435 install_element(BGP_NODE
,
19436 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19437 install_element(BGP_IPV4_NODE
,
19438 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19439 install_element(BGP_IPV4_NODE
,
19440 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19441 install_element(BGP_IPV4M_NODE
,
19442 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19443 install_element(BGP_IPV4M_NODE
,
19444 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19445 install_element(BGP_IPV4L_NODE
,
19446 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19447 install_element(BGP_IPV4L_NODE
,
19448 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19449 install_element(BGP_IPV6_NODE
,
19450 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19451 install_element(BGP_IPV6_NODE
,
19452 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19453 install_element(BGP_IPV6M_NODE
,
19454 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19455 install_element(BGP_IPV6M_NODE
,
19456 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19457 install_element(BGP_IPV6L_NODE
,
19458 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19459 install_element(BGP_IPV6L_NODE
,
19460 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19461 install_element(BGP_VPNV4_NODE
,
19462 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19463 install_element(BGP_VPNV4_NODE
,
19464 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19465 install_element(BGP_VPNV6_NODE
,
19466 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19467 install_element(BGP_VPNV6_NODE
,
19468 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19470 /* "neighbor sender-as-path-loop-detection" commands. */
19471 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19472 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19474 /* "neighbor passive" commands. */
19475 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19476 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19479 /* "neighbor shutdown" commands. */
19480 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19481 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19482 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19483 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19484 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19485 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19487 /* "neighbor capability extended-nexthop" commands.*/
19488 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19489 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19491 /* "neighbor capability orf prefix-list" commands.*/
19492 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19493 install_element(BGP_NODE
,
19494 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19495 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19496 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19497 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19498 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19499 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19500 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19501 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19502 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19503 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19504 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19505 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19506 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19508 /* "neighbor capability dynamic" commands.*/
19509 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19510 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19512 /* "neighbor dont-capability-negotiate" commands. */
19513 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19514 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19516 /* "neighbor ebgp-multihop" commands. */
19517 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19518 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19519 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19521 /* "neighbor disable-connected-check" commands. */
19522 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19523 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19525 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19526 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19527 install_element(BGP_NODE
,
19528 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19530 /* "neighbor extended-optional-parameters" commands. */
19531 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19532 install_element(BGP_NODE
,
19533 &no_neighbor_extended_optional_parameters_cmd
);
19535 /* "neighbor enforce-first-as" commands. */
19536 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19537 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19539 /* "neighbor description" commands. */
19540 install_element(BGP_NODE
, &neighbor_description_cmd
);
19541 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19542 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19544 /* "neighbor update-source" commands. "*/
19545 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19546 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19548 /* "neighbor default-originate" commands. */
19549 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19550 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19551 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19552 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19553 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19554 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19555 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19556 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19557 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19558 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19559 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19560 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19561 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19562 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19563 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19564 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19565 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19566 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19567 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19568 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19569 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19571 /* "neighbor port" commands. */
19572 install_element(BGP_NODE
, &neighbor_port_cmd
);
19573 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19575 /* "neighbor weight" commands. */
19576 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19577 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19579 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19580 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19581 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19582 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19583 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19584 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19585 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19586 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19587 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19588 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19589 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19590 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19591 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19592 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19593 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19594 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19596 /* "neighbor override-capability" commands. */
19597 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19598 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19600 /* "neighbor strict-capability-match" commands. */
19601 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19602 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19604 /* "neighbor timers" commands. */
19605 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19606 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19608 /* "neighbor timers connect" commands. */
19609 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19610 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19612 /* "neighbor timers delayopen" commands. */
19613 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19614 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19616 /* "neighbor advertisement-interval" commands. */
19617 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19618 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19620 /* "neighbor interface" commands. */
19621 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19622 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19624 /* "neighbor distribute" commands. */
19625 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19626 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19627 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19628 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19629 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19630 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19631 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19632 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19633 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19634 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19635 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19636 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19637 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19638 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19639 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19640 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19641 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19642 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19644 /* "neighbor prefix-list" commands. */
19645 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19646 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19647 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19648 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19649 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19650 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19651 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19652 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19653 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19654 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19655 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19656 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19657 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19658 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19659 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19660 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19661 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19662 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19663 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19664 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19665 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19666 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19668 /* "neighbor filter-list" commands. */
19669 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19670 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19671 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19672 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19673 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19674 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19675 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19676 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19677 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19678 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19679 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19680 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19681 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19682 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19683 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19684 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19685 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19686 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19687 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19688 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19689 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19690 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19692 /* "neighbor route-map" commands. */
19693 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19694 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19695 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19696 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19697 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19698 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19699 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19700 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19701 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19702 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19703 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19704 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19705 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19706 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19707 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19708 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19709 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19710 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19711 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19712 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19713 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19714 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19715 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19716 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19718 /* "neighbor unsuppress-map" commands. */
19719 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19720 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19721 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19722 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19723 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19724 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19725 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19726 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19727 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19728 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19729 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19730 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19731 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19732 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19733 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19734 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19735 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19736 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19738 /* "neighbor advertise-map" commands. */
19739 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19740 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19741 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19742 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19743 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19744 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19745 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19746 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19747 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19748 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19750 /* neighbor maximum-prefix-out commands. */
19751 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19752 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19753 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19754 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19755 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19756 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19757 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19758 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19759 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19760 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19761 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19762 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19763 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19764 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19765 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19766 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19767 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19768 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19770 /* "neighbor maximum-prefix" commands. */
19771 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19772 install_element(BGP_NODE
,
19773 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19774 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19775 install_element(BGP_NODE
,
19776 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19777 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19778 install_element(BGP_NODE
,
19779 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19780 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19781 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19782 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19783 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19784 install_element(BGP_IPV4_NODE
,
19785 &neighbor_maximum_prefix_threshold_warning_cmd
);
19786 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19787 install_element(BGP_IPV4_NODE
,
19788 &neighbor_maximum_prefix_threshold_restart_cmd
);
19789 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19790 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19791 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19792 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19793 install_element(BGP_IPV4M_NODE
,
19794 &neighbor_maximum_prefix_threshold_warning_cmd
);
19795 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19796 install_element(BGP_IPV4M_NODE
,
19797 &neighbor_maximum_prefix_threshold_restart_cmd
);
19798 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19799 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19800 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19801 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19802 install_element(BGP_IPV4L_NODE
,
19803 &neighbor_maximum_prefix_threshold_warning_cmd
);
19804 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19805 install_element(BGP_IPV4L_NODE
,
19806 &neighbor_maximum_prefix_threshold_restart_cmd
);
19807 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19808 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19809 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19810 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19811 install_element(BGP_IPV6_NODE
,
19812 &neighbor_maximum_prefix_threshold_warning_cmd
);
19813 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19814 install_element(BGP_IPV6_NODE
,
19815 &neighbor_maximum_prefix_threshold_restart_cmd
);
19816 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19817 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19818 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19819 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19820 install_element(BGP_IPV6M_NODE
,
19821 &neighbor_maximum_prefix_threshold_warning_cmd
);
19822 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19823 install_element(BGP_IPV6M_NODE
,
19824 &neighbor_maximum_prefix_threshold_restart_cmd
);
19825 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19826 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19827 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19828 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19829 install_element(BGP_IPV6L_NODE
,
19830 &neighbor_maximum_prefix_threshold_warning_cmd
);
19831 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19832 install_element(BGP_IPV6L_NODE
,
19833 &neighbor_maximum_prefix_threshold_restart_cmd
);
19834 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19835 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19836 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19837 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19838 install_element(BGP_VPNV4_NODE
,
19839 &neighbor_maximum_prefix_threshold_warning_cmd
);
19840 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19841 install_element(BGP_VPNV4_NODE
,
19842 &neighbor_maximum_prefix_threshold_restart_cmd
);
19843 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19844 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19845 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19846 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19847 install_element(BGP_VPNV6_NODE
,
19848 &neighbor_maximum_prefix_threshold_warning_cmd
);
19849 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19850 install_element(BGP_VPNV6_NODE
,
19851 &neighbor_maximum_prefix_threshold_restart_cmd
);
19852 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19854 /* "neighbor allowas-in" */
19855 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19856 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19857 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19858 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19859 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19860 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19861 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19862 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19863 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19864 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19865 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19866 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19867 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19868 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19869 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19870 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19871 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19872 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19873 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19874 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19876 /* neighbor accept-own */
19877 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19878 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19880 /* "neighbor soo" */
19881 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19882 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19883 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19884 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19885 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19886 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19887 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19888 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19889 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19890 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19891 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19892 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19893 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19894 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19895 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19896 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19897 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19898 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19900 /* address-family commands. */
19901 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19902 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19903 #ifdef KEEP_OLD_VPN_COMMANDS
19904 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19905 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19906 #endif /* KEEP_OLD_VPN_COMMANDS */
19908 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19910 /* "exit-address-family" command. */
19911 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19912 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19913 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19914 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19915 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19916 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19917 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19918 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19919 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19920 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19921 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19923 /* BGP retain all route-target */
19924 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19925 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19927 /* "clear ip bgp commands" */
19928 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19930 /* clear ip bgp prefix */
19931 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19932 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19933 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19935 /* "show [ip] bgp summary" commands. */
19936 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19937 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19938 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19939 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19940 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19941 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19942 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19944 /* "show [ip] bgp neighbors" commands. */
19945 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19947 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19949 /* "show [ip] bgp peer-group" commands. */
19950 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19952 /* "show [ip] bgp paths" commands. */
19953 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19955 /* "show [ip] bgp community" commands. */
19956 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19958 /* "show ip bgp large-community" commands. */
19959 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19960 /* "show [ip] bgp attribute-info" commands. */
19961 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19962 /* "show [ip] bgp route-leak" command */
19963 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19965 /* "redistribute" commands. */
19966 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19967 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19968 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19969 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19970 install_element(BGP_NODE
,
19971 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19972 install_element(BGP_NODE
,
19973 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19974 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19975 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19976 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19977 install_element(BGP_NODE
,
19978 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19979 install_element(BGP_NODE
,
19980 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19981 install_element(BGP_NODE
,
19982 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19983 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19984 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19985 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19986 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19987 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19988 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19989 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19990 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19991 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19992 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19993 install_element(BGP_IPV4_NODE
,
19994 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19995 install_element(BGP_IPV4_NODE
,
19996 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19997 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19998 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19999 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20000 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20001 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20002 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20004 /* import|export vpn [route-map RMAP_NAME] */
20005 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20006 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20008 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20009 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20011 /* ttl_security commands */
20012 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20013 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20015 /* "bgp tcp-keepalive" commands */
20016 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20017 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20019 /* "show [ip] bgp memory" commands. */
20020 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20022 /* "show bgp martian next-hop" */
20023 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20025 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20027 /* "show [ip] bgp views" commands. */
20028 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20030 /* "show [ip] bgp vrfs" commands. */
20031 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20033 /* Community-list. */
20034 community_list_vty();
20036 community_alias_vty();
20038 /* vpn-policy commands */
20039 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20040 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20041 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20042 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20043 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20044 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20045 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20046 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20047 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20048 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20049 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20050 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20052 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20053 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20055 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20056 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20057 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20058 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20059 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20060 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20061 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20062 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20063 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20064 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20066 /* tcp-mss command */
20067 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20068 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20070 /* srv6 commands */
20071 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20072 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20073 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20074 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20075 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20076 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20077 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20078 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20079 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20084 #include "memory.h"
20085 #include "bgp_regex.h"
20086 #include "bgp_clist.h"
20087 #include "bgp_ecommunity.h"
20089 /* VTY functions. */
20091 /* Direction value to string conversion. */
20092 static const char *community_direct_str(int direct
)
20095 case COMMUNITY_DENY
:
20097 case COMMUNITY_PERMIT
:
20104 /* Display error string. */
20105 static void community_list_perror(struct vty
*vty
, int ret
)
20108 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20109 vty_out(vty
, "%% Can't find community-list\n");
20111 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20112 vty_out(vty
, "%% Malformed community-list value\n");
20114 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20116 "%% Community name conflict, previously defined as standard community\n");
20118 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20120 "%% Community name conflict, previously defined as expanded community\n");
20125 /* "community-list" keyword help string. */
20126 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20128 /*community-list standard */
20129 DEFUN (community_list_standard
,
20130 bgp_community_list_standard_cmd
,
20131 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20134 "Community list number (standard)\n"
20135 "Add an standard community-list entry\n"
20136 "Community list name\n"
20137 "Sequence number of an entry\n"
20138 "Sequence number\n"
20139 "Specify community to reject\n"
20140 "Specify community to accept\n"
20143 char *cl_name_or_number
= NULL
;
20146 int style
= COMMUNITY_LIST_STANDARD
;
20149 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20150 seq
= argv
[idx
]->arg
;
20153 argv_find(argv
, argc
, "(1-99)", &idx
);
20154 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20155 cl_name_or_number
= argv
[idx
]->arg
;
20156 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20158 argv_find(argv
, argc
, "AA:NN", &idx
);
20159 char *str
= argv_concat(argv
, argc
, idx
);
20161 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20164 XFREE(MTYPE_TMP
, str
);
20167 /* Display error string. */
20168 community_list_perror(vty
, ret
);
20169 return CMD_WARNING_CONFIG_FAILED
;
20172 return CMD_SUCCESS
;
20175 DEFUN (no_community_list_standard_all
,
20176 no_bgp_community_list_standard_all_cmd
,
20177 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20181 "Community list number (standard)\n"
20182 "Add an standard community-list entry\n"
20183 "Community list name\n"
20184 "Sequence number of an entry\n"
20185 "Sequence number\n"
20186 "Specify community to reject\n"
20187 "Specify community to accept\n"
20190 char *cl_name_or_number
= NULL
;
20193 int style
= COMMUNITY_LIST_STANDARD
;
20197 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20198 seq
= argv
[idx
]->arg
;
20201 argv_find(argv
, argc
, "permit", &idx
);
20202 argv_find(argv
, argc
, "deny", &idx
);
20205 direct
= argv_find(argv
, argc
, "permit", &idx
)
20210 argv_find(argv
, argc
, "AA:NN", &idx
);
20211 str
= argv_concat(argv
, argc
, idx
);
20215 argv_find(argv
, argc
, "(1-99)", &idx
);
20216 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20217 cl_name_or_number
= argv
[idx
]->arg
;
20219 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20222 XFREE(MTYPE_TMP
, str
);
20225 community_list_perror(vty
, ret
);
20226 return CMD_WARNING_CONFIG_FAILED
;
20229 return CMD_SUCCESS
;
20232 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20233 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20234 NO_STR BGP_STR COMMUNITY_LIST_STR
20235 "Community list number (standard)\n"
20236 "Add an standard community-list entry\n"
20237 "Community list name\n")
20239 /*community-list expanded */
20240 DEFUN (community_list_expanded_all
,
20241 bgp_community_list_expanded_all_cmd
,
20242 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20245 "Community list number (expanded)\n"
20246 "Add an expanded community-list entry\n"
20247 "Community list name\n"
20248 "Sequence number of an entry\n"
20249 "Sequence number\n"
20250 "Specify community to reject\n"
20251 "Specify community to accept\n"
20254 char *cl_name_or_number
= NULL
;
20257 int style
= COMMUNITY_LIST_EXPANDED
;
20260 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20261 seq
= argv
[idx
]->arg
;
20265 argv_find(argv
, argc
, "(100-500)", &idx
);
20266 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20267 cl_name_or_number
= argv
[idx
]->arg
;
20268 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20270 argv_find(argv
, argc
, "AA:NN", &idx
);
20271 char *str
= argv_concat(argv
, argc
, idx
);
20273 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20276 XFREE(MTYPE_TMP
, str
);
20279 /* Display error string. */
20280 community_list_perror(vty
, ret
);
20281 return CMD_WARNING_CONFIG_FAILED
;
20284 return CMD_SUCCESS
;
20287 DEFUN (no_community_list_expanded_all
,
20288 no_bgp_community_list_expanded_all_cmd
,
20289 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20293 "Community list number (expanded)\n"
20294 "Add an expanded community-list entry\n"
20295 "Community list name\n"
20296 "Sequence number of an entry\n"
20297 "Sequence number\n"
20298 "Specify community to reject\n"
20299 "Specify community to accept\n"
20302 char *cl_name_or_number
= NULL
;
20306 int style
= COMMUNITY_LIST_EXPANDED
;
20309 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20310 seq
= argv
[idx
]->arg
;
20313 argv_find(argv
, argc
, "permit", &idx
);
20314 argv_find(argv
, argc
, "deny", &idx
);
20317 direct
= argv_find(argv
, argc
, "permit", &idx
)
20322 argv_find(argv
, argc
, "AA:NN", &idx
);
20323 str
= argv_concat(argv
, argc
, idx
);
20327 argv_find(argv
, argc
, "(100-500)", &idx
);
20328 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20329 cl_name_or_number
= argv
[idx
]->arg
;
20331 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20334 XFREE(MTYPE_TMP
, str
);
20337 community_list_perror(vty
, ret
);
20338 return CMD_WARNING_CONFIG_FAILED
;
20341 return CMD_SUCCESS
;
20344 ALIAS(no_community_list_expanded_all
,
20345 no_bgp_community_list_expanded_all_list_cmd
,
20346 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20347 NO_STR BGP_STR COMMUNITY_LIST_STR
20348 "Community list number (expanded)\n"
20349 "Add an expanded community-list entry\n"
20350 "Community list name\n")
20352 /* Return configuration string of community-list entry. */
20353 static const char *community_list_config_str(struct community_entry
*entry
)
20360 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20361 str
= community_str(entry
->u
.com
, false, false);
20362 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20363 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20365 str
= entry
->config
;
20370 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20372 struct community_entry
*entry
;
20374 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20375 if (entry
== list
->head
) {
20376 if (all_digit(list
->name
))
20377 vty_out(vty
, "Community %s list %s\n",
20378 entry
->style
== COMMUNITY_LIST_STANDARD
20380 : "(expanded) access",
20383 vty_out(vty
, "Named Community %s list %s\n",
20384 entry
->style
== COMMUNITY_LIST_STANDARD
20390 vty_out(vty
, " %s\n",
20391 community_direct_str(entry
->direct
));
20393 vty_out(vty
, " %s %s\n",
20394 community_direct_str(entry
->direct
),
20395 community_list_config_str(entry
));
20399 DEFUN (show_community_list
,
20400 show_bgp_community_list_cmd
,
20401 "show bgp community-list",
20404 "List community-list\n")
20406 struct community_list
*list
;
20407 struct community_list_master
*cm
;
20409 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20411 return CMD_SUCCESS
;
20413 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20414 community_list_show(vty
, list
);
20416 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20417 community_list_show(vty
, list
);
20419 return CMD_SUCCESS
;
20422 DEFUN (show_community_list_arg
,
20423 show_bgp_community_list_arg_cmd
,
20424 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20427 "List community-list\n"
20428 "Community-list number\n"
20429 "Community-list name\n"
20430 "Detailed information on community-list\n")
20432 int idx_comm_list
= 3;
20433 struct community_list
*list
;
20435 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20436 COMMUNITY_LIST_MASTER
);
20438 vty_out(vty
, "%% Can't find community-list\n");
20439 return CMD_WARNING
;
20442 community_list_show(vty
, list
);
20444 return CMD_SUCCESS
;
20448 * Large Community code.
20450 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20451 struct cmd_token
**argv
, int style
,
20452 int reject_all_digit_name
)
20461 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20462 seq
= argv
[idx
]->arg
;
20465 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20468 /* All digit name check. */
20470 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20471 argv_find(argv
, argc
, "(1-99)", &idx
);
20472 argv_find(argv
, argc
, "(100-500)", &idx
);
20473 cl_name
= argv
[idx
]->arg
;
20474 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20475 vty_out(vty
, "%% Community name cannot have all digits\n");
20476 return CMD_WARNING_CONFIG_FAILED
;
20480 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20481 argv_find(argv
, argc
, "LINE", &idx
);
20482 /* Concat community string argument. */
20484 str
= argv_concat(argv
, argc
, idx
);
20488 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20490 /* Free temporary community list string allocated by
20492 XFREE(MTYPE_TMP
, str
);
20495 community_list_perror(vty
, ret
);
20496 return CMD_WARNING_CONFIG_FAILED
;
20498 return CMD_SUCCESS
;
20501 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20502 struct cmd_token
**argv
, int style
)
20510 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20511 seq
= argv
[idx
]->arg
;
20514 argv_find(argv
, argc
, "permit", &idx
);
20515 argv_find(argv
, argc
, "deny", &idx
);
20518 /* Check the list direct. */
20519 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20520 direct
= COMMUNITY_PERMIT
;
20522 direct
= COMMUNITY_DENY
;
20525 argv_find(argv
, argc
, "LINE", &idx
);
20526 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20527 /* Concat community string argument. */
20528 str
= argv_concat(argv
, argc
, idx
);
20532 argv_find(argv
, argc
, "(1-99)", &idx
);
20533 argv_find(argv
, argc
, "(100-500)", &idx
);
20534 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20536 /* Unset community list. */
20537 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20540 /* Free temporary community list string allocated by
20542 XFREE(MTYPE_TMP
, str
);
20545 community_list_perror(vty
, ret
);
20546 return CMD_WARNING_CONFIG_FAILED
;
20549 return CMD_SUCCESS
;
20552 /* "large-community-list" keyword help string. */
20553 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20554 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20556 DEFUN (lcommunity_list_standard
,
20557 bgp_lcommunity_list_standard_cmd
,
20558 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20560 LCOMMUNITY_LIST_STR
20561 "Large Community list number (standard)\n"
20562 "Sequence number of an entry\n"
20563 "Sequence number\n"
20564 "Specify large community to reject\n"
20565 "Specify large community to accept\n"
20566 LCOMMUNITY_VAL_STR
)
20568 return lcommunity_list_set_vty(vty
, argc
, argv
,
20569 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20572 DEFUN (lcommunity_list_expanded
,
20573 bgp_lcommunity_list_expanded_cmd
,
20574 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20576 LCOMMUNITY_LIST_STR
20577 "Large Community list number (expanded)\n"
20578 "Sequence number of an entry\n"
20579 "Sequence number\n"
20580 "Specify large community to reject\n"
20581 "Specify large community to accept\n"
20582 "An ordered list as a regular-expression\n")
20584 return lcommunity_list_set_vty(vty
, argc
, argv
,
20585 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20588 DEFUN (lcommunity_list_name_standard
,
20589 bgp_lcommunity_list_name_standard_cmd
,
20590 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20592 LCOMMUNITY_LIST_STR
20593 "Specify standard large-community-list\n"
20594 "Large Community list name\n"
20595 "Sequence number of an entry\n"
20596 "Sequence number\n"
20597 "Specify large community to reject\n"
20598 "Specify large community to accept\n"
20599 LCOMMUNITY_VAL_STR
)
20601 return lcommunity_list_set_vty(vty
, argc
, argv
,
20602 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20605 DEFUN (lcommunity_list_name_expanded
,
20606 bgp_lcommunity_list_name_expanded_cmd
,
20607 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20609 LCOMMUNITY_LIST_STR
20610 "Specify expanded large-community-list\n"
20611 "Large Community list name\n"
20612 "Sequence number of an entry\n"
20613 "Sequence number\n"
20614 "Specify large community to reject\n"
20615 "Specify large community to accept\n"
20616 "An ordered list as a regular-expression\n")
20618 return lcommunity_list_set_vty(vty
, argc
, argv
,
20619 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20622 DEFUN (no_lcommunity_list_all
,
20623 no_bgp_lcommunity_list_all_cmd
,
20624 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20627 LCOMMUNITY_LIST_STR
20628 "Large Community list number (standard)\n"
20629 "Large Community list number (expanded)\n"
20630 "Large Community list name\n")
20632 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20633 LARGE_COMMUNITY_LIST_STANDARD
);
20636 DEFUN (no_lcommunity_list_name_standard_all
,
20637 no_bgp_lcommunity_list_name_standard_all_cmd
,
20638 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20641 LCOMMUNITY_LIST_STR
20642 "Specify standard large-community-list\n"
20643 "Large Community list name\n")
20645 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20646 LARGE_COMMUNITY_LIST_STANDARD
);
20649 DEFUN (no_lcommunity_list_name_expanded_all
,
20650 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20651 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20654 LCOMMUNITY_LIST_STR
20655 "Specify expanded large-community-list\n"
20656 "Large Community list name\n")
20658 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20659 LARGE_COMMUNITY_LIST_EXPANDED
);
20662 DEFUN (no_lcommunity_list_standard
,
20663 no_bgp_lcommunity_list_standard_cmd
,
20664 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20667 LCOMMUNITY_LIST_STR
20668 "Large Community list number (standard)\n"
20669 "Sequence number of an entry\n"
20670 "Sequence number\n"
20671 "Specify large community to reject\n"
20672 "Specify large community to accept\n"
20673 LCOMMUNITY_VAL_STR
)
20675 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20676 LARGE_COMMUNITY_LIST_STANDARD
);
20679 DEFUN (no_lcommunity_list_expanded
,
20680 no_bgp_lcommunity_list_expanded_cmd
,
20681 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20684 LCOMMUNITY_LIST_STR
20685 "Large Community list number (expanded)\n"
20686 "Sequence number of an entry\n"
20687 "Sequence number\n"
20688 "Specify large community to reject\n"
20689 "Specify large community to accept\n"
20690 "An ordered list as a regular-expression\n")
20692 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20693 LARGE_COMMUNITY_LIST_EXPANDED
);
20696 DEFUN (no_lcommunity_list_name_standard
,
20697 no_bgp_lcommunity_list_name_standard_cmd
,
20698 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20701 LCOMMUNITY_LIST_STR
20702 "Specify standard large-community-list\n"
20703 "Large Community list name\n"
20704 "Sequence number of an entry\n"
20705 "Sequence number\n"
20706 "Specify large community to reject\n"
20707 "Specify large community to accept\n"
20708 LCOMMUNITY_VAL_STR
)
20710 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20711 LARGE_COMMUNITY_LIST_STANDARD
);
20714 DEFUN (no_lcommunity_list_name_expanded
,
20715 no_bgp_lcommunity_list_name_expanded_cmd
,
20716 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20719 LCOMMUNITY_LIST_STR
20720 "Specify expanded large-community-list\n"
20721 "Large community list name\n"
20722 "Sequence number of an entry\n"
20723 "Sequence number\n"
20724 "Specify large community to reject\n"
20725 "Specify large community to accept\n"
20726 "An ordered list as a regular-expression\n")
20728 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20729 LARGE_COMMUNITY_LIST_EXPANDED
);
20732 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20734 struct community_entry
*entry
;
20736 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20737 if (entry
== list
->head
) {
20738 if (all_digit(list
->name
))
20739 vty_out(vty
, "Large community %s list %s\n",
20741 LARGE_COMMUNITY_LIST_STANDARD
20743 : "(expanded) access",
20747 "Named large community %s list %s\n",
20749 LARGE_COMMUNITY_LIST_STANDARD
20755 vty_out(vty
, " %s\n",
20756 community_direct_str(entry
->direct
));
20758 vty_out(vty
, " %s %s\n",
20759 community_direct_str(entry
->direct
),
20760 community_list_config_str(entry
));
20764 DEFUN (show_lcommunity_list
,
20765 show_bgp_lcommunity_list_cmd
,
20766 "show bgp large-community-list",
20769 "List large-community list\n")
20771 struct community_list
*list
;
20772 struct community_list_master
*cm
;
20774 cm
= community_list_master_lookup(bgp_clist
,
20775 LARGE_COMMUNITY_LIST_MASTER
);
20777 return CMD_SUCCESS
;
20779 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20780 lcommunity_list_show(vty
, list
);
20782 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20783 lcommunity_list_show(vty
, list
);
20785 return CMD_SUCCESS
;
20788 DEFUN (show_lcommunity_list_arg
,
20789 show_bgp_lcommunity_list_arg_cmd
,
20790 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20793 "List large-community list\n"
20794 "Large-community-list number\n"
20795 "Large-community-list name\n"
20796 "Detailed information on large-community-list\n")
20798 struct community_list
*list
;
20800 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20801 LARGE_COMMUNITY_LIST_MASTER
);
20803 vty_out(vty
, "%% Can't find large-community-list\n");
20804 return CMD_WARNING
;
20807 lcommunity_list_show(vty
, list
);
20809 return CMD_SUCCESS
;
20812 /* "extcommunity-list" keyword help string. */
20813 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20814 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20816 DEFUN (extcommunity_list_standard
,
20817 bgp_extcommunity_list_standard_cmd
,
20818 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20820 EXTCOMMUNITY_LIST_STR
20821 "Extended Community list number (standard)\n"
20822 "Specify standard extcommunity-list\n"
20823 "Community list name\n"
20824 "Sequence number of an entry\n"
20825 "Sequence number\n"
20826 "Specify community to reject\n"
20827 "Specify community to accept\n"
20828 EXTCOMMUNITY_VAL_STR
)
20830 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20832 char *cl_number_or_name
= NULL
;
20837 argv_find(argv
, argc
, "(1-99)", &idx
);
20838 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20839 cl_number_or_name
= argv
[idx
]->arg
;
20841 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20842 seq
= argv
[idx
]->arg
;
20844 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20846 argv_find(argv
, argc
, "AA:NN", &idx
);
20847 char *str
= argv_concat(argv
, argc
, idx
);
20849 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20852 XFREE(MTYPE_TMP
, str
);
20855 community_list_perror(vty
, ret
);
20856 return CMD_WARNING_CONFIG_FAILED
;
20859 return CMD_SUCCESS
;
20862 DEFUN (extcommunity_list_name_expanded
,
20863 bgp_extcommunity_list_name_expanded_cmd
,
20864 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20866 EXTCOMMUNITY_LIST_STR
20867 "Extended Community list number (expanded)\n"
20868 "Specify expanded extcommunity-list\n"
20869 "Extended Community list name\n"
20870 "Sequence number of an entry\n"
20871 "Sequence number\n"
20872 "Specify community to reject\n"
20873 "Specify community to accept\n"
20874 "An ordered list as a regular-expression\n")
20876 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20878 char *cl_number_or_name
= NULL
;
20882 argv_find(argv
, argc
, "(100-500)", &idx
);
20883 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20884 cl_number_or_name
= argv
[idx
]->arg
;
20886 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20887 seq
= argv
[idx
]->arg
;
20889 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20891 argv_find(argv
, argc
, "LINE", &idx
);
20892 char *str
= argv_concat(argv
, argc
, idx
);
20894 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20897 XFREE(MTYPE_TMP
, str
);
20900 community_list_perror(vty
, ret
);
20901 return CMD_WARNING_CONFIG_FAILED
;
20904 return CMD_SUCCESS
;
20907 DEFUN (no_extcommunity_list_standard_all
,
20908 no_bgp_extcommunity_list_standard_all_cmd
,
20909 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20912 EXTCOMMUNITY_LIST_STR
20913 "Extended Community list number (standard)\n"
20914 "Specify standard extcommunity-list\n"
20915 "Community list name\n"
20916 "Sequence number of an entry\n"
20917 "Sequence number\n"
20918 "Specify community to reject\n"
20919 "Specify community to accept\n"
20920 EXTCOMMUNITY_VAL_STR
)
20922 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20924 char *cl_number_or_name
= NULL
;
20929 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20930 seq
= argv
[idx
]->arg
;
20933 argv_find(argv
, argc
, "permit", &idx
);
20934 argv_find(argv
, argc
, "deny", &idx
);
20936 direct
= argv_find(argv
, argc
, "permit", &idx
)
20941 argv_find(argv
, argc
, "AA:NN", &idx
);
20942 str
= argv_concat(argv
, argc
, idx
);
20946 argv_find(argv
, argc
, "(1-99)", &idx
);
20947 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20948 cl_number_or_name
= argv
[idx
]->arg
;
20950 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20951 seq
, direct
, style
);
20953 XFREE(MTYPE_TMP
, str
);
20956 community_list_perror(vty
, ret
);
20957 return CMD_WARNING_CONFIG_FAILED
;
20960 return CMD_SUCCESS
;
20963 ALIAS(no_extcommunity_list_standard_all
,
20964 no_bgp_extcommunity_list_standard_all_list_cmd
,
20965 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20966 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20967 "Extended Community list number (standard)\n"
20968 "Specify standard extcommunity-list\n"
20969 "Community list name\n")
20971 DEFUN (no_extcommunity_list_expanded_all
,
20972 no_bgp_extcommunity_list_expanded_all_cmd
,
20973 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20976 EXTCOMMUNITY_LIST_STR
20977 "Extended Community list number (expanded)\n"
20978 "Specify expanded extcommunity-list\n"
20979 "Extended Community list name\n"
20980 "Sequence number of an entry\n"
20981 "Sequence number\n"
20982 "Specify community to reject\n"
20983 "Specify community to accept\n"
20984 "An ordered list as a regular-expression\n")
20986 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20988 char *cl_number_or_name
= NULL
;
20993 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20994 seq
= argv
[idx
]->arg
;
20997 argv_find(argv
, argc
, "permit", &idx
);
20998 argv_find(argv
, argc
, "deny", &idx
);
21001 direct
= argv_find(argv
, argc
, "permit", &idx
)
21006 argv_find(argv
, argc
, "LINE", &idx
);
21007 str
= argv_concat(argv
, argc
, idx
);
21011 argv_find(argv
, argc
, "(100-500)", &idx
);
21012 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21013 cl_number_or_name
= argv
[idx
]->arg
;
21015 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21016 seq
, direct
, style
);
21018 XFREE(MTYPE_TMP
, str
);
21021 community_list_perror(vty
, ret
);
21022 return CMD_WARNING_CONFIG_FAILED
;
21025 return CMD_SUCCESS
;
21028 ALIAS(no_extcommunity_list_expanded_all
,
21029 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21030 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21031 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21032 "Extended Community list number (expanded)\n"
21033 "Specify expanded extcommunity-list\n"
21034 "Extended Community list name\n")
21036 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21038 struct community_entry
*entry
;
21040 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21041 if (entry
== list
->head
) {
21042 if (all_digit(list
->name
))
21043 vty_out(vty
, "Extended community %s list %s\n",
21044 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21046 : "(expanded) access",
21050 "Named extended community %s list %s\n",
21051 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21057 vty_out(vty
, " %s\n",
21058 community_direct_str(entry
->direct
));
21060 vty_out(vty
, " %s %s\n",
21061 community_direct_str(entry
->direct
),
21062 community_list_config_str(entry
));
21066 DEFUN (show_extcommunity_list
,
21067 show_bgp_extcommunity_list_cmd
,
21068 "show bgp extcommunity-list",
21071 "List extended-community list\n")
21073 struct community_list
*list
;
21074 struct community_list_master
*cm
;
21076 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21078 return CMD_SUCCESS
;
21080 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21081 extcommunity_list_show(vty
, list
);
21083 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21084 extcommunity_list_show(vty
, list
);
21086 return CMD_SUCCESS
;
21089 DEFUN (show_extcommunity_list_arg
,
21090 show_bgp_extcommunity_list_arg_cmd
,
21091 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21094 "List extended-community list\n"
21095 "Extcommunity-list number\n"
21096 "Extcommunity-list name\n"
21097 "Detailed information on extcommunity-list\n")
21099 int idx_comm_list
= 3;
21100 struct community_list
*list
;
21102 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21103 EXTCOMMUNITY_LIST_MASTER
);
21105 vty_out(vty
, "%% Can't find extcommunity-list\n");
21106 return CMD_WARNING
;
21109 extcommunity_list_show(vty
, list
);
21111 return CMD_SUCCESS
;
21114 /* Display community-list and extcommunity-list configuration. */
21115 static int community_list_config_write(struct vty
*vty
)
21117 struct community_list
*list
;
21118 struct community_entry
*entry
;
21119 struct community_list_master
*cm
;
21122 /* Community-list. */
21123 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21125 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21126 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21128 "bgp community-list %s seq %" PRId64
" %s %s\n",
21129 list
->name
, entry
->seq
,
21130 community_direct_str(entry
->direct
),
21131 community_list_config_str(entry
));
21134 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21135 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21137 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21138 entry
->style
== COMMUNITY_LIST_STANDARD
21141 list
->name
, entry
->seq
,
21142 community_direct_str(entry
->direct
),
21143 community_list_config_str(entry
));
21147 /* Extcommunity-list. */
21148 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21150 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21151 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21153 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21154 list
->name
, entry
->seq
,
21155 community_direct_str(entry
->direct
),
21156 community_list_config_str(entry
));
21159 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21160 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21162 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21163 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21166 list
->name
, entry
->seq
,
21167 community_direct_str(entry
->direct
),
21168 community_list_config_str(entry
));
21173 /* lcommunity-list. */
21174 cm
= community_list_master_lookup(bgp_clist
,
21175 LARGE_COMMUNITY_LIST_MASTER
);
21177 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21178 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21180 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21181 list
->name
, entry
->seq
,
21182 community_direct_str(entry
->direct
),
21183 community_list_config_str(entry
));
21186 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21187 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21189 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21191 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21194 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21195 community_list_config_str(entry
));
21202 static int community_list_config_write(struct vty
*vty
);
21203 static struct cmd_node community_list_node
= {
21204 .name
= "community list",
21205 .node
= COMMUNITY_LIST_NODE
,
21207 .config_write
= community_list_config_write
,
21210 static void community_list_vty(void)
21212 install_node(&community_list_node
);
21214 /* Community-list. */
21215 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21216 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21217 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21218 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21219 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21220 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21221 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21222 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21224 /* Extcommunity-list. */
21225 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21226 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21227 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21228 install_element(CONFIG_NODE
,
21229 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21230 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21231 install_element(CONFIG_NODE
,
21232 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21233 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21234 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21236 /* Large Community List */
21237 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21238 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21239 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21240 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21241 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21242 install_element(CONFIG_NODE
,
21243 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21244 install_element(CONFIG_NODE
,
21245 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21246 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21247 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21248 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21249 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21250 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21251 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21253 bgp_community_list_command_completion_setup();
21256 static struct cmd_node community_alias_node
= {
21257 .name
= "community alias",
21258 .node
= COMMUNITY_ALIAS_NODE
,
21260 .config_write
= bgp_community_alias_write
,
21263 void community_alias_vty(void)
21265 install_node(&community_alias_node
);
21267 /* Community-list. */
21268 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21270 bgp_community_alias_command_completion_setup();