2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
163 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
166 afi_t afi
, bool use_json
);
168 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
174 return BGP_IPV4_NODE
;
176 return BGP_IPV4M_NODE
;
177 case SAFI_LABELED_UNICAST
:
178 return BGP_IPV4L_NODE
;
180 return BGP_VPNV4_NODE
;
182 return BGP_FLOWSPECV4_NODE
;
185 return BGP_IPV4_NODE
;
190 return BGP_IPV6_NODE
;
192 return BGP_IPV6M_NODE
;
193 case SAFI_LABELED_UNICAST
:
194 return BGP_IPV6L_NODE
;
196 return BGP_VPNV6_NODE
;
198 return BGP_FLOWSPECV6_NODE
;
201 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* unset srv6 locator */
294 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
297 struct listnode
*node
, *nnode
;
298 struct srv6_locator_chunk
*chunk
, *tovpn_sid_locator
;
299 struct bgp_srv6_function
*func
;
302 /* release chunk notification via ZAPI */
303 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
304 bgp
->srv6_locator_name
);
309 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
310 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
311 srv6_locator_chunk_free(chunk
);
314 /* refresh functions */
315 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
316 listnode_delete(bgp
->srv6_functions
, func
);
317 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
320 /* refresh tovpn_sid */
321 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
322 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
325 /* refresh vpnv4 tovpn_sid */
326 XFREE(MTYPE_BGP_SRV6_SID
,
327 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
329 /* refresh vpnv6 tovpn_sid */
330 XFREE(MTYPE_BGP_SRV6_SID
,
331 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
334 /* update vpn bgp processes */
335 vpn_leak_postchange_all();
337 /* refresh tovpn_sid_locator */
338 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
339 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
342 /* refresh vpnv4 tovpn_sid_locator */
344 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
;
345 if (tovpn_sid_locator
) {
346 srv6_locator_chunk_free(tovpn_sid_locator
);
347 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
= NULL
;
350 /* refresh vpnv6 tovpn_sid_locator */
352 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
;
353 if (tovpn_sid_locator
) {
354 srv6_locator_chunk_free(tovpn_sid_locator
);
355 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
= NULL
;
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";
950 vty_out(vty
, "%% %s\n", str
);
951 return CMD_WARNING_CONFIG_FAILED
;
956 /* BGP clear sort. */
965 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
966 safi_t safi
, int error
)
969 case BGP_ERR_AF_UNCONFIGURED
:
972 "%% BGP: Enable %s address family for the neighbor %s\n",
973 get_afi_safi_str(afi
, safi
, false), peer
->host
);
976 "%% BGP: Enable %s address family for the neighbor %s",
977 get_afi_safi_str(afi
, safi
, false), peer
->host
);
979 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
982 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
986 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
994 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
995 struct listnode
**nnode
, enum bgp_clear_type stype
)
1000 /* if afi/.safi not specified, spin thru all of them */
1001 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1004 enum bgp_af_index index
;
1006 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1007 paf
= peer
->peer_af_array
[index
];
1011 if (paf
&& paf
->subgroup
)
1012 SET_FLAG(paf
->subgroup
->sflags
,
1013 SUBGRP_STATUS_FORCE_UPDATES
);
1016 tmp_safi
= paf
->safi
;
1017 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1020 if (stype
== BGP_CLEAR_SOFT_NONE
)
1021 ret
= peer_clear(peer
, nnode
);
1023 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1026 /* if afi specified and safi not, spin thru safis on this afi */
1027 } else if (safi
== SAFI_UNSPEC
) {
1030 for (tmp_safi
= SAFI_UNICAST
;
1031 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1032 if (!peer
->afc
[afi
][tmp_safi
])
1035 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1036 if (paf
&& paf
->subgroup
)
1037 SET_FLAG(paf
->subgroup
->sflags
,
1038 SUBGRP_STATUS_FORCE_UPDATES
);
1040 if (stype
== BGP_CLEAR_SOFT_NONE
)
1041 ret
= peer_clear(peer
, nnode
);
1043 ret
= peer_clear_soft(peer
, afi
,
1046 /* both afi/safi specified, let the caller know if not defined */
1048 if (!peer
->afc
[afi
][safi
])
1051 paf
= peer_af_find(peer
, afi
, safi
);
1052 if (paf
&& paf
->subgroup
)
1053 SET_FLAG(paf
->subgroup
->sflags
,
1054 SUBGRP_STATUS_FORCE_UPDATES
);
1056 if (stype
== BGP_CLEAR_SOFT_NONE
)
1057 ret
= peer_clear(peer
, nnode
);
1059 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1065 /* `clear ip bgp' functions. */
1066 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1067 enum clear_sort sort
, enum bgp_clear_type stype
,
1074 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1076 /* Clear all neighbors. */
1078 * Pass along pointer to next node to peer_clear() when walking all
1079 * nodes on the BGP instance as that may get freed if it is a
1082 if (sort
== clear_all
) {
1083 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1085 bgp_peer_gr_flags_update(peer
);
1087 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1088 gr_router_detected
= true;
1090 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1094 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1097 if (gr_router_detected
1098 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1099 bgp_zebra_send_capabilities(bgp
, false);
1100 } else if (!gr_router_detected
1101 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1102 bgp_zebra_send_capabilities(bgp
, true);
1105 /* This is to apply read-only mode on this clear. */
1106 if (stype
== BGP_CLEAR_SOFT_NONE
)
1107 bgp
->update_delay_over
= 0;
1112 /* Clear specified neighbor. */
1113 if (sort
== clear_peer
) {
1116 /* Make sockunion for lookup. */
1117 ret
= str2sockunion(arg
, &su
);
1119 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1121 peer
= peer_lookup_by_hostname(bgp
, arg
);
1124 "Malformed address or name: %s\n",
1130 peer
= peer_lookup(bgp
, &su
);
1133 "%% BGP: Unknown neighbor - \"%s\"\n",
1139 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1140 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1142 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1144 /* if afi/safi not defined for this peer, let caller know */
1146 ret
= BGP_ERR_AF_UNCONFIGURED
;
1149 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1154 /* Clear all neighbors belonging to a specific peer-group. */
1155 if (sort
== clear_group
) {
1156 struct peer_group
*group
;
1158 group
= peer_group_lookup(bgp
, arg
);
1160 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1164 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1165 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1168 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1175 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1176 get_afi_safi_str(afi
, safi
, false), arg
);
1181 /* Clear all external (eBGP) neighbors. */
1182 if (sort
== clear_external
) {
1183 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1184 if (peer
->sort
== BGP_PEER_IBGP
)
1187 bgp_peer_gr_flags_update(peer
);
1189 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1190 gr_router_detected
= true;
1192 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1195 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1200 if (gr_router_detected
1201 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1202 bgp_zebra_send_capabilities(bgp
, false);
1203 } else if (!gr_router_detected
1204 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1205 bgp_zebra_send_capabilities(bgp
, true);
1210 "%% BGP: No external %s peer is configured\n",
1211 get_afi_safi_str(afi
, safi
, false));
1216 /* Clear all neighbors belonging to a specific AS. */
1217 if (sort
== clear_as
) {
1218 as_t as
= strtoul(arg
, NULL
, 10);
1220 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1224 bgp_peer_gr_flags_update(peer
);
1226 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1227 gr_router_detected
= true;
1229 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1232 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1237 if (gr_router_detected
1238 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1239 bgp_zebra_send_capabilities(bgp
, false);
1240 } else if (!gr_router_detected
1241 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1242 bgp_zebra_send_capabilities(bgp
, true);
1247 "%% BGP: No %s peer is configured with AS %s\n",
1248 get_afi_safi_str(afi
, safi
, false), arg
);
1256 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1257 safi_t safi
, enum clear_sort sort
,
1258 enum bgp_clear_type stype
, const char *arg
)
1262 /* BGP structure lookup. */
1264 bgp
= bgp_lookup_by_name(name
);
1266 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1270 bgp
= bgp_get_default();
1272 vty_out(vty
, "No BGP process is configured\n");
1277 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1280 /* clear soft inbound */
1281 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1286 FOREACH_AFI_SAFI (afi
, safi
)
1287 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1288 BGP_CLEAR_SOFT_IN
, NULL
);
1291 /* clear soft outbound */
1292 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1297 FOREACH_AFI_SAFI (afi
, safi
)
1298 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1299 BGP_CLEAR_SOFT_OUT
, NULL
);
1303 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1305 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1308 #ifndef VTYSH_EXTRACT_PL
1309 #include "bgpd/bgp_vty_clippy.c"
1312 DEFUN_HIDDEN (bgp_local_mac
,
1314 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1316 "Local MAC config\n"
1317 "VxLAN Network Identifier\n"
1321 "mac-mobility sequence\n"
1331 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1332 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1333 vty_out(vty
, "%% Malformed MAC address\n");
1336 memset(&ip
, 0, sizeof(ip
));
1337 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1339 bgp
= bgp_get_default();
1341 vty_out(vty
, "Default BGP instance is not there\n");
1345 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1348 vty_out(vty
, "Internal error\n");
1355 DEFUN_HIDDEN (no_bgp_local_mac
,
1356 no_bgp_local_mac_cmd
,
1357 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1360 "Local MAC config\n"
1361 "VxLAN Network Identifier\n"
1372 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1373 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1374 vty_out(vty
, "%% Malformed MAC address\n");
1377 memset(&ip
, 0, sizeof(ip
));
1379 bgp
= bgp_get_default();
1381 vty_out(vty
, "Default BGP instance is not there\n");
1385 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1387 vty_out(vty
, "Internal error\n");
1394 DEFUN (no_synchronization
,
1395 no_synchronization_cmd
,
1396 "no synchronization",
1398 "Perform IGP synchronization\n")
1403 DEFUN (no_auto_summary
,
1404 no_auto_summary_cmd
,
1407 "Enable automatic network number summarization\n")
1412 /* "router bgp" commands. */
1413 DEFUN_NOSH (router_bgp
,
1415 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1419 BGP_INSTANCE_HELP_STR
)
1422 int idx_view_vrf
= 3;
1428 const char *name
= NULL
;
1429 enum bgp_instance_type inst_type
;
1431 // "router bgp" without an ASN
1433 // Pending: Make VRF option available for ASN less config
1434 bgp
= bgp_get_default();
1437 vty_out(vty
, "%% No BGP process is configured\n");
1438 return CMD_WARNING_CONFIG_FAILED
;
1441 if (listcount(bm
->bgp
) > 1) {
1442 vty_out(vty
, "%% Please specify ASN and VRF\n");
1443 return CMD_WARNING_CONFIG_FAILED
;
1449 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1451 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1452 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1453 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1455 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1457 name
= argv
[idx_vrf
]->arg
;
1459 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1460 if (strmatch(name
, VRF_DEFAULT_NAME
))
1463 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1464 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1465 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1468 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1469 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1471 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1473 case BGP_ERR_AS_MISMATCH
:
1474 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1475 return CMD_WARNING_CONFIG_FAILED
;
1476 case BGP_ERR_INSTANCE_MISMATCH
:
1478 "BGP instance name and AS number mismatch\n");
1480 "BGP instance is already running; AS is %u\n",
1482 return CMD_WARNING_CONFIG_FAILED
;
1486 * If we just instantiated the default instance, complete
1487 * any pending VRF-VPN leaking that was configured via
1488 * earlier "router bgp X vrf FOO" blocks.
1490 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1491 vpn_leak_postchange_all();
1493 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1494 bgp_vpn_leak_export(bgp
);
1495 /* Pending: handle when user tries to change a view to vrf n vv.
1499 /* unset the auto created flag as the user config is now present */
1500 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1501 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1506 /* "no router bgp" commands. */
1507 DEFUN (no_router_bgp
,
1509 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1514 BGP_INSTANCE_HELP_STR
)
1520 const char *name
= NULL
;
1522 // "no router bgp" without an ASN
1524 // Pending: Make VRF option available for ASN less config
1525 bgp
= bgp_get_default();
1528 vty_out(vty
, "%% No BGP process is configured\n");
1529 return CMD_WARNING_CONFIG_FAILED
;
1532 if (listcount(bm
->bgp
) > 1) {
1533 vty_out(vty
, "%% Please specify ASN and VRF\n");
1534 return CMD_WARNING_CONFIG_FAILED
;
1538 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1540 return CMD_WARNING_CONFIG_FAILED
;
1543 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1546 name
= argv
[idx_vrf
]->arg
;
1547 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1548 && strmatch(name
, VRF_DEFAULT_NAME
))
1552 /* Lookup bgp structure. */
1553 bgp
= bgp_lookup(as
, name
);
1555 vty_out(vty
, "%% Can't find BGP instance\n");
1556 return CMD_WARNING_CONFIG_FAILED
;
1560 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1562 return CMD_WARNING_CONFIG_FAILED
;
1565 /* Cannot delete default instance if vrf instances exist */
1566 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1567 struct listnode
*node
;
1568 struct bgp
*tmp_bgp
;
1570 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1571 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1573 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1574 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1575 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1576 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1577 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1578 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1579 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1580 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1581 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1582 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1583 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1584 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1585 (bgp
== bgp_get_evpn() &&
1586 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1587 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1588 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1589 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1590 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1591 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1592 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1593 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1594 (hashcount(tmp_bgp
->vnihash
))) {
1596 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1597 return CMD_WARNING_CONFIG_FAILED
;
1608 /* bgp session-dscp */
1610 DEFPY (bgp_session_dscp
,
1611 bgp_session_dscp_cmd
,
1612 "bgp session-dscp (0-63)$dscp",
1614 "Override default (C6) bgp TCP session DSCP value\n"
1615 "Manually configured dscp parameter\n")
1617 bm
->tcp_dscp
= dscp
<< 2;
1622 DEFPY (no_bgp_session_dscp
,
1623 no_bgp_session_dscp_cmd
,
1624 "no bgp session-dscp [(0-63)]",
1627 "Override default (C6) bgp TCP session DSCP value\n"
1628 "Manually configured dscp parameter\n")
1630 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1635 /* BGP router-id. */
1637 DEFPY (bgp_router_id
,
1639 "bgp router-id A.B.C.D",
1641 "Override configured router identifier\n"
1642 "Manually configured router identifier\n")
1644 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1645 bgp_router_id_static_set(bgp
, router_id
);
1649 DEFPY (no_bgp_router_id
,
1650 no_bgp_router_id_cmd
,
1651 "no bgp router-id [A.B.C.D]",
1654 "Override configured router identifier\n"
1655 "Manually configured router identifier\n")
1657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1659 if (router_id_str
) {
1660 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1661 vty_out(vty
, "%% BGP router-id doesn't match\n");
1662 return CMD_WARNING_CONFIG_FAILED
;
1666 router_id
.s_addr
= 0;
1667 bgp_router_id_static_set(bgp
, router_id
);
1672 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1673 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1675 "Add community specific parameters\n"
1676 "Create an alias for a community\n"
1677 "Community (AA:BB or AA:BB:CC)\n"
1680 struct community_alias ca
= {};
1681 struct community_alias
*lookup_community
;
1682 struct community_alias
*lookup_alias
;
1683 struct community
*comm
;
1684 struct lcommunity
*lcomm
;
1685 uint8_t invalid
= 0;
1687 comm
= community_str2com(community
);
1690 community_free(&comm
);
1692 lcomm
= lcommunity_str2com(community
);
1695 lcommunity_free(&lcomm
);
1698 vty_out(vty
, "Invalid community format\n");
1702 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1703 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1705 lookup_community
= bgp_ca_community_lookup(&ca
);
1706 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1709 bgp_ca_alias_delete(&ca
);
1710 bgp_ca_community_delete(&ca
);
1713 /* Lookup if community hash table has an item
1714 * with the same alias name.
1716 strlcpy(ca
.community
, lookup_alias
->community
,
1717 sizeof(ca
.community
));
1718 if (bgp_ca_community_lookup(&ca
)) {
1720 "community (%s) already has this alias (%s)\n",
1721 lookup_alias
->community
,
1722 lookup_alias
->alias
);
1725 bgp_ca_alias_delete(&ca
);
1728 if (lookup_community
) {
1729 /* Lookup if alias hash table has an item
1730 * with the same community.
1732 strlcpy(ca
.alias
, lookup_community
->alias
,
1734 if (bgp_ca_alias_lookup(&ca
)) {
1736 "alias (%s) already has this community (%s)\n",
1737 lookup_community
->alias
,
1738 lookup_community
->community
);
1741 bgp_ca_community_delete(&ca
);
1744 bgp_ca_alias_insert(&ca
);
1745 bgp_ca_community_insert(&ca
);
1751 DEFPY (bgp_global_suppress_fib_pending
,
1752 bgp_global_suppress_fib_pending_cmd
,
1753 "[no] bgp suppress-fib-pending",
1756 "Advertise only routes that are programmed in kernel to peers globally\n")
1758 bm_wait_for_fib_set(!no
);
1763 DEFPY (bgp_suppress_fib_pending
,
1764 bgp_suppress_fib_pending_cmd
,
1765 "[no] bgp suppress-fib-pending",
1768 "Advertise only routes that are programmed in kernel to peers\n")
1770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1772 bgp_suppress_fib_pending_set(bgp
, !no
);
1777 /* BGP Cluster ID. */
1778 DEFUN (bgp_cluster_id
,
1780 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1782 "Configure Route-Reflector Cluster-id\n"
1783 "Route-Reflector Cluster-id in IP address format\n"
1784 "Route-Reflector Cluster-id as 32 bit quantity\n")
1786 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1789 struct in_addr cluster
;
1791 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1793 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1794 return CMD_WARNING_CONFIG_FAILED
;
1797 bgp_cluster_id_set(bgp
, &cluster
);
1798 bgp_clear_star_soft_out(vty
, bgp
->name
);
1803 DEFUN (no_bgp_cluster_id
,
1804 no_bgp_cluster_id_cmd
,
1805 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1808 "Configure Route-Reflector Cluster-id\n"
1809 "Route-Reflector Cluster-id in IP address format\n"
1810 "Route-Reflector Cluster-id as 32 bit quantity\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1813 bgp_cluster_id_unset(bgp
);
1814 bgp_clear_star_soft_out(vty
, bgp
->name
);
1823 "Disable BGP route installation to RIB (Zebra)\n")
1825 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1827 "%% No-RIB option is already set, nothing to do here.\n");
1831 bgp_option_norib_set_runtime();
1836 DEFPY (no_bgp_norib
,
1841 "Disable BGP route installation to RIB (Zebra)\n")
1843 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1845 "%% No-RIB option is not set, nothing to do here.\n");
1849 bgp_option_norib_unset_runtime();
1854 DEFPY (no_bgp_send_extra_data
,
1855 no_bgp_send_extra_data_cmd
,
1856 "[no] bgp send-extra-data zebra",
1859 "Extra data to Zebra for display/use\n"
1863 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1865 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1870 DEFUN (bgp_confederation_identifier
,
1871 bgp_confederation_identifier_cmd
,
1872 "bgp confederation identifier (1-4294967295)",
1874 "AS confederation parameters\n"
1876 "Set routing domain confederation AS\n")
1878 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1882 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1884 bgp_confederation_id_set(bgp
, as
);
1889 DEFUN (no_bgp_confederation_identifier
,
1890 no_bgp_confederation_identifier_cmd
,
1891 "no bgp confederation identifier [(1-4294967295)]",
1894 "AS confederation parameters\n"
1896 "Set routing domain confederation AS\n")
1898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1899 bgp_confederation_id_unset(bgp
);
1904 DEFUN (bgp_confederation_peers
,
1905 bgp_confederation_peers_cmd
,
1906 "bgp confederation peers (1-4294967295)...",
1908 "AS confederation parameters\n"
1909 "Peer ASs in BGP confederation\n"
1912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1917 for (i
= idx_asn
; i
< argc
; i
++) {
1918 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1920 if (bgp
->as
== as
) {
1922 "%% Local member-AS not allowed in confed peer list\n");
1926 bgp_confederation_peers_add(bgp
, as
);
1931 DEFUN (no_bgp_confederation_peers
,
1932 no_bgp_confederation_peers_cmd
,
1933 "no bgp confederation peers (1-4294967295)...",
1936 "AS confederation parameters\n"
1937 "Peer ASs in BGP confederation\n"
1940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1945 for (i
= idx_asn
; i
< argc
; i
++) {
1946 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1948 bgp_confederation_peers_remove(bgp
, as
);
1954 * Central routine for maximum-paths configuration.
1955 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1956 * @set: 1 for setting values, 0 for removing the max-paths config.
1958 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1959 const char *mpaths
, uint16_t options
,
1962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1963 uint16_t maxpaths
= 0;
1968 afi
= bgp_node_afi(vty
);
1969 safi
= bgp_node_safi(vty
);
1972 maxpaths
= strtol(mpaths
, NULL
, 10);
1973 if (maxpaths
> multipath_num
) {
1975 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1976 maxpaths
, multipath_num
);
1977 return CMD_WARNING_CONFIG_FAILED
;
1979 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1982 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1986 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1987 (set
== 1) ? "" : "un",
1988 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1989 maxpaths
, afi
, safi
);
1990 return CMD_WARNING_CONFIG_FAILED
;
1993 bgp_recalculate_all_bestpaths(bgp
);
1998 DEFUN (bgp_maxmed_admin
,
1999 bgp_maxmed_admin_cmd
,
2000 "bgp max-med administrative ",
2002 "Advertise routes with max-med\n"
2003 "Administratively applied, for an indefinite period\n")
2005 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2007 bgp
->v_maxmed_admin
= 1;
2008 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2010 bgp_maxmed_update(bgp
);
2015 DEFUN (bgp_maxmed_admin_medv
,
2016 bgp_maxmed_admin_medv_cmd
,
2017 "bgp max-med administrative (0-4294967295)",
2019 "Advertise routes with max-med\n"
2020 "Administratively applied, for an indefinite period\n"
2021 "Max MED value to be used\n")
2023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2026 bgp
->v_maxmed_admin
= 1;
2027 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2029 bgp_maxmed_update(bgp
);
2034 DEFUN (no_bgp_maxmed_admin
,
2035 no_bgp_maxmed_admin_cmd
,
2036 "no bgp max-med administrative [(0-4294967295)]",
2039 "Advertise routes with max-med\n"
2040 "Administratively applied, for an indefinite period\n"
2041 "Max MED value to be used\n")
2043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2044 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2045 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2046 bgp_maxmed_update(bgp
);
2051 DEFUN (bgp_maxmed_onstartup
,
2052 bgp_maxmed_onstartup_cmd
,
2053 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2055 "Advertise routes with max-med\n"
2056 "Effective on a startup\n"
2057 "Time (seconds) period for max-med\n"
2058 "Max MED value to be used\n")
2060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2064 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2065 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2066 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2068 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2070 bgp_maxmed_update(bgp
);
2075 DEFUN (no_bgp_maxmed_onstartup
,
2076 no_bgp_maxmed_onstartup_cmd
,
2077 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2080 "Advertise routes with max-med\n"
2081 "Effective on a startup\n"
2082 "Time (seconds) period for max-med\n"
2083 "Max MED value to be used\n")
2085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2087 /* Cancel max-med onstartup if its on */
2088 if (bgp
->t_maxmed_onstartup
) {
2089 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2090 bgp
->maxmed_onstartup_over
= 1;
2093 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2094 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2096 bgp_maxmed_update(bgp
);
2101 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2102 uint16_t update_delay
,
2103 uint16_t establish_wait
)
2105 struct listnode
*node
, *nnode
;
2107 bool vrf_cfg
= false;
2110 * See if update-delay is set per-vrf and warn user to delete it
2111 * Note that we only need to check this if this is the first time
2112 * setting the global config.
2114 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2115 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2116 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2118 "%% update-delay configuration found in vrf %s\n",
2119 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2129 "%%Failed: global update-delay config not permitted\n");
2133 if (!establish_wait
) { /* update-delay <delay> */
2134 bm
->v_update_delay
= update_delay
;
2135 bm
->v_establish_wait
= bm
->v_update_delay
;
2137 /* update-delay <delay> <establish-wait> */
2138 if (update_delay
< establish_wait
) {
2140 "%%Failed: update-delay less than the establish-wait!\n");
2141 return CMD_WARNING_CONFIG_FAILED
;
2144 bm
->v_update_delay
= update_delay
;
2145 bm
->v_establish_wait
= establish_wait
;
2148 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2149 bgp
->v_update_delay
= bm
->v_update_delay
;
2150 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2156 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2158 struct listnode
*node
, *nnode
;
2161 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2162 bm
->v_establish_wait
= bm
->v_update_delay
;
2164 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2165 bgp
->v_update_delay
= bm
->v_update_delay
;
2166 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2172 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2173 uint16_t establish_wait
)
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2177 /* if configured globally, per-instance config is not allowed */
2178 if (bm
->v_update_delay
) {
2180 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2181 return CMD_WARNING_CONFIG_FAILED
;
2185 if (!establish_wait
) /* update-delay <delay> */
2187 bgp
->v_update_delay
= update_delay
;
2188 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2192 /* update-delay <delay> <establish-wait> */
2193 if (update_delay
< establish_wait
) {
2195 "%%Failed: update-delay less than the establish-wait!\n");
2196 return CMD_WARNING_CONFIG_FAILED
;
2199 bgp
->v_update_delay
= update_delay
;
2200 bgp
->v_establish_wait
= establish_wait
;
2205 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2209 /* If configured globally, cannot remove from one bgp instance */
2210 if (bm
->v_update_delay
) {
2212 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2213 return CMD_WARNING_CONFIG_FAILED
;
2215 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2216 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2221 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2223 /* If configured globally, no need to display per-instance value */
2224 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2225 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2226 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2227 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2232 /* Global update-delay configuration */
2233 DEFPY (bgp_global_update_delay
,
2234 bgp_global_update_delay_cmd
,
2235 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2237 "Force initial delay for best-path and updates for all bgp instances\n"
2238 "Max delay in seconds\n"
2239 "Establish wait in seconds\n")
2241 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2244 /* Global update-delay deconfiguration */
2245 DEFPY (no_bgp_global_update_delay
,
2246 no_bgp_global_update_delay_cmd
,
2247 "no bgp update-delay [(0-3600) [(1-3600)]]",
2250 "Force initial delay for best-path and updates\n"
2251 "Max delay in seconds\n"
2252 "Establish wait in seconds\n")
2254 return bgp_global_update_delay_deconfig_vty(vty
);
2257 /* Update-delay configuration */
2259 DEFPY (bgp_update_delay
,
2260 bgp_update_delay_cmd
,
2261 "update-delay (0-3600)$delay [(1-3600)$wait]",
2262 "Force initial delay for best-path and updates\n"
2263 "Max delay in seconds\n"
2264 "Establish wait in seconds\n")
2266 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2269 /* Update-delay deconfiguration */
2270 DEFPY (no_bgp_update_delay
,
2271 no_bgp_update_delay_cmd
,
2272 "no update-delay [(0-3600) [(1-3600)]]",
2274 "Force initial delay for best-path and updates\n"
2275 "Max delay in seconds\n"
2276 "Establish wait in seconds\n")
2278 return bgp_update_delay_deconfig_vty(vty
);
2282 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2287 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2288 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2293 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2298 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2299 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2304 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2307 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2308 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2309 vty_out(vty
, " write-quanta %d\n", quanta
);
2312 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2315 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2316 if (quanta
!= BGP_READ_PACKET_MAX
)
2317 vty_out(vty
, " read-quanta %d\n", quanta
);
2320 /* Packet quanta configuration
2322 * XXX: The value set here controls the size of a stack buffer in the IO
2323 * thread. When changing these limits be careful to prevent stack overflow.
2325 * Furthermore, the maximums used here should correspond to
2326 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2328 DEFPY (bgp_wpkt_quanta
,
2329 bgp_wpkt_quanta_cmd
,
2330 "[no] write-quanta (1-64)$quanta",
2332 "How many packets to write to peer socket per run\n"
2333 "Number of packets\n")
2335 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2338 DEFPY (bgp_rpkt_quanta
,
2339 bgp_rpkt_quanta_cmd
,
2340 "[no] read-quanta (1-10)$quanta",
2342 "How many packets to read from peer socket per I/O cycle\n"
2343 "Number of packets\n")
2345 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2348 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2350 if (!bgp
->heuristic_coalesce
)
2351 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2354 /* BGP TCP keepalive */
2355 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2357 if (bgp
->tcp_keepalive_idle
) {
2358 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2359 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2360 bgp
->tcp_keepalive_probes
);
2364 DEFUN (bgp_coalesce_time
,
2365 bgp_coalesce_time_cmd
,
2366 "coalesce-time (0-4294967295)",
2367 "Subgroup coalesce timer\n"
2368 "Subgroup coalesce timer value (in ms)\n")
2370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2374 bgp
->heuristic_coalesce
= false;
2376 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2377 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2382 DEFUN (no_bgp_coalesce_time
,
2383 no_bgp_coalesce_time_cmd
,
2384 "no coalesce-time (0-4294967295)",
2386 "Subgroup coalesce timer\n"
2387 "Subgroup coalesce timer value (in ms)\n")
2389 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2391 bgp
->heuristic_coalesce
= true;
2392 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2396 /* Maximum-paths configuration */
2397 DEFUN (bgp_maxpaths
,
2399 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2400 "Forward packets over multiple paths\n"
2401 "Number of paths\n")
2404 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2405 argv
[idx_number
]->arg
, 0, 1);
2408 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2409 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2410 "Forward packets over multiple paths\n"
2411 "Number of paths\n")
2413 DEFUN (bgp_maxpaths_ibgp
,
2414 bgp_maxpaths_ibgp_cmd
,
2415 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2416 "Forward packets over multiple paths\n"
2418 "Number of paths\n")
2421 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2422 argv
[idx_number
]->arg
, 0, 1);
2425 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2426 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2427 "Forward packets over multiple paths\n"
2429 "Number of paths\n")
2431 DEFUN (bgp_maxpaths_ibgp_cluster
,
2432 bgp_maxpaths_ibgp_cluster_cmd
,
2433 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2434 "Forward packets over multiple paths\n"
2437 "Match the cluster length\n")
2440 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2441 argv
[idx_number
]->arg
, true, 1);
2444 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2445 "maximum-paths ibgp " CMD_RANGE_STR(
2446 1, MULTIPATH_NUM
) " equal-cluster-length",
2447 "Forward packets over multiple paths\n"
2450 "Match the cluster length\n")
2452 DEFUN (no_bgp_maxpaths
,
2453 no_bgp_maxpaths_cmd
,
2454 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2456 "Forward packets over multiple paths\n"
2457 "Number of paths\n")
2459 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2462 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2463 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2464 "Forward packets over multiple paths\n"
2465 "Number of paths\n")
2467 DEFUN (no_bgp_maxpaths_ibgp
,
2468 no_bgp_maxpaths_ibgp_cmd
,
2469 "no 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")
2476 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2479 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2480 "no maximum-paths ibgp [" CMD_RANGE_STR(
2481 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2483 "Forward packets over multiple paths\n"
2486 "Match the cluster length\n")
2488 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2489 afi_t afi
, safi_t safi
)
2491 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2492 vty_out(vty
, " maximum-paths %d\n",
2493 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2496 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2497 vty_out(vty
, " maximum-paths ibgp %d",
2498 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2499 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2500 vty_out(vty
, " equal-cluster-length");
2509 "timers bgp (0-65535) (0-65535)",
2510 "Adjust routing timers\n"
2512 "Keepalive interval\n"
2515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2517 int idx_number_2
= 3;
2518 unsigned long keepalive
= 0;
2519 unsigned long holdtime
= 0;
2521 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2522 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2524 /* Holdtime value check. */
2525 if (holdtime
< 3 && holdtime
!= 0) {
2527 "%% hold time value must be either 0 or greater than 3\n");
2528 return CMD_WARNING_CONFIG_FAILED
;
2531 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2532 BGP_DEFAULT_DELAYOPEN
);
2537 DEFUN (no_bgp_timers
,
2539 "no timers bgp [(0-65535) (0-65535)]",
2541 "Adjust routing timers\n"
2543 "Keepalive interval\n"
2546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2547 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2548 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2553 /* BGP minimum holdtime. */
2555 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2556 "bgp minimum-holdtime (1-65535)",
2557 "BGP specific commands\n"
2558 "BGP minimum holdtime\n"
2561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2563 unsigned long min_holdtime
;
2565 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2567 bgp
->default_min_holdtime
= min_holdtime
;
2572 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2573 "no bgp minimum-holdtime [(1-65535)]",
2575 "BGP specific commands\n"
2576 "BGP minimum holdtime\n"
2579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2581 bgp
->default_min_holdtime
= 0;
2586 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2587 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2589 "TCP keepalive parameters\n"
2590 "TCP keepalive idle time (seconds)\n"
2591 "TCP keepalive interval (seconds)\n"
2592 "TCP keepalive maximum probes\n")
2594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2596 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2602 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2603 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2606 "TCP keepalive parameters\n"
2607 "TCP keepalive idle time (seconds)\n"
2608 "TCP keepalive interval (seconds)\n"
2609 "TCP keepalive maximum probes\n")
2611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 bgp_tcp_keepalive_unset(bgp
);
2618 DEFUN (bgp_client_to_client_reflection
,
2619 bgp_client_to_client_reflection_cmd
,
2620 "bgp client-to-client reflection",
2622 "Configure client to client route reflection\n"
2623 "reflection of routes allowed\n")
2625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2626 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2627 bgp_clear_star_soft_out(vty
, bgp
->name
);
2632 DEFUN (no_bgp_client_to_client_reflection
,
2633 no_bgp_client_to_client_reflection_cmd
,
2634 "no bgp client-to-client reflection",
2637 "Configure client to client route reflection\n"
2638 "reflection of routes allowed\n")
2640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2641 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2642 bgp_clear_star_soft_out(vty
, bgp
->name
);
2647 /* "bgp always-compare-med" configuration. */
2648 DEFUN (bgp_always_compare_med
,
2649 bgp_always_compare_med_cmd
,
2650 "bgp always-compare-med",
2652 "Allow comparing MED from different neighbors\n")
2654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2655 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2656 bgp_recalculate_all_bestpaths(bgp
);
2661 DEFUN (no_bgp_always_compare_med
,
2662 no_bgp_always_compare_med_cmd
,
2663 "no bgp always-compare-med",
2666 "Allow comparing MED from different neighbors\n")
2668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2669 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2670 bgp_recalculate_all_bestpaths(bgp
);
2676 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2677 "bgp ebgp-requires-policy",
2679 "Require in and out policy for eBGP peers (RFC8212)\n")
2681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2682 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2686 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2687 "no bgp ebgp-requires-policy",
2690 "Require in and out policy for eBGP peers (RFC8212)\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2697 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2698 "bgp suppress-duplicates",
2700 "Suppress duplicate updates if the route actually not changed\n")
2702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2703 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2707 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2708 "no bgp suppress-duplicates",
2711 "Suppress duplicate updates if the route actually not changed\n")
2713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2714 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2718 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2719 "bgp reject-as-sets",
2721 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2724 struct listnode
*node
, *nnode
;
2727 bgp
->reject_as_sets
= true;
2729 /* Reset existing BGP sessions to reject routes
2730 * with aspath containing AS_SET or AS_CONFED_SET.
2732 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2733 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2734 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2735 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2736 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2743 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2744 "no bgp reject-as-sets",
2747 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2750 struct listnode
*node
, *nnode
;
2753 bgp
->reject_as_sets
= false;
2755 /* Reset existing BGP sessions to reject routes
2756 * with aspath containing AS_SET or AS_CONFED_SET.
2758 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2759 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2760 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2761 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2762 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2769 /* "bgp deterministic-med" configuration. */
2770 DEFUN (bgp_deterministic_med
,
2771 bgp_deterministic_med_cmd
,
2772 "bgp deterministic-med",
2774 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2778 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2779 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2780 bgp_recalculate_all_bestpaths(bgp
);
2786 DEFUN (no_bgp_deterministic_med
,
2787 no_bgp_deterministic_med_cmd
,
2788 "no bgp deterministic-med",
2791 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2794 int bestpath_per_as_used
;
2798 struct listnode
*node
, *nnode
;
2800 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2801 bestpath_per_as_used
= 0;
2803 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2804 FOREACH_AFI_SAFI (afi
, safi
)
2805 if (bgp_addpath_dmed_required(
2806 peer
->addpath_type
[afi
][safi
])) {
2807 bestpath_per_as_used
= 1;
2811 if (bestpath_per_as_used
)
2815 if (bestpath_per_as_used
) {
2817 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2818 return CMD_WARNING_CONFIG_FAILED
;
2820 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2821 bgp_recalculate_all_bestpaths(bgp
);
2828 /* "bgp graceful-restart mode" configuration. */
2829 DEFUN (bgp_graceful_restart
,
2830 bgp_graceful_restart_cmd
,
2831 "bgp graceful-restart",
2836 int ret
= BGP_GR_FAILURE
;
2838 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2839 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2843 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2845 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2848 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2849 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2851 "Graceful restart configuration changed, reset all peers to take effect\n");
2852 return bgp_vty_return(vty
, ret
);
2855 DEFUN (no_bgp_graceful_restart
,
2856 no_bgp_graceful_restart_cmd
,
2857 "no bgp graceful-restart",
2863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2865 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2866 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2868 int ret
= BGP_GR_FAILURE
;
2870 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2872 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2875 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2876 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2878 "Graceful restart configuration changed, reset all peers to take effect\n");
2880 return bgp_vty_return(vty
, ret
);
2883 DEFUN (bgp_graceful_restart_stalepath_time
,
2884 bgp_graceful_restart_stalepath_time_cmd
,
2885 "bgp graceful-restart stalepath-time (1-4095)",
2887 "Graceful restart capability parameters\n"
2888 "Set the max time to hold onto restarting peer's stale paths\n"
2889 "Delay value (seconds)\n")
2891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2895 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2896 bgp
->stalepath_time
= stalepath
;
2900 DEFUN (bgp_graceful_restart_restart_time
,
2901 bgp_graceful_restart_restart_time_cmd
,
2902 "bgp graceful-restart restart-time (0-4095)",
2904 "Graceful restart capability parameters\n"
2905 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2906 "Delay value (seconds)\n")
2908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2912 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2913 bgp
->restart_time
= restart
;
2917 DEFUN (bgp_graceful_restart_select_defer_time
,
2918 bgp_graceful_restart_select_defer_time_cmd
,
2919 "bgp graceful-restart select-defer-time (0-3600)",
2921 "Graceful restart capability parameters\n"
2922 "Set the time to defer the BGP route selection after restart\n"
2923 "Delay value (seconds, 0 - disable)\n")
2925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2927 uint32_t defer_time
;
2929 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2930 bgp
->select_defer_time
= defer_time
;
2931 if (defer_time
== 0)
2932 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2934 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2939 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2940 no_bgp_graceful_restart_stalepath_time_cmd
,
2941 "no bgp graceful-restart stalepath-time [(1-4095)]",
2944 "Graceful restart capability parameters\n"
2945 "Set the max time to hold onto restarting peer's stale paths\n"
2946 "Delay value (seconds)\n")
2948 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2954 DEFUN (no_bgp_graceful_restart_restart_time
,
2955 no_bgp_graceful_restart_restart_time_cmd
,
2956 "no bgp graceful-restart restart-time [(0-4095)]",
2959 "Graceful restart capability parameters\n"
2960 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2961 "Delay value (seconds)\n")
2963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2965 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2969 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2970 no_bgp_graceful_restart_select_defer_time_cmd
,
2971 "no bgp graceful-restart select-defer-time [(0-3600)]",
2974 "Graceful restart capability parameters\n"
2975 "Set the time to defer the BGP route selection after restart\n"
2976 "Delay value (seconds)\n")
2978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2980 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2981 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2986 DEFUN (bgp_graceful_restart_preserve_fw
,
2987 bgp_graceful_restart_preserve_fw_cmd
,
2988 "bgp graceful-restart preserve-fw-state",
2990 "Graceful restart capability parameters\n"
2991 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2993 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2994 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2998 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2999 no_bgp_graceful_restart_preserve_fw_cmd
,
3000 "no bgp graceful-restart preserve-fw-state",
3003 "Graceful restart capability parameters\n"
3004 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3007 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3011 DEFPY (bgp_graceful_restart_notification
,
3012 bgp_graceful_restart_notification_cmd
,
3013 "[no$no] bgp graceful-restart notification",
3016 "Graceful restart capability parameters\n"
3017 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3022 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3024 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3029 DEFPY (bgp_administrative_reset
,
3030 bgp_administrative_reset_cmd
,
3031 "[no$no] bgp hard-administrative-reset",
3034 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3036 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3039 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3041 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3046 DEFUN (bgp_graceful_restart_disable
,
3047 bgp_graceful_restart_disable_cmd
,
3048 "bgp graceful-restart-disable",
3052 int ret
= BGP_GR_FAILURE
;
3054 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3056 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3058 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3060 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3062 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3065 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3067 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3069 "Graceful restart configuration changed, reset all peers to take effect\n");
3071 return bgp_vty_return(vty
, ret
);
3074 DEFUN (no_bgp_graceful_restart_disable
,
3075 no_bgp_graceful_restart_disable_cmd
,
3076 "no bgp graceful-restart-disable",
3082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3084 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3086 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3088 int ret
= BGP_GR_FAILURE
;
3090 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3092 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3095 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3097 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3099 "Graceful restart configuration changed, reset all peers to take effect\n");
3101 return bgp_vty_return(vty
, ret
);
3104 DEFUN (bgp_neighbor_graceful_restart_set
,
3105 bgp_neighbor_graceful_restart_set_cmd
,
3106 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3114 int ret
= BGP_GR_FAILURE
;
3116 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3118 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3120 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3122 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3124 return CMD_WARNING_CONFIG_FAILED
;
3126 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3128 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3129 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3131 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3133 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3135 "Graceful restart configuration changed, reset this peer to take effect\n");
3137 return bgp_vty_return(vty
, ret
);
3140 DEFUN (no_bgp_neighbor_graceful_restart
,
3141 no_bgp_neighbor_graceful_restart_set_cmd
,
3142 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3150 int ret
= BGP_GR_FAILURE
;
3153 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3155 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3157 return CMD_WARNING_CONFIG_FAILED
;
3159 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3161 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3163 ret
= bgp_neighbor_graceful_restart(peer
, NO_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] no_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 (bgp_neighbor_graceful_restart_helper_set
,
3178 bgp_neighbor_graceful_restart_helper_set_cmd
,
3179 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3182 GR_NEIGHBOR_HELPER_CMD
3187 int ret
= BGP_GR_FAILURE
;
3189 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3191 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3193 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3195 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3198 return CMD_WARNING_CONFIG_FAILED
;
3201 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3203 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3204 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3206 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3208 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3210 "Graceful restart configuration changed, reset this peer to take effect\n");
3212 return bgp_vty_return(vty
, ret
);
3215 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3216 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3217 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3221 NO_GR_NEIGHBOR_HELPER_CMD
3225 int ret
= BGP_GR_FAILURE
;
3228 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3232 return CMD_WARNING_CONFIG_FAILED
;
3234 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3236 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3238 ret
= bgp_neighbor_graceful_restart(peer
, NO_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] no_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 (bgp_neighbor_graceful_restart_disable_set
,
3253 bgp_neighbor_graceful_restart_disable_set_cmd
,
3254 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3257 GR_NEIGHBOR_DISABLE_CMD
3262 int ret
= BGP_GR_FAILURE
;
3264 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3266 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3268 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3270 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3272 return CMD_WARNING_CONFIG_FAILED
;
3274 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3276 if (peer
->bgp
->t_startup
)
3277 bgp_peer_gr_flags_update(peer
);
3279 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3280 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3282 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3284 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3286 "Graceful restart configuration changed, reset this peer to take effect\n");
3288 return bgp_vty_return(vty
, ret
);
3291 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3292 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3293 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3297 NO_GR_NEIGHBOR_DISABLE_CMD
3301 int ret
= BGP_GR_FAILURE
;
3304 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3308 return CMD_WARNING_CONFIG_FAILED
;
3310 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3312 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3314 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
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] no_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_HIDDEN (bgp_graceful_restart_disable_eor
,
3329 bgp_graceful_restart_disable_eor_cmd
,
3330 "bgp graceful-restart disable-eor",
3332 "Graceful restart configuration parameters\n"
3333 "Disable EOR Check\n")
3335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3336 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3341 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3342 no_bgp_graceful_restart_disable_eor_cmd
,
3343 "no bgp graceful-restart disable-eor",
3346 "Graceful restart configuration parameters\n"
3347 "Disable EOR Check\n")
3349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3350 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3355 DEFUN (bgp_graceful_restart_rib_stale_time
,
3356 bgp_graceful_restart_rib_stale_time_cmd
,
3357 "bgp graceful-restart rib-stale-time (1-3600)",
3359 "Graceful restart configuration parameters\n"
3360 "Specify the stale route removal timer in rib\n"
3361 "Delay value (seconds)\n")
3363 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3365 uint32_t stale_time
;
3367 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3368 bgp
->rib_stale_time
= stale_time
;
3369 /* Send the stale timer update message to RIB */
3370 if (bgp_zebra_stale_timer_update(bgp
))
3376 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3377 no_bgp_graceful_restart_rib_stale_time_cmd
,
3378 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3381 "Graceful restart configuration parameters\n"
3382 "Specify the stale route removal timer in rib\n"
3383 "Delay value (seconds)\n")
3385 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3387 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3388 /* Send the stale timer update message to RIB */
3389 if (bgp_zebra_stale_timer_update(bgp
))
3395 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3396 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3398 "Enable Long-lived Graceful Restart\n"
3399 "Specifies maximum time to wait before purging long-lived stale routes\n"
3400 "Stale time value (seconds)\n")
3402 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3404 uint32_t llgr_stale_time
;
3406 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3407 bgp
->llgr_stale_time
= llgr_stale_time
;
3412 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3413 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3415 "Enable Long-lived Graceful Restart\n"
3416 "Specifies maximum time to wait before purging long-lived stale routes\n"
3417 "Stale time value (seconds)\n")
3419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3421 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3426 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3429 bgp_static_redo_import_check(bgp
);
3430 bgp_redistribute_redo(bgp
);
3431 bgp_clear_star_soft_out(vty
, bgp
->name
);
3432 bgp_clear_star_soft_in(vty
, bgp
->name
);
3435 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3437 struct listnode
*node
, *nnode
;
3439 bool vrf_cfg
= false;
3441 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3444 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3445 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3446 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3448 "%% graceful-shutdown configuration found in vrf %s\n",
3449 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3450 VRF_DEFAULT_NAME
: bgp
->name
);
3457 "%%Failed: global graceful-shutdown not permitted\n");
3461 /* Set flag globally */
3462 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3464 /* Initiate processing for all BGP instances. */
3465 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3466 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3471 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3473 struct listnode
*node
, *nnode
;
3476 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3479 /* Unset flag globally */
3480 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3482 /* Initiate processing for all BGP instances. */
3483 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3484 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3489 /* "bgp graceful-shutdown" configuration */
3490 DEFUN (bgp_graceful_shutdown
,
3491 bgp_graceful_shutdown_cmd
,
3492 "bgp graceful-shutdown",
3494 "Graceful shutdown parameters\n")
3496 if (vty
->node
== CONFIG_NODE
)
3497 return bgp_global_graceful_shutdown_config_vty(vty
);
3499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3501 /* if configured globally, per-instance config is not allowed */
3502 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3504 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3505 return CMD_WARNING_CONFIG_FAILED
;
3508 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3509 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3510 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3516 DEFUN (no_bgp_graceful_shutdown
,
3517 no_bgp_graceful_shutdown_cmd
,
3518 "no bgp graceful-shutdown",
3521 "Graceful shutdown parameters\n")
3523 if (vty
->node
== CONFIG_NODE
)
3524 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3528 /* If configured globally, cannot remove from one bgp instance */
3529 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3531 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3532 return CMD_WARNING_CONFIG_FAILED
;
3535 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3536 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3537 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3543 /* "bgp fast-external-failover" configuration. */
3544 DEFUN (bgp_fast_external_failover
,
3545 bgp_fast_external_failover_cmd
,
3546 "bgp fast-external-failover",
3548 "Immediately reset session if a link to a directly connected external peer goes down\n")
3550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3551 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3555 DEFUN (no_bgp_fast_external_failover
,
3556 no_bgp_fast_external_failover_cmd
,
3557 "no bgp fast-external-failover",
3560 "Immediately reset session if a link to a directly connected external peer goes down\n")
3562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3563 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3567 /* "bgp bestpath compare-routerid" configuration. */
3568 DEFUN (bgp_bestpath_compare_router_id
,
3569 bgp_bestpath_compare_router_id_cmd
,
3570 "bgp bestpath compare-routerid",
3572 "Change the default bestpath selection\n"
3573 "Compare router-id for identical EBGP paths\n")
3575 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3576 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3577 bgp_recalculate_all_bestpaths(bgp
);
3582 DEFUN (no_bgp_bestpath_compare_router_id
,
3583 no_bgp_bestpath_compare_router_id_cmd
,
3584 "no bgp bestpath compare-routerid",
3587 "Change the default bestpath selection\n"
3588 "Compare router-id for identical EBGP paths\n")
3590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3591 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3592 bgp_recalculate_all_bestpaths(bgp
);
3597 /* "bgp bestpath as-path ignore" configuration. */
3598 DEFUN (bgp_bestpath_aspath_ignore
,
3599 bgp_bestpath_aspath_ignore_cmd
,
3600 "bgp bestpath as-path ignore",
3602 "Change the default bestpath selection\n"
3603 "AS-path attribute\n"
3604 "Ignore as-path length in selecting a route\n")
3606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3607 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3608 bgp_recalculate_all_bestpaths(bgp
);
3613 DEFUN (no_bgp_bestpath_aspath_ignore
,
3614 no_bgp_bestpath_aspath_ignore_cmd
,
3615 "no bgp bestpath as-path ignore",
3618 "Change the default bestpath selection\n"
3619 "AS-path attribute\n"
3620 "Ignore as-path length in selecting a route\n")
3622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3623 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3624 bgp_recalculate_all_bestpaths(bgp
);
3629 /* "bgp bestpath as-path confed" configuration. */
3630 DEFUN (bgp_bestpath_aspath_confed
,
3631 bgp_bestpath_aspath_confed_cmd
,
3632 "bgp bestpath as-path confed",
3634 "Change the default bestpath selection\n"
3635 "AS-path attribute\n"
3636 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3639 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3640 bgp_recalculate_all_bestpaths(bgp
);
3645 DEFUN (no_bgp_bestpath_aspath_confed
,
3646 no_bgp_bestpath_aspath_confed_cmd
,
3647 "no bgp bestpath as-path confed",
3650 "Change the default bestpath selection\n"
3651 "AS-path attribute\n"
3652 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3655 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3656 bgp_recalculate_all_bestpaths(bgp
);
3661 /* "bgp bestpath as-path multipath-relax" configuration. */
3662 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3663 bgp_bestpath_aspath_multipath_relax_cmd
,
3664 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3666 "Change the default bestpath selection\n"
3667 "AS-path attribute\n"
3668 "Allow load sharing across routes that have different AS paths (but same length)\n"
3669 "Generate an AS_SET\n"
3670 "Do not generate an AS_SET\n")
3672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3674 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3676 /* no-as-set is now the default behavior so we can silently
3678 if (argv_find(argv
, argc
, "as-set", &idx
))
3679 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3681 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3683 bgp_recalculate_all_bestpaths(bgp
);
3688 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3689 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3690 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3693 "Change the default bestpath selection\n"
3694 "AS-path attribute\n"
3695 "Allow load sharing across routes that have different AS paths (but same length)\n"
3696 "Generate an AS_SET\n"
3697 "Do not generate an AS_SET\n")
3699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3700 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3701 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3702 bgp_recalculate_all_bestpaths(bgp
);
3707 /* "bgp bestpath peer-type multipath-relax" configuration. */
3708 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3709 bgp_bestpath_peer_type_multipath_relax_cmd
,
3710 "bgp bestpath peer-type multipath-relax",
3712 "Change the default bestpath selection\n"
3714 "Allow load sharing across routes learned from different peer types\n")
3716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3717 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3718 bgp_recalculate_all_bestpaths(bgp
);
3723 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3724 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3725 "no bgp bestpath peer-type multipath-relax",
3727 "Change the default bestpath selection\n"
3729 "Allow load sharing across routes learned from different peer types\n")
3731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3732 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3733 bgp_recalculate_all_bestpaths(bgp
);
3738 /* "bgp log-neighbor-changes" configuration. */
3739 DEFUN (bgp_log_neighbor_changes
,
3740 bgp_log_neighbor_changes_cmd
,
3741 "bgp log-neighbor-changes",
3743 "Log neighbor up/down and reset reason\n")
3745 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3746 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3750 DEFUN (no_bgp_log_neighbor_changes
,
3751 no_bgp_log_neighbor_changes_cmd
,
3752 "no bgp log-neighbor-changes",
3755 "Log neighbor up/down and reset reason\n")
3757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3758 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3762 /* "bgp bestpath med" configuration. */
3763 DEFUN (bgp_bestpath_med
,
3764 bgp_bestpath_med_cmd
,
3765 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3767 "Change the default bestpath selection\n"
3769 "Compare MED among confederation paths\n"
3770 "Treat missing MED as the least preferred one\n"
3771 "Treat missing MED as the least preferred one\n"
3772 "Compare MED among confederation paths\n")
3774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3777 if (argv_find(argv
, argc
, "confed", &idx
))
3778 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3780 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3781 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3783 bgp_recalculate_all_bestpaths(bgp
);
3788 DEFUN (no_bgp_bestpath_med
,
3789 no_bgp_bestpath_med_cmd
,
3790 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3793 "Change the default bestpath selection\n"
3795 "Compare MED among confederation paths\n"
3796 "Treat missing MED as the least preferred one\n"
3797 "Treat missing MED as the least preferred one\n"
3798 "Compare MED among confederation paths\n")
3800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3803 if (argv_find(argv
, argc
, "confed", &idx
))
3804 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3806 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3807 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3809 bgp_recalculate_all_bestpaths(bgp
);
3814 /* "bgp bestpath bandwidth" configuration. */
3815 DEFPY (bgp_bestpath_bw
,
3816 bgp_bestpath_bw_cmd
,
3817 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3819 "Change the default bestpath selection\n"
3820 "Link Bandwidth attribute\n"
3821 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3822 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3823 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3830 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3831 return CMD_ERR_INCOMPLETE
;
3833 if (!strcmp(bw_cfg
, "ignore"))
3834 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3835 else if (!strcmp(bw_cfg
, "skip-missing"))
3836 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3837 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3838 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3840 return CMD_ERR_NO_MATCH
;
3842 /* This config is used in route install, so redo that. */
3843 FOREACH_AFI_SAFI (afi
, safi
) {
3844 if (!bgp_fibupd_safi(safi
))
3846 bgp_zebra_announce_table(bgp
, afi
, safi
);
3852 DEFPY (no_bgp_bestpath_bw
,
3853 no_bgp_bestpath_bw_cmd
,
3854 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3857 "Change the default bestpath selection\n"
3858 "Link Bandwidth attribute\n"
3859 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3860 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3861 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3867 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3869 /* This config is used in route install, so redo that. */
3870 FOREACH_AFI_SAFI (afi
, safi
) {
3871 if (!bgp_fibupd_safi(safi
))
3873 bgp_zebra_announce_table(bgp
, afi
, safi
);
3878 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3879 "[no] bgp default <ipv4-unicast|"
3882 "ipv4-labeled-unicast|"
3887 "ipv6-labeled-unicast|"
3889 "l2vpn-evpn>$afi_safi",
3892 "Configure BGP defaults\n"
3893 "Activate ipv4-unicast for a peer by default\n"
3894 "Activate ipv4-multicast for a peer by default\n"
3895 "Activate ipv4-vpn for a peer by default\n"
3896 "Activate ipv4-labeled-unicast for a peer by default\n"
3897 "Activate ipv4-flowspec for a peer by default\n"
3898 "Activate ipv6-unicast for a peer by default\n"
3899 "Activate ipv6-multicast for a peer by default\n"
3900 "Activate ipv6-vpn for a peer by default\n"
3901 "Activate ipv6-labeled-unicast for a peer by default\n"
3902 "Activate ipv6-flowspec for a peer by default\n"
3903 "Activate l2vpn-evpn for a peer by default\n")
3905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3906 char afi_safi_str
[strlen(afi_safi
) + 1];
3907 char *afi_safi_str_tok
;
3909 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3910 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3911 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3912 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3916 * Impossible situation but making coverity happy
3918 assert(afi
!= AFI_MAX
);
3920 if (strmatch(safi_str
, "labeled"))
3921 safi
= bgp_vty_safi_from_str("labeled-unicast");
3923 safi
= bgp_vty_safi_from_str(safi_str
);
3925 assert(safi
!= SAFI_MAX
);
3927 bgp
->default_af
[afi
][safi
] = false;
3929 if ((safi
== SAFI_LABELED_UNICAST
3930 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3931 || (safi
== SAFI_UNICAST
3932 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3933 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3935 bgp
->default_af
[afi
][safi
] = true;
3941 /* Display hostname in certain command outputs */
3942 DEFUN (bgp_default_show_hostname
,
3943 bgp_default_show_hostname_cmd
,
3944 "bgp default show-hostname",
3946 "Configure BGP defaults\n"
3947 "Show hostname in certain command outputs\n")
3949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3950 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3954 DEFUN (no_bgp_default_show_hostname
,
3955 no_bgp_default_show_hostname_cmd
,
3956 "no bgp default show-hostname",
3959 "Configure BGP defaults\n"
3960 "Show hostname in certain command outputs\n")
3962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3963 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3967 /* Display hostname in certain command outputs */
3968 DEFUN (bgp_default_show_nexthop_hostname
,
3969 bgp_default_show_nexthop_hostname_cmd
,
3970 "bgp default show-nexthop-hostname",
3972 "Configure BGP defaults\n"
3973 "Show hostname for nexthop in certain command outputs\n")
3975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3976 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3980 DEFUN (no_bgp_default_show_nexthop_hostname
,
3981 no_bgp_default_show_nexthop_hostname_cmd
,
3982 "no bgp default show-nexthop-hostname",
3985 "Configure BGP defaults\n"
3986 "Show hostname for nexthop in certain command outputs\n")
3988 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3989 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3993 /* "bgp network import-check" configuration. */
3994 DEFUN (bgp_network_import_check
,
3995 bgp_network_import_check_cmd
,
3996 "bgp network import-check",
3998 "BGP network command\n"
3999 "Check BGP network route exists in IGP\n")
4001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4002 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4003 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4004 bgp_static_redo_import_check(bgp
);
4010 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4011 "bgp network import-check exact",
4013 "BGP network command\n"
4014 "Check BGP network route exists in IGP\n"
4015 "Match route precisely\n")
4017 DEFUN (no_bgp_network_import_check
,
4018 no_bgp_network_import_check_cmd
,
4019 "no bgp network import-check",
4022 "BGP network command\n"
4023 "Check BGP network route exists in IGP\n")
4025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4026 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4027 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4028 bgp_static_redo_import_check(bgp
);
4034 DEFUN (bgp_default_local_preference
,
4035 bgp_default_local_preference_cmd
,
4036 "bgp default local-preference (0-4294967295)",
4038 "Configure BGP defaults\n"
4039 "local preference (higher=more preferred)\n"
4040 "Configure default local preference value\n")
4042 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4044 uint32_t local_pref
;
4046 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4048 bgp_default_local_preference_set(bgp
, local_pref
);
4049 bgp_clear_star_soft_in(vty
, bgp
->name
);
4054 DEFUN (no_bgp_default_local_preference
,
4055 no_bgp_default_local_preference_cmd
,
4056 "no bgp default local-preference [(0-4294967295)]",
4059 "Configure BGP defaults\n"
4060 "local preference (higher=more preferred)\n"
4061 "Configure default local preference value\n")
4063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4064 bgp_default_local_preference_unset(bgp
);
4065 bgp_clear_star_soft_in(vty
, bgp
->name
);
4071 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4072 bgp_default_subgroup_pkt_queue_max_cmd
,
4073 "bgp default subgroup-pkt-queue-max (20-100)",
4075 "Configure BGP defaults\n"
4076 "subgroup-pkt-queue-max\n"
4077 "Configure subgroup packet queue max\n")
4079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4083 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4085 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4090 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4091 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4092 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4095 "Configure BGP defaults\n"
4096 "subgroup-pkt-queue-max\n"
4097 "Configure subgroup packet queue max\n")
4099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4100 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4105 DEFUN (bgp_rr_allow_outbound_policy
,
4106 bgp_rr_allow_outbound_policy_cmd
,
4107 "bgp route-reflector allow-outbound-policy",
4109 "Allow modifications made by out route-map\n"
4110 "on ibgp neighbors\n")
4112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4114 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4115 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4116 update_group_announce_rrclients(bgp
);
4117 bgp_clear_star_soft_out(vty
, bgp
->name
);
4123 DEFUN (no_bgp_rr_allow_outbound_policy
,
4124 no_bgp_rr_allow_outbound_policy_cmd
,
4125 "no bgp route-reflector allow-outbound-policy",
4128 "Allow modifications made by out route-map\n"
4129 "on ibgp neighbors\n")
4131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4133 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4134 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4135 update_group_announce_rrclients(bgp
);
4136 bgp_clear_star_soft_out(vty
, bgp
->name
);
4142 DEFUN (bgp_listen_limit
,
4143 bgp_listen_limit_cmd
,
4144 "bgp listen limit (1-65535)",
4146 "BGP Dynamic Neighbors listen commands\n"
4147 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4148 "Configure Dynamic Neighbors listen limit value\n")
4150 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4154 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4156 bgp_listen_limit_set(bgp
, listen_limit
);
4161 DEFUN (no_bgp_listen_limit
,
4162 no_bgp_listen_limit_cmd
,
4163 "no bgp listen limit [(1-65535)]",
4166 "BGP Dynamic Neighbors listen commands\n"
4167 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4168 "Configure Dynamic Neighbors listen limit value\n")
4170 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4171 bgp_listen_limit_unset(bgp
);
4177 * Check if this listen range is already configured. Check for exact
4178 * match or overlap based on input.
4180 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4181 struct prefix
*range
, int exact
)
4183 struct listnode
*node
, *nnode
;
4184 struct listnode
*node1
, *nnode1
;
4185 struct peer_group
*group
;
4190 afi
= family2afi(range
->family
);
4191 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4192 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4195 match
= prefix_same(range
, lr
);
4197 match
= (prefix_match(range
, lr
)
4198 || prefix_match(lr
, range
));
4207 DEFUN (bgp_listen_range
,
4208 bgp_listen_range_cmd
,
4209 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4211 "Configure BGP dynamic neighbors listen range\n"
4212 "Configure BGP dynamic neighbors listen range\n"
4214 "Member of the peer-group\n"
4215 "Peer-group name\n")
4217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4218 struct prefix range
;
4219 struct peer_group
*group
, *existing_group
;
4224 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4225 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4226 char *prefix
= argv
[idx
]->arg
;
4227 argv_find(argv
, argc
, "PGNAME", &idx
);
4228 char *peergroup
= argv
[idx
]->arg
;
4230 /* Convert IP prefix string to struct prefix. */
4231 ret
= str2prefix(prefix
, &range
);
4233 vty_out(vty
, "%% Malformed listen range\n");
4234 return CMD_WARNING_CONFIG_FAILED
;
4237 afi
= family2afi(range
.family
);
4239 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4241 "%% Malformed listen range (link-local address)\n");
4242 return CMD_WARNING_CONFIG_FAILED
;
4247 /* Check if same listen range is already configured. */
4248 existing_group
= listen_range_exists(bgp
, &range
, 1);
4249 if (existing_group
) {
4250 if (strcmp(existing_group
->name
, peergroup
) == 0)
4254 "%% Same listen range is attached to peer-group %s\n",
4255 existing_group
->name
);
4256 return CMD_WARNING_CONFIG_FAILED
;
4260 /* Check if an overlapping listen range exists. */
4261 if (listen_range_exists(bgp
, &range
, 0)) {
4263 "%% Listen range overlaps with existing listen range\n");
4264 return CMD_WARNING_CONFIG_FAILED
;
4267 group
= peer_group_lookup(bgp
, peergroup
);
4269 vty_out(vty
, "%% Configure the peer-group first\n");
4270 return CMD_WARNING_CONFIG_FAILED
;
4273 ret
= peer_group_listen_range_add(group
, &range
);
4274 return bgp_vty_return(vty
, ret
);
4277 DEFUN (no_bgp_listen_range
,
4278 no_bgp_listen_range_cmd
,
4279 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4282 "Unconfigure BGP dynamic neighbors listen range\n"
4283 "Unconfigure BGP dynamic neighbors listen range\n"
4285 "Member of the peer-group\n"
4286 "Peer-group name\n")
4288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4289 struct prefix range
;
4290 struct peer_group
*group
;
4295 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4296 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4297 char *prefix
= argv
[idx
]->arg
;
4298 argv_find(argv
, argc
, "PGNAME", &idx
);
4299 char *peergroup
= argv
[idx
]->arg
;
4301 /* Convert IP prefix string to struct prefix. */
4302 ret
= str2prefix(prefix
, &range
);
4304 vty_out(vty
, "%% Malformed listen range\n");
4305 return CMD_WARNING_CONFIG_FAILED
;
4308 afi
= family2afi(range
.family
);
4310 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4312 "%% Malformed listen range (link-local address)\n");
4313 return CMD_WARNING_CONFIG_FAILED
;
4318 group
= peer_group_lookup(bgp
, peergroup
);
4320 vty_out(vty
, "%% Peer-group does not exist\n");
4321 return CMD_WARNING_CONFIG_FAILED
;
4324 ret
= peer_group_listen_range_del(group
, &range
);
4325 return bgp_vty_return(vty
, ret
);
4328 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4330 struct peer_group
*group
;
4331 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4332 struct prefix
*range
;
4335 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4336 vty_out(vty
, " bgp listen limit %d\n",
4337 bgp
->dynamic_neighbors_limit
);
4339 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4340 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4341 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4344 " bgp listen range %pFX peer-group %s\n",
4345 range
, group
->name
);
4352 DEFUN (bgp_disable_connected_route_check
,
4353 bgp_disable_connected_route_check_cmd
,
4354 "bgp disable-ebgp-connected-route-check",
4356 "Disable checking if nexthop is connected on ebgp sessions\n")
4358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4359 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4360 bgp_clear_star_soft_in(vty
, bgp
->name
);
4365 DEFUN (no_bgp_disable_connected_route_check
,
4366 no_bgp_disable_connected_route_check_cmd
,
4367 "no bgp disable-ebgp-connected-route-check",
4370 "Disable checking if nexthop is connected on ebgp sessions\n")
4372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4373 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4374 bgp_clear_star_soft_in(vty
, bgp
->name
);
4380 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4386 int as_type
= AS_SPECIFIED
;
4389 if (as_str
[0] == 'i') {
4391 as_type
= AS_INTERNAL
;
4392 } else if (as_str
[0] == 'e') {
4394 as_type
= AS_EXTERNAL
;
4396 /* Get AS number. */
4397 as
= strtoul(as_str
, NULL
, 10);
4400 /* If peer is peer group or interface peer, call proper function. */
4401 ret
= str2sockunion(peer_str
, &su
);
4405 /* Check if existing interface peer */
4406 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4408 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4410 /* if not interface peer, check peer-group settings */
4411 if (ret
< 0 && !peer
) {
4412 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4415 "%% Create the peer-group or interface first\n");
4416 return CMD_WARNING_CONFIG_FAILED
;
4421 if (peer_address_self_check(bgp
, &su
)) {
4423 "%% Can not configure the local system as neighbor\n");
4424 return CMD_WARNING_CONFIG_FAILED
;
4426 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4429 return bgp_vty_return(vty
, ret
);
4432 DEFUN (bgp_default_shutdown
,
4433 bgp_default_shutdown_cmd
,
4434 "[no] bgp default shutdown",
4437 "Configure BGP defaults\n"
4438 "Apply administrative shutdown to newly configured peers\n")
4440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4441 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4445 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4447 "Administrative shutdown of the BGP instance\n"
4448 "Add a shutdown message (RFC 8203)\n"
4449 "Shutdown message\n")
4451 char *msgstr
= NULL
;
4453 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4456 msgstr
= argv_concat(argv
, argc
, 3);
4458 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4459 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4460 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4461 return CMD_WARNING_CONFIG_FAILED
;
4464 bgp_shutdown_enable(bgp
, msgstr
);
4465 XFREE(MTYPE_TMP
, msgstr
);
4470 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4471 BGP_STR
"Administrative shutdown of the BGP instance\n")
4473 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4475 bgp_shutdown_enable(bgp
, NULL
);
4480 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4481 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4483 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4485 bgp_shutdown_disable(bgp
);
4490 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4491 "no bgp shutdown message MSG...", NO_STR BGP_STR
4492 "Administrative shutdown of the BGP instance\n"
4493 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4495 DEFUN (neighbor_remote_as
,
4496 neighbor_remote_as_cmd
,
4497 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4500 "Specify a BGP neighbor\n"
4502 "Internal BGP peer\n"
4503 "External BGP peer\n")
4506 int idx_remote_as
= 3;
4507 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4508 argv
[idx_remote_as
]->arg
);
4511 DEFPY (bgp_allow_martian
,
4512 bgp_allow_martian_cmd
,
4513 "[no]$no bgp allow-martian-nexthop",
4516 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4521 bgp
->allow_martian
= false;
4523 bgp
->allow_martian
= true;
4528 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4529 * sessions do not wait for hold timer expiry to bring down the sessions
4530 * when nexthop becomes unreachable
4532 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4533 BGP_STR
"Fast convergence for bgp sessions\n")
4535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4536 bgp
->fast_convergence
= true;
4541 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4542 "no bgp fast-convergence",
4543 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4546 bgp
->fast_convergence
= false;
4551 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4553 const char *peer_group_name
,
4556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4558 int as_type
= AS_UNSPECIFIED
;
4560 struct peer_group
*group
;
4563 group
= peer_group_lookup(bgp
, conf_if
);
4566 vty_out(vty
, "%% Name conflict with peer-group \n");
4567 return CMD_WARNING_CONFIG_FAILED
;
4571 if (as_str
[0] == 'i') {
4572 as_type
= AS_INTERNAL
;
4573 } else if (as_str
[0] == 'e') {
4574 as_type
= AS_EXTERNAL
;
4576 /* Get AS number. */
4577 as
= strtoul(as_str
, NULL
, 10);
4578 as_type
= AS_SPECIFIED
;
4582 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4585 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4587 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4591 vty_out(vty
, "%% BGP failed to create peer\n");
4592 return CMD_WARNING_CONFIG_FAILED
;
4596 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4598 /* Request zebra to initiate IPv6 RAs on this interface. We do
4600 * any unnumbered peer in order to not worry about run-time
4602 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4604 * gets deleted later etc.)
4607 bgp_zebra_initiate_radv(bgp
, peer
);
4610 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4611 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4613 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4615 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4617 /* v6only flag changed. Reset bgp seesion */
4618 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4619 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4620 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4621 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4623 bgp_session_reset(peer
);
4626 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4627 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4628 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4629 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4632 if (peer_group_name
) {
4633 group
= peer_group_lookup(bgp
, peer_group_name
);
4635 vty_out(vty
, "%% Configure the peer-group first\n");
4636 return CMD_WARNING_CONFIG_FAILED
;
4639 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4642 return bgp_vty_return(vty
, ret
);
4645 DEFUN (neighbor_interface_config
,
4646 neighbor_interface_config_cmd
,
4647 "neighbor WORD interface [peer-group PGNAME]",
4649 "Interface name or neighbor tag\n"
4650 "Enable BGP on interface\n"
4651 "Member of the peer-group\n"
4652 "Peer-group name\n")
4655 int idx_peer_group_word
= 4;
4657 if (argc
> idx_peer_group_word
)
4658 return peer_conf_interface_get(
4659 vty
, argv
[idx_word
]->arg
, 0,
4660 argv
[idx_peer_group_word
]->arg
, NULL
);
4662 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4666 DEFUN (neighbor_interface_config_v6only
,
4667 neighbor_interface_config_v6only_cmd
,
4668 "neighbor WORD interface v6only [peer-group PGNAME]",
4670 "Interface name or neighbor tag\n"
4671 "Enable BGP on interface\n"
4672 "Enable BGP with v6 link-local only\n"
4673 "Member of the peer-group\n"
4674 "Peer-group name\n")
4677 int idx_peer_group_word
= 5;
4679 if (argc
> idx_peer_group_word
)
4680 return peer_conf_interface_get(
4681 vty
, argv
[idx_word
]->arg
, 1,
4682 argv
[idx_peer_group_word
]->arg
, NULL
);
4684 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4688 DEFUN (neighbor_interface_config_remote_as
,
4689 neighbor_interface_config_remote_as_cmd
,
4690 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4692 "Interface name or neighbor tag\n"
4693 "Enable BGP on interface\n"
4694 "Specify a BGP neighbor\n"
4696 "Internal BGP peer\n"
4697 "External BGP peer\n")
4700 int idx_remote_as
= 4;
4701 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4702 argv
[idx_remote_as
]->arg
);
4705 DEFUN (neighbor_interface_v6only_config_remote_as
,
4706 neighbor_interface_v6only_config_remote_as_cmd
,
4707 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4709 "Interface name or neighbor tag\n"
4710 "Enable BGP with v6 link-local only\n"
4711 "Enable BGP on interface\n"
4712 "Specify a BGP neighbor\n"
4714 "Internal BGP peer\n"
4715 "External BGP peer\n")
4718 int idx_remote_as
= 5;
4719 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4720 argv
[idx_remote_as
]->arg
);
4723 DEFUN (neighbor_peer_group
,
4724 neighbor_peer_group_cmd
,
4725 "neighbor WORD peer-group",
4727 "Interface name or neighbor tag\n"
4728 "Configure peer-group\n")
4730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4733 struct peer_group
*group
;
4735 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4737 vty_out(vty
, "%% Name conflict with interface: \n");
4738 return CMD_WARNING_CONFIG_FAILED
;
4741 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4743 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4744 return CMD_WARNING_CONFIG_FAILED
;
4752 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4756 "Specify a BGP neighbor\n"
4758 "Internal BGP peer\n"
4759 "External BGP peer\n")
4761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4765 struct peer_group
*group
;
4769 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4771 /* look up for neighbor by interface name config. */
4772 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4774 /* Request zebra to terminate IPv6 RAs on this
4777 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4778 peer_notify_unconfig(peer
);
4783 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4785 peer_group_notify_unconfig(group
);
4786 peer_group_delete(group
);
4788 vty_out(vty
, "%% Create the peer-group first\n");
4789 return CMD_WARNING_CONFIG_FAILED
;
4792 peer
= peer_lookup(bgp
, &su
);
4794 if (peer_dynamic_neighbor(peer
)) {
4796 "%% Operation not allowed on a dynamic neighbor\n");
4797 return CMD_WARNING_CONFIG_FAILED
;
4800 other
= peer
->doppelganger
;
4802 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4803 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4805 peer_notify_unconfig(peer
);
4807 if (other
&& other
->status
!= Deleted
) {
4808 peer_notify_unconfig(other
);
4817 DEFUN (no_neighbor_interface_config
,
4818 no_neighbor_interface_config_cmd
,
4819 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4823 "Configure BGP on interface\n"
4824 "Enable BGP with v6 link-local only\n"
4825 "Member of the peer-group\n"
4827 "Specify a BGP neighbor\n"
4829 "Internal BGP peer\n"
4830 "External BGP peer\n")
4832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4836 /* look up for neighbor by interface name config. */
4837 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4839 /* Request zebra to terminate IPv6 RAs on this interface. */
4841 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4842 peer_notify_unconfig(peer
);
4845 vty_out(vty
, "%% Create the bgp interface first\n");
4846 return CMD_WARNING_CONFIG_FAILED
;
4851 DEFUN (no_neighbor_peer_group
,
4852 no_neighbor_peer_group_cmd
,
4853 "no neighbor WORD peer-group",
4857 "Configure peer-group\n")
4859 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4861 struct peer_group
*group
;
4863 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4865 peer_group_notify_unconfig(group
);
4866 peer_group_delete(group
);
4868 vty_out(vty
, "%% Create the peer-group first\n");
4869 return CMD_WARNING_CONFIG_FAILED
;
4874 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4875 no_neighbor_interface_peer_group_remote_as_cmd
,
4876 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4879 "Interface name or neighbor tag\n"
4880 "Specify a BGP neighbor\n"
4882 "Internal BGP peer\n"
4883 "External BGP peer\n")
4885 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4887 struct peer_group
*group
;
4890 /* look up for neighbor by interface name config. */
4891 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4893 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4897 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4899 peer_group_remote_as_delete(group
);
4901 vty_out(vty
, "%% Create the peer-group or interface first\n");
4902 return CMD_WARNING_CONFIG_FAILED
;
4907 DEFUN (neighbor_local_as
,
4908 neighbor_local_as_cmd
,
4909 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4912 "Specify a local-as number\n"
4913 "AS number used as local AS\n")
4921 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4923 return CMD_WARNING_CONFIG_FAILED
;
4925 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4926 ret
= peer_local_as_set(peer
, as
, 0, 0);
4927 return bgp_vty_return(vty
, ret
);
4930 DEFUN (neighbor_local_as_no_prepend
,
4931 neighbor_local_as_no_prepend_cmd
,
4932 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4935 "Specify a local-as number\n"
4936 "AS number used as local AS\n"
4937 "Do not prepend local-as to updates from ebgp peers\n")
4945 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4947 return CMD_WARNING_CONFIG_FAILED
;
4949 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4950 ret
= peer_local_as_set(peer
, as
, 1, 0);
4951 return bgp_vty_return(vty
, ret
);
4954 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4955 neighbor_local_as_no_prepend_replace_as_cmd
,
4956 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4959 "Specify a local-as number\n"
4960 "AS number used as local AS\n"
4961 "Do not prepend local-as to updates from ebgp peers\n"
4962 "Do not prepend local-as to updates from ibgp peers\n")
4970 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4972 return CMD_WARNING_CONFIG_FAILED
;
4974 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4975 ret
= peer_local_as_set(peer
, as
, 1, 1);
4976 return bgp_vty_return(vty
, ret
);
4979 DEFUN (no_neighbor_local_as
,
4980 no_neighbor_local_as_cmd
,
4981 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4985 "Specify a local-as number\n"
4986 "AS number used as local AS\n"
4987 "Do not prepend local-as to updates from ebgp peers\n"
4988 "Do not prepend local-as to updates from ibgp peers\n")
4994 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4996 return CMD_WARNING_CONFIG_FAILED
;
4998 ret
= peer_local_as_unset(peer
);
4999 return bgp_vty_return(vty
, ret
);
5003 DEFUN (neighbor_solo
,
5005 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5008 "Solo peer - part of its own update group\n")
5014 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5016 return CMD_WARNING_CONFIG_FAILED
;
5018 ret
= update_group_adjust_soloness(peer
, 1);
5019 return bgp_vty_return(vty
, ret
);
5022 DEFUN (no_neighbor_solo
,
5023 no_neighbor_solo_cmd
,
5024 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5028 "Solo peer - part of its own update group\n")
5034 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5036 return CMD_WARNING_CONFIG_FAILED
;
5038 ret
= update_group_adjust_soloness(peer
, 0);
5039 return bgp_vty_return(vty
, ret
);
5042 DEFUN (neighbor_password
,
5043 neighbor_password_cmd
,
5044 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5055 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5057 return CMD_WARNING_CONFIG_FAILED
;
5059 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5060 return bgp_vty_return(vty
, ret
);
5063 DEFUN (no_neighbor_password
,
5064 no_neighbor_password_cmd
,
5065 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5076 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5078 return CMD_WARNING_CONFIG_FAILED
;
5080 ret
= peer_password_unset(peer
);
5081 return bgp_vty_return(vty
, ret
);
5084 DEFUN (neighbor_activate
,
5085 neighbor_activate_cmd
,
5086 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5089 "Enable the Address Family for this Neighbor\n")
5095 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5097 return CMD_WARNING_CONFIG_FAILED
;
5099 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5100 return bgp_vty_return(vty
, ret
);
5103 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5104 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5105 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5106 "Enable the Address Family for this Neighbor\n")
5108 DEFUN (no_neighbor_activate
,
5109 no_neighbor_activate_cmd
,
5110 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5114 "Enable the Address Family for this Neighbor\n")
5121 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5123 return CMD_WARNING_CONFIG_FAILED
;
5125 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5126 return bgp_vty_return(vty
, ret
);
5129 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5130 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5131 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5132 "Enable the Address Family for this Neighbor\n")
5134 DEFUN (neighbor_set_peer_group
,
5135 neighbor_set_peer_group_cmd
,
5136 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5139 "Member of the peer-group\n"
5140 "Peer-group name\n")
5142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5149 struct peer_group
*group
;
5151 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5153 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5155 vty_out(vty
, "%% Malformed address or name: %s\n",
5156 argv
[idx_peer
]->arg
);
5157 return CMD_WARNING_CONFIG_FAILED
;
5160 if (peer_address_self_check(bgp
, &su
)) {
5162 "%% Can not configure the local system as neighbor\n");
5163 return CMD_WARNING_CONFIG_FAILED
;
5166 /* Disallow for dynamic neighbor. */
5167 peer
= peer_lookup(bgp
, &su
);
5168 if (peer
&& peer_dynamic_neighbor(peer
)) {
5170 "%% Operation not allowed on a dynamic neighbor\n");
5171 return CMD_WARNING_CONFIG_FAILED
;
5175 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5177 vty_out(vty
, "%% Configure the peer-group first\n");
5178 return CMD_WARNING_CONFIG_FAILED
;
5181 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5183 return bgp_vty_return(vty
, ret
);
5186 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5187 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5188 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5189 "Member of the peer-group\n"
5190 "Peer-group name\n")
5192 DEFUN (no_neighbor_set_peer_group
,
5193 no_neighbor_set_peer_group_cmd
,
5194 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5198 "Member of the peer-group\n"
5199 "Peer-group name\n")
5201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5206 struct peer_group
*group
;
5208 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5210 return CMD_WARNING_CONFIG_FAILED
;
5212 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5214 vty_out(vty
, "%% Configure the peer-group first\n");
5215 return CMD_WARNING_CONFIG_FAILED
;
5218 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5219 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5221 peer_notify_unconfig(peer
);
5222 ret
= peer_delete(peer
);
5224 return bgp_vty_return(vty
, ret
);
5227 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5228 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5229 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5230 "Member of the peer-group\n"
5231 "Peer-group name\n")
5233 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5234 uint64_t flag
, int set
)
5239 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5241 return CMD_WARNING_CONFIG_FAILED
;
5244 * If 'neighbor <interface>', then this is for directly connected peers,
5245 * we should not accept disable-connected-check.
5247 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5249 "%s is directly connected peer, cannot accept disable-connected-check\n",
5251 return CMD_WARNING_CONFIG_FAILED
;
5254 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5255 peer_tx_shutdown_message_unset(peer
);
5258 ret
= peer_flag_set(peer
, flag
);
5260 ret
= peer_flag_unset(peer
, flag
);
5262 return bgp_vty_return(vty
, ret
);
5265 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5267 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5270 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5273 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5276 /* neighbor passive. */
5277 DEFUN (neighbor_passive
,
5278 neighbor_passive_cmd
,
5279 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5282 "Don't send open messages to this neighbor\n")
5285 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5288 DEFUN (no_neighbor_passive
,
5289 no_neighbor_passive_cmd
,
5290 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5294 "Don't send open messages to this neighbor\n")
5297 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5300 /* neighbor shutdown. */
5301 DEFUN (neighbor_shutdown_msg
,
5302 neighbor_shutdown_msg_cmd
,
5303 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5306 "Administratively shut down this neighbor\n"
5307 "Add a shutdown message (RFC 8203)\n"
5308 "Shutdown message\n")
5314 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5318 return CMD_WARNING_CONFIG_FAILED
;
5319 message
= argv_concat(argv
, argc
, 4);
5320 peer_tx_shutdown_message_set(peer
, message
);
5321 XFREE(MTYPE_TMP
, message
);
5324 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5327 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5328 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5329 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5330 "Administratively shut down this neighbor\n")
5332 DEFUN (no_neighbor_shutdown_msg
,
5333 no_neighbor_shutdown_msg_cmd
,
5334 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5338 "Administratively shut down this neighbor\n"
5339 "Remove a shutdown message (RFC 8203)\n"
5340 "Shutdown message\n")
5344 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5345 PEER_FLAG_SHUTDOWN
);
5348 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5349 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5350 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5351 "Administratively shut down this neighbor\n")
5353 DEFUN(neighbor_shutdown_rtt
,
5354 neighbor_shutdown_rtt_cmd
,
5355 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5358 "Administratively shut down this neighbor\n"
5359 "Shutdown if round-trip-time is higher than expected\n"
5360 "Round-trip-time in milliseconds\n"
5361 "Specify the number of keepalives before shutdown\n"
5362 "The number of keepalives with higher RTT to shutdown\n")
5369 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5372 return CMD_WARNING_CONFIG_FAILED
;
5374 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5376 if (argv_find(argv
, argc
, "count", &idx_count
))
5377 peer
->rtt_keepalive_conf
=
5378 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5380 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5381 PEER_FLAG_RTT_SHUTDOWN
);
5384 DEFUN(no_neighbor_shutdown_rtt
,
5385 no_neighbor_shutdown_rtt_cmd
,
5386 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5390 "Administratively shut down this neighbor\n"
5391 "Shutdown if round-trip-time is higher than expected\n"
5392 "Round-trip-time in milliseconds\n"
5393 "Specify the number of keepalives before shutdown\n"
5394 "The number of keepalives with higher RTT to shutdown\n")
5399 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5402 return CMD_WARNING_CONFIG_FAILED
;
5404 peer
->rtt_expected
= 0;
5405 peer
->rtt_keepalive_conf
= 1;
5407 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5408 PEER_FLAG_RTT_SHUTDOWN
);
5411 /* neighbor capability dynamic. */
5412 DEFUN (neighbor_capability_dynamic
,
5413 neighbor_capability_dynamic_cmd
,
5414 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5417 "Advertise capability to the peer\n"
5418 "Advertise dynamic capability to this neighbor\n")
5421 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5422 PEER_FLAG_DYNAMIC_CAPABILITY
);
5425 DEFUN (no_neighbor_capability_dynamic
,
5426 no_neighbor_capability_dynamic_cmd
,
5427 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5431 "Advertise capability to the peer\n"
5432 "Advertise dynamic capability to this neighbor\n")
5435 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5436 PEER_FLAG_DYNAMIC_CAPABILITY
);
5439 /* neighbor dont-capability-negotiate */
5440 DEFUN (neighbor_dont_capability_negotiate
,
5441 neighbor_dont_capability_negotiate_cmd
,
5442 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5445 "Do not perform capability negotiation\n")
5448 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5449 PEER_FLAG_DONT_CAPABILITY
);
5452 DEFUN (no_neighbor_dont_capability_negotiate
,
5453 no_neighbor_dont_capability_negotiate_cmd
,
5454 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5458 "Do not perform capability negotiation\n")
5461 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5462 PEER_FLAG_DONT_CAPABILITY
);
5465 /* neighbor capability extended next hop encoding */
5466 DEFUN (neighbor_capability_enhe
,
5467 neighbor_capability_enhe_cmd
,
5468 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5471 "Advertise capability to the peer\n"
5472 "Advertise extended next-hop capability to the peer\n")
5477 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5478 if (peer
&& peer
->conf_if
)
5481 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5482 PEER_FLAG_CAPABILITY_ENHE
);
5485 DEFUN (no_neighbor_capability_enhe
,
5486 no_neighbor_capability_enhe_cmd
,
5487 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5491 "Advertise capability to the peer\n"
5492 "Advertise extended next-hop capability to the peer\n")
5497 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5498 if (peer
&& peer
->conf_if
) {
5500 "Peer %s cannot have capability extended-nexthop turned off\n",
5501 argv
[idx_peer
]->arg
);
5502 return CMD_WARNING_CONFIG_FAILED
;
5505 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5506 PEER_FLAG_CAPABILITY_ENHE
);
5509 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5510 afi_t afi
, safi_t safi
, uint32_t flag
,
5516 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5518 return CMD_WARNING_CONFIG_FAILED
;
5521 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5523 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5525 return bgp_vty_return(vty
, ret
);
5528 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5529 afi_t afi
, safi_t safi
, uint32_t flag
)
5531 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5534 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5535 afi_t afi
, safi_t safi
, uint32_t flag
)
5537 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5540 /* neighbor capability orf prefix-list. */
5541 DEFUN (neighbor_capability_orf_prefix
,
5542 neighbor_capability_orf_prefix_cmd
,
5543 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5546 "Advertise capability to the peer\n"
5547 "Advertise ORF capability to the peer\n"
5548 "Advertise prefixlist ORF capability to this neighbor\n"
5549 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5550 "Capability to RECEIVE the ORF from this neighbor\n"
5551 "Capability to SEND the ORF to this neighbor\n")
5553 int idx_send_recv
= 5;
5554 char *peer_str
= argv
[1]->arg
;
5556 afi_t afi
= bgp_node_afi(vty
);
5557 safi_t safi
= bgp_node_safi(vty
);
5559 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5561 return CMD_WARNING_CONFIG_FAILED
;
5563 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5564 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5565 PEER_FLAG_ORF_PREFIX_SM
);
5567 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5568 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5569 PEER_FLAG_ORF_PREFIX_RM
);
5571 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5572 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5573 PEER_FLAG_ORF_PREFIX_SM
)
5574 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5575 PEER_FLAG_ORF_PREFIX_RM
);
5577 return CMD_WARNING_CONFIG_FAILED
;
5581 neighbor_capability_orf_prefix
,
5582 neighbor_capability_orf_prefix_hidden_cmd
,
5583 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5584 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5585 "Advertise capability to the peer\n"
5586 "Advertise ORF capability to the peer\n"
5587 "Advertise prefixlist ORF capability to this neighbor\n"
5588 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5589 "Capability to RECEIVE the ORF from this neighbor\n"
5590 "Capability to SEND the ORF to this neighbor\n")
5592 DEFUN (no_neighbor_capability_orf_prefix
,
5593 no_neighbor_capability_orf_prefix_cmd
,
5594 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5598 "Advertise capability to the peer\n"
5599 "Advertise ORF capability to the peer\n"
5600 "Advertise prefixlist ORF capability to this neighbor\n"
5601 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5602 "Capability to RECEIVE the ORF from this neighbor\n"
5603 "Capability to SEND the ORF to this neighbor\n")
5605 int idx_send_recv
= 6;
5606 char *peer_str
= argv
[2]->arg
;
5608 afi_t afi
= bgp_node_afi(vty
);
5609 safi_t safi
= bgp_node_safi(vty
);
5611 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5613 return CMD_WARNING_CONFIG_FAILED
;
5615 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5616 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5617 PEER_FLAG_ORF_PREFIX_SM
);
5619 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5620 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5621 PEER_FLAG_ORF_PREFIX_RM
);
5623 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5624 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5625 PEER_FLAG_ORF_PREFIX_SM
)
5626 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5627 PEER_FLAG_ORF_PREFIX_RM
);
5629 return CMD_WARNING_CONFIG_FAILED
;
5633 no_neighbor_capability_orf_prefix
,
5634 no_neighbor_capability_orf_prefix_hidden_cmd
,
5635 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5636 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Advertise capability to the peer\n"
5638 "Advertise ORF capability to the peer\n"
5639 "Advertise prefixlist ORF capability to this neighbor\n"
5640 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5641 "Capability to RECEIVE the ORF from this neighbor\n"
5642 "Capability to SEND the ORF to this neighbor\n")
5644 /* neighbor next-hop-self. */
5645 DEFUN (neighbor_nexthop_self
,
5646 neighbor_nexthop_self_cmd
,
5647 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5650 "Disable the next hop calculation for this neighbor\n")
5653 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5654 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5657 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5658 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5659 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5660 "Disable the next hop calculation for this neighbor\n")
5662 /* neighbor next-hop-self. */
5663 DEFUN (neighbor_nexthop_self_force
,
5664 neighbor_nexthop_self_force_cmd
,
5665 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5668 "Disable the next hop calculation for this neighbor\n"
5669 "Set the next hop to self for reflected routes\n")
5672 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5674 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5677 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5678 neighbor_nexthop_self_force_hidden_cmd
,
5679 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5680 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5681 "Disable the next hop calculation for this neighbor\n"
5682 "Set the next hop to self for reflected routes\n")
5684 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5685 neighbor_nexthop_self_all_hidden_cmd
,
5686 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5687 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5688 "Disable the next hop calculation for this neighbor\n"
5689 "Set the next hop to self for reflected routes\n")
5691 DEFUN (no_neighbor_nexthop_self
,
5692 no_neighbor_nexthop_self_cmd
,
5693 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5697 "Disable the next hop calculation for this neighbor\n")
5700 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5701 bgp_node_afi(vty
), bgp_node_safi(vty
),
5702 PEER_FLAG_NEXTHOP_SELF
);
5705 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5706 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5708 "Disable the next hop calculation for this neighbor\n")
5710 DEFUN (no_neighbor_nexthop_self_force
,
5711 no_neighbor_nexthop_self_force_cmd
,
5712 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5716 "Disable the next hop calculation for this neighbor\n"
5717 "Set the next hop to self for reflected routes\n")
5720 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5721 bgp_node_afi(vty
), bgp_node_safi(vty
),
5722 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5725 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5726 no_neighbor_nexthop_self_force_hidden_cmd
,
5727 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5728 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5729 "Disable the next hop calculation for this neighbor\n"
5730 "Set the next hop to self for reflected routes\n")
5732 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5733 no_neighbor_nexthop_self_all_hidden_cmd
,
5734 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5735 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Disable the next hop calculation for this neighbor\n"
5737 "Set the next hop to self for reflected routes\n")
5739 /* neighbor as-override */
5740 DEFUN (neighbor_as_override
,
5741 neighbor_as_override_cmd
,
5742 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5745 "Override ASNs in outbound updates if aspath equals remote-as\n")
5748 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5749 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5752 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5753 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5754 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5755 "Override ASNs in outbound updates if aspath equals remote-as\n")
5757 DEFUN (no_neighbor_as_override
,
5758 no_neighbor_as_override_cmd
,
5759 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5763 "Override ASNs in outbound updates if aspath equals remote-as\n")
5766 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5767 bgp_node_afi(vty
), bgp_node_safi(vty
),
5768 PEER_FLAG_AS_OVERRIDE
);
5771 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5772 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5773 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5774 "Override ASNs in outbound updates if aspath equals remote-as\n")
5776 /* neighbor remove-private-AS. */
5777 DEFUN (neighbor_remove_private_as
,
5778 neighbor_remove_private_as_cmd
,
5779 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5782 "Remove private ASNs in outbound updates\n")
5785 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5787 PEER_FLAG_REMOVE_PRIVATE_AS
);
5790 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5791 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5792 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5793 "Remove private ASNs in outbound updates\n")
5795 DEFUN (neighbor_remove_private_as_all
,
5796 neighbor_remove_private_as_all_cmd
,
5797 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5800 "Remove private ASNs in outbound updates\n"
5801 "Apply to all AS numbers\n")
5804 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5806 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5809 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5810 neighbor_remove_private_as_all_hidden_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5813 "Remove private ASNs in outbound updates\n"
5814 "Apply to all AS numbers")
5816 DEFUN (neighbor_remove_private_as_replace_as
,
5817 neighbor_remove_private_as_replace_as_cmd
,
5818 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5821 "Remove private ASNs in outbound updates\n"
5822 "Replace private ASNs with our ASN in outbound updates\n")
5825 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5827 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5830 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5831 neighbor_remove_private_as_replace_as_hidden_cmd
,
5832 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5833 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5834 "Remove private ASNs in outbound updates\n"
5835 "Replace private ASNs with our ASN in outbound updates\n")
5837 DEFUN (neighbor_remove_private_as_all_replace_as
,
5838 neighbor_remove_private_as_all_replace_as_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5842 "Remove private ASNs in outbound updates\n"
5843 "Apply to all AS numbers\n"
5844 "Replace private ASNs with our ASN in outbound updates\n")
5847 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5849 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5853 neighbor_remove_private_as_all_replace_as
,
5854 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5855 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5857 "Remove private ASNs in outbound updates\n"
5858 "Apply to all AS numbers\n"
5859 "Replace private ASNs with our ASN in outbound updates\n")
5861 DEFUN (no_neighbor_remove_private_as
,
5862 no_neighbor_remove_private_as_cmd
,
5863 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5867 "Remove private ASNs in outbound updates\n")
5870 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5871 bgp_node_afi(vty
), bgp_node_safi(vty
),
5872 PEER_FLAG_REMOVE_PRIVATE_AS
);
5875 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5876 no_neighbor_remove_private_as_hidden_cmd
,
5877 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5878 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5879 "Remove private ASNs in outbound updates\n")
5881 DEFUN (no_neighbor_remove_private_as_all
,
5882 no_neighbor_remove_private_as_all_cmd
,
5883 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5887 "Remove private ASNs in outbound updates\n"
5888 "Apply to all AS numbers\n")
5891 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5892 bgp_node_afi(vty
), bgp_node_safi(vty
),
5893 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5896 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5897 no_neighbor_remove_private_as_all_hidden_cmd
,
5898 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5899 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5900 "Remove private ASNs in outbound updates\n"
5901 "Apply to all AS numbers\n")
5903 DEFUN (no_neighbor_remove_private_as_replace_as
,
5904 no_neighbor_remove_private_as_replace_as_cmd
,
5905 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5909 "Remove private ASNs in outbound updates\n"
5910 "Replace private ASNs with our ASN in outbound updates\n")
5913 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5914 bgp_node_afi(vty
), bgp_node_safi(vty
),
5915 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5918 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5919 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5920 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5921 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5922 "Remove private ASNs in outbound updates\n"
5923 "Replace private ASNs with our ASN in outbound updates\n")
5925 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5926 no_neighbor_remove_private_as_all_replace_as_cmd
,
5927 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5931 "Remove private ASNs in outbound updates\n"
5932 "Apply to all AS numbers\n"
5933 "Replace private ASNs with our ASN in outbound updates\n")
5936 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5937 bgp_node_afi(vty
), bgp_node_safi(vty
),
5938 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5942 no_neighbor_remove_private_as_all_replace_as
,
5943 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5944 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5946 "Remove private ASNs in outbound updates\n"
5947 "Apply to all AS numbers\n"
5948 "Replace private ASNs with our ASN in outbound updates\n")
5951 /* neighbor send-community. */
5952 DEFUN (neighbor_send_community
,
5953 neighbor_send_community_cmd
,
5954 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5957 "Send Community attribute to this neighbor\n")
5961 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5963 PEER_FLAG_SEND_COMMUNITY
);
5966 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5967 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "Send Community attribute to this neighbor\n")
5971 DEFUN (no_neighbor_send_community
,
5972 no_neighbor_send_community_cmd
,
5973 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5977 "Send Community attribute to this neighbor\n")
5981 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5982 bgp_node_afi(vty
), bgp_node_safi(vty
),
5983 PEER_FLAG_SEND_COMMUNITY
);
5986 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5987 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5988 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5989 "Send Community attribute to this neighbor\n")
5991 /* neighbor send-community extended. */
5992 DEFUN (neighbor_send_community_type
,
5993 neighbor_send_community_type_cmd
,
5994 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5997 "Send Community attribute to this neighbor\n"
5998 "Send Standard and Extended Community attributes\n"
5999 "Send Standard, Large and Extended Community attributes\n"
6000 "Send Extended Community attributes\n"
6001 "Send Standard Community attributes\n"
6002 "Send Large Community attributes\n")
6004 const char *type
= argv
[argc
- 1]->text
;
6005 char *peer_str
= argv
[1]->arg
;
6007 afi_t afi
= bgp_node_afi(vty
);
6008 safi_t safi
= bgp_node_safi(vty
);
6010 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6012 return CMD_WARNING_CONFIG_FAILED
;
6014 if (strmatch(type
, "standard"))
6015 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6016 PEER_FLAG_SEND_COMMUNITY
);
6018 if (strmatch(type
, "extended"))
6019 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6020 PEER_FLAG_SEND_EXT_COMMUNITY
);
6022 if (strmatch(type
, "large"))
6023 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6024 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6026 if (strmatch(type
, "both")) {
6027 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6028 PEER_FLAG_SEND_COMMUNITY
)
6029 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6030 PEER_FLAG_SEND_EXT_COMMUNITY
);
6032 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6033 PEER_FLAG_SEND_COMMUNITY
)
6034 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6035 PEER_FLAG_SEND_EXT_COMMUNITY
)
6036 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6037 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6041 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6042 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6043 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6044 "Send Community attribute to this neighbor\n"
6045 "Send Standard and Extended Community attributes\n"
6046 "Send Standard, Large and Extended Community attributes\n"
6047 "Send Extended Community attributes\n"
6048 "Send Standard Community attributes\n"
6049 "Send Large Community attributes\n")
6051 DEFUN (no_neighbor_send_community_type
,
6052 no_neighbor_send_community_type_cmd
,
6053 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6057 "Send Community attribute to this neighbor\n"
6058 "Send Standard and Extended Community attributes\n"
6059 "Send Standard, Large and Extended Community attributes\n"
6060 "Send Extended Community attributes\n"
6061 "Send Standard Community attributes\n"
6062 "Send Large Community attributes\n")
6064 const char *type
= argv
[argc
- 1]->text
;
6065 char *peer_str
= argv
[2]->arg
;
6067 afi_t afi
= bgp_node_afi(vty
);
6068 safi_t safi
= bgp_node_safi(vty
);
6070 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6072 return CMD_WARNING_CONFIG_FAILED
;
6074 if (strmatch(type
, "standard"))
6075 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6076 PEER_FLAG_SEND_COMMUNITY
);
6078 if (strmatch(type
, "extended"))
6079 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6080 PEER_FLAG_SEND_EXT_COMMUNITY
);
6082 if (strmatch(type
, "large"))
6083 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6084 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6086 if (strmatch(type
, "both")) {
6088 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6089 PEER_FLAG_SEND_COMMUNITY
)
6090 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6091 PEER_FLAG_SEND_EXT_COMMUNITY
);
6094 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6095 PEER_FLAG_SEND_COMMUNITY
)
6096 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6097 PEER_FLAG_SEND_EXT_COMMUNITY
)
6098 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6099 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6103 no_neighbor_send_community_type
,
6104 no_neighbor_send_community_type_hidden_cmd
,
6105 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6106 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
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 /* neighbor soft-reconfig. */
6115 DEFUN (neighbor_soft_reconfiguration
,
6116 neighbor_soft_reconfiguration_cmd
,
6117 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6120 "Per neighbor soft reconfiguration\n"
6121 "Allow inbound soft reconfiguration for this neighbor\n")
6124 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6126 PEER_FLAG_SOFT_RECONFIG
);
6129 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6130 neighbor_soft_reconfiguration_hidden_cmd
,
6131 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6132 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6133 "Per neighbor soft reconfiguration\n"
6134 "Allow inbound soft reconfiguration for this neighbor\n")
6136 DEFUN (no_neighbor_soft_reconfiguration
,
6137 no_neighbor_soft_reconfiguration_cmd
,
6138 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6142 "Per neighbor soft reconfiguration\n"
6143 "Allow inbound soft reconfiguration for this neighbor\n")
6146 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6147 bgp_node_afi(vty
), bgp_node_safi(vty
),
6148 PEER_FLAG_SOFT_RECONFIG
);
6151 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6152 no_neighbor_soft_reconfiguration_hidden_cmd
,
6153 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6154 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6155 "Per neighbor soft reconfiguration\n"
6156 "Allow inbound soft reconfiguration for this neighbor\n")
6158 DEFUN (neighbor_route_reflector_client
,
6159 neighbor_route_reflector_client_cmd
,
6160 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6163 "Configure a neighbor as Route Reflector client\n")
6169 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6171 return CMD_WARNING_CONFIG_FAILED
;
6173 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6175 PEER_FLAG_REFLECTOR_CLIENT
);
6178 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6179 neighbor_route_reflector_client_hidden_cmd
,
6180 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6181 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6182 "Configure a neighbor as Route Reflector client\n")
6184 DEFUN (no_neighbor_route_reflector_client
,
6185 no_neighbor_route_reflector_client_cmd
,
6186 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6190 "Configure a neighbor as Route Reflector client\n")
6193 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6194 bgp_node_afi(vty
), bgp_node_safi(vty
),
6195 PEER_FLAG_REFLECTOR_CLIENT
);
6198 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6199 no_neighbor_route_reflector_client_hidden_cmd
,
6200 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6201 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6202 "Configure a neighbor as Route Reflector client\n")
6204 /* neighbor route-server-client. */
6205 DEFUN (neighbor_route_server_client
,
6206 neighbor_route_server_client_cmd
,
6207 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6210 "Configure a neighbor as Route Server client\n")
6215 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6217 return CMD_WARNING_CONFIG_FAILED
;
6218 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6220 PEER_FLAG_RSERVER_CLIENT
);
6223 ALIAS_HIDDEN(neighbor_route_server_client
,
6224 neighbor_route_server_client_hidden_cmd
,
6225 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6226 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6227 "Configure a neighbor as Route Server client\n")
6229 DEFUN (no_neighbor_route_server_client
,
6230 no_neighbor_route_server_client_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6235 "Configure a neighbor as Route Server client\n")
6238 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6239 bgp_node_afi(vty
), bgp_node_safi(vty
),
6240 PEER_FLAG_RSERVER_CLIENT
);
6243 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6244 no_neighbor_route_server_client_hidden_cmd
,
6245 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6246 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6247 "Configure a neighbor as Route Server client\n")
6249 DEFUN (neighbor_nexthop_local_unchanged
,
6250 neighbor_nexthop_local_unchanged_cmd
,
6251 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6254 "Configure treatment of outgoing link-local nexthop attribute\n"
6255 "Leave link-local nexthop unchanged for this peer\n")
6258 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6260 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6263 DEFUN (no_neighbor_nexthop_local_unchanged
,
6264 no_neighbor_nexthop_local_unchanged_cmd
,
6265 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6269 "Configure treatment of outgoing link-local-nexthop attribute\n"
6270 "Leave link-local nexthop unchanged for this peer\n")
6273 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6274 bgp_node_afi(vty
), bgp_node_safi(vty
),
6275 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6278 DEFUN (neighbor_attr_unchanged
,
6279 neighbor_attr_unchanged_cmd
,
6280 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6283 "BGP attribute is propagated unchanged to this neighbor\n"
6284 "As-path attribute\n"
6285 "Nexthop attribute\n"
6289 char *peer_str
= argv
[1]->arg
;
6291 bool aspath
= false;
6292 bool nexthop
= false;
6294 afi_t afi
= bgp_node_afi(vty
);
6295 safi_t safi
= bgp_node_safi(vty
);
6298 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6300 return CMD_WARNING_CONFIG_FAILED
;
6302 if (argv_find(argv
, argc
, "as-path", &idx
))
6306 if (argv_find(argv
, argc
, "next-hop", &idx
))
6310 if (argv_find(argv
, argc
, "med", &idx
))
6313 /* no flags means all of them! */
6314 if (!aspath
&& !nexthop
&& !med
) {
6315 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6316 PEER_FLAG_AS_PATH_UNCHANGED
);
6317 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6318 PEER_FLAG_NEXTHOP_UNCHANGED
);
6319 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6320 PEER_FLAG_MED_UNCHANGED
);
6323 if (peer_af_flag_check(peer
, afi
, safi
,
6324 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6325 ret
|= peer_af_flag_unset_vty(
6326 vty
, peer_str
, afi
, safi
,
6327 PEER_FLAG_AS_PATH_UNCHANGED
);
6330 ret
|= peer_af_flag_set_vty(
6331 vty
, peer_str
, afi
, safi
,
6332 PEER_FLAG_AS_PATH_UNCHANGED
);
6335 if (peer_af_flag_check(peer
, afi
, safi
,
6336 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6337 ret
|= peer_af_flag_unset_vty(
6338 vty
, peer_str
, afi
, safi
,
6339 PEER_FLAG_NEXTHOP_UNCHANGED
);
6342 ret
|= peer_af_flag_set_vty(
6343 vty
, peer_str
, afi
, safi
,
6344 PEER_FLAG_NEXTHOP_UNCHANGED
);
6347 if (peer_af_flag_check(peer
, afi
, safi
,
6348 PEER_FLAG_MED_UNCHANGED
)) {
6349 ret
|= peer_af_flag_unset_vty(
6350 vty
, peer_str
, afi
, safi
,
6351 PEER_FLAG_MED_UNCHANGED
);
6354 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6355 PEER_FLAG_MED_UNCHANGED
);
6362 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6363 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6364 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6365 "BGP attribute is propagated unchanged to this neighbor\n"
6366 "As-path attribute\n"
6367 "Nexthop attribute\n"
6370 DEFUN (no_neighbor_attr_unchanged
,
6371 no_neighbor_attr_unchanged_cmd
,
6372 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6376 "BGP attribute is propagated unchanged to this neighbor\n"
6377 "As-path attribute\n"
6378 "Nexthop attribute\n"
6382 char *peer_str
= argv
[2]->arg
;
6384 bool aspath
= false;
6385 bool nexthop
= false;
6387 afi_t afi
= bgp_node_afi(vty
);
6388 safi_t safi
= bgp_node_safi(vty
);
6391 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6393 return CMD_WARNING_CONFIG_FAILED
;
6395 if (argv_find(argv
, argc
, "as-path", &idx
))
6399 if (argv_find(argv
, argc
, "next-hop", &idx
))
6403 if (argv_find(argv
, argc
, "med", &idx
))
6406 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6407 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6408 PEER_FLAG_AS_PATH_UNCHANGED
)
6409 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6410 PEER_FLAG_NEXTHOP_UNCHANGED
)
6411 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6412 PEER_FLAG_MED_UNCHANGED
);
6415 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6416 PEER_FLAG_AS_PATH_UNCHANGED
);
6419 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6420 PEER_FLAG_NEXTHOP_UNCHANGED
);
6423 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6424 PEER_FLAG_MED_UNCHANGED
);
6430 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6431 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6432 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6433 "BGP attribute is propagated unchanged to this neighbor\n"
6434 "As-path attribute\n"
6435 "Nexthop attribute\n"
6438 /* EBGP multihop configuration. */
6439 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6440 const char *ttl_str
)
6445 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6447 return CMD_WARNING_CONFIG_FAILED
;
6450 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6455 ttl
= strtoul(ttl_str
, NULL
, 10);
6457 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6460 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6464 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6466 return CMD_WARNING_CONFIG_FAILED
;
6468 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6471 /* neighbor ebgp-multihop. */
6472 DEFUN (neighbor_ebgp_multihop
,
6473 neighbor_ebgp_multihop_cmd
,
6474 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6477 "Allow EBGP neighbors not on directly connected networks\n")
6480 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6483 DEFUN (neighbor_ebgp_multihop_ttl
,
6484 neighbor_ebgp_multihop_ttl_cmd
,
6485 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6488 "Allow EBGP neighbors not on directly connected networks\n"
6489 "maximum hop count\n")
6493 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6494 argv
[idx_number
]->arg
);
6497 DEFUN (no_neighbor_ebgp_multihop
,
6498 no_neighbor_ebgp_multihop_cmd
,
6499 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6503 "Allow EBGP neighbors not on directly connected networks\n"
6504 "maximum hop count\n")
6507 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6510 static uint8_t get_role_by_name(const char *role_str
)
6512 if (strncmp(role_str
, "peer", 2) == 0)
6514 if (strncmp(role_str
, "provider", 2) == 0)
6515 return ROLE_PROVIDER
;
6516 if (strncmp(role_str
, "customer", 2) == 0)
6517 return ROLE_CUSTOMER
;
6518 if (strncmp(role_str
, "rs-server", 4) == 0)
6519 return ROLE_RS_SERVER
;
6520 if (strncmp(role_str
, "rs-client", 4) == 0)
6521 return ROLE_RS_CLIENT
;
6522 return ROLE_UNDEFINED
;
6525 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6526 const char *role_str
, bool strict_mode
)
6530 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6532 return CMD_WARNING_CONFIG_FAILED
;
6533 uint8_t role
= get_role_by_name(role_str
);
6535 if (role
== ROLE_UNDEFINED
)
6536 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6537 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6540 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6544 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6546 return CMD_WARNING_CONFIG_FAILED
;
6547 return bgp_vty_return(vty
, peer_role_unset(peer
));
6550 DEFPY(neighbor_role
,
6552 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6555 "Set session role\n"
6561 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6565 DEFPY(neighbor_role_strict
,
6566 neighbor_role_strict_cmd
,
6567 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6570 "Set session role\n"
6572 "Use additional restriction on peer\n")
6577 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6581 DEFPY(no_neighbor_role
,
6582 no_neighbor_role_cmd
,
6583 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6587 "Set session role\n"
6589 "Use additional restriction on peer\n")
6593 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6596 /* disable-connected-check */
6597 DEFUN (neighbor_disable_connected_check
,
6598 neighbor_disable_connected_check_cmd
,
6599 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6602 "one-hop away EBGP peer using loopback address\n"
6603 "Enforce EBGP neighbors perform multihop\n")
6606 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6607 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6610 DEFUN (no_neighbor_disable_connected_check
,
6611 no_neighbor_disable_connected_check_cmd
,
6612 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6616 "one-hop away EBGP peer using loopback address\n"
6617 "Enforce EBGP neighbors perform multihop\n")
6620 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6621 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6624 /* disable-link-bw-encoding-ieee */
6625 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6626 neighbor_disable_link_bw_encoding_ieee_cmd
,
6627 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6628 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6629 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6633 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6634 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6637 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6638 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6639 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6640 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6641 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6645 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6646 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6649 /* extended-optional-parameters */
6650 DEFUN(neighbor_extended_optional_parameters
,
6651 neighbor_extended_optional_parameters_cmd
,
6652 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6653 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6654 "Force the extended optional parameters format for OPEN messages\n")
6658 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6659 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6662 DEFUN(no_neighbor_extended_optional_parameters
,
6663 no_neighbor_extended_optional_parameters_cmd
,
6664 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6665 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6666 "Force the extended optional parameters format for OPEN messages\n")
6670 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6671 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6674 /* enforce-first-as */
6675 DEFUN (neighbor_enforce_first_as
,
6676 neighbor_enforce_first_as_cmd
,
6677 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6680 "Enforce the first AS for EBGP routes\n")
6684 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6685 PEER_FLAG_ENFORCE_FIRST_AS
);
6688 DEFUN (no_neighbor_enforce_first_as
,
6689 no_neighbor_enforce_first_as_cmd
,
6690 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6694 "Enforce the first AS for EBGP routes\n")
6698 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6699 PEER_FLAG_ENFORCE_FIRST_AS
);
6703 DEFUN (neighbor_description
,
6704 neighbor_description_cmd
,
6705 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6708 "Neighbor specific description\n"
6709 "Up to 80 characters describing this neighbor\n")
6716 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6718 return CMD_WARNING_CONFIG_FAILED
;
6720 str
= argv_concat(argv
, argc
, idx_line
);
6722 peer_description_set(peer
, str
);
6724 XFREE(MTYPE_TMP
, str
);
6729 DEFUN (no_neighbor_description
,
6730 no_neighbor_description_cmd
,
6731 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6735 "Neighbor specific description\n")
6740 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6742 return CMD_WARNING_CONFIG_FAILED
;
6744 peer_description_unset(peer
);
6749 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6750 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6751 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6752 "Neighbor specific description\n"
6753 "Up to 80 characters describing this neighbor\n")
6755 /* Neighbor update-source. */
6756 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6757 const char *source_str
)
6763 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6765 return CMD_WARNING_CONFIG_FAILED
;
6771 if (str2sockunion(source_str
, &su
) == 0)
6772 peer_update_source_addr_set(peer
, &su
);
6774 if (str2prefix(source_str
, &p
)) {
6776 "%% Invalid update-source, remove prefix length \n");
6777 return CMD_WARNING_CONFIG_FAILED
;
6779 peer_update_source_if_set(peer
, source_str
);
6782 peer_update_source_unset(peer
);
6787 #define BGP_UPDATE_SOURCE_HELP_STR \
6790 "Interface name (requires zebra to be running)\n"
6792 DEFUN (neighbor_update_source
,
6793 neighbor_update_source_cmd
,
6794 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6797 "Source of routing updates\n"
6798 BGP_UPDATE_SOURCE_HELP_STR
)
6802 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6803 argv
[idx_peer_2
]->arg
);
6806 DEFUN (no_neighbor_update_source
,
6807 no_neighbor_update_source_cmd
,
6808 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6812 "Source of routing updates\n"
6813 BGP_UPDATE_SOURCE_HELP_STR
)
6816 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6819 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6820 afi_t afi
, safi_t safi
,
6821 const char *rmap
, int set
)
6825 struct route_map
*route_map
= NULL
;
6827 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6829 return CMD_WARNING_CONFIG_FAILED
;
6833 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6834 ret
= peer_default_originate_set(peer
, afi
, safi
,
6837 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6839 return bgp_vty_return(vty
, ret
);
6842 /* neighbor default-originate. */
6843 DEFUN (neighbor_default_originate
,
6844 neighbor_default_originate_cmd
,
6845 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6848 "Originate default route to this neighbor\n")
6851 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6853 bgp_node_safi(vty
), NULL
, 1);
6856 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6857 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6858 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6859 "Originate default route to this neighbor\n")
6861 DEFUN (neighbor_default_originate_rmap
,
6862 neighbor_default_originate_rmap_cmd
,
6863 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6866 "Originate default route to this neighbor\n"
6867 "Route-map to specify criteria to originate default\n"
6872 return peer_default_originate_set_vty(
6873 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6874 argv
[idx_word
]->arg
, 1);
6878 neighbor_default_originate_rmap
,
6879 neighbor_default_originate_rmap_hidden_cmd
,
6880 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6882 "Originate default route to this neighbor\n"
6883 "Route-map to specify criteria to originate default\n"
6886 DEFUN (no_neighbor_default_originate
,
6887 no_neighbor_default_originate_cmd
,
6888 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6892 "Originate default route to this neighbor\n"
6893 "Route-map to specify criteria to originate default\n"
6897 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6899 bgp_node_safi(vty
), NULL
, 0);
6903 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6904 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6905 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6906 "Originate default route to this neighbor\n"
6907 "Route-map to specify criteria to originate default\n"
6911 /* Set neighbor's BGP port. */
6912 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6913 const char *port_str
)
6919 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6921 return CMD_WARNING_CONFIG_FAILED
;
6924 sp
= getservbyname("bgp", "tcp");
6925 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6927 port
= strtoul(port_str
, NULL
, 10);
6930 peer_port_set(peer
, port
);
6935 /* Set specified peer's BGP port. */
6936 DEFUN (neighbor_port
,
6938 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6941 "Neighbor's BGP port\n"
6942 "TCP port number\n")
6946 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6947 argv
[idx_number
]->arg
);
6950 DEFUN (no_neighbor_port
,
6951 no_neighbor_port_cmd
,
6952 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6956 "Neighbor's BGP port\n"
6957 "TCP port number\n")
6960 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6964 /* neighbor weight. */
6965 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6966 safi_t safi
, const char *weight_str
)
6970 unsigned long weight
;
6972 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6974 return CMD_WARNING_CONFIG_FAILED
;
6976 weight
= strtoul(weight_str
, NULL
, 10);
6978 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6979 return bgp_vty_return(vty
, ret
);
6982 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6988 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6990 return CMD_WARNING_CONFIG_FAILED
;
6992 ret
= peer_weight_unset(peer
, afi
, safi
);
6993 return bgp_vty_return(vty
, ret
);
6996 DEFUN (neighbor_weight
,
6997 neighbor_weight_cmd
,
6998 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7001 "Set default weight for routes from this neighbor\n"
7006 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7007 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7010 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7011 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7012 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7013 "Set default weight for routes from this neighbor\n"
7016 DEFUN (no_neighbor_weight
,
7017 no_neighbor_weight_cmd
,
7018 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7022 "Set default weight for routes from this neighbor\n"
7026 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7027 bgp_node_afi(vty
), bgp_node_safi(vty
));
7030 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7031 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7032 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7033 "Set default weight for routes from this neighbor\n"
7037 /* Override capability negotiation. */
7038 DEFUN (neighbor_override_capability
,
7039 neighbor_override_capability_cmd
,
7040 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7043 "Override capability negotiation result\n")
7046 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7047 PEER_FLAG_OVERRIDE_CAPABILITY
);
7050 DEFUN (no_neighbor_override_capability
,
7051 no_neighbor_override_capability_cmd
,
7052 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7056 "Override capability negotiation result\n")
7059 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7060 PEER_FLAG_OVERRIDE_CAPABILITY
);
7063 DEFUN (neighbor_strict_capability
,
7064 neighbor_strict_capability_cmd
,
7065 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7068 "Strict capability negotiation match\n")
7072 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7073 PEER_FLAG_STRICT_CAP_MATCH
);
7076 DEFUN (no_neighbor_strict_capability
,
7077 no_neighbor_strict_capability_cmd
,
7078 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7082 "Strict capability negotiation match\n")
7086 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7087 PEER_FLAG_STRICT_CAP_MATCH
);
7090 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7091 const char *keep_str
, const char *hold_str
)
7098 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7100 return CMD_WARNING_CONFIG_FAILED
;
7102 keepalive
= strtoul(keep_str
, NULL
, 10);
7103 holdtime
= strtoul(hold_str
, NULL
, 10);
7105 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7107 return bgp_vty_return(vty
, ret
);
7110 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7115 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7117 return CMD_WARNING_CONFIG_FAILED
;
7119 ret
= peer_timers_unset(peer
);
7121 return bgp_vty_return(vty
, ret
);
7124 DEFUN (neighbor_timers
,
7125 neighbor_timers_cmd
,
7126 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7129 "BGP per neighbor timers\n"
7130 "Keepalive interval\n"
7135 int idx_number_2
= 4;
7136 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7137 argv
[idx_number
]->arg
,
7138 argv
[idx_number_2
]->arg
);
7141 DEFUN (no_neighbor_timers
,
7142 no_neighbor_timers_cmd
,
7143 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7147 "BGP per neighbor timers\n"
7148 "Keepalive interval\n"
7152 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7156 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7157 const char *time_str
)
7163 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7165 return CMD_WARNING_CONFIG_FAILED
;
7167 connect
= strtoul(time_str
, NULL
, 10);
7169 ret
= peer_timers_connect_set(peer
, connect
);
7171 return bgp_vty_return(vty
, ret
);
7174 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7179 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7181 return CMD_WARNING_CONFIG_FAILED
;
7183 ret
= peer_timers_connect_unset(peer
);
7185 return bgp_vty_return(vty
, ret
);
7188 DEFUN (neighbor_timers_connect
,
7189 neighbor_timers_connect_cmd
,
7190 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7193 "BGP per neighbor timers\n"
7194 "BGP connect timer\n"
7199 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7200 argv
[idx_number
]->arg
);
7203 DEFUN (no_neighbor_timers_connect
,
7204 no_neighbor_timers_connect_cmd
,
7205 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7209 "BGP per neighbor timers\n"
7210 "BGP connect timer\n"
7214 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7217 DEFPY (neighbor_timers_delayopen
,
7218 neighbor_timers_delayopen_cmd
,
7219 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7222 "BGP per neighbor timers\n"
7223 "RFC 4271 DelayOpenTimer\n"
7224 "DelayOpenTime timer interval\n")
7228 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7230 return CMD_WARNING_CONFIG_FAILED
;
7233 if (peer_timers_delayopen_unset(peer
))
7234 return CMD_WARNING_CONFIG_FAILED
;
7236 if (peer_timers_delayopen_set(peer
, interval
))
7237 return CMD_WARNING_CONFIG_FAILED
;
7243 DEFPY (no_neighbor_timers_delayopen
,
7244 no_neighbor_timers_delayopen_cmd
,
7245 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7249 "BGP per neighbor timers\n"
7250 "RFC 4271 DelayOpenTimer\n"
7251 "DelayOpenTime timer interval\n")
7255 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7257 return CMD_WARNING_CONFIG_FAILED
;
7259 if (peer_timers_delayopen_unset(peer
))
7260 return CMD_WARNING_CONFIG_FAILED
;
7265 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7266 const char *time_str
, int set
)
7270 uint32_t routeadv
= 0;
7272 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7274 return CMD_WARNING_CONFIG_FAILED
;
7277 routeadv
= strtoul(time_str
, NULL
, 10);
7280 ret
= peer_advertise_interval_set(peer
, routeadv
);
7282 ret
= peer_advertise_interval_unset(peer
);
7284 return bgp_vty_return(vty
, ret
);
7287 DEFUN (neighbor_advertise_interval
,
7288 neighbor_advertise_interval_cmd
,
7289 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7292 "Minimum interval between sending BGP routing updates\n"
7293 "time in seconds\n")
7297 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7298 argv
[idx_number
]->arg
, 1);
7301 DEFUN (no_neighbor_advertise_interval
,
7302 no_neighbor_advertise_interval_cmd
,
7303 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7307 "Minimum interval between sending BGP routing updates\n"
7308 "time in seconds\n")
7311 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7315 /* Time to wait before processing route-map updates */
7316 DEFUN (bgp_set_route_map_delay_timer
,
7317 bgp_set_route_map_delay_timer_cmd
,
7318 "bgp route-map delay-timer (0-600)",
7320 "BGP route-map delay timer\n"
7321 "Time in secs to wait before processing route-map changes\n"
7322 "0 disables the timer, no route updates happen when route-maps change\n")
7325 uint32_t rmap_delay_timer
;
7327 if (argv
[idx_number
]->arg
) {
7328 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7329 bm
->rmap_update_timer
= rmap_delay_timer
;
7331 /* if the dynamic update handling is being disabled, and a timer
7333 * running, stop the timer and act as if the timer has already
7336 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7337 THREAD_OFF(bm
->t_rmap_update
);
7338 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7343 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7344 return CMD_WARNING_CONFIG_FAILED
;
7348 DEFUN (no_bgp_set_route_map_delay_timer
,
7349 no_bgp_set_route_map_delay_timer_cmd
,
7350 "no bgp route-map delay-timer [(0-600)]",
7353 "Default BGP route-map delay timer\n"
7354 "Reset to default time to wait for processing route-map changes\n"
7355 "0 disables the timer, no route updates happen when route-maps change\n")
7358 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7363 /* neighbor interface */
7364 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7369 peer
= peer_lookup_vty(vty
, ip_str
);
7370 if (!peer
|| peer
->conf_if
) {
7371 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7372 return CMD_WARNING_CONFIG_FAILED
;
7376 peer_interface_set(peer
, str
);
7378 peer_interface_unset(peer
);
7383 DEFUN (neighbor_interface
,
7384 neighbor_interface_cmd
,
7385 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7394 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7397 DEFUN (no_neighbor_interface
,
7398 no_neighbor_interface_cmd
,
7399 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7408 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7411 DEFUN (neighbor_distribute_list
,
7412 neighbor_distribute_list_cmd
,
7413 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7416 "Filter updates to/from this neighbor\n"
7417 "IP Access-list name\n"
7418 "Filter incoming updates\n"
7419 "Filter outgoing updates\n")
7426 const char *pstr
= argv
[idx_peer
]->arg
;
7427 const char *acl
= argv
[idx_acl
]->arg
;
7428 const char *inout
= argv
[argc
- 1]->text
;
7430 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7432 return CMD_WARNING_CONFIG_FAILED
;
7434 /* Check filter direction. */
7435 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7436 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7439 return bgp_vty_return(vty
, ret
);
7443 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7444 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7445 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7446 "Filter updates to/from this neighbor\n"
7447 "IP Access-list name\n"
7448 "Filter incoming updates\n"
7449 "Filter outgoing updates\n")
7451 DEFUN (no_neighbor_distribute_list
,
7452 no_neighbor_distribute_list_cmd
,
7453 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7457 "Filter updates to/from this neighbor\n"
7458 "IP Access-list name\n"
7459 "Filter incoming updates\n"
7460 "Filter outgoing updates\n")
7466 const char *pstr
= argv
[idx_peer
]->arg
;
7467 const char *inout
= argv
[argc
- 1]->text
;
7469 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7471 return CMD_WARNING_CONFIG_FAILED
;
7473 /* Check filter direction. */
7474 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7475 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7478 return bgp_vty_return(vty
, ret
);
7482 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7483 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7484 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7485 "Filter updates to/from this neighbor\n"
7486 "IP Access-list name\n"
7487 "Filter incoming updates\n"
7488 "Filter outgoing updates\n")
7490 /* Set prefix list to the peer. */
7491 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7492 afi_t afi
, safi_t safi
,
7493 const char *name_str
,
7494 const char *direct_str
)
7497 int direct
= FILTER_IN
;
7500 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7502 return CMD_WARNING_CONFIG_FAILED
;
7504 /* Check filter direction. */
7505 if (strncmp(direct_str
, "i", 1) == 0)
7507 else if (strncmp(direct_str
, "o", 1) == 0)
7508 direct
= FILTER_OUT
;
7510 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7512 return bgp_vty_return(vty
, ret
);
7515 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7516 afi_t afi
, safi_t safi
,
7517 const char *direct_str
)
7521 int direct
= FILTER_IN
;
7523 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7525 return CMD_WARNING_CONFIG_FAILED
;
7527 /* Check filter direction. */
7528 if (strncmp(direct_str
, "i", 1) == 0)
7530 else if (strncmp(direct_str
, "o", 1) == 0)
7531 direct
= FILTER_OUT
;
7533 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7535 return bgp_vty_return(vty
, ret
);
7538 DEFUN (neighbor_prefix_list
,
7539 neighbor_prefix_list_cmd
,
7540 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7543 "Filter updates to/from this neighbor\n"
7544 "Name of a prefix list\n"
7545 "Filter incoming updates\n"
7546 "Filter outgoing updates\n")
7551 return peer_prefix_list_set_vty(
7552 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7553 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7556 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7557 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7558 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7559 "Filter updates to/from this neighbor\n"
7560 "Name of a prefix list\n"
7561 "Filter incoming updates\n"
7562 "Filter outgoing updates\n")
7564 DEFUN (no_neighbor_prefix_list
,
7565 no_neighbor_prefix_list_cmd
,
7566 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7570 "Filter updates to/from this neighbor\n"
7571 "Name of a prefix list\n"
7572 "Filter incoming updates\n"
7573 "Filter outgoing updates\n")
7577 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7578 bgp_node_afi(vty
), bgp_node_safi(vty
),
7579 argv
[idx_in_out
]->arg
);
7582 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7583 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7584 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7585 "Filter updates to/from this neighbor\n"
7586 "Name of a prefix list\n"
7587 "Filter incoming updates\n"
7588 "Filter outgoing updates\n")
7590 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7591 safi_t safi
, const char *name_str
,
7592 const char *direct_str
)
7596 int direct
= FILTER_IN
;
7598 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7600 return CMD_WARNING_CONFIG_FAILED
;
7602 /* Check filter direction. */
7603 if (strncmp(direct_str
, "i", 1) == 0)
7605 else if (strncmp(direct_str
, "o", 1) == 0)
7606 direct
= FILTER_OUT
;
7608 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7610 return bgp_vty_return(vty
, ret
);
7613 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7614 safi_t safi
, const char *direct_str
)
7618 int direct
= FILTER_IN
;
7620 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7622 return CMD_WARNING_CONFIG_FAILED
;
7624 /* Check filter direction. */
7625 if (strncmp(direct_str
, "i", 1) == 0)
7627 else if (strncmp(direct_str
, "o", 1) == 0)
7628 direct
= FILTER_OUT
;
7630 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7632 return bgp_vty_return(vty
, ret
);
7635 DEFUN (neighbor_filter_list
,
7636 neighbor_filter_list_cmd
,
7637 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7640 "Establish BGP filters\n"
7641 "AS path access-list name\n"
7642 "Filter incoming routes\n"
7643 "Filter outgoing routes\n")
7648 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7649 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7650 argv
[idx_in_out
]->arg
);
7653 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7654 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7655 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7656 "Establish BGP filters\n"
7657 "AS path access-list name\n"
7658 "Filter incoming routes\n"
7659 "Filter outgoing routes\n")
7661 DEFUN (no_neighbor_filter_list
,
7662 no_neighbor_filter_list_cmd
,
7663 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7667 "Establish BGP filters\n"
7668 "AS path access-list name\n"
7669 "Filter incoming routes\n"
7670 "Filter outgoing routes\n")
7674 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7675 bgp_node_afi(vty
), bgp_node_safi(vty
),
7676 argv
[idx_in_out
]->arg
);
7679 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7680 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7681 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7682 "Establish BGP filters\n"
7683 "AS path access-list name\n"
7684 "Filter incoming routes\n"
7685 "Filter outgoing routes\n")
7687 /* Set advertise-map to the peer. */
7688 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7689 afi_t afi
, safi_t safi
,
7690 const char *advertise_str
,
7691 const char *condition_str
, bool condition
,
7694 int ret
= CMD_WARNING_CONFIG_FAILED
;
7696 struct route_map
*advertise_map
;
7697 struct route_map
*condition_map
;
7699 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7703 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7704 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7707 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7708 advertise_map
, condition_str
,
7709 condition_map
, condition
);
7711 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7712 advertise_map
, condition_str
,
7713 condition_map
, condition
);
7715 return bgp_vty_return(vty
, ret
);
7718 DEFPY (bgp_condadv_period
,
7719 bgp_condadv_period_cmd
,
7720 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7723 "Conditional advertisement settings\n"
7724 "Set period to rescan BGP table to check if condition is met\n"
7725 "Period between BGP table scans, in seconds; default 60\n")
7727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7729 bgp
->condition_check_period
=
7730 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7735 DEFPY (neighbor_advertise_map
,
7736 neighbor_advertise_map_cmd
,
7737 "[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",
7741 "Route-map to conditionally advertise routes\n"
7742 "Name of advertise map\n"
7743 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7744 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7745 "Name of the exist or non exist map\n")
7747 bool condition
= CONDITION_EXIST
;
7749 if (!strcmp(exist
, "non-exist-map"))
7750 condition
= CONDITION_NON_EXIST
;
7752 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7753 bgp_node_safi(vty
), advertise_str
,
7754 condition_str
, condition
, !no
);
7757 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7758 "[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",
7759 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7760 "Route-map to conditionally advertise routes\n"
7761 "Name of advertise map\n"
7762 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7763 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7764 "Name of the exist or non exist map\n")
7766 /* Set route-map to the peer. */
7767 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7768 afi_t afi
, safi_t safi
, const char *name_str
,
7769 const char *direct_str
)
7773 int direct
= RMAP_IN
;
7774 struct route_map
*route_map
;
7776 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7778 return CMD_WARNING_CONFIG_FAILED
;
7780 /* Check filter direction. */
7781 if (strncmp(direct_str
, "in", 2) == 0)
7783 else if (strncmp(direct_str
, "o", 1) == 0)
7786 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7787 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7789 return bgp_vty_return(vty
, ret
);
7792 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7793 afi_t afi
, safi_t safi
,
7794 const char *direct_str
)
7798 int direct
= RMAP_IN
;
7800 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7802 return CMD_WARNING_CONFIG_FAILED
;
7804 /* Check filter direction. */
7805 if (strncmp(direct_str
, "in", 2) == 0)
7807 else if (strncmp(direct_str
, "o", 1) == 0)
7810 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7812 return bgp_vty_return(vty
, ret
);
7815 DEFUN (neighbor_route_map
,
7816 neighbor_route_map_cmd
,
7817 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7820 "Apply route map to neighbor\n"
7821 "Name of route map\n"
7822 "Apply map to incoming routes\n"
7823 "Apply map to outbound routes\n")
7828 return peer_route_map_set_vty(
7829 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7830 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7833 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7834 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7835 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7836 "Apply route map to neighbor\n"
7837 "Name of route map\n"
7838 "Apply map to incoming routes\n"
7839 "Apply map to outbound routes\n")
7841 DEFUN (no_neighbor_route_map
,
7842 no_neighbor_route_map_cmd
,
7843 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7847 "Apply route map to neighbor\n"
7848 "Name of route map\n"
7849 "Apply map to incoming routes\n"
7850 "Apply map to outbound routes\n")
7854 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7855 bgp_node_afi(vty
), bgp_node_safi(vty
),
7856 argv
[idx_in_out
]->arg
);
7859 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7860 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7861 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7862 "Apply route map to neighbor\n"
7863 "Name of route map\n"
7864 "Apply map to incoming routes\n"
7865 "Apply map to outbound routes\n")
7867 /* Set unsuppress-map to the peer. */
7868 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7869 afi_t afi
, safi_t safi
,
7870 const char *name_str
)
7874 struct route_map
*route_map
;
7876 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7878 return CMD_WARNING_CONFIG_FAILED
;
7880 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7881 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7883 return bgp_vty_return(vty
, ret
);
7886 /* Unset route-map from the peer. */
7887 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7888 afi_t afi
, safi_t safi
)
7893 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7895 return CMD_WARNING_CONFIG_FAILED
;
7897 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7899 return bgp_vty_return(vty
, ret
);
7902 DEFUN (neighbor_unsuppress_map
,
7903 neighbor_unsuppress_map_cmd
,
7904 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7907 "Route-map to selectively unsuppress suppressed routes\n"
7908 "Name of route map\n")
7912 return peer_unsuppress_map_set_vty(
7913 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7914 argv
[idx_word
]->arg
);
7917 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7918 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7919 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7920 "Route-map to selectively unsuppress suppressed routes\n"
7921 "Name of route map\n")
7923 DEFUN (no_neighbor_unsuppress_map
,
7924 no_neighbor_unsuppress_map_cmd
,
7925 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7929 "Route-map to selectively unsuppress suppressed routes\n"
7930 "Name of route map\n")
7933 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7935 bgp_node_safi(vty
));
7938 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7939 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7940 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7941 "Route-map to selectively unsuppress suppressed routes\n"
7942 "Name of route map\n")
7944 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7945 afi_t afi
, safi_t safi
,
7946 const char *num_str
,
7947 const char *threshold_str
, int warning
,
7948 const char *restart_str
,
7949 const char *force_str
)
7957 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7959 return CMD_WARNING_CONFIG_FAILED
;
7961 max
= strtoul(num_str
, NULL
, 10);
7963 threshold
= atoi(threshold_str
);
7965 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7968 restart
= atoi(restart_str
);
7972 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7973 restart
, force_str
? true : false);
7975 return bgp_vty_return(vty
, ret
);
7978 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7979 afi_t afi
, safi_t safi
)
7984 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7986 return CMD_WARNING_CONFIG_FAILED
;
7988 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7990 return bgp_vty_return(vty
, ret
);
7993 /* Maximum number of prefix to be sent to the neighbor. */
7994 DEFUN(neighbor_maximum_prefix_out
,
7995 neighbor_maximum_prefix_out_cmd
,
7996 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7999 "Maximum number of prefixes to be sent to this peer\n"
8000 "Maximum no. of prefix limit\n")
8007 afi_t afi
= bgp_node_afi(vty
);
8008 safi_t safi
= bgp_node_safi(vty
);
8010 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8012 return CMD_WARNING_CONFIG_FAILED
;
8014 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8016 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8018 return bgp_vty_return(vty
, ret
);
8021 DEFUN(no_neighbor_maximum_prefix_out
,
8022 no_neighbor_maximum_prefix_out_cmd
,
8023 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8027 "Maximum number of prefixes to be sent to this peer\n"
8028 "Maximum no. of prefix limit\n")
8033 afi_t afi
= bgp_node_afi(vty
);
8034 safi_t safi
= bgp_node_safi(vty
);
8036 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8038 return CMD_WARNING_CONFIG_FAILED
;
8040 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8042 return bgp_vty_return(vty
, ret
);
8045 /* Maximum number of prefix configuration. Prefix count is different
8046 for each peer configuration. So this configuration can be set for
8047 each peer configuration. */
8048 DEFUN (neighbor_maximum_prefix
,
8049 neighbor_maximum_prefix_cmd
,
8050 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8053 "Maximum number of prefix accept from this peer\n"
8054 "maximum no. of prefix limit\n"
8055 "Force checking all received routes not only accepted\n")
8062 if (argv_find(argv
, argc
, "force", &idx_force
))
8063 force
= argv
[idx_force
]->arg
;
8065 return peer_maximum_prefix_set_vty(
8066 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8067 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8070 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8071 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8072 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8073 "Maximum number of prefix accept from this peer\n"
8074 "maximum no. of prefix limit\n"
8075 "Force checking all received routes not only accepted\n")
8077 DEFUN (neighbor_maximum_prefix_threshold
,
8078 neighbor_maximum_prefix_threshold_cmd
,
8079 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8082 "Maximum number of prefix accept from this peer\n"
8083 "maximum no. of prefix limit\n"
8084 "Threshold value (%) at which to generate a warning msg\n"
8085 "Force checking all received routes not only accepted\n")
8089 int idx_number_2
= 4;
8093 if (argv_find(argv
, argc
, "force", &idx_force
))
8094 force
= argv
[idx_force
]->arg
;
8096 return peer_maximum_prefix_set_vty(
8097 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8098 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8102 neighbor_maximum_prefix_threshold
,
8103 neighbor_maximum_prefix_threshold_hidden_cmd
,
8104 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8105 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8106 "Maximum number of prefix accept from this peer\n"
8107 "maximum no. of prefix limit\n"
8108 "Threshold value (%) at which to generate a warning msg\n"
8109 "Force checking all received routes not only accepted\n")
8111 DEFUN (neighbor_maximum_prefix_warning
,
8112 neighbor_maximum_prefix_warning_cmd
,
8113 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8116 "Maximum number of prefix accept from this peer\n"
8117 "maximum no. of prefix limit\n"
8118 "Only give warning message when limit is exceeded\n"
8119 "Force checking all received routes not only accepted\n")
8126 if (argv_find(argv
, argc
, "force", &idx_force
))
8127 force
= argv
[idx_force
]->arg
;
8129 return peer_maximum_prefix_set_vty(
8130 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8131 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8135 neighbor_maximum_prefix_warning
,
8136 neighbor_maximum_prefix_warning_hidden_cmd
,
8137 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8138 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8139 "Maximum number of prefix accept from this peer\n"
8140 "maximum no. of prefix limit\n"
8141 "Only give warning message when limit is exceeded\n"
8142 "Force checking all received routes not only accepted\n")
8144 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8145 neighbor_maximum_prefix_threshold_warning_cmd
,
8146 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8149 "Maximum number of prefix accept from this peer\n"
8150 "maximum no. of prefix limit\n"
8151 "Threshold value (%) at which to generate a warning msg\n"
8152 "Only give warning message when limit is exceeded\n"
8153 "Force checking all received routes not only accepted\n")
8157 int idx_number_2
= 4;
8161 if (argv_find(argv
, argc
, "force", &idx_force
))
8162 force
= argv
[idx_force
]->arg
;
8164 return peer_maximum_prefix_set_vty(
8165 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8166 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8170 neighbor_maximum_prefix_threshold_warning
,
8171 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8172 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8173 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8174 "Maximum number of prefix accept from this peer\n"
8175 "maximum no. of prefix limit\n"
8176 "Threshold value (%) at which to generate a warning msg\n"
8177 "Only give warning message when limit is exceeded\n"
8178 "Force checking all received routes not only accepted\n")
8180 DEFUN (neighbor_maximum_prefix_restart
,
8181 neighbor_maximum_prefix_restart_cmd
,
8182 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8185 "Maximum number of prefix accept from this peer\n"
8186 "maximum no. of prefix limit\n"
8187 "Restart bgp connection after limit is exceeded\n"
8188 "Restart interval in minutes\n"
8189 "Force checking all received routes not only accepted\n")
8193 int idx_number_2
= 5;
8197 if (argv_find(argv
, argc
, "force", &idx_force
))
8198 force
= argv
[idx_force
]->arg
;
8200 return peer_maximum_prefix_set_vty(
8201 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8202 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8206 neighbor_maximum_prefix_restart
,
8207 neighbor_maximum_prefix_restart_hidden_cmd
,
8208 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8209 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8210 "Maximum number of prefix accept from this peer\n"
8211 "maximum no. of prefix limit\n"
8212 "Restart bgp connection after limit is exceeded\n"
8213 "Restart interval in minutes\n"
8214 "Force checking all received routes not only accepted\n")
8216 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8217 neighbor_maximum_prefix_threshold_restart_cmd
,
8218 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8221 "Maximum number of prefixes to accept from this peer\n"
8222 "maximum no. of prefix limit\n"
8223 "Threshold value (%) at which to generate a warning msg\n"
8224 "Restart bgp connection after limit is exceeded\n"
8225 "Restart interval in minutes\n"
8226 "Force checking all received routes not only accepted\n")
8230 int idx_number_2
= 4;
8231 int idx_number_3
= 6;
8235 if (argv_find(argv
, argc
, "force", &idx_force
))
8236 force
= argv
[idx_force
]->arg
;
8238 return peer_maximum_prefix_set_vty(
8239 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8240 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8241 argv
[idx_number_3
]->arg
, force
);
8245 neighbor_maximum_prefix_threshold_restart
,
8246 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8247 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8248 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8249 "Maximum number of prefixes to accept from this peer\n"
8250 "maximum no. of prefix limit\n"
8251 "Threshold value (%) at which to generate a warning msg\n"
8252 "Restart bgp connection after limit is exceeded\n"
8253 "Restart interval in minutes\n"
8254 "Force checking all received routes not only accepted\n")
8256 DEFUN (no_neighbor_maximum_prefix
,
8257 no_neighbor_maximum_prefix_cmd
,
8258 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8262 "Maximum number of prefixes to accept from this peer\n"
8263 "maximum no. of prefix limit\n"
8264 "Threshold value (%) at which to generate a warning msg\n"
8265 "Restart bgp connection after limit is exceeded\n"
8266 "Restart interval in minutes\n"
8267 "Only give warning message when limit is exceeded\n"
8268 "Force checking all received routes not only accepted\n")
8271 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8273 bgp_node_safi(vty
));
8277 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8278 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8279 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8280 "Maximum number of prefixes to accept from this peer\n"
8281 "maximum no. of prefix limit\n"
8282 "Threshold value (%) at which to generate a warning msg\n"
8283 "Restart bgp connection after limit is exceeded\n"
8284 "Restart interval in minutes\n"
8285 "Only give warning message when limit is exceeded\n"
8286 "Force checking all received routes not only accepted\n")
8288 /* "neighbor soo" */
8289 DEFPY (neighbor_soo
,
8291 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8294 "Set the Site-of-Origin (SoO) extended community\n"
8295 "VPN extended community\n")
8298 afi_t afi
= bgp_node_afi(vty
);
8299 safi_t safi
= bgp_node_safi(vty
);
8300 struct ecommunity
*ecomm_soo
;
8302 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8304 return CMD_WARNING_CONFIG_FAILED
;
8306 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8308 vty_out(vty
, "%% Malformed SoO extended community\n");
8311 ecommunity_str(ecomm_soo
);
8313 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8314 ecommunity_free(&peer
->soo
[afi
][safi
]);
8315 peer
->soo
[afi
][safi
] = ecomm_soo
;
8316 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8319 return bgp_vty_return(vty
,
8320 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8323 DEFPY (no_neighbor_soo
,
8324 no_neighbor_soo_cmd
,
8325 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8329 "Set the Site-of-Origin (SoO) extended community\n"
8330 "VPN extended community\n")
8333 afi_t afi
= bgp_node_afi(vty
);
8334 safi_t safi
= bgp_node_safi(vty
);
8336 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8338 return CMD_WARNING_CONFIG_FAILED
;
8340 ecommunity_free(&peer
->soo
[afi
][safi
]);
8342 return bgp_vty_return(
8343 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8346 /* "neighbor allowas-in" */
8347 DEFUN (neighbor_allowas_in
,
8348 neighbor_allowas_in_cmd
,
8349 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8352 "Accept as-path with my AS present in it\n"
8353 "Number of occurrences of AS number\n"
8354 "Only accept my AS in the as-path if the route was originated in my AS\n")
8357 int idx_number_origin
= 3;
8363 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8365 return CMD_WARNING_CONFIG_FAILED
;
8367 if (argc
<= idx_number_origin
)
8370 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8373 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8376 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8379 return bgp_vty_return(vty
, ret
);
8383 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8384 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8385 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8386 "Accept as-path with my AS present in it\n"
8387 "Number of occurrences of AS number\n"
8388 "Only accept my AS in the as-path if the route was originated in my AS\n")
8390 DEFUN (no_neighbor_allowas_in
,
8391 no_neighbor_allowas_in_cmd
,
8392 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8396 "allow local ASN appears in aspath attribute\n"
8397 "Number of occurrences of AS number\n"
8398 "Only accept my AS in the as-path if the route was originated in my AS\n")
8404 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8406 return CMD_WARNING_CONFIG_FAILED
;
8408 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8409 bgp_node_safi(vty
));
8411 return bgp_vty_return(vty
, ret
);
8415 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8416 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8417 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8418 "allow local ASN appears in aspath attribute\n"
8419 "Number of occurrences of AS number\n"
8420 "Only accept my AS in the as-path if the route was originated in my AS\n")
8422 DEFUN (neighbor_ttl_security
,
8423 neighbor_ttl_security_cmd
,
8424 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8427 "BGP ttl-security parameters\n"
8428 "Specify the maximum number of hops to the BGP peer\n"
8429 "Number of hops to BGP peer\n")
8436 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8438 return CMD_WARNING_CONFIG_FAILED
;
8440 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8443 * If 'neighbor swpX', then this is for directly connected peers,
8444 * we should not accept a ttl-security hops value greater than 1.
8446 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8448 "%s is directly connected peer, hops cannot exceed 1\n",
8449 argv
[idx_peer
]->arg
);
8450 return CMD_WARNING_CONFIG_FAILED
;
8453 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8456 DEFUN (no_neighbor_ttl_security
,
8457 no_neighbor_ttl_security_cmd
,
8458 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8462 "BGP ttl-security parameters\n"
8463 "Specify the maximum number of hops to the BGP peer\n"
8464 "Number of hops to BGP peer\n")
8469 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8471 return CMD_WARNING_CONFIG_FAILED
;
8473 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8476 /* disable-addpath-rx */
8477 DEFUN(neighbor_disable_addpath_rx
,
8478 neighbor_disable_addpath_rx_cmd
,
8479 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8482 "Do not accept additional paths\n")
8484 char *peer_str
= argv
[1]->arg
;
8486 afi_t afi
= bgp_node_afi(vty
);
8487 safi_t safi
= bgp_node_safi(vty
);
8489 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8491 return CMD_WARNING_CONFIG_FAILED
;
8493 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8494 PEER_FLAG_DISABLE_ADDPATH_RX
);
8497 DEFUN(no_neighbor_disable_addpath_rx
,
8498 no_neighbor_disable_addpath_rx_cmd
,
8499 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8503 "Do not accept additional paths\n")
8505 char *peer_str
= argv
[2]->arg
;
8507 afi_t afi
= bgp_node_afi(vty
);
8508 safi_t safi
= bgp_node_safi(vty
);
8510 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8512 return CMD_WARNING_CONFIG_FAILED
;
8514 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8515 PEER_FLAG_DISABLE_ADDPATH_RX
);
8518 DEFUN (neighbor_addpath_tx_all_paths
,
8519 neighbor_addpath_tx_all_paths_cmd
,
8520 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8523 "Use addpath to advertise all paths to a neighbor\n")
8528 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8530 return CMD_WARNING_CONFIG_FAILED
;
8532 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8537 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8538 neighbor_addpath_tx_all_paths_hidden_cmd
,
8539 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8540 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8541 "Use addpath to advertise all paths to a neighbor\n")
8543 DEFUN (no_neighbor_addpath_tx_all_paths
,
8544 no_neighbor_addpath_tx_all_paths_cmd
,
8545 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8549 "Use addpath to advertise all paths to a neighbor\n")
8554 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8556 return CMD_WARNING_CONFIG_FAILED
;
8558 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8559 != BGP_ADDPATH_ALL
) {
8561 "%% Peer not currently configured to transmit all paths.");
8562 return CMD_WARNING_CONFIG_FAILED
;
8565 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8571 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8572 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8573 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8574 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8575 "Use addpath to advertise all paths to a neighbor\n")
8577 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8578 neighbor_addpath_tx_bestpath_per_as_cmd
,
8579 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8582 "Use addpath to advertise the bestpath per each neighboring AS\n")
8587 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8589 return CMD_WARNING_CONFIG_FAILED
;
8591 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8592 BGP_ADDPATH_BEST_PER_AS
);
8597 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8598 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8599 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8600 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8601 "Use addpath to advertise the bestpath per each neighboring AS\n")
8603 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8604 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8605 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8609 "Use addpath to advertise the bestpath per each neighboring AS\n")
8614 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8616 return CMD_WARNING_CONFIG_FAILED
;
8618 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8619 != BGP_ADDPATH_BEST_PER_AS
) {
8621 "%% Peer not currently configured to transmit all best path per as.");
8622 return CMD_WARNING_CONFIG_FAILED
;
8625 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8631 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8632 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8633 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8634 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8635 "Use addpath to advertise the bestpath per each neighboring AS\n")
8638 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8639 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8642 "Detect AS loops before sending to neighbor\n")
8646 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8648 return CMD_WARNING_CONFIG_FAILED
;
8650 peer
->as_path_loop_detection
= true;
8656 no_neighbor_aspath_loop_detection
,
8657 no_neighbor_aspath_loop_detection_cmd
,
8658 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8662 "Detect AS loops before sending to neighbor\n")
8666 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8668 return CMD_WARNING_CONFIG_FAILED
;
8670 peer
->as_path_loop_detection
= false;
8675 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8676 struct ecommunity
**list
, bool is_rt6
)
8678 struct ecommunity
*ecom
= NULL
;
8679 struct ecommunity
*ecomadd
;
8681 for (; argc
; --argc
, ++argv
) {
8683 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8684 ECOMMUNITY_ROUTE_TARGET
,
8687 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8688 ECOMMUNITY_ROUTE_TARGET
,
8691 vty_out(vty
, "Malformed community-list value\n");
8693 ecommunity_free(&ecom
);
8694 return CMD_WARNING_CONFIG_FAILED
;
8698 ecommunity_merge(ecom
, ecomadd
);
8699 ecommunity_free(&ecomadd
);
8706 ecommunity_free(&*list
);
8714 * v2vimport is true if we are handling a `import vrf ...` command
8716 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8720 switch (vty
->node
) {
8729 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8734 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8735 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8736 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8737 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8739 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8743 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8744 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8745 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8746 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8748 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8755 DEFPY (af_rd_vpn_export
,
8756 af_rd_vpn_export_cmd
,
8757 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8759 "Specify route distinguisher\n"
8760 "Between current address-family and vpn\n"
8761 "For routes leaked from current address-family to vpn\n"
8762 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8765 struct prefix_rd prd
;
8771 if (argv_find(argv
, argc
, "no", &idx
))
8775 ret
= str2prefix_rd(rd_str
, &prd
);
8777 vty_out(vty
, "%% Malformed rd\n");
8778 return CMD_WARNING_CONFIG_FAILED
;
8782 afi
= vpn_policy_getafi(vty
, bgp
, false);
8784 return CMD_WARNING_CONFIG_FAILED
;
8787 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8789 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8790 bgp_get_default(), bgp
);
8793 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8794 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8795 BGP_VPN_POLICY_TOVPN_RD_SET
);
8797 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8798 BGP_VPN_POLICY_TOVPN_RD_SET
);
8801 /* post-change: re-export vpn routes */
8802 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8803 bgp_get_default(), bgp
);
8808 ALIAS (af_rd_vpn_export
,
8809 af_no_rd_vpn_export_cmd
,
8812 "Specify route distinguisher\n"
8813 "Between current address-family and vpn\n"
8814 "For routes leaked from current address-family to vpn\n")
8816 DEFPY (af_label_vpn_export
,
8817 af_label_vpn_export_cmd
,
8818 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8820 "label value for VRF\n"
8821 "Between current address-family and vpn\n"
8822 "For routes leaked from current address-family to vpn\n"
8823 "Label Value <0-1048575>\n"
8824 "Automatically assign a label\n")
8826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8827 mpls_label_t label
= MPLS_LABEL_NONE
;
8832 if (argv_find(argv
, argc
, "no", &idx
))
8835 /* If "no ...", squash trailing parameter */
8841 label
= label_val
; /* parser should force unsigned */
8844 afi
= vpn_policy_getafi(vty
, bgp
, false);
8846 return CMD_WARNING_CONFIG_FAILED
;
8849 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8850 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8855 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8857 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8858 bgp_get_default(), bgp
);
8860 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8861 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8863 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8866 * label has previously been automatically
8867 * assigned by labelpool: release it
8869 * NB if tovpn_label == MPLS_LABEL_NONE it
8870 * means the automatic assignment is in flight
8871 * and therefore the labelpool callback must
8872 * detect that the auto label is not needed.
8875 bgp_lp_release(LP_TYPE_VRF
,
8876 &bgp
->vpn_policy
[afi
],
8877 bgp
->vpn_policy
[afi
].tovpn_label
);
8879 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8880 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8883 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8885 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8886 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8887 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8888 vpn_leak_label_callback
);
8891 /* post-change: re-export vpn routes */
8892 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8893 bgp_get_default(), bgp
);
8895 hook_call(bgp_snmp_update_last_changed
, bgp
);
8899 DEFPY (af_sid_vpn_export
,
8900 af_sid_vpn_export_cmd
,
8901 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
8903 "sid value for VRF\n"
8904 "Between current address-family and vpn\n"
8905 "For routes leaked from current address-family to vpn\n"
8906 "Sid allocation index\n"
8907 "Automatically assign a label\n")
8909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8915 if (argv_find(argv
, argc
, "no", &idx
))
8917 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8918 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8920 afi
= vpn_policy_getafi(vty
, bgp
, false);
8922 return CMD_WARNING_CONFIG_FAILED
;
8926 vty_out(vty
, "It's not implemented\n");
8927 return CMD_WARNING_CONFIG_FAILED
;
8930 /* skip when it's already configured */
8931 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8932 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8933 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8937 * mode change between sid_idx and sid_auto isn't supported.
8938 * user must negate sid vpn export when they want to change the mode
8940 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8941 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8942 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8943 vty_out(vty
, "it's already configured as %s.\n",
8944 sid_auto
? "auto-mode" : "idx-mode");
8945 return CMD_WARNING_CONFIG_FAILED
;
8949 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8950 bgp_get_default(), bgp
);
8953 /* SID allocation auto-mode */
8955 zlog_debug("%s: auto sid alloc.", __func__
);
8956 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8957 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8959 /* SID allocation index-mode */
8961 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8962 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8966 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8967 bgp_get_default(), bgp
);
8971 ALIAS (af_label_vpn_export
,
8972 af_no_label_vpn_export_cmd
,
8973 "no label vpn export",
8975 "label value for VRF\n"
8976 "Between current address-family and vpn\n"
8977 "For routes leaked from current address-family to vpn\n")
8979 DEFPY (af_nexthop_vpn_export
,
8980 af_nexthop_vpn_export_cmd
,
8981 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8983 "Specify next hop to use for VRF advertised prefixes\n"
8984 "Between current address-family and vpn\n"
8985 "For routes leaked from current address-family to vpn\n"
8989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8995 vty_out(vty
, "%% Nexthop required\n");
8996 return CMD_WARNING_CONFIG_FAILED
;
8998 if (!sockunion2hostprefix(nexthop_su
, &p
))
8999 return CMD_WARNING_CONFIG_FAILED
;
9002 afi
= vpn_policy_getafi(vty
, bgp
, false);
9004 return CMD_WARNING_CONFIG_FAILED
;
9007 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9009 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9010 bgp_get_default(), bgp
);
9013 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9014 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9015 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9017 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9018 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9021 /* post-change: re-export vpn routes */
9022 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9023 bgp_get_default(), bgp
);
9028 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9030 if (!strcmp(dstr
, "import")) {
9031 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9032 } else if (!strcmp(dstr
, "export")) {
9033 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9034 } else if (!strcmp(dstr
, "both")) {
9035 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9036 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9038 vty_out(vty
, "%% direction parse error\n");
9039 return CMD_WARNING_CONFIG_FAILED
;
9044 DEFPY (af_rt_vpn_imexport
,
9045 af_rt_vpn_imexport_cmd
,
9046 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9048 "Specify route target list\n"
9049 "Specify route target list\n"
9050 "Between current address-family and vpn\n"
9051 "For routes leaked from vpn to current address-family: match any\n"
9052 "For routes leaked from current address-family to vpn: set\n"
9053 "both import: match any and export: set\n"
9054 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9058 struct ecommunity
*ecom
= NULL
;
9059 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9060 enum vpn_policy_direction dir
;
9065 if (argv_find(argv
, argc
, "no", &idx
))
9068 afi
= vpn_policy_getafi(vty
, bgp
, false);
9070 return CMD_WARNING_CONFIG_FAILED
;
9072 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9073 if (ret
!= CMD_SUCCESS
)
9077 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9078 vty_out(vty
, "%% Missing RTLIST\n");
9079 return CMD_WARNING_CONFIG_FAILED
;
9081 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9082 if (ret
!= CMD_SUCCESS
) {
9087 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9091 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9094 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9096 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9097 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9098 ecommunity_dup(ecom
);
9100 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9102 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9103 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9106 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9110 ecommunity_free(&ecom
);
9115 ALIAS (af_rt_vpn_imexport
,
9116 af_no_rt_vpn_imexport_cmd
,
9117 "no <rt|route-target> vpn <import|export|both>$direction_str",
9119 "Specify route target list\n"
9120 "Specify route target list\n"
9121 "Between current address-family and vpn\n"
9122 "For routes leaked from vpn to current address-family\n"
9123 "For routes leaked from current address-family to vpn\n"
9124 "both import and export\n")
9126 DEFPY (af_route_map_vpn_imexport
,
9127 af_route_map_vpn_imexport_cmd
,
9128 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9129 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9131 "Specify route map\n"
9132 "Between current address-family and vpn\n"
9133 "For routes leaked from vpn to current address-family\n"
9134 "For routes leaked from current address-family to vpn\n"
9135 "name of route-map\n")
9137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9139 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9140 enum vpn_policy_direction dir
;
9145 if (argv_find(argv
, argc
, "no", &idx
))
9148 afi
= vpn_policy_getafi(vty
, bgp
, false);
9150 return CMD_WARNING_CONFIG_FAILED
;
9152 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9153 if (ret
!= CMD_SUCCESS
)
9156 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9160 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9163 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9164 XFREE(MTYPE_ROUTE_MAP_NAME
,
9165 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9166 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9167 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9168 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9169 route_map_lookup_warn_noexist(vty
, rmap_str
);
9170 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9173 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9174 XFREE(MTYPE_ROUTE_MAP_NAME
,
9175 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9176 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9177 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9180 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9186 ALIAS (af_route_map_vpn_imexport
,
9187 af_no_route_map_vpn_imexport_cmd
,
9188 "no route-map vpn <import|export>$direction_str",
9190 "Specify route map\n"
9191 "Between current address-family and vpn\n"
9192 "For routes leaked from vpn to current address-family\n"
9193 "For routes leaked from current address-family to vpn\n")
9195 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9196 "import vrf route-map RMAP$rmap_str",
9197 "Import routes from another VRF\n"
9198 "Vrf routes being filtered\n"
9199 "Specify route map\n"
9200 "name of route-map\n")
9202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9203 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9205 struct bgp
*bgp_default
;
9207 afi
= vpn_policy_getafi(vty
, bgp
, true);
9209 return CMD_WARNING_CONFIG_FAILED
;
9211 bgp_default
= bgp_get_default();
9216 /* Auto-create assuming the same AS */
9217 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9218 BGP_INSTANCE_TYPE_DEFAULT
);
9222 "VRF default is not configured as a bgp instance\n");
9227 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9229 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9230 XFREE(MTYPE_ROUTE_MAP_NAME
,
9231 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9232 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9233 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9234 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9235 route_map_lookup_warn_noexist(vty
, rmap_str
);
9236 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9239 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9240 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9242 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9247 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9248 "no import vrf route-map [RMAP$rmap_str]",
9250 "Import routes from another VRF\n"
9251 "Vrf routes being filtered\n"
9252 "Specify route map\n"
9253 "name of route-map\n")
9255 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9256 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9259 afi
= vpn_policy_getafi(vty
, bgp
, true);
9261 return CMD_WARNING_CONFIG_FAILED
;
9263 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9265 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9266 XFREE(MTYPE_ROUTE_MAP_NAME
,
9267 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9268 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9269 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9271 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9272 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9273 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9275 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9280 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9281 "[no] import vrf VIEWVRFNAME$import_name",
9283 "Import routes from another VRF\n"
9284 "VRF to import from\n"
9285 "The name of the VRF\n")
9287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9288 struct listnode
*node
;
9289 struct bgp
*vrf_bgp
, *bgp_default
;
9292 bool remove
= false;
9295 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9299 if (import_name
== NULL
) {
9300 vty_out(vty
, "%% Missing import name\n");
9304 if (strcmp(import_name
, "route-map") == 0) {
9305 vty_out(vty
, "%% Must include route-map name\n");
9309 if (argv_find(argv
, argc
, "no", &idx
))
9312 afi
= vpn_policy_getafi(vty
, bgp
, true);
9314 return CMD_WARNING_CONFIG_FAILED
;
9316 safi
= bgp_node_safi(vty
);
9318 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9319 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9320 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9321 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9322 remove
? "unimport" : "import", import_name
);
9326 bgp_default
= bgp_get_default();
9328 /* Auto-create assuming the same AS */
9329 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9330 BGP_INSTANCE_TYPE_DEFAULT
);
9334 "VRF default is not configured as a bgp instance\n");
9339 vrf_bgp
= bgp_lookup_by_name(import_name
);
9341 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9342 vrf_bgp
= bgp_default
;
9344 /* Auto-create assuming the same AS */
9345 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9349 "VRF %s is not configured as a bgp instance\n",
9356 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9358 /* Already importing from "import_vrf"? */
9359 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9361 if (strcmp(vname
, import_name
) == 0)
9365 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9371 /* This command is valid only in a bgp vrf instance or the default instance */
9372 DEFPY (bgp_imexport_vpn
,
9373 bgp_imexport_vpn_cmd
,
9374 "[no] <import|export>$direction_str vpn",
9376 "Import routes to this address-family\n"
9377 "Export routes from this address-family\n"
9378 "to/from default instance VPN RIB\n")
9380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9387 enum vpn_policy_direction dir
;
9389 if (argv_find(argv
, argc
, "no", &idx
))
9392 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9393 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9395 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9396 return CMD_WARNING_CONFIG_FAILED
;
9399 afi
= bgp_node_afi(vty
);
9400 safi
= bgp_node_safi(vty
);
9401 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9402 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9403 return CMD_WARNING_CONFIG_FAILED
;
9406 if (!strcmp(direction_str
, "import")) {
9407 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9408 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9409 } else if (!strcmp(direction_str
, "export")) {
9410 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9411 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9413 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9414 return CMD_WARNING_CONFIG_FAILED
;
9417 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9420 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9421 if (!previous_state
) {
9422 /* trigger export current vrf */
9423 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9426 if (previous_state
) {
9427 /* trigger un-export current vrf */
9428 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9430 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9433 hook_call(bgp_snmp_init_stats
, bgp
);
9438 DEFPY (af_routetarget_import
,
9439 af_routetarget_import_cmd
,
9440 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9442 "Specify route target list\n"
9443 "Specify route target list\n"
9444 "Specify route target list\n"
9445 "Specify route target list\n"
9446 "Flow-spec redirect type route target\n"
9447 "Import routes to this address-family\n"
9448 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9452 struct ecommunity
*ecom
= NULL
;
9454 int idx
= 0, idx_unused
= 0;
9458 if (argv_find(argv
, argc
, "no", &idx
))
9461 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9462 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9465 afi
= vpn_policy_getafi(vty
, bgp
, false);
9467 return CMD_WARNING_CONFIG_FAILED
;
9469 if (rt6
&& afi
!= AFI_IP6
)
9470 return CMD_WARNING_CONFIG_FAILED
;
9473 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9474 vty_out(vty
, "%% Missing RTLIST\n");
9475 return CMD_WARNING_CONFIG_FAILED
;
9477 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9478 if (ret
!= CMD_SUCCESS
)
9483 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9484 ecommunity_free(&bgp
->vpn_policy
[afi
]
9485 .import_redirect_rtlist
);
9486 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9487 ecommunity_dup(ecom
);
9489 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9490 ecommunity_free(&bgp
->vpn_policy
[afi
]
9491 .import_redirect_rtlist
);
9492 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9496 ecommunity_free(&ecom
);
9501 DEFUN_NOSH (address_family_ipv4_safi
,
9502 address_family_ipv4_safi_cmd
,
9503 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9504 "Enter Address Family command mode\n"
9506 BGP_SAFI_WITH_LABEL_HELP_STR
)
9510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9511 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9512 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9513 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9514 && safi
!= SAFI_EVPN
) {
9516 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9517 return CMD_WARNING_CONFIG_FAILED
;
9519 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9521 vty
->node
= BGP_IPV4_NODE
;
9526 DEFUN_NOSH (address_family_ipv6_safi
,
9527 address_family_ipv6_safi_cmd
,
9528 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9529 "Enter Address Family command mode\n"
9531 BGP_SAFI_WITH_LABEL_HELP_STR
)
9534 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9535 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9536 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9537 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9538 && safi
!= SAFI_EVPN
) {
9540 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9541 return CMD_WARNING_CONFIG_FAILED
;
9543 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9545 vty
->node
= BGP_IPV6_NODE
;
9550 #ifdef KEEP_OLD_VPN_COMMANDS
9551 DEFUN_NOSH (address_family_vpnv4
,
9552 address_family_vpnv4_cmd
,
9553 "address-family vpnv4 [unicast]",
9554 "Enter Address Family command mode\n"
9556 BGP_AF_MODIFIER_STR
)
9558 vty
->node
= BGP_VPNV4_NODE
;
9562 DEFUN_NOSH (address_family_vpnv6
,
9563 address_family_vpnv6_cmd
,
9564 "address-family vpnv6 [unicast]",
9565 "Enter Address Family command mode\n"
9567 BGP_AF_MODIFIER_STR
)
9569 vty
->node
= BGP_VPNV6_NODE
;
9572 #endif /* KEEP_OLD_VPN_COMMANDS */
9574 DEFUN_NOSH (address_family_evpn
,
9575 address_family_evpn_cmd
,
9576 "address-family l2vpn evpn",
9577 "Enter Address Family command mode\n"
9579 BGP_AF_MODIFIER_STR
)
9581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9582 vty
->node
= BGP_EVPN_NODE
;
9586 DEFUN_NOSH (bgp_segment_routing_srv6
,
9587 bgp_segment_routing_srv6_cmd
,
9588 "segment-routing srv6",
9589 "Segment-Routing configuration\n"
9590 "Segment-Routing SRv6 configuration\n")
9592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9593 bgp
->srv6_enabled
= true;
9594 vty
->node
= BGP_SRV6_NODE
;
9598 DEFUN (no_bgp_segment_routing_srv6
,
9599 no_bgp_segment_routing_srv6_cmd
,
9600 "no segment-routing srv6",
9602 "Segment-Routing configuration\n"
9603 "Segment-Routing SRv6 configuration\n")
9605 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9607 if (strlen(bgp
->srv6_locator_name
) > 0)
9608 if (bgp_srv6_locator_unset(bgp
) < 0)
9609 return CMD_WARNING_CONFIG_FAILED
;
9611 bgp
->srv6_enabled
= false;
9615 DEFPY (bgp_srv6_locator
,
9616 bgp_srv6_locator_cmd
,
9617 "locator NAME$name",
9618 "Specify SRv6 locator\n"
9619 "Specify SRv6 locator\n")
9621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9624 if (strlen(bgp
->srv6_locator_name
) > 0
9625 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9626 vty_out(vty
, "srv6 locator is already configured\n");
9627 return CMD_WARNING_CONFIG_FAILED
;
9630 snprintf(bgp
->srv6_locator_name
,
9631 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9633 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9635 return CMD_WARNING_CONFIG_FAILED
;
9640 DEFPY (no_bgp_srv6_locator
,
9641 no_bgp_srv6_locator_cmd
,
9642 "no locator NAME$name",
9644 "Specify SRv6 locator\n"
9645 "Specify SRv6 locator\n")
9647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9649 /* when locator isn't configured, do nothing */
9650 if (strlen(bgp
->srv6_locator_name
) < 1)
9653 /* name validation */
9654 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9655 vty_out(vty
, "%% No srv6 locator is configured\n");
9656 return CMD_WARNING_CONFIG_FAILED
;
9660 if (bgp_srv6_locator_unset(bgp
) < 0)
9661 return CMD_WARNING_CONFIG_FAILED
;
9666 DEFPY (show_bgp_srv6
,
9668 "show bgp segment-routing srv6",
9671 "BGP Segment Routing\n"
9672 "BGP Segment Routing SRv6\n")
9675 struct listnode
*node
;
9676 struct srv6_locator_chunk
*chunk
;
9677 struct bgp_srv6_function
*func
;
9680 bgp
= bgp_get_default();
9684 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9685 vty_out(vty
, "locator_chunks:\n");
9686 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9687 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9689 vty_out(vty
, "functions:\n");
9690 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9691 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9692 vty_out(vty
, "- sid: %s\n", buf
);
9693 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9696 vty_out(vty
, "bgps:\n");
9697 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9698 vty_out(vty
, "- name: %s\n",
9699 bgp
->name
? bgp
->name
: "default");
9701 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9702 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9703 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9704 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9710 DEFUN_NOSH (exit_address_family
,
9711 exit_address_family_cmd
,
9712 "exit-address-family",
9713 "Exit from Address Family configuration mode\n")
9715 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9716 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9717 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9718 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9719 || vty
->node
== BGP_EVPN_NODE
9720 || vty
->node
== BGP_FLOWSPECV4_NODE
9721 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9722 vty
->node
= BGP_NODE
;
9726 /* Recalculate bestpath and re-advertise a prefix */
9727 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9728 const char *ip_str
, afi_t afi
, safi_t safi
,
9729 struct prefix_rd
*prd
)
9732 struct prefix match
;
9733 struct bgp_dest
*dest
;
9734 struct bgp_dest
*rm
;
9736 struct bgp_table
*table
;
9737 struct bgp_table
*rib
;
9739 /* BGP structure lookup. */
9741 bgp
= bgp_lookup_by_name(view_name
);
9743 vty_out(vty
, "%% Can't find BGP instance %s\n",
9748 bgp
= bgp_get_default();
9750 vty_out(vty
, "%% No BGP process is configured\n");
9755 /* Check IP address argument. */
9756 ret
= str2prefix(ip_str
, &match
);
9758 vty_out(vty
, "%% address is malformed\n");
9762 match
.family
= afi2family(afi
);
9763 rib
= bgp
->rib
[afi
][safi
];
9765 if (safi
== SAFI_MPLS_VPN
) {
9766 for (dest
= bgp_table_top(rib
); dest
;
9767 dest
= bgp_route_next(dest
)) {
9768 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9770 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9773 table
= bgp_dest_get_bgp_table_info(dest
);
9777 rm
= bgp_node_match(table
, &match
);
9779 const struct prefix
*rm_p
=
9780 bgp_dest_get_prefix(rm
);
9782 if (rm_p
->prefixlen
== match
.prefixlen
) {
9784 BGP_NODE_USER_CLEAR
);
9785 bgp_process(bgp
, rm
, afi
, safi
);
9787 bgp_dest_unlock_node(rm
);
9791 dest
= bgp_node_match(rib
, &match
);
9793 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9795 if (dest_p
->prefixlen
== match
.prefixlen
) {
9796 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9797 bgp_process(bgp
, dest
, afi
, safi
);
9799 bgp_dest_unlock_node(dest
);
9806 /* one clear bgp command to rule them all */
9807 DEFUN (clear_ip_bgp_all
,
9808 clear_ip_bgp_all_cmd
,
9809 "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>]",
9813 BGP_INSTANCE_HELP_STR
9816 BGP_SAFI_WITH_LABEL_HELP_STR
9819 "BGP IPv4 neighbor to clear\n"
9820 "BGP IPv6 neighbor to clear\n"
9821 "BGP neighbor on interface to clear\n"
9822 "Clear peers with the AS number\n"
9823 "Clear all external peers\n"
9824 "Clear all members of peer-group\n"
9825 "BGP peer-group name\n"
9830 "Push out prefix-list ORF and do inbound soft reconfig\n"
9832 "Reset message statistics\n")
9836 afi_t afi
= AFI_UNSPEC
;
9837 safi_t safi
= SAFI_UNSPEC
;
9838 enum clear_sort clr_sort
= clear_peer
;
9839 enum bgp_clear_type clr_type
;
9840 char *clr_arg
= NULL
;
9844 /* clear [ip] bgp */
9845 if (argv_find(argv
, argc
, "ip", &idx
))
9848 /* [<vrf> VIEWVRFNAME] */
9849 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9850 vrf
= argv
[idx
+ 1]->arg
;
9852 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9854 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9855 /* [<view> VIEWVRFNAME] */
9856 vrf
= argv
[idx
+ 1]->arg
;
9859 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9860 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9861 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9863 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9864 if (argv_find(argv
, argc
, "*", &idx
)) {
9865 clr_sort
= clear_all
;
9866 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9867 clr_sort
= clear_peer
;
9868 clr_arg
= argv
[idx
]->arg
;
9869 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9870 clr_sort
= clear_peer
;
9871 clr_arg
= argv
[idx
]->arg
;
9872 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9873 clr_sort
= clear_group
;
9875 clr_arg
= argv
[idx
]->arg
;
9876 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9877 clr_sort
= clear_peer
;
9878 clr_arg
= argv
[idx
]->arg
;
9879 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9880 clr_sort
= clear_peer
;
9881 clr_arg
= argv
[idx
]->arg
;
9882 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9883 clr_sort
= clear_as
;
9884 clr_arg
= argv
[idx
]->arg
;
9885 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9886 clr_sort
= clear_external
;
9889 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9890 if (argv_find(argv
, argc
, "soft", &idx
)) {
9891 if (argv_find(argv
, argc
, "in", &idx
)
9892 || argv_find(argv
, argc
, "out", &idx
))
9893 clr_type
= strmatch(argv
[idx
]->text
, "in")
9895 : BGP_CLEAR_SOFT_OUT
;
9897 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9898 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9899 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9900 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9901 : BGP_CLEAR_SOFT_IN
;
9902 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9903 clr_type
= BGP_CLEAR_SOFT_OUT
;
9904 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9905 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9907 clr_type
= BGP_CLEAR_SOFT_NONE
;
9909 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9912 DEFUN (clear_ip_bgp_prefix
,
9913 clear_ip_bgp_prefix_cmd
,
9914 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9918 BGP_INSTANCE_HELP_STR
9919 "Clear bestpath and re-advertise\n"
9923 char *prefix
= NULL
;
9927 /* [<view|vrf> VIEWVRFNAME] */
9928 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9929 vrf
= argv
[idx
+ 1]->arg
;
9931 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9933 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9934 /* [<view> VIEWVRFNAME] */
9935 vrf
= argv
[idx
+ 1]->arg
;
9939 prefix
= argv
[argc
- 1]->arg
;
9941 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9944 DEFUN (clear_bgp_ipv6_safi_prefix
,
9945 clear_bgp_ipv6_safi_prefix_cmd
,
9946 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9952 "Clear bestpath and re-advertise\n"
9956 int idx_ipv6_prefix
= 0;
9957 safi_t safi
= SAFI_UNICAST
;
9958 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9959 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9961 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9962 return bgp_clear_prefix(
9963 vty
, NULL
, prefix
, AFI_IP6
,
9967 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9968 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9969 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9973 BGP_INSTANCE_HELP_STR
9976 "Clear bestpath and re-advertise\n"
9980 int idx_vrfview
= 0;
9981 int idx_ipv6_prefix
= 0;
9982 safi_t safi
= SAFI_UNICAST
;
9983 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9984 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9985 char *vrfview
= NULL
;
9987 /* [<view|vrf> VIEWVRFNAME] */
9988 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9989 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9990 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9992 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9993 /* [<view> VIEWVRFNAME] */
9994 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9996 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9998 return bgp_clear_prefix(
9999 vty
, vrfview
, prefix
,
10000 AFI_IP6
, safi
, NULL
);
10003 DEFUN (show_bgp_views
,
10004 show_bgp_views_cmd
,
10005 "show [ip] bgp views",
10009 "Show the defined BGP views\n")
10011 struct list
*inst
= bm
->bgp
;
10012 struct listnode
*node
;
10015 vty_out(vty
, "Defined BGP views:\n");
10016 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10018 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10020 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10024 return CMD_SUCCESS
;
10027 DEFUN (show_bgp_vrfs
,
10029 "show [ip] bgp vrfs [json]",
10036 char buf
[ETHER_ADDR_STRLEN
];
10037 struct list
*inst
= bm
->bgp
;
10038 struct listnode
*node
;
10040 bool uj
= use_json(argc
, argv
);
10041 json_object
*json
= NULL
;
10042 json_object
*json_vrfs
= NULL
;
10046 json
= json_object_new_object();
10047 json_vrfs
= json_object_new_object();
10050 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10051 const char *name
, *type
;
10053 struct listnode
*node2
, *nnode2
;
10054 int peers_cfg
, peers_estb
;
10055 json_object
*json_vrf
= NULL
;
10058 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10062 if (!uj
&& count
== 1) {
10064 "%4s %-5s %-16s %9s %10s %-37s\n",
10065 "Type", "Id", "routerId", "#PeersCfg",
10066 "#PeersEstb", "Name");
10067 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10068 "L3-VNI", "RouterMAC", "Interface");
10071 peers_cfg
= peers_estb
= 0;
10073 json_vrf
= json_object_new_object();
10076 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10077 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10080 if (peer_established(peer
))
10084 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10085 name
= VRF_DEFAULT_NAME
;
10094 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10096 : (int64_t)bgp
->vrf_id
;
10097 char buf
[BUFSIZ
] = {0};
10099 json_object_string_add(json_vrf
, "type", type
);
10100 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10101 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10103 json_object_int_add(json_vrf
, "numConfiguredPeers",
10105 json_object_int_add(json_vrf
, "numEstablishedPeers",
10108 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10109 json_object_string_add(
10111 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10112 json_object_string_add(json_vrf
, "interface",
10113 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10115 json_object_object_add(json_vrfs
, name
, json_vrf
);
10117 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10119 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10120 : (int)bgp
->vrf_id
,
10121 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10122 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10124 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10125 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10131 json_object_object_add(json
, "vrfs", json_vrfs
);
10133 json_object_int_add(json
, "totalVrfs", count
);
10135 vty_json(vty
, json
);
10139 "\nTotal number of VRFs (including default): %d\n",
10143 return CMD_SUCCESS
;
10146 DEFUN (show_bgp_mac_hash
,
10147 show_bgp_mac_hash_cmd
,
10148 "show bgp mac hash",
10152 "Mac Address database\n")
10154 bgp_mac_dump_table(vty
);
10156 return CMD_SUCCESS
;
10159 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10161 struct vty
*vty
= (struct vty
*)args
;
10162 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10164 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10167 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10169 vty_out(vty
, "self nexthop database:\n");
10170 bgp_nexthop_show_address_hash(vty
, bgp
);
10172 vty_out(vty
, "Tunnel-ip database:\n");
10173 hash_iterate(bgp
->tip_hash
,
10174 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10178 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10179 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10180 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10181 "martian next-hops\n"
10182 "martian next-hop database\n")
10184 struct bgp
*bgp
= NULL
;
10188 /* [<vrf> VIEWVRFNAME] */
10189 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10190 name
= argv
[idx
+ 1]->arg
;
10191 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10193 } else if (argv_find(argv
, argc
, "view", &idx
))
10194 /* [<view> VIEWVRFNAME] */
10195 name
= argv
[idx
+ 1]->arg
;
10197 bgp
= bgp_lookup_by_name(name
);
10199 bgp
= bgp_get_default();
10202 vty_out(vty
, "%% No BGP process is configured\n");
10203 return CMD_WARNING
;
10205 bgp_show_martian_nexthops(vty
, bgp
);
10207 return CMD_SUCCESS
;
10210 DEFUN (show_bgp_memory
,
10211 show_bgp_memory_cmd
,
10212 "show [ip] bgp memory",
10216 "Global BGP memory statistics\n")
10218 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10219 unsigned long count
;
10221 /* RIB related usage stats */
10222 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10223 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10224 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10225 count
* sizeof(struct bgp_dest
)));
10227 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10228 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10229 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10230 count
* sizeof(struct bgp_path_info
)));
10231 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10232 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10235 memstrbuf
, sizeof(memstrbuf
),
10236 count
* sizeof(struct bgp_path_info_extra
)));
10238 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10239 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10240 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10241 count
* sizeof(struct bgp_static
)));
10243 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10244 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10245 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10246 count
* sizeof(struct bpacket
)));
10249 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10250 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10251 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10252 count
* sizeof(struct bgp_adj_in
)));
10253 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10254 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10255 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10256 count
* sizeof(struct bgp_adj_out
)));
10258 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10259 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10261 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10262 count
* sizeof(struct bgp_nexthop_cache
)));
10264 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10265 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10267 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10268 count
* sizeof(struct bgp_damp_info
)));
10271 count
= attr_count();
10272 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10273 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10274 count
* sizeof(struct attr
)));
10276 if ((count
= attr_unknown_count()))
10277 vty_out(vty
, "%ld unknown attributes\n", count
);
10279 /* AS_PATH attributes */
10280 count
= aspath_count();
10281 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10282 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10283 count
* sizeof(struct aspath
)));
10285 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10286 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10287 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10288 count
* sizeof(struct assegment
)));
10290 /* Other attributes */
10291 if ((count
= community_count()))
10292 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10293 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10294 count
* sizeof(struct community
)));
10295 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10297 "%ld BGP ext-community entries, using %s of memory\n",
10299 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10300 count
* sizeof(struct ecommunity
)));
10301 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10303 "%ld BGP large-community entries, using %s of memory\n",
10304 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10305 count
* sizeof(struct lcommunity
)));
10307 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10308 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10309 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10310 count
* sizeof(struct cluster_list
)));
10312 /* Peer related usage */
10313 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10314 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10315 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10316 count
* sizeof(struct peer
)));
10318 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10319 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10320 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10321 count
* sizeof(struct peer_group
)));
10324 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10325 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10326 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10327 count
* sizeof(regex_t
)));
10328 return CMD_SUCCESS
;
10331 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10333 json_object
*bestpath
= json_object_new_object();
10335 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10336 json_object_string_add(bestpath
, "asPath", "ignore");
10338 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10339 json_object_string_add(bestpath
, "asPath", "confed");
10341 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10342 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10343 json_object_string_add(bestpath
, "multiPathRelax",
10346 json_object_string_add(bestpath
, "multiPathRelax",
10349 json_object_string_add(bestpath
, "multiPathRelax", "false");
10351 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10352 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10354 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10355 json_object_string_add(bestpath
, "compareRouterId", "true");
10356 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10357 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10358 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10359 json_object_string_add(bestpath
, "med", "confed");
10360 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10361 json_object_string_add(bestpath
, "med",
10362 "missing-as-worst");
10364 json_object_string_add(bestpath
, "med", "true");
10367 json_object_object_add(json
, "bestPath", bestpath
);
10370 /* Print the error code/subcode for why the peer is down */
10371 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10372 json_object
*json_peer
, bool use_json
)
10374 const char *code_str
;
10375 const char *subcode_str
;
10378 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10379 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10380 char errorcodesubcode_hexstr
[5];
10381 char errorcodesubcode_str
[256];
10383 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10384 subcode_str
= bgp_notify_subcode_str(
10386 peer
->notify
.subcode
);
10388 snprintf(errorcodesubcode_hexstr
,
10389 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10390 peer
->notify
.code
, peer
->notify
.subcode
);
10391 json_object_string_add(json_peer
,
10392 "lastErrorCodeSubcode",
10393 errorcodesubcode_hexstr
);
10394 snprintf(errorcodesubcode_str
, 255, "%s%s",
10395 code_str
, subcode_str
);
10396 json_object_string_add(json_peer
,
10397 "lastNotificationReason",
10398 errorcodesubcode_str
);
10399 json_object_boolean_add(json_peer
,
10400 "lastNotificationHardReset",
10401 peer
->notify
.hard_reset
);
10402 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10403 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10404 && (peer
->notify
.subcode
10405 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10406 || peer
->notify
.subcode
10407 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10408 && peer
->notify
.length
) {
10410 const char *msg_str
;
10412 msg_str
= bgp_notify_admin_message(
10413 msgbuf
, sizeof(msgbuf
),
10414 (uint8_t *)peer
->notify
.data
,
10415 peer
->notify
.length
);
10417 json_object_string_add(
10419 "lastShutdownDescription",
10424 json_object_string_add(json_peer
, "lastResetDueTo",
10425 peer_down_str
[(int)peer
->last_reset
]);
10426 json_object_int_add(json_peer
, "lastResetCode",
10429 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10430 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10431 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10433 bgp_notify_subcode_str(peer
->notify
.code
,
10434 peer
->notify
.subcode
);
10435 vty_out(vty
, " Notification %s (%s%s%s)\n",
10436 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10439 code_str
, subcode_str
,
10440 peer
->notify
.hard_reset
10441 ? bgp_notify_subcode_str(
10443 BGP_NOTIFY_CEASE_HARD_RESET
)
10446 vty_out(vty
, " %s\n",
10447 peer_down_str
[(int)peer
->last_reset
]);
10452 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10455 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10458 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10459 struct peer
*peer
, json_object
*json_peer
,
10460 int max_neighbor_width
, bool use_json
)
10462 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10466 if (peer_dynamic_neighbor(peer
))
10467 json_object_boolean_true_add(json_peer
,
10469 if (peer
->hostname
)
10470 json_object_string_add(json_peer
, "hostname",
10473 if (peer
->domainname
)
10474 json_object_string_add(json_peer
, "domainname",
10476 json_object_int_add(json_peer
, "connectionsEstablished",
10477 peer
->established
);
10478 json_object_int_add(json_peer
, "connectionsDropped",
10480 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10481 use_json
, json_peer
);
10482 if (peer_established(peer
))
10483 json_object_string_add(json_peer
, "lastResetDueTo",
10484 "AFI/SAFI Not Negotiated");
10486 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10489 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10491 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10492 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10493 peer
->hostname
, peer
->host
);
10495 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10497 /* pad the neighbor column with spaces */
10498 if (len
< max_neighbor_width
)
10499 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10501 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10503 peer_uptime(peer
->uptime
, timebuf
,
10504 BGP_UPTIME_LEN
, 0, NULL
));
10505 if (peer_established(peer
))
10506 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10508 bgp_show_peer_reset(vty
, peer
, NULL
,
10513 /* Strip peer's description to the given size. */
10514 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10516 static char stripped
[BUFSIZ
];
10518 uint32_t last_space
= 0;
10521 if (*(desc
+ i
) == 0) {
10522 stripped
[i
] = '\0';
10525 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10527 stripped
[i
] = *(desc
+ i
);
10531 if (last_space
> size
)
10532 stripped
[size
+ 1] = '\0';
10534 stripped
[last_space
] = '\0';
10539 /* Determine whether var peer should be filtered out of the summary. */
10540 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10541 struct peer
*fpeer
, int as_type
,
10545 /* filter neighbor XXXX */
10546 if (fpeer
&& fpeer
!= peer
)
10549 /* filter remote-as (internal|external) */
10550 if (as_type
!= AS_UNSPECIFIED
) {
10551 if (peer
->as_type
== AS_SPECIFIED
) {
10552 if (as_type
== AS_INTERNAL
) {
10553 if (peer
->as
!= peer
->local_as
)
10555 } else if (peer
->as
== peer
->local_as
)
10557 } else if (as_type
!= peer
->as_type
)
10559 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10565 /* Show BGP peer's summary information.
10567 * Peer's description is stripped according to if `wide` option is given
10570 * When adding new columns to `show bgp summary` output, please make
10571 * sure `Desc` is the lastest column to show because it can contain
10572 * whitespaces and the whole output will be tricky.
10574 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10575 struct peer
*fpeer
, int as_type
, as_t as
,
10576 uint16_t show_flags
)
10579 struct listnode
*node
, *nnode
;
10580 unsigned int count
= 0, dn_count
= 0;
10581 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10582 char neighbor_buf
[VTY_BUFSIZ
];
10583 int neighbor_col_default_width
= 16;
10584 int len
, failed_count
= 0;
10585 unsigned int filtered_count
= 0;
10586 int max_neighbor_width
= 0;
10588 json_object
*json
= NULL
;
10589 json_object
*json_peer
= NULL
;
10590 json_object
*json_peers
= NULL
;
10591 struct peer_af
*paf
;
10592 struct bgp_filter
*filter
;
10593 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10594 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10595 bool show_established
=
10596 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10597 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10598 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10600 /* labeled-unicast routes are installed in the unicast table so in order
10602 * display the correct PfxRcd value we must look at SAFI_UNICAST
10605 if (safi
== SAFI_LABELED_UNICAST
)
10606 pfx_rcd_safi
= SAFI_UNICAST
;
10608 pfx_rcd_safi
= safi
;
10611 json
= json_object_new_object();
10612 json_peers
= json_object_new_object();
10613 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10614 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10621 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10624 if (peer
->afc
[afi
][safi
]) {
10625 /* See if we have at least a single failed peer */
10626 if (bgp_has_peer_failed(peer
, afi
, safi
))
10630 if (peer_dynamic_neighbor(peer
))
10635 /* Loop over all neighbors that will be displayed to determine
10637 * characters are needed for the Neighbor column
10639 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10640 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10647 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10650 if (peer
->afc
[afi
][safi
]) {
10651 memset(dn_flag
, '\0', sizeof(dn_flag
));
10652 if (peer_dynamic_neighbor(peer
))
10656 && CHECK_FLAG(bgp
->flags
,
10657 BGP_FLAG_SHOW_HOSTNAME
))
10658 snprintf(neighbor_buf
,
10659 sizeof(neighbor_buf
),
10660 "%s%s(%s) ", dn_flag
,
10661 peer
->hostname
, peer
->host
);
10663 snprintf(neighbor_buf
,
10664 sizeof(neighbor_buf
), "%s%s ",
10665 dn_flag
, peer
->host
);
10667 len
= strlen(neighbor_buf
);
10669 if (len
> max_neighbor_width
)
10670 max_neighbor_width
= len
;
10672 /* See if we have at least a single failed peer */
10673 if (bgp_has_peer_failed(peer
, afi
, safi
))
10679 /* Originally we displayed the Neighbor column as 16
10680 * characters wide so make that the default
10682 if (max_neighbor_width
< neighbor_col_default_width
)
10683 max_neighbor_width
= neighbor_col_default_width
;
10686 if (show_failed
&& !failed_count
) {
10688 json_object_int_add(json
, "failedPeersCount", 0);
10689 json_object_int_add(json
, "dynamicPeers", dn_count
);
10690 json_object_int_add(json
, "totalPeers", count
);
10692 vty_json(vty
, json
);
10694 vty_out(vty
, "%% No failed BGP neighbors found\n");
10696 return CMD_SUCCESS
;
10699 count
= 0; /* Reset the value as its used again */
10700 filtered_count
= 0;
10702 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10703 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10706 if (!peer
->afc
[afi
][safi
])
10710 unsigned long ents
;
10711 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10714 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10716 : (int64_t)bgp
->vrf_id
;
10718 /* Usage summary and header */
10720 json_object_string_addf(json
, "routerId",
10723 json_object_int_add(json
, "as", bgp
->as
);
10724 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10725 json_object_string_add(
10728 == BGP_INSTANCE_TYPE_DEFAULT
)
10733 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10734 &bgp
->router_id
, bgp
->as
,
10735 bgp
->vrf_id
== VRF_UNKNOWN
10737 : (int)bgp
->vrf_id
);
10738 vty_out(vty
, "\n");
10741 if (bgp_update_delay_configured(bgp
)) {
10743 json_object_int_add(
10744 json
, "updateDelayLimit",
10745 bgp
->v_update_delay
);
10747 if (bgp
->v_update_delay
10748 != bgp
->v_establish_wait
)
10749 json_object_int_add(
10751 "updateDelayEstablishWait",
10752 bgp
->v_establish_wait
);
10754 if (bgp_update_delay_active(bgp
)) {
10755 json_object_string_add(
10757 "updateDelayFirstNeighbor",
10758 bgp
->update_delay_begin_time
);
10759 json_object_boolean_true_add(
10761 "updateDelayInProgress");
10763 if (bgp
->update_delay_over
) {
10764 json_object_string_add(
10766 "updateDelayFirstNeighbor",
10767 bgp
->update_delay_begin_time
);
10768 json_object_string_add(
10770 "updateDelayBestpathResumed",
10771 bgp
->update_delay_end_time
);
10772 json_object_string_add(
10774 "updateDelayZebraUpdateResume",
10775 bgp
->update_delay_zebra_resume_time
);
10776 json_object_string_add(
10778 "updateDelayPeerUpdateResume",
10779 bgp
->update_delay_peers_resume_time
);
10784 "Read-only mode update-delay limit: %d seconds\n",
10785 bgp
->v_update_delay
);
10786 if (bgp
->v_update_delay
10787 != bgp
->v_establish_wait
)
10789 " Establish wait: %d seconds\n",
10790 bgp
->v_establish_wait
);
10792 if (bgp_update_delay_active(bgp
)) {
10794 " First neighbor established: %s\n",
10795 bgp
->update_delay_begin_time
);
10797 " Delay in progress\n");
10799 if (bgp
->update_delay_over
) {
10801 " First neighbor established: %s\n",
10802 bgp
->update_delay_begin_time
);
10804 " Best-paths resumed: %s\n",
10805 bgp
->update_delay_end_time
);
10807 " zebra update resumed: %s\n",
10808 bgp
->update_delay_zebra_resume_time
);
10810 " peers update resumed: %s\n",
10811 bgp
->update_delay_peers_resume_time
);
10818 if (bgp_maxmed_onstartup_configured(bgp
)
10819 && bgp
->maxmed_active
)
10820 json_object_boolean_true_add(
10821 json
, "maxMedOnStartup");
10822 if (bgp
->v_maxmed_admin
)
10823 json_object_boolean_true_add(
10824 json
, "maxMedAdministrative");
10826 json_object_int_add(
10827 json
, "tableVersion",
10828 bgp_table_version(bgp
->rib
[afi
][safi
]));
10830 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10831 json_object_int_add(json
, "ribCount", ents
);
10832 json_object_int_add(
10834 ents
* sizeof(struct bgp_dest
));
10836 ents
= bgp
->af_peer_count
[afi
][safi
];
10837 json_object_int_add(json
, "peerCount", ents
);
10838 json_object_int_add(json
, "peerMemory",
10839 ents
* sizeof(struct peer
));
10841 if ((ents
= listcount(bgp
->group
))) {
10842 json_object_int_add(
10843 json
, "peerGroupCount", ents
);
10844 json_object_int_add(
10845 json
, "peerGroupMemory",
10846 ents
* sizeof(struct
10850 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10851 BGP_CONFIG_DAMPENING
))
10852 json_object_boolean_true_add(
10853 json
, "dampeningEnabled");
10856 if (bgp_maxmed_onstartup_configured(bgp
)
10857 && bgp
->maxmed_active
)
10859 "Max-med on-startup active\n");
10860 if (bgp
->v_maxmed_admin
)
10862 "Max-med administrative active\n");
10865 "BGP table version %" PRIu64
10868 bgp
->rib
[afi
][safi
]));
10870 ents
= bgp_table_count(
10871 bgp
->rib
[afi
][safi
]);
10873 "RIB entries %ld, using %s of memory\n",
10883 /* Peer related usage */
10884 ents
= bgp
->af_peer_count
[afi
][safi
];
10886 "Peers %ld, using %s of memory\n",
10896 if ((ents
= listcount(bgp
->group
)))
10898 "Peer groups %ld, using %s of memory\n",
10908 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10909 BGP_CONFIG_DAMPENING
))
10911 "Dampening enabled.\n");
10914 vty_out(vty
, "\n");
10916 /* Subtract 8 here because 'Neighbor' is
10918 vty_out(vty
, "Neighbor");
10919 vty_out(vty
, "%*s",
10920 max_neighbor_width
- 8, " ");
10922 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10927 paf
= peer_af_find(peer
, afi
, safi
);
10928 filter
= &peer
->filter
[afi
][safi
];
10931 /* Works for both failed & successful cases */
10932 if (peer_dynamic_neighbor(peer
))
10937 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10943 bgp_has_peer_failed(peer
, afi
, safi
)) {
10944 json_peer
= json_object_new_object();
10945 bgp_show_failed_summary(vty
, bgp
, peer
,
10946 json_peer
, 0, use_json
);
10947 } else if (!show_failed
) {
10948 if (show_established
10949 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10954 json_peer
= json_object_new_object();
10955 if (peer_dynamic_neighbor(peer
)) {
10956 json_object_boolean_true_add(json_peer
,
10960 if (peer
->hostname
)
10961 json_object_string_add(json_peer
, "hostname",
10964 if (peer
->domainname
)
10965 json_object_string_add(json_peer
, "domainname",
10968 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10969 json_object_int_add(
10970 json_peer
, "localAs",
10971 peer
->change_local_as
10972 ? peer
->change_local_as
10974 json_object_int_add(json_peer
, "version", 4);
10975 json_object_int_add(json_peer
, "msgRcvd",
10976 PEER_TOTAL_RX(peer
));
10977 json_object_int_add(json_peer
, "msgSent",
10978 PEER_TOTAL_TX(peer
));
10980 atomic_size_t outq_count
, inq_count
;
10981 outq_count
= atomic_load_explicit(
10982 &peer
->obuf
->count
,
10983 memory_order_relaxed
);
10984 inq_count
= atomic_load_explicit(
10985 &peer
->ibuf
->count
,
10986 memory_order_relaxed
);
10988 json_object_int_add(json_peer
, "tableVersion",
10989 peer
->version
[afi
][safi
]);
10990 json_object_int_add(json_peer
, "outq",
10992 json_object_int_add(json_peer
, "inq",
10994 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10995 use_json
, json_peer
);
10997 json_object_int_add(json_peer
, "pfxRcd",
10998 peer
->pcount
[afi
][pfx_rcd_safi
]);
11000 if (paf
&& PAF_SUBGRP(paf
))
11001 json_object_int_add(
11002 json_peer
, "pfxSnt",
11003 (PAF_SUBGRP(paf
))->scount
);
11005 json_object_int_add(json_peer
, "pfxSnt",
11008 /* BGP FSM state */
11009 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11010 || CHECK_FLAG(peer
->bgp
->flags
,
11011 BGP_FLAG_SHUTDOWN
))
11012 json_object_string_add(json_peer
,
11015 else if (peer
->afc_recv
[afi
][safi
])
11016 json_object_string_add(
11017 json_peer
, "state",
11018 lookup_msg(bgp_status_msg
,
11019 peer
->status
, NULL
));
11020 else if (CHECK_FLAG(
11022 PEER_STATUS_PREFIX_OVERFLOW
))
11023 json_object_string_add(json_peer
,
11027 json_object_string_add(
11028 json_peer
, "state",
11029 lookup_msg(bgp_status_msg
,
11030 peer
->status
, NULL
));
11032 /* BGP peer state */
11033 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11034 || CHECK_FLAG(peer
->bgp
->flags
,
11035 BGP_FLAG_SHUTDOWN
))
11036 json_object_string_add(json_peer
,
11039 else if (CHECK_FLAG(
11041 PEER_STATUS_PREFIX_OVERFLOW
))
11042 json_object_string_add(json_peer
,
11045 else if (CHECK_FLAG(peer
->flags
,
11046 PEER_FLAG_PASSIVE
))
11047 json_object_string_add(json_peer
,
11050 else if (CHECK_FLAG(peer
->sflags
,
11051 PEER_STATUS_NSF_WAIT
))
11052 json_object_string_add(json_peer
,
11055 else if (CHECK_FLAG(
11057 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11058 && (!bgp_inbound_policy_exists(peer
,
11060 || !bgp_outbound_policy_exists(
11062 json_object_string_add(json_peer
,
11066 json_object_string_add(
11067 json_peer
, "peerState", "OK");
11069 json_object_int_add(json_peer
, "connectionsEstablished",
11070 peer
->established
);
11071 json_object_int_add(json_peer
, "connectionsDropped",
11074 json_object_string_add(
11075 json_peer
, "desc", peer
->desc
);
11077 /* Avoid creating empty peer dicts in JSON */
11078 if (json_peer
== NULL
)
11082 json_object_string_add(json_peer
, "idType",
11084 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11085 json_object_string_add(json_peer
, "idType",
11087 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11088 json_object_string_add(json_peer
, "idType",
11090 json_object_object_add(json_peers
, peer
->host
,
11093 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11099 bgp_has_peer_failed(peer
, afi
, safi
)) {
11100 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11101 max_neighbor_width
,
11103 } else if (!show_failed
) {
11104 if (show_established
11105 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11110 if ((count
- filtered_count
) == 1) {
11111 /* display headline before the first
11113 vty_out(vty
, "\n");
11115 /* Subtract 8 here because 'Neighbor' is
11117 vty_out(vty
, "Neighbor");
11118 vty_out(vty
, "%*s",
11119 max_neighbor_width
- 8, " ");
11122 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11123 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11126 memset(dn_flag
, '\0', sizeof(dn_flag
));
11127 if (peer_dynamic_neighbor(peer
)) {
11132 && CHECK_FLAG(bgp
->flags
,
11133 BGP_FLAG_SHOW_HOSTNAME
))
11134 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11138 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11140 /* pad the neighbor column with spaces */
11141 if (len
< max_neighbor_width
)
11142 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11145 atomic_size_t outq_count
, inq_count
;
11146 outq_count
= atomic_load_explicit(
11147 &peer
->obuf
->count
,
11148 memory_order_relaxed
);
11149 inq_count
= atomic_load_explicit(
11150 &peer
->ibuf
->count
,
11151 memory_order_relaxed
);
11155 "4 %10u %10u %9u %9u %8" PRIu64
11158 peer
->change_local_as
11159 ? peer
->change_local_as
11161 PEER_TOTAL_RX(peer
),
11162 PEER_TOTAL_TX(peer
),
11163 peer
->version
[afi
][safi
],
11164 inq_count
, outq_count
,
11165 peer_uptime(peer
->uptime
,
11170 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11172 peer
->as
, PEER_TOTAL_RX(peer
),
11173 PEER_TOTAL_TX(peer
),
11174 peer
->version
[afi
][safi
],
11175 inq_count
, outq_count
,
11176 peer_uptime(peer
->uptime
,
11181 if (peer_established(peer
)) {
11182 if (peer
->afc_recv
[afi
][safi
]) {
11185 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11186 && !bgp_inbound_policy_exists(
11188 vty_out(vty
, " %12s",
11197 vty_out(vty
, " NoNeg");
11200 if (paf
&& PAF_SUBGRP(paf
)) {
11203 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11204 && !bgp_outbound_policy_exists(
11206 vty_out(vty
, " %8s",
11215 vty_out(vty
, " NoNeg");
11218 if (CHECK_FLAG(peer
->flags
,
11219 PEER_FLAG_SHUTDOWN
)
11220 || CHECK_FLAG(peer
->bgp
->flags
,
11221 BGP_FLAG_SHUTDOWN
))
11222 vty_out(vty
, " Idle (Admin)");
11223 else if (CHECK_FLAG(
11225 PEER_STATUS_PREFIX_OVERFLOW
))
11226 vty_out(vty
, " Idle (PfxCt)");
11228 vty_out(vty
, " %12s",
11229 lookup_msg(bgp_status_msg
,
11230 peer
->status
, NULL
));
11232 vty_out(vty
, " %8u", 0);
11234 /* Make sure `Desc` column is the lastest in
11238 vty_out(vty
, " %s",
11239 bgp_peer_description_stripped(
11241 show_wide
? 64 : 20));
11243 vty_out(vty
, " N/A");
11244 vty_out(vty
, "\n");
11251 json_object_object_add(json
, "peers", json_peers
);
11252 json_object_int_add(json
, "failedPeers", failed_count
);
11253 json_object_int_add(json
, "displayedPeers",
11254 count
- filtered_count
);
11255 json_object_int_add(json
, "totalPeers", count
);
11256 json_object_int_add(json
, "dynamicPeers", dn_count
);
11259 bgp_show_bestpath_json(bgp
, json
);
11261 vty_json(vty
, json
);
11264 if (filtered_count
== count
)
11265 vty_out(vty
, "\n%% No matching neighbor\n");
11268 vty_out(vty
, "\nDisplayed neighbors %d",
11270 else if (as_type
!= AS_UNSPECIFIED
|| as
11271 || fpeer
|| show_established
)
11272 vty_out(vty
, "\nDisplayed neighbors %d",
11273 count
- filtered_count
);
11275 vty_out(vty
, "\nTotal number of neighbors %d\n",
11279 vty_out(vty
, "No %s neighbor is configured\n",
11280 get_afi_safi_str(afi
, safi
, false));
11284 vty_out(vty
, "* - dynamic neighbor\n");
11285 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11286 dn_count
, bgp
->dynamic_neighbors_limit
);
11290 return CMD_SUCCESS
;
11293 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11294 int safi
, struct peer
*fpeer
, int as_type
,
11295 as_t as
, uint16_t show_flags
)
11298 int afi_wildcard
= (afi
== AFI_MAX
);
11299 int safi_wildcard
= (safi
== SAFI_MAX
);
11300 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11301 bool nbr_output
= false;
11302 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11304 if (use_json
&& is_wildcard
)
11305 vty_out(vty
, "{\n");
11307 afi
= 1; /* AFI_IP */
11308 while (afi
< AFI_MAX
) {
11310 safi
= 1; /* SAFI_UNICAST */
11311 while (safi
< SAFI_MAX
) {
11312 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11317 * So limit output to those afi/safi
11319 * actualy have something interesting in
11324 vty_out(vty
, ",\n");
11328 vty_out(vty
, "\"%s\":",
11329 get_afi_safi_str(afi
,
11334 "\n%s Summary (%s):\n",
11335 get_afi_safi_str(afi
,
11341 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11342 as_type
, as
, show_flags
);
11345 if (!safi_wildcard
)
11353 if (use_json
&& is_wildcard
)
11354 vty_out(vty
, "}\n");
11355 else if (!nbr_output
) {
11357 vty_out(vty
, "{}\n");
11359 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11364 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11366 const char *neighbor
,
11367 int as_type
, as_t as
,
11368 uint16_t show_flags
)
11370 struct listnode
*node
, *nnode
;
11372 struct peer
*fpeer
= NULL
;
11374 bool nbr_output
= false;
11375 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11378 vty_out(vty
, "{\n");
11380 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11384 vty_out(vty
, ",\n");
11388 vty_out(vty
, "\"%s\":",
11389 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11394 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11399 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11404 vty_out(vty
, "}\n");
11405 else if (!nbr_output
)
11406 vty_out(vty
, "%% BGP instance not found\n");
11409 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11410 safi_t safi
, const char *neighbor
, int as_type
,
11411 as_t as
, uint16_t show_flags
)
11414 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11415 struct peer
*fpeer
= NULL
;
11418 if (strmatch(name
, "all")) {
11419 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11422 return CMD_SUCCESS
;
11424 bgp
= bgp_lookup_by_name(name
);
11428 vty_out(vty
, "{}\n");
11431 "%% BGP instance not found\n");
11432 return CMD_WARNING
;
11436 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11439 return CMD_WARNING
;
11441 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11442 as_type
, as
, show_flags
);
11443 return CMD_SUCCESS
;
11447 bgp
= bgp_get_default();
11451 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11454 return CMD_WARNING
;
11456 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11460 vty_out(vty
, "{}\n");
11462 vty_out(vty
, "%% BGP instance not found\n");
11463 return CMD_WARNING
;
11466 return CMD_SUCCESS
;
11469 /* `show [ip] bgp summary' commands. */
11470 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11471 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11472 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11473 "]] [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]",
11474 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11475 BGP_SAFI_WITH_LABEL_HELP_STR
11476 "Display the entries for all address families\n"
11477 "Summary of BGP neighbor status\n"
11478 "Show only sessions in Established state\n"
11479 "Show only sessions not in Established state\n"
11480 "Show only the specified neighbor session\n"
11481 "Neighbor to display information about\n"
11482 "Neighbor to display information about\n"
11483 "Neighbor on BGP configured interface\n"
11484 "Show only the specified remote AS sessions\n"
11486 "Internal (iBGP) AS sessions\n"
11487 "External (eBGP) AS sessions\n"
11488 "Shorten the information on BGP instances\n"
11489 "Increase table width for longer output\n" JSON_STR
)
11492 afi_t afi
= AFI_MAX
;
11493 safi_t safi
= SAFI_MAX
;
11494 as_t as
= 0; /* 0 means AS filter not set */
11495 int as_type
= AS_UNSPECIFIED
;
11496 uint16_t show_flags
= 0;
11500 /* show [ip] bgp */
11501 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11503 /* [<vrf> VIEWVRFNAME] */
11504 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11505 vrf
= argv
[idx
+ 1]->arg
;
11506 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11508 } else if (argv_find(argv
, argc
, "view", &idx
))
11509 /* [<view> VIEWVRFNAME] */
11510 vrf
= argv
[idx
+ 1]->arg
;
11511 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11512 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11513 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11516 if (argv_find(argv
, argc
, "failed", &idx
))
11517 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11519 if (argv_find(argv
, argc
, "established", &idx
))
11520 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11522 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11523 if (argv
[idx
+ 1]->arg
[0] == 'i')
11524 as_type
= AS_INTERNAL
;
11525 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11526 as_type
= AS_EXTERNAL
;
11528 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11531 if (argv_find(argv
, argc
, "terse", &idx
))
11532 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11534 if (argv_find(argv
, argc
, "wide", &idx
))
11535 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11537 if (argv_find(argv
, argc
, "json", &idx
))
11538 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11540 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11544 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11547 return get_afi_safi_json_str(afi
, safi
);
11549 return get_afi_safi_vty_str(afi
, safi
);
11553 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11554 afi_t afi
, safi_t safi
,
11555 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11556 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11557 bool use_json
, json_object
*json_pref
)
11560 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11561 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11563 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11564 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11565 json_object_string_add(json_pref
, "sendMode",
11566 "advertisedAndReceived");
11567 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11568 json_object_string_add(json_pref
, "sendMode",
11570 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11571 json_object_string_add(json_pref
, "sendMode",
11574 vty_out(vty
, " Send-mode: ");
11575 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11576 vty_out(vty
, "advertised");
11577 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11578 vty_out(vty
, "%sreceived",
11579 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11583 vty_out(vty
, "\n");
11588 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11589 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11591 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11592 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11593 json_object_string_add(json_pref
, "recvMode",
11594 "advertisedAndReceived");
11595 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11596 json_object_string_add(json_pref
, "recvMode",
11598 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11599 json_object_string_add(json_pref
, "recvMode",
11602 vty_out(vty
, " Receive-mode: ");
11603 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11604 vty_out(vty
, "advertised");
11605 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11606 vty_out(vty
, "%sreceived",
11607 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11611 vty_out(vty
, "\n");
11616 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11624 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11625 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11626 && (peer_established(p
))) {
11627 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11628 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11632 json_object_boolean_add(json
, "rBit", rbit
);
11633 json_object_boolean_add(json
, "nBit", nbit
);
11635 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11636 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11640 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11645 const char *mode
= "NotApplicable";
11648 vty_out(vty
, "\n Remote GR Mode: ");
11650 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11651 && (peer_established(peer
))) {
11653 if ((peer
->nsf_af_count
== 0)
11654 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11658 } else if (peer
->nsf_af_count
== 0
11659 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11663 } else if (peer
->nsf_af_count
!= 0
11664 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11671 json_object_string_add(json
, "remoteGrMode", mode
);
11673 vty_out(vty
, mode
, "\n");
11676 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11681 const char *mode
= "Invalid";
11684 vty_out(vty
, " Local GR Mode: ");
11686 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11688 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11690 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11692 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11693 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11695 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11697 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11704 json_object_string_add(json
, "localGrMode", mode
);
11706 vty_out(vty
, mode
, "\n");
11710 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11711 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11715 json_object
*json_afi_safi
= NULL
;
11716 json_object
*json_timer
= NULL
;
11717 json_object
*json_endofrib_status
= NULL
;
11718 bool eor_flag
= false;
11720 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11721 if (!peer
->afc
[afi
][safi
])
11724 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11725 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11729 json_afi_safi
= json_object_new_object();
11730 json_endofrib_status
= json_object_new_object();
11731 json_timer
= json_object_new_object();
11734 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11740 vty_out(vty
, " %s:\n",
11741 get_afi_safi_str(afi
, safi
, false));
11743 vty_out(vty
, " F bit: ");
11746 if (peer
->nsf
[afi
][safi
] &&
11747 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11748 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11751 json_object_boolean_true_add(json_afi_safi
,
11754 vty_out(vty
, "True\n");
11757 json_object_boolean_false_add(json_afi_safi
,
11760 vty_out(vty
, "False\n");
11764 vty_out(vty
, " End-of-RIB sent: ");
11766 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11767 PEER_STATUS_EOR_SEND
)) {
11769 json_object_boolean_true_add(
11770 json_endofrib_status
, "endOfRibSend");
11772 PRINT_EOR_JSON(eor_flag
);
11774 vty_out(vty
, "Yes\n");
11776 " End-of-RIB sent after update: ");
11778 PRINT_EOR(eor_flag
);
11782 json_object_boolean_false_add(
11783 json_endofrib_status
, "endOfRibSend");
11784 json_object_boolean_false_add(
11785 json_endofrib_status
,
11786 "endOfRibSentAfterUpdate");
11788 vty_out(vty
, "No\n");
11790 " End-of-RIB sent after update: ");
11791 vty_out(vty
, "No\n");
11796 vty_out(vty
, " End-of-RIB received: ");
11798 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11799 PEER_STATUS_EOR_RECEIVED
)) {
11801 json_object_boolean_true_add(
11802 json_endofrib_status
, "endOfRibRecv");
11804 vty_out(vty
, "Yes\n");
11807 json_object_boolean_false_add(
11808 json_endofrib_status
, "endOfRibRecv");
11810 vty_out(vty
, "No\n");
11814 json_object_int_add(json_timer
, "stalePathTimer",
11815 peer
->bgp
->stalepath_time
);
11817 if (peer
->t_gr_stale
!= NULL
) {
11818 json_object_int_add(json_timer
,
11819 "stalePathTimerRemaining",
11820 thread_timer_remain_second(
11821 peer
->t_gr_stale
));
11824 /* Display Configured Selection
11825 * Deferral only when when
11826 * Gr mode is enabled.
11828 if (CHECK_FLAG(peer
->flags
,
11829 PEER_FLAG_GRACEFUL_RESTART
)) {
11830 json_object_int_add(json_timer
,
11831 "selectionDeferralTimer",
11832 peer
->bgp
->stalepath_time
);
11835 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11838 json_object_int_add(
11840 "selectionDeferralTimerRemaining",
11841 thread_timer_remain_second(
11842 peer
->bgp
->gr_info
[afi
][safi
]
11843 .t_select_deferral
));
11846 vty_out(vty
, " Timers:\n");
11848 " Configured Stale Path Time(sec): %u\n",
11849 peer
->bgp
->stalepath_time
);
11851 if (peer
->t_gr_stale
!= NULL
)
11853 " Stale Path Remaining(sec): %ld\n",
11854 thread_timer_remain_second(
11855 peer
->t_gr_stale
));
11856 /* Display Configured Selection
11857 * Deferral only when when
11858 * Gr mode is enabled.
11860 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11862 " Configured Selection Deferral Time(sec): %u\n",
11863 peer
->bgp
->select_defer_time
);
11865 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11868 " Selection Deferral Time Remaining(sec): %ld\n",
11869 thread_timer_remain_second(
11870 peer
->bgp
->gr_info
[afi
][safi
]
11871 .t_select_deferral
));
11874 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11875 json_endofrib_status
);
11876 json_object_object_add(json_afi_safi
, "timers",
11878 json_object_object_add(
11879 json
, get_afi_safi_str(afi
, safi
, true),
11885 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11891 json_object
*json_timer
= NULL
;
11893 json_timer
= json_object_new_object();
11895 json_object_int_add(json_timer
, "configuredRestartTimer",
11896 p
->bgp
->restart_time
);
11898 json_object_int_add(json_timer
, "receivedRestartTimer",
11901 if (p
->t_gr_restart
!= NULL
)
11902 json_object_int_add(
11903 json_timer
, "restartTimerRemaining",
11904 thread_timer_remain_second(p
->t_gr_restart
));
11906 json_object_object_add(json
, "timers", json_timer
);
11909 vty_out(vty
, " Timers:\n");
11910 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11911 p
->bgp
->restart_time
);
11913 vty_out(vty
, " Received Restart Time(sec): %u\n",
11915 if (p
->t_gr_restart
!= NULL
)
11916 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11917 thread_timer_remain_second(p
->t_gr_restart
));
11918 if (p
->t_gr_restart
!= NULL
) {
11919 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11920 thread_timer_remain_second(p
->t_gr_restart
));
11925 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11926 bool use_json
, json_object
*json
)
11928 char dn_flag
[2] = {0};
11929 /* '*' + v6 address of neighbor */
11930 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11932 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11937 json_object_string_addf(json
, "neighborAddr", "%pSU",
11940 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11943 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11947 json_object_string_add(json
, "neighborAddr",
11950 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11953 /* more gr info in new format */
11954 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11957 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11958 safi_t safi
, bool use_json
,
11959 json_object
*json_neigh
)
11961 struct bgp_filter
*filter
;
11962 struct peer_af
*paf
;
11963 char orf_pfx_name
[BUFSIZ
];
11965 json_object
*json_af
= NULL
;
11966 json_object
*json_prefA
= NULL
;
11967 json_object
*json_prefB
= NULL
;
11968 json_object
*json_addr
= NULL
;
11969 json_object
*json_advmap
= NULL
;
11972 json_addr
= json_object_new_object();
11973 json_af
= json_object_new_object();
11974 filter
= &p
->filter
[afi
][safi
];
11976 if (peer_group_active(p
))
11977 json_object_string_add(json_addr
, "peerGroupMember",
11980 paf
= peer_af_find(p
, afi
, safi
);
11981 if (paf
&& PAF_SUBGRP(paf
)) {
11982 json_object_int_add(json_addr
, "updateGroupId",
11983 PAF_UPDGRP(paf
)->id
);
11984 json_object_int_add(json_addr
, "subGroupId",
11985 PAF_SUBGRP(paf
)->id
);
11986 json_object_int_add(json_addr
, "packetQueueLength",
11987 bpacket_queue_virtual_length(paf
));
11990 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11991 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11992 PEER_CAP_ORF_PREFIX_SM_RCV
)
11993 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11994 PEER_CAP_ORF_PREFIX_RM_ADV
)
11995 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11996 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11997 json_object_int_add(json_af
, "orfType",
11999 json_prefA
= json_object_new_object();
12000 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12001 PEER_CAP_ORF_PREFIX_SM_ADV
,
12002 PEER_CAP_ORF_PREFIX_RM_ADV
,
12003 PEER_CAP_ORF_PREFIX_SM_RCV
,
12004 PEER_CAP_ORF_PREFIX_RM_RCV
,
12005 use_json
, json_prefA
);
12006 json_object_object_add(json_af
, "orfPrefixList",
12010 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12011 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12012 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12013 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12014 PEER_CAP_ORF_PREFIX_RM_ADV
)
12015 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12016 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12017 json_object_int_add(json_af
, "orfOldType",
12018 ORF_TYPE_PREFIX_OLD
);
12019 json_prefB
= json_object_new_object();
12020 bgp_show_peer_afi_orf_cap(
12021 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12022 PEER_CAP_ORF_PREFIX_RM_ADV
,
12023 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12024 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12026 json_object_object_add(json_af
, "orfOldPrefixList",
12030 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12031 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12032 PEER_CAP_ORF_PREFIX_SM_RCV
)
12033 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12034 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12035 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12036 PEER_CAP_ORF_PREFIX_RM_ADV
)
12037 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12038 PEER_CAP_ORF_PREFIX_RM_RCV
)
12039 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12040 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12041 json_object_object_add(json_addr
, "afDependentCap",
12044 json_object_free(json_af
);
12046 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12047 p
->host
, afi
, safi
);
12048 orf_pfx_count
= prefix_bgp_show_prefix_list(
12049 NULL
, afi
, orf_pfx_name
, use_json
);
12051 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12052 PEER_STATUS_ORF_PREFIX_SEND
)
12053 || orf_pfx_count
) {
12054 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12055 PEER_STATUS_ORF_PREFIX_SEND
))
12056 json_object_boolean_true_add(json_neigh
,
12059 json_object_int_add(json_addr
, "orfRecvCounter",
12062 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12063 PEER_STATUS_ORF_WAIT_REFRESH
))
12064 json_object_string_add(
12065 json_addr
, "orfFirstUpdate",
12066 "deferredUntilORFOrRouteRefreshRecvd");
12068 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12069 PEER_FLAG_REFLECTOR_CLIENT
))
12070 json_object_boolean_true_add(json_addr
,
12071 "routeReflectorClient");
12072 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12073 PEER_FLAG_RSERVER_CLIENT
))
12074 json_object_boolean_true_add(json_addr
,
12075 "routeServerClient");
12076 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12077 json_object_boolean_true_add(json_addr
,
12078 "inboundSoftConfigPermit");
12080 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12081 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12082 json_object_boolean_true_add(
12084 "privateAsNumsAllReplacedInUpdatesToNbr");
12085 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12086 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12087 json_object_boolean_true_add(
12089 "privateAsNumsReplacedInUpdatesToNbr");
12090 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12091 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12092 json_object_boolean_true_add(
12094 "privateAsNumsAllRemovedInUpdatesToNbr");
12095 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12096 PEER_FLAG_REMOVE_PRIVATE_AS
))
12097 json_object_boolean_true_add(
12099 "privateAsNumsRemovedInUpdatesToNbr");
12101 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12102 json_object_boolean_true_add(
12104 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12107 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12108 json_object_string_add(json_addr
,
12109 "overrideASNsInOutboundUpdates",
12110 "ifAspathEqualRemoteAs");
12112 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12113 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12114 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12115 json_object_boolean_true_add(json_addr
,
12116 "routerAlwaysNextHop");
12117 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12118 PEER_FLAG_AS_PATH_UNCHANGED
))
12119 json_object_boolean_true_add(
12120 json_addr
, "unchangedAsPathPropogatedToNbr");
12121 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12122 PEER_FLAG_NEXTHOP_UNCHANGED
))
12123 json_object_boolean_true_add(
12124 json_addr
, "unchangedNextHopPropogatedToNbr");
12125 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12126 json_object_boolean_true_add(
12127 json_addr
, "unchangedMedPropogatedToNbr");
12128 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12129 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12130 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12131 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12132 PEER_FLAG_SEND_COMMUNITY
)
12133 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12134 PEER_FLAG_SEND_EXT_COMMUNITY
))
12135 json_object_string_add(json_addr
,
12136 "commAttriSentToNbr",
12137 "extendedAndStandard");
12138 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12139 PEER_FLAG_SEND_EXT_COMMUNITY
))
12140 json_object_string_add(json_addr
,
12141 "commAttriSentToNbr",
12144 json_object_string_add(json_addr
,
12145 "commAttriSentToNbr",
12148 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12149 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12150 if (p
->default_rmap
[afi
][safi
].name
)
12151 json_object_string_add(
12152 json_addr
, "defaultRouteMap",
12153 p
->default_rmap
[afi
][safi
].name
);
12155 if (paf
&& PAF_SUBGRP(paf
)
12156 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12157 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12158 json_object_boolean_true_add(json_addr
,
12161 json_object_boolean_true_add(json_addr
,
12165 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12166 if (is_evpn_enabled())
12167 json_object_boolean_true_add(
12168 json_addr
, "advertiseAllVnis");
12171 if (filter
->plist
[FILTER_IN
].name
12172 || filter
->dlist
[FILTER_IN
].name
12173 || filter
->aslist
[FILTER_IN
].name
12174 || filter
->map
[RMAP_IN
].name
)
12175 json_object_boolean_true_add(json_addr
,
12176 "inboundPathPolicyConfig");
12177 if (filter
->plist
[FILTER_OUT
].name
12178 || filter
->dlist
[FILTER_OUT
].name
12179 || filter
->aslist
[FILTER_OUT
].name
12180 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12181 json_object_boolean_true_add(
12182 json_addr
, "outboundPathPolicyConfig");
12185 if (filter
->plist
[FILTER_IN
].name
)
12186 json_object_string_add(json_addr
,
12187 "incomingUpdatePrefixFilterList",
12188 filter
->plist
[FILTER_IN
].name
);
12189 if (filter
->plist
[FILTER_OUT
].name
)
12190 json_object_string_add(json_addr
,
12191 "outgoingUpdatePrefixFilterList",
12192 filter
->plist
[FILTER_OUT
].name
);
12194 /* distribute-list */
12195 if (filter
->dlist
[FILTER_IN
].name
)
12196 json_object_string_add(
12197 json_addr
, "incomingUpdateNetworkFilterList",
12198 filter
->dlist
[FILTER_IN
].name
);
12199 if (filter
->dlist
[FILTER_OUT
].name
)
12200 json_object_string_add(
12201 json_addr
, "outgoingUpdateNetworkFilterList",
12202 filter
->dlist
[FILTER_OUT
].name
);
12205 if (filter
->aslist
[FILTER_IN
].name
)
12206 json_object_string_add(json_addr
,
12207 "incomingUpdateAsPathFilterList",
12208 filter
->aslist
[FILTER_IN
].name
);
12209 if (filter
->aslist
[FILTER_OUT
].name
)
12210 json_object_string_add(json_addr
,
12211 "outgoingUpdateAsPathFilterList",
12212 filter
->aslist
[FILTER_OUT
].name
);
12215 if (filter
->map
[RMAP_IN
].name
)
12216 json_object_string_add(
12217 json_addr
, "routeMapForIncomingAdvertisements",
12218 filter
->map
[RMAP_IN
].name
);
12219 if (filter
->map
[RMAP_OUT
].name
)
12220 json_object_string_add(
12221 json_addr
, "routeMapForOutgoingAdvertisements",
12222 filter
->map
[RMAP_OUT
].name
);
12224 /* ebgp-requires-policy (inbound) */
12225 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12226 && !bgp_inbound_policy_exists(p
, filter
))
12227 json_object_string_add(
12228 json_addr
, "inboundEbgpRequiresPolicy",
12229 "Inbound updates discarded due to missing policy");
12231 /* ebgp-requires-policy (outbound) */
12232 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12233 && (!bgp_outbound_policy_exists(p
, filter
)))
12234 json_object_string_add(
12235 json_addr
, "outboundEbgpRequiresPolicy",
12236 "Outbound updates discarded due to missing policy");
12238 /* unsuppress-map */
12239 if (filter
->usmap
.name
)
12240 json_object_string_add(json_addr
,
12241 "selectiveUnsuppressRouteMap",
12242 filter
->usmap
.name
);
12244 /* advertise-map */
12245 if (filter
->advmap
.aname
) {
12246 json_advmap
= json_object_new_object();
12247 json_object_string_add(json_advmap
, "condition",
12248 filter
->advmap
.condition
12251 json_object_string_add(json_advmap
, "conditionMap",
12252 filter
->advmap
.cname
);
12253 json_object_string_add(json_advmap
, "advertiseMap",
12254 filter
->advmap
.aname
);
12255 json_object_string_add(
12256 json_advmap
, "advertiseStatus",
12257 filter
->advmap
.update_type
==
12258 UPDATE_TYPE_ADVERTISE
12261 json_object_object_add(json_addr
, "advertiseMap",
12265 /* Receive prefix count */
12266 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12267 p
->pcount
[afi
][safi
]);
12268 if (paf
&& PAF_SUBGRP(paf
))
12269 json_object_int_add(json_addr
, "sentPrefixCounter",
12270 (PAF_SUBGRP(paf
))->scount
);
12272 /* Maximum prefix */
12273 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12274 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12275 p
->pmax_out
[afi
][safi
]);
12277 /* Maximum prefix */
12278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12279 json_object_int_add(json_addr
, "prefixAllowedMax",
12280 p
->pmax
[afi
][safi
]);
12281 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12282 PEER_FLAG_MAX_PREFIX_WARNING
))
12283 json_object_boolean_true_add(
12284 json_addr
, "prefixAllowedMaxWarning");
12285 json_object_int_add(json_addr
,
12286 "prefixAllowedWarningThresh",
12287 p
->pmax_threshold
[afi
][safi
]);
12288 if (p
->pmax_restart
[afi
][safi
])
12289 json_object_int_add(
12291 "prefixAllowedRestartIntervalMsecs",
12292 p
->pmax_restart
[afi
][safi
] * 60000);
12294 json_object_object_add(json_neigh
,
12295 get_afi_safi_str(afi
, safi
, true),
12299 filter
= &p
->filter
[afi
][safi
];
12301 vty_out(vty
, " For address family: %s\n",
12302 get_afi_safi_str(afi
, safi
, false));
12304 if (peer_group_active(p
))
12305 vty_out(vty
, " %s peer-group member\n",
12308 paf
= peer_af_find(p
, afi
, safi
);
12309 if (paf
&& PAF_SUBGRP(paf
)) {
12310 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12311 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12312 vty_out(vty
, " Packet Queue length %d\n",
12313 bpacket_queue_virtual_length(paf
));
12315 vty_out(vty
, " Not part of any update group\n");
12317 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12318 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12319 PEER_CAP_ORF_PREFIX_SM_RCV
)
12320 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12321 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12322 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12323 PEER_CAP_ORF_PREFIX_RM_ADV
)
12324 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12325 PEER_CAP_ORF_PREFIX_RM_RCV
)
12326 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12327 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12328 vty_out(vty
, " AF-dependant capabilities:\n");
12330 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12331 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12332 PEER_CAP_ORF_PREFIX_SM_RCV
)
12333 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12334 PEER_CAP_ORF_PREFIX_RM_ADV
)
12335 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12336 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12338 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12340 bgp_show_peer_afi_orf_cap(
12341 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12342 PEER_CAP_ORF_PREFIX_RM_ADV
,
12343 PEER_CAP_ORF_PREFIX_SM_RCV
,
12344 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12346 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12347 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12348 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12349 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12350 PEER_CAP_ORF_PREFIX_RM_ADV
)
12351 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12352 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12354 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12355 ORF_TYPE_PREFIX_OLD
);
12356 bgp_show_peer_afi_orf_cap(
12357 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12358 PEER_CAP_ORF_PREFIX_RM_ADV
,
12359 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12360 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12363 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12364 p
->host
, afi
, safi
);
12365 orf_pfx_count
= prefix_bgp_show_prefix_list(
12366 NULL
, afi
, orf_pfx_name
, use_json
);
12368 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12369 PEER_STATUS_ORF_PREFIX_SEND
)
12370 || orf_pfx_count
) {
12371 vty_out(vty
, " Outbound Route Filter (ORF):");
12372 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12373 PEER_STATUS_ORF_PREFIX_SEND
))
12374 vty_out(vty
, " sent;");
12376 vty_out(vty
, " received (%d entries)",
12378 vty_out(vty
, "\n");
12380 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12381 PEER_STATUS_ORF_WAIT_REFRESH
))
12383 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12385 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12386 PEER_FLAG_REFLECTOR_CLIENT
))
12387 vty_out(vty
, " Route-Reflector Client\n");
12388 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12389 PEER_FLAG_RSERVER_CLIENT
))
12390 vty_out(vty
, " Route-Server Client\n");
12391 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12393 " Inbound soft reconfiguration allowed\n");
12395 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12396 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12398 " Private AS numbers (all) replaced in updates to this neighbor\n");
12399 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12400 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12402 " Private AS numbers replaced in updates to this neighbor\n");
12403 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12404 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12406 " Private AS numbers (all) removed in updates to this neighbor\n");
12407 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12408 PEER_FLAG_REMOVE_PRIVATE_AS
))
12410 " Private AS numbers removed in updates to this neighbor\n");
12412 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12413 vty_out(vty
, " %s\n",
12414 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12415 ->human_description
);
12417 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12419 " Override ASNs in outbound updates if aspath equals remote-as\n");
12421 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12422 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12424 vty_out(vty
, " NEXT_HOP is always this router\n");
12425 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12426 PEER_FLAG_AS_PATH_UNCHANGED
))
12428 " AS_PATH is propagated unchanged to this neighbor\n");
12429 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12430 PEER_FLAG_NEXTHOP_UNCHANGED
))
12432 " NEXT_HOP is propagated unchanged to this neighbor\n");
12433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12435 " MED is propagated unchanged to this neighbor\n");
12436 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12437 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12438 PEER_FLAG_SEND_EXT_COMMUNITY
)
12439 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12440 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12442 " Community attribute sent to this neighbor");
12443 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12444 PEER_FLAG_SEND_COMMUNITY
)
12445 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_SEND_EXT_COMMUNITY
)
12447 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12448 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12449 vty_out(vty
, "(all)\n");
12450 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12451 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12452 vty_out(vty
, "(large)\n");
12453 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12454 PEER_FLAG_SEND_EXT_COMMUNITY
))
12455 vty_out(vty
, "(extended)\n");
12457 vty_out(vty
, "(standard)\n");
12459 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12460 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12461 vty_out(vty
, " Default information originate,");
12463 if (p
->default_rmap
[afi
][safi
].name
)
12464 vty_out(vty
, " default route-map %s%s,",
12465 p
->default_rmap
[afi
][safi
].map
? "*"
12467 p
->default_rmap
[afi
][safi
].name
);
12468 if (paf
&& PAF_SUBGRP(paf
)
12469 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12470 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12471 vty_out(vty
, " default sent\n");
12473 vty_out(vty
, " default not sent\n");
12476 /* advertise-vni-all */
12477 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12478 if (is_evpn_enabled())
12479 vty_out(vty
, " advertise-all-vni\n");
12482 if (filter
->plist
[FILTER_IN
].name
12483 || filter
->dlist
[FILTER_IN
].name
12484 || filter
->aslist
[FILTER_IN
].name
12485 || filter
->map
[RMAP_IN
].name
)
12486 vty_out(vty
, " Inbound path policy configured\n");
12487 if (filter
->plist
[FILTER_OUT
].name
12488 || filter
->dlist
[FILTER_OUT
].name
12489 || filter
->aslist
[FILTER_OUT
].name
12490 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12491 vty_out(vty
, " Outbound path policy configured\n");
12494 if (filter
->plist
[FILTER_IN
].name
)
12496 " Incoming update prefix filter list is %s%s\n",
12497 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12498 filter
->plist
[FILTER_IN
].name
);
12499 if (filter
->plist
[FILTER_OUT
].name
)
12501 " Outgoing update prefix filter list is %s%s\n",
12502 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12503 filter
->plist
[FILTER_OUT
].name
);
12505 /* distribute-list */
12506 if (filter
->dlist
[FILTER_IN
].name
)
12508 " Incoming update network filter list is %s%s\n",
12509 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12510 filter
->dlist
[FILTER_IN
].name
);
12511 if (filter
->dlist
[FILTER_OUT
].name
)
12513 " Outgoing update network filter list is %s%s\n",
12514 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12515 filter
->dlist
[FILTER_OUT
].name
);
12518 if (filter
->aslist
[FILTER_IN
].name
)
12520 " Incoming update AS path filter list is %s%s\n",
12521 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12522 filter
->aslist
[FILTER_IN
].name
);
12523 if (filter
->aslist
[FILTER_OUT
].name
)
12525 " Outgoing update AS path filter list is %s%s\n",
12526 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12527 filter
->aslist
[FILTER_OUT
].name
);
12530 if (filter
->map
[RMAP_IN
].name
)
12532 " Route map for incoming advertisements is %s%s\n",
12533 filter
->map
[RMAP_IN
].map
? "*" : "",
12534 filter
->map
[RMAP_IN
].name
);
12535 if (filter
->map
[RMAP_OUT
].name
)
12537 " Route map for outgoing advertisements is %s%s\n",
12538 filter
->map
[RMAP_OUT
].map
? "*" : "",
12539 filter
->map
[RMAP_OUT
].name
);
12541 /* ebgp-requires-policy (inbound) */
12542 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12543 && !bgp_inbound_policy_exists(p
, filter
))
12545 " Inbound updates discarded due to missing policy\n");
12547 /* ebgp-requires-policy (outbound) */
12548 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12549 && !bgp_outbound_policy_exists(p
, filter
))
12551 " Outbound updates discarded due to missing policy\n");
12553 /* unsuppress-map */
12554 if (filter
->usmap
.name
)
12556 " Route map for selective unsuppress is %s%s\n",
12557 filter
->usmap
.map
? "*" : "",
12558 filter
->usmap
.name
);
12560 /* advertise-map */
12561 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12563 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12564 filter
->advmap
.condition
? "EXIST"
12566 filter
->advmap
.cmap
? "*" : "",
12567 filter
->advmap
.cname
,
12568 filter
->advmap
.amap
? "*" : "",
12569 filter
->advmap
.aname
,
12570 filter
->advmap
.update_type
==
12571 UPDATE_TYPE_ADVERTISE
12575 /* Receive prefix count */
12576 vty_out(vty
, " %u accepted prefixes\n",
12577 p
->pcount
[afi
][safi
]);
12579 /* maximum-prefix-out */
12580 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12581 PEER_FLAG_MAX_PREFIX_OUT
))
12583 " Maximum allowed prefixes sent %u\n",
12584 p
->pmax_out
[afi
][safi
]);
12586 /* Maximum prefix */
12587 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12589 " Maximum prefixes allowed %u%s\n",
12590 p
->pmax
[afi
][safi
],
12591 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12592 PEER_FLAG_MAX_PREFIX_WARNING
)
12593 ? " (warning-only)"
12595 vty_out(vty
, " Threshold for warning message %d%%",
12596 p
->pmax_threshold
[afi
][safi
]);
12597 if (p
->pmax_restart
[afi
][safi
])
12598 vty_out(vty
, ", restart interval %d min",
12599 p
->pmax_restart
[afi
][safi
]);
12600 vty_out(vty
, "\n");
12603 vty_out(vty
, "\n");
12607 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12611 char buf1
[PREFIX2STR_BUFFER
];
12612 char timebuf
[BGP_UPTIME_LEN
];
12618 json_object
*json_neigh
= NULL
;
12620 uint32_t sync_tcp_mss
;
12625 json_neigh
= json_object_new_object();
12627 memset(dn_flag
, '\0', sizeof(dn_flag
));
12628 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12632 if (p
->conf_if
) /* Configured interface name. */
12633 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12635 else /* Configured IP address. */
12636 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12641 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12642 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12644 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12645 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12648 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12650 if (p
->change_local_as
)
12651 json_object_int_add(json_neigh
, "localAs",
12652 p
->change_local_as
);
12654 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12656 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12657 json_object_boolean_true_add(json_neigh
,
12658 "localAsNoPrepend");
12660 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12661 json_object_boolean_true_add(json_neigh
,
12662 "localAsReplaceAs");
12664 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12665 || (p
->as_type
== AS_INTERNAL
))
12666 vty_out(vty
, "remote AS %u, ", p
->as
);
12668 vty_out(vty
, "remote AS Unspecified, ");
12669 vty_out(vty
, "local AS %u%s%s, ",
12670 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12671 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12674 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12678 /* peer type internal or confed-internal */
12679 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12681 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12682 json_object_boolean_true_add(
12683 json_neigh
, "nbrConfedInternalLink");
12685 json_object_boolean_true_add(json_neigh
,
12686 "nbrInternalLink");
12688 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12689 vty_out(vty
, "confed-internal link\n");
12691 vty_out(vty
, "internal link\n");
12693 /* peer type external or confed-external */
12694 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12696 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12697 json_object_boolean_true_add(
12698 json_neigh
, "nbrConfedExternalLink");
12700 json_object_boolean_true_add(json_neigh
,
12701 "nbrExternalLink");
12703 if (bgp_confederation_peers_check(bgp
, p
->as
))
12704 vty_out(vty
, "confed-external link\n");
12706 vty_out(vty
, "external link\n");
12710 json_object_boolean_true_add(json_neigh
,
12711 "nbrUnspecifiedLink");
12713 vty_out(vty
, "unspecified link\n");
12718 json_object_string_add(json_neigh
, "localRole",
12719 bgp_get_name_by_role(p
->local_role
));
12720 json_object_string_add(json_neigh
, "remoteRole",
12721 bgp_get_name_by_role(p
->remote_role
));
12723 vty_out(vty
, " Local Role: %s\n",
12724 bgp_get_name_by_role(p
->local_role
));
12725 vty_out(vty
, " Remote Role: %s\n",
12726 bgp_get_name_by_role(p
->remote_role
));
12733 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12735 vty_out(vty
, " Description: %s\n", p
->desc
);
12741 json_object_string_add(json_neigh
, "hostname",
12745 json_object_string_add(json_neigh
, "domainname",
12748 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12749 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12752 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12759 json_object_string_add(json_neigh
, "peerGroup",
12763 struct prefix prefix
, *range
= NULL
;
12765 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12766 range
= peer_group_lookup_dynamic_neighbor_range(
12767 p
->group
, &prefix
);
12770 json_object_string_addf(
12772 "peerSubnetRangeGroup", "%pFX",
12778 " Member of peer-group %s for session parameters\n",
12782 struct prefix prefix
, *range
= NULL
;
12784 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12785 range
= peer_group_lookup_dynamic_neighbor_range(
12786 p
->group
, &prefix
);
12790 " Belongs to the subnet range group: %pFX\n",
12798 /* Administrative shutdown. */
12799 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12800 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12801 json_object_boolean_true_add(json_neigh
,
12805 json_object_int_add(json_neigh
, "bgpVersion", 4);
12806 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12808 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12811 /* Confederation */
12812 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12813 && bgp_confederation_peers_check(bgp
, p
->as
))
12814 json_object_boolean_true_add(json_neigh
,
12818 json_object_string_add(
12819 json_neigh
, "bgpState",
12820 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12822 if (peer_established(p
)) {
12825 uptime
= monotime(NULL
);
12826 uptime
-= p
->uptime
;
12827 epoch_tbuf
= time(NULL
) - uptime
;
12829 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12831 json_object_string_add(json_neigh
, "bgpTimerUpString",
12832 peer_uptime(p
->uptime
, timebuf
,
12835 json_object_int_add(json_neigh
,
12836 "bgpTimerUpEstablishedEpoch",
12840 else if (p
->status
== Active
) {
12841 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12842 json_object_string_add(json_neigh
, "bgpStateIs",
12844 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12845 json_object_string_add(json_neigh
, "bgpStateIs",
12853 uptime
= monotime(NULL
);
12854 uptime
-= p
->readtime
;
12855 gmtime_r(&uptime
, &tm
);
12857 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12858 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12859 + (tm
.tm_hour
* 3600000));
12861 uptime
= monotime(NULL
);
12862 uptime
-= p
->last_write
;
12863 gmtime_r(&uptime
, &tm
);
12865 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12866 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12867 + (tm
.tm_hour
* 3600000));
12869 uptime
= monotime(NULL
);
12870 uptime
-= p
->update_time
;
12871 gmtime_r(&uptime
, &tm
);
12873 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12874 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12875 + (tm
.tm_hour
* 3600000));
12877 /* Configured timer values. */
12878 json_object_int_add(json_neigh
,
12879 "bgpTimerConfiguredHoldTimeMsecs",
12880 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12881 ? p
->holdtime
* 1000
12882 : bgp
->default_holdtime
* 1000);
12883 json_object_int_add(json_neigh
,
12884 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12885 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12886 ? p
->keepalive
* 1000
12887 : bgp
->default_keepalive
* 1000);
12888 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12889 p
->v_holdtime
* 1000);
12890 json_object_int_add(json_neigh
,
12891 "bgpTimerKeepAliveIntervalMsecs",
12892 p
->v_keepalive
* 1000);
12893 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12894 json_object_int_add(json_neigh
,
12895 "bgpTimerDelayOpenTimeMsecs",
12896 p
->v_delayopen
* 1000);
12899 /* Configured and Synced tcp-mss value for peer */
12900 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12901 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12902 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12904 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12908 /* Extended Optional Parameters Length for BGP OPEN Message */
12909 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12910 json_object_boolean_true_add(
12911 json_neigh
, "extendedOptionalParametersLength");
12913 json_object_boolean_false_add(
12914 json_neigh
, "extendedOptionalParametersLength");
12916 /* Conditional advertisements */
12917 json_object_int_add(
12919 "bgpTimerConfiguredConditionalAdvertisementsSec",
12920 bgp
->condition_check_period
);
12921 if (thread_is_scheduled(bgp
->t_condition_check
))
12922 json_object_int_add(
12924 "bgpTimerUntilConditionalAdvertisementsSec",
12925 thread_timer_remain_second(
12926 bgp
->t_condition_check
));
12928 /* Administrative shutdown. */
12929 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12930 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12931 vty_out(vty
, " Administratively shut down\n");
12934 vty_out(vty
, " BGP version 4");
12935 vty_out(vty
, ", remote router ID %s",
12936 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12937 vty_out(vty
, ", local router ID %s\n",
12938 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12941 /* Confederation */
12942 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12943 && bgp_confederation_peers_check(bgp
, p
->as
))
12945 " Neighbor under common administration\n");
12948 vty_out(vty
, " BGP state = %s",
12949 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12951 if (peer_established(p
))
12952 vty_out(vty
, ", up for %8s",
12953 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12956 else if (p
->status
== Active
) {
12957 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12958 vty_out(vty
, " (passive)");
12959 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12960 vty_out(vty
, " (NSF passive)");
12962 vty_out(vty
, "\n");
12965 vty_out(vty
, " Last read %s",
12966 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12968 vty_out(vty
, ", Last write %s\n",
12969 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12972 /* Configured timer values. */
12974 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12975 p
->v_holdtime
, p
->v_keepalive
);
12976 vty_out(vty
, " Configured hold time is %d seconds",
12977 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12979 : bgp
->default_holdtime
);
12980 vty_out(vty
, ", keepalive interval is %d seconds\n",
12981 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12983 : bgp
->default_keepalive
);
12984 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12986 " Configured DelayOpenTime is %d seconds\n",
12989 /* Configured and synced tcp-mss value for peer */
12990 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12991 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12992 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12993 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12996 /* Extended Optional Parameters Length for BGP OPEN Message */
12997 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12999 " Extended Optional Parameters Length is enabled\n");
13001 /* Conditional advertisements */
13003 " Configured conditional advertisements interval is %d seconds\n",
13004 bgp
->condition_check_period
);
13005 if (thread_is_scheduled(bgp
->t_condition_check
))
13007 " Time until conditional advertisements begin is %lu seconds\n",
13008 thread_timer_remain_second(
13009 bgp
->t_condition_check
));
13012 if (peer_established(p
) &&
13013 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13015 json_object
*json_cap
= NULL
;
13017 json_cap
= json_object_new_object();
13020 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13021 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13022 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13023 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13024 json_object_string_add(
13025 json_cap
, "4byteAs",
13026 "advertisedAndReceived");
13027 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13028 json_object_string_add(json_cap
,
13031 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13032 json_object_string_add(json_cap
,
13037 /* Extended Message Support */
13038 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13039 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13040 json_object_string_add(json_cap
,
13042 "advertisedAndReceived");
13043 else if (CHECK_FLAG(p
->cap
,
13044 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13045 json_object_string_add(json_cap
,
13048 else if (CHECK_FLAG(p
->cap
,
13049 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13050 json_object_string_add(json_cap
,
13055 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13056 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13057 json_object
*json_add
= NULL
;
13058 const char *print_store
;
13060 json_add
= json_object_new_object();
13062 FOREACH_AFI_SAFI (afi
, safi
) {
13063 json_object
*json_sub
= NULL
;
13064 json_sub
= json_object_new_object();
13065 print_store
= get_afi_safi_str(
13069 p
->af_cap
[afi
][safi
],
13070 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13072 p
->af_cap
[afi
][safi
],
13073 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13077 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13081 PEER_CAP_ADDPATH_AF_TX_RCV
))
13082 json_object_boolean_true_add(
13084 "txAdvertisedAndReceived");
13089 PEER_CAP_ADDPATH_AF_TX_ADV
))
13090 json_object_boolean_true_add(
13097 PEER_CAP_ADDPATH_AF_TX_RCV
))
13098 json_object_boolean_true_add(
13104 p
->af_cap
[afi
][safi
],
13105 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13107 p
->af_cap
[afi
][safi
],
13108 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13112 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13116 PEER_CAP_ADDPATH_AF_RX_RCV
))
13117 json_object_boolean_true_add(
13119 "rxAdvertisedAndReceived");
13124 PEER_CAP_ADDPATH_AF_RX_ADV
))
13125 json_object_boolean_true_add(
13132 PEER_CAP_ADDPATH_AF_RX_RCV
))
13133 json_object_boolean_true_add(
13139 p
->af_cap
[afi
][safi
],
13140 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13142 p
->af_cap
[afi
][safi
],
13143 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13145 p
->af_cap
[afi
][safi
],
13146 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13148 p
->af_cap
[afi
][safi
],
13149 PEER_CAP_ADDPATH_AF_RX_RCV
))
13150 json_object_object_add(
13151 json_add
, print_store
,
13154 json_object_free(json_sub
);
13157 json_object_object_add(json_cap
, "addPath",
13162 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13163 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13164 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13165 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13166 json_object_string_add(
13167 json_cap
, "dynamic",
13168 "advertisedAndReceived");
13169 else if (CHECK_FLAG(p
->cap
,
13170 PEER_CAP_DYNAMIC_ADV
))
13171 json_object_string_add(json_cap
,
13174 else if (CHECK_FLAG(p
->cap
,
13175 PEER_CAP_DYNAMIC_RCV
))
13176 json_object_string_add(json_cap
,
13182 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13183 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13184 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13185 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13186 json_object_string_add(
13188 "advertisedAndReceived");
13189 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13190 json_object_string_add(json_cap
, "role",
13192 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13193 json_object_string_add(json_cap
, "role",
13197 /* Extended nexthop */
13198 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13199 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13200 json_object
*json_nxt
= NULL
;
13201 const char *print_store
;
13204 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13205 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13206 json_object_string_add(
13207 json_cap
, "extendedNexthop",
13208 "advertisedAndReceived");
13209 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13210 json_object_string_add(
13211 json_cap
, "extendedNexthop",
13213 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13214 json_object_string_add(
13215 json_cap
, "extendedNexthop",
13218 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13219 json_nxt
= json_object_new_object();
13221 for (safi
= SAFI_UNICAST
;
13222 safi
< SAFI_MAX
; safi
++) {
13226 PEER_CAP_ENHE_AF_RCV
)) {
13232 json_object_string_add(
13235 "recieved"); /* misspelled for compatibility */
13238 json_object_object_add(
13240 "extendedNexthopFamililesByPeer",
13245 /* Long-lived Graceful Restart */
13246 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13247 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13248 json_object
*json_llgr
= NULL
;
13249 const char *afi_safi_str
;
13251 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13252 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13253 json_object_string_add(
13255 "longLivedGracefulRestart",
13256 "advertisedAndReceived");
13257 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13258 json_object_string_add(
13260 "longLivedGracefulRestart",
13262 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13263 json_object_string_add(
13265 "longLivedGracefulRestart",
13268 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13269 json_llgr
= json_object_new_object();
13271 FOREACH_AFI_SAFI (afi
, safi
) {
13275 PEER_CAP_ENHE_AF_RCV
)) {
13281 json_object_string_add(
13287 json_object_object_add(
13289 "longLivedGracefulRestartByPeer",
13294 /* Route Refresh */
13295 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13296 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13297 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13298 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13299 (CHECK_FLAG(p
->cap
,
13300 PEER_CAP_REFRESH_NEW_RCV
) ||
13302 PEER_CAP_REFRESH_OLD_RCV
))) {
13305 PEER_CAP_REFRESH_OLD_RCV
) &&
13308 PEER_CAP_REFRESH_NEW_RCV
))
13309 json_object_string_add(
13312 "advertisedAndReceivedOldNew");
13316 PEER_CAP_REFRESH_OLD_RCV
))
13317 json_object_string_add(
13320 "advertisedAndReceivedOld");
13322 json_object_string_add(
13325 "advertisedAndReceivedNew");
13327 } else if (CHECK_FLAG(p
->cap
,
13328 PEER_CAP_REFRESH_ADV
))
13329 json_object_string_add(json_cap
,
13332 else if (CHECK_FLAG(p
->cap
,
13333 PEER_CAP_REFRESH_NEW_RCV
) ||
13335 PEER_CAP_REFRESH_OLD_RCV
))
13336 json_object_string_add(json_cap
,
13341 /* Enhanced Route Refresh */
13342 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13343 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13344 if (CHECK_FLAG(p
->cap
,
13345 PEER_CAP_ENHANCED_RR_ADV
) &&
13347 PEER_CAP_ENHANCED_RR_RCV
))
13348 json_object_string_add(
13350 "enhancedRouteRefresh",
13351 "advertisedAndReceived");
13352 else if (CHECK_FLAG(p
->cap
,
13353 PEER_CAP_ENHANCED_RR_ADV
))
13354 json_object_string_add(
13356 "enhancedRouteRefresh",
13358 else if (CHECK_FLAG(p
->cap
,
13359 PEER_CAP_ENHANCED_RR_RCV
))
13360 json_object_string_add(
13362 "enhancedRouteRefresh",
13366 /* Multiprotocol Extensions */
13367 json_object
*json_multi
= NULL
;
13369 json_multi
= json_object_new_object();
13371 FOREACH_AFI_SAFI (afi
, safi
) {
13372 if (p
->afc_adv
[afi
][safi
] ||
13373 p
->afc_recv
[afi
][safi
]) {
13374 json_object
*json_exten
= NULL
;
13375 json_exten
= json_object_new_object();
13377 if (p
->afc_adv
[afi
][safi
] &&
13378 p
->afc_recv
[afi
][safi
])
13379 json_object_boolean_true_add(
13381 "advertisedAndReceived");
13382 else if (p
->afc_adv
[afi
][safi
])
13383 json_object_boolean_true_add(
13386 else if (p
->afc_recv
[afi
][safi
])
13387 json_object_boolean_true_add(
13388 json_exten
, "received");
13390 json_object_object_add(
13392 get_afi_safi_str(afi
, safi
,
13397 json_object_object_add(json_cap
,
13398 "multiprotocolExtensions",
13401 /* Hostname capabilities */
13402 json_object
*json_hname
= NULL
;
13404 json_hname
= json_object_new_object();
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13407 json_object_string_add(
13408 json_hname
, "advHostName",
13409 bgp
->peer_self
->hostname
13410 ? bgp
->peer_self
->hostname
13412 json_object_string_add(
13413 json_hname
, "advDomainName",
13414 bgp
->peer_self
->domainname
13415 ? bgp
->peer_self
->domainname
13420 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13421 json_object_string_add(
13422 json_hname
, "rcvHostName",
13423 p
->hostname
? p
->hostname
: "n/a");
13424 json_object_string_add(
13425 json_hname
, "rcvDomainName",
13426 p
->domainname
? p
->domainname
: "n/a");
13429 json_object_object_add(json_cap
, "hostName",
13432 /* Graceful Restart */
13433 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13434 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13435 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13436 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13437 json_object_string_add(
13438 json_cap
, "gracefulRestart",
13439 "advertisedAndReceived");
13440 else if (CHECK_FLAG(p
->cap
,
13441 PEER_CAP_RESTART_ADV
))
13442 json_object_string_add(
13444 "gracefulRestartCapability",
13446 else if (CHECK_FLAG(p
->cap
,
13447 PEER_CAP_RESTART_RCV
))
13448 json_object_string_add(
13450 "gracefulRestartCapability",
13453 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13454 int restart_af_count
= 0;
13455 json_object
*json_restart
= NULL
;
13456 json_restart
= json_object_new_object();
13458 json_object_int_add(
13460 "gracefulRestartRemoteTimerMsecs",
13461 p
->v_gr_restart
* 1000);
13463 FOREACH_AFI_SAFI (afi
, safi
) {
13467 PEER_CAP_RESTART_AF_RCV
)) {
13468 json_object
*json_sub
=
13471 json_object_new_object();
13477 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13478 json_object_boolean_true_add(
13481 restart_af_count
++;
13482 json_object_object_add(
13491 if (!restart_af_count
) {
13492 json_object_string_add(
13494 "addressFamiliesByPeer",
13496 json_object_free(json_restart
);
13498 json_object_object_add(
13500 "addressFamiliesByPeer",
13504 json_object_object_add(
13505 json_neigh
, "neighborCapabilities", json_cap
);
13507 vty_out(vty
, " Neighbor capabilities:\n");
13510 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13511 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13512 vty_out(vty
, " 4 Byte AS:");
13513 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13514 vty_out(vty
, " advertised");
13515 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13516 vty_out(vty
, " %sreceived",
13521 vty_out(vty
, "\n");
13524 /* Extended Message Support */
13525 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13526 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13527 vty_out(vty
, " Extended Message:");
13528 if (CHECK_FLAG(p
->cap
,
13529 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13530 vty_out(vty
, " advertised");
13531 if (CHECK_FLAG(p
->cap
,
13532 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13533 vty_out(vty
, " %sreceived",
13536 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13539 vty_out(vty
, "\n");
13543 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13544 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13545 vty_out(vty
, " AddPath:\n");
13547 FOREACH_AFI_SAFI (afi
, safi
) {
13549 p
->af_cap
[afi
][safi
],
13550 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13552 p
->af_cap
[afi
][safi
],
13553 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13554 vty_out(vty
, " %s: TX ",
13562 PEER_CAP_ADDPATH_AF_TX_ADV
))
13569 PEER_CAP_ADDPATH_AF_TX_RCV
))
13576 PEER_CAP_ADDPATH_AF_TX_ADV
)
13580 vty_out(vty
, "\n");
13584 p
->af_cap
[afi
][safi
],
13585 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13587 p
->af_cap
[afi
][safi
],
13588 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13589 vty_out(vty
, " %s: RX ",
13597 PEER_CAP_ADDPATH_AF_RX_ADV
))
13604 PEER_CAP_ADDPATH_AF_RX_RCV
))
13611 PEER_CAP_ADDPATH_AF_RX_ADV
)
13615 vty_out(vty
, "\n");
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13622 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13623 vty_out(vty
, " Dynamic:");
13624 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13625 vty_out(vty
, " advertised");
13626 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13627 vty_out(vty
, " %sreceived",
13629 PEER_CAP_DYNAMIC_ADV
)
13632 vty_out(vty
, "\n");
13636 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13637 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13638 vty_out(vty
, " Role:");
13639 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13640 vty_out(vty
, " advertised");
13641 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13642 vty_out(vty
, " %sreceived",
13647 vty_out(vty
, "\n");
13650 /* Extended nexthop */
13651 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13652 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13653 vty_out(vty
, " Extended nexthop:");
13654 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13655 vty_out(vty
, " advertised");
13656 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13657 vty_out(vty
, " %sreceived",
13662 vty_out(vty
, "\n");
13664 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13666 " Address families by peer:\n ");
13667 for (safi
= SAFI_UNICAST
;
13668 safi
< SAFI_MAX
; safi
++)
13672 PEER_CAP_ENHE_AF_RCV
))
13682 /* Long-lived Graceful Restart */
13683 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13684 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13686 " Long-lived Graceful Restart:");
13687 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13688 vty_out(vty
, " advertised");
13689 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13690 vty_out(vty
, " %sreceived",
13695 vty_out(vty
, "\n");
13697 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13699 " Address families by peer:\n");
13700 FOREACH_AFI_SAFI (afi
, safi
)
13704 PEER_CAP_LLGR_AF_RCV
))
13714 /* Route Refresh */
13715 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13716 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13717 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13718 vty_out(vty
, " Route refresh:");
13719 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13720 vty_out(vty
, " advertised");
13721 if (CHECK_FLAG(p
->cap
,
13722 PEER_CAP_REFRESH_NEW_RCV
) ||
13724 PEER_CAP_REFRESH_OLD_RCV
))
13725 vty_out(vty
, " %sreceived(%s)",
13727 PEER_CAP_REFRESH_ADV
)
13732 PEER_CAP_REFRESH_OLD_RCV
) &&
13735 PEER_CAP_REFRESH_NEW_RCV
))
13739 PEER_CAP_REFRESH_OLD_RCV
)
13743 vty_out(vty
, "\n");
13746 /* Enhanced Route Refresh */
13747 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13748 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13749 vty_out(vty
, " Enhanced Route Refresh:");
13750 if (CHECK_FLAG(p
->cap
,
13751 PEER_CAP_ENHANCED_RR_ADV
))
13752 vty_out(vty
, " advertised");
13753 if (CHECK_FLAG(p
->cap
,
13754 PEER_CAP_ENHANCED_RR_RCV
))
13755 vty_out(vty
, " %sreceived",
13757 PEER_CAP_REFRESH_ADV
)
13760 vty_out(vty
, "\n");
13763 /* Multiprotocol Extensions */
13764 FOREACH_AFI_SAFI (afi
, safi
)
13765 if (p
->afc_adv
[afi
][safi
] ||
13766 p
->afc_recv
[afi
][safi
]) {
13767 vty_out(vty
, " Address Family %s:",
13768 get_afi_safi_str(afi
, safi
,
13770 if (p
->afc_adv
[afi
][safi
])
13771 vty_out(vty
, " advertised");
13772 if (p
->afc_recv
[afi
][safi
])
13773 vty_out(vty
, " %sreceived",
13774 p
->afc_adv
[afi
][safi
]
13777 vty_out(vty
, "\n");
13780 /* Hostname capability */
13781 vty_out(vty
, " Hostname Capability:");
13783 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13785 " advertised (name: %s,domain name: %s)",
13786 bgp
->peer_self
->hostname
13787 ? bgp
->peer_self
->hostname
13789 bgp
->peer_self
->domainname
13790 ? bgp
->peer_self
->domainname
13793 vty_out(vty
, " not advertised");
13796 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13798 " received (name: %s,domain name: %s)",
13799 p
->hostname
? p
->hostname
: "n/a",
13800 p
->domainname
? p
->domainname
: "n/a");
13802 vty_out(vty
, " not received");
13805 vty_out(vty
, "\n");
13807 /* Graceful Restart */
13808 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13809 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13811 " Graceful Restart Capability:");
13812 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13813 vty_out(vty
, " advertised");
13814 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13815 vty_out(vty
, " %sreceived",
13817 PEER_CAP_RESTART_ADV
)
13820 vty_out(vty
, "\n");
13822 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13823 int restart_af_count
= 0;
13826 " Remote Restart timer is %d seconds\n",
13829 " Address families by peer:\n ");
13831 FOREACH_AFI_SAFI (afi
, safi
)
13835 PEER_CAP_RESTART_AF_RCV
)) {
13836 vty_out(vty
, "%s%s(%s)",
13848 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13850 : "not preserved");
13851 restart_af_count
++;
13853 if (!restart_af_count
)
13854 vty_out(vty
, "none");
13855 vty_out(vty
, "\n");
13857 } /* Graceful Restart */
13861 /* graceful restart information */
13862 json_object
*json_grace
= NULL
;
13863 json_object
*json_grace_send
= NULL
;
13864 json_object
*json_grace_recv
= NULL
;
13865 int eor_send_af_count
= 0;
13866 int eor_receive_af_count
= 0;
13869 json_grace
= json_object_new_object();
13870 json_grace_send
= json_object_new_object();
13871 json_grace_recv
= json_object_new_object();
13873 if ((peer_established(p
)) &&
13874 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13875 FOREACH_AFI_SAFI (afi
, safi
) {
13876 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13877 PEER_STATUS_EOR_SEND
)) {
13878 json_object_boolean_true_add(
13880 get_afi_safi_str(afi
, safi
,
13882 eor_send_af_count
++;
13885 FOREACH_AFI_SAFI (afi
, safi
) {
13886 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13887 PEER_STATUS_EOR_RECEIVED
)) {
13888 json_object_boolean_true_add(
13890 get_afi_safi_str(afi
, safi
,
13892 eor_receive_af_count
++;
13896 json_object_object_add(json_grace
, "endOfRibSend",
13898 json_object_object_add(json_grace
, "endOfRibRecv",
13902 if (p
->t_gr_restart
)
13903 json_object_int_add(
13904 json_grace
, "gracefulRestartTimerMsecs",
13905 thread_timer_remain_second(p
->t_gr_restart
) *
13909 json_object_int_add(
13910 json_grace
, "gracefulStalepathTimerMsecs",
13911 thread_timer_remain_second(p
->t_gr_stale
) *
13913 /* more gr info in new format */
13914 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13915 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13918 vty_out(vty
, " Graceful restart information:\n");
13919 if ((peer_established(p
)) &&
13920 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13922 vty_out(vty
, " End-of-RIB send: ");
13923 FOREACH_AFI_SAFI (afi
, safi
) {
13924 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13925 PEER_STATUS_EOR_SEND
)) {
13926 vty_out(vty
, "%s%s",
13927 eor_send_af_count
? ", " : "",
13928 get_afi_safi_str(afi
, safi
,
13930 eor_send_af_count
++;
13933 vty_out(vty
, "\n");
13934 vty_out(vty
, " End-of-RIB received: ");
13935 FOREACH_AFI_SAFI (afi
, safi
) {
13936 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13937 PEER_STATUS_EOR_RECEIVED
)) {
13938 vty_out(vty
, "%s%s",
13939 eor_receive_af_count
? ", "
13941 get_afi_safi_str(afi
, safi
,
13943 eor_receive_af_count
++;
13946 vty_out(vty
, "\n");
13949 if (p
->t_gr_restart
)
13951 " The remaining time of restart timer is %ld\n",
13952 thread_timer_remain_second(p
->t_gr_restart
));
13956 " The remaining time of stalepath timer is %ld\n",
13957 thread_timer_remain_second(p
->t_gr_stale
));
13959 /* more gr info in new format */
13960 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13964 json_object
*json_stat
= NULL
;
13965 json_stat
= json_object_new_object();
13966 /* Packet counts. */
13968 atomic_size_t outq_count
, inq_count
;
13969 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13970 memory_order_relaxed
);
13971 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13972 memory_order_relaxed
);
13974 json_object_int_add(json_stat
, "depthInq",
13975 (unsigned long)inq_count
);
13976 json_object_int_add(json_stat
, "depthOutq",
13977 (unsigned long)outq_count
);
13978 json_object_int_add(json_stat
, "opensSent",
13979 atomic_load_explicit(&p
->open_out
,
13980 memory_order_relaxed
));
13981 json_object_int_add(json_stat
, "opensRecv",
13982 atomic_load_explicit(&p
->open_in
,
13983 memory_order_relaxed
));
13984 json_object_int_add(json_stat
, "notificationsSent",
13985 atomic_load_explicit(&p
->notify_out
,
13986 memory_order_relaxed
));
13987 json_object_int_add(json_stat
, "notificationsRecv",
13988 atomic_load_explicit(&p
->notify_in
,
13989 memory_order_relaxed
));
13990 json_object_int_add(json_stat
, "updatesSent",
13991 atomic_load_explicit(&p
->update_out
,
13992 memory_order_relaxed
));
13993 json_object_int_add(json_stat
, "updatesRecv",
13994 atomic_load_explicit(&p
->update_in
,
13995 memory_order_relaxed
));
13996 json_object_int_add(json_stat
, "keepalivesSent",
13997 atomic_load_explicit(&p
->keepalive_out
,
13998 memory_order_relaxed
));
13999 json_object_int_add(json_stat
, "keepalivesRecv",
14000 atomic_load_explicit(&p
->keepalive_in
,
14001 memory_order_relaxed
));
14002 json_object_int_add(json_stat
, "routeRefreshSent",
14003 atomic_load_explicit(&p
->refresh_out
,
14004 memory_order_relaxed
));
14005 json_object_int_add(json_stat
, "routeRefreshRecv",
14006 atomic_load_explicit(&p
->refresh_in
,
14007 memory_order_relaxed
));
14008 json_object_int_add(json_stat
, "capabilitySent",
14009 atomic_load_explicit(&p
->dynamic_cap_out
,
14010 memory_order_relaxed
));
14011 json_object_int_add(json_stat
, "capabilityRecv",
14012 atomic_load_explicit(&p
->dynamic_cap_in
,
14013 memory_order_relaxed
));
14014 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14015 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14016 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14018 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14019 notify_out
, notify_in
, update_out
, update_in
,
14020 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14021 dynamic_cap_out
, dynamic_cap_in
;
14022 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14023 memory_order_relaxed
);
14024 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14025 memory_order_relaxed
);
14026 open_out
= atomic_load_explicit(&p
->open_out
,
14027 memory_order_relaxed
);
14029 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14030 notify_out
= atomic_load_explicit(&p
->notify_out
,
14031 memory_order_relaxed
);
14032 notify_in
= atomic_load_explicit(&p
->notify_in
,
14033 memory_order_relaxed
);
14034 update_out
= atomic_load_explicit(&p
->update_out
,
14035 memory_order_relaxed
);
14036 update_in
= atomic_load_explicit(&p
->update_in
,
14037 memory_order_relaxed
);
14038 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14039 memory_order_relaxed
);
14040 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14041 memory_order_relaxed
);
14042 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14043 memory_order_relaxed
);
14044 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14045 memory_order_relaxed
);
14046 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14047 memory_order_relaxed
);
14048 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14049 memory_order_relaxed
);
14051 /* Packet counts. */
14052 vty_out(vty
, " Message statistics:\n");
14053 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14054 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14055 vty_out(vty
, " Sent Rcvd\n");
14056 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14058 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14060 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14062 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14064 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14066 vty_out(vty
, " Capability: %10zu %10zu\n",
14067 dynamic_cap_out
, dynamic_cap_in
);
14068 vty_out(vty
, " Total: %10u %10u\n",
14069 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14073 /* advertisement-interval */
14074 json_object_int_add(json_neigh
,
14075 "minBtwnAdvertisementRunsTimerMsecs",
14076 p
->v_routeadv
* 1000);
14078 /* Update-source. */
14079 if (p
->update_if
|| p
->update_source
) {
14081 json_object_string_add(json_neigh
,
14084 else if (p
->update_source
)
14085 json_object_string_addf(json_neigh
,
14086 "updateSource", "%pSU",
14090 /* advertisement-interval */
14092 " Minimum time between advertisement runs is %d seconds\n",
14095 /* Update-source. */
14096 if (p
->update_if
|| p
->update_source
) {
14097 vty_out(vty
, " Update source is ");
14099 vty_out(vty
, "%s", p
->update_if
);
14100 else if (p
->update_source
)
14101 vty_out(vty
, "%pSU", p
->update_source
);
14102 vty_out(vty
, "\n");
14105 vty_out(vty
, "\n");
14108 /* Address Family Information */
14109 json_object
*json_hold
= NULL
;
14112 json_hold
= json_object_new_object();
14114 FOREACH_AFI_SAFI (afi
, safi
)
14115 if (p
->afc
[afi
][safi
])
14116 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14120 json_object_object_add(json_neigh
, "addressFamilyInfo",
14122 json_object_int_add(json_neigh
, "connectionsEstablished",
14124 json_object_int_add(json_neigh
, "connectionsDropped",
14127 vty_out(vty
, " Connections established %d; dropped %d\n",
14128 p
->established
, p
->dropped
);
14130 if (!p
->last_reset
) {
14132 json_object_string_add(json_neigh
, "lastReset",
14135 vty_out(vty
, " Last reset never\n");
14141 uptime
= monotime(NULL
);
14142 uptime
-= p
->resettime
;
14143 gmtime_r(&uptime
, &tm
);
14145 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14147 + (tm
.tm_min
* 60000)
14148 + (tm
.tm_hour
* 3600000));
14149 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14151 vty_out(vty
, " Last reset %s, ",
14152 peer_uptime(p
->resettime
, timebuf
,
14153 BGP_UPTIME_LEN
, 0, NULL
));
14155 bgp_show_peer_reset(vty
, p
, NULL
, false);
14156 if (p
->last_reset_cause_size
) {
14157 msg
= p
->last_reset_cause
;
14159 " Message received that caused BGP to send a NOTIFICATION:\n ");
14160 for (i
= 1; i
<= p
->last_reset_cause_size
;
14162 vty_out(vty
, "%02X", *msg
++);
14164 if (i
!= p
->last_reset_cause_size
) {
14166 vty_out(vty
, "\n ");
14167 } else if (i
% 4 == 0) {
14172 vty_out(vty
, "\n");
14177 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14179 json_object_boolean_true_add(json_neigh
,
14180 "prefixesConfigExceedMax");
14183 " Peer had exceeded the max. no. of prefixes configured.\n");
14185 if (p
->t_pmax_restart
) {
14187 json_object_boolean_true_add(
14188 json_neigh
, "reducePrefixNumFrom");
14189 json_object_int_add(json_neigh
,
14190 "restartInTimerMsec",
14191 thread_timer_remain_second(
14196 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14197 p
->host
, thread_timer_remain_second(
14198 p
->t_pmax_restart
));
14201 json_object_boolean_true_add(
14203 "reducePrefixNumAndClearIpBgp");
14206 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14211 /* EBGP Multihop and GTSM */
14212 if (p
->sort
!= BGP_PEER_IBGP
) {
14214 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14215 json_object_int_add(json_neigh
,
14216 "externalBgpNbrMaxHopsAway",
14219 json_object_int_add(json_neigh
,
14220 "externalBgpNbrMaxHopsAway",
14223 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14225 " External BGP neighbor may be up to %d hops away.\n",
14229 " External BGP neighbor may be up to %d hops away.\n",
14234 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14235 json_object_int_add(json_neigh
,
14236 "internalBgpNbrMaxHopsAway",
14239 json_object_int_add(json_neigh
,
14240 "internalBgpNbrMaxHopsAway",
14243 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14245 " Internal BGP neighbor may be up to %d hops away.\n",
14249 " Internal BGP neighbor may be up to %d hops away.\n",
14254 /* Local address. */
14257 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14259 json_object_int_add(json_neigh
, "portLocal",
14260 ntohs(p
->su_local
->sin
.sin_port
));
14262 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14263 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14266 json_object_string_add(json_neigh
, "hostLocal",
14268 json_object_int_add(json_neigh
, "portLocal", -1);
14272 /* Remote address. */
14273 if (p
->su_remote
) {
14275 json_object_string_addf(json_neigh
, "hostForeign",
14276 "%pSU", p
->su_remote
);
14277 json_object_int_add(json_neigh
, "portForeign",
14278 ntohs(p
->su_remote
->sin
.sin_port
));
14280 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14282 ntohs(p
->su_remote
->sin
.sin_port
));
14285 json_object_string_add(json_neigh
, "hostForeign",
14287 json_object_int_add(json_neigh
, "portForeign", -1);
14291 /* Nexthop display. */
14294 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14296 json_object_string_addf(json_neigh
, "nexthopGlobal",
14297 "%pI6", &p
->nexthop
.v6_global
);
14298 json_object_string_addf(json_neigh
, "nexthopLocal",
14299 "%pI6", &p
->nexthop
.v6_local
);
14300 if (p
->shared_network
)
14301 json_object_string_add(json_neigh
,
14305 json_object_string_add(json_neigh
,
14307 "nonSharedNetwork");
14309 vty_out(vty
, "Nexthop: %s\n",
14310 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14312 vty_out(vty
, "Nexthop global: %s\n",
14313 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14315 vty_out(vty
, "Nexthop local: %s\n",
14316 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14318 vty_out(vty
, "BGP connection: %s\n",
14319 p
->shared_network
? "shared network"
14320 : "non shared network");
14324 /* Timer information. */
14326 json_object_int_add(json_neigh
, "connectRetryTimer",
14328 if (peer_established(p
) && p
->rtt
)
14329 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14332 json_object_int_add(
14333 json_neigh
, "nextStartTimerDueInMsecs",
14334 thread_timer_remain_second(p
->t_start
) * 1000);
14336 json_object_int_add(
14337 json_neigh
, "nextConnectTimerDueInMsecs",
14338 thread_timer_remain_second(p
->t_connect
)
14340 if (p
->t_routeadv
) {
14341 json_object_int_add(json_neigh
, "mraiInterval",
14343 json_object_int_add(
14344 json_neigh
, "mraiTimerExpireInMsecs",
14345 thread_timer_remain_second(p
->t_routeadv
)
14349 json_object_int_add(json_neigh
, "authenticationEnabled",
14353 json_object_string_add(json_neigh
, "readThread", "on");
14355 json_object_string_add(json_neigh
, "readThread", "off");
14357 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14358 json_object_string_add(json_neigh
, "writeThread", "on");
14360 json_object_string_add(json_neigh
, "writeThread",
14363 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14365 if (peer_established(p
) && p
->rtt
)
14366 vty_out(vty
, "Estimated round trip time: %d ms\n",
14369 vty_out(vty
, "Next start timer due in %ld seconds\n",
14370 thread_timer_remain_second(p
->t_start
));
14372 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14373 thread_timer_remain_second(p
->t_connect
));
14376 "MRAI (interval %u) timer expires in %ld seconds\n",
14378 thread_timer_remain_second(p
->t_routeadv
));
14380 vty_out(vty
, "Peer Authentication Enabled\n");
14382 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14383 p
->t_read
? "on" : "off",
14384 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14389 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14390 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14391 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14394 vty_out(vty
, "\n");
14396 /* BFD information. */
14398 bgp_bfd_show_info(vty
, p
, json_neigh
);
14401 if (p
->conf_if
) /* Configured interface name. */
14402 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14403 else /* Configured IP address. */
14404 json_object_object_add(json
, p
->host
, json_neigh
);
14408 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14409 enum show_type type
,
14410 union sockunion
*su
,
14411 const char *conf_if
, afi_t afi
,
14414 struct listnode
*node
, *nnode
;
14417 safi_t safi
= SAFI_UNICAST
;
14418 json_object
*json
= NULL
;
14419 json_object
*json_neighbor
= NULL
;
14422 json
= json_object_new_object();
14423 json_neighbor
= json_object_new_object();
14426 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14428 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14431 if ((peer
->afc
[afi
][safi
]) == 0)
14434 if (type
== show_all
) {
14435 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14439 json_object_object_add(json
, peer
->host
,
14441 json_neighbor
= NULL
;
14444 } else if (type
== show_peer
) {
14447 && !strcmp(peer
->conf_if
, conf_if
))
14449 && !strcmp(peer
->hostname
, conf_if
))) {
14451 bgp_show_peer_gr_status(vty
, peer
,
14456 if (sockunion_same(&peer
->su
, su
)) {
14458 bgp_show_peer_gr_status(vty
, peer
,
14463 if (use_json
&& find
)
14464 json_object_object_add(json
, peer
->host
,
14469 json_neighbor
= NULL
;
14474 if (type
== show_peer
&& !find
) {
14476 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14478 vty_out(vty
, "%% No such neighbor\n");
14482 json_object_free(json_neighbor
);
14483 vty_json(vty
, json
);
14485 vty_out(vty
, "\n");
14488 return CMD_SUCCESS
;
14491 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14492 enum show_type type
, union sockunion
*su
,
14493 const char *conf_if
, bool use_json
,
14496 struct listnode
*node
, *nnode
;
14499 bool nbr_output
= false;
14500 afi_t afi
= AFI_MAX
;
14501 safi_t safi
= SAFI_MAX
;
14503 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14505 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14509 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14510 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14515 bgp_show_peer(vty
, peer
, use_json
, json
);
14521 && !strcmp(peer
->conf_if
, conf_if
))
14523 && !strcmp(peer
->hostname
, conf_if
))) {
14525 bgp_show_peer(vty
, peer
, use_json
,
14529 if (sockunion_same(&peer
->su
, su
)) {
14531 bgp_show_peer(vty
, peer
, use_json
,
14536 case show_ipv4_peer
:
14537 case show_ipv6_peer
:
14538 FOREACH_SAFI (safi
) {
14539 if (peer
->afc
[afi
][safi
]) {
14542 && !strcmp(peer
->conf_if
, conf_if
))
14544 && !strcmp(peer
->hostname
, conf_if
))) {
14546 bgp_show_peer(vty
, peer
, use_json
,
14551 if (sockunion_same(&peer
->su
, su
)) {
14553 bgp_show_peer(vty
, peer
, use_json
,
14561 case show_ipv4_all
:
14562 case show_ipv6_all
:
14563 FOREACH_SAFI (safi
) {
14564 if (peer
->afc
[afi
][safi
]) {
14565 bgp_show_peer(vty
, peer
, use_json
, json
);
14574 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14575 type
== show_ipv6_peer
) && !find
) {
14577 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14579 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14582 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14583 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14584 vty_out(vty
, "%% No BGP neighbors found\n");
14587 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14588 json
, JSON_C_TO_STRING_PRETTY
));
14590 vty_out(vty
, "\n");
14593 return CMD_SUCCESS
;
14596 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14597 enum show_type type
,
14598 const char *ip_str
,
14599 afi_t afi
, bool use_json
)
14604 union sockunion su
;
14606 bgp
= bgp_get_default();
14612 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14616 ret
= str2sockunion(ip_str
, &su
);
14618 bgp_show_neighbor_graceful_restart(
14619 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14621 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14622 NULL
, afi
, use_json
);
14624 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14628 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14629 enum show_type type
,
14630 const char *ip_str
,
14633 struct listnode
*node
, *nnode
;
14635 union sockunion su
;
14636 json_object
*json
= NULL
;
14637 int ret
, is_first
= 1;
14638 bool nbr_output
= false;
14641 vty_out(vty
, "{\n");
14643 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14646 if (!(json
= json_object_new_object())) {
14648 EC_BGP_JSON_MEM_ERROR
,
14649 "Unable to allocate memory for JSON object");
14651 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14655 json_object_int_add(json
, "vrfId",
14656 (bgp
->vrf_id
== VRF_UNKNOWN
)
14658 : (int64_t)bgp
->vrf_id
);
14659 json_object_string_add(
14661 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14666 vty_out(vty
, ",\n");
14670 vty_out(vty
, "\"%s\":",
14671 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14675 vty_out(vty
, "\nInstance %s:\n",
14676 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14681 if (type
== show_peer
|| type
== show_ipv4_peer
||
14682 type
== show_ipv6_peer
) {
14683 ret
= str2sockunion(ip_str
, &su
);
14685 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14688 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14691 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14694 json_object_free(json
);
14699 vty_out(vty
, "}\n");
14700 else if (!nbr_output
)
14701 vty_out(vty
, "%% BGP instance not found\n");
14704 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14705 enum show_type type
, const char *ip_str
,
14710 union sockunion su
;
14711 json_object
*json
= NULL
;
14714 if (strmatch(name
, "all")) {
14715 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14717 return CMD_SUCCESS
;
14719 bgp
= bgp_lookup_by_name(name
);
14722 json
= json_object_new_object();
14723 vty_json(vty
, json
);
14726 "%% BGP instance not found\n");
14728 return CMD_WARNING
;
14732 bgp
= bgp_get_default();
14736 json
= json_object_new_object();
14738 ret
= str2sockunion(ip_str
, &su
);
14740 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14743 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14746 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14749 json_object_free(json
);
14752 vty_out(vty
, "{}\n");
14754 vty_out(vty
, "%% BGP instance not found\n");
14757 return CMD_SUCCESS
;
14762 /* "show [ip] bgp neighbors graceful-restart" commands. */
14763 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14764 show_ip_bgp_neighbors_graceful_restart_cmd
,
14765 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14771 "Neighbor to display information about\n"
14772 "Neighbor to display information about\n"
14773 "Neighbor on BGP configured interface\n"
14777 char *sh_arg
= NULL
;
14778 enum show_type sh_type
;
14780 afi_t afi
= AFI_MAX
;
14781 bool uj
= use_json(argc
, argv
);
14783 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14788 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14789 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14790 || argv_find(argv
, argc
, "WORD", &idx
)) {
14791 sh_type
= show_peer
;
14792 sh_arg
= argv
[idx
]->arg
;
14794 sh_type
= show_all
;
14796 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14797 return CMD_SUCCESS
;
14800 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14804 /* "show [ip] bgp neighbors" commands. */
14805 DEFUN (show_ip_bgp_neighbors
,
14806 show_ip_bgp_neighbors_cmd
,
14807 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14811 BGP_INSTANCE_HELP_STR
14814 "Detailed information on TCP and BGP neighbor connections\n"
14815 "Neighbor to display information about\n"
14816 "Neighbor to display information about\n"
14817 "Neighbor on BGP configured interface\n"
14821 char *sh_arg
= NULL
;
14822 enum show_type sh_type
;
14823 afi_t afi
= AFI_MAX
;
14825 bool uj
= use_json(argc
, argv
);
14829 /* [<vrf> VIEWVRFNAME] */
14830 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14831 vrf
= argv
[idx
+ 1]->arg
;
14832 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14834 } else if (argv_find(argv
, argc
, "view", &idx
))
14835 /* [<view> VIEWVRFNAME] */
14836 vrf
= argv
[idx
+ 1]->arg
;
14840 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14841 sh_type
= show_ipv4_all
;
14843 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14844 sh_type
= show_ipv6_all
;
14847 sh_type
= show_all
;
14850 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14851 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14852 || argv_find(argv
, argc
, "WORD", &idx
)) {
14853 sh_type
= show_peer
;
14854 sh_arg
= argv
[idx
]->arg
;
14857 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14858 sh_type
= show_ipv4_peer
;
14859 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14860 sh_type
= show_ipv6_peer
;
14863 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14866 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14867 paths' and `show ip mbgp paths'. Those functions results are the
14869 DEFUN (show_ip_bgp_paths
,
14870 show_ip_bgp_paths_cmd
,
14871 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14876 "Path information\n")
14878 vty_out(vty
, "Address Refcnt Path\n");
14879 aspath_print_all_vty(vty
);
14880 return CMD_SUCCESS
;
14885 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14888 struct community
*com
;
14890 com
= (struct community
*)bucket
->data
;
14891 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14892 community_str(com
, false, false));
14895 /* Show BGP's community internal data. */
14896 DEFUN (show_ip_bgp_community_info
,
14897 show_ip_bgp_community_info_cmd
,
14898 "show [ip] bgp community-info",
14902 "List all bgp community information\n")
14904 vty_out(vty
, "Address Refcnt Community\n");
14906 hash_iterate(community_hash(),
14907 (void (*)(struct hash_bucket
*,
14908 void *))community_show_all_iterator
,
14911 return CMD_SUCCESS
;
14914 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14917 struct lcommunity
*lcom
;
14919 lcom
= (struct lcommunity
*)bucket
->data
;
14920 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14921 lcommunity_str(lcom
, false, false));
14924 /* Show BGP's community internal data. */
14925 DEFUN (show_ip_bgp_lcommunity_info
,
14926 show_ip_bgp_lcommunity_info_cmd
,
14927 "show ip bgp large-community-info",
14931 "List all bgp large-community information\n")
14933 vty_out(vty
, "Address Refcnt Large-community\n");
14935 hash_iterate(lcommunity_hash(),
14936 (void (*)(struct hash_bucket
*,
14937 void *))lcommunity_show_all_iterator
,
14940 return CMD_SUCCESS
;
14942 /* Graceful Restart */
14944 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14951 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14953 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14955 switch (bgp_global_gr_mode
) {
14957 case GLOBAL_HELPER
:
14958 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14962 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14965 case GLOBAL_DISABLE
:
14966 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14969 case GLOBAL_INVALID
:
14971 "Global BGP GR Mode Invalid\n");
14974 vty_out(vty
, "\n");
14977 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14978 enum show_type type
,
14979 const char *ip_str
,
14980 afi_t afi
, bool use_json
)
14982 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14985 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14987 bgp_show_neighbor_graceful_restart_vty(
14988 vty
, type
, ip_str
, afi
, use_json
);
14991 } else if (afi
!= AFI_MAX
) {
14992 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14995 return CMD_ERR_INCOMPLETE
;
14998 return CMD_SUCCESS
;
15000 /* Graceful Restart */
15002 DEFUN (show_ip_bgp_attr_info
,
15003 show_ip_bgp_attr_info_cmd
,
15004 "show [ip] bgp attribute-info",
15008 "List all bgp attribute information\n")
15010 attr_show_all(vty
);
15011 return CMD_SUCCESS
;
15014 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15015 afi_t afi
, safi_t safi
,
15016 bool use_json
, json_object
*json
)
15019 struct listnode
*node
;
15022 enum vpn_policy_direction dir
;
15025 json_object
*json_import_vrfs
= NULL
;
15026 json_object
*json_export_vrfs
= NULL
;
15028 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15031 vty_json(vty
, json
);
15033 return CMD_WARNING
;
15036 /* Provide context for the block */
15037 json_object_string_add(json
, "vrf", name
? name
: "default");
15038 json_object_string_add(json
, "afiSafi",
15039 get_afi_safi_str(afi
, safi
, true));
15041 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15042 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15043 json_object_string_add(json
, "importFromVrfs", "none");
15044 json_object_string_add(json
, "importRts", "none");
15046 json_import_vrfs
= json_object_new_array();
15048 for (ALL_LIST_ELEMENTS_RO(
15049 bgp
->vpn_policy
[afi
].import_vrf
,
15051 json_object_array_add(json_import_vrfs
,
15052 json_object_new_string(vname
));
15054 json_object_object_add(json
, "importFromVrfs",
15056 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15057 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15058 ecom_str
= ecommunity_ecom2str(
15059 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15060 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15061 json_object_string_add(json
, "importRts",
15063 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15065 json_object_string_add(json
, "importRts",
15069 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15070 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15071 json_object_string_add(json
, "exportToVrfs", "none");
15072 json_object_string_add(json
, "routeDistinguisher",
15074 json_object_string_add(json
, "exportRts", "none");
15076 json_export_vrfs
= json_object_new_array();
15078 for (ALL_LIST_ELEMENTS_RO(
15079 bgp
->vpn_policy
[afi
].export_vrf
,
15081 json_object_array_add(json_export_vrfs
,
15082 json_object_new_string(vname
));
15083 json_object_object_add(json
, "exportToVrfs",
15085 json_object_string_addf(json
, "routeDistinguisher",
15087 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15089 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15090 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15091 ecom_str
= ecommunity_ecom2str(
15092 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15093 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15094 json_object_string_add(json
, "exportRts",
15096 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15098 json_object_string_add(json
, "exportRts",
15103 vty_json(vty
, json
);
15106 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15109 vty_out(vty
, "%% No such BGP instance exist\n");
15110 return CMD_WARNING
;
15113 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15114 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15116 "This VRF is not importing %s routes from any other VRF\n",
15117 get_afi_safi_str(afi
, safi
, false));
15120 "This VRF is importing %s routes from the following VRFs:\n",
15121 get_afi_safi_str(afi
, safi
, false));
15123 for (ALL_LIST_ELEMENTS_RO(
15124 bgp
->vpn_policy
[afi
].import_vrf
,
15126 vty_out(vty
, " %s\n", vname
);
15128 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15130 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15131 ecom_str
= ecommunity_ecom2str(
15132 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15133 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15134 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15136 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15138 vty_out(vty
, "Import RT(s):\n");
15141 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15142 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15144 "This VRF is not exporting %s routes to any other VRF\n",
15145 get_afi_safi_str(afi
, safi
, false));
15148 "This VRF is exporting %s routes to the following VRFs:\n",
15149 get_afi_safi_str(afi
, safi
, false));
15151 for (ALL_LIST_ELEMENTS_RO(
15152 bgp
->vpn_policy
[afi
].export_vrf
,
15154 vty_out(vty
, " %s\n", vname
);
15156 vty_out(vty
, "RD: %pRD\n",
15157 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15159 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15160 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15161 ecom_str
= ecommunity_ecom2str(
15162 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15163 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15164 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15165 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15167 vty_out(vty
, "Import RT(s):\n");
15171 return CMD_SUCCESS
;
15174 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15175 safi_t safi
, bool use_json
)
15177 struct listnode
*node
, *nnode
;
15179 char *vrf_name
= NULL
;
15180 json_object
*json
= NULL
;
15181 json_object
*json_vrf
= NULL
;
15182 json_object
*json_vrfs
= NULL
;
15185 json
= json_object_new_object();
15186 json_vrfs
= json_object_new_object();
15189 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15191 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15192 vrf_name
= bgp
->name
;
15195 json_vrf
= json_object_new_object();
15197 vty_out(vty
, "\nInstance %s:\n",
15198 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15199 ? VRF_DEFAULT_NAME
: bgp
->name
);
15201 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15203 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15204 json_object_object_add(json_vrfs
,
15205 VRF_DEFAULT_NAME
, json_vrf
);
15207 json_object_object_add(json_vrfs
, vrf_name
,
15213 json_object_object_add(json
, "vrfs", json_vrfs
);
15214 vty_json(vty
, json
);
15217 return CMD_SUCCESS
;
15220 /* "show [ip] bgp route-leak" command. */
15221 DEFUN (show_ip_bgp_route_leak
,
15222 show_ip_bgp_route_leak_cmd
,
15223 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15227 BGP_INSTANCE_HELP_STR
15230 "Route leaking information\n"
15234 afi_t afi
= AFI_MAX
;
15235 safi_t safi
= SAFI_MAX
;
15237 bool uj
= use_json(argc
, argv
);
15239 json_object
*json
= NULL
;
15241 /* show [ip] bgp */
15242 if (argv_find(argv
, argc
, "ip", &idx
)) {
15244 safi
= SAFI_UNICAST
;
15246 /* [vrf VIEWVRFNAME] */
15247 if (argv_find(argv
, argc
, "view", &idx
)) {
15249 "%% This command is not applicable to BGP views\n");
15250 return CMD_WARNING
;
15253 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15254 vrf
= argv
[idx
+ 1]->arg
;
15255 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15258 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15259 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15260 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15262 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15264 "%% This command is applicable only for unicast ipv4|ipv6\n");
15265 return CMD_WARNING
;
15268 if (vrf
&& strmatch(vrf
, "all"))
15269 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15272 json
= json_object_new_object();
15274 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15277 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15280 struct listnode
*node
, *nnode
;
15283 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15284 vty_out(vty
, "\nInstance %s:\n",
15285 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15288 update_group_show(bgp
, afi
, safi
, vty
, 0);
15292 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15293 int safi
, uint64_t subgrp_id
)
15298 if (strmatch(name
, "all")) {
15299 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15300 return CMD_SUCCESS
;
15302 bgp
= bgp_lookup_by_name(name
);
15305 bgp
= bgp_get_default();
15309 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15310 return CMD_SUCCESS
;
15313 DEFUN (show_ip_bgp_updgrps
,
15314 show_ip_bgp_updgrps_cmd
,
15315 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15319 BGP_INSTANCE_HELP_STR
15321 BGP_SAFI_WITH_LABEL_HELP_STR
15322 "Detailed info about dynamic update groups\n"
15323 "Specific subgroup to display detailed info for\n")
15326 afi_t afi
= AFI_IP6
;
15327 safi_t safi
= SAFI_UNICAST
;
15328 uint64_t subgrp_id
= 0;
15332 /* show [ip] bgp */
15333 if (argv_find(argv
, argc
, "ip", &idx
))
15335 /* [<vrf> VIEWVRFNAME] */
15336 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15337 vrf
= argv
[idx
+ 1]->arg
;
15338 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15340 } else if (argv_find(argv
, argc
, "view", &idx
))
15341 /* [<view> VIEWVRFNAME] */
15342 vrf
= argv
[idx
+ 1]->arg
;
15343 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15344 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15345 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15348 /* get subgroup id, if provided */
15350 if (argv
[idx
]->type
== VARIABLE_TKN
)
15351 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15353 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15356 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15357 show_bgp_instance_all_ipv6_updgrps_cmd
,
15358 "show [ip] bgp <view|vrf> all update-groups",
15362 BGP_INSTANCE_ALL_HELP_STR
15363 "Detailed info about dynamic update groups\n")
15365 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15366 return CMD_SUCCESS
;
15369 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15370 show_bgp_l2vpn_evpn_updgrps_cmd
,
15371 "show [ip] bgp l2vpn evpn update-groups",
15375 "l2vpn address family\n"
15376 "evpn sub-address family\n"
15377 "Detailed info about dynamic update groups\n")
15380 uint64_t subgrp_id
= 0;
15382 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15383 return CMD_SUCCESS
;
15386 DEFUN (show_bgp_updgrps_stats
,
15387 show_bgp_updgrps_stats_cmd
,
15388 "show [ip] bgp update-groups statistics",
15392 "Detailed info about dynamic update groups\n"
15397 bgp
= bgp_get_default();
15399 update_group_show_stats(bgp
, vty
);
15401 return CMD_SUCCESS
;
15404 DEFUN (show_bgp_instance_updgrps_stats
,
15405 show_bgp_instance_updgrps_stats_cmd
,
15406 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15410 BGP_INSTANCE_HELP_STR
15411 "Detailed info about dynamic update groups\n"
15417 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15419 update_group_show_stats(bgp
, vty
);
15421 return CMD_SUCCESS
;
15424 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15425 afi_t afi
, safi_t safi
,
15426 const char *what
, uint64_t subgrp_id
)
15431 bgp
= bgp_lookup_by_name(name
);
15433 bgp
= bgp_get_default();
15436 if (!strcmp(what
, "advertise-queue"))
15437 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15439 else if (!strcmp(what
, "advertised-routes"))
15440 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15442 else if (!strcmp(what
, "packet-queue"))
15443 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15448 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15449 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15450 "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",
15451 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15453 "Detailed info about dynamic update groups\n"
15454 "Specific subgroup to display info for\n"
15455 "Advertisement queue\n"
15456 "Announced routes\n"
15459 uint64_t subgrp_id
= 0;
15463 subgrp_id
= strtoull(sgid
, NULL
, 10);
15468 afiz
= bgp_vty_afi_from_str(afi
);
15472 afiz
= bgp_vty_afi_from_str(afi
);
15473 if (afiz
!= AFI_IP
)
15475 "%% Cannot specify both 'ip' and 'ipv6'\n");
15476 return CMD_WARNING
;
15479 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15481 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15482 return CMD_SUCCESS
;
15485 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15488 struct listnode
*node
, *nnode
;
15489 struct prefix
*range
;
15494 const char *peer_status
;
15498 json_object
*json_peer_group
= NULL
;
15499 json_object
*json_peer_group_afc
= NULL
;
15500 json_object
*json_peer_group_members
= NULL
;
15501 json_object
*json_peer_group_dynamic
= NULL
;
15502 json_object
*json_peer_group_dynamic_af
= NULL
;
15503 json_object
*json_peer_group_ranges
= NULL
;
15505 conf
= group
->conf
;
15508 json_peer_group
= json_object_new_object();
15509 json_peer_group_afc
= json_object_new_array();
15512 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15514 json_object_int_add(json_peer_group
, "remoteAs",
15517 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15518 group
->name
, conf
->as
);
15519 } else if (conf
->as_type
== AS_INTERNAL
) {
15521 json_object_int_add(json_peer_group
, "remoteAs",
15524 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15525 group
->name
, group
->bgp
->as
);
15528 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15531 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15533 json_object_string_add(json_peer_group
, "type",
15536 vty_out(vty
, " Peer-group type is internal\n");
15539 json_object_string_add(json_peer_group
, "type",
15542 vty_out(vty
, " Peer-group type is external\n");
15545 /* Display AFs configured. */
15547 vty_out(vty
, " Configured address-families:");
15549 FOREACH_AFI_SAFI (afi
, safi
) {
15550 if (conf
->afc
[afi
][safi
]) {
15553 json_object_array_add(
15554 json_peer_group_afc
,
15555 json_object_new_string(get_afi_safi_str(
15556 afi
, safi
, false)));
15558 vty_out(vty
, " %s;",
15559 get_afi_safi_str(afi
, safi
, false));
15564 json_object_object_add(json_peer_group
,
15565 "addressFamiliesConfigured",
15566 json_peer_group_afc
);
15569 vty_out(vty
, " none\n");
15571 vty_out(vty
, "\n");
15574 /* Display listen ranges (for dynamic neighbors), if any */
15575 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15576 lr_count
= listcount(group
->listen_range
[afi
]);
15579 if (!json_peer_group_dynamic
)
15580 json_peer_group_dynamic
=
15581 json_object_new_object();
15583 json_peer_group_dynamic_af
=
15584 json_object_new_object();
15585 json_peer_group_ranges
=
15586 json_object_new_array();
15587 json_object_int_add(json_peer_group_dynamic_af
,
15588 "count", lr_count
);
15590 vty_out(vty
, " %d %s listen range(s)\n",
15591 lr_count
, afi2str(afi
));
15594 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15599 snprintfrr(buf
, sizeof(buf
), "%pFX",
15602 json_object_array_add(
15603 json_peer_group_ranges
,
15604 json_object_new_string(buf
));
15606 vty_out(vty
, " %pFX\n", range
);
15611 json_object_object_add(
15612 json_peer_group_dynamic_af
, "ranges",
15613 json_peer_group_ranges
);
15615 json_object_object_add(
15616 json_peer_group_dynamic
, afi2str(afi
),
15617 json_peer_group_dynamic_af
);
15622 if (json_peer_group_dynamic
)
15623 json_object_object_add(json_peer_group
, "dynamicRanges",
15624 json_peer_group_dynamic
);
15626 /* Display group members and their status */
15627 if (listcount(group
->peer
)) {
15629 json_peer_group_members
= json_object_new_object();
15631 vty_out(vty
, " Peer-group members:\n");
15632 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15633 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15634 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15635 peer_status
= "Idle (Admin)";
15636 else if (CHECK_FLAG(peer
->sflags
,
15637 PEER_STATUS_PREFIX_OVERFLOW
))
15638 peer_status
= "Idle (PfxCt)";
15640 peer_status
= lookup_msg(bgp_status_msg
,
15641 peer
->status
, NULL
);
15643 dynamic
= peer_dynamic_neighbor(peer
);
15646 json_object
*json_peer_group_member
=
15647 json_object_new_object();
15649 json_object_string_add(json_peer_group_member
,
15650 "status", peer_status
);
15653 json_object_boolean_true_add(
15654 json_peer_group_member
,
15657 json_object_object_add(json_peer_group_members
,
15659 json_peer_group_member
);
15661 vty_out(vty
, " %s %s %s \n", peer
->host
,
15662 dynamic
? "(dynamic)" : "",
15667 json_object_object_add(json_peer_group
, "members",
15668 json_peer_group_members
);
15672 json_object_object_add(json
, group
->name
, json_peer_group
);
15674 return CMD_SUCCESS
;
15677 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15678 const char *group_name
, bool uj
)
15681 struct listnode
*node
, *nnode
;
15682 struct peer_group
*group
;
15683 bool found
= false;
15684 json_object
*json
= NULL
;
15687 json
= json_object_new_object();
15689 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15693 vty_json(vty
, json
);
15695 vty_out(vty
, "%% BGP instance not found\n");
15697 return CMD_WARNING
;
15700 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15702 if (strmatch(group
->name
, group_name
)) {
15703 bgp_show_one_peer_group(vty
, group
, json
);
15708 bgp_show_one_peer_group(vty
, group
, json
);
15712 if (group_name
&& !found
&& !uj
)
15713 vty_out(vty
, "%% No such peer-group\n");
15716 vty_json(vty
, json
);
15718 return CMD_SUCCESS
;
15721 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15722 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15723 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15724 "Detailed information on BGP peer groups\n"
15725 "Peer group name\n" JSON_STR
)
15729 bool uj
= use_json(argc
, argv
);
15731 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15733 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15735 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15739 /* Redistribute VTY commands. */
15741 DEFUN (bgp_redistribute_ipv4
,
15742 bgp_redistribute_ipv4_cmd
,
15743 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15744 "Redistribute information from another routing protocol\n"
15745 FRR_IP_REDIST_HELP_STR_BGPD
)
15747 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15748 int idx_protocol
= 1;
15751 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15753 vty_out(vty
, "%% Invalid route type\n");
15754 return CMD_WARNING_CONFIG_FAILED
;
15757 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15758 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15762 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15763 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15764 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15766 DEFUN (bgp_redistribute_ipv4_rmap
,
15767 bgp_redistribute_ipv4_rmap_cmd
,
15768 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15769 "Redistribute information from another routing protocol\n"
15770 FRR_IP_REDIST_HELP_STR_BGPD
15771 "Route map reference\n"
15772 "Pointer to route-map entries\n")
15774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15775 int idx_protocol
= 1;
15778 struct bgp_redist
*red
;
15780 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15781 vty
, argv
[idx_word
]->arg
);
15783 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15785 vty_out(vty
, "%% Invalid route type\n");
15786 return CMD_WARNING_CONFIG_FAILED
;
15789 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15791 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15792 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15796 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15797 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15798 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15799 "Route map reference\n"
15800 "Pointer to route-map entries\n")
15802 DEFUN (bgp_redistribute_ipv4_metric
,
15803 bgp_redistribute_ipv4_metric_cmd
,
15804 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15805 "Redistribute information from another routing protocol\n"
15806 FRR_IP_REDIST_HELP_STR_BGPD
15807 "Metric for redistributed routes\n"
15808 "Default metric\n")
15810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15811 int idx_protocol
= 1;
15812 int idx_number
= 3;
15815 struct bgp_redist
*red
;
15818 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15820 vty_out(vty
, "%% Invalid route type\n");
15821 return CMD_WARNING_CONFIG_FAILED
;
15823 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15825 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15826 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15827 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15831 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15832 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15833 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15834 "Metric for redistributed routes\n"
15835 "Default metric\n")
15837 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15838 bgp_redistribute_ipv4_rmap_metric_cmd
,
15839 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15840 "Redistribute information from another routing protocol\n"
15841 FRR_IP_REDIST_HELP_STR_BGPD
15842 "Route map reference\n"
15843 "Pointer to route-map entries\n"
15844 "Metric for redistributed routes\n"
15845 "Default metric\n")
15847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15848 int idx_protocol
= 1;
15850 int idx_number
= 5;
15853 struct bgp_redist
*red
;
15855 struct route_map
*route_map
=
15856 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15858 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15860 vty_out(vty
, "%% Invalid route type\n");
15861 return CMD_WARNING_CONFIG_FAILED
;
15863 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15865 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15867 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15868 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15869 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15873 bgp_redistribute_ipv4_rmap_metric
,
15874 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15875 "redistribute " FRR_IP_REDIST_STR_BGPD
15876 " route-map RMAP_NAME metric (0-4294967295)",
15877 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15878 "Route map reference\n"
15879 "Pointer to route-map entries\n"
15880 "Metric for redistributed routes\n"
15881 "Default metric\n")
15883 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15884 bgp_redistribute_ipv4_metric_rmap_cmd
,
15885 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15886 "Redistribute information from another routing protocol\n"
15887 FRR_IP_REDIST_HELP_STR_BGPD
15888 "Metric for redistributed routes\n"
15890 "Route map reference\n"
15891 "Pointer to route-map entries\n")
15893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15894 int idx_protocol
= 1;
15895 int idx_number
= 3;
15899 struct bgp_redist
*red
;
15901 struct route_map
*route_map
=
15902 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15904 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15906 vty_out(vty
, "%% Invalid route type\n");
15907 return CMD_WARNING_CONFIG_FAILED
;
15909 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15911 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15912 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15914 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15915 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15919 bgp_redistribute_ipv4_metric_rmap
,
15920 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15921 "redistribute " FRR_IP_REDIST_STR_BGPD
15922 " metric (0-4294967295) route-map RMAP_NAME",
15923 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15924 "Metric for redistributed routes\n"
15926 "Route map reference\n"
15927 "Pointer to route-map entries\n")
15929 DEFUN (bgp_redistribute_ipv4_ospf
,
15930 bgp_redistribute_ipv4_ospf_cmd
,
15931 "redistribute <ospf|table> (1-65535)",
15932 "Redistribute information from another routing protocol\n"
15933 "Open Shortest Path First (OSPFv2)\n"
15934 "Non-main Kernel Routing Table\n"
15935 "Instance ID/Table ID\n")
15937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15938 int idx_ospf_table
= 1;
15939 int idx_number
= 2;
15940 unsigned short instance
;
15941 unsigned short protocol
;
15943 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15945 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15946 protocol
= ZEBRA_ROUTE_OSPF
;
15948 protocol
= ZEBRA_ROUTE_TABLE
;
15950 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15951 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15954 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15955 "redistribute <ospf|table> (1-65535)",
15956 "Redistribute information from another routing protocol\n"
15957 "Open Shortest Path First (OSPFv2)\n"
15958 "Non-main Kernel Routing Table\n"
15959 "Instance ID/Table ID\n")
15961 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15962 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15963 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15964 "Redistribute information from another routing protocol\n"
15965 "Open Shortest Path First (OSPFv2)\n"
15966 "Non-main Kernel Routing Table\n"
15967 "Instance ID/Table ID\n"
15968 "Route map reference\n"
15969 "Pointer to route-map entries\n")
15971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15972 int idx_ospf_table
= 1;
15973 int idx_number
= 2;
15975 struct bgp_redist
*red
;
15976 unsigned short instance
;
15979 struct route_map
*route_map
=
15980 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15982 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15983 protocol
= ZEBRA_ROUTE_OSPF
;
15985 protocol
= ZEBRA_ROUTE_TABLE
;
15987 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15988 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15990 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15991 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15994 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15995 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15996 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15997 "Redistribute information from another routing protocol\n"
15998 "Open Shortest Path First (OSPFv2)\n"
15999 "Non-main Kernel Routing Table\n"
16000 "Instance ID/Table ID\n"
16001 "Route map reference\n"
16002 "Pointer to route-map entries\n")
16004 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16005 bgp_redistribute_ipv4_ospf_metric_cmd
,
16006 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16007 "Redistribute information from another routing protocol\n"
16008 "Open Shortest Path First (OSPFv2)\n"
16009 "Non-main Kernel Routing Table\n"
16010 "Instance ID/Table ID\n"
16011 "Metric for redistributed routes\n"
16012 "Default metric\n")
16014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16015 int idx_ospf_table
= 1;
16016 int idx_number
= 2;
16017 int idx_number_2
= 4;
16019 struct bgp_redist
*red
;
16020 unsigned short instance
;
16024 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16025 protocol
= ZEBRA_ROUTE_OSPF
;
16027 protocol
= ZEBRA_ROUTE_TABLE
;
16029 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16030 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16032 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16033 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16035 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16038 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16039 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16040 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16041 "Redistribute information from another routing protocol\n"
16042 "Open Shortest Path First (OSPFv2)\n"
16043 "Non-main Kernel Routing Table\n"
16044 "Instance ID/Table ID\n"
16045 "Metric for redistributed routes\n"
16046 "Default metric\n")
16048 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16049 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16050 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16051 "Redistribute information from another routing protocol\n"
16052 "Open Shortest Path First (OSPFv2)\n"
16053 "Non-main Kernel Routing Table\n"
16054 "Instance ID/Table ID\n"
16055 "Route map reference\n"
16056 "Pointer to route-map entries\n"
16057 "Metric for redistributed routes\n"
16058 "Default metric\n")
16060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16061 int idx_ospf_table
= 1;
16062 int idx_number
= 2;
16064 int idx_number_2
= 6;
16066 struct bgp_redist
*red
;
16067 unsigned short instance
;
16070 struct route_map
*route_map
=
16071 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16073 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16074 protocol
= ZEBRA_ROUTE_OSPF
;
16076 protocol
= ZEBRA_ROUTE_TABLE
;
16078 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16079 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16081 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16083 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16084 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16086 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16090 bgp_redistribute_ipv4_ospf_rmap_metric
,
16091 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16092 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16093 "Redistribute information from another routing protocol\n"
16094 "Open Shortest Path First (OSPFv2)\n"
16095 "Non-main Kernel Routing Table\n"
16096 "Instance ID/Table ID\n"
16097 "Route map reference\n"
16098 "Pointer to route-map entries\n"
16099 "Metric for redistributed routes\n"
16100 "Default metric\n")
16102 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16103 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16104 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16105 "Redistribute information from another routing protocol\n"
16106 "Open Shortest Path First (OSPFv2)\n"
16107 "Non-main Kernel Routing Table\n"
16108 "Instance ID/Table ID\n"
16109 "Metric for redistributed routes\n"
16111 "Route map reference\n"
16112 "Pointer to route-map entries\n")
16114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16115 int idx_ospf_table
= 1;
16116 int idx_number
= 2;
16117 int idx_number_2
= 4;
16120 struct bgp_redist
*red
;
16121 unsigned short instance
;
16124 struct route_map
*route_map
=
16125 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16127 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16128 protocol
= ZEBRA_ROUTE_OSPF
;
16130 protocol
= ZEBRA_ROUTE_TABLE
;
16132 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16133 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16135 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16136 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16139 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16140 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16144 bgp_redistribute_ipv4_ospf_metric_rmap
,
16145 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16146 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16147 "Redistribute information from another routing protocol\n"
16148 "Open Shortest Path First (OSPFv2)\n"
16149 "Non-main Kernel Routing Table\n"
16150 "Instance ID/Table ID\n"
16151 "Metric for redistributed routes\n"
16153 "Route map reference\n"
16154 "Pointer to route-map entries\n")
16156 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16157 no_bgp_redistribute_ipv4_ospf_cmd
,
16158 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16160 "Redistribute information from another routing protocol\n"
16161 "Open Shortest Path First (OSPFv2)\n"
16162 "Non-main Kernel Routing Table\n"
16163 "Instance ID/Table ID\n"
16164 "Metric for redistributed routes\n"
16166 "Route map reference\n"
16167 "Pointer to route-map entries\n")
16169 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16170 int idx_ospf_table
= 2;
16171 int idx_number
= 3;
16172 unsigned short instance
;
16175 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16176 protocol
= ZEBRA_ROUTE_OSPF
;
16178 protocol
= ZEBRA_ROUTE_TABLE
;
16180 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16181 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16185 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16186 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16188 "Redistribute information from another routing protocol\n"
16189 "Open Shortest Path First (OSPFv2)\n"
16190 "Non-main Kernel Routing Table\n"
16191 "Instance ID/Table ID\n"
16192 "Metric for redistributed routes\n"
16194 "Route map reference\n"
16195 "Pointer to route-map entries\n")
16197 DEFUN (no_bgp_redistribute_ipv4
,
16198 no_bgp_redistribute_ipv4_cmd
,
16199 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16201 "Redistribute information from another routing protocol\n"
16202 FRR_IP_REDIST_HELP_STR_BGPD
16203 "Metric for redistributed routes\n"
16205 "Route map reference\n"
16206 "Pointer to route-map entries\n")
16208 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16209 int idx_protocol
= 2;
16212 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16214 vty_out(vty
, "%% Invalid route type\n");
16215 return CMD_WARNING_CONFIG_FAILED
;
16217 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16221 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16222 "no redistribute " FRR_IP_REDIST_STR_BGPD
16223 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16225 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16226 "Metric for redistributed routes\n"
16228 "Route map reference\n"
16229 "Pointer to route-map entries\n")
16231 DEFUN (bgp_redistribute_ipv6
,
16232 bgp_redistribute_ipv6_cmd
,
16233 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16234 "Redistribute information from another routing protocol\n"
16235 FRR_IP6_REDIST_HELP_STR_BGPD
)
16237 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16238 int idx_protocol
= 1;
16241 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16243 vty_out(vty
, "%% Invalid route type\n");
16244 return CMD_WARNING_CONFIG_FAILED
;
16247 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16248 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16251 DEFUN (bgp_redistribute_ipv6_rmap
,
16252 bgp_redistribute_ipv6_rmap_cmd
,
16253 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16254 "Redistribute information from another routing protocol\n"
16255 FRR_IP6_REDIST_HELP_STR_BGPD
16256 "Route map reference\n"
16257 "Pointer to route-map entries\n")
16259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16260 int idx_protocol
= 1;
16263 struct bgp_redist
*red
;
16265 struct route_map
*route_map
=
16266 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16268 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16270 vty_out(vty
, "%% Invalid route type\n");
16271 return CMD_WARNING_CONFIG_FAILED
;
16274 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16276 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16277 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16280 DEFUN (bgp_redistribute_ipv6_metric
,
16281 bgp_redistribute_ipv6_metric_cmd
,
16282 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16283 "Redistribute information from another routing protocol\n"
16284 FRR_IP6_REDIST_HELP_STR_BGPD
16285 "Metric for redistributed routes\n"
16286 "Default metric\n")
16288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16289 int idx_protocol
= 1;
16290 int idx_number
= 3;
16293 struct bgp_redist
*red
;
16296 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16298 vty_out(vty
, "%% Invalid route type\n");
16299 return CMD_WARNING_CONFIG_FAILED
;
16301 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16303 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16304 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16305 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16308 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16309 bgp_redistribute_ipv6_rmap_metric_cmd
,
16310 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16311 "Redistribute information from another routing protocol\n"
16312 FRR_IP6_REDIST_HELP_STR_BGPD
16313 "Route map reference\n"
16314 "Pointer to route-map entries\n"
16315 "Metric for redistributed routes\n"
16316 "Default metric\n")
16318 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16319 int idx_protocol
= 1;
16321 int idx_number
= 5;
16324 struct bgp_redist
*red
;
16326 struct route_map
*route_map
=
16327 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16329 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16331 vty_out(vty
, "%% Invalid route type\n");
16332 return CMD_WARNING_CONFIG_FAILED
;
16334 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16336 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16338 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16339 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16341 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16344 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16345 bgp_redistribute_ipv6_metric_rmap_cmd
,
16346 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16347 "Redistribute information from another routing protocol\n"
16348 FRR_IP6_REDIST_HELP_STR_BGPD
16349 "Metric for redistributed routes\n"
16351 "Route map reference\n"
16352 "Pointer to route-map entries\n")
16354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16355 int idx_protocol
= 1;
16356 int idx_number
= 3;
16360 struct bgp_redist
*red
;
16362 struct route_map
*route_map
=
16363 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16365 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16367 vty_out(vty
, "%% Invalid route type\n");
16368 return CMD_WARNING_CONFIG_FAILED
;
16370 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16372 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16373 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16376 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16377 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16380 DEFUN (no_bgp_redistribute_ipv6
,
16381 no_bgp_redistribute_ipv6_cmd
,
16382 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16384 "Redistribute information from another routing protocol\n"
16385 FRR_IP6_REDIST_HELP_STR_BGPD
16386 "Metric for redistributed routes\n"
16388 "Route map reference\n"
16389 "Pointer to route-map entries\n")
16391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16392 int idx_protocol
= 2;
16395 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16397 vty_out(vty
, "%% Invalid route type\n");
16398 return CMD_WARNING_CONFIG_FAILED
;
16401 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16404 /* Neighbor update tcp-mss. */
16405 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16406 const char *tcp_mss_str
)
16409 uint32_t tcp_mss_val
= 0;
16411 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16413 return CMD_WARNING_CONFIG_FAILED
;
16416 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16417 peer_tcp_mss_set(peer
, tcp_mss_val
);
16419 peer_tcp_mss_unset(peer
);
16422 return CMD_SUCCESS
;
16425 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16426 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16428 "TCP max segment size\n"
16431 int peer_index
= 1;
16435 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16436 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16437 argv
[mss_index
]->arg
);
16440 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16441 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16442 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16443 "TCP max segment size\n"
16446 int peer_index
= 2;
16449 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16450 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16453 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16454 "[no$no] bgp retain route-target all",
16456 "Retain BGP updates\n"
16457 "Retain BGP updates based on route-target values\n"
16458 "Retain all BGP updates\n")
16461 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16463 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16464 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16465 if (check
!= !no
) {
16467 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16468 [bgp_node_safi(vty
)],
16469 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16471 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16472 [bgp_node_safi(vty
)],
16473 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16474 /* trigger a flush to re-sync with ADJ-RIB-in */
16475 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16476 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16478 return CMD_SUCCESS
;
16481 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16482 afi_t afi
, safi_t safi
)
16486 /* Unicast redistribution only. */
16487 if (safi
!= SAFI_UNICAST
)
16490 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16491 /* Redistribute BGP does not make sense. */
16492 if (i
!= ZEBRA_ROUTE_BGP
) {
16493 struct list
*red_list
;
16494 struct listnode
*node
;
16495 struct bgp_redist
*red
;
16497 red_list
= bgp
->redist
[afi
][i
];
16501 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16502 /* "redistribute" configuration. */
16503 vty_out(vty
, " redistribute %s",
16504 zebra_route_string(i
));
16506 vty_out(vty
, " %d", red
->instance
);
16507 if (red
->redist_metric_flag
)
16508 vty_out(vty
, " metric %u",
16509 red
->redist_metric
);
16510 if (red
->rmap
.name
)
16511 vty_out(vty
, " route-map %s",
16513 vty_out(vty
, "\n");
16519 /* peer-group helpers for config-write */
16521 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16523 if (!peer_group_active(peer
)) {
16524 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16525 return !CHECK_FLAG(peer
->flags
, flag
);
16527 return !!CHECK_FLAG(peer
->flags
, flag
);
16530 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16533 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16536 if (!peer_group_active(peer
)) {
16537 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16538 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16540 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16543 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16546 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16547 uint8_t type
, int direct
)
16549 struct bgp_filter
*filter
;
16551 if (peer_group_active(peer
))
16552 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16555 filter
= &peer
->filter
[afi
][safi
];
16557 case PEER_FT_DISTRIBUTE_LIST
:
16558 return !!(filter
->dlist
[direct
].name
);
16559 case PEER_FT_FILTER_LIST
:
16560 return !!(filter
->aslist
[direct
].name
);
16561 case PEER_FT_PREFIX_LIST
:
16562 return !!(filter
->plist
[direct
].name
);
16563 case PEER_FT_ROUTE_MAP
:
16564 return !!(filter
->map
[direct
].name
);
16565 case PEER_FT_UNSUPPRESS_MAP
:
16566 return !!(filter
->usmap
.name
);
16567 case PEER_FT_ADVERTISE_MAP
:
16568 return !!(filter
->advmap
.aname
16569 && ((filter
->advmap
.condition
== direct
)
16570 && filter
->advmap
.cname
));
16576 /* Return true if the addpath type is set for peer and different from
16579 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16582 enum bgp_addpath_strat type
, g_type
;
16584 type
= peer
->addpath_type
[afi
][safi
];
16586 if (type
!= BGP_ADDPATH_NONE
) {
16587 if (peer_group_active(peer
)) {
16588 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16590 if (type
!= g_type
)
16602 /* This is part of the address-family block (unicast only) */
16603 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16607 uint32_t tovpn_sid_index
= 0;
16609 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16610 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16611 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16612 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16613 bgp
->vpn_policy
[afi
]
16614 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16616 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16617 bgp
->vpn_policy
[afi
]
16618 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16620 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16621 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16622 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16623 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16626 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16627 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16629 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16632 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16633 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16634 bgp
->vpn_policy
[afi
].tovpn_label
);
16638 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16639 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16640 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16641 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16642 } else if (tovpn_sid_index
!= 0) {
16643 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16647 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16648 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16649 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16651 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16652 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16654 char buf
[PREFIX_STRLEN
];
16655 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16656 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16659 vty_out(vty
, "%*snexthop vpn export %s\n",
16663 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16664 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16666 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16667 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16669 char *b
= ecommunity_ecom2str(
16670 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16671 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16672 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16673 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16675 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16676 char *b
= ecommunity_ecom2str(
16677 bgp
->vpn_policy
[afi
]
16678 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16679 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16680 ECOMMUNITY_ROUTE_TARGET
);
16681 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16682 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16684 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16685 char *b
= ecommunity_ecom2str(
16686 bgp
->vpn_policy
[afi
]
16687 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16688 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16689 ECOMMUNITY_ROUTE_TARGET
);
16690 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16691 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16695 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16696 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16697 bgp
->vpn_policy
[afi
]
16698 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16700 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16701 char *b
= ecommunity_ecom2str(
16702 bgp
->vpn_policy
[afi
]
16703 .import_redirect_rtlist
,
16704 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16705 ECOMMUNITY_ROUTE_TARGET
);
16707 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16708 != ECOMMUNITY_SIZE
)
16709 vty_out(vty
, "%*srt6 redirect import %s\n",
16712 vty_out(vty
, "%*srt redirect import %s\n",
16714 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16718 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16719 afi_t afi
, safi_t safi
)
16721 struct bgp_filter
*filter
;
16725 filter
= &peer
->filter
[afi
][safi
];
16727 /* distribute-list. */
16728 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16730 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16731 filter
->dlist
[FILTER_IN
].name
);
16733 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16735 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16736 filter
->dlist
[FILTER_OUT
].name
);
16739 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16741 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16742 filter
->plist
[FILTER_IN
].name
);
16744 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16746 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16747 filter
->plist
[FILTER_OUT
].name
);
16750 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16751 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16752 filter
->map
[RMAP_IN
].name
);
16754 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16756 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16757 filter
->map
[RMAP_OUT
].name
);
16759 /* unsuppress-map */
16760 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16761 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16762 filter
->usmap
.name
);
16764 /* advertise-map : always applied in OUT direction*/
16765 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16766 CONDITION_NON_EXIST
))
16768 " neighbor %s advertise-map %s non-exist-map %s\n",
16769 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16771 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16773 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16774 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16777 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16779 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16780 filter
->aslist
[FILTER_IN
].name
);
16782 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16784 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16785 filter
->aslist
[FILTER_OUT
].name
);
16788 /* BGP peer configuration display function. */
16789 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16792 struct peer
*g_peer
= NULL
;
16794 int if_pg_printed
= false;
16795 int if_ras_printed
= false;
16797 /* Skip dynamic neighbors. */
16798 if (peer_dynamic_neighbor(peer
))
16802 addr
= peer
->conf_if
;
16806 /************************************
16807 ****** Global to the neighbor ******
16808 ************************************/
16809 if (peer
->conf_if
) {
16810 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16811 vty_out(vty
, " neighbor %s interface v6only", addr
);
16813 vty_out(vty
, " neighbor %s interface", addr
);
16815 if (peer_group_active(peer
)) {
16816 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16817 if_pg_printed
= true;
16818 } else if (peer
->as_type
== AS_SPECIFIED
) {
16819 vty_out(vty
, " remote-as %u", peer
->as
);
16820 if_ras_printed
= true;
16821 } else if (peer
->as_type
== AS_INTERNAL
) {
16822 vty_out(vty
, " remote-as internal");
16823 if_ras_printed
= true;
16824 } else if (peer
->as_type
== AS_EXTERNAL
) {
16825 vty_out(vty
, " remote-as external");
16826 if_ras_printed
= true;
16829 vty_out(vty
, "\n");
16832 /* remote-as and peer-group */
16833 /* peer is a member of a peer-group */
16834 if (peer_group_active(peer
)) {
16835 g_peer
= peer
->group
->conf
;
16837 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16838 if (peer
->as_type
== AS_SPECIFIED
) {
16839 vty_out(vty
, " neighbor %s remote-as %u\n",
16841 } else if (peer
->as_type
== AS_INTERNAL
) {
16843 " neighbor %s remote-as internal\n",
16845 } else if (peer
->as_type
== AS_EXTERNAL
) {
16847 " neighbor %s remote-as external\n",
16852 /* For swpX peers we displayed the peer-group
16853 * via 'neighbor swpX interface peer-group PGNAME' */
16854 if (!if_pg_printed
)
16855 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16856 peer
->group
->name
);
16859 /* peer is NOT a member of a peer-group */
16861 /* peer is a peer-group, declare the peer-group */
16862 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16863 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16866 if (!if_ras_printed
) {
16867 if (peer
->as_type
== AS_SPECIFIED
) {
16868 vty_out(vty
, " neighbor %s remote-as %u\n",
16870 } else if (peer
->as_type
== AS_INTERNAL
) {
16872 " neighbor %s remote-as internal\n",
16874 } else if (peer
->as_type
== AS_EXTERNAL
) {
16876 " neighbor %s remote-as external\n",
16883 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16884 vty_out(vty
, " neighbor %s local-as %u", addr
,
16885 peer
->change_local_as
);
16886 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16887 vty_out(vty
, " no-prepend");
16888 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16889 vty_out(vty
, " replace-as");
16890 vty_out(vty
, "\n");
16895 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16899 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16900 if (peer
->tx_shutdown_message
)
16901 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16902 peer
->tx_shutdown_message
);
16904 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16907 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16908 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16909 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16912 if (peer
->bfd_config
)
16913 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16916 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16917 vty_out(vty
, " neighbor %s password %s\n", addr
,
16920 /* neighbor solo */
16921 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16922 if (!peer_group_active(peer
)) {
16923 vty_out(vty
, " neighbor %s solo\n", addr
);
16928 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16929 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16932 /* Local interface name */
16933 if (peer
->ifname
) {
16934 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16937 /* TCP max segment size */
16938 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16939 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16942 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16943 vty_out(vty
, " neighbor %s passive\n", addr
);
16945 /* ebgp-multihop */
16946 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16947 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16948 && peer
->ttl
== MAXTTL
)) {
16949 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16950 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16956 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16957 peer
->local_role
!= ROLE_UNDEFINED
)
16958 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16959 bgp_get_name_by_role(peer
->local_role
),
16960 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16964 /* ttl-security hops */
16965 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16966 if (!peer_group_active(peer
)
16967 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16968 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16969 addr
, peer
->gtsm_hops
);
16973 /* disable-connected-check */
16974 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16975 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16977 /* link-bw-encoding-ieee */
16978 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16979 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16982 /* extended-optional-parameters */
16983 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16984 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16987 /* enforce-first-as */
16988 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16989 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16991 /* update-source */
16992 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16993 if (peer
->update_source
)
16994 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16995 peer
->update_source
);
16996 else if (peer
->update_if
)
16997 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17001 /* advertisement-interval */
17002 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17003 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17007 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17008 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17009 peer
->keepalive
, peer
->holdtime
);
17011 /* timers connect */
17012 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17013 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17015 /* need special-case handling for changed default values due to
17016 * config profile / version (because there is no "timers bgp connect"
17017 * command, we need to save this per-peer :/)
17019 else if (!peer_group_active(peer
) && !peer
->connect
&&
17020 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17021 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17022 peer
->bgp
->default_connect_retry
);
17024 /* timers delayopen */
17025 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17026 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17028 /* Save config even though flag is not set if default values have been
17031 else if (!peer_group_active(peer
) && !peer
->delayopen
17032 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17033 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17034 peer
->bgp
->default_delayopen
);
17036 /* capability dynamic */
17037 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17038 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17040 /* capability extended-nexthop */
17041 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17042 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17045 " no neighbor %s capability extended-nexthop\n",
17047 else if (!peer
->conf_if
)
17049 " neighbor %s capability extended-nexthop\n",
17053 /* dont-capability-negotiation */
17054 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17055 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17057 /* override-capability */
17058 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17059 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17061 /* strict-capability-match */
17062 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17063 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17065 /* Sender side AS path loop detection. */
17066 if (peer
->as_path_loop_detection
)
17067 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17070 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17071 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17073 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17074 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17076 " neighbor %s graceful-restart-helper\n", addr
);
17077 } else if (CHECK_FLAG(
17078 peer
->peer_gr_new_status_flag
,
17079 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17081 " neighbor %s graceful-restart\n", addr
);
17083 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17084 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17086 peer
->peer_gr_new_status_flag
,
17087 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17088 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17094 /* BGP peer configuration display function. */
17095 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17096 struct peer
*peer
, afi_t afi
, safi_t safi
)
17098 struct peer
*g_peer
= NULL
;
17100 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17102 /* Skip dynamic neighbors. */
17103 if (peer_dynamic_neighbor(peer
))
17107 addr
= peer
->conf_if
;
17111 /************************************
17112 ****** Per AF to the neighbor ******
17113 ************************************/
17114 if (peer_group_active(peer
)) {
17115 g_peer
= peer
->group
->conf
;
17117 /* If the peer-group is active but peer is not, print a 'no
17119 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17120 vty_out(vty
, " no neighbor %s activate\n", addr
);
17123 /* If the peer-group is not active but peer is, print an
17125 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17126 vty_out(vty
, " neighbor %s activate\n", addr
);
17129 if (peer
->afc
[afi
][safi
]) {
17130 if (safi
== SAFI_ENCAP
)
17131 vty_out(vty
, " neighbor %s activate\n", addr
);
17132 else if (!bgp
->default_af
[afi
][safi
])
17133 vty_out(vty
, " neighbor %s activate\n", addr
);
17135 if (bgp
->default_af
[afi
][safi
])
17136 vty_out(vty
, " no neighbor %s activate\n",
17141 /* addpath TX knobs */
17142 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17143 switch (peer
->addpath_type
[afi
][safi
]) {
17144 case BGP_ADDPATH_ALL
:
17145 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17148 case BGP_ADDPATH_BEST_PER_AS
:
17150 " neighbor %s addpath-tx-bestpath-per-AS\n",
17153 case BGP_ADDPATH_MAX
:
17154 case BGP_ADDPATH_NONE
:
17159 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17160 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17162 /* ORF capability. */
17163 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17164 || peergroup_af_flag_check(peer
, afi
, safi
,
17165 PEER_FLAG_ORF_PREFIX_RM
)) {
17166 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17168 if (peergroup_af_flag_check(peer
, afi
, safi
,
17169 PEER_FLAG_ORF_PREFIX_SM
)
17170 && peergroup_af_flag_check(peer
, afi
, safi
,
17171 PEER_FLAG_ORF_PREFIX_RM
))
17172 vty_out(vty
, " both");
17173 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17174 PEER_FLAG_ORF_PREFIX_SM
))
17175 vty_out(vty
, " send");
17177 vty_out(vty
, " receive");
17178 vty_out(vty
, "\n");
17181 /* Route reflector client. */
17182 if (peergroup_af_flag_check(peer
, afi
, safi
,
17183 PEER_FLAG_REFLECTOR_CLIENT
)) {
17184 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17187 /* next-hop-self force */
17188 if (peergroup_af_flag_check(peer
, afi
, safi
,
17189 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17190 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17193 /* next-hop-self */
17194 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17195 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17198 /* remove-private-AS */
17199 if (peergroup_af_flag_check(peer
, afi
, safi
,
17200 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17201 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17205 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17206 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17207 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17211 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17212 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17213 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17216 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17217 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17218 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17222 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17223 vty_out(vty
, " neighbor %s as-override\n", addr
);
17226 /* send-community print. */
17227 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17228 PEER_FLAG_SEND_COMMUNITY
);
17229 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17230 PEER_FLAG_SEND_EXT_COMMUNITY
);
17231 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17232 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17234 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17235 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17238 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17241 " no neighbor %s send-community extended\n",
17245 vty_out(vty
, " no neighbor %s send-community large\n",
17249 /* Default information */
17250 if (peergroup_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17252 vty_out(vty
, " neighbor %s default-originate", addr
);
17254 if (peer
->default_rmap
[afi
][safi
].name
)
17255 vty_out(vty
, " route-map %s",
17256 peer
->default_rmap
[afi
][safi
].name
);
17258 vty_out(vty
, "\n");
17261 /* Soft reconfiguration inbound. */
17262 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17263 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17267 /* maximum-prefix. */
17268 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17269 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17270 peer
->pmax
[afi
][safi
]);
17272 if (peer
->pmax_threshold
[afi
][safi
]
17273 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17274 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17275 if (peer_af_flag_check(peer
, afi
, safi
,
17276 PEER_FLAG_MAX_PREFIX_WARNING
))
17277 vty_out(vty
, " warning-only");
17278 if (peer
->pmax_restart
[afi
][safi
])
17279 vty_out(vty
, " restart %u",
17280 peer
->pmax_restart
[afi
][safi
]);
17281 if (peer_af_flag_check(peer
, afi
, safi
,
17282 PEER_FLAG_MAX_PREFIX_FORCE
))
17283 vty_out(vty
, " force");
17285 vty_out(vty
, "\n");
17288 /* maximum-prefix-out */
17289 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17290 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17291 addr
, peer
->pmax_out
[afi
][safi
]);
17293 /* Route server client. */
17294 if (peergroup_af_flag_check(peer
, afi
, safi
,
17295 PEER_FLAG_RSERVER_CLIENT
)) {
17296 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17299 /* Nexthop-local unchanged. */
17300 if (peergroup_af_flag_check(peer
, afi
, safi
,
17301 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17302 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17305 /* allowas-in <1-10> */
17306 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17307 if (peer_af_flag_check(peer
, afi
, safi
,
17308 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17309 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17310 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17311 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17313 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17314 peer
->allowas_in
[afi
][safi
]);
17319 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17320 char *soo_str
= ecommunity_ecom2str(
17321 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17323 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17324 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17328 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17329 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17330 peer
->weight
[afi
][safi
]);
17333 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17335 /* atribute-unchanged. */
17336 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17337 || (safi
!= SAFI_EVPN
17338 && peer_af_flag_check(peer
, afi
, safi
,
17339 PEER_FLAG_NEXTHOP_UNCHANGED
))
17340 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17342 if (!peer_group_active(peer
)
17343 || peergroup_af_flag_check(peer
, afi
, safi
,
17344 PEER_FLAG_AS_PATH_UNCHANGED
)
17345 || peergroup_af_flag_check(peer
, afi
, safi
,
17346 PEER_FLAG_NEXTHOP_UNCHANGED
)
17347 || peergroup_af_flag_check(peer
, afi
, safi
,
17348 PEER_FLAG_MED_UNCHANGED
)) {
17351 " neighbor %s attribute-unchanged%s%s%s\n",
17353 peer_af_flag_check(peer
, afi
, safi
,
17354 PEER_FLAG_AS_PATH_UNCHANGED
)
17357 peer_af_flag_check(peer
, afi
, safi
,
17358 PEER_FLAG_NEXTHOP_UNCHANGED
)
17361 peer_af_flag_check(peer
, afi
, safi
,
17362 PEER_FLAG_MED_UNCHANGED
)
17369 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17372 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17373 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17374 vty_out(vty
, " no bgp retain route-target all\n");
17377 /* Address family based peer configuration display. */
17378 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17382 struct peer_group
*group
;
17383 struct listnode
*node
, *nnode
;
17386 vty_frame(vty
, " !\n address-family ");
17387 if (afi
== AFI_IP
) {
17388 if (safi
== SAFI_UNICAST
)
17389 vty_frame(vty
, "ipv4 unicast");
17390 else if (safi
== SAFI_LABELED_UNICAST
)
17391 vty_frame(vty
, "ipv4 labeled-unicast");
17392 else if (safi
== SAFI_MULTICAST
)
17393 vty_frame(vty
, "ipv4 multicast");
17394 else if (safi
== SAFI_MPLS_VPN
)
17395 vty_frame(vty
, "ipv4 vpn");
17396 else if (safi
== SAFI_ENCAP
)
17397 vty_frame(vty
, "ipv4 encap");
17398 else if (safi
== SAFI_FLOWSPEC
)
17399 vty_frame(vty
, "ipv4 flowspec");
17400 } else if (afi
== AFI_IP6
) {
17401 if (safi
== SAFI_UNICAST
)
17402 vty_frame(vty
, "ipv6 unicast");
17403 else if (safi
== SAFI_LABELED_UNICAST
)
17404 vty_frame(vty
, "ipv6 labeled-unicast");
17405 else if (safi
== SAFI_MULTICAST
)
17406 vty_frame(vty
, "ipv6 multicast");
17407 else if (safi
== SAFI_MPLS_VPN
)
17408 vty_frame(vty
, "ipv6 vpn");
17409 else if (safi
== SAFI_ENCAP
)
17410 vty_frame(vty
, "ipv6 encap");
17411 else if (safi
== SAFI_FLOWSPEC
)
17412 vty_frame(vty
, "ipv6 flowspec");
17413 } else if (afi
== AFI_L2VPN
) {
17414 if (safi
== SAFI_EVPN
)
17415 vty_frame(vty
, "l2vpn evpn");
17417 vty_frame(vty
, "\n");
17419 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17421 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17423 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17425 /* BGP flag dampening. */
17426 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17427 bgp_config_write_damp(vty
, afi
, safi
);
17429 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17430 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17432 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17433 /* Do not display doppelganger peers */
17434 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17435 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17438 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17439 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17441 if (safi
== SAFI_EVPN
)
17442 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17444 if (safi
== SAFI_FLOWSPEC
)
17445 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17447 if (safi
== SAFI_MPLS_VPN
)
17448 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17450 if (safi
== SAFI_UNICAST
) {
17451 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17452 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17453 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17455 vty_out(vty
, " export vpn\n");
17457 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17458 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17460 vty_out(vty
, " import vpn\n");
17462 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17463 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17466 for (ALL_LIST_ELEMENTS_RO(
17467 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17469 vty_out(vty
, " import vrf %s\n", name
);
17473 vty_endframe(vty
, " exit-address-family\n");
17476 int bgp_config_write(struct vty
*vty
)
17479 struct peer_group
*group
;
17481 struct listnode
*node
, *nnode
;
17482 struct listnode
*mnode
, *mnnode
;
17486 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17487 vty_out(vty
, "bgp route-map delay-timer %u\n",
17488 bm
->rmap_update_timer
);
17490 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17491 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17492 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17493 vty_out(vty
, " %d", bm
->v_establish_wait
);
17494 vty_out(vty
, "\n");
17497 if (bm
->wait_for_fib
)
17498 vty_out(vty
, "bgp suppress-fib-pending\n");
17500 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17501 vty_out(vty
, "bgp graceful-shutdown\n");
17503 /* No-RIB (Zebra) option flag configuration */
17504 if (bgp_option_check(BGP_OPT_NO_FIB
))
17505 vty_out(vty
, "bgp no-rib\n");
17507 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17508 vty_out(vty
, "bgp send-extra-data zebra\n");
17510 /* BGP session DSCP value */
17511 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17512 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17514 /* BGP configuration. */
17515 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17517 /* skip all auto created vrf as they dont have user config */
17518 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17521 /* Router bgp ASN */
17522 vty_out(vty
, "router bgp %u", bgp
->as
);
17525 vty_out(vty
, " %s %s",
17526 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17527 ? "view" : "vrf", bgp
->name
);
17528 vty_out(vty
, "\n");
17530 /* BGP fast-external-failover. */
17531 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17532 vty_out(vty
, " no bgp fast-external-failover\n");
17534 /* BGP router ID. */
17535 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17536 vty_out(vty
, " bgp router-id %pI4\n",
17537 &bgp
->router_id_static
);
17539 /* Suppress fib pending */
17540 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17541 vty_out(vty
, " bgp suppress-fib-pending\n");
17543 /* BGP log-neighbor-changes. */
17544 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17545 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17546 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17547 CHECK_FLAG(bgp
->flags
,
17548 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17552 /* BGP configuration. */
17553 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17554 vty_out(vty
, " bgp always-compare-med\n");
17556 /* RFC8212 default eBGP policy. */
17557 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17558 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17559 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17560 CHECK_FLAG(bgp
->flags
,
17561 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17565 /* draft-ietf-idr-deprecate-as-set-confed-set */
17566 if (bgp
->reject_as_sets
)
17567 vty_out(vty
, " bgp reject-as-sets\n");
17569 /* Suppress duplicate updates if the route actually not changed
17571 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17572 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17573 vty_out(vty
, " %sbgp suppress-duplicates\n",
17574 CHECK_FLAG(bgp
->flags
,
17575 BGP_FLAG_SUPPRESS_DUPLICATES
)
17579 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17581 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17582 SAVE_BGP_HARD_ADMIN_RESET
)
17583 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17584 CHECK_FLAG(bgp
->flags
,
17585 BGP_FLAG_HARD_ADMIN_RESET
)
17589 /* BGP default <afi>-<safi> */
17590 FOREACH_AFI_SAFI (afi
, safi
) {
17591 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17592 if (!bgp
->default_af
[afi
][safi
])
17593 vty_out(vty
, " no bgp default %s\n",
17594 get_bgp_default_af_flag(afi
,
17596 } else if (bgp
->default_af
[afi
][safi
])
17597 vty_out(vty
, " bgp default %s\n",
17598 get_bgp_default_af_flag(afi
, safi
));
17601 /* BGP default local-preference. */
17602 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17603 vty_out(vty
, " bgp default local-preference %u\n",
17604 bgp
->default_local_pref
);
17606 /* BGP default show-hostname */
17607 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17608 != SAVE_BGP_SHOW_HOSTNAME
)
17609 vty_out(vty
, " %sbgp default show-hostname\n",
17610 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17614 /* BGP default show-nexthop-hostname */
17615 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17616 != SAVE_BGP_SHOW_HOSTNAME
)
17617 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17618 CHECK_FLAG(bgp
->flags
,
17619 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17623 /* BGP default subgroup-pkt-queue-max. */
17624 if (bgp
->default_subgroup_pkt_queue_max
17625 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17626 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17627 bgp
->default_subgroup_pkt_queue_max
);
17629 /* BGP client-to-client reflection. */
17630 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17631 vty_out(vty
, " no bgp client-to-client reflection\n");
17633 /* BGP cluster ID. */
17634 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17635 vty_out(vty
, " bgp cluster-id %pI4\n",
17638 /* Disable ebgp connected nexthop check */
17639 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17641 " bgp disable-ebgp-connected-route-check\n");
17643 /* Confederation identifier*/
17644 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17645 vty_out(vty
, " bgp confederation identifier %u\n",
17648 /* Confederation peer */
17649 if (bgp
->confed_peers_cnt
> 0) {
17652 vty_out(vty
, " bgp confederation peers");
17654 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17655 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17657 vty_out(vty
, "\n");
17660 /* BGP deterministic-med. */
17661 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17662 != SAVE_BGP_DETERMINISTIC_MED
)
17663 vty_out(vty
, " %sbgp deterministic-med\n",
17664 CHECK_FLAG(bgp
->flags
,
17665 BGP_FLAG_DETERMINISTIC_MED
)
17669 /* BGP update-delay. */
17670 bgp_config_write_update_delay(vty
, bgp
);
17672 if (bgp
->v_maxmed_onstartup
17673 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17674 vty_out(vty
, " bgp max-med on-startup %u",
17675 bgp
->v_maxmed_onstartup
);
17676 if (bgp
->maxmed_onstartup_value
17677 != BGP_MAXMED_VALUE_DEFAULT
)
17678 vty_out(vty
, " %u",
17679 bgp
->maxmed_onstartup_value
);
17680 vty_out(vty
, "\n");
17682 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17683 vty_out(vty
, " bgp max-med administrative");
17684 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17685 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17686 vty_out(vty
, "\n");
17690 bgp_config_write_wpkt_quanta(vty
, bgp
);
17692 bgp_config_write_rpkt_quanta(vty
, bgp
);
17694 /* coalesce time */
17695 bgp_config_write_coalesce_time(vty
, bgp
);
17697 /* BGP per-instance graceful-shutdown */
17698 /* BGP-wide settings and per-instance settings are mutually
17701 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17702 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17703 vty_out(vty
, " bgp graceful-shutdown\n");
17705 /* Long-lived Graceful Restart */
17706 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17708 " bgp long-lived-graceful-restart stale-time %u\n",
17709 bgp
->llgr_stale_time
);
17711 /* BGP graceful-restart. */
17712 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17714 " bgp graceful-restart stalepath-time %u\n",
17715 bgp
->stalepath_time
);
17717 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17718 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17719 bgp
->restart_time
);
17721 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17722 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17723 vty_out(vty
, " %sbgp graceful-restart notification\n",
17724 CHECK_FLAG(bgp
->flags
,
17725 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17729 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17731 " bgp graceful-restart select-defer-time %u\n",
17732 bgp
->select_defer_time
);
17734 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17735 vty_out(vty
, " bgp graceful-restart\n");
17737 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17738 vty_out(vty
, " bgp graceful-restart-disable\n");
17740 /* BGP graceful-restart Preserve State F bit. */
17741 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17743 " bgp graceful-restart preserve-fw-state\n");
17745 /* BGP TCP keepalive */
17746 bgp_config_tcp_keepalive(vty
, bgp
);
17748 /* Stale timer for RIB */
17749 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17751 " bgp graceful-restart rib-stale-time %u\n",
17752 bgp
->rib_stale_time
);
17754 /* BGP bestpath method. */
17755 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17756 vty_out(vty
, " bgp bestpath as-path ignore\n");
17757 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17758 vty_out(vty
, " bgp bestpath as-path confed\n");
17760 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17761 if (CHECK_FLAG(bgp
->flags
,
17762 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17764 " bgp bestpath as-path multipath-relax as-set\n");
17767 " bgp bestpath as-path multipath-relax\n");
17771 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17773 " bgp route-reflector allow-outbound-policy\n");
17775 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17776 vty_out(vty
, " bgp bestpath compare-routerid\n");
17777 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17778 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17779 vty_out(vty
, " bgp bestpath med");
17780 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17781 vty_out(vty
, " confed");
17782 if (CHECK_FLAG(bgp
->flags
,
17783 BGP_FLAG_MED_MISSING_AS_WORST
))
17784 vty_out(vty
, " missing-as-worst");
17785 vty_out(vty
, "\n");
17788 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17790 " bgp bestpath peer-type multipath-relax\n");
17792 /* Link bandwidth handling. */
17793 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17794 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17795 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17796 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17797 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17798 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17800 /* BGP network import check. */
17801 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17802 != SAVE_BGP_IMPORT_CHECK
)
17803 vty_out(vty
, " %sbgp network import-check\n",
17804 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17808 /* BGP timers configuration. */
17809 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17810 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17811 vty_out(vty
, " timers bgp %u %u\n",
17812 bgp
->default_keepalive
, bgp
->default_holdtime
);
17814 /* BGP minimum holdtime configuration. */
17815 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17816 && bgp
->default_min_holdtime
!= 0)
17817 vty_out(vty
, " bgp minimum-holdtime %u\n",
17818 bgp
->default_min_holdtime
);
17820 /* Conditional advertisement timer configuration */
17821 if (bgp
->condition_check_period
17822 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17824 " bgp conditional-advertisement timer %u\n",
17825 bgp
->condition_check_period
);
17828 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17829 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17832 /* Normal neighbor configuration. */
17833 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17834 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17835 bgp_config_write_peer_global(vty
, bgp
, peer
);
17838 /* listen range and limit for dynamic BGP neighbors */
17839 bgp_config_write_listen(vty
, bgp
);
17842 * BGP default autoshutdown neighbors
17844 * This must be placed after any peer and peer-group
17845 * configuration, to avoid setting all peers to shutdown after
17846 * a daemon restart, which is undesired behavior. (see #2286)
17848 if (bgp
->autoshutdown
)
17849 vty_out(vty
, " bgp default shutdown\n");
17851 /* BGP instance administrative shutdown */
17852 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17853 vty_out(vty
, " bgp shutdown\n");
17855 if (bgp
->allow_martian
)
17856 vty_out(vty
, " bgp allow-martian-nexthop\n");
17858 if (bgp
->fast_convergence
)
17859 vty_out(vty
, " bgp fast-convergence\n");
17861 if (bgp
->srv6_enabled
) {
17862 vty_frame(vty
, " !\n segment-routing srv6\n");
17863 if (strlen(bgp
->srv6_locator_name
))
17864 vty_out(vty
, " locator %s\n",
17865 bgp
->srv6_locator_name
);
17866 vty_endframe(vty
, " exit\n");
17870 /* IPv4 unicast configuration. */
17871 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17873 /* IPv4 multicast configuration. */
17874 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17876 /* IPv4 labeled-unicast configuration. */
17877 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17879 /* IPv4 VPN configuration. */
17880 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17882 /* ENCAPv4 configuration. */
17883 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17885 /* FLOWSPEC v4 configuration. */
17886 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17888 /* IPv6 unicast configuration. */
17889 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17891 /* IPv6 multicast configuration. */
17892 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17894 /* IPv6 labeled-unicast configuration. */
17895 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17896 SAFI_LABELED_UNICAST
);
17898 /* IPv6 VPN configuration. */
17899 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17901 /* ENCAPv6 configuration. */
17902 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17904 /* FLOWSPEC v6 configuration. */
17905 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17907 /* EVPN configuration. */
17908 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17910 hook_call(bgp_inst_config_write
, bgp
, vty
);
17912 #ifdef ENABLE_BGP_VNC
17913 bgp_rfapi_cfg_write(vty
, bgp
);
17916 vty_out(vty
, "exit\n");
17917 vty_out(vty
, "!\n");
17923 /* BGP node structure. */
17924 static struct cmd_node bgp_node
= {
17927 .parent_node
= CONFIG_NODE
,
17928 .prompt
= "%s(config-router)# ",
17929 .config_write
= bgp_config_write
,
17932 static struct cmd_node bgp_ipv4_unicast_node
= {
17933 .name
= "bgp ipv4 unicast",
17934 .node
= BGP_IPV4_NODE
,
17935 .parent_node
= BGP_NODE
,
17936 .prompt
= "%s(config-router-af)# ",
17940 static struct cmd_node bgp_ipv4_multicast_node
= {
17941 .name
= "bgp ipv4 multicast",
17942 .node
= BGP_IPV4M_NODE
,
17943 .parent_node
= BGP_NODE
,
17944 .prompt
= "%s(config-router-af)# ",
17948 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17949 .name
= "bgp ipv4 labeled unicast",
17950 .node
= BGP_IPV4L_NODE
,
17951 .parent_node
= BGP_NODE
,
17952 .prompt
= "%s(config-router-af)# ",
17956 static struct cmd_node bgp_ipv6_unicast_node
= {
17957 .name
= "bgp ipv6 unicast",
17958 .node
= BGP_IPV6_NODE
,
17959 .parent_node
= BGP_NODE
,
17960 .prompt
= "%s(config-router-af)# ",
17964 static struct cmd_node bgp_ipv6_multicast_node
= {
17965 .name
= "bgp ipv6 multicast",
17966 .node
= BGP_IPV6M_NODE
,
17967 .parent_node
= BGP_NODE
,
17968 .prompt
= "%s(config-router-af)# ",
17972 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17973 .name
= "bgp ipv6 labeled unicast",
17974 .node
= BGP_IPV6L_NODE
,
17975 .parent_node
= BGP_NODE
,
17976 .prompt
= "%s(config-router-af)# ",
17980 static struct cmd_node bgp_vpnv4_node
= {
17981 .name
= "bgp vpnv4",
17982 .node
= BGP_VPNV4_NODE
,
17983 .parent_node
= BGP_NODE
,
17984 .prompt
= "%s(config-router-af)# ",
17988 static struct cmd_node bgp_vpnv6_node
= {
17989 .name
= "bgp vpnv6",
17990 .node
= BGP_VPNV6_NODE
,
17991 .parent_node
= BGP_NODE
,
17992 .prompt
= "%s(config-router-af-vpnv6)# ",
17996 static struct cmd_node bgp_evpn_node
= {
17997 .name
= "bgp evpn",
17998 .node
= BGP_EVPN_NODE
,
17999 .parent_node
= BGP_NODE
,
18000 .prompt
= "%s(config-router-evpn)# ",
18004 static struct cmd_node bgp_evpn_vni_node
= {
18005 .name
= "bgp evpn vni",
18006 .node
= BGP_EVPN_VNI_NODE
,
18007 .parent_node
= BGP_EVPN_NODE
,
18008 .prompt
= "%s(config-router-af-vni)# ",
18011 static struct cmd_node bgp_flowspecv4_node
= {
18012 .name
= "bgp ipv4 flowspec",
18013 .node
= BGP_FLOWSPECV4_NODE
,
18014 .parent_node
= BGP_NODE
,
18015 .prompt
= "%s(config-router-af)# ",
18019 static struct cmd_node bgp_flowspecv6_node
= {
18020 .name
= "bgp ipv6 flowspec",
18021 .node
= BGP_FLOWSPECV6_NODE
,
18022 .parent_node
= BGP_NODE
,
18023 .prompt
= "%s(config-router-af-vpnv6)# ",
18027 static struct cmd_node bgp_srv6_node
= {
18028 .name
= "bgp srv6",
18029 .node
= BGP_SRV6_NODE
,
18030 .parent_node
= BGP_NODE
,
18031 .prompt
= "%s(config-router-srv6)# ",
18034 static void community_list_vty(void);
18036 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18039 struct peer_group
*group
;
18040 struct listnode
*lnbgp
, *lnpeer
;
18042 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18043 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18045 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18049 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18053 struct listnode
*lnbgp
, *lnpeer
;
18055 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18056 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18057 /* only provide suggestions on the appropriate input
18059 * they'll otherwise show up multiple times */
18060 enum cmd_token_type match_type
;
18061 char *name
= peer
->host
;
18063 if (peer
->conf_if
) {
18064 match_type
= VARIABLE_TKN
;
18065 name
= peer
->conf_if
;
18066 } else if (strchr(peer
->host
, ':'))
18067 match_type
= IPV6_TKN
;
18069 match_type
= IPV4_TKN
;
18071 if (token
->type
!= match_type
)
18074 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18079 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18081 bgp_ac_peer(comps
, token
);
18083 if (token
->type
== VARIABLE_TKN
)
18084 bgp_ac_peergroup(comps
, token
);
18087 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18088 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18089 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18090 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18091 {.completions
= NULL
}};
18093 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18094 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18095 {.completions
= NULL
} };
18097 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18099 static struct thread
*t_bgp_cfg
;
18101 bool bgp_config_inprocess(void)
18103 return thread_is_scheduled(t_bgp_cfg
);
18106 static void bgp_config_finish(struct thread
*t
)
18108 struct listnode
*node
;
18111 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18112 hook_call(bgp_config_end
, bgp
);
18115 static void bgp_config_start(void)
18117 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18118 THREAD_OFF(t_bgp_cfg
);
18119 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18120 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18123 /* When we receive a hook the configuration is read,
18124 * we start a timer to make sure we postpone sending
18125 * EoR before route-maps are processed.
18126 * This is especially valid if using `bgp route-map delay-timer`.
18128 static void bgp_config_end(void)
18130 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18131 uint32_t bgp_post_config_delay
=
18132 thread_is_scheduled(bm
->t_rmap_update
)
18133 ? thread_timer_remain_second(bm
->t_rmap_update
)
18134 : BGP_POST_CONFIG_DELAY_SECONDS
;
18136 /* If BGP config processing thread isn't running, then
18137 * we can return and rely it's properly handled.
18139 if (!bgp_config_inprocess())
18142 THREAD_OFF(t_bgp_cfg
);
18144 /* Start a new timer to make sure we don't send EoR
18145 * before route-maps are processed.
18147 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18148 bgp_post_config_delay
, &t_bgp_cfg
);
18151 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18154 struct interface
*ifp
;
18155 struct bgp_interface
*iifp
;
18157 FOR_ALL_INTERFACES (vrf
, ifp
) {
18162 if_vty_config_start(vty
, ifp
);
18164 if (CHECK_FLAG(iifp
->flags
,
18165 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18166 vty_out(vty
, " mpls bgp forwarding\n");
18170 if_vty_config_end(vty
);
18176 /* Configuration write function for bgpd. */
18177 static int config_write_interface(struct vty
*vty
)
18180 struct vrf
*vrf
= NULL
;
18182 /* Display all VRF aware OSPF interface configuration */
18183 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18184 write
+= config_write_interface_one(vty
, vrf
);
18190 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18191 "[no$no] mpls bgp forwarding",
18192 NO_STR MPLS_STR BGP_STR
18193 "Enable MPLS forwarding for eBGP directly connected peers\n")
18196 struct bgp_interface
*iifp
;
18198 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18201 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18202 return CMD_WARNING_CONFIG_FAILED
;
18204 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18205 if (check
!= !no
) {
18207 UNSET_FLAG(iifp
->flags
,
18208 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18210 SET_FLAG(iifp
->flags
,
18211 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18212 /* trigger a nht update on eBGP sessions */
18213 if (if_is_operative(ifp
))
18214 bgp_nht_ifp_up(ifp
);
18216 return CMD_SUCCESS
;
18219 /* Initialization of BGP interface. */
18220 static void bgp_vty_if_init(void)
18222 /* Install interface node. */
18223 if_cmd_init(config_write_interface
);
18225 /* "mpls bgp forwarding" commands. */
18226 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18229 void bgp_vty_init(void)
18231 cmd_variable_handler_register(bgp_var_neighbor
);
18232 cmd_variable_handler_register(bgp_var_peergroup
);
18234 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18236 /* Install bgp top node. */
18237 install_node(&bgp_node
);
18238 install_node(&bgp_ipv4_unicast_node
);
18239 install_node(&bgp_ipv4_multicast_node
);
18240 install_node(&bgp_ipv4_labeled_unicast_node
);
18241 install_node(&bgp_ipv6_unicast_node
);
18242 install_node(&bgp_ipv6_multicast_node
);
18243 install_node(&bgp_ipv6_labeled_unicast_node
);
18244 install_node(&bgp_vpnv4_node
);
18245 install_node(&bgp_vpnv6_node
);
18246 install_node(&bgp_evpn_node
);
18247 install_node(&bgp_evpn_vni_node
);
18248 install_node(&bgp_flowspecv4_node
);
18249 install_node(&bgp_flowspecv6_node
);
18250 install_node(&bgp_srv6_node
);
18252 /* Install default VTY commands to new nodes. */
18253 install_default(BGP_NODE
);
18254 install_default(BGP_IPV4_NODE
);
18255 install_default(BGP_IPV4M_NODE
);
18256 install_default(BGP_IPV4L_NODE
);
18257 install_default(BGP_IPV6_NODE
);
18258 install_default(BGP_IPV6M_NODE
);
18259 install_default(BGP_IPV6L_NODE
);
18260 install_default(BGP_VPNV4_NODE
);
18261 install_default(BGP_VPNV6_NODE
);
18262 install_default(BGP_FLOWSPECV4_NODE
);
18263 install_default(BGP_FLOWSPECV6_NODE
);
18264 install_default(BGP_EVPN_NODE
);
18265 install_default(BGP_EVPN_VNI_NODE
);
18266 install_default(BGP_SRV6_NODE
);
18268 /* "bgp local-mac" hidden commands. */
18269 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18270 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18272 /* "bgp suppress-fib-pending" global */
18273 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18275 /* bgp route-map delay-timer commands. */
18276 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18277 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18279 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18281 /* bgp fast-convergence command */
18282 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18283 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18285 /* global bgp update-delay command */
18286 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18287 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18289 /* global bgp graceful-shutdown command */
18290 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18291 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18293 /* Dummy commands (Currently not supported) */
18294 install_element(BGP_NODE
, &no_synchronization_cmd
);
18295 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18297 /* "router bgp" commands. */
18298 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18300 /* "no router bgp" commands. */
18301 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18303 /* "bgp session-dscp command */
18304 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18305 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18307 /* "bgp router-id" commands. */
18308 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18309 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18311 /* "bgp suppress-fib-pending" command */
18312 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18314 /* "bgp cluster-id" commands. */
18315 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18316 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18318 /* "bgp no-rib" commands. */
18319 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18320 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18322 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18324 /* "bgp confederation" commands. */
18325 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18326 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18328 /* "bgp confederation peers" commands. */
18329 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18330 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18332 /* bgp max-med command */
18333 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18334 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18335 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18336 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18337 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18339 /* "neighbor role" commands. */
18340 install_element(BGP_NODE
, &neighbor_role_cmd
);
18341 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18342 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18344 /* bgp disable-ebgp-connected-nh-check */
18345 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18346 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18348 /* bgp update-delay command */
18349 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18350 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18352 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18353 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18355 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18356 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18358 /* "maximum-paths" commands. */
18359 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18360 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18361 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18362 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18363 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18364 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18365 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18366 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18367 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18368 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18369 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18370 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18371 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18372 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18373 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18375 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18376 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18377 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18378 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18379 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18380 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18381 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18382 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18383 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18384 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18386 /* "timers bgp" commands. */
18387 install_element(BGP_NODE
, &bgp_timers_cmd
);
18388 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18390 /* "minimum-holdtime" commands. */
18391 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18392 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18394 /* route-map delay-timer commands - per instance for backwards compat.
18396 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18397 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18399 /* "bgp client-to-client reflection" commands */
18400 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18401 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18403 /* "bgp always-compare-med" commands */
18404 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18405 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18407 /* bgp ebgp-requires-policy */
18408 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18409 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18411 /* bgp suppress-duplicates */
18412 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18413 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18415 /* bgp reject-as-sets */
18416 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18417 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18419 /* "bgp deterministic-med" commands */
18420 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18421 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18423 /* "bgp graceful-restart" command */
18424 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18425 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18427 /* "bgp graceful-restart-disable" command */
18428 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18429 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18431 /* "neighbor a:b:c:d graceful-restart" command */
18432 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18433 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18435 /* "neighbor a:b:c:d graceful-restart-disable" command */
18436 install_element(BGP_NODE
,
18437 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18438 install_element(BGP_NODE
,
18439 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18441 /* "neighbor a:b:c:d graceful-restart-helper" command */
18442 install_element(BGP_NODE
,
18443 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18444 install_element(BGP_NODE
,
18445 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18447 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18448 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18449 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18450 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18451 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18452 install_element(BGP_NODE
,
18453 &no_bgp_graceful_restart_select_defer_time_cmd
);
18454 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18455 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18456 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18458 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18459 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18460 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18461 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18463 /* "bgp graceful-shutdown" commands */
18464 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18465 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18467 /* "bgp hard-administrative-reset" commands */
18468 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18470 /* "bgp long-lived-graceful-restart" commands */
18471 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18472 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18474 /* "bgp fast-external-failover" commands */
18475 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18476 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18478 /* "bgp bestpath compare-routerid" commands */
18479 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18480 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18482 /* "bgp bestpath as-path ignore" commands */
18483 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18484 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18486 /* "bgp bestpath as-path confed" commands */
18487 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18488 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18490 /* "bgp bestpath as-path multipath-relax" commands */
18491 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18492 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18494 /* "bgp bestpath peer-type multipath-relax" commands */
18495 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18496 install_element(BGP_NODE
,
18497 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18499 /* "bgp log-neighbor-changes" commands */
18500 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18501 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18503 /* "bgp bestpath med" commands */
18504 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18505 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18507 /* "bgp bestpath bandwidth" commands */
18508 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18509 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18511 /* "no bgp default <afi>-<safi>" commands. */
18512 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18514 /* "bgp network import-check" commands. */
18515 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18516 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18519 /* "bgp default local-preference" commands. */
18520 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18521 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18523 /* bgp default show-hostname */
18524 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18525 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18527 /* bgp default show-nexthop-hostname */
18528 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18529 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18531 /* "bgp default subgroup-pkt-queue-max" commands. */
18532 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18533 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18535 /* bgp ibgp-allow-policy-mods command */
18536 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18537 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18539 /* "bgp listen limit" commands. */
18540 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18541 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18543 /* "bgp listen range" commands. */
18544 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18545 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18547 /* "bgp default shutdown" command */
18548 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18550 /* "bgp shutdown" commands */
18551 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18552 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18553 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18554 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18556 /* "neighbor remote-as" commands. */
18557 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18558 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18559 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18560 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18561 install_element(BGP_NODE
,
18562 &neighbor_interface_v6only_config_remote_as_cmd
);
18563 install_element(BGP_NODE
, &no_neighbor_cmd
);
18564 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18566 /* "neighbor peer-group" commands. */
18567 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18568 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18569 install_element(BGP_NODE
,
18570 &no_neighbor_interface_peer_group_remote_as_cmd
);
18572 /* "neighbor local-as" commands. */
18573 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18574 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18575 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18576 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18578 /* "neighbor solo" commands. */
18579 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18580 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18582 /* "neighbor password" commands. */
18583 install_element(BGP_NODE
, &neighbor_password_cmd
);
18584 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18586 /* "neighbor activate" commands. */
18587 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18588 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18589 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18590 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18591 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18592 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18593 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18594 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18595 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18596 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18597 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18598 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18600 /* "no neighbor activate" commands. */
18601 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18602 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18603 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18604 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18605 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18606 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18607 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18608 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18609 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18610 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18611 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18612 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18614 /* "neighbor peer-group" set commands. */
18615 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18616 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18617 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18618 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18619 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18620 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18621 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18622 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18623 install_element(BGP_FLOWSPECV4_NODE
,
18624 &neighbor_set_peer_group_hidden_cmd
);
18625 install_element(BGP_FLOWSPECV6_NODE
,
18626 &neighbor_set_peer_group_hidden_cmd
);
18628 /* "no neighbor peer-group unset" commands. */
18629 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18630 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18631 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18632 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18633 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18634 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18635 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18636 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18637 install_element(BGP_FLOWSPECV4_NODE
,
18638 &no_neighbor_set_peer_group_hidden_cmd
);
18639 install_element(BGP_FLOWSPECV6_NODE
,
18640 &no_neighbor_set_peer_group_hidden_cmd
);
18642 /* "neighbor softreconfiguration inbound" commands.*/
18643 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18644 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18645 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18646 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18647 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18648 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18649 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18650 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18651 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18652 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18653 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18654 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18655 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18656 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18657 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18658 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18659 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18660 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18661 install_element(BGP_FLOWSPECV4_NODE
,
18662 &neighbor_soft_reconfiguration_cmd
);
18663 install_element(BGP_FLOWSPECV4_NODE
,
18664 &no_neighbor_soft_reconfiguration_cmd
);
18665 install_element(BGP_FLOWSPECV6_NODE
,
18666 &neighbor_soft_reconfiguration_cmd
);
18667 install_element(BGP_FLOWSPECV6_NODE
,
18668 &no_neighbor_soft_reconfiguration_cmd
);
18669 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18670 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18672 /* "neighbor attribute-unchanged" commands. */
18673 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18674 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18675 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18676 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18677 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18678 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18679 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18680 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18681 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18682 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18683 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18684 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18685 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18686 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18687 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18688 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18689 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18690 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18692 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18693 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18695 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18696 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18697 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18698 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18700 /* "nexthop-local unchanged" commands */
18701 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18702 install_element(BGP_IPV6_NODE
,
18703 &no_neighbor_nexthop_local_unchanged_cmd
);
18705 /* "neighbor next-hop-self" commands. */
18706 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18707 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18708 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18709 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18710 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18711 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18712 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18713 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18714 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18715 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18716 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18717 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18718 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18719 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18720 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18721 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18722 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18723 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18724 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18725 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18727 /* "neighbor next-hop-self force" commands. */
18728 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18729 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18730 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18731 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18732 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18733 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18734 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18735 install_element(BGP_IPV4_NODE
,
18736 &no_neighbor_nexthop_self_all_hidden_cmd
);
18737 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18738 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18739 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18740 install_element(BGP_IPV4M_NODE
,
18741 &no_neighbor_nexthop_self_all_hidden_cmd
);
18742 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18743 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18744 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18745 install_element(BGP_IPV4L_NODE
,
18746 &no_neighbor_nexthop_self_all_hidden_cmd
);
18747 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18748 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18749 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18750 install_element(BGP_IPV6_NODE
,
18751 &no_neighbor_nexthop_self_all_hidden_cmd
);
18752 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18753 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18754 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18755 install_element(BGP_IPV6M_NODE
,
18756 &no_neighbor_nexthop_self_all_hidden_cmd
);
18757 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18758 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18759 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18760 install_element(BGP_IPV6L_NODE
,
18761 &no_neighbor_nexthop_self_all_hidden_cmd
);
18762 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18763 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18764 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18765 install_element(BGP_VPNV4_NODE
,
18766 &no_neighbor_nexthop_self_all_hidden_cmd
);
18767 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18768 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18769 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18770 install_element(BGP_VPNV6_NODE
,
18771 &no_neighbor_nexthop_self_all_hidden_cmd
);
18772 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18773 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18775 /* "neighbor as-override" commands. */
18776 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18777 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18778 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18779 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18780 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18781 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18782 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18783 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18784 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18785 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18786 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18787 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18788 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18789 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18790 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18791 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18792 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18793 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18795 /* "neighbor remove-private-AS" commands. */
18796 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18797 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18798 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18799 install_element(BGP_NODE
,
18800 &no_neighbor_remove_private_as_all_hidden_cmd
);
18801 install_element(BGP_NODE
,
18802 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18803 install_element(BGP_NODE
,
18804 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18805 install_element(BGP_NODE
,
18806 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18809 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18810 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18811 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18812 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18813 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18814 install_element(BGP_IPV4_NODE
,
18815 &neighbor_remove_private_as_replace_as_cmd
);
18816 install_element(BGP_IPV4_NODE
,
18817 &no_neighbor_remove_private_as_replace_as_cmd
);
18818 install_element(BGP_IPV4_NODE
,
18819 &neighbor_remove_private_as_all_replace_as_cmd
);
18820 install_element(BGP_IPV4_NODE
,
18821 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18822 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18823 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18824 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18825 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18826 install_element(BGP_IPV4M_NODE
,
18827 &neighbor_remove_private_as_replace_as_cmd
);
18828 install_element(BGP_IPV4M_NODE
,
18829 &no_neighbor_remove_private_as_replace_as_cmd
);
18830 install_element(BGP_IPV4M_NODE
,
18831 &neighbor_remove_private_as_all_replace_as_cmd
);
18832 install_element(BGP_IPV4M_NODE
,
18833 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18834 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18835 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18836 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18837 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18838 install_element(BGP_IPV4L_NODE
,
18839 &neighbor_remove_private_as_replace_as_cmd
);
18840 install_element(BGP_IPV4L_NODE
,
18841 &no_neighbor_remove_private_as_replace_as_cmd
);
18842 install_element(BGP_IPV4L_NODE
,
18843 &neighbor_remove_private_as_all_replace_as_cmd
);
18844 install_element(BGP_IPV4L_NODE
,
18845 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18846 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18847 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18848 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18849 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18850 install_element(BGP_IPV6_NODE
,
18851 &neighbor_remove_private_as_replace_as_cmd
);
18852 install_element(BGP_IPV6_NODE
,
18853 &no_neighbor_remove_private_as_replace_as_cmd
);
18854 install_element(BGP_IPV6_NODE
,
18855 &neighbor_remove_private_as_all_replace_as_cmd
);
18856 install_element(BGP_IPV6_NODE
,
18857 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18858 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18859 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18860 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18861 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18862 install_element(BGP_IPV6M_NODE
,
18863 &neighbor_remove_private_as_replace_as_cmd
);
18864 install_element(BGP_IPV6M_NODE
,
18865 &no_neighbor_remove_private_as_replace_as_cmd
);
18866 install_element(BGP_IPV6M_NODE
,
18867 &neighbor_remove_private_as_all_replace_as_cmd
);
18868 install_element(BGP_IPV6M_NODE
,
18869 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18870 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18871 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18872 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18873 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18874 install_element(BGP_IPV6L_NODE
,
18875 &neighbor_remove_private_as_replace_as_cmd
);
18876 install_element(BGP_IPV6L_NODE
,
18877 &no_neighbor_remove_private_as_replace_as_cmd
);
18878 install_element(BGP_IPV6L_NODE
,
18879 &neighbor_remove_private_as_all_replace_as_cmd
);
18880 install_element(BGP_IPV6L_NODE
,
18881 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18882 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18883 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18884 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18885 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18886 install_element(BGP_VPNV4_NODE
,
18887 &neighbor_remove_private_as_replace_as_cmd
);
18888 install_element(BGP_VPNV4_NODE
,
18889 &no_neighbor_remove_private_as_replace_as_cmd
);
18890 install_element(BGP_VPNV4_NODE
,
18891 &neighbor_remove_private_as_all_replace_as_cmd
);
18892 install_element(BGP_VPNV4_NODE
,
18893 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18894 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18895 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18896 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18897 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18898 install_element(BGP_VPNV6_NODE
,
18899 &neighbor_remove_private_as_replace_as_cmd
);
18900 install_element(BGP_VPNV6_NODE
,
18901 &no_neighbor_remove_private_as_replace_as_cmd
);
18902 install_element(BGP_VPNV6_NODE
,
18903 &neighbor_remove_private_as_all_replace_as_cmd
);
18904 install_element(BGP_VPNV6_NODE
,
18905 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18907 /* "neighbor send-community" commands.*/
18908 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18909 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18910 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18911 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18912 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18913 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18914 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18915 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18916 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18917 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18918 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18919 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18921 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18922 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18923 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18924 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18925 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18926 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18927 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18928 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18929 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18930 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18931 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18932 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18933 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18934 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18935 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18936 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18937 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18938 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18939 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18940 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18941 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18942 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18943 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18945 /* "neighbor route-reflector" commands.*/
18946 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18947 install_element(BGP_NODE
,
18948 &no_neighbor_route_reflector_client_hidden_cmd
);
18949 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18950 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18951 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18952 install_element(BGP_IPV4M_NODE
,
18953 &no_neighbor_route_reflector_client_cmd
);
18954 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18955 install_element(BGP_IPV4L_NODE
,
18956 &no_neighbor_route_reflector_client_cmd
);
18957 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18958 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18959 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18960 install_element(BGP_IPV6M_NODE
,
18961 &no_neighbor_route_reflector_client_cmd
);
18962 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18963 install_element(BGP_IPV6L_NODE
,
18964 &no_neighbor_route_reflector_client_cmd
);
18965 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18966 install_element(BGP_VPNV4_NODE
,
18967 &no_neighbor_route_reflector_client_cmd
);
18968 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18969 install_element(BGP_VPNV6_NODE
,
18970 &no_neighbor_route_reflector_client_cmd
);
18971 install_element(BGP_FLOWSPECV4_NODE
,
18972 &neighbor_route_reflector_client_cmd
);
18973 install_element(BGP_FLOWSPECV4_NODE
,
18974 &no_neighbor_route_reflector_client_cmd
);
18975 install_element(BGP_FLOWSPECV6_NODE
,
18976 &neighbor_route_reflector_client_cmd
);
18977 install_element(BGP_FLOWSPECV6_NODE
,
18978 &no_neighbor_route_reflector_client_cmd
);
18979 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18980 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18982 /* "neighbor route-server" commands.*/
18983 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18984 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18985 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18986 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18987 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18988 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18989 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18990 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18991 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18992 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18993 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18994 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18995 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18996 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18997 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18998 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18999 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19000 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19001 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19002 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19003 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19004 install_element(BGP_FLOWSPECV4_NODE
,
19005 &no_neighbor_route_server_client_cmd
);
19006 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19007 install_element(BGP_FLOWSPECV6_NODE
,
19008 &no_neighbor_route_server_client_cmd
);
19010 /* "neighbor disable-addpath-rx" commands. */
19011 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19012 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19013 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19014 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19015 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19016 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19017 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19018 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19019 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19020 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19021 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19022 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19023 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19024 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19025 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19026 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19028 /* "neighbor addpath-tx-all-paths" commands.*/
19029 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19030 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19031 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19032 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19033 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19034 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19035 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19036 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19037 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19038 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19039 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19040 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19041 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19042 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19043 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19044 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19045 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19046 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19048 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19049 install_element(BGP_NODE
,
19050 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19051 install_element(BGP_NODE
,
19052 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19053 install_element(BGP_IPV4_NODE
,
19054 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19055 install_element(BGP_IPV4_NODE
,
19056 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19057 install_element(BGP_IPV4M_NODE
,
19058 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19059 install_element(BGP_IPV4M_NODE
,
19060 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19061 install_element(BGP_IPV4L_NODE
,
19062 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19063 install_element(BGP_IPV4L_NODE
,
19064 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19065 install_element(BGP_IPV6_NODE
,
19066 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19067 install_element(BGP_IPV6_NODE
,
19068 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19069 install_element(BGP_IPV6M_NODE
,
19070 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19071 install_element(BGP_IPV6M_NODE
,
19072 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19073 install_element(BGP_IPV6L_NODE
,
19074 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19075 install_element(BGP_IPV6L_NODE
,
19076 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19077 install_element(BGP_VPNV4_NODE
,
19078 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19079 install_element(BGP_VPNV4_NODE
,
19080 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19081 install_element(BGP_VPNV6_NODE
,
19082 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19083 install_element(BGP_VPNV6_NODE
,
19084 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19086 /* "neighbor sender-as-path-loop-detection" commands. */
19087 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19088 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19090 /* "neighbor passive" commands. */
19091 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19092 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19095 /* "neighbor shutdown" commands. */
19096 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19097 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19098 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19099 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19100 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19101 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19103 /* "neighbor capability extended-nexthop" commands.*/
19104 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19105 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19107 /* "neighbor capability orf prefix-list" commands.*/
19108 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19109 install_element(BGP_NODE
,
19110 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19111 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19112 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19113 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19114 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19115 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19116 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19117 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19118 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19119 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19120 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19121 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19122 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19124 /* "neighbor capability dynamic" commands.*/
19125 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19126 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19128 /* "neighbor dont-capability-negotiate" commands. */
19129 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19130 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19132 /* "neighbor ebgp-multihop" commands. */
19133 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19134 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19135 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19137 /* "neighbor disable-connected-check" commands. */
19138 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19139 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19141 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19142 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19143 install_element(BGP_NODE
,
19144 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19146 /* "neighbor extended-optional-parameters" commands. */
19147 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19148 install_element(BGP_NODE
,
19149 &no_neighbor_extended_optional_parameters_cmd
);
19151 /* "neighbor enforce-first-as" commands. */
19152 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19153 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19155 /* "neighbor description" commands. */
19156 install_element(BGP_NODE
, &neighbor_description_cmd
);
19157 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19158 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19160 /* "neighbor update-source" commands. "*/
19161 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19162 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19164 /* "neighbor default-originate" commands. */
19165 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19166 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19167 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19168 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19169 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19170 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19171 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19172 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19173 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19174 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19175 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19176 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19177 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19178 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19179 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19180 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19181 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19182 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19183 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19184 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19185 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19187 /* "neighbor port" commands. */
19188 install_element(BGP_NODE
, &neighbor_port_cmd
);
19189 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19191 /* "neighbor weight" commands. */
19192 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19193 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19195 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19196 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19197 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19198 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19199 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19200 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19201 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19202 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19203 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19204 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19205 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19206 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19207 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19208 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19209 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19210 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19212 /* "neighbor override-capability" commands. */
19213 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19214 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19216 /* "neighbor strict-capability-match" commands. */
19217 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19218 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19220 /* "neighbor timers" commands. */
19221 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19222 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19224 /* "neighbor timers connect" commands. */
19225 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19226 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19228 /* "neighbor timers delayopen" commands. */
19229 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19230 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19232 /* "neighbor advertisement-interval" commands. */
19233 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19234 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19236 /* "neighbor interface" commands. */
19237 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19238 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19240 /* "neighbor distribute" commands. */
19241 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19242 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19243 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19244 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19245 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19246 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19247 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19248 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19249 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19250 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19251 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19252 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19253 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19254 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19255 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19256 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19257 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19258 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19260 /* "neighbor prefix-list" commands. */
19261 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19262 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19263 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19264 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19265 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19266 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19267 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19268 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19269 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19270 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19271 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19272 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19273 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19274 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19275 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19276 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19277 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19278 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19279 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19280 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19281 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19282 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19284 /* "neighbor filter-list" commands. */
19285 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19286 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19287 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19288 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19289 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19290 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19291 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19292 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19293 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19294 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19295 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19296 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19297 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19298 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19299 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19300 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19301 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19302 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19303 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19304 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19305 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19306 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19308 /* "neighbor route-map" commands. */
19309 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19310 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19311 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19312 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19313 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19314 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19315 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19316 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19317 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19318 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19319 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19320 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19321 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19322 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19323 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19324 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19325 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19326 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19327 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19328 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19329 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19330 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19331 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19332 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19334 /* "neighbor unsuppress-map" commands. */
19335 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19336 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19337 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19338 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19339 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19340 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19341 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19342 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19343 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19344 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19345 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19346 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19347 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19348 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19349 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19350 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19351 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19352 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19354 /* "neighbor advertise-map" commands. */
19355 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19356 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19357 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19358 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19359 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19360 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19361 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19362 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19363 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19364 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19366 /* neighbor maximum-prefix-out commands. */
19367 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19368 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19369 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19370 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19371 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19372 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19373 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19374 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19375 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19376 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19377 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19378 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19379 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19380 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19381 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19382 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19383 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19384 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19386 /* "neighbor maximum-prefix" commands. */
19387 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19388 install_element(BGP_NODE
,
19389 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19390 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19391 install_element(BGP_NODE
,
19392 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19393 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19394 install_element(BGP_NODE
,
19395 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19396 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19397 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19398 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19399 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19400 install_element(BGP_IPV4_NODE
,
19401 &neighbor_maximum_prefix_threshold_warning_cmd
);
19402 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19403 install_element(BGP_IPV4_NODE
,
19404 &neighbor_maximum_prefix_threshold_restart_cmd
);
19405 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19406 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19407 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19408 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19409 install_element(BGP_IPV4M_NODE
,
19410 &neighbor_maximum_prefix_threshold_warning_cmd
);
19411 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19412 install_element(BGP_IPV4M_NODE
,
19413 &neighbor_maximum_prefix_threshold_restart_cmd
);
19414 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19415 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19416 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19417 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19418 install_element(BGP_IPV4L_NODE
,
19419 &neighbor_maximum_prefix_threshold_warning_cmd
);
19420 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19421 install_element(BGP_IPV4L_NODE
,
19422 &neighbor_maximum_prefix_threshold_restart_cmd
);
19423 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19424 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19425 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19426 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19427 install_element(BGP_IPV6_NODE
,
19428 &neighbor_maximum_prefix_threshold_warning_cmd
);
19429 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19430 install_element(BGP_IPV6_NODE
,
19431 &neighbor_maximum_prefix_threshold_restart_cmd
);
19432 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19433 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19434 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19435 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19436 install_element(BGP_IPV6M_NODE
,
19437 &neighbor_maximum_prefix_threshold_warning_cmd
);
19438 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19439 install_element(BGP_IPV6M_NODE
,
19440 &neighbor_maximum_prefix_threshold_restart_cmd
);
19441 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19442 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19443 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19444 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19445 install_element(BGP_IPV6L_NODE
,
19446 &neighbor_maximum_prefix_threshold_warning_cmd
);
19447 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19448 install_element(BGP_IPV6L_NODE
,
19449 &neighbor_maximum_prefix_threshold_restart_cmd
);
19450 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19451 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19452 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19453 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19454 install_element(BGP_VPNV4_NODE
,
19455 &neighbor_maximum_prefix_threshold_warning_cmd
);
19456 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19457 install_element(BGP_VPNV4_NODE
,
19458 &neighbor_maximum_prefix_threshold_restart_cmd
);
19459 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19460 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19461 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19462 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19463 install_element(BGP_VPNV6_NODE
,
19464 &neighbor_maximum_prefix_threshold_warning_cmd
);
19465 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19466 install_element(BGP_VPNV6_NODE
,
19467 &neighbor_maximum_prefix_threshold_restart_cmd
);
19468 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19470 /* "neighbor allowas-in" */
19471 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19472 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19473 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19474 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19475 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19476 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19477 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19478 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19479 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19480 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19481 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19482 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19483 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19484 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19485 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19486 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19487 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19488 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19489 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19490 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19492 /* "neighbor soo" */
19493 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19494 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19495 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19496 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19497 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19498 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19499 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19500 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19501 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19502 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19503 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19504 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19505 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19506 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19507 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19508 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19509 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19510 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19512 /* address-family commands. */
19513 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19514 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19515 #ifdef KEEP_OLD_VPN_COMMANDS
19516 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19517 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19518 #endif /* KEEP_OLD_VPN_COMMANDS */
19520 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19522 /* "exit-address-family" command. */
19523 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19524 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19525 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19526 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19527 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19528 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19529 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19530 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19531 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19532 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19533 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19535 /* BGP retain all route-target */
19536 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19537 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19539 /* "clear ip bgp commands" */
19540 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19542 /* clear ip bgp prefix */
19543 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19544 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19545 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19547 /* "show [ip] bgp summary" commands. */
19548 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19549 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19550 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19551 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19552 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19553 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19554 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19556 /* "show [ip] bgp neighbors" commands. */
19557 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19559 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19561 /* "show [ip] bgp peer-group" commands. */
19562 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19564 /* "show [ip] bgp paths" commands. */
19565 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19567 /* "show [ip] bgp community" commands. */
19568 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19570 /* "show ip bgp large-community" commands. */
19571 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19572 /* "show [ip] bgp attribute-info" commands. */
19573 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19574 /* "show [ip] bgp route-leak" command */
19575 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19577 /* "redistribute" commands. */
19578 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19579 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19580 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19581 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19582 install_element(BGP_NODE
,
19583 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19584 install_element(BGP_NODE
,
19585 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19586 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19587 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19588 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19589 install_element(BGP_NODE
,
19590 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19591 install_element(BGP_NODE
,
19592 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19593 install_element(BGP_NODE
,
19594 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19595 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19596 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19597 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19598 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19599 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19600 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19601 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19602 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19603 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19604 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19605 install_element(BGP_IPV4_NODE
,
19606 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19607 install_element(BGP_IPV4_NODE
,
19608 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19609 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19610 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19611 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19612 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19613 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19614 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19616 /* import|export vpn [route-map RMAP_NAME] */
19617 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19618 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19620 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19621 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19623 /* ttl_security commands */
19624 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19625 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19627 /* "bgp tcp-keepalive" commands */
19628 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19629 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19631 /* "show [ip] bgp memory" commands. */
19632 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19634 /* "show bgp martian next-hop" */
19635 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19637 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19639 /* "show [ip] bgp views" commands. */
19640 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19642 /* "show [ip] bgp vrfs" commands. */
19643 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19645 /* Community-list. */
19646 community_list_vty();
19648 community_alias_vty();
19650 /* vpn-policy commands */
19651 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19652 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19653 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19654 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19655 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19656 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19657 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19658 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19659 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19660 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19661 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19662 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19664 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19665 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19667 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19668 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19669 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19670 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19671 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19672 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19673 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19674 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19675 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19676 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19678 /* tcp-mss command */
19679 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19680 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19682 /* srv6 commands */
19683 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19684 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19685 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19686 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19687 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19688 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19689 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19694 #include "memory.h"
19695 #include "bgp_regex.h"
19696 #include "bgp_clist.h"
19697 #include "bgp_ecommunity.h"
19699 /* VTY functions. */
19701 /* Direction value to string conversion. */
19702 static const char *community_direct_str(int direct
)
19705 case COMMUNITY_DENY
:
19707 case COMMUNITY_PERMIT
:
19714 /* Display error string. */
19715 static void community_list_perror(struct vty
*vty
, int ret
)
19718 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19719 vty_out(vty
, "%% Can't find community-list\n");
19721 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19722 vty_out(vty
, "%% Malformed community-list value\n");
19724 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19726 "%% Community name conflict, previously defined as standard community\n");
19728 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19730 "%% Community name conflict, previously defined as expanded community\n");
19735 /* "community-list" keyword help string. */
19736 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19738 /*community-list standard */
19739 DEFUN (community_list_standard
,
19740 bgp_community_list_standard_cmd
,
19741 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19744 "Community list number (standard)\n"
19745 "Add an standard community-list entry\n"
19746 "Community list name\n"
19747 "Sequence number of an entry\n"
19748 "Sequence number\n"
19749 "Specify community to reject\n"
19750 "Specify community to accept\n"
19753 char *cl_name_or_number
= NULL
;
19756 int style
= COMMUNITY_LIST_STANDARD
;
19759 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19760 seq
= argv
[idx
]->arg
;
19763 argv_find(argv
, argc
, "(1-99)", &idx
);
19764 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19765 cl_name_or_number
= argv
[idx
]->arg
;
19766 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19768 argv_find(argv
, argc
, "AA:NN", &idx
);
19769 char *str
= argv_concat(argv
, argc
, idx
);
19771 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19774 XFREE(MTYPE_TMP
, str
);
19777 /* Display error string. */
19778 community_list_perror(vty
, ret
);
19779 return CMD_WARNING_CONFIG_FAILED
;
19782 return CMD_SUCCESS
;
19785 DEFUN (no_community_list_standard_all
,
19786 no_bgp_community_list_standard_all_cmd
,
19787 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19791 "Community list number (standard)\n"
19792 "Add an standard community-list entry\n"
19793 "Community list name\n"
19794 "Sequence number of an entry\n"
19795 "Sequence number\n"
19796 "Specify community to reject\n"
19797 "Specify community to accept\n"
19800 char *cl_name_or_number
= NULL
;
19803 int style
= COMMUNITY_LIST_STANDARD
;
19807 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19808 seq
= argv
[idx
]->arg
;
19811 argv_find(argv
, argc
, "permit", &idx
);
19812 argv_find(argv
, argc
, "deny", &idx
);
19815 direct
= argv_find(argv
, argc
, "permit", &idx
)
19820 argv_find(argv
, argc
, "AA:NN", &idx
);
19821 str
= argv_concat(argv
, argc
, idx
);
19825 argv_find(argv
, argc
, "(1-99)", &idx
);
19826 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19827 cl_name_or_number
= argv
[idx
]->arg
;
19829 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19832 XFREE(MTYPE_TMP
, str
);
19835 community_list_perror(vty
, ret
);
19836 return CMD_WARNING_CONFIG_FAILED
;
19839 return CMD_SUCCESS
;
19842 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19843 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19844 NO_STR BGP_STR COMMUNITY_LIST_STR
19845 "Community list number (standard)\n"
19846 "Add an standard community-list entry\n"
19847 "Community list name\n")
19849 /*community-list expanded */
19850 DEFUN (community_list_expanded_all
,
19851 bgp_community_list_expanded_all_cmd
,
19852 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19855 "Community list number (expanded)\n"
19856 "Add an expanded community-list entry\n"
19857 "Community list name\n"
19858 "Sequence number of an entry\n"
19859 "Sequence number\n"
19860 "Specify community to reject\n"
19861 "Specify community to accept\n"
19864 char *cl_name_or_number
= NULL
;
19867 int style
= COMMUNITY_LIST_EXPANDED
;
19870 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19871 seq
= argv
[idx
]->arg
;
19875 argv_find(argv
, argc
, "(100-500)", &idx
);
19876 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19877 cl_name_or_number
= argv
[idx
]->arg
;
19878 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19880 argv_find(argv
, argc
, "AA:NN", &idx
);
19881 char *str
= argv_concat(argv
, argc
, idx
);
19883 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19886 XFREE(MTYPE_TMP
, str
);
19889 /* Display error string. */
19890 community_list_perror(vty
, ret
);
19891 return CMD_WARNING_CONFIG_FAILED
;
19894 return CMD_SUCCESS
;
19897 DEFUN (no_community_list_expanded_all
,
19898 no_bgp_community_list_expanded_all_cmd
,
19899 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19903 "Community list number (expanded)\n"
19904 "Add an expanded community-list entry\n"
19905 "Community list name\n"
19906 "Sequence number of an entry\n"
19907 "Sequence number\n"
19908 "Specify community to reject\n"
19909 "Specify community to accept\n"
19912 char *cl_name_or_number
= NULL
;
19916 int style
= COMMUNITY_LIST_EXPANDED
;
19919 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19920 seq
= argv
[idx
]->arg
;
19923 argv_find(argv
, argc
, "permit", &idx
);
19924 argv_find(argv
, argc
, "deny", &idx
);
19927 direct
= argv_find(argv
, argc
, "permit", &idx
)
19932 argv_find(argv
, argc
, "AA:NN", &idx
);
19933 str
= argv_concat(argv
, argc
, idx
);
19937 argv_find(argv
, argc
, "(100-500)", &idx
);
19938 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19939 cl_name_or_number
= argv
[idx
]->arg
;
19941 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19944 XFREE(MTYPE_TMP
, str
);
19947 community_list_perror(vty
, ret
);
19948 return CMD_WARNING_CONFIG_FAILED
;
19951 return CMD_SUCCESS
;
19954 ALIAS(no_community_list_expanded_all
,
19955 no_bgp_community_list_expanded_all_list_cmd
,
19956 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19957 NO_STR BGP_STR COMMUNITY_LIST_STR
19958 "Community list number (expanded)\n"
19959 "Add an expanded community-list entry\n"
19960 "Community list name\n")
19962 /* Return configuration string of community-list entry. */
19963 static const char *community_list_config_str(struct community_entry
*entry
)
19970 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19971 str
= community_str(entry
->u
.com
, false, false);
19972 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19973 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19975 str
= entry
->config
;
19980 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19982 struct community_entry
*entry
;
19984 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19985 if (entry
== list
->head
) {
19986 if (all_digit(list
->name
))
19987 vty_out(vty
, "Community %s list %s\n",
19988 entry
->style
== COMMUNITY_LIST_STANDARD
19990 : "(expanded) access",
19993 vty_out(vty
, "Named Community %s list %s\n",
19994 entry
->style
== COMMUNITY_LIST_STANDARD
20000 vty_out(vty
, " %s\n",
20001 community_direct_str(entry
->direct
));
20003 vty_out(vty
, " %s %s\n",
20004 community_direct_str(entry
->direct
),
20005 community_list_config_str(entry
));
20009 DEFUN (show_community_list
,
20010 show_bgp_community_list_cmd
,
20011 "show bgp community-list",
20014 "List community-list\n")
20016 struct community_list
*list
;
20017 struct community_list_master
*cm
;
20019 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20021 return CMD_SUCCESS
;
20023 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20024 community_list_show(vty
, list
);
20026 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20027 community_list_show(vty
, list
);
20029 return CMD_SUCCESS
;
20032 DEFUN (show_community_list_arg
,
20033 show_bgp_community_list_arg_cmd
,
20034 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20037 "List community-list\n"
20038 "Community-list number\n"
20039 "Community-list name\n"
20040 "Detailed information on community-list\n")
20042 int idx_comm_list
= 3;
20043 struct community_list
*list
;
20045 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20046 COMMUNITY_LIST_MASTER
);
20048 vty_out(vty
, "%% Can't find community-list\n");
20049 return CMD_WARNING
;
20052 community_list_show(vty
, list
);
20054 return CMD_SUCCESS
;
20058 * Large Community code.
20060 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20061 struct cmd_token
**argv
, int style
,
20062 int reject_all_digit_name
)
20071 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20072 seq
= argv
[idx
]->arg
;
20075 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20078 /* All digit name check. */
20080 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20081 argv_find(argv
, argc
, "(1-99)", &idx
);
20082 argv_find(argv
, argc
, "(100-500)", &idx
);
20083 cl_name
= argv
[idx
]->arg
;
20084 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20085 vty_out(vty
, "%% Community name cannot have all digits\n");
20086 return CMD_WARNING_CONFIG_FAILED
;
20090 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20091 argv_find(argv
, argc
, "LINE", &idx
);
20092 /* Concat community string argument. */
20094 str
= argv_concat(argv
, argc
, idx
);
20098 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20100 /* Free temporary community list string allocated by
20102 XFREE(MTYPE_TMP
, str
);
20105 community_list_perror(vty
, ret
);
20106 return CMD_WARNING_CONFIG_FAILED
;
20108 return CMD_SUCCESS
;
20111 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20112 struct cmd_token
**argv
, int style
)
20120 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20121 seq
= argv
[idx
]->arg
;
20124 argv_find(argv
, argc
, "permit", &idx
);
20125 argv_find(argv
, argc
, "deny", &idx
);
20128 /* Check the list direct. */
20129 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20130 direct
= COMMUNITY_PERMIT
;
20132 direct
= COMMUNITY_DENY
;
20135 argv_find(argv
, argc
, "LINE", &idx
);
20136 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20137 /* Concat community string argument. */
20138 str
= argv_concat(argv
, argc
, idx
);
20142 argv_find(argv
, argc
, "(1-99)", &idx
);
20143 argv_find(argv
, argc
, "(100-500)", &idx
);
20144 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20146 /* Unset community list. */
20147 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20150 /* Free temporary community list string allocated by
20152 XFREE(MTYPE_TMP
, str
);
20155 community_list_perror(vty
, ret
);
20156 return CMD_WARNING_CONFIG_FAILED
;
20159 return CMD_SUCCESS
;
20162 /* "large-community-list" keyword help string. */
20163 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20164 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20166 DEFUN (lcommunity_list_standard
,
20167 bgp_lcommunity_list_standard_cmd
,
20168 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20170 LCOMMUNITY_LIST_STR
20171 "Large Community list number (standard)\n"
20172 "Sequence number of an entry\n"
20173 "Sequence number\n"
20174 "Specify large community to reject\n"
20175 "Specify large community to accept\n"
20176 LCOMMUNITY_VAL_STR
)
20178 return lcommunity_list_set_vty(vty
, argc
, argv
,
20179 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20182 DEFUN (lcommunity_list_expanded
,
20183 bgp_lcommunity_list_expanded_cmd
,
20184 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20186 LCOMMUNITY_LIST_STR
20187 "Large Community list number (expanded)\n"
20188 "Sequence number of an entry\n"
20189 "Sequence number\n"
20190 "Specify large community to reject\n"
20191 "Specify large community to accept\n"
20192 "An ordered list as a regular-expression\n")
20194 return lcommunity_list_set_vty(vty
, argc
, argv
,
20195 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20198 DEFUN (lcommunity_list_name_standard
,
20199 bgp_lcommunity_list_name_standard_cmd
,
20200 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20202 LCOMMUNITY_LIST_STR
20203 "Specify standard large-community-list\n"
20204 "Large Community list name\n"
20205 "Sequence number of an entry\n"
20206 "Sequence number\n"
20207 "Specify large community to reject\n"
20208 "Specify large community to accept\n"
20209 LCOMMUNITY_VAL_STR
)
20211 return lcommunity_list_set_vty(vty
, argc
, argv
,
20212 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20215 DEFUN (lcommunity_list_name_expanded
,
20216 bgp_lcommunity_list_name_expanded_cmd
,
20217 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20219 LCOMMUNITY_LIST_STR
20220 "Specify expanded large-community-list\n"
20221 "Large Community list name\n"
20222 "Sequence number of an entry\n"
20223 "Sequence number\n"
20224 "Specify large community to reject\n"
20225 "Specify large community to accept\n"
20226 "An ordered list as a regular-expression\n")
20228 return lcommunity_list_set_vty(vty
, argc
, argv
,
20229 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20232 DEFUN (no_lcommunity_list_all
,
20233 no_bgp_lcommunity_list_all_cmd
,
20234 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20237 LCOMMUNITY_LIST_STR
20238 "Large Community list number (standard)\n"
20239 "Large Community list number (expanded)\n"
20240 "Large Community list name\n")
20242 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20243 LARGE_COMMUNITY_LIST_STANDARD
);
20246 DEFUN (no_lcommunity_list_name_standard_all
,
20247 no_bgp_lcommunity_list_name_standard_all_cmd
,
20248 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20251 LCOMMUNITY_LIST_STR
20252 "Specify standard large-community-list\n"
20253 "Large Community list name\n")
20255 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20256 LARGE_COMMUNITY_LIST_STANDARD
);
20259 DEFUN (no_lcommunity_list_name_expanded_all
,
20260 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20261 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20264 LCOMMUNITY_LIST_STR
20265 "Specify expanded large-community-list\n"
20266 "Large Community list name\n")
20268 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20269 LARGE_COMMUNITY_LIST_EXPANDED
);
20272 DEFUN (no_lcommunity_list_standard
,
20273 no_bgp_lcommunity_list_standard_cmd
,
20274 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20277 LCOMMUNITY_LIST_STR
20278 "Large Community list number (standard)\n"
20279 "Sequence number of an entry\n"
20280 "Sequence number\n"
20281 "Specify large community to reject\n"
20282 "Specify large community to accept\n"
20283 LCOMMUNITY_VAL_STR
)
20285 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20286 LARGE_COMMUNITY_LIST_STANDARD
);
20289 DEFUN (no_lcommunity_list_expanded
,
20290 no_bgp_lcommunity_list_expanded_cmd
,
20291 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20294 LCOMMUNITY_LIST_STR
20295 "Large Community list number (expanded)\n"
20296 "Sequence number of an entry\n"
20297 "Sequence number\n"
20298 "Specify large community to reject\n"
20299 "Specify large community to accept\n"
20300 "An ordered list as a regular-expression\n")
20302 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20303 LARGE_COMMUNITY_LIST_EXPANDED
);
20306 DEFUN (no_lcommunity_list_name_standard
,
20307 no_bgp_lcommunity_list_name_standard_cmd
,
20308 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20311 LCOMMUNITY_LIST_STR
20312 "Specify standard large-community-list\n"
20313 "Large Community list name\n"
20314 "Sequence number of an entry\n"
20315 "Sequence number\n"
20316 "Specify large community to reject\n"
20317 "Specify large community to accept\n"
20318 LCOMMUNITY_VAL_STR
)
20320 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20321 LARGE_COMMUNITY_LIST_STANDARD
);
20324 DEFUN (no_lcommunity_list_name_expanded
,
20325 no_bgp_lcommunity_list_name_expanded_cmd
,
20326 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20329 LCOMMUNITY_LIST_STR
20330 "Specify expanded large-community-list\n"
20331 "Large community list name\n"
20332 "Sequence number of an entry\n"
20333 "Sequence number\n"
20334 "Specify large community to reject\n"
20335 "Specify large community to accept\n"
20336 "An ordered list as a regular-expression\n")
20338 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20339 LARGE_COMMUNITY_LIST_EXPANDED
);
20342 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20344 struct community_entry
*entry
;
20346 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20347 if (entry
== list
->head
) {
20348 if (all_digit(list
->name
))
20349 vty_out(vty
, "Large community %s list %s\n",
20351 LARGE_COMMUNITY_LIST_STANDARD
20353 : "(expanded) access",
20357 "Named large community %s list %s\n",
20359 LARGE_COMMUNITY_LIST_STANDARD
20365 vty_out(vty
, " %s\n",
20366 community_direct_str(entry
->direct
));
20368 vty_out(vty
, " %s %s\n",
20369 community_direct_str(entry
->direct
),
20370 community_list_config_str(entry
));
20374 DEFUN (show_lcommunity_list
,
20375 show_bgp_lcommunity_list_cmd
,
20376 "show bgp large-community-list",
20379 "List large-community list\n")
20381 struct community_list
*list
;
20382 struct community_list_master
*cm
;
20384 cm
= community_list_master_lookup(bgp_clist
,
20385 LARGE_COMMUNITY_LIST_MASTER
);
20387 return CMD_SUCCESS
;
20389 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20390 lcommunity_list_show(vty
, list
);
20392 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20393 lcommunity_list_show(vty
, list
);
20395 return CMD_SUCCESS
;
20398 DEFUN (show_lcommunity_list_arg
,
20399 show_bgp_lcommunity_list_arg_cmd
,
20400 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20403 "List large-community list\n"
20404 "Large-community-list number\n"
20405 "Large-community-list name\n"
20406 "Detailed information on large-community-list\n")
20408 struct community_list
*list
;
20410 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20411 LARGE_COMMUNITY_LIST_MASTER
);
20413 vty_out(vty
, "%% Can't find large-community-list\n");
20414 return CMD_WARNING
;
20417 lcommunity_list_show(vty
, list
);
20419 return CMD_SUCCESS
;
20422 /* "extcommunity-list" keyword help string. */
20423 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20424 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20426 DEFUN (extcommunity_list_standard
,
20427 bgp_extcommunity_list_standard_cmd
,
20428 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20430 EXTCOMMUNITY_LIST_STR
20431 "Extended Community list number (standard)\n"
20432 "Specify standard extcommunity-list\n"
20433 "Community list name\n"
20434 "Sequence number of an entry\n"
20435 "Sequence number\n"
20436 "Specify community to reject\n"
20437 "Specify community to accept\n"
20438 EXTCOMMUNITY_VAL_STR
)
20440 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20442 char *cl_number_or_name
= NULL
;
20447 argv_find(argv
, argc
, "(1-99)", &idx
);
20448 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20449 cl_number_or_name
= argv
[idx
]->arg
;
20451 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20452 seq
= argv
[idx
]->arg
;
20454 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20456 argv_find(argv
, argc
, "AA:NN", &idx
);
20457 char *str
= argv_concat(argv
, argc
, idx
);
20459 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20462 XFREE(MTYPE_TMP
, str
);
20465 community_list_perror(vty
, ret
);
20466 return CMD_WARNING_CONFIG_FAILED
;
20469 return CMD_SUCCESS
;
20472 DEFUN (extcommunity_list_name_expanded
,
20473 bgp_extcommunity_list_name_expanded_cmd
,
20474 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20476 EXTCOMMUNITY_LIST_STR
20477 "Extended Community list number (expanded)\n"
20478 "Specify expanded extcommunity-list\n"
20479 "Extended Community list name\n"
20480 "Sequence number of an entry\n"
20481 "Sequence number\n"
20482 "Specify community to reject\n"
20483 "Specify community to accept\n"
20484 "An ordered list as a regular-expression\n")
20486 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20488 char *cl_number_or_name
= NULL
;
20492 argv_find(argv
, argc
, "(100-500)", &idx
);
20493 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20494 cl_number_or_name
= argv
[idx
]->arg
;
20496 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20497 seq
= argv
[idx
]->arg
;
20499 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20501 argv_find(argv
, argc
, "LINE", &idx
);
20502 char *str
= argv_concat(argv
, argc
, idx
);
20504 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20507 XFREE(MTYPE_TMP
, str
);
20510 community_list_perror(vty
, ret
);
20511 return CMD_WARNING_CONFIG_FAILED
;
20514 return CMD_SUCCESS
;
20517 DEFUN (no_extcommunity_list_standard_all
,
20518 no_bgp_extcommunity_list_standard_all_cmd
,
20519 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20522 EXTCOMMUNITY_LIST_STR
20523 "Extended Community list number (standard)\n"
20524 "Specify standard extcommunity-list\n"
20525 "Community list name\n"
20526 "Sequence number of an entry\n"
20527 "Sequence number\n"
20528 "Specify community to reject\n"
20529 "Specify community to accept\n"
20530 EXTCOMMUNITY_VAL_STR
)
20532 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20534 char *cl_number_or_name
= NULL
;
20539 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20540 seq
= argv
[idx
]->arg
;
20543 argv_find(argv
, argc
, "permit", &idx
);
20544 argv_find(argv
, argc
, "deny", &idx
);
20546 direct
= argv_find(argv
, argc
, "permit", &idx
)
20551 argv_find(argv
, argc
, "AA:NN", &idx
);
20552 str
= argv_concat(argv
, argc
, idx
);
20556 argv_find(argv
, argc
, "(1-99)", &idx
);
20557 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20558 cl_number_or_name
= argv
[idx
]->arg
;
20560 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20561 seq
, direct
, style
);
20563 XFREE(MTYPE_TMP
, str
);
20566 community_list_perror(vty
, ret
);
20567 return CMD_WARNING_CONFIG_FAILED
;
20570 return CMD_SUCCESS
;
20573 ALIAS(no_extcommunity_list_standard_all
,
20574 no_bgp_extcommunity_list_standard_all_list_cmd
,
20575 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20576 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20577 "Extended Community list number (standard)\n"
20578 "Specify standard extcommunity-list\n"
20579 "Community list name\n")
20581 DEFUN (no_extcommunity_list_expanded_all
,
20582 no_bgp_extcommunity_list_expanded_all_cmd
,
20583 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20586 EXTCOMMUNITY_LIST_STR
20587 "Extended Community list number (expanded)\n"
20588 "Specify expanded extcommunity-list\n"
20589 "Extended Community list name\n"
20590 "Sequence number of an entry\n"
20591 "Sequence number\n"
20592 "Specify community to reject\n"
20593 "Specify community to accept\n"
20594 "An ordered list as a regular-expression\n")
20596 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20598 char *cl_number_or_name
= NULL
;
20603 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20604 seq
= argv
[idx
]->arg
;
20607 argv_find(argv
, argc
, "permit", &idx
);
20608 argv_find(argv
, argc
, "deny", &idx
);
20611 direct
= argv_find(argv
, argc
, "permit", &idx
)
20616 argv_find(argv
, argc
, "LINE", &idx
);
20617 str
= argv_concat(argv
, argc
, idx
);
20621 argv_find(argv
, argc
, "(100-500)", &idx
);
20622 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20623 cl_number_or_name
= argv
[idx
]->arg
;
20625 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20626 seq
, direct
, style
);
20628 XFREE(MTYPE_TMP
, str
);
20631 community_list_perror(vty
, ret
);
20632 return CMD_WARNING_CONFIG_FAILED
;
20635 return CMD_SUCCESS
;
20638 ALIAS(no_extcommunity_list_expanded_all
,
20639 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20640 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20641 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20642 "Extended Community list number (expanded)\n"
20643 "Specify expanded extcommunity-list\n"
20644 "Extended Community list name\n")
20646 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20648 struct community_entry
*entry
;
20650 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20651 if (entry
== list
->head
) {
20652 if (all_digit(list
->name
))
20653 vty_out(vty
, "Extended community %s list %s\n",
20654 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20656 : "(expanded) access",
20660 "Named extended community %s list %s\n",
20661 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20667 vty_out(vty
, " %s\n",
20668 community_direct_str(entry
->direct
));
20670 vty_out(vty
, " %s %s\n",
20671 community_direct_str(entry
->direct
),
20672 community_list_config_str(entry
));
20676 DEFUN (show_extcommunity_list
,
20677 show_bgp_extcommunity_list_cmd
,
20678 "show bgp extcommunity-list",
20681 "List extended-community list\n")
20683 struct community_list
*list
;
20684 struct community_list_master
*cm
;
20686 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20688 return CMD_SUCCESS
;
20690 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20691 extcommunity_list_show(vty
, list
);
20693 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20694 extcommunity_list_show(vty
, list
);
20696 return CMD_SUCCESS
;
20699 DEFUN (show_extcommunity_list_arg
,
20700 show_bgp_extcommunity_list_arg_cmd
,
20701 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20704 "List extended-community list\n"
20705 "Extcommunity-list number\n"
20706 "Extcommunity-list name\n"
20707 "Detailed information on extcommunity-list\n")
20709 int idx_comm_list
= 3;
20710 struct community_list
*list
;
20712 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20713 EXTCOMMUNITY_LIST_MASTER
);
20715 vty_out(vty
, "%% Can't find extcommunity-list\n");
20716 return CMD_WARNING
;
20719 extcommunity_list_show(vty
, list
);
20721 return CMD_SUCCESS
;
20724 /* Display community-list and extcommunity-list configuration. */
20725 static int community_list_config_write(struct vty
*vty
)
20727 struct community_list
*list
;
20728 struct community_entry
*entry
;
20729 struct community_list_master
*cm
;
20732 /* Community-list. */
20733 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20735 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20736 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20738 "bgp community-list %s seq %" PRId64
" %s %s\n",
20739 list
->name
, entry
->seq
,
20740 community_direct_str(entry
->direct
),
20741 community_list_config_str(entry
));
20744 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20745 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20747 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20748 entry
->style
== COMMUNITY_LIST_STANDARD
20751 list
->name
, entry
->seq
,
20752 community_direct_str(entry
->direct
),
20753 community_list_config_str(entry
));
20757 /* Extcommunity-list. */
20758 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20760 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20761 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20763 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20764 list
->name
, entry
->seq
,
20765 community_direct_str(entry
->direct
),
20766 community_list_config_str(entry
));
20769 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20770 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20772 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20773 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20776 list
->name
, entry
->seq
,
20777 community_direct_str(entry
->direct
),
20778 community_list_config_str(entry
));
20783 /* lcommunity-list. */
20784 cm
= community_list_master_lookup(bgp_clist
,
20785 LARGE_COMMUNITY_LIST_MASTER
);
20787 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20788 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20790 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20791 list
->name
, entry
->seq
,
20792 community_direct_str(entry
->direct
),
20793 community_list_config_str(entry
));
20796 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20797 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20799 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20801 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20804 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20805 community_list_config_str(entry
));
20812 static int community_list_config_write(struct vty
*vty
);
20813 static struct cmd_node community_list_node
= {
20814 .name
= "community list",
20815 .node
= COMMUNITY_LIST_NODE
,
20817 .config_write
= community_list_config_write
,
20820 static void community_list_vty(void)
20822 install_node(&community_list_node
);
20824 /* Community-list. */
20825 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20826 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20827 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20828 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20829 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20830 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20831 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20832 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20834 /* Extcommunity-list. */
20835 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20836 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20837 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20838 install_element(CONFIG_NODE
,
20839 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20840 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20841 install_element(CONFIG_NODE
,
20842 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20843 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20844 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20846 /* Large Community List */
20847 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20848 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20849 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20850 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20851 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20852 install_element(CONFIG_NODE
,
20853 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20854 install_element(CONFIG_NODE
,
20855 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20856 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20857 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20858 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20859 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20860 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20861 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20863 bgp_community_list_command_completion_setup();
20866 static struct cmd_node community_alias_node
= {
20867 .name
= "community alias",
20868 .node
= COMMUNITY_ALIAS_NODE
,
20870 .config_write
= bgp_community_alias_write
,
20873 void community_alias_vty(void)
20875 install_node(&community_alias_node
);
20877 /* Community-list. */
20878 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20880 bgp_community_alias_command_completion_setup();