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"
44 #include "bgpd/bgpd.h"
45 #include "bgpd/bgp_attr_evpn.h"
46 #include "bgpd/bgp_advertise.h"
47 #include "bgpd/bgp_attr.h"
48 #include "bgpd/bgp_aspath.h"
49 #include "bgpd/bgp_community.h"
50 #include "bgpd/bgp_community_alias.h"
51 #include "bgpd/bgp_ecommunity.h"
52 #include "bgpd/bgp_lcommunity.h"
53 #include "bgpd/bgp_damp.h"
54 #include "bgpd/bgp_debug.h"
55 #include "bgpd/bgp_errors.h"
56 #include "bgpd/bgp_fsm.h"
57 #include "bgpd/bgp_nht.h"
58 #include "bgpd/bgp_nexthop.h"
59 #include "bgpd/bgp_network.h"
60 #include "bgpd/bgp_open.h"
61 #include "bgpd/bgp_regex.h"
62 #include "bgpd/bgp_route.h"
63 #include "bgpd/bgp_mplsvpn.h"
64 #include "bgpd/bgp_zebra.h"
65 #include "bgpd/bgp_table.h"
66 #include "bgpd/bgp_vty.h"
67 #include "bgpd/bgp_mpath.h"
68 #include "bgpd/bgp_packet.h"
69 #include "bgpd/bgp_updgrp.h"
70 #include "bgpd/bgp_bfd.h"
71 #include "bgpd/bgp_io.h"
72 #include "bgpd/bgp_evpn.h"
73 #include "bgpd/bgp_evpn_vty.h"
74 #include "bgpd/bgp_evpn_mh.h"
75 #include "bgpd/bgp_addpath.h"
76 #include "bgpd/bgp_mac.h"
77 #include "bgpd/bgp_flowspec.h"
78 #include "bgpd/bgp_conditional_adv.h"
80 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
83 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
86 .match_profile
= "traditional",
87 .match_version
= "< 7.4",
91 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
92 { .val_bool
= true, .match_profile
= "datacenter", },
93 { .val_bool
= false },
95 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
96 { .val_bool
= true, .match_profile
= "datacenter", },
97 { .val_bool
= false },
99 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
100 { .val_bool
= true, .match_profile
= "datacenter", },
101 { .val_bool
= false },
103 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
104 { .val_bool
= true, .match_profile
= "datacenter", },
105 { .val_bool
= false },
107 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
108 { .val_ulong
= 10, .match_profile
= "datacenter", },
109 { .val_ulong
= 120 },
111 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
112 { .val_ulong
= 9, .match_profile
= "datacenter", },
113 { .val_ulong
= 180 },
115 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
116 { .val_ulong
= 3, .match_profile
= "datacenter", },
119 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
120 { .val_bool
= false, .match_profile
= "datacenter", },
121 { .val_bool
= false, .match_version
= "< 7.4", },
122 { .val_bool
= true },
124 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
125 { .val_bool
= false, .match_version
= "< 7.6", },
126 { .val_bool
= true },
128 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
129 { .val_bool
= false, .match_version
= "< 8.3", },
130 { .val_bool
= true },
132 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
133 { .val_bool
= false, .match_version
= "< 8.3", },
134 { .val_bool
= true },
137 DEFINE_HOOK(bgp_inst_config_write
,
138 (struct bgp
*bgp
, struct vty
*vty
),
140 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
141 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
143 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
144 struct prefix
*range
, int exact
);
146 /* Show BGP peer's information. */
156 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
157 struct prefix
*range
, int exact
);
159 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
162 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
165 afi_t afi
, bool use_json
);
167 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
173 return BGP_IPV4_NODE
;
175 return BGP_IPV4M_NODE
;
176 case SAFI_LABELED_UNICAST
:
177 return BGP_IPV4L_NODE
;
179 return BGP_VPNV4_NODE
;
181 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
193 return BGP_IPV6_NODE
;
195 return BGP_IPV6M_NODE
;
196 case SAFI_LABELED_UNICAST
:
197 return BGP_IPV6L_NODE
;
199 return BGP_VPNV6_NODE
;
201 return BGP_FLOWSPECV6_NODE
;
206 /* not expected and the return value seems wrong */
207 return BGP_IPV4_NODE
;
211 return BGP_EVPN_NODE
;
214 // We should never be here but to clarify the switch statement..
215 return BGP_IPV4_NODE
;
218 // Impossible to happen
219 return BGP_IPV4_NODE
;
222 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
225 if (safi
== SAFI_UNICAST
)
226 return "IPv4 Unicast";
227 if (safi
== SAFI_MULTICAST
)
228 return "IPv4 Multicast";
229 if (safi
== SAFI_LABELED_UNICAST
)
230 return "IPv4 Labeled Unicast";
231 if (safi
== SAFI_MPLS_VPN
)
233 if (safi
== SAFI_ENCAP
)
235 if (safi
== SAFI_FLOWSPEC
)
236 return "IPv4 Flowspec";
237 } else if (afi
== AFI_IP6
) {
238 if (safi
== SAFI_UNICAST
)
239 return "IPv6 Unicast";
240 if (safi
== SAFI_MULTICAST
)
241 return "IPv6 Multicast";
242 if (safi
== SAFI_LABELED_UNICAST
)
243 return "IPv6 Labeled Unicast";
244 if (safi
== SAFI_MPLS_VPN
)
246 if (safi
== SAFI_ENCAP
)
248 if (safi
== SAFI_FLOWSPEC
)
249 return "IPv6 Flowspec";
250 } else if (afi
== AFI_L2VPN
) {
251 if (safi
== SAFI_EVPN
)
259 * Please note that we have intentionally camelCased
260 * the return strings here. So if you want
261 * to use this function, please ensure you
262 * are doing this within json output
264 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
267 if (safi
== SAFI_UNICAST
)
268 return "ipv4Unicast";
269 if (safi
== SAFI_MULTICAST
)
270 return "ipv4Multicast";
271 if (safi
== SAFI_LABELED_UNICAST
)
272 return "ipv4LabeledUnicast";
273 if (safi
== SAFI_MPLS_VPN
)
275 if (safi
== SAFI_ENCAP
)
277 if (safi
== SAFI_FLOWSPEC
)
278 return "ipv4Flowspec";
279 } else if (afi
== AFI_IP6
) {
280 if (safi
== SAFI_UNICAST
)
281 return "ipv6Unicast";
282 if (safi
== SAFI_MULTICAST
)
283 return "ipv6Multicast";
284 if (safi
== SAFI_LABELED_UNICAST
)
285 return "ipv6LabeledUnicast";
286 if (safi
== SAFI_MPLS_VPN
)
288 if (safi
== SAFI_ENCAP
)
290 if (safi
== SAFI_FLOWSPEC
)
291 return "ipv6Flowspec";
292 } else if (afi
== AFI_L2VPN
) {
293 if (safi
== SAFI_EVPN
)
300 /* unset srv6 locator */
301 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
304 struct listnode
*node
, *nnode
;
305 struct srv6_locator_chunk
*chunk
;
306 struct bgp_srv6_function
*func
;
309 /* release chunk notification via ZAPI */
310 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
311 bgp
->srv6_locator_name
);
316 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
317 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
318 srv6_locator_chunk_free(&chunk
);
321 /* refresh functions */
322 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
323 listnode_delete(bgp
->srv6_functions
, func
);
324 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
327 /* refresh tovpn_sid */
328 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
329 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
332 /* refresh vpnv4 tovpn_sid */
333 XFREE(MTYPE_BGP_SRV6_SID
,
334 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
336 /* refresh vpnv6 tovpn_sid */
337 XFREE(MTYPE_BGP_SRV6_SID
,
338 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
340 /* refresh per-vrf tovpn_sid */
341 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
344 /* update vpn bgp processes */
345 vpn_leak_postchange_all();
347 /* refresh tovpn_sid_locator */
348 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
349 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
352 /* refresh vpnv4 tovpn_sid_locator */
353 srv6_locator_chunk_free(
354 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
356 /* refresh vpnv6 tovpn_sid_locator */
357 srv6_locator_chunk_free(
358 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
360 /* refresh per-vrf tovpn_sid_locator */
361 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
364 /* clear locator name */
365 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
370 /* Utility function to get address family from current node. */
371 afi_t
bgp_node_afi(struct vty
*vty
)
379 case BGP_FLOWSPECV6_NODE
:
392 /* Utility function to get subsequent address family from current
394 safi_t
bgp_node_safi(struct vty
*vty
)
400 safi
= SAFI_MPLS_VPN
;
404 safi
= SAFI_MULTICAST
;
411 safi
= SAFI_LABELED_UNICAST
;
413 case BGP_FLOWSPECV4_NODE
:
414 case BGP_FLOWSPECV6_NODE
:
415 safi
= SAFI_FLOWSPEC
;
425 * Converts an AFI in string form to afi_t
427 * @param afi string, one of
431 * @return the corresponding afi_t
433 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
435 afi_t afi
= AFI_MAX
; /* unknown */
436 if (strmatch(afi_str
, "ipv4"))
438 else if (strmatch(afi_str
, "ipv6"))
440 else if (strmatch(afi_str
, "l2vpn"))
445 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
449 if (argv_find(argv
, argc
, "ipv4", index
)) {
453 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
457 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
465 /* supports <unicast|multicast|vpn|labeled-unicast> */
466 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
468 safi_t safi
= SAFI_MAX
; /* unknown */
469 if (strmatch(safi_str
, "multicast"))
470 safi
= SAFI_MULTICAST
;
471 else if (strmatch(safi_str
, "unicast"))
473 else if (strmatch(safi_str
, "vpn"))
474 safi
= SAFI_MPLS_VPN
;
475 else if (strmatch(safi_str
, "evpn"))
477 else if (strmatch(safi_str
, "labeled-unicast"))
478 safi
= SAFI_LABELED_UNICAST
;
479 else if (strmatch(safi_str
, "flowspec"))
480 safi
= SAFI_FLOWSPEC
;
484 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
488 if (argv_find(argv
, argc
, "unicast", index
)) {
491 *safi
= SAFI_UNICAST
;
492 } else if (argv_find(argv
, argc
, "multicast", index
)) {
495 *safi
= SAFI_MULTICAST
;
496 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
499 *safi
= SAFI_LABELED_UNICAST
;
500 } else if (argv_find(argv
, argc
, "vpn", index
)) {
503 *safi
= SAFI_MPLS_VPN
;
504 } else if (argv_find(argv
, argc
, "evpn", index
)) {
508 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
511 *safi
= SAFI_FLOWSPEC
;
517 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
520 * address-family identifier
523 * subsequent address-family identifier
526 * default_af string corresponding to the supplied afi/safi pair.
527 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
530 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
536 return "ipv4-unicast";
538 return "ipv4-multicast";
543 case SAFI_LABELED_UNICAST
:
544 return "ipv4-labeled-unicast";
546 return "ipv4-flowspec";
550 return "unknown-afi/safi";
556 return "ipv6-unicast";
558 return "ipv6-multicast";
563 case SAFI_LABELED_UNICAST
:
564 return "ipv6-labeled-unicast";
566 return "ipv6-flowspec";
570 return "unknown-afi/safi";
581 case SAFI_LABELED_UNICAST
:
585 return "unknown-afi/safi";
590 return "unknown-afi/safi";
592 /* all AFIs are accounted for above, so this shouldn't happen */
594 assert(!"Reached end of function where we did not expect to");
597 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
598 enum bgp_instance_type inst_type
, const char *as_pretty
)
600 int ret
= bgp_get(bgp
, as
, name
, inst_type
, as_pretty
);
602 if (ret
== BGP_CREATED
) {
603 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
604 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
606 if (DFLT_BGP_IMPORT_CHECK
)
607 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
608 if (DFLT_BGP_SHOW_HOSTNAME
)
609 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
610 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
611 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
612 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
613 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
614 if (DFLT_BGP_DETERMINISTIC_MED
)
615 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
616 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
617 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
618 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
619 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
620 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
621 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
622 if (DFLT_BGP_HARD_ADMIN_RESET
)
623 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
631 * bgp_vty_find_and_parse_afi_safi_bgp
633 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
634 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
635 * to appropriate values for the calling function. This is to allow the
636 * calling function to make decisions appropriate for the show command
637 * that is being parsed.
639 * The show commands are generally of the form:
640 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
641 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
643 * Since we use argv_find if the show command in particular doesn't have:
645 * [<view|vrf> VIEWVRFNAME]
646 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
647 * The command parsing should still be ok.
649 * vty -> The vty for the command so we can output some useful data in
650 * the event of a parse error in the vrf.
651 * argv -> The command tokens
652 * argc -> How many command tokens we have
653 * idx -> The current place in the command, generally should be 0 for this
655 * afi -> The parsed afi if it was included in the show command, returned here
656 * safi -> The parsed safi if it was included in the show command, returned here
657 * bgp -> Pointer to the bgp data structure we need to fill in.
658 * use_json -> json is configured or not
660 * The function returns the correct location in the parse tree for the
663 * Returns 0 for failure to parse correctly, else the idx position of where
664 * it found the last token.
666 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
667 struct cmd_token
**argv
, int argc
,
668 int *idx
, afi_t
*afi
, safi_t
*safi
,
669 struct bgp
**bgp
, bool use_json
)
671 char *vrf_name
= NULL
;
677 if (argv_find(argv
, argc
, "ip", idx
))
680 if (argv_find(argv
, argc
, "view", idx
))
681 vrf_name
= argv
[*idx
+ 1]->arg
;
682 else if (argv_find(argv
, argc
, "vrf", idx
)) {
683 vrf_name
= argv
[*idx
+ 1]->arg
;
684 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
688 if (strmatch(vrf_name
, "all"))
691 *bgp
= bgp_lookup_by_name(vrf_name
);
694 json_object
*json
= NULL
;
695 json
= json_object_new_object();
696 json_object_string_add(
698 "View/Vrf is unknown");
702 vty_out(vty
, "View/Vrf %s is unknown\n",
709 *bgp
= bgp_get_default();
712 json_object
*json
= NULL
;
713 json
= json_object_new_object();
714 json_object_string_add(
716 "Default BGP instance not found");
721 "Default BGP instance not found\n");
727 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
728 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
734 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
736 struct interface
*ifp
= NULL
;
737 struct listnode
*node
;
738 struct bgp_listener
*listener
;
739 union sockunion all_su
;
741 if (su
->sa
.sa_family
== AF_INET
) {
742 (void)str2sockunion("0.0.0.0", &all_su
);
743 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
744 } else if (su
->sa
.sa_family
== AF_INET6
) {
745 (void)str2sockunion("::", &all_su
);
746 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
747 su
->sin6
.sin6_scope_id
,
752 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
753 if (sockunion_family(su
) !=
754 sockunion_family(&listener
->su
))
757 /* If 0.0.0.0/:: is a listener, then treat as self and
760 if (!sockunion_cmp(&listener
->su
, su
) ||
761 !sockunion_cmp(&listener
->su
, &all_su
))
769 /* Utility function for looking up peer from VTY. */
770 /* This is used only for configuration, so disallow if attempted on
771 * a dynamic neighbor.
773 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
775 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
784 ret
= str2sockunion(ip_str
, &su
);
786 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
788 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
791 "%% Malformed address or name: %s\n",
797 peer
= peer_lookup(bgp
, &su
);
800 "%% Specify remote-as or peer-group commands first\n");
803 if (peer_dynamic_neighbor(peer
)) {
805 "%% Operation not allowed on a dynamic neighbor\n");
812 /* Utility function for looking up peer or peer group. */
813 /* This is used only for configuration, so disallow if attempted on
814 * a dynamic neighbor.
816 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
818 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
821 struct peer
*peer
= NULL
;
822 struct peer_group
*group
= NULL
;
828 ret
= str2sockunion(peer_str
, &su
);
830 /* IP address, locate peer. */
831 peer
= peer_lookup(bgp
, &su
);
833 /* Not IP, could match either peer configured on interface or a
835 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
837 group
= peer_group_lookup(bgp
, peer_str
);
841 if (peer_dynamic_neighbor(peer
)) {
843 "%pBP: Operation not allowed on a dynamic neighbor",
846 "%% Operation not allowed on a dynamic neighbor\n");
856 zlog_warn("Specify remote-as or peer-group commands first before: %s",
858 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
863 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
865 const char *str
= NULL
;
870 case BGP_GR_NO_OPERATION
:
872 case BGP_ERR_INVALID_VALUE
:
873 str
= "Invalid value";
875 case BGP_ERR_INVALID_FLAG
:
876 str
= "Invalid flag";
878 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
879 str
= "Peer-group has been shutdown. Activate the peer-group first";
881 case BGP_ERR_PEER_FLAG_CONFLICT
:
882 str
= "Can't set override-capability and strict-capability-match at the same time";
884 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
885 str
= "Specify remote-as or peer-group remote AS first";
887 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
888 str
= "Cannot change the peer-group. Deconfigure first";
890 case BGP_ERR_PEER_GROUP_MISMATCH
:
891 str
= "Peer is not a member of this peer-group";
893 case BGP_ERR_PEER_FILTER_CONFLICT
:
894 str
= "Prefix/distribute list can not co-exist";
896 case BGP_ERR_NOT_INTERNAL_PEER
:
897 str
= "Invalid command. Not an internal neighbor";
899 case BGP_ERR_REMOVE_PRIVATE_AS
:
900 str
= "remove-private-AS cannot be configured for IBGP peers";
902 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
903 str
= "Cannot have local-as same as BGP AS number";
905 case BGP_ERR_TCPSIG_FAILED
:
906 str
= "Error while applying TCP-Sig to session(s)";
908 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
909 str
= "ebgp-multihop and ttl-security cannot be configured together";
911 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
912 str
= "ttl-security only allowed for EBGP peers";
914 case BGP_ERR_AS_OVERRIDE
:
915 str
= "as-override cannot be configured for IBGP peers";
917 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
918 str
= "Invalid limit for number of dynamic neighbors";
920 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
921 str
= "Dynamic neighbor listen range already exists";
923 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
924 str
= "Operation not allowed on a dynamic neighbor";
926 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
927 str
= "Operation not allowed on a directly connected neighbor";
929 case BGP_ERR_PEER_SAFI_CONFLICT
:
930 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
932 case BGP_ERR_GR_INVALID_CMD
:
933 str
= "The Graceful Restart command used is not valid at this moment.";
935 case BGP_ERR_GR_OPERATION_FAILED
:
936 str
= "The Graceful Restart Operation failed due to an err.";
938 case BGP_ERR_PEER_GROUP_MEMBER
:
939 str
= "Peer-group member cannot override remote-as of peer-group.";
941 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
942 str
= "Peer-group members must be all internal or all external.";
944 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
945 str
= "Range specified cannot be deleted because it is not part of current config.";
947 case BGP_ERR_INSTANCE_MISMATCH
:
948 str
= "Instance specified does not match the current instance.";
950 case BGP_ERR_NO_INTERFACE_CONFIG
:
951 str
= "Interface specified is not being used for interface based peer.";
953 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
954 str
= "No configuration already specified for soft reconfiguration.";
956 case BGP_ERR_AS_MISMATCH
:
957 str
= "BGP is already running.";
959 case BGP_ERR_AF_UNCONFIGURED
:
960 str
= "AFI/SAFI specified is not currently configured.";
962 case BGP_ERR_INVALID_AS
:
963 str
= "Confederation AS specified is the same AS as our AS.";
965 case BGP_ERR_INVALID_ROLE_NAME
:
966 str
= "Invalid role name";
968 case BGP_ERR_INVALID_INTERNAL_ROLE
:
969 str
= "External roles can be set only on eBGP session";
973 vty_out(vty
, "%% %s\n", str
);
974 return CMD_WARNING_CONFIG_FAILED
;
979 /* BGP clear sort. */
988 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
989 safi_t safi
, int error
)
992 case BGP_ERR_AF_UNCONFIGURED
:
995 "%% BGP: Enable %s address family for the neighbor %s\n",
996 get_afi_safi_str(afi
, safi
, false), peer
->host
);
999 "%% BGP: Enable %s address family for the neighbor %s",
1000 get_afi_safi_str(afi
, safi
, false), peer
->host
);
1002 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
1005 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
1009 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
1017 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1018 struct listnode
**nnode
, enum bgp_clear_type stype
)
1021 struct peer_af
*paf
;
1023 /* if afi/.safi not specified, spin thru all of them */
1024 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1027 enum bgp_af_index index
;
1029 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1030 paf
= peer
->peer_af_array
[index
];
1034 if (paf
&& paf
->subgroup
)
1035 SET_FLAG(paf
->subgroup
->sflags
,
1036 SUBGRP_STATUS_FORCE_UPDATES
);
1039 tmp_safi
= paf
->safi
;
1040 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1043 if (stype
== BGP_CLEAR_SOFT_NONE
)
1044 ret
= peer_clear(peer
, nnode
);
1046 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1049 /* if afi specified and safi not, spin thru safis on this afi */
1050 } else if (safi
== SAFI_UNSPEC
) {
1053 for (tmp_safi
= SAFI_UNICAST
;
1054 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1055 if (!peer
->afc
[afi
][tmp_safi
])
1058 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1059 if (paf
&& paf
->subgroup
)
1060 SET_FLAG(paf
->subgroup
->sflags
,
1061 SUBGRP_STATUS_FORCE_UPDATES
);
1063 if (stype
== BGP_CLEAR_SOFT_NONE
)
1064 ret
= peer_clear(peer
, nnode
);
1066 ret
= peer_clear_soft(peer
, afi
,
1069 /* both afi/safi specified, let the caller know if not defined */
1071 if (!peer
->afc
[afi
][safi
])
1074 paf
= peer_af_find(peer
, afi
, safi
);
1075 if (paf
&& paf
->subgroup
)
1076 SET_FLAG(paf
->subgroup
->sflags
,
1077 SUBGRP_STATUS_FORCE_UPDATES
);
1079 if (stype
== BGP_CLEAR_SOFT_NONE
)
1080 ret
= peer_clear(peer
, nnode
);
1082 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1088 /* `clear ip bgp' functions. */
1089 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1090 enum clear_sort sort
, enum bgp_clear_type stype
,
1097 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1099 /* Clear all neighbors. */
1101 * Pass along pointer to next node to peer_clear() when walking all
1102 * nodes on the BGP instance as that may get freed if it is a
1105 if (sort
== clear_all
) {
1106 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1108 bgp_peer_gr_flags_update(peer
);
1110 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1111 gr_router_detected
= true;
1113 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1117 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1120 if (gr_router_detected
1121 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1122 bgp_zebra_send_capabilities(bgp
, false);
1123 } else if (!gr_router_detected
1124 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1125 bgp_zebra_send_capabilities(bgp
, true);
1128 /* This is to apply read-only mode on this clear. */
1129 if (stype
== BGP_CLEAR_SOFT_NONE
)
1130 bgp
->update_delay_over
= 0;
1135 /* Clear specified neighbor. */
1136 if (sort
== clear_peer
) {
1139 /* Make sockunion for lookup. */
1140 ret
= str2sockunion(arg
, &su
);
1142 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1144 peer
= peer_lookup_by_hostname(bgp
, arg
);
1147 "Malformed address or name: %s\n",
1153 peer
= peer_lookup(bgp
, &su
);
1156 "%% BGP: Unknown neighbor - \"%s\"\n",
1162 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1163 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1165 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1167 /* if afi/safi not defined for this peer, let caller know */
1169 ret
= BGP_ERR_AF_UNCONFIGURED
;
1172 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1177 /* Clear all neighbors belonging to a specific peer-group. */
1178 if (sort
== clear_group
) {
1179 struct peer_group
*group
;
1181 group
= peer_group_lookup(bgp
, arg
);
1183 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1187 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1188 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1191 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1198 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1199 get_afi_safi_str(afi
, safi
, false), arg
);
1204 /* Clear all external (eBGP) neighbors. */
1205 if (sort
== clear_external
) {
1206 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1207 if (peer
->sort
== BGP_PEER_IBGP
)
1210 bgp_peer_gr_flags_update(peer
);
1212 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1213 gr_router_detected
= true;
1215 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1218 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1223 if (gr_router_detected
1224 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1225 bgp_zebra_send_capabilities(bgp
, false);
1226 } else if (!gr_router_detected
1227 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1228 bgp_zebra_send_capabilities(bgp
, true);
1233 "%% BGP: No external %s peer is configured\n",
1234 get_afi_safi_str(afi
, safi
, false));
1239 /* Clear all neighbors belonging to a specific AS. */
1240 if (sort
== clear_as
) {
1243 if (!asn_str2asn(arg
, &as
)) {
1244 vty_out(vty
, "%% BGP: No such AS %s\n", arg
);
1248 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1252 bgp_peer_gr_flags_update(peer
);
1254 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1255 gr_router_detected
= true;
1257 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1260 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1265 if (gr_router_detected
1266 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1267 bgp_zebra_send_capabilities(bgp
, false);
1268 } else if (!gr_router_detected
1269 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1270 bgp_zebra_send_capabilities(bgp
, true);
1275 "%% BGP: No %s peer is configured with AS %s\n",
1276 get_afi_safi_str(afi
, safi
, false), arg
);
1284 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1285 safi_t safi
, enum clear_sort sort
,
1286 enum bgp_clear_type stype
, const char *arg
)
1290 /* BGP structure lookup. */
1292 bgp
= bgp_lookup_by_name(name
);
1294 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1298 bgp
= bgp_get_default();
1300 vty_out(vty
, "No BGP process is configured\n");
1305 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1308 /* clear soft inbound */
1309 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1314 FOREACH_AFI_SAFI (afi
, safi
)
1315 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1316 BGP_CLEAR_SOFT_IN
, NULL
);
1319 /* clear soft outbound */
1320 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1325 FOREACH_AFI_SAFI (afi
, safi
)
1326 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1327 BGP_CLEAR_SOFT_OUT
, NULL
);
1331 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1333 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1336 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1337 uint64_t flag
, int set
)
1342 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1344 return CMD_WARNING_CONFIG_FAILED
;
1347 * If 'neighbor <interface>', then this is for directly connected peers,
1348 * we should not accept disable-connected-check.
1350 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1352 "%s is directly connected peer, cannot accept disable-connected-check\n",
1354 return CMD_WARNING_CONFIG_FAILED
;
1357 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1358 peer_tx_shutdown_message_unset(peer
);
1361 ret
= peer_flag_set(peer
, flag
);
1363 ret
= peer_flag_unset(peer
, flag
);
1365 return bgp_vty_return(vty
, ret
);
1368 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1370 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1373 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1376 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1379 #include "bgpd/bgp_vty_clippy.c"
1381 DEFUN_HIDDEN (bgp_local_mac
,
1383 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1385 "Local MAC config\n"
1386 "VxLAN Network Identifier\n"
1390 "mac-mobility sequence\n"
1400 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1401 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1402 vty_out(vty
, "%% Malformed MAC address\n");
1405 memset(&ip
, 0, sizeof(ip
));
1406 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1408 bgp
= bgp_get_default();
1410 vty_out(vty
, "Default BGP instance is not there\n");
1414 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1417 vty_out(vty
, "Internal error\n");
1424 DEFUN_HIDDEN (no_bgp_local_mac
,
1425 no_bgp_local_mac_cmd
,
1426 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1429 "Local MAC config\n"
1430 "VxLAN Network Identifier\n"
1441 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1442 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1443 vty_out(vty
, "%% Malformed MAC address\n");
1446 memset(&ip
, 0, sizeof(ip
));
1448 bgp
= bgp_get_default();
1450 vty_out(vty
, "Default BGP instance is not there\n");
1454 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1456 vty_out(vty
, "Internal error\n");
1463 DEFUN (no_synchronization
,
1464 no_synchronization_cmd
,
1465 "no synchronization",
1467 "Perform IGP synchronization\n")
1472 DEFUN (no_auto_summary
,
1473 no_auto_summary_cmd
,
1476 "Enable automatic network number summarization\n")
1481 /* "router bgp" commands. */
1482 DEFUN_NOSH (router_bgp
,
1484 "router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME]]",
1488 BGP_INSTANCE_HELP_STR
)
1491 int idx_view_vrf
= 3;
1497 const char *name
= NULL
;
1498 enum bgp_instance_type inst_type
;
1500 // "router bgp" without an ASN
1502 // Pending: Make VRF option available for ASN less config
1503 bgp
= bgp_get_default();
1506 vty_out(vty
, "%% No BGP process is configured\n");
1507 return CMD_WARNING_CONFIG_FAILED
;
1510 if (listcount(bm
->bgp
) > 1) {
1511 vty_out(vty
, "%% Please specify ASN and VRF\n");
1512 return CMD_WARNING_CONFIG_FAILED
;
1518 if (!asn_str2asn(argv
[idx_asn
]->arg
, &as
)) {
1519 vty_out(vty
, "%% BGP: No such AS %s\n",
1520 argv
[idx_asn
]->arg
);
1521 return CMD_WARNING_CONFIG_FAILED
;
1524 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1525 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1526 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1528 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1530 name
= argv
[idx_vrf
]->arg
;
1532 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1533 if (strmatch(name
, VRF_DEFAULT_NAME
))
1536 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1537 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1538 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1541 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1542 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1544 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
,
1545 argv
[idx_asn
]->arg
);
1547 case BGP_ERR_AS_MISMATCH
:
1548 vty_out(vty
, "BGP is already running; AS is %s\n",
1550 return CMD_WARNING_CONFIG_FAILED
;
1551 case BGP_ERR_INSTANCE_MISMATCH
:
1553 "BGP instance name and AS number mismatch\n");
1555 "BGP instance is already running; AS is %s\n",
1557 return CMD_WARNING_CONFIG_FAILED
;
1561 * If we just instantiated the default instance, complete
1562 * any pending VRF-VPN leaking that was configured via
1563 * earlier "router bgp X vrf FOO" blocks.
1565 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1566 vpn_leak_postchange_all();
1568 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1569 bgp_vpn_leak_export(bgp
);
1570 /* Pending: handle when user tries to change a view to vrf n vv.
1574 /* unset the auto created flag as the user config is now present */
1575 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1576 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1581 /* "no router bgp" commands. */
1582 DEFUN (no_router_bgp
,
1584 "no router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME]]",
1589 BGP_INSTANCE_HELP_STR
)
1595 const char *name
= NULL
;
1597 // "no router bgp" without an ASN
1599 // Pending: Make VRF option available for ASN less config
1600 bgp
= bgp_get_default();
1603 vty_out(vty
, "%% No BGP process is configured\n");
1604 return CMD_WARNING_CONFIG_FAILED
;
1607 if (listcount(bm
->bgp
) > 1) {
1608 vty_out(vty
, "%% Please specify ASN and VRF\n");
1609 return CMD_WARNING_CONFIG_FAILED
;
1613 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1615 return CMD_WARNING_CONFIG_FAILED
;
1618 if (!asn_str2asn(argv
[idx_asn
]->arg
, &as
)) {
1619 vty_out(vty
, "%% BGP: No such AS %s\n",
1620 argv
[idx_asn
]->arg
);
1621 return CMD_WARNING_CONFIG_FAILED
;
1624 name
= argv
[idx_vrf
]->arg
;
1625 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1626 && strmatch(name
, VRF_DEFAULT_NAME
))
1630 /* Lookup bgp structure. */
1631 bgp
= bgp_lookup(as
, name
);
1633 vty_out(vty
, "%% Can't find BGP instance\n");
1634 return CMD_WARNING_CONFIG_FAILED
;
1638 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1640 return CMD_WARNING_CONFIG_FAILED
;
1643 /* Cannot delete default instance if vrf instances exist */
1644 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1645 struct listnode
*node
;
1646 struct bgp
*tmp_bgp
;
1648 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1649 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1651 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1652 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1653 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1654 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1655 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1656 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1657 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1658 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1659 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1660 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1661 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1662 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1663 (bgp
== bgp_get_evpn() &&
1664 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1665 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1666 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1667 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1668 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1669 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1670 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1671 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1672 (hashcount(tmp_bgp
->vnihash
))) {
1674 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1675 return CMD_WARNING_CONFIG_FAILED
;
1686 /* bgp session-dscp */
1688 DEFPY (bgp_session_dscp
,
1689 bgp_session_dscp_cmd
,
1690 "bgp session-dscp (0-63)$dscp",
1692 "Override default (C6) bgp TCP session DSCP value\n"
1693 "Manually configured dscp parameter\n")
1695 bm
->tcp_dscp
= dscp
<< 2;
1700 DEFPY (no_bgp_session_dscp
,
1701 no_bgp_session_dscp_cmd
,
1702 "no bgp session-dscp [(0-63)]",
1705 "Override default (C6) bgp TCP session DSCP value\n"
1706 "Manually configured dscp parameter\n")
1708 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1713 /* BGP router-id. */
1715 DEFPY (bgp_router_id
,
1717 "bgp router-id A.B.C.D",
1719 "Override configured router identifier\n"
1720 "Manually configured router identifier\n")
1722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1723 bgp_router_id_static_set(bgp
, router_id
);
1727 DEFPY (no_bgp_router_id
,
1728 no_bgp_router_id_cmd
,
1729 "no bgp router-id [A.B.C.D]",
1732 "Override configured router identifier\n"
1733 "Manually configured router identifier\n")
1735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1737 if (router_id_str
) {
1738 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1739 vty_out(vty
, "%% BGP router-id doesn't match\n");
1740 return CMD_WARNING_CONFIG_FAILED
;
1744 router_id
.s_addr
= 0;
1745 bgp_router_id_static_set(bgp
, router_id
);
1750 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1751 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1753 "Add community specific parameters\n"
1754 "Create an alias for a community\n"
1755 "Community (AA:BB or AA:BB:CC)\n"
1758 struct community_alias ca
= {};
1759 struct community_alias
*lookup_community
;
1760 struct community_alias
*lookup_alias
;
1761 struct community
*comm
;
1762 struct lcommunity
*lcomm
;
1763 uint8_t invalid
= 0;
1765 comm
= community_str2com(community
);
1768 community_free(&comm
);
1770 lcomm
= lcommunity_str2com(community
);
1773 lcommunity_free(&lcomm
);
1776 vty_out(vty
, "Invalid community format\n");
1780 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1781 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1783 lookup_community
= bgp_ca_community_lookup(&ca
);
1784 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1787 bgp_ca_alias_delete(&ca
);
1788 bgp_ca_community_delete(&ca
);
1791 /* Lookup if community hash table has an item
1792 * with the same alias name.
1794 strlcpy(ca
.community
, lookup_alias
->community
,
1795 sizeof(ca
.community
));
1796 if (bgp_ca_community_lookup(&ca
)) {
1798 "community (%s) already has this alias (%s)\n",
1799 lookup_alias
->community
,
1800 lookup_alias
->alias
);
1803 bgp_ca_alias_delete(&ca
);
1806 if (lookup_community
) {
1807 /* Lookup if alias hash table has an item
1808 * with the same community.
1810 strlcpy(ca
.alias
, lookup_community
->alias
,
1812 if (bgp_ca_alias_lookup(&ca
)) {
1814 "alias (%s) already has this community (%s)\n",
1815 lookup_community
->alias
,
1816 lookup_community
->community
);
1819 bgp_ca_community_delete(&ca
);
1822 bgp_ca_alias_insert(&ca
);
1823 bgp_ca_community_insert(&ca
);
1829 DEFPY (bgp_global_suppress_fib_pending
,
1830 bgp_global_suppress_fib_pending_cmd
,
1831 "[no] bgp suppress-fib-pending",
1834 "Advertise only routes that are programmed in kernel to peers globally\n")
1836 bm_wait_for_fib_set(!no
);
1841 DEFPY (bgp_suppress_fib_pending
,
1842 bgp_suppress_fib_pending_cmd
,
1843 "[no] bgp suppress-fib-pending",
1846 "Advertise only routes that are programmed in kernel to peers\n")
1848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1850 bgp_suppress_fib_pending_set(bgp
, !no
);
1855 /* BGP Cluster ID. */
1856 DEFUN (bgp_cluster_id
,
1858 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1860 "Configure Route-Reflector Cluster-id\n"
1861 "Route-Reflector Cluster-id in IP address format\n"
1862 "Route-Reflector Cluster-id as 32 bit quantity\n")
1864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1867 struct in_addr cluster
;
1869 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1871 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1872 return CMD_WARNING_CONFIG_FAILED
;
1875 bgp_cluster_id_set(bgp
, &cluster
);
1876 bgp_clear_star_soft_out(vty
, bgp
->name
);
1881 DEFUN (no_bgp_cluster_id
,
1882 no_bgp_cluster_id_cmd
,
1883 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1886 "Configure Route-Reflector Cluster-id\n"
1887 "Route-Reflector Cluster-id in IP address format\n"
1888 "Route-Reflector Cluster-id as 32 bit quantity\n")
1890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1891 bgp_cluster_id_unset(bgp
);
1892 bgp_clear_star_soft_out(vty
, bgp
->name
);
1901 "Disable BGP route installation to RIB (Zebra)\n")
1903 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1905 "%% No-RIB option is already set, nothing to do here.\n");
1909 bgp_option_norib_set_runtime();
1914 DEFPY (no_bgp_norib
,
1919 "Disable BGP route installation to RIB (Zebra)\n")
1921 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1923 "%% No-RIB option is not set, nothing to do here.\n");
1927 bgp_option_norib_unset_runtime();
1932 DEFPY (no_bgp_send_extra_data
,
1933 no_bgp_send_extra_data_cmd
,
1934 "[no] bgp send-extra-data zebra",
1937 "Extra data to Zebra for display/use\n"
1941 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1943 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1948 DEFUN (bgp_confederation_identifier
,
1949 bgp_confederation_identifier_cmd
,
1950 "bgp confederation identifier ASNUM",
1952 "AS confederation parameters\n"
1954 "Set routing domain confederation AS\n")
1956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1960 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
1961 vty_out(vty
, "%% BGP: No such AS %s\n", argv
[idx_number
]->arg
);
1962 return CMD_WARNING_CONFIG_FAILED
;
1965 bgp_confederation_id_set(bgp
, as
);
1970 DEFUN (no_bgp_confederation_identifier
,
1971 no_bgp_confederation_identifier_cmd
,
1972 "no bgp confederation identifier [ASNUM]",
1975 "AS confederation parameters\n"
1977 "Set routing domain confederation AS\n")
1979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1980 bgp_confederation_id_unset(bgp
);
1985 DEFUN (bgp_confederation_peers
,
1986 bgp_confederation_peers_cmd
,
1987 "bgp confederation peers ASNUM...",
1989 "AS confederation parameters\n"
1990 "Peer ASs in BGP confederation\n"
1993 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 for (i
= idx_asn
; i
< argc
; i
++) {
1999 if (!asn_str2asn(argv
[i
]->arg
, &as
)) {
2000 vty_out(vty
, "%% Invalid confed peer AS value: %s\n",
2005 bgp_confederation_peers_add(bgp
, as
);
2010 DEFUN (no_bgp_confederation_peers
,
2011 no_bgp_confederation_peers_cmd
,
2012 "no bgp confederation peers ASNUM...",
2015 "AS confederation parameters\n"
2016 "Peer ASs in BGP confederation\n"
2019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2024 for (i
= idx_asn
; i
< argc
; i
++) {
2025 if (!asn_str2asn(argv
[i
]->arg
, &as
)) {
2026 vty_out(vty
, "%% Invalid confed peer AS value: %s\n",
2030 bgp_confederation_peers_remove(bgp
, as
);
2036 * Central routine for maximum-paths configuration.
2037 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
2038 * @set: 1 for setting values, 0 for removing the max-paths config.
2040 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
2041 const char *mpaths
, uint16_t options
,
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2045 uint16_t maxpaths
= 0;
2050 afi
= bgp_node_afi(vty
);
2051 safi
= bgp_node_safi(vty
);
2054 maxpaths
= strtol(mpaths
, NULL
, 10);
2055 if (maxpaths
> multipath_num
) {
2057 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2058 maxpaths
, multipath_num
);
2059 return CMD_WARNING_CONFIG_FAILED
;
2061 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2064 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2068 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2069 (set
== 1) ? "" : "un",
2070 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2071 maxpaths
, afi
, safi
);
2072 return CMD_WARNING_CONFIG_FAILED
;
2075 bgp_recalculate_all_bestpaths(bgp
);
2080 DEFUN (bgp_maxmed_admin
,
2081 bgp_maxmed_admin_cmd
,
2082 "bgp max-med administrative ",
2084 "Advertise routes with max-med\n"
2085 "Administratively applied, for an indefinite period\n")
2087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2089 bgp
->v_maxmed_admin
= 1;
2090 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2092 bgp_maxmed_update(bgp
);
2097 DEFUN (bgp_maxmed_admin_medv
,
2098 bgp_maxmed_admin_medv_cmd
,
2099 "bgp max-med administrative (0-4294967295)",
2101 "Advertise routes with max-med\n"
2102 "Administratively applied, for an indefinite period\n"
2103 "Max MED value to be used\n")
2105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2108 bgp
->v_maxmed_admin
= 1;
2109 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2111 bgp_maxmed_update(bgp
);
2116 DEFUN (no_bgp_maxmed_admin
,
2117 no_bgp_maxmed_admin_cmd
,
2118 "no bgp max-med administrative [(0-4294967295)]",
2121 "Advertise routes with max-med\n"
2122 "Administratively applied, for an indefinite period\n"
2123 "Max MED value to be used\n")
2125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2126 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2127 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2128 bgp_maxmed_update(bgp
);
2133 DEFUN (bgp_maxmed_onstartup
,
2134 bgp_maxmed_onstartup_cmd
,
2135 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2137 "Advertise routes with max-med\n"
2138 "Effective on a startup\n"
2139 "Time (seconds) period for max-med\n"
2140 "Max MED value to be used\n")
2142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2145 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2146 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2147 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2148 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2150 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2152 bgp_maxmed_update(bgp
);
2157 DEFUN (no_bgp_maxmed_onstartup
,
2158 no_bgp_maxmed_onstartup_cmd
,
2159 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2162 "Advertise routes with max-med\n"
2163 "Effective on a startup\n"
2164 "Time (seconds) period for max-med\n"
2165 "Max MED value to be used\n")
2167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2169 /* Cancel max-med onstartup if its on */
2170 if (bgp
->t_maxmed_onstartup
) {
2171 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2172 bgp
->maxmed_onstartup_over
= 1;
2175 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2176 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2178 bgp_maxmed_update(bgp
);
2183 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2184 uint16_t update_delay
,
2185 uint16_t establish_wait
)
2187 struct listnode
*node
, *nnode
;
2189 bool vrf_cfg
= false;
2192 * See if update-delay is set per-vrf and warn user to delete it
2193 * Note that we only need to check this if this is the first time
2194 * setting the global config.
2196 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2197 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2198 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2200 "%% update-delay configuration found in vrf %s\n",
2201 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2211 "%%Failed: global update-delay config not permitted\n");
2215 if (!establish_wait
) { /* update-delay <delay> */
2216 bm
->v_update_delay
= update_delay
;
2217 bm
->v_establish_wait
= bm
->v_update_delay
;
2219 /* update-delay <delay> <establish-wait> */
2220 if (update_delay
< establish_wait
) {
2222 "%%Failed: update-delay less than the establish-wait!\n");
2223 return CMD_WARNING_CONFIG_FAILED
;
2226 bm
->v_update_delay
= update_delay
;
2227 bm
->v_establish_wait
= establish_wait
;
2230 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2231 bgp
->v_update_delay
= bm
->v_update_delay
;
2232 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2238 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2240 struct listnode
*node
, *nnode
;
2243 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2244 bm
->v_establish_wait
= bm
->v_update_delay
;
2246 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2247 bgp
->v_update_delay
= bm
->v_update_delay
;
2248 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2254 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2255 uint16_t establish_wait
)
2257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2259 /* if configured globally, per-instance config is not allowed */
2260 if (bm
->v_update_delay
) {
2262 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2263 return CMD_WARNING_CONFIG_FAILED
;
2267 if (!establish_wait
) /* update-delay <delay> */
2269 bgp
->v_update_delay
= update_delay
;
2270 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2274 /* update-delay <delay> <establish-wait> */
2275 if (update_delay
< establish_wait
) {
2277 "%%Failed: update-delay less than the establish-wait!\n");
2278 return CMD_WARNING_CONFIG_FAILED
;
2281 bgp
->v_update_delay
= update_delay
;
2282 bgp
->v_establish_wait
= establish_wait
;
2287 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2291 /* If configured globally, cannot remove from one bgp instance */
2292 if (bm
->v_update_delay
) {
2294 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2295 return CMD_WARNING_CONFIG_FAILED
;
2297 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2298 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2303 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2305 /* If configured globally, no need to display per-instance value */
2306 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2307 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2308 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2309 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2314 /* Global update-delay configuration */
2315 DEFPY (bgp_global_update_delay
,
2316 bgp_global_update_delay_cmd
,
2317 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2319 "Force initial delay for best-path and updates for all bgp instances\n"
2320 "Max delay in seconds\n"
2321 "Establish wait in seconds\n")
2323 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2326 /* Global update-delay deconfiguration */
2327 DEFPY (no_bgp_global_update_delay
,
2328 no_bgp_global_update_delay_cmd
,
2329 "no bgp update-delay [(0-3600) [(1-3600)]]",
2332 "Force initial delay for best-path and updates\n"
2333 "Max delay in seconds\n"
2334 "Establish wait in seconds\n")
2336 return bgp_global_update_delay_deconfig_vty(vty
);
2339 /* Update-delay configuration */
2341 DEFPY (bgp_update_delay
,
2342 bgp_update_delay_cmd
,
2343 "update-delay (0-3600)$delay [(1-3600)$wait]",
2344 "Force initial delay for best-path and updates\n"
2345 "Max delay in seconds\n"
2346 "Establish wait in seconds\n")
2348 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2351 /* Update-delay deconfiguration */
2352 DEFPY (no_bgp_update_delay
,
2353 no_bgp_update_delay_cmd
,
2354 "no update-delay [(0-3600) [(1-3600)]]",
2356 "Force initial delay for best-path and updates\n"
2357 "Max delay in seconds\n"
2358 "Establish wait in seconds\n")
2360 return bgp_update_delay_deconfig_vty(vty
);
2364 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2369 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2370 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2375 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2380 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2381 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2386 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2389 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2390 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2391 vty_out(vty
, " write-quanta %d\n", quanta
);
2394 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2397 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2398 if (quanta
!= BGP_READ_PACKET_MAX
)
2399 vty_out(vty
, " read-quanta %d\n", quanta
);
2402 /* Packet quanta configuration
2404 * XXX: The value set here controls the size of a stack buffer in the IO
2405 * thread. When changing these limits be careful to prevent stack overflow.
2407 * Furthermore, the maximums used here should correspond to
2408 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2410 DEFPY (bgp_wpkt_quanta
,
2411 bgp_wpkt_quanta_cmd
,
2412 "[no] write-quanta (1-64)$quanta",
2414 "How many packets to write to peer socket per run\n"
2415 "Number of packets\n")
2417 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2420 DEFPY (bgp_rpkt_quanta
,
2421 bgp_rpkt_quanta_cmd
,
2422 "[no] read-quanta (1-10)$quanta",
2424 "How many packets to read from peer socket per I/O cycle\n"
2425 "Number of packets\n")
2427 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2430 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2432 if (!bgp
->heuristic_coalesce
)
2433 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2436 /* BGP TCP keepalive */
2437 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2439 if (bgp
->tcp_keepalive_idle
) {
2440 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2441 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2442 bgp
->tcp_keepalive_probes
);
2446 DEFUN (bgp_coalesce_time
,
2447 bgp_coalesce_time_cmd
,
2448 "coalesce-time (0-4294967295)",
2449 "Subgroup coalesce timer\n"
2450 "Subgroup coalesce timer value (in ms)\n")
2452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2456 bgp
->heuristic_coalesce
= false;
2458 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2459 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2464 DEFUN (no_bgp_coalesce_time
,
2465 no_bgp_coalesce_time_cmd
,
2466 "no coalesce-time (0-4294967295)",
2468 "Subgroup coalesce timer\n"
2469 "Subgroup coalesce timer value (in ms)\n")
2471 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2473 bgp
->heuristic_coalesce
= true;
2474 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2478 /* Maximum-paths configuration */
2479 DEFUN (bgp_maxpaths
,
2481 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2482 "Forward packets over multiple paths\n"
2483 "Number of paths\n")
2486 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2487 argv
[idx_number
]->arg
, 0, 1);
2490 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2491 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2492 "Forward packets over multiple paths\n"
2493 "Number of paths\n")
2495 DEFUN (bgp_maxpaths_ibgp
,
2496 bgp_maxpaths_ibgp_cmd
,
2497 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2498 "Forward packets over multiple paths\n"
2500 "Number of paths\n")
2503 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2504 argv
[idx_number
]->arg
, 0, 1);
2507 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2508 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2509 "Forward packets over multiple paths\n"
2511 "Number of paths\n")
2513 DEFUN (bgp_maxpaths_ibgp_cluster
,
2514 bgp_maxpaths_ibgp_cluster_cmd
,
2515 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2516 "Forward packets over multiple paths\n"
2519 "Match the cluster length\n")
2522 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2523 argv
[idx_number
]->arg
, true, 1);
2526 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2527 "maximum-paths ibgp " CMD_RANGE_STR(
2528 1, MULTIPATH_NUM
) " equal-cluster-length",
2529 "Forward packets over multiple paths\n"
2532 "Match the cluster length\n")
2534 DEFUN (no_bgp_maxpaths
,
2535 no_bgp_maxpaths_cmd
,
2536 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2538 "Forward packets over multiple paths\n"
2539 "Number of paths\n")
2541 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2544 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2545 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2546 "Forward packets over multiple paths\n"
2547 "Number of paths\n")
2549 DEFUN (no_bgp_maxpaths_ibgp
,
2550 no_bgp_maxpaths_ibgp_cmd
,
2551 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2553 "Forward packets over multiple paths\n"
2556 "Match the cluster length\n")
2558 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2561 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2562 "no maximum-paths ibgp [" CMD_RANGE_STR(
2563 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2565 "Forward packets over multiple paths\n"
2568 "Match the cluster length\n")
2570 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2571 afi_t afi
, safi_t safi
)
2573 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2574 vty_out(vty
, " maximum-paths %d\n",
2575 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2578 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2579 vty_out(vty
, " maximum-paths ibgp %d",
2580 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2581 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2582 vty_out(vty
, " equal-cluster-length");
2591 "timers bgp (0-65535) (0-65535)",
2592 "Adjust routing timers\n"
2594 "Keepalive interval\n"
2597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2599 int idx_number_2
= 3;
2600 unsigned long keepalive
= 0;
2601 unsigned long holdtime
= 0;
2603 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2604 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2606 /* Holdtime value check. */
2607 if (holdtime
< 3 && holdtime
!= 0) {
2609 "%% hold time value must be either 0 or greater than 3\n");
2610 return CMD_WARNING_CONFIG_FAILED
;
2613 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2614 BGP_DEFAULT_DELAYOPEN
);
2619 DEFUN (no_bgp_timers
,
2621 "no timers bgp [(0-65535) (0-65535)]",
2623 "Adjust routing timers\n"
2625 "Keepalive interval\n"
2628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2629 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2630 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2635 /* BGP minimum holdtime. */
2637 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2638 "bgp minimum-holdtime (1-65535)",
2639 "BGP specific commands\n"
2640 "BGP minimum holdtime\n"
2643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2645 unsigned long min_holdtime
;
2647 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2649 bgp
->default_min_holdtime
= min_holdtime
;
2654 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2655 "no bgp minimum-holdtime [(1-65535)]",
2657 "BGP specific commands\n"
2658 "BGP minimum holdtime\n"
2661 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2663 bgp
->default_min_holdtime
= 0;
2668 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2669 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2671 "TCP keepalive parameters\n"
2672 "TCP keepalive idle time (seconds)\n"
2673 "TCP keepalive interval (seconds)\n"
2674 "TCP keepalive maximum probes\n")
2676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2678 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2684 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2685 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2688 "TCP keepalive parameters\n"
2689 "TCP keepalive idle time (seconds)\n"
2690 "TCP keepalive interval (seconds)\n"
2691 "TCP keepalive maximum probes\n")
2693 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2695 bgp_tcp_keepalive_unset(bgp
);
2700 DEFUN (bgp_client_to_client_reflection
,
2701 bgp_client_to_client_reflection_cmd
,
2702 "bgp client-to-client reflection",
2704 "Configure client to client route reflection\n"
2705 "reflection of routes allowed\n")
2707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2708 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2709 bgp_clear_star_soft_out(vty
, bgp
->name
);
2714 DEFUN (no_bgp_client_to_client_reflection
,
2715 no_bgp_client_to_client_reflection_cmd
,
2716 "no bgp client-to-client reflection",
2719 "Configure client to client route reflection\n"
2720 "reflection of routes allowed\n")
2722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2723 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2724 bgp_clear_star_soft_out(vty
, bgp
->name
);
2729 /* "bgp always-compare-med" configuration. */
2730 DEFUN (bgp_always_compare_med
,
2731 bgp_always_compare_med_cmd
,
2732 "bgp always-compare-med",
2734 "Allow comparing MED from different neighbors\n")
2736 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2737 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2738 bgp_recalculate_all_bestpaths(bgp
);
2743 DEFUN (no_bgp_always_compare_med
,
2744 no_bgp_always_compare_med_cmd
,
2745 "no bgp always-compare-med",
2748 "Allow comparing MED from different neighbors\n")
2750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2751 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2752 bgp_recalculate_all_bestpaths(bgp
);
2758 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2759 "bgp ebgp-requires-policy",
2761 "Require in and out policy for eBGP peers (RFC8212)\n")
2763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2764 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2768 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2769 "no bgp ebgp-requires-policy",
2772 "Require in and out policy for eBGP peers (RFC8212)\n")
2774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2775 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2779 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2780 "bgp suppress-duplicates",
2782 "Suppress duplicate updates if the route actually not changed\n")
2784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2785 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2789 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2790 "no bgp suppress-duplicates",
2793 "Suppress duplicate updates if the route actually not changed\n")
2795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2796 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2800 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2801 "bgp reject-as-sets",
2803 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2806 struct listnode
*node
, *nnode
;
2809 bgp
->reject_as_sets
= true;
2811 /* Reset existing BGP sessions to reject routes
2812 * with aspath containing AS_SET or AS_CONFED_SET.
2814 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2815 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2816 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2817 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2818 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2825 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2826 "no bgp reject-as-sets",
2829 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2832 struct listnode
*node
, *nnode
;
2835 bgp
->reject_as_sets
= false;
2837 /* Reset existing BGP sessions to reject routes
2838 * with aspath containing AS_SET or AS_CONFED_SET.
2840 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2841 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2842 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2843 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2844 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2851 /* "bgp deterministic-med" configuration. */
2852 DEFUN (bgp_deterministic_med
,
2853 bgp_deterministic_med_cmd
,
2854 "bgp deterministic-med",
2856 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2860 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2861 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2862 bgp_recalculate_all_bestpaths(bgp
);
2868 DEFUN (no_bgp_deterministic_med
,
2869 no_bgp_deterministic_med_cmd
,
2870 "no bgp deterministic-med",
2873 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2876 int bestpath_per_as_used
;
2880 struct listnode
*node
, *nnode
;
2882 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2883 bestpath_per_as_used
= 0;
2885 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2886 FOREACH_AFI_SAFI (afi
, safi
)
2887 if (bgp_addpath_dmed_required(
2888 peer
->addpath_type
[afi
][safi
])) {
2889 bestpath_per_as_used
= 1;
2893 if (bestpath_per_as_used
)
2897 if (bestpath_per_as_used
) {
2899 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2900 return CMD_WARNING_CONFIG_FAILED
;
2902 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2903 bgp_recalculate_all_bestpaths(bgp
);
2910 /* "bgp graceful-restart mode" configuration. */
2911 DEFUN (bgp_graceful_restart
,
2912 bgp_graceful_restart_cmd
,
2913 "bgp graceful-restart",
2918 int ret
= BGP_GR_FAILURE
;
2920 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2921 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2927 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2930 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2931 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2933 "Graceful restart configuration changed, reset all peers to take effect\n");
2934 return bgp_vty_return(vty
, ret
);
2937 DEFUN (no_bgp_graceful_restart
,
2938 no_bgp_graceful_restart_cmd
,
2939 "no bgp graceful-restart",
2945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2947 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2948 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2950 int ret
= BGP_GR_FAILURE
;
2952 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2954 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2957 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2958 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2960 "Graceful restart configuration changed, reset all peers to take effect\n");
2962 return bgp_vty_return(vty
, ret
);
2965 DEFUN (bgp_graceful_restart_stalepath_time
,
2966 bgp_graceful_restart_stalepath_time_cmd
,
2967 "bgp graceful-restart stalepath-time (1-4095)",
2969 "Graceful restart capability parameters\n"
2970 "Set the max time to hold onto restarting peer's stale paths\n"
2971 "Delay value (seconds)\n")
2973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2977 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2978 bgp
->stalepath_time
= stalepath
;
2982 DEFUN (bgp_graceful_restart_restart_time
,
2983 bgp_graceful_restart_restart_time_cmd
,
2984 "bgp graceful-restart restart-time (0-4095)",
2986 "Graceful restart capability parameters\n"
2987 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2988 "Delay value (seconds)\n")
2990 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2994 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2995 bgp
->restart_time
= restart
;
2999 DEFUN (bgp_graceful_restart_select_defer_time
,
3000 bgp_graceful_restart_select_defer_time_cmd
,
3001 "bgp graceful-restart select-defer-time (0-3600)",
3003 "Graceful restart capability parameters\n"
3004 "Set the time to defer the BGP route selection after restart\n"
3005 "Delay value (seconds, 0 - disable)\n")
3007 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3009 uint32_t defer_time
;
3011 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3012 bgp
->select_defer_time
= defer_time
;
3013 if (defer_time
== 0)
3014 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3016 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3021 DEFUN (no_bgp_graceful_restart_stalepath_time
,
3022 no_bgp_graceful_restart_stalepath_time_cmd
,
3023 "no bgp graceful-restart stalepath-time [(1-4095)]",
3026 "Graceful restart capability parameters\n"
3027 "Set the max time to hold onto restarting peer's stale paths\n"
3028 "Delay value (seconds)\n")
3030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3032 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
3036 DEFUN (no_bgp_graceful_restart_restart_time
,
3037 no_bgp_graceful_restart_restart_time_cmd
,
3038 "no bgp graceful-restart restart-time [(0-4095)]",
3041 "Graceful restart capability parameters\n"
3042 "Set the time to wait to delete stale routes before a BGP open message is received\n"
3043 "Delay value (seconds)\n")
3045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3047 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3051 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3052 no_bgp_graceful_restart_select_defer_time_cmd
,
3053 "no bgp graceful-restart select-defer-time [(0-3600)]",
3056 "Graceful restart capability parameters\n"
3057 "Set the time to defer the BGP route selection after restart\n"
3058 "Delay value (seconds)\n")
3060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3062 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3063 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3068 DEFUN (bgp_graceful_restart_preserve_fw
,
3069 bgp_graceful_restart_preserve_fw_cmd
,
3070 "bgp graceful-restart preserve-fw-state",
3072 "Graceful restart capability parameters\n"
3073 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3076 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3080 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3081 no_bgp_graceful_restart_preserve_fw_cmd
,
3082 "no bgp graceful-restart preserve-fw-state",
3085 "Graceful restart capability parameters\n"
3086 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3089 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3093 DEFPY (bgp_graceful_restart_notification
,
3094 bgp_graceful_restart_notification_cmd
,
3095 "[no$no] bgp graceful-restart notification",
3098 "Graceful restart capability parameters\n"
3099 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3104 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3106 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3111 DEFPY (bgp_administrative_reset
,
3112 bgp_administrative_reset_cmd
,
3113 "[no$no] bgp hard-administrative-reset",
3116 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3118 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3121 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3123 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3128 DEFUN (bgp_graceful_restart_disable
,
3129 bgp_graceful_restart_disable_cmd
,
3130 "bgp graceful-restart-disable",
3134 int ret
= BGP_GR_FAILURE
;
3136 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3138 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3142 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3144 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3147 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3149 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3151 "Graceful restart configuration changed, reset all peers to take effect\n");
3153 return bgp_vty_return(vty
, ret
);
3156 DEFUN (no_bgp_graceful_restart_disable
,
3157 no_bgp_graceful_restart_disable_cmd
,
3158 "no bgp graceful-restart-disable",
3164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3166 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3168 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3170 int ret
= BGP_GR_FAILURE
;
3172 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3174 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3177 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3179 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3181 "Graceful restart configuration changed, reset all peers to take effect\n");
3183 return bgp_vty_return(vty
, ret
);
3186 DEFUN (bgp_neighbor_graceful_restart_set
,
3187 bgp_neighbor_graceful_restart_set_cmd
,
3188 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3196 int ret
= BGP_GR_FAILURE
;
3198 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3200 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3202 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3204 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3206 return CMD_WARNING_CONFIG_FAILED
;
3208 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3210 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3211 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3213 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3215 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3217 "Graceful restart configuration changed, reset this peer to take effect\n");
3219 return bgp_vty_return(vty
, ret
);
3222 DEFUN (no_bgp_neighbor_graceful_restart
,
3223 no_bgp_neighbor_graceful_restart_set_cmd
,
3224 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3232 int ret
= BGP_GR_FAILURE
;
3235 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3237 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3239 return CMD_WARNING_CONFIG_FAILED
;
3241 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3243 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3245 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3247 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3248 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3250 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3252 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3254 "Graceful restart configuration changed, reset this peer to take effect\n");
3256 return bgp_vty_return(vty
, ret
);
3259 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3260 bgp_neighbor_graceful_restart_helper_set_cmd
,
3261 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3264 GR_NEIGHBOR_HELPER_CMD
3269 int ret
= BGP_GR_FAILURE
;
3271 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3273 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3275 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3277 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3280 return CMD_WARNING_CONFIG_FAILED
;
3283 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3285 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3286 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3288 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3290 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3292 "Graceful restart configuration changed, reset this peer to take effect\n");
3294 return bgp_vty_return(vty
, ret
);
3297 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3298 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3299 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3303 NO_GR_NEIGHBOR_HELPER_CMD
3307 int ret
= BGP_GR_FAILURE
;
3310 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3312 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3314 return CMD_WARNING_CONFIG_FAILED
;
3316 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3318 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3320 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3322 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3323 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3325 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3327 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3329 "Graceful restart configuration changed, reset this peer to take effect\n");
3331 return bgp_vty_return(vty
, ret
);
3334 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3335 bgp_neighbor_graceful_restart_disable_set_cmd
,
3336 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3339 GR_NEIGHBOR_DISABLE_CMD
3344 int ret
= BGP_GR_FAILURE
;
3346 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3348 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3350 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3352 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3354 return CMD_WARNING_CONFIG_FAILED
;
3356 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3358 if (peer
->bgp
->t_startup
)
3359 bgp_peer_gr_flags_update(peer
);
3361 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3362 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3364 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3366 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3368 "Graceful restart configuration changed, reset this peer to take effect\n");
3370 return bgp_vty_return(vty
, ret
);
3373 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3374 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3375 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3379 NO_GR_NEIGHBOR_DISABLE_CMD
3383 int ret
= BGP_GR_FAILURE
;
3386 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3388 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3390 return CMD_WARNING_CONFIG_FAILED
;
3392 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3394 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3396 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3398 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3399 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3401 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3403 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3405 "Graceful restart configuration changed, reset this peer to take effect\n");
3407 return bgp_vty_return(vty
, ret
);
3410 DEFPY (neighbor_graceful_shutdown
,
3411 neighbor_graceful_shutdown_cmd
,
3412 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3416 "Graceful shutdown\n")
3421 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3424 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3426 return CMD_WARNING_CONFIG_FAILED
;
3429 ret
= peer_flag_unset_vty(vty
, neighbor
,
3430 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3432 ret
= peer_flag_set_vty(vty
, neighbor
,
3433 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3435 FOREACH_AFI_SAFI (afi
, safi
) {
3436 if (!peer
->afc
[afi
][safi
])
3439 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3446 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3447 bgp_graceful_restart_disable_eor_cmd
,
3448 "bgp graceful-restart disable-eor",
3450 "Graceful restart configuration parameters\n"
3451 "Disable EOR Check\n")
3453 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3454 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3459 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3460 no_bgp_graceful_restart_disable_eor_cmd
,
3461 "no bgp graceful-restart disable-eor",
3464 "Graceful restart configuration parameters\n"
3465 "Disable EOR Check\n")
3467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3468 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3473 DEFUN (bgp_graceful_restart_rib_stale_time
,
3474 bgp_graceful_restart_rib_stale_time_cmd
,
3475 "bgp graceful-restart rib-stale-time (1-3600)",
3477 "Graceful restart configuration parameters\n"
3478 "Specify the stale route removal timer in rib\n"
3479 "Delay value (seconds)\n")
3481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3483 uint32_t stale_time
;
3485 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3486 bgp
->rib_stale_time
= stale_time
;
3487 /* Send the stale timer update message to RIB */
3488 if (bgp_zebra_stale_timer_update(bgp
))
3494 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3495 no_bgp_graceful_restart_rib_stale_time_cmd
,
3496 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3499 "Graceful restart configuration parameters\n"
3500 "Specify the stale route removal timer in rib\n"
3501 "Delay value (seconds)\n")
3503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3505 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3506 /* Send the stale timer update message to RIB */
3507 if (bgp_zebra_stale_timer_update(bgp
))
3513 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3514 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3516 "Enable Long-lived Graceful Restart\n"
3517 "Specifies maximum time to wait before purging long-lived stale routes\n"
3518 "Stale time value (seconds)\n")
3520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3522 uint32_t llgr_stale_time
;
3524 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3525 bgp
->llgr_stale_time
= llgr_stale_time
;
3530 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3531 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3533 "Enable Long-lived Graceful Restart\n"
3534 "Specifies maximum time to wait before purging long-lived stale routes\n"
3535 "Stale time value (seconds)\n")
3537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3539 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3544 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3547 bgp_static_redo_import_check(bgp
);
3548 bgp_redistribute_redo(bgp
);
3549 bgp_clear_star_soft_out(vty
, bgp
->name
);
3550 bgp_clear_star_soft_in(vty
, bgp
->name
);
3553 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3555 struct listnode
*node
, *nnode
;
3557 bool vrf_cfg
= false;
3559 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3562 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3563 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3564 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3566 "%% graceful-shutdown configuration found in vrf %s\n",
3567 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3568 VRF_DEFAULT_NAME
: bgp
->name
);
3575 "%%Failed: global graceful-shutdown not permitted\n");
3579 /* Set flag globally */
3580 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3582 /* Initiate processing for all BGP instances. */
3583 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3584 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3589 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3591 struct listnode
*node
, *nnode
;
3594 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3597 /* Unset flag globally */
3598 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3600 /* Initiate processing for all BGP instances. */
3601 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3602 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3607 /* "bgp graceful-shutdown" configuration */
3608 DEFUN (bgp_graceful_shutdown
,
3609 bgp_graceful_shutdown_cmd
,
3610 "bgp graceful-shutdown",
3612 "Graceful shutdown parameters\n")
3614 if (vty
->node
== CONFIG_NODE
)
3615 return bgp_global_graceful_shutdown_config_vty(vty
);
3617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3619 /* if configured globally, per-instance config is not allowed */
3620 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3622 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3623 return CMD_WARNING_CONFIG_FAILED
;
3626 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3627 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3628 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3634 DEFUN (no_bgp_graceful_shutdown
,
3635 no_bgp_graceful_shutdown_cmd
,
3636 "no bgp graceful-shutdown",
3639 "Graceful shutdown parameters\n")
3641 if (vty
->node
== CONFIG_NODE
)
3642 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3644 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3646 /* If configured globally, cannot remove from one bgp instance */
3647 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3649 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3650 return CMD_WARNING_CONFIG_FAILED
;
3653 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3654 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3655 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3661 /* "bgp fast-external-failover" configuration. */
3662 DEFUN (bgp_fast_external_failover
,
3663 bgp_fast_external_failover_cmd
,
3664 "bgp fast-external-failover",
3666 "Immediately reset session if a link to a directly connected external peer goes down\n")
3668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3669 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3673 DEFUN (no_bgp_fast_external_failover
,
3674 no_bgp_fast_external_failover_cmd
,
3675 "no bgp fast-external-failover",
3678 "Immediately reset session if a link to a directly connected external peer goes down\n")
3680 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3681 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3685 DEFPY (bgp_bestpath_aigp
,
3686 bgp_bestpath_aigp_cmd
,
3687 "[no$no] bgp bestpath aigp",
3690 "Change the default bestpath selection\n"
3691 "Evaluate the AIGP attribute during the best path selection process\n")
3693 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3696 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3698 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3700 bgp_recalculate_all_bestpaths(bgp
);
3705 /* "bgp bestpath compare-routerid" configuration. */
3706 DEFUN (bgp_bestpath_compare_router_id
,
3707 bgp_bestpath_compare_router_id_cmd
,
3708 "bgp bestpath compare-routerid",
3710 "Change the default bestpath selection\n"
3711 "Compare router-id for identical EBGP paths\n")
3713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3714 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3715 bgp_recalculate_all_bestpaths(bgp
);
3720 DEFUN (no_bgp_bestpath_compare_router_id
,
3721 no_bgp_bestpath_compare_router_id_cmd
,
3722 "no bgp bestpath compare-routerid",
3725 "Change the default bestpath selection\n"
3726 "Compare router-id for identical EBGP paths\n")
3728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3729 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3730 bgp_recalculate_all_bestpaths(bgp
);
3735 /* "bgp bestpath as-path ignore" configuration. */
3736 DEFUN (bgp_bestpath_aspath_ignore
,
3737 bgp_bestpath_aspath_ignore_cmd
,
3738 "bgp bestpath as-path ignore",
3740 "Change the default bestpath selection\n"
3741 "AS-path attribute\n"
3742 "Ignore as-path length in selecting a route\n")
3744 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3745 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3746 bgp_recalculate_all_bestpaths(bgp
);
3751 DEFUN (no_bgp_bestpath_aspath_ignore
,
3752 no_bgp_bestpath_aspath_ignore_cmd
,
3753 "no bgp bestpath as-path ignore",
3756 "Change the default bestpath selection\n"
3757 "AS-path attribute\n"
3758 "Ignore as-path length in selecting a route\n")
3760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3761 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3762 bgp_recalculate_all_bestpaths(bgp
);
3767 /* "bgp bestpath as-path confed" configuration. */
3768 DEFUN (bgp_bestpath_aspath_confed
,
3769 bgp_bestpath_aspath_confed_cmd
,
3770 "bgp bestpath as-path confed",
3772 "Change the default bestpath selection\n"
3773 "AS-path attribute\n"
3774 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3777 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3778 bgp_recalculate_all_bestpaths(bgp
);
3783 DEFUN (no_bgp_bestpath_aspath_confed
,
3784 no_bgp_bestpath_aspath_confed_cmd
,
3785 "no bgp bestpath as-path confed",
3788 "Change the default bestpath selection\n"
3789 "AS-path attribute\n"
3790 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3793 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3794 bgp_recalculate_all_bestpaths(bgp
);
3799 /* "bgp bestpath as-path multipath-relax" configuration. */
3800 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3801 bgp_bestpath_aspath_multipath_relax_cmd
,
3802 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3804 "Change the default bestpath selection\n"
3805 "AS-path attribute\n"
3806 "Allow load sharing across routes that have different AS paths (but same length)\n"
3807 "Generate an AS_SET\n"
3808 "Do not generate an AS_SET\n")
3810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3812 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3814 /* no-as-set is now the default behavior so we can silently
3816 if (argv_find(argv
, argc
, "as-set", &idx
))
3817 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3819 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3821 bgp_recalculate_all_bestpaths(bgp
);
3826 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3827 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3828 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3831 "Change the default bestpath selection\n"
3832 "AS-path attribute\n"
3833 "Allow load sharing across routes that have different AS paths (but same length)\n"
3834 "Generate an AS_SET\n"
3835 "Do not generate an AS_SET\n")
3837 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3838 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3839 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3840 bgp_recalculate_all_bestpaths(bgp
);
3845 /* "bgp bestpath peer-type multipath-relax" configuration. */
3846 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3847 bgp_bestpath_peer_type_multipath_relax_cmd
,
3848 "bgp bestpath peer-type multipath-relax",
3850 "Change the default bestpath selection\n"
3852 "Allow load sharing across routes learned from different peer types\n")
3854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3855 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3856 bgp_recalculate_all_bestpaths(bgp
);
3861 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3862 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3863 "no bgp bestpath peer-type multipath-relax",
3865 "Change the default bestpath selection\n"
3867 "Allow load sharing across routes learned from different peer types\n")
3869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3870 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3871 bgp_recalculate_all_bestpaths(bgp
);
3876 /* "bgp log-neighbor-changes" configuration. */
3877 DEFUN (bgp_log_neighbor_changes
,
3878 bgp_log_neighbor_changes_cmd
,
3879 "bgp log-neighbor-changes",
3881 "Log neighbor up/down and reset reason\n")
3883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3884 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3888 DEFUN (no_bgp_log_neighbor_changes
,
3889 no_bgp_log_neighbor_changes_cmd
,
3890 "no bgp log-neighbor-changes",
3893 "Log neighbor up/down and reset reason\n")
3895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3896 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3900 /* "bgp bestpath med" configuration. */
3901 DEFUN (bgp_bestpath_med
,
3902 bgp_bestpath_med_cmd
,
3903 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3905 "Change the default bestpath selection\n"
3907 "Compare MED among confederation paths\n"
3908 "Treat missing MED as the least preferred one\n"
3909 "Treat missing MED as the least preferred one\n"
3910 "Compare MED among confederation paths\n")
3912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3915 if (argv_find(argv
, argc
, "confed", &idx
))
3916 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3918 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3919 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3921 bgp_recalculate_all_bestpaths(bgp
);
3926 DEFUN (no_bgp_bestpath_med
,
3927 no_bgp_bestpath_med_cmd
,
3928 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3931 "Change the default bestpath selection\n"
3933 "Compare MED among confederation paths\n"
3934 "Treat missing MED as the least preferred one\n"
3935 "Treat missing MED as the least preferred one\n"
3936 "Compare MED among confederation paths\n")
3938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3941 if (argv_find(argv
, argc
, "confed", &idx
))
3942 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3944 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3945 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3947 bgp_recalculate_all_bestpaths(bgp
);
3952 /* "bgp bestpath bandwidth" configuration. */
3953 DEFPY (bgp_bestpath_bw
,
3954 bgp_bestpath_bw_cmd
,
3955 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3957 "Change the default bestpath selection\n"
3958 "Link Bandwidth attribute\n"
3959 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3960 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3961 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3968 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3969 return CMD_ERR_INCOMPLETE
;
3971 if (!strcmp(bw_cfg
, "ignore"))
3972 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3973 else if (!strcmp(bw_cfg
, "skip-missing"))
3974 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3975 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3976 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3978 return CMD_ERR_NO_MATCH
;
3980 /* This config is used in route install, so redo that. */
3981 FOREACH_AFI_SAFI (afi
, safi
) {
3982 if (!bgp_fibupd_safi(safi
))
3984 bgp_zebra_announce_table(bgp
, afi
, safi
);
3990 DEFPY (no_bgp_bestpath_bw
,
3991 no_bgp_bestpath_bw_cmd
,
3992 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3995 "Change the default bestpath selection\n"
3996 "Link Bandwidth attribute\n"
3997 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3998 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3999 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
4001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4005 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
4007 /* This config is used in route install, so redo that. */
4008 FOREACH_AFI_SAFI (afi
, safi
) {
4009 if (!bgp_fibupd_safi(safi
))
4011 bgp_zebra_announce_table(bgp
, afi
, safi
);
4016 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
4017 "[no] bgp default <ipv4-unicast|"
4020 "ipv4-labeled-unicast|"
4025 "ipv6-labeled-unicast|"
4027 "l2vpn-evpn>$afi_safi",
4030 "Configure BGP defaults\n"
4031 "Activate ipv4-unicast for a peer by default\n"
4032 "Activate ipv4-multicast for a peer by default\n"
4033 "Activate ipv4-vpn for a peer by default\n"
4034 "Activate ipv4-labeled-unicast for a peer by default\n"
4035 "Activate ipv4-flowspec for a peer by default\n"
4036 "Activate ipv6-unicast for a peer by default\n"
4037 "Activate ipv6-multicast for a peer by default\n"
4038 "Activate ipv6-vpn for a peer by default\n"
4039 "Activate ipv6-labeled-unicast for a peer by default\n"
4040 "Activate ipv6-flowspec for a peer by default\n"
4041 "Activate l2vpn-evpn for a peer by default\n")
4043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4044 char afi_safi_str
[strlen(afi_safi
) + 1];
4045 char *afi_safi_str_tok
;
4047 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4048 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4049 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4050 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4054 * Impossible situation but making coverity happy
4056 assert(afi
!= AFI_MAX
);
4058 if (strmatch(safi_str
, "labeled"))
4059 safi
= bgp_vty_safi_from_str("labeled-unicast");
4061 safi
= bgp_vty_safi_from_str(safi_str
);
4063 assert(safi
!= SAFI_MAX
);
4065 bgp
->default_af
[afi
][safi
] = false;
4067 if ((safi
== SAFI_LABELED_UNICAST
4068 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4069 || (safi
== SAFI_UNICAST
4070 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4071 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4073 bgp
->default_af
[afi
][safi
] = true;
4079 /* Display hostname in certain command outputs */
4080 DEFUN (bgp_default_show_hostname
,
4081 bgp_default_show_hostname_cmd
,
4082 "bgp default show-hostname",
4084 "Configure BGP defaults\n"
4085 "Show hostname in certain command outputs\n")
4087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4088 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4092 DEFUN (no_bgp_default_show_hostname
,
4093 no_bgp_default_show_hostname_cmd
,
4094 "no bgp default show-hostname",
4097 "Configure BGP defaults\n"
4098 "Show hostname in certain command outputs\n")
4100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4101 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4105 /* Display hostname in certain command outputs */
4106 DEFUN (bgp_default_show_nexthop_hostname
,
4107 bgp_default_show_nexthop_hostname_cmd
,
4108 "bgp default show-nexthop-hostname",
4110 "Configure BGP defaults\n"
4111 "Show hostname for nexthop in certain command outputs\n")
4113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4114 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4118 DEFUN (no_bgp_default_show_nexthop_hostname
,
4119 no_bgp_default_show_nexthop_hostname_cmd
,
4120 "no bgp default show-nexthop-hostname",
4123 "Configure BGP defaults\n"
4124 "Show hostname for nexthop in certain command outputs\n")
4126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4127 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4131 /* "bgp network import-check" configuration. */
4132 DEFUN (bgp_network_import_check
,
4133 bgp_network_import_check_cmd
,
4134 "bgp network import-check",
4136 "BGP network command\n"
4137 "Check BGP network route exists in IGP\n")
4139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4140 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4141 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4142 bgp_static_redo_import_check(bgp
);
4148 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4149 "bgp network import-check exact",
4151 "BGP network command\n"
4152 "Check BGP network route exists in IGP\n"
4153 "Match route precisely\n")
4155 DEFUN (no_bgp_network_import_check
,
4156 no_bgp_network_import_check_cmd
,
4157 "no bgp network import-check",
4160 "BGP network command\n"
4161 "Check BGP network route exists in IGP\n")
4163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4164 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4165 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4166 bgp_static_redo_import_check(bgp
);
4172 DEFUN (bgp_default_local_preference
,
4173 bgp_default_local_preference_cmd
,
4174 "bgp default local-preference (0-4294967295)",
4176 "Configure BGP defaults\n"
4177 "local preference (higher=more preferred)\n"
4178 "Configure default local preference value\n")
4180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4182 uint32_t local_pref
;
4184 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4186 bgp_default_local_preference_set(bgp
, local_pref
);
4187 bgp_clear_star_soft_in(vty
, bgp
->name
);
4192 DEFUN (no_bgp_default_local_preference
,
4193 no_bgp_default_local_preference_cmd
,
4194 "no bgp default local-preference [(0-4294967295)]",
4197 "Configure BGP defaults\n"
4198 "local preference (higher=more preferred)\n"
4199 "Configure default local preference value\n")
4201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4202 bgp_default_local_preference_unset(bgp
);
4203 bgp_clear_star_soft_in(vty
, bgp
->name
);
4209 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4210 bgp_default_subgroup_pkt_queue_max_cmd
,
4211 "bgp default subgroup-pkt-queue-max (20-100)",
4213 "Configure BGP defaults\n"
4214 "subgroup-pkt-queue-max\n"
4215 "Configure subgroup packet queue max\n")
4217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4221 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4223 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4228 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4229 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4230 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4233 "Configure BGP defaults\n"
4234 "subgroup-pkt-queue-max\n"
4235 "Configure subgroup packet queue max\n")
4237 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4238 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4243 DEFUN (bgp_rr_allow_outbound_policy
,
4244 bgp_rr_allow_outbound_policy_cmd
,
4245 "bgp route-reflector allow-outbound-policy",
4247 "Allow modifications made by out route-map\n"
4248 "on ibgp neighbors\n")
4250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4252 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4253 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4254 update_group_announce_rrclients(bgp
);
4255 bgp_clear_star_soft_out(vty
, bgp
->name
);
4261 DEFUN (no_bgp_rr_allow_outbound_policy
,
4262 no_bgp_rr_allow_outbound_policy_cmd
,
4263 "no bgp route-reflector allow-outbound-policy",
4266 "Allow modifications made by out route-map\n"
4267 "on ibgp neighbors\n")
4269 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4271 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4272 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4273 update_group_announce_rrclients(bgp
);
4274 bgp_clear_star_soft_out(vty
, bgp
->name
);
4280 DEFUN (bgp_listen_limit
,
4281 bgp_listen_limit_cmd
,
4282 "bgp listen limit (1-65535)",
4284 "BGP Dynamic Neighbors listen commands\n"
4285 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4286 "Configure Dynamic Neighbors listen limit value\n")
4288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4292 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4294 bgp_listen_limit_set(bgp
, listen_limit
);
4299 DEFUN (no_bgp_listen_limit
,
4300 no_bgp_listen_limit_cmd
,
4301 "no bgp listen limit [(1-65535)]",
4304 "BGP Dynamic Neighbors listen commands\n"
4305 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4306 "Configure Dynamic Neighbors listen limit value\n")
4308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4309 bgp_listen_limit_unset(bgp
);
4315 * Check if this listen range is already configured. Check for exact
4316 * match or overlap based on input.
4318 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4319 struct prefix
*range
, int exact
)
4321 struct listnode
*node
, *nnode
;
4322 struct listnode
*node1
, *nnode1
;
4323 struct peer_group
*group
;
4328 afi
= family2afi(range
->family
);
4329 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4330 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4333 match
= prefix_same(range
, lr
);
4335 match
= (prefix_match(range
, lr
)
4336 || prefix_match(lr
, range
));
4345 DEFUN (bgp_listen_range
,
4346 bgp_listen_range_cmd
,
4347 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4349 "Configure BGP dynamic neighbors listen range\n"
4350 "Configure BGP dynamic neighbors listen range\n"
4352 "Member of the peer-group\n"
4353 "Peer-group name\n")
4355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4356 struct prefix range
;
4357 struct peer_group
*group
, *existing_group
;
4362 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4363 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4364 char *prefix
= argv
[idx
]->arg
;
4365 argv_find(argv
, argc
, "PGNAME", &idx
);
4366 char *peergroup
= argv
[idx
]->arg
;
4368 /* Convert IP prefix string to struct prefix. */
4369 ret
= str2prefix(prefix
, &range
);
4371 vty_out(vty
, "%% Malformed listen range\n");
4372 return CMD_WARNING_CONFIG_FAILED
;
4375 afi
= family2afi(range
.family
);
4377 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4379 "%% Malformed listen range (link-local address)\n");
4380 return CMD_WARNING_CONFIG_FAILED
;
4385 /* Check if same listen range is already configured. */
4386 existing_group
= listen_range_exists(bgp
, &range
, 1);
4387 if (existing_group
) {
4388 if (strcmp(existing_group
->name
, peergroup
) == 0)
4392 "%% Same listen range is attached to peer-group %s\n",
4393 existing_group
->name
);
4394 return CMD_WARNING_CONFIG_FAILED
;
4398 /* Check if an overlapping listen range exists. */
4399 if (listen_range_exists(bgp
, &range
, 0)) {
4401 "%% Listen range overlaps with existing listen range\n");
4402 return CMD_WARNING_CONFIG_FAILED
;
4405 group
= peer_group_lookup(bgp
, peergroup
);
4407 vty_out(vty
, "%% Configure the peer-group first\n");
4408 return CMD_WARNING_CONFIG_FAILED
;
4411 ret
= peer_group_listen_range_add(group
, &range
);
4412 return bgp_vty_return(vty
, ret
);
4415 DEFUN (no_bgp_listen_range
,
4416 no_bgp_listen_range_cmd
,
4417 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4420 "Unconfigure BGP dynamic neighbors listen range\n"
4421 "Unconfigure BGP dynamic neighbors listen range\n"
4423 "Member of the peer-group\n"
4424 "Peer-group name\n")
4426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4427 struct prefix range
;
4428 struct peer_group
*group
;
4433 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4434 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4435 char *prefix
= argv
[idx
]->arg
;
4436 argv_find(argv
, argc
, "PGNAME", &idx
);
4437 char *peergroup
= argv
[idx
]->arg
;
4439 /* Convert IP prefix string to struct prefix. */
4440 ret
= str2prefix(prefix
, &range
);
4442 vty_out(vty
, "%% Malformed listen range\n");
4443 return CMD_WARNING_CONFIG_FAILED
;
4446 afi
= family2afi(range
.family
);
4448 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4450 "%% Malformed listen range (link-local address)\n");
4451 return CMD_WARNING_CONFIG_FAILED
;
4456 group
= peer_group_lookup(bgp
, peergroup
);
4458 vty_out(vty
, "%% Peer-group does not exist\n");
4459 return CMD_WARNING_CONFIG_FAILED
;
4462 ret
= peer_group_listen_range_del(group
, &range
);
4463 return bgp_vty_return(vty
, ret
);
4466 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4468 struct peer_group
*group
;
4469 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4470 struct prefix
*range
;
4473 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4474 vty_out(vty
, " bgp listen limit %d\n",
4475 bgp
->dynamic_neighbors_limit
);
4477 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4478 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4479 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4482 " bgp listen range %pFX peer-group %s\n",
4483 range
, group
->name
);
4490 DEFUN (bgp_disable_connected_route_check
,
4491 bgp_disable_connected_route_check_cmd
,
4492 "bgp disable-ebgp-connected-route-check",
4494 "Disable checking if nexthop is connected on ebgp sessions\n")
4496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4497 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4498 bgp_clear_star_soft_in(vty
, bgp
->name
);
4503 DEFUN (no_bgp_disable_connected_route_check
,
4504 no_bgp_disable_connected_route_check_cmd
,
4505 "no bgp disable-ebgp-connected-route-check",
4508 "Disable checking if nexthop is connected on ebgp sessions\n")
4510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4511 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4512 bgp_clear_star_soft_in(vty
, bgp
->name
);
4518 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4524 int as_type
= AS_SPECIFIED
;
4527 if (as_str
[0] == 'i') {
4529 as_type
= AS_INTERNAL
;
4530 } else if (as_str
[0] == 'e') {
4532 as_type
= AS_EXTERNAL
;
4533 } else if (!asn_str2asn(as_str
, &as
))
4534 as_type
= AS_UNSPECIFIED
;
4536 if (as_type
== AS_UNSPECIFIED
) {
4537 vty_out(vty
, "%% Invalid peer AS: %s\n", as_str
);
4538 return CMD_WARNING_CONFIG_FAILED
;
4540 /* If peer is peer group or interface peer, call proper function. */
4541 ret
= str2sockunion(peer_str
, &su
);
4545 /* Check if existing interface peer */
4546 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4548 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4550 /* if not interface peer, check peer-group settings */
4551 if (ret
< 0 && !peer
) {
4552 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4555 "%% Create the peer-group or interface first\n");
4556 return CMD_WARNING_CONFIG_FAILED
;
4561 if (peer_address_self_check(bgp
, &su
)) {
4563 "%% Can not configure the local system as neighbor\n");
4564 return CMD_WARNING_CONFIG_FAILED
;
4566 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4569 return bgp_vty_return(vty
, ret
);
4572 DEFUN (bgp_default_shutdown
,
4573 bgp_default_shutdown_cmd
,
4574 "[no] bgp default shutdown",
4577 "Configure BGP defaults\n"
4578 "Apply administrative shutdown to newly configured peers\n")
4580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4581 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4585 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4587 "Administrative shutdown of the BGP instance\n"
4588 "Add a shutdown message (RFC 8203)\n"
4589 "Shutdown message\n")
4591 char *msgstr
= NULL
;
4593 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4596 msgstr
= argv_concat(argv
, argc
, 3);
4598 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4599 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4600 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4601 return CMD_WARNING_CONFIG_FAILED
;
4604 bgp_shutdown_enable(bgp
, msgstr
);
4605 XFREE(MTYPE_TMP
, msgstr
);
4610 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4611 BGP_STR
"Administrative shutdown of the BGP instance\n")
4613 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4615 bgp_shutdown_enable(bgp
, NULL
);
4620 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4621 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4623 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4625 bgp_shutdown_disable(bgp
);
4630 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4631 "no bgp shutdown message MSG...", NO_STR BGP_STR
4632 "Administrative shutdown of the BGP instance\n"
4633 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4635 DEFUN (neighbor_remote_as
,
4636 neighbor_remote_as_cmd
,
4637 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <ASNUM|internal|external>",
4640 "Specify a BGP neighbor\n"
4642 "Internal BGP peer\n"
4643 "External BGP peer\n")
4646 int idx_remote_as
= 3;
4647 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4648 argv
[idx_remote_as
]->arg
);
4651 DEFPY (bgp_allow_martian
,
4652 bgp_allow_martian_cmd
,
4653 "[no]$no bgp allow-martian-nexthop",
4656 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4661 bgp
->allow_martian
= false;
4663 bgp
->allow_martian
= true;
4668 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4669 * sessions do not wait for hold timer expiry to bring down the sessions
4670 * when nexthop becomes unreachable
4672 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4673 BGP_STR
"Fast convergence for bgp sessions\n")
4675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4676 bgp
->fast_convergence
= true;
4681 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4682 "no bgp fast-convergence",
4683 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4685 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4686 bgp
->fast_convergence
= false;
4691 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4693 const char *peer_group_name
,
4696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4698 int as_type
= AS_UNSPECIFIED
;
4700 struct peer_group
*group
;
4703 group
= peer_group_lookup(bgp
, conf_if
);
4706 vty_out(vty
, "%% Name conflict with peer-group \n");
4707 return CMD_WARNING_CONFIG_FAILED
;
4711 if (as_str
[0] == 'i') {
4712 as_type
= AS_INTERNAL
;
4713 } else if (as_str
[0] == 'e') {
4714 as_type
= AS_EXTERNAL
;
4716 /* Get AS number. */
4717 if (asn_str2asn(as_str
, &as
))
4718 as_type
= AS_SPECIFIED
;
4722 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4725 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4727 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4731 vty_out(vty
, "%% BGP failed to create peer\n");
4732 return CMD_WARNING_CONFIG_FAILED
;
4736 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4738 /* Request zebra to initiate IPv6 RAs on this interface. We do
4740 * any unnumbered peer in order to not worry about run-time
4742 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4744 * gets deleted later etc.)
4747 bgp_zebra_initiate_radv(bgp
, peer
);
4750 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4751 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4753 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4755 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4757 /* v6only flag changed. Reset bgp seesion */
4758 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4759 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4760 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4761 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4763 bgp_session_reset(peer
);
4766 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4767 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4768 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4769 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4772 if (peer_group_name
) {
4773 group
= peer_group_lookup(bgp
, peer_group_name
);
4775 vty_out(vty
, "%% Configure the peer-group first\n");
4776 return CMD_WARNING_CONFIG_FAILED
;
4779 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4782 return bgp_vty_return(vty
, ret
);
4785 DEFUN (neighbor_interface_config
,
4786 neighbor_interface_config_cmd
,
4787 "neighbor WORD interface [peer-group PGNAME]",
4789 "Interface name or neighbor tag\n"
4790 "Enable BGP on interface\n"
4791 "Member of the peer-group\n"
4792 "Peer-group name\n")
4795 int idx_peer_group_word
= 4;
4797 if (argc
> idx_peer_group_word
)
4798 return peer_conf_interface_get(
4799 vty
, argv
[idx_word
]->arg
, 0,
4800 argv
[idx_peer_group_word
]->arg
, NULL
);
4802 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4806 DEFUN (neighbor_interface_config_v6only
,
4807 neighbor_interface_config_v6only_cmd
,
4808 "neighbor WORD interface v6only [peer-group PGNAME]",
4810 "Interface name or neighbor tag\n"
4811 "Enable BGP on interface\n"
4812 "Enable BGP with v6 link-local only\n"
4813 "Member of the peer-group\n"
4814 "Peer-group name\n")
4817 int idx_peer_group_word
= 5;
4819 if (argc
> idx_peer_group_word
)
4820 return peer_conf_interface_get(
4821 vty
, argv
[idx_word
]->arg
, 1,
4822 argv
[idx_peer_group_word
]->arg
, NULL
);
4824 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4828 DEFUN (neighbor_interface_config_remote_as
,
4829 neighbor_interface_config_remote_as_cmd
,
4830 "neighbor WORD interface remote-as <ASNUM|internal|external>",
4832 "Interface name or neighbor tag\n"
4833 "Enable BGP on interface\n"
4834 "Specify a BGP neighbor\n"
4836 "Internal BGP peer\n"
4837 "External BGP peer\n")
4840 int idx_remote_as
= 4;
4841 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4842 argv
[idx_remote_as
]->arg
);
4845 DEFUN (neighbor_interface_v6only_config_remote_as
,
4846 neighbor_interface_v6only_config_remote_as_cmd
,
4847 "neighbor WORD interface v6only remote-as <ASNUM|internal|external>",
4849 "Interface name or neighbor tag\n"
4850 "Enable BGP with v6 link-local only\n"
4851 "Enable BGP on interface\n"
4852 "Specify a BGP neighbor\n"
4854 "Internal BGP peer\n"
4855 "External BGP peer\n")
4858 int idx_remote_as
= 5;
4859 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4860 argv
[idx_remote_as
]->arg
);
4863 DEFUN (neighbor_peer_group
,
4864 neighbor_peer_group_cmd
,
4865 "neighbor WORD peer-group",
4867 "Interface name or neighbor tag\n"
4868 "Configure peer-group\n")
4870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4873 struct peer_group
*group
;
4875 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4877 vty_out(vty
, "%% Name conflict with interface: \n");
4878 return CMD_WARNING_CONFIG_FAILED
;
4881 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4883 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4884 return CMD_WARNING_CONFIG_FAILED
;
4892 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4896 "Specify a BGP neighbor\n"
4898 "Internal BGP peer\n"
4899 "External BGP peer\n")
4901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4905 struct peer_group
*group
;
4909 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4911 /* look up for neighbor by interface name config. */
4912 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4914 /* Request zebra to terminate IPv6 RAs on this
4917 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4918 peer_notify_unconfig(peer
);
4923 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4925 peer_group_notify_unconfig(group
);
4926 peer_group_delete(group
);
4928 vty_out(vty
, "%% Create the peer-group first\n");
4929 return CMD_WARNING_CONFIG_FAILED
;
4932 peer
= peer_lookup(bgp
, &su
);
4934 if (peer_dynamic_neighbor(peer
)) {
4936 "%% Operation not allowed on a dynamic neighbor\n");
4937 return CMD_WARNING_CONFIG_FAILED
;
4940 other
= peer
->doppelganger
;
4942 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4943 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4945 peer_notify_unconfig(peer
);
4947 if (other
&& other
->status
!= Deleted
) {
4948 peer_notify_unconfig(other
);
4957 DEFUN (no_neighbor_interface_config
,
4958 no_neighbor_interface_config_cmd
,
4959 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4963 "Configure BGP on interface\n"
4964 "Enable BGP with v6 link-local only\n"
4965 "Member of the peer-group\n"
4967 "Specify a BGP neighbor\n"
4969 "Internal BGP peer\n"
4970 "External BGP peer\n")
4972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4976 /* look up for neighbor by interface name config. */
4977 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4979 /* Request zebra to terminate IPv6 RAs on this interface. */
4981 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4982 peer_notify_unconfig(peer
);
4985 vty_out(vty
, "%% Create the bgp interface first\n");
4986 return CMD_WARNING_CONFIG_FAILED
;
4991 DEFUN (no_neighbor_peer_group
,
4992 no_neighbor_peer_group_cmd
,
4993 "no neighbor WORD peer-group",
4997 "Configure peer-group\n")
4999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5001 struct peer_group
*group
;
5003 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5005 peer_group_notify_unconfig(group
);
5006 peer_group_delete(group
);
5008 vty_out(vty
, "%% Create the peer-group first\n");
5009 return CMD_WARNING_CONFIG_FAILED
;
5014 DEFUN (no_neighbor_interface_peer_group_remote_as
,
5015 no_neighbor_interface_peer_group_remote_as_cmd
,
5016 "no neighbor WORD remote-as <ASNUM|internal|external>",
5019 "Interface name or neighbor tag\n"
5020 "Specify a BGP neighbor\n"
5022 "Internal BGP peer\n"
5023 "External BGP peer\n")
5025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5027 struct peer_group
*group
;
5030 /* look up for neighbor by interface name config. */
5031 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
5033 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
5037 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5039 peer_group_remote_as_delete(group
);
5041 vty_out(vty
, "%% Create the peer-group or interface first\n");
5042 return CMD_WARNING_CONFIG_FAILED
;
5047 DEFUN (neighbor_local_as
,
5048 neighbor_local_as_cmd
,
5049 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM",
5052 "Specify a local-as number\n"
5053 "AS number expressed in dotted or plain format used as local AS\n")
5061 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5063 return CMD_WARNING_CONFIG_FAILED
;
5065 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5066 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5067 argv
[idx_number
]->arg
);
5068 return CMD_WARNING_CONFIG_FAILED
;
5071 ret
= peer_local_as_set(peer
, as
, 0, 0);
5072 return bgp_vty_return(vty
, ret
);
5075 DEFUN (neighbor_local_as_no_prepend
,
5076 neighbor_local_as_no_prepend_cmd
,
5077 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend",
5080 "Specify a local-as number\n"
5081 "AS number expressed in dotted or plain format used as local AS\n"
5082 "Do not prepend local-as to updates from ebgp peers\n")
5090 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5092 return CMD_WARNING_CONFIG_FAILED
;
5094 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5095 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5096 argv
[idx_number
]->arg
);
5097 return CMD_WARNING_CONFIG_FAILED
;
5100 ret
= peer_local_as_set(peer
, as
, 1, 0);
5101 return bgp_vty_return(vty
, ret
);
5104 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5105 neighbor_local_as_no_prepend_replace_as_cmd
,
5106 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend replace-as",
5109 "Specify a local-as number\n"
5110 "AS number expressed in dotted or plain format used as local AS\n"
5111 "Do not prepend local-as to updates from ebgp peers\n"
5112 "Do not prepend local-as to updates from ibgp peers\n")
5120 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5122 return CMD_WARNING_CONFIG_FAILED
;
5124 if (!asn_str2asn(argv
[idx_number
]->arg
, &as
)) {
5125 vty_out(vty
, "%% Invalid neighbor local-as value: %s\n",
5126 argv
[idx_number
]->arg
);
5127 return CMD_WARNING_CONFIG_FAILED
;
5130 ret
= peer_local_as_set(peer
, as
, 1, 1);
5131 return bgp_vty_return(vty
, ret
);
5134 DEFUN (no_neighbor_local_as
,
5135 no_neighbor_local_as_cmd
,
5136 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [ASNUM [no-prepend [replace-as]]]",
5140 "Specify a local-as number\n"
5141 "AS number expressed in dotted or plain format used as local AS\n"
5142 "Do not prepend local-as to updates from ebgp peers\n"
5143 "Do not prepend local-as to updates from ibgp peers\n")
5149 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5151 return CMD_WARNING_CONFIG_FAILED
;
5153 ret
= peer_local_as_unset(peer
);
5154 return bgp_vty_return(vty
, ret
);
5158 DEFUN (neighbor_solo
,
5160 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5163 "Solo peer - part of its own update group\n")
5169 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5171 return CMD_WARNING_CONFIG_FAILED
;
5173 ret
= update_group_adjust_soloness(peer
, 1);
5174 return bgp_vty_return(vty
, ret
);
5177 DEFUN (no_neighbor_solo
,
5178 no_neighbor_solo_cmd
,
5179 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5183 "Solo peer - part of its own update group\n")
5189 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5191 return CMD_WARNING_CONFIG_FAILED
;
5193 ret
= update_group_adjust_soloness(peer
, 0);
5194 return bgp_vty_return(vty
, ret
);
5197 DEFUN (neighbor_password
,
5198 neighbor_password_cmd
,
5199 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5210 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5212 return CMD_WARNING_CONFIG_FAILED
;
5214 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5215 return bgp_vty_return(vty
, ret
);
5218 DEFUN (no_neighbor_password
,
5219 no_neighbor_password_cmd
,
5220 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5233 return CMD_WARNING_CONFIG_FAILED
;
5235 ret
= peer_password_unset(peer
);
5236 return bgp_vty_return(vty
, ret
);
5239 DEFUN (neighbor_activate
,
5240 neighbor_activate_cmd
,
5241 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5244 "Enable the Address Family for this Neighbor\n")
5250 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5252 return CMD_WARNING_CONFIG_FAILED
;
5254 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5255 return bgp_vty_return(vty
, ret
);
5258 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5259 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5260 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5261 "Enable the Address Family for this Neighbor\n")
5263 DEFUN (no_neighbor_activate
,
5264 no_neighbor_activate_cmd
,
5265 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5269 "Enable the Address Family for this Neighbor\n")
5276 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5278 return CMD_WARNING_CONFIG_FAILED
;
5280 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5281 return bgp_vty_return(vty
, ret
);
5284 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5285 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5286 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5287 "Enable the Address Family for this Neighbor\n")
5289 DEFUN (neighbor_set_peer_group
,
5290 neighbor_set_peer_group_cmd
,
5291 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5294 "Member of the peer-group\n"
5295 "Peer-group name\n")
5297 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5304 struct peer_group
*group
;
5306 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5308 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5310 vty_out(vty
, "%% Malformed address or name: %s\n",
5311 argv
[idx_peer
]->arg
);
5312 return CMD_WARNING_CONFIG_FAILED
;
5315 if (peer_address_self_check(bgp
, &su
)) {
5317 "%% Can not configure the local system as neighbor\n");
5318 return CMD_WARNING_CONFIG_FAILED
;
5321 /* Disallow for dynamic neighbor. */
5322 peer
= peer_lookup(bgp
, &su
);
5323 if (peer
&& peer_dynamic_neighbor(peer
)) {
5325 "%% Operation not allowed on a dynamic neighbor\n");
5326 return CMD_WARNING_CONFIG_FAILED
;
5330 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5332 vty_out(vty
, "%% Configure the peer-group first\n");
5333 return CMD_WARNING_CONFIG_FAILED
;
5336 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5338 return bgp_vty_return(vty
, ret
);
5341 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5342 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5343 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5344 "Member of the peer-group\n"
5345 "Peer-group name\n")
5347 DEFUN (no_neighbor_set_peer_group
,
5348 no_neighbor_set_peer_group_cmd
,
5349 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5353 "Member of the peer-group\n"
5354 "Peer-group name\n")
5356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5361 struct peer_group
*group
;
5363 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5365 return CMD_WARNING_CONFIG_FAILED
;
5367 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5369 vty_out(vty
, "%% Configure the peer-group first\n");
5370 return CMD_WARNING_CONFIG_FAILED
;
5373 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5374 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5376 peer_notify_unconfig(peer
);
5377 ret
= peer_delete(peer
);
5379 return bgp_vty_return(vty
, ret
);
5382 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5383 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5384 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5385 "Member of the peer-group\n"
5386 "Peer-group name\n")
5388 /* neighbor passive. */
5389 DEFUN (neighbor_passive
,
5390 neighbor_passive_cmd
,
5391 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5394 "Don't send open messages to this neighbor\n")
5397 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5400 DEFUN (no_neighbor_passive
,
5401 no_neighbor_passive_cmd
,
5402 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5406 "Don't send open messages to this neighbor\n")
5409 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5412 /* neighbor shutdown. */
5413 DEFUN (neighbor_shutdown_msg
,
5414 neighbor_shutdown_msg_cmd
,
5415 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5418 "Administratively shut down this neighbor\n"
5419 "Add a shutdown message (RFC 8203)\n"
5420 "Shutdown message\n")
5426 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5430 return CMD_WARNING_CONFIG_FAILED
;
5431 message
= argv_concat(argv
, argc
, 4);
5432 peer_tx_shutdown_message_set(peer
, message
);
5433 XFREE(MTYPE_TMP
, message
);
5436 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5439 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5440 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5441 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5442 "Administratively shut down this neighbor\n")
5444 DEFUN (no_neighbor_shutdown_msg
,
5445 no_neighbor_shutdown_msg_cmd
,
5446 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5450 "Administratively shut down this neighbor\n"
5451 "Remove a shutdown message (RFC 8203)\n"
5452 "Shutdown message\n")
5456 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5457 PEER_FLAG_SHUTDOWN
);
5460 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5461 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5462 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5463 "Administratively shut down this neighbor\n")
5465 DEFUN(neighbor_shutdown_rtt
,
5466 neighbor_shutdown_rtt_cmd
,
5467 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5470 "Administratively shut down this neighbor\n"
5471 "Shutdown if round-trip-time is higher than expected\n"
5472 "Round-trip-time in milliseconds\n"
5473 "Specify the number of keepalives before shutdown\n"
5474 "The number of keepalives with higher RTT to shutdown\n")
5481 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5484 return CMD_WARNING_CONFIG_FAILED
;
5486 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5488 if (argv_find(argv
, argc
, "count", &idx_count
))
5489 peer
->rtt_keepalive_conf
=
5490 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5492 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5493 PEER_FLAG_RTT_SHUTDOWN
);
5496 DEFUN(no_neighbor_shutdown_rtt
,
5497 no_neighbor_shutdown_rtt_cmd
,
5498 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5502 "Administratively shut down this neighbor\n"
5503 "Shutdown if round-trip-time is higher than expected\n"
5504 "Round-trip-time in milliseconds\n"
5505 "Specify the number of keepalives before shutdown\n"
5506 "The number of keepalives with higher RTT to shutdown\n")
5511 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5514 return CMD_WARNING_CONFIG_FAILED
;
5516 peer
->rtt_expected
= 0;
5517 peer
->rtt_keepalive_conf
= 1;
5519 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5520 PEER_FLAG_RTT_SHUTDOWN
);
5523 /* neighbor capability dynamic. */
5524 DEFUN (neighbor_capability_dynamic
,
5525 neighbor_capability_dynamic_cmd
,
5526 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5529 "Advertise capability to the peer\n"
5530 "Advertise dynamic capability to this neighbor\n")
5533 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5534 PEER_FLAG_DYNAMIC_CAPABILITY
);
5537 DEFUN (no_neighbor_capability_dynamic
,
5538 no_neighbor_capability_dynamic_cmd
,
5539 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5543 "Advertise capability to the peer\n"
5544 "Advertise dynamic capability to this neighbor\n")
5547 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5548 PEER_FLAG_DYNAMIC_CAPABILITY
);
5551 /* neighbor dont-capability-negotiate */
5552 DEFUN (neighbor_dont_capability_negotiate
,
5553 neighbor_dont_capability_negotiate_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5557 "Do not perform capability negotiation\n")
5560 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5561 PEER_FLAG_DONT_CAPABILITY
);
5564 DEFUN (no_neighbor_dont_capability_negotiate
,
5565 no_neighbor_dont_capability_negotiate_cmd
,
5566 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5570 "Do not perform capability negotiation\n")
5573 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5574 PEER_FLAG_DONT_CAPABILITY
);
5577 /* neighbor capability extended next hop encoding */
5578 DEFUN (neighbor_capability_enhe
,
5579 neighbor_capability_enhe_cmd
,
5580 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5583 "Advertise capability to the peer\n"
5584 "Advertise extended next-hop capability to the peer\n")
5589 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5590 if (peer
&& peer
->conf_if
)
5593 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5594 PEER_FLAG_CAPABILITY_ENHE
);
5597 DEFUN (no_neighbor_capability_enhe
,
5598 no_neighbor_capability_enhe_cmd
,
5599 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5603 "Advertise capability to the peer\n"
5604 "Advertise extended next-hop capability to the peer\n")
5609 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5610 if (peer
&& peer
->conf_if
) {
5612 "Peer %s cannot have capability extended-nexthop turned off\n",
5613 argv
[idx_peer
]->arg
);
5614 return CMD_WARNING_CONFIG_FAILED
;
5617 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5618 PEER_FLAG_CAPABILITY_ENHE
);
5621 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5622 afi_t afi
, safi_t safi
, uint32_t flag
,
5628 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5630 return CMD_WARNING_CONFIG_FAILED
;
5633 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5635 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5637 return bgp_vty_return(vty
, ret
);
5640 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5641 afi_t afi
, safi_t safi
, uint32_t flag
)
5643 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5646 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5647 afi_t afi
, safi_t safi
, uint32_t flag
)
5649 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5652 /* neighbor capability orf prefix-list. */
5653 DEFUN (neighbor_capability_orf_prefix
,
5654 neighbor_capability_orf_prefix_cmd
,
5655 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5658 "Advertise capability to the peer\n"
5659 "Advertise ORF capability to the peer\n"
5660 "Advertise prefixlist ORF capability to this neighbor\n"
5661 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5662 "Capability to RECEIVE the ORF from this neighbor\n"
5663 "Capability to SEND the ORF to this neighbor\n")
5665 int idx_send_recv
= 5;
5666 char *peer_str
= argv
[1]->arg
;
5668 afi_t afi
= bgp_node_afi(vty
);
5669 safi_t safi
= bgp_node_safi(vty
);
5671 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5673 return CMD_WARNING_CONFIG_FAILED
;
5675 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5676 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5677 PEER_FLAG_ORF_PREFIX_SM
);
5679 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5680 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5681 PEER_FLAG_ORF_PREFIX_RM
);
5683 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5684 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5685 PEER_FLAG_ORF_PREFIX_SM
)
5686 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5687 PEER_FLAG_ORF_PREFIX_RM
);
5689 return CMD_WARNING_CONFIG_FAILED
;
5693 neighbor_capability_orf_prefix
,
5694 neighbor_capability_orf_prefix_hidden_cmd
,
5695 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5696 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5697 "Advertise capability to the peer\n"
5698 "Advertise ORF capability to the peer\n"
5699 "Advertise prefixlist ORF capability to this neighbor\n"
5700 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5701 "Capability to RECEIVE the ORF from this neighbor\n"
5702 "Capability to SEND the ORF to this neighbor\n")
5704 DEFUN (no_neighbor_capability_orf_prefix
,
5705 no_neighbor_capability_orf_prefix_cmd
,
5706 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5710 "Advertise capability to the peer\n"
5711 "Advertise ORF capability to the peer\n"
5712 "Advertise prefixlist ORF capability to this neighbor\n"
5713 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5714 "Capability to RECEIVE the ORF from this neighbor\n"
5715 "Capability to SEND the ORF to this neighbor\n")
5717 int idx_send_recv
= 6;
5718 char *peer_str
= argv
[2]->arg
;
5720 afi_t afi
= bgp_node_afi(vty
);
5721 safi_t safi
= bgp_node_safi(vty
);
5723 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5725 return CMD_WARNING_CONFIG_FAILED
;
5727 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5728 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5729 PEER_FLAG_ORF_PREFIX_SM
);
5731 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5732 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5733 PEER_FLAG_ORF_PREFIX_RM
);
5735 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5736 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5737 PEER_FLAG_ORF_PREFIX_SM
)
5738 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5739 PEER_FLAG_ORF_PREFIX_RM
);
5741 return CMD_WARNING_CONFIG_FAILED
;
5745 no_neighbor_capability_orf_prefix
,
5746 no_neighbor_capability_orf_prefix_hidden_cmd
,
5747 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5748 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5749 "Advertise capability to the peer\n"
5750 "Advertise ORF capability to the peer\n"
5751 "Advertise prefixlist ORF capability to this neighbor\n"
5752 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5753 "Capability to RECEIVE the ORF from this neighbor\n"
5754 "Capability to SEND the ORF to this neighbor\n")
5756 /* neighbor next-hop-self. */
5757 DEFUN (neighbor_nexthop_self
,
5758 neighbor_nexthop_self_cmd
,
5759 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5762 "Disable the next hop calculation for this neighbor\n")
5765 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5766 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5769 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5770 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5771 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5772 "Disable the next hop calculation for this neighbor\n")
5774 /* neighbor next-hop-self. */
5775 DEFUN (neighbor_nexthop_self_force
,
5776 neighbor_nexthop_self_force_cmd
,
5777 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5780 "Disable the next hop calculation for this neighbor\n"
5781 "Set the next hop to self for reflected routes\n")
5784 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5786 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5789 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5790 neighbor_nexthop_self_force_hidden_cmd
,
5791 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5792 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5793 "Disable the next hop calculation for this neighbor\n"
5794 "Set the next hop to self for reflected routes\n")
5796 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5797 neighbor_nexthop_self_all_hidden_cmd
,
5798 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5799 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5800 "Disable the next hop calculation for this neighbor\n"
5801 "Set the next hop to self for reflected routes\n")
5803 DEFUN (no_neighbor_nexthop_self
,
5804 no_neighbor_nexthop_self_cmd
,
5805 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5809 "Disable the next hop calculation for this neighbor\n")
5812 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5813 bgp_node_afi(vty
), bgp_node_safi(vty
),
5814 PEER_FLAG_NEXTHOP_SELF
);
5817 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5818 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5819 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5820 "Disable the next hop calculation for this neighbor\n")
5822 DEFUN (no_neighbor_nexthop_self_force
,
5823 no_neighbor_nexthop_self_force_cmd
,
5824 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5828 "Disable the next hop calculation for this neighbor\n"
5829 "Set the next hop to self for reflected routes\n")
5832 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5833 bgp_node_afi(vty
), bgp_node_safi(vty
),
5834 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5837 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5838 no_neighbor_nexthop_self_force_hidden_cmd
,
5839 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5840 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5841 "Disable the next hop calculation for this neighbor\n"
5842 "Set the next hop to self for reflected routes\n")
5844 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5845 no_neighbor_nexthop_self_all_hidden_cmd
,
5846 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5848 "Disable the next hop calculation for this neighbor\n"
5849 "Set the next hop to self for reflected routes\n")
5851 /* neighbor as-override */
5852 DEFUN (neighbor_as_override
,
5853 neighbor_as_override_cmd
,
5854 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5857 "Override ASNs in outbound updates if aspath equals remote-as\n")
5860 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5861 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5864 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5865 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5866 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5867 "Override ASNs in outbound updates if aspath equals remote-as\n")
5869 DEFUN (no_neighbor_as_override
,
5870 no_neighbor_as_override_cmd
,
5871 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5875 "Override ASNs in outbound updates if aspath equals remote-as\n")
5878 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5879 bgp_node_afi(vty
), bgp_node_safi(vty
),
5880 PEER_FLAG_AS_OVERRIDE
);
5883 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5884 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5885 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5886 "Override ASNs in outbound updates if aspath equals remote-as\n")
5888 /* neighbor remove-private-AS. */
5889 DEFUN (neighbor_remove_private_as
,
5890 neighbor_remove_private_as_cmd
,
5891 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5894 "Remove private ASNs in outbound updates\n")
5897 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5899 PEER_FLAG_REMOVE_PRIVATE_AS
);
5902 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5903 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5904 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5905 "Remove private ASNs in outbound updates\n")
5907 DEFUN (neighbor_remove_private_as_all
,
5908 neighbor_remove_private_as_all_cmd
,
5909 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5912 "Remove private ASNs in outbound updates\n"
5913 "Apply to all AS numbers\n")
5916 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5918 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5921 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5922 neighbor_remove_private_as_all_hidden_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5925 "Remove private ASNs in outbound updates\n"
5926 "Apply to all AS numbers\n")
5928 DEFUN (neighbor_remove_private_as_replace_as
,
5929 neighbor_remove_private_as_replace_as_cmd
,
5930 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5933 "Remove private ASNs in outbound updates\n"
5934 "Replace private ASNs with our ASN in outbound updates\n")
5937 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5939 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5942 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5943 neighbor_remove_private_as_replace_as_hidden_cmd
,
5944 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5945 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5946 "Remove private ASNs in outbound updates\n"
5947 "Replace private ASNs with our ASN in outbound updates\n")
5949 DEFUN (neighbor_remove_private_as_all_replace_as
,
5950 neighbor_remove_private_as_all_replace_as_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5954 "Remove private ASNs in outbound updates\n"
5955 "Apply to all AS numbers\n"
5956 "Replace private ASNs with our ASN in outbound updates\n")
5959 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5961 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5965 neighbor_remove_private_as_all_replace_as
,
5966 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5967 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "Remove private ASNs in outbound updates\n"
5970 "Apply to all AS numbers\n"
5971 "Replace private ASNs with our ASN in outbound updates\n")
5973 DEFUN (no_neighbor_remove_private_as
,
5974 no_neighbor_remove_private_as_cmd
,
5975 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5979 "Remove private ASNs in outbound updates\n")
5982 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5983 bgp_node_afi(vty
), bgp_node_safi(vty
),
5984 PEER_FLAG_REMOVE_PRIVATE_AS
);
5987 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5988 no_neighbor_remove_private_as_hidden_cmd
,
5989 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5990 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5991 "Remove private ASNs in outbound updates\n")
5993 DEFUN (no_neighbor_remove_private_as_all
,
5994 no_neighbor_remove_private_as_all_cmd
,
5995 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5999 "Remove private ASNs in outbound updates\n"
6000 "Apply to all AS numbers\n")
6003 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6004 bgp_node_afi(vty
), bgp_node_safi(vty
),
6005 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
6008 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6009 no_neighbor_remove_private_as_all_hidden_cmd
,
6010 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6011 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6012 "Remove private ASNs in outbound updates\n"
6013 "Apply to all AS numbers\n")
6015 DEFUN (no_neighbor_remove_private_as_replace_as
,
6016 no_neighbor_remove_private_as_replace_as_cmd
,
6017 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6021 "Remove private ASNs in outbound updates\n"
6022 "Replace private ASNs with our ASN in outbound updates\n")
6025 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6026 bgp_node_afi(vty
), bgp_node_safi(vty
),
6027 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
6030 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6031 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6032 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6033 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6034 "Remove private ASNs in outbound updates\n"
6035 "Replace private ASNs with our ASN in outbound updates\n")
6037 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
6038 no_neighbor_remove_private_as_all_replace_as_cmd
,
6039 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6043 "Remove private ASNs in outbound updates\n"
6044 "Apply to all AS numbers\n"
6045 "Replace private ASNs with our ASN in outbound updates\n")
6048 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6049 bgp_node_afi(vty
), bgp_node_safi(vty
),
6050 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
6054 no_neighbor_remove_private_as_all_replace_as
,
6055 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6056 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6057 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6058 "Remove private ASNs in outbound updates\n"
6059 "Apply to all AS numbers\n"
6060 "Replace private ASNs with our ASN in outbound updates\n")
6063 /* neighbor send-community. */
6064 DEFUN (neighbor_send_community
,
6065 neighbor_send_community_cmd
,
6066 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6069 "Send Community attribute to this neighbor\n")
6073 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6075 PEER_FLAG_SEND_COMMUNITY
);
6078 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6079 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6080 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6081 "Send Community attribute to this neighbor\n")
6083 DEFUN (no_neighbor_send_community
,
6084 no_neighbor_send_community_cmd
,
6085 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6089 "Send Community attribute to this neighbor\n")
6093 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6094 bgp_node_afi(vty
), bgp_node_safi(vty
),
6095 PEER_FLAG_SEND_COMMUNITY
);
6098 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6099 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6100 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6101 "Send Community attribute to this neighbor\n")
6103 /* neighbor send-community extended. */
6104 DEFUN (neighbor_send_community_type
,
6105 neighbor_send_community_type_cmd
,
6106 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6109 "Send Community attribute to this neighbor\n"
6110 "Send Standard and Extended Community attributes\n"
6111 "Send Standard, Large and Extended Community attributes\n"
6112 "Send Extended Community attributes\n"
6113 "Send Standard Community attributes\n"
6114 "Send Large Community attributes\n")
6116 const char *type
= argv
[argc
- 1]->text
;
6117 char *peer_str
= argv
[1]->arg
;
6119 afi_t afi
= bgp_node_afi(vty
);
6120 safi_t safi
= bgp_node_safi(vty
);
6122 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6124 return CMD_WARNING_CONFIG_FAILED
;
6126 if (strmatch(type
, "standard"))
6127 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6128 PEER_FLAG_SEND_COMMUNITY
);
6130 if (strmatch(type
, "extended"))
6131 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6132 PEER_FLAG_SEND_EXT_COMMUNITY
);
6134 if (strmatch(type
, "large"))
6135 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6136 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6138 if (strmatch(type
, "both")) {
6139 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6140 PEER_FLAG_SEND_COMMUNITY
)
6141 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6142 PEER_FLAG_SEND_EXT_COMMUNITY
);
6144 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6145 PEER_FLAG_SEND_COMMUNITY
)
6146 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6147 PEER_FLAG_SEND_EXT_COMMUNITY
)
6148 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6149 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6153 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6154 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6155 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6156 "Send Community attribute to this neighbor\n"
6157 "Send Standard and Extended Community attributes\n"
6158 "Send Standard, Large and Extended Community attributes\n"
6159 "Send Extended Community attributes\n"
6160 "Send Standard Community attributes\n"
6161 "Send Large Community attributes\n")
6163 DEFUN (no_neighbor_send_community_type
,
6164 no_neighbor_send_community_type_cmd
,
6165 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6169 "Send Community attribute to this neighbor\n"
6170 "Send Standard and Extended Community attributes\n"
6171 "Send Standard, Large and Extended Community attributes\n"
6172 "Send Extended Community attributes\n"
6173 "Send Standard Community attributes\n"
6174 "Send Large Community attributes\n")
6176 const char *type
= argv
[argc
- 1]->text
;
6177 char *peer_str
= argv
[2]->arg
;
6179 afi_t afi
= bgp_node_afi(vty
);
6180 safi_t safi
= bgp_node_safi(vty
);
6182 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6184 return CMD_WARNING_CONFIG_FAILED
;
6186 if (strmatch(type
, "standard"))
6187 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6188 PEER_FLAG_SEND_COMMUNITY
);
6190 if (strmatch(type
, "extended"))
6191 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6192 PEER_FLAG_SEND_EXT_COMMUNITY
);
6194 if (strmatch(type
, "large"))
6195 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6196 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6198 if (strmatch(type
, "both")) {
6200 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6201 PEER_FLAG_SEND_COMMUNITY
)
6202 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6203 PEER_FLAG_SEND_EXT_COMMUNITY
);
6206 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6207 PEER_FLAG_SEND_COMMUNITY
)
6208 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6209 PEER_FLAG_SEND_EXT_COMMUNITY
)
6210 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6211 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6215 no_neighbor_send_community_type
,
6216 no_neighbor_send_community_type_hidden_cmd
,
6217 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6218 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6219 "Send Community attribute to this neighbor\n"
6220 "Send Standard and Extended Community attributes\n"
6221 "Send Standard, Large and Extended Community attributes\n"
6222 "Send Extended Community attributes\n"
6223 "Send Standard Community attributes\n"
6224 "Send Large Community attributes\n")
6226 /* neighbor soft-reconfig. */
6227 DEFUN (neighbor_soft_reconfiguration
,
6228 neighbor_soft_reconfiguration_cmd
,
6229 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6232 "Per neighbor soft reconfiguration\n"
6233 "Allow inbound soft reconfiguration for this neighbor\n")
6236 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6238 PEER_FLAG_SOFT_RECONFIG
);
6241 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6242 neighbor_soft_reconfiguration_hidden_cmd
,
6243 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6244 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6245 "Per neighbor soft reconfiguration\n"
6246 "Allow inbound soft reconfiguration for this neighbor\n")
6248 DEFUN (no_neighbor_soft_reconfiguration
,
6249 no_neighbor_soft_reconfiguration_cmd
,
6250 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6254 "Per neighbor soft reconfiguration\n"
6255 "Allow inbound soft reconfiguration for this neighbor\n")
6258 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6259 bgp_node_afi(vty
), bgp_node_safi(vty
),
6260 PEER_FLAG_SOFT_RECONFIG
);
6263 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6264 no_neighbor_soft_reconfiguration_hidden_cmd
,
6265 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6266 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6267 "Per neighbor soft reconfiguration\n"
6268 "Allow inbound soft reconfiguration for this neighbor\n")
6270 DEFUN (neighbor_route_reflector_client
,
6271 neighbor_route_reflector_client_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6275 "Configure a neighbor as Route Reflector client\n")
6281 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6283 return CMD_WARNING_CONFIG_FAILED
;
6285 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6287 PEER_FLAG_REFLECTOR_CLIENT
);
6290 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6291 neighbor_route_reflector_client_hidden_cmd
,
6292 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6294 "Configure a neighbor as Route Reflector client\n")
6296 DEFUN (no_neighbor_route_reflector_client
,
6297 no_neighbor_route_reflector_client_cmd
,
6298 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6302 "Configure a neighbor as Route Reflector client\n")
6305 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6306 bgp_node_afi(vty
), bgp_node_safi(vty
),
6307 PEER_FLAG_REFLECTOR_CLIENT
);
6310 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6311 no_neighbor_route_reflector_client_hidden_cmd
,
6312 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6313 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6314 "Configure a neighbor as Route Reflector client\n")
6316 /* neighbor route-server-client. */
6317 DEFUN (neighbor_route_server_client
,
6318 neighbor_route_server_client_cmd
,
6319 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6322 "Configure a neighbor as Route Server client\n")
6327 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6329 return CMD_WARNING_CONFIG_FAILED
;
6330 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6332 PEER_FLAG_RSERVER_CLIENT
);
6335 ALIAS_HIDDEN(neighbor_route_server_client
,
6336 neighbor_route_server_client_hidden_cmd
,
6337 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6338 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6339 "Configure a neighbor as Route Server client\n")
6341 DEFUN (no_neighbor_route_server_client
,
6342 no_neighbor_route_server_client_cmd
,
6343 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6347 "Configure a neighbor as Route Server client\n")
6350 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6351 bgp_node_afi(vty
), bgp_node_safi(vty
),
6352 PEER_FLAG_RSERVER_CLIENT
);
6355 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6356 no_neighbor_route_server_client_hidden_cmd
,
6357 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6358 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6359 "Configure a neighbor as Route Server client\n")
6361 DEFUN (neighbor_nexthop_local_unchanged
,
6362 neighbor_nexthop_local_unchanged_cmd
,
6363 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6366 "Configure treatment of outgoing link-local nexthop attribute\n"
6367 "Leave link-local nexthop unchanged for this peer\n")
6370 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6372 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6375 DEFUN (no_neighbor_nexthop_local_unchanged
,
6376 no_neighbor_nexthop_local_unchanged_cmd
,
6377 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6381 "Configure treatment of outgoing link-local-nexthop attribute\n"
6382 "Leave link-local nexthop unchanged for this peer\n")
6385 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6386 bgp_node_afi(vty
), bgp_node_safi(vty
),
6387 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6390 DEFUN (neighbor_attr_unchanged
,
6391 neighbor_attr_unchanged_cmd
,
6392 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6395 "BGP attribute is propagated unchanged to this neighbor\n"
6396 "As-path attribute\n"
6397 "Nexthop attribute\n"
6401 char *peer_str
= argv
[1]->arg
;
6403 bool aspath
= false;
6404 bool nexthop
= false;
6406 afi_t afi
= bgp_node_afi(vty
);
6407 safi_t safi
= bgp_node_safi(vty
);
6410 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6412 return CMD_WARNING_CONFIG_FAILED
;
6414 if (argv_find(argv
, argc
, "as-path", &idx
))
6418 if (argv_find(argv
, argc
, "next-hop", &idx
))
6422 if (argv_find(argv
, argc
, "med", &idx
))
6425 /* no flags means all of them! */
6426 if (!aspath
&& !nexthop
&& !med
) {
6427 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6428 PEER_FLAG_AS_PATH_UNCHANGED
);
6429 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6430 PEER_FLAG_NEXTHOP_UNCHANGED
);
6431 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6432 PEER_FLAG_MED_UNCHANGED
);
6435 if (peer_af_flag_check(peer
, afi
, safi
,
6436 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6437 ret
|= peer_af_flag_unset_vty(
6438 vty
, peer_str
, afi
, safi
,
6439 PEER_FLAG_AS_PATH_UNCHANGED
);
6442 ret
|= peer_af_flag_set_vty(
6443 vty
, peer_str
, afi
, safi
,
6444 PEER_FLAG_AS_PATH_UNCHANGED
);
6447 if (peer_af_flag_check(peer
, afi
, safi
,
6448 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6449 ret
|= peer_af_flag_unset_vty(
6450 vty
, peer_str
, afi
, safi
,
6451 PEER_FLAG_NEXTHOP_UNCHANGED
);
6454 ret
|= peer_af_flag_set_vty(
6455 vty
, peer_str
, afi
, safi
,
6456 PEER_FLAG_NEXTHOP_UNCHANGED
);
6459 if (peer_af_flag_check(peer
, afi
, safi
,
6460 PEER_FLAG_MED_UNCHANGED
)) {
6461 ret
|= peer_af_flag_unset_vty(
6462 vty
, peer_str
, afi
, safi
,
6463 PEER_FLAG_MED_UNCHANGED
);
6466 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6467 PEER_FLAG_MED_UNCHANGED
);
6474 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6475 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6476 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6477 "BGP attribute is propagated unchanged to this neighbor\n"
6478 "As-path attribute\n"
6479 "Nexthop attribute\n"
6482 DEFUN (no_neighbor_attr_unchanged
,
6483 no_neighbor_attr_unchanged_cmd
,
6484 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6488 "BGP attribute is propagated unchanged to this neighbor\n"
6489 "As-path attribute\n"
6490 "Nexthop attribute\n"
6494 char *peer_str
= argv
[2]->arg
;
6496 bool aspath
= false;
6497 bool nexthop
= false;
6499 afi_t afi
= bgp_node_afi(vty
);
6500 safi_t safi
= bgp_node_safi(vty
);
6503 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6505 return CMD_WARNING_CONFIG_FAILED
;
6507 if (argv_find(argv
, argc
, "as-path", &idx
))
6511 if (argv_find(argv
, argc
, "next-hop", &idx
))
6515 if (argv_find(argv
, argc
, "med", &idx
))
6518 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6519 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6520 PEER_FLAG_AS_PATH_UNCHANGED
)
6521 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6522 PEER_FLAG_NEXTHOP_UNCHANGED
)
6523 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6524 PEER_FLAG_MED_UNCHANGED
);
6527 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6528 PEER_FLAG_AS_PATH_UNCHANGED
);
6531 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6532 PEER_FLAG_NEXTHOP_UNCHANGED
);
6535 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6536 PEER_FLAG_MED_UNCHANGED
);
6542 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6543 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6544 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6545 "BGP attribute is propagated unchanged to this neighbor\n"
6546 "As-path attribute\n"
6547 "Nexthop attribute\n"
6550 /* EBGP multihop configuration. */
6551 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6552 const char *ttl_str
)
6557 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6559 return CMD_WARNING_CONFIG_FAILED
;
6562 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6567 ttl
= strtoul(ttl_str
, NULL
, 10);
6569 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6572 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6576 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6578 return CMD_WARNING_CONFIG_FAILED
;
6580 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6583 /* neighbor ebgp-multihop. */
6584 DEFUN (neighbor_ebgp_multihop
,
6585 neighbor_ebgp_multihop_cmd
,
6586 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6589 "Allow EBGP neighbors not on directly connected networks\n")
6592 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6595 DEFUN (neighbor_ebgp_multihop_ttl
,
6596 neighbor_ebgp_multihop_ttl_cmd
,
6597 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6600 "Allow EBGP neighbors not on directly connected networks\n"
6601 "maximum hop count\n")
6605 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6606 argv
[idx_number
]->arg
);
6609 DEFUN (no_neighbor_ebgp_multihop
,
6610 no_neighbor_ebgp_multihop_cmd
,
6611 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6615 "Allow EBGP neighbors not on directly connected networks\n"
6616 "maximum hop count\n")
6619 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6622 DEFPY (neighbor_aigp
,
6624 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6628 "Enable send and receive of the AIGP attribute per neighbor\n")
6632 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6634 return CMD_WARNING_CONFIG_FAILED
;
6637 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6639 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6642 static uint8_t get_role_by_name(const char *role_str
)
6644 if (strncmp(role_str
, "peer", 2) == 0)
6646 if (strncmp(role_str
, "provider", 2) == 0)
6647 return ROLE_PROVIDER
;
6648 if (strncmp(role_str
, "customer", 2) == 0)
6649 return ROLE_CUSTOMER
;
6650 if (strncmp(role_str
, "rs-server", 4) == 0)
6651 return ROLE_RS_SERVER
;
6652 if (strncmp(role_str
, "rs-client", 4) == 0)
6653 return ROLE_RS_CLIENT
;
6654 return ROLE_UNDEFINED
;
6657 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6658 const char *role_str
, bool strict_mode
)
6662 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6664 return CMD_WARNING_CONFIG_FAILED
;
6665 uint8_t role
= get_role_by_name(role_str
);
6667 if (role
== ROLE_UNDEFINED
)
6668 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6669 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6672 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6676 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6678 return CMD_WARNING_CONFIG_FAILED
;
6679 return bgp_vty_return(vty
, peer_role_unset(peer
));
6682 DEFPY(neighbor_role
,
6684 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6687 "Set session role\n"
6693 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6697 DEFPY(neighbor_role_strict
,
6698 neighbor_role_strict_cmd
,
6699 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6702 "Set session role\n"
6704 "Use additional restriction on peer\n")
6709 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6713 DEFPY(no_neighbor_role
,
6714 no_neighbor_role_cmd
,
6715 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6719 "Set session role\n"
6721 "Use additional restriction on peer\n")
6725 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6728 /* disable-connected-check */
6729 DEFUN (neighbor_disable_connected_check
,
6730 neighbor_disable_connected_check_cmd
,
6731 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6734 "one-hop away EBGP peer using loopback address\n"
6735 "Enforce EBGP neighbors perform multihop\n")
6738 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6739 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6742 DEFUN (no_neighbor_disable_connected_check
,
6743 no_neighbor_disable_connected_check_cmd
,
6744 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6748 "one-hop away EBGP peer using loopback address\n"
6749 "Enforce EBGP neighbors perform multihop\n")
6752 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6753 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6756 /* disable-link-bw-encoding-ieee */
6757 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6758 neighbor_disable_link_bw_encoding_ieee_cmd
,
6759 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6760 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6761 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6765 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6766 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6769 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6770 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6771 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6772 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6773 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6777 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6778 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6781 /* extended-optional-parameters */
6782 DEFUN(neighbor_extended_optional_parameters
,
6783 neighbor_extended_optional_parameters_cmd
,
6784 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6785 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6786 "Force the extended optional parameters format for OPEN messages\n")
6790 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6791 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6794 DEFUN(no_neighbor_extended_optional_parameters
,
6795 no_neighbor_extended_optional_parameters_cmd
,
6796 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6797 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6798 "Force the extended optional parameters format for OPEN messages\n")
6802 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6803 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6806 /* enforce-first-as */
6807 DEFUN (neighbor_enforce_first_as
,
6808 neighbor_enforce_first_as_cmd
,
6809 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6812 "Enforce the first AS for EBGP routes\n")
6816 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6817 PEER_FLAG_ENFORCE_FIRST_AS
);
6820 DEFUN (no_neighbor_enforce_first_as
,
6821 no_neighbor_enforce_first_as_cmd
,
6822 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6826 "Enforce the first AS for EBGP routes\n")
6830 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6831 PEER_FLAG_ENFORCE_FIRST_AS
);
6835 DEFUN (neighbor_description
,
6836 neighbor_description_cmd
,
6837 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6840 "Neighbor specific description\n"
6841 "Up to 80 characters describing this neighbor\n")
6848 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6850 return CMD_WARNING_CONFIG_FAILED
;
6852 str
= argv_concat(argv
, argc
, idx_line
);
6854 peer_description_set(peer
, str
);
6856 XFREE(MTYPE_TMP
, str
);
6861 DEFUN (no_neighbor_description
,
6862 no_neighbor_description_cmd
,
6863 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6867 "Neighbor specific description\n")
6872 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6874 return CMD_WARNING_CONFIG_FAILED
;
6876 peer_description_unset(peer
);
6881 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6882 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6883 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6884 "Neighbor specific description\n"
6885 "Up to 80 characters describing this neighbor\n")
6887 /* Neighbor update-source. */
6888 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6889 const char *source_str
)
6895 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6897 return CMD_WARNING_CONFIG_FAILED
;
6903 if (str2sockunion(source_str
, &su
) == 0)
6904 peer_update_source_addr_set(peer
, &su
);
6906 if (str2prefix(source_str
, &p
)) {
6908 "%% Invalid update-source, remove prefix length \n");
6909 return CMD_WARNING_CONFIG_FAILED
;
6911 peer_update_source_if_set(peer
, source_str
);
6914 peer_update_source_unset(peer
);
6919 #define BGP_UPDATE_SOURCE_HELP_STR \
6922 "Interface name (requires zebra to be running)\n"
6924 DEFUN (neighbor_update_source
,
6925 neighbor_update_source_cmd
,
6926 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6929 "Source of routing updates\n"
6930 BGP_UPDATE_SOURCE_HELP_STR
)
6934 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6935 argv
[idx_peer_2
]->arg
);
6938 DEFUN (no_neighbor_update_source
,
6939 no_neighbor_update_source_cmd
,
6940 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6944 "Source of routing updates\n"
6945 BGP_UPDATE_SOURCE_HELP_STR
)
6948 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6951 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6952 afi_t afi
, safi_t safi
,
6953 const char *rmap
, int set
)
6957 struct route_map
*route_map
= NULL
;
6959 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6961 return CMD_WARNING_CONFIG_FAILED
;
6965 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6966 ret
= peer_default_originate_set(peer
, afi
, safi
,
6969 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6971 return bgp_vty_return(vty
, ret
);
6974 /* neighbor default-originate. */
6975 DEFUN (neighbor_default_originate
,
6976 neighbor_default_originate_cmd
,
6977 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6980 "Originate default route to this neighbor\n")
6983 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6985 bgp_node_safi(vty
), NULL
, 1);
6988 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6989 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6990 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6991 "Originate default route to this neighbor\n")
6993 DEFUN (neighbor_default_originate_rmap
,
6994 neighbor_default_originate_rmap_cmd
,
6995 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6998 "Originate default route to this neighbor\n"
6999 "Route-map to specify criteria to originate default\n"
7004 return peer_default_originate_set_vty(
7005 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7006 argv
[idx_word
]->arg
, 1);
7010 neighbor_default_originate_rmap
,
7011 neighbor_default_originate_rmap_hidden_cmd
,
7012 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
7013 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7014 "Originate default route to this neighbor\n"
7015 "Route-map to specify criteria to originate default\n"
7018 DEFUN (no_neighbor_default_originate
,
7019 no_neighbor_default_originate_cmd
,
7020 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7024 "Originate default route to this neighbor\n"
7025 "Route-map to specify criteria to originate default\n"
7029 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7031 bgp_node_safi(vty
), NULL
, 0);
7035 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7036 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7037 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7038 "Originate default route to this neighbor\n"
7039 "Route-map to specify criteria to originate default\n"
7043 /* Set neighbor's BGP port. */
7044 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
7045 const char *port_str
)
7051 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7053 return CMD_WARNING_CONFIG_FAILED
;
7056 sp
= getservbyname("bgp", "tcp");
7057 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
7059 port
= strtoul(port_str
, NULL
, 10);
7062 peer_port_set(peer
, port
);
7067 /* Set specified peer's BGP port. */
7068 DEFUN (neighbor_port
,
7070 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7073 "Neighbor's BGP port\n"
7074 "TCP port number\n")
7078 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7079 argv
[idx_number
]->arg
);
7082 DEFUN (no_neighbor_port
,
7083 no_neighbor_port_cmd
,
7084 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7088 "Neighbor's BGP port\n"
7089 "TCP port number\n")
7092 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7096 /* neighbor weight. */
7097 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7098 safi_t safi
, const char *weight_str
)
7102 unsigned long weight
;
7104 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7106 return CMD_WARNING_CONFIG_FAILED
;
7108 weight
= strtoul(weight_str
, NULL
, 10);
7110 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7111 return bgp_vty_return(vty
, ret
);
7114 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7120 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7122 return CMD_WARNING_CONFIG_FAILED
;
7124 ret
= peer_weight_unset(peer
, afi
, safi
);
7125 return bgp_vty_return(vty
, ret
);
7128 DEFUN (neighbor_weight
,
7129 neighbor_weight_cmd
,
7130 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7133 "Set default weight for routes from this neighbor\n"
7138 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7139 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7142 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7143 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7144 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7145 "Set default weight for routes from this neighbor\n"
7148 DEFUN (no_neighbor_weight
,
7149 no_neighbor_weight_cmd
,
7150 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7154 "Set default weight for routes from this neighbor\n"
7158 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7159 bgp_node_afi(vty
), bgp_node_safi(vty
));
7162 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7163 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7164 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7165 "Set default weight for routes from this neighbor\n"
7169 /* Override capability negotiation. */
7170 DEFUN (neighbor_override_capability
,
7171 neighbor_override_capability_cmd
,
7172 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7175 "Override capability negotiation result\n")
7178 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7179 PEER_FLAG_OVERRIDE_CAPABILITY
);
7182 DEFUN (no_neighbor_override_capability
,
7183 no_neighbor_override_capability_cmd
,
7184 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7188 "Override capability negotiation result\n")
7191 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7192 PEER_FLAG_OVERRIDE_CAPABILITY
);
7195 DEFUN (neighbor_strict_capability
,
7196 neighbor_strict_capability_cmd
,
7197 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7200 "Strict capability negotiation match\n")
7204 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7205 PEER_FLAG_STRICT_CAP_MATCH
);
7208 DEFUN (no_neighbor_strict_capability
,
7209 no_neighbor_strict_capability_cmd
,
7210 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7214 "Strict capability negotiation match\n")
7218 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7219 PEER_FLAG_STRICT_CAP_MATCH
);
7222 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7223 const char *keep_str
, const char *hold_str
)
7230 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7232 return CMD_WARNING_CONFIG_FAILED
;
7234 keepalive
= strtoul(keep_str
, NULL
, 10);
7235 holdtime
= strtoul(hold_str
, NULL
, 10);
7237 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7239 return bgp_vty_return(vty
, ret
);
7242 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7247 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7249 return CMD_WARNING_CONFIG_FAILED
;
7251 ret
= peer_timers_unset(peer
);
7253 return bgp_vty_return(vty
, ret
);
7256 DEFUN (neighbor_timers
,
7257 neighbor_timers_cmd
,
7258 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7261 "BGP per neighbor timers\n"
7262 "Keepalive interval\n"
7267 int idx_number_2
= 4;
7268 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7269 argv
[idx_number
]->arg
,
7270 argv
[idx_number_2
]->arg
);
7273 DEFUN (no_neighbor_timers
,
7274 no_neighbor_timers_cmd
,
7275 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7279 "BGP per neighbor timers\n"
7280 "Keepalive interval\n"
7284 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7288 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7289 const char *time_str
)
7295 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7297 return CMD_WARNING_CONFIG_FAILED
;
7299 connect
= strtoul(time_str
, NULL
, 10);
7301 ret
= peer_timers_connect_set(peer
, connect
);
7303 return bgp_vty_return(vty
, ret
);
7306 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7311 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7313 return CMD_WARNING_CONFIG_FAILED
;
7315 ret
= peer_timers_connect_unset(peer
);
7317 return bgp_vty_return(vty
, ret
);
7320 DEFUN (neighbor_timers_connect
,
7321 neighbor_timers_connect_cmd
,
7322 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7325 "BGP per neighbor timers\n"
7326 "BGP connect timer\n"
7331 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7332 argv
[idx_number
]->arg
);
7335 DEFUN (no_neighbor_timers_connect
,
7336 no_neighbor_timers_connect_cmd
,
7337 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7341 "BGP per neighbor timers\n"
7342 "BGP connect timer\n"
7346 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7349 DEFPY (neighbor_timers_delayopen
,
7350 neighbor_timers_delayopen_cmd
,
7351 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7354 "BGP per neighbor timers\n"
7355 "RFC 4271 DelayOpenTimer\n"
7356 "DelayOpenTime timer interval\n")
7360 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7362 return CMD_WARNING_CONFIG_FAILED
;
7365 if (peer_timers_delayopen_unset(peer
))
7366 return CMD_WARNING_CONFIG_FAILED
;
7368 if (peer_timers_delayopen_set(peer
, interval
))
7369 return CMD_WARNING_CONFIG_FAILED
;
7375 DEFPY (no_neighbor_timers_delayopen
,
7376 no_neighbor_timers_delayopen_cmd
,
7377 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7381 "BGP per neighbor timers\n"
7382 "RFC 4271 DelayOpenTimer\n"
7383 "DelayOpenTime timer interval\n")
7387 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7389 return CMD_WARNING_CONFIG_FAILED
;
7391 if (peer_timers_delayopen_unset(peer
))
7392 return CMD_WARNING_CONFIG_FAILED
;
7397 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7398 const char *time_str
, int set
)
7402 uint32_t routeadv
= 0;
7404 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7406 return CMD_WARNING_CONFIG_FAILED
;
7409 routeadv
= strtoul(time_str
, NULL
, 10);
7412 ret
= peer_advertise_interval_set(peer
, routeadv
);
7414 ret
= peer_advertise_interval_unset(peer
);
7416 return bgp_vty_return(vty
, ret
);
7419 DEFUN (neighbor_advertise_interval
,
7420 neighbor_advertise_interval_cmd
,
7421 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7424 "Minimum interval between sending BGP routing updates\n"
7425 "time in seconds\n")
7429 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7430 argv
[idx_number
]->arg
, 1);
7433 DEFUN (no_neighbor_advertise_interval
,
7434 no_neighbor_advertise_interval_cmd
,
7435 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7439 "Minimum interval between sending BGP routing updates\n"
7440 "time in seconds\n")
7443 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7447 /* Time to wait before processing route-map updates */
7448 DEFUN (bgp_set_route_map_delay_timer
,
7449 bgp_set_route_map_delay_timer_cmd
,
7450 "bgp route-map delay-timer (0-600)",
7452 "BGP route-map delay timer\n"
7453 "Time in secs to wait before processing route-map changes\n"
7454 "0 disables the timer, no route updates happen when route-maps change\n")
7457 uint32_t rmap_delay_timer
;
7459 if (argv
[idx_number
]->arg
) {
7460 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7461 bm
->rmap_update_timer
= rmap_delay_timer
;
7463 /* if the dynamic update handling is being disabled, and a timer
7465 * running, stop the timer and act as if the timer has already
7468 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7469 THREAD_OFF(bm
->t_rmap_update
);
7470 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7475 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7476 return CMD_WARNING_CONFIG_FAILED
;
7480 DEFUN (no_bgp_set_route_map_delay_timer
,
7481 no_bgp_set_route_map_delay_timer_cmd
,
7482 "no bgp route-map delay-timer [(0-600)]",
7485 "Default BGP route-map delay timer\n"
7486 "Reset to default time to wait for processing route-map changes\n"
7487 "0 disables the timer, no route updates happen when route-maps change\n")
7490 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7495 /* neighbor interface */
7496 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7501 peer
= peer_lookup_vty(vty
, ip_str
);
7502 if (!peer
|| peer
->conf_if
) {
7503 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7504 return CMD_WARNING_CONFIG_FAILED
;
7508 peer_interface_set(peer
, str
);
7510 peer_interface_unset(peer
);
7515 DEFUN (neighbor_interface
,
7516 neighbor_interface_cmd
,
7517 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7526 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7529 DEFUN (no_neighbor_interface
,
7530 no_neighbor_interface_cmd
,
7531 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7540 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7543 DEFUN (neighbor_distribute_list
,
7544 neighbor_distribute_list_cmd
,
7545 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7548 "Filter updates to/from this neighbor\n"
7549 "IP Access-list name\n"
7550 "Filter incoming updates\n"
7551 "Filter outgoing updates\n")
7558 const char *pstr
= argv
[idx_peer
]->arg
;
7559 const char *acl
= argv
[idx_acl
]->arg
;
7560 const char *inout
= argv
[argc
- 1]->text
;
7562 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7564 return CMD_WARNING_CONFIG_FAILED
;
7566 /* Check filter direction. */
7567 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7568 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7571 return bgp_vty_return(vty
, ret
);
7575 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7576 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7578 "Filter updates to/from this neighbor\n"
7579 "IP Access-list name\n"
7580 "Filter incoming updates\n"
7581 "Filter outgoing updates\n")
7583 DEFUN (no_neighbor_distribute_list
,
7584 no_neighbor_distribute_list_cmd
,
7585 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7589 "Filter updates to/from this neighbor\n"
7590 "IP Access-list name\n"
7591 "Filter incoming updates\n"
7592 "Filter outgoing updates\n")
7598 const char *pstr
= argv
[idx_peer
]->arg
;
7599 const char *inout
= argv
[argc
- 1]->text
;
7601 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7603 return CMD_WARNING_CONFIG_FAILED
;
7605 /* Check filter direction. */
7606 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7607 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7610 return bgp_vty_return(vty
, ret
);
7614 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7615 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7616 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7617 "Filter updates to/from this neighbor\n"
7618 "IP Access-list name\n"
7619 "Filter incoming updates\n"
7620 "Filter outgoing updates\n")
7622 /* Set prefix list to the peer. */
7623 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7624 afi_t afi
, safi_t safi
,
7625 const char *name_str
,
7626 const char *direct_str
)
7629 int direct
= FILTER_IN
;
7632 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7634 return CMD_WARNING_CONFIG_FAILED
;
7636 /* Check filter direction. */
7637 if (strncmp(direct_str
, "i", 1) == 0)
7639 else if (strncmp(direct_str
, "o", 1) == 0)
7640 direct
= FILTER_OUT
;
7642 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7644 return bgp_vty_return(vty
, ret
);
7647 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7648 afi_t afi
, safi_t safi
,
7649 const char *direct_str
)
7653 int direct
= FILTER_IN
;
7655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7657 return CMD_WARNING_CONFIG_FAILED
;
7659 /* Check filter direction. */
7660 if (strncmp(direct_str
, "i", 1) == 0)
7662 else if (strncmp(direct_str
, "o", 1) == 0)
7663 direct
= FILTER_OUT
;
7665 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7667 return bgp_vty_return(vty
, ret
);
7670 DEFUN (neighbor_prefix_list
,
7671 neighbor_prefix_list_cmd
,
7672 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7675 "Filter updates to/from this neighbor\n"
7676 "Name of a prefix list\n"
7677 "Filter incoming updates\n"
7678 "Filter outgoing updates\n")
7683 return peer_prefix_list_set_vty(
7684 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7685 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7688 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7689 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7690 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7691 "Filter updates to/from this neighbor\n"
7692 "Name of a prefix list\n"
7693 "Filter incoming updates\n"
7694 "Filter outgoing updates\n")
7696 DEFUN (no_neighbor_prefix_list
,
7697 no_neighbor_prefix_list_cmd
,
7698 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7702 "Filter updates to/from this neighbor\n"
7703 "Name of a prefix list\n"
7704 "Filter incoming updates\n"
7705 "Filter outgoing updates\n")
7709 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7710 bgp_node_afi(vty
), bgp_node_safi(vty
),
7711 argv
[idx_in_out
]->arg
);
7714 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7715 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7716 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7717 "Filter updates to/from this neighbor\n"
7718 "Name of a prefix list\n"
7719 "Filter incoming updates\n"
7720 "Filter outgoing updates\n")
7722 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7723 safi_t safi
, const char *name_str
,
7724 const char *direct_str
)
7728 int direct
= FILTER_IN
;
7730 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7732 return CMD_WARNING_CONFIG_FAILED
;
7734 /* Check filter direction. */
7735 if (strncmp(direct_str
, "i", 1) == 0)
7737 else if (strncmp(direct_str
, "o", 1) == 0)
7738 direct
= FILTER_OUT
;
7740 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7742 return bgp_vty_return(vty
, ret
);
7745 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7746 safi_t safi
, const char *direct_str
)
7750 int direct
= FILTER_IN
;
7752 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7754 return CMD_WARNING_CONFIG_FAILED
;
7756 /* Check filter direction. */
7757 if (strncmp(direct_str
, "i", 1) == 0)
7759 else if (strncmp(direct_str
, "o", 1) == 0)
7760 direct
= FILTER_OUT
;
7762 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7764 return bgp_vty_return(vty
, ret
);
7767 DEFUN (neighbor_filter_list
,
7768 neighbor_filter_list_cmd
,
7769 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7772 "Establish BGP filters\n"
7773 "AS path access-list name\n"
7774 "Filter incoming routes\n"
7775 "Filter outgoing routes\n")
7780 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7781 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7782 argv
[idx_in_out
]->arg
);
7785 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7786 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7787 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7788 "Establish BGP filters\n"
7789 "AS path access-list name\n"
7790 "Filter incoming routes\n"
7791 "Filter outgoing routes\n")
7793 DEFUN (no_neighbor_filter_list
,
7794 no_neighbor_filter_list_cmd
,
7795 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7799 "Establish BGP filters\n"
7800 "AS path access-list name\n"
7801 "Filter incoming routes\n"
7802 "Filter outgoing routes\n")
7806 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7807 bgp_node_afi(vty
), bgp_node_safi(vty
),
7808 argv
[idx_in_out
]->arg
);
7811 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7812 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7813 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7814 "Establish BGP filters\n"
7815 "AS path access-list name\n"
7816 "Filter incoming routes\n"
7817 "Filter outgoing routes\n")
7819 /* Set advertise-map to the peer. */
7820 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7821 afi_t afi
, safi_t safi
,
7822 const char *advertise_str
,
7823 const char *condition_str
, bool condition
,
7826 int ret
= CMD_WARNING_CONFIG_FAILED
;
7828 struct route_map
*advertise_map
;
7829 struct route_map
*condition_map
;
7831 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7835 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7836 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7839 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7840 advertise_map
, condition_str
,
7841 condition_map
, condition
);
7843 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7844 advertise_map
, condition_str
,
7845 condition_map
, condition
);
7847 return bgp_vty_return(vty
, ret
);
7850 DEFPY (bgp_condadv_period
,
7851 bgp_condadv_period_cmd
,
7852 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7855 "Conditional advertisement settings\n"
7856 "Set period to rescan BGP table to check if condition is met\n"
7857 "Period between BGP table scans, in seconds; default 60\n")
7859 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7861 bgp
->condition_check_period
=
7862 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7867 DEFPY (neighbor_advertise_map
,
7868 neighbor_advertise_map_cmd
,
7869 "[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",
7873 "Route-map to conditionally advertise routes\n"
7874 "Name of advertise map\n"
7875 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7876 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7877 "Name of the exist or non exist map\n")
7879 bool condition
= CONDITION_EXIST
;
7881 if (!strcmp(exist
, "non-exist-map"))
7882 condition
= CONDITION_NON_EXIST
;
7884 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7885 bgp_node_safi(vty
), advertise_str
,
7886 condition_str
, condition
, !no
);
7889 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7890 "[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",
7891 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7892 "Route-map to conditionally advertise routes\n"
7893 "Name of advertise map\n"
7894 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7895 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7896 "Name of the exist or non exist map\n")
7898 /* Set route-map to the peer. */
7899 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7900 afi_t afi
, safi_t safi
, const char *name_str
,
7901 const char *direct_str
)
7905 int direct
= RMAP_IN
;
7906 struct route_map
*route_map
;
7908 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7910 return CMD_WARNING_CONFIG_FAILED
;
7912 /* Check filter direction. */
7913 if (strncmp(direct_str
, "in", 2) == 0)
7915 else if (strncmp(direct_str
, "o", 1) == 0)
7918 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7919 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7921 return bgp_vty_return(vty
, ret
);
7924 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7925 afi_t afi
, safi_t safi
,
7926 const char *direct_str
)
7930 int direct
= RMAP_IN
;
7932 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7934 return CMD_WARNING_CONFIG_FAILED
;
7936 /* Check filter direction. */
7937 if (strncmp(direct_str
, "in", 2) == 0)
7939 else if (strncmp(direct_str
, "o", 1) == 0)
7942 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7944 return bgp_vty_return(vty
, ret
);
7947 DEFUN (neighbor_route_map
,
7948 neighbor_route_map_cmd
,
7949 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7952 "Apply route map to neighbor\n"
7953 "Name of route map\n"
7954 "Apply map to incoming routes\n"
7955 "Apply map to outbound routes\n")
7960 return peer_route_map_set_vty(
7961 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7962 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7965 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7966 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7967 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7968 "Apply route map to neighbor\n"
7969 "Name of route map\n"
7970 "Apply map to incoming routes\n"
7971 "Apply map to outbound routes\n")
7973 DEFUN (no_neighbor_route_map
,
7974 no_neighbor_route_map_cmd
,
7975 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7979 "Apply route map to neighbor\n"
7980 "Name of route map\n"
7981 "Apply map to incoming routes\n"
7982 "Apply map to outbound routes\n")
7986 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7987 bgp_node_afi(vty
), bgp_node_safi(vty
),
7988 argv
[idx_in_out
]->arg
);
7991 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7992 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7993 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7994 "Apply route map to neighbor\n"
7995 "Name of route map\n"
7996 "Apply map to incoming routes\n"
7997 "Apply map to outbound routes\n")
7999 /* Set unsuppress-map to the peer. */
8000 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8001 afi_t afi
, safi_t safi
,
8002 const char *name_str
)
8006 struct route_map
*route_map
;
8008 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8010 return CMD_WARNING_CONFIG_FAILED
;
8012 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8013 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8015 return bgp_vty_return(vty
, ret
);
8018 /* Unset route-map from the peer. */
8019 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8020 afi_t afi
, safi_t safi
)
8025 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8027 return CMD_WARNING_CONFIG_FAILED
;
8029 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8031 return bgp_vty_return(vty
, ret
);
8034 DEFUN (neighbor_unsuppress_map
,
8035 neighbor_unsuppress_map_cmd
,
8036 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8039 "Route-map to selectively unsuppress suppressed routes\n"
8040 "Name of route map\n")
8044 return peer_unsuppress_map_set_vty(
8045 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8046 argv
[idx_word
]->arg
);
8049 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8050 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8051 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8052 "Route-map to selectively unsuppress suppressed routes\n"
8053 "Name of route map\n")
8055 DEFUN (no_neighbor_unsuppress_map
,
8056 no_neighbor_unsuppress_map_cmd
,
8057 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8061 "Route-map to selectively unsuppress suppressed routes\n"
8062 "Name of route map\n")
8065 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8067 bgp_node_safi(vty
));
8070 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8071 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8072 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8073 "Route-map to selectively unsuppress suppressed routes\n"
8074 "Name of route map\n")
8076 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8077 afi_t afi
, safi_t safi
,
8078 const char *num_str
,
8079 const char *threshold_str
, int warning
,
8080 const char *restart_str
,
8081 const char *force_str
)
8089 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8091 return CMD_WARNING_CONFIG_FAILED
;
8093 max
= strtoul(num_str
, NULL
, 10);
8095 threshold
= atoi(threshold_str
);
8097 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8100 restart
= atoi(restart_str
);
8104 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8105 restart
, force_str
? true : false);
8107 return bgp_vty_return(vty
, ret
);
8110 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8111 afi_t afi
, safi_t safi
)
8116 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8118 return CMD_WARNING_CONFIG_FAILED
;
8120 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8122 return bgp_vty_return(vty
, ret
);
8125 /* Maximum number of prefix to be sent to the neighbor. */
8126 DEFUN(neighbor_maximum_prefix_out
,
8127 neighbor_maximum_prefix_out_cmd
,
8128 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8131 "Maximum number of prefixes to be sent to this peer\n"
8132 "Maximum no. of prefix limit\n")
8139 afi_t afi
= bgp_node_afi(vty
);
8140 safi_t safi
= bgp_node_safi(vty
);
8142 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8144 return CMD_WARNING_CONFIG_FAILED
;
8146 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8148 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8150 return bgp_vty_return(vty
, ret
);
8153 DEFUN(no_neighbor_maximum_prefix_out
,
8154 no_neighbor_maximum_prefix_out_cmd
,
8155 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8159 "Maximum number of prefixes to be sent to this peer\n"
8160 "Maximum no. of prefix limit\n")
8165 afi_t afi
= bgp_node_afi(vty
);
8166 safi_t safi
= bgp_node_safi(vty
);
8168 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8170 return CMD_WARNING_CONFIG_FAILED
;
8172 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8174 return bgp_vty_return(vty
, ret
);
8177 /* Maximum number of prefix configuration. Prefix count is different
8178 for each peer configuration. So this configuration can be set for
8179 each peer configuration. */
8180 DEFUN (neighbor_maximum_prefix
,
8181 neighbor_maximum_prefix_cmd
,
8182 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8185 "Maximum number of prefix accept from this peer\n"
8186 "maximum no. of prefix limit\n"
8187 "Force checking all received routes not only accepted\n")
8194 if (argv_find(argv
, argc
, "force", &idx_force
))
8195 force
= argv
[idx_force
]->arg
;
8197 return peer_maximum_prefix_set_vty(
8198 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8199 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8202 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8203 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8204 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8205 "Maximum number of prefix accept from this peer\n"
8206 "maximum no. of prefix limit\n"
8207 "Force checking all received routes not only accepted\n")
8209 DEFUN (neighbor_maximum_prefix_threshold
,
8210 neighbor_maximum_prefix_threshold_cmd
,
8211 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8214 "Maximum number of prefix accept from this peer\n"
8215 "maximum no. of prefix limit\n"
8216 "Threshold value (%) at which to generate a warning msg\n"
8217 "Force checking all received routes not only accepted\n")
8221 int idx_number_2
= 4;
8225 if (argv_find(argv
, argc
, "force", &idx_force
))
8226 force
= argv
[idx_force
]->arg
;
8228 return peer_maximum_prefix_set_vty(
8229 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8230 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8234 neighbor_maximum_prefix_threshold
,
8235 neighbor_maximum_prefix_threshold_hidden_cmd
,
8236 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8237 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8238 "Maximum number of prefix accept from this peer\n"
8239 "maximum no. of prefix limit\n"
8240 "Threshold value (%) at which to generate a warning msg\n"
8241 "Force checking all received routes not only accepted\n")
8243 DEFUN (neighbor_maximum_prefix_warning
,
8244 neighbor_maximum_prefix_warning_cmd
,
8245 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8248 "Maximum number of prefix accept from this peer\n"
8249 "maximum no. of prefix limit\n"
8250 "Only give warning message when limit is exceeded\n"
8251 "Force checking all received routes not only accepted\n")
8258 if (argv_find(argv
, argc
, "force", &idx_force
))
8259 force
= argv
[idx_force
]->arg
;
8261 return peer_maximum_prefix_set_vty(
8262 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8263 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8267 neighbor_maximum_prefix_warning
,
8268 neighbor_maximum_prefix_warning_hidden_cmd
,
8269 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8270 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8271 "Maximum number of prefix accept from this peer\n"
8272 "maximum no. of prefix limit\n"
8273 "Only give warning message when limit is exceeded\n"
8274 "Force checking all received routes not only accepted\n")
8276 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8277 neighbor_maximum_prefix_threshold_warning_cmd
,
8278 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8281 "Maximum number of prefix accept from this peer\n"
8282 "maximum no. of prefix limit\n"
8283 "Threshold value (%) at which to generate a warning msg\n"
8284 "Only give warning message when limit is exceeded\n"
8285 "Force checking all received routes not only accepted\n")
8289 int idx_number_2
= 4;
8293 if (argv_find(argv
, argc
, "force", &idx_force
))
8294 force
= argv
[idx_force
]->arg
;
8296 return peer_maximum_prefix_set_vty(
8297 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8298 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8302 neighbor_maximum_prefix_threshold_warning
,
8303 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8304 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8305 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8306 "Maximum number of prefix accept from this peer\n"
8307 "maximum no. of prefix limit\n"
8308 "Threshold value (%) at which to generate a warning msg\n"
8309 "Only give warning message when limit is exceeded\n"
8310 "Force checking all received routes not only accepted\n")
8312 DEFUN (neighbor_maximum_prefix_restart
,
8313 neighbor_maximum_prefix_restart_cmd
,
8314 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8317 "Maximum number of prefix accept from this peer\n"
8318 "maximum no. of prefix limit\n"
8319 "Restart bgp connection after limit is exceeded\n"
8320 "Restart interval in minutes\n"
8321 "Force checking all received routes not only accepted\n")
8325 int idx_number_2
= 5;
8329 if (argv_find(argv
, argc
, "force", &idx_force
))
8330 force
= argv
[idx_force
]->arg
;
8332 return peer_maximum_prefix_set_vty(
8333 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8334 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8338 neighbor_maximum_prefix_restart
,
8339 neighbor_maximum_prefix_restart_hidden_cmd
,
8340 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8341 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8342 "Maximum number of prefix accept from this peer\n"
8343 "maximum no. of prefix limit\n"
8344 "Restart bgp connection after limit is exceeded\n"
8345 "Restart interval in minutes\n"
8346 "Force checking all received routes not only accepted\n")
8348 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8349 neighbor_maximum_prefix_threshold_restart_cmd
,
8350 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8353 "Maximum number of prefixes to accept from this peer\n"
8354 "maximum no. of prefix limit\n"
8355 "Threshold value (%) at which to generate a warning msg\n"
8356 "Restart bgp connection after limit is exceeded\n"
8357 "Restart interval in minutes\n"
8358 "Force checking all received routes not only accepted\n")
8362 int idx_number_2
= 4;
8363 int idx_number_3
= 6;
8367 if (argv_find(argv
, argc
, "force", &idx_force
))
8368 force
= argv
[idx_force
]->arg
;
8370 return peer_maximum_prefix_set_vty(
8371 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8372 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8373 argv
[idx_number_3
]->arg
, force
);
8377 neighbor_maximum_prefix_threshold_restart
,
8378 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8379 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8380 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8381 "Maximum number of prefixes to accept from this peer\n"
8382 "maximum no. of prefix limit\n"
8383 "Threshold value (%) at which to generate a warning msg\n"
8384 "Restart bgp connection after limit is exceeded\n"
8385 "Restart interval in minutes\n"
8386 "Force checking all received routes not only accepted\n")
8388 DEFUN (no_neighbor_maximum_prefix
,
8389 no_neighbor_maximum_prefix_cmd
,
8390 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8394 "Maximum number of prefixes to accept from this peer\n"
8395 "maximum no. of prefix limit\n"
8396 "Threshold value (%) at which to generate a warning msg\n"
8397 "Restart bgp connection after limit is exceeded\n"
8398 "Restart interval in minutes\n"
8399 "Only give warning message when limit is exceeded\n"
8400 "Force checking all received routes not only accepted\n")
8403 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8405 bgp_node_safi(vty
));
8409 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8410 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8411 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8412 "Maximum number of prefixes to accept from this peer\n"
8413 "maximum no. of prefix limit\n"
8414 "Threshold value (%) at which to generate a warning msg\n"
8415 "Restart bgp connection after limit is exceeded\n"
8416 "Restart interval in minutes\n"
8417 "Only give warning message when limit is exceeded\n"
8418 "Force checking all received routes not only accepted\n")
8420 /* "neighbor accept-own" */
8421 DEFPY (neighbor_accept_own
,
8422 neighbor_accept_own_cmd
,
8423 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8427 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8430 afi_t afi
= bgp_node_afi(vty
);
8431 safi_t safi
= bgp_node_safi(vty
);
8434 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8436 return CMD_WARNING_CONFIG_FAILED
;
8439 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8441 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8443 return bgp_vty_return(vty
, ret
);
8446 /* "neighbor soo" */
8447 DEFPY (neighbor_soo
,
8449 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8452 "Set the Site-of-Origin (SoO) extended community\n"
8453 "VPN extended community\n")
8456 afi_t afi
= bgp_node_afi(vty
);
8457 safi_t safi
= bgp_node_safi(vty
);
8458 struct ecommunity
*ecomm_soo
;
8460 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8462 return CMD_WARNING_CONFIG_FAILED
;
8464 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8466 vty_out(vty
, "%% Malformed SoO extended community\n");
8469 ecommunity_str(ecomm_soo
);
8471 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8472 ecommunity_free(&peer
->soo
[afi
][safi
]);
8473 peer
->soo
[afi
][safi
] = ecomm_soo
;
8474 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8477 return bgp_vty_return(vty
,
8478 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8481 DEFPY (no_neighbor_soo
,
8482 no_neighbor_soo_cmd
,
8483 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8487 "Set the Site-of-Origin (SoO) extended community\n"
8488 "VPN extended community\n")
8491 afi_t afi
= bgp_node_afi(vty
);
8492 safi_t safi
= bgp_node_safi(vty
);
8494 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8496 return CMD_WARNING_CONFIG_FAILED
;
8498 ecommunity_free(&peer
->soo
[afi
][safi
]);
8500 return bgp_vty_return(
8501 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8504 /* "neighbor allowas-in" */
8505 DEFUN (neighbor_allowas_in
,
8506 neighbor_allowas_in_cmd
,
8507 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8510 "Accept as-path with my AS present in it\n"
8511 "Number of occurrences of AS number\n"
8512 "Only accept my AS in the as-path if the route was originated in my AS\n")
8515 int idx_number_origin
= 3;
8521 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8523 return CMD_WARNING_CONFIG_FAILED
;
8525 if (argc
<= idx_number_origin
)
8528 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8531 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8534 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8537 return bgp_vty_return(vty
, ret
);
8541 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8542 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8543 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8544 "Accept as-path with my AS present in it\n"
8545 "Number of occurrences of AS number\n"
8546 "Only accept my AS in the as-path if the route was originated in my AS\n")
8548 DEFUN (no_neighbor_allowas_in
,
8549 no_neighbor_allowas_in_cmd
,
8550 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8554 "allow local ASN appears in aspath attribute\n"
8555 "Number of occurrences of AS number\n"
8556 "Only accept my AS in the as-path if the route was originated in my AS\n")
8562 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8564 return CMD_WARNING_CONFIG_FAILED
;
8566 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8567 bgp_node_safi(vty
));
8569 return bgp_vty_return(vty
, ret
);
8573 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8574 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8575 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8576 "allow local ASN appears in aspath attribute\n"
8577 "Number of occurrences of AS number\n"
8578 "Only accept my AS in the as-path if the route was originated in my AS\n")
8580 DEFUN (neighbor_ttl_security
,
8581 neighbor_ttl_security_cmd
,
8582 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8585 "BGP ttl-security parameters\n"
8586 "Specify the maximum number of hops to the BGP peer\n"
8587 "Number of hops to BGP peer\n")
8594 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8596 return CMD_WARNING_CONFIG_FAILED
;
8598 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8601 * If 'neighbor swpX', then this is for directly connected peers,
8602 * we should not accept a ttl-security hops value greater than 1.
8604 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8606 "%s is directly connected peer, hops cannot exceed 1\n",
8607 argv
[idx_peer
]->arg
);
8608 return CMD_WARNING_CONFIG_FAILED
;
8611 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8614 DEFUN (no_neighbor_ttl_security
,
8615 no_neighbor_ttl_security_cmd
,
8616 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8620 "BGP ttl-security parameters\n"
8621 "Specify the maximum number of hops to the BGP peer\n"
8622 "Number of hops to BGP peer\n")
8627 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8629 return CMD_WARNING_CONFIG_FAILED
;
8631 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8634 /* disable-addpath-rx */
8635 DEFUN(neighbor_disable_addpath_rx
,
8636 neighbor_disable_addpath_rx_cmd
,
8637 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8640 "Do not accept additional paths\n")
8642 char *peer_str
= argv
[1]->arg
;
8644 afi_t afi
= bgp_node_afi(vty
);
8645 safi_t safi
= bgp_node_safi(vty
);
8647 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8649 return CMD_WARNING_CONFIG_FAILED
;
8651 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8652 PEER_FLAG_DISABLE_ADDPATH_RX
);
8655 DEFUN(no_neighbor_disable_addpath_rx
,
8656 no_neighbor_disable_addpath_rx_cmd
,
8657 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8661 "Do not accept additional paths\n")
8663 char *peer_str
= argv
[2]->arg
;
8665 afi_t afi
= bgp_node_afi(vty
);
8666 safi_t safi
= bgp_node_safi(vty
);
8668 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8670 return CMD_WARNING_CONFIG_FAILED
;
8672 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8673 PEER_FLAG_DISABLE_ADDPATH_RX
);
8676 DEFUN (neighbor_addpath_tx_all_paths
,
8677 neighbor_addpath_tx_all_paths_cmd
,
8678 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8681 "Use addpath to advertise all paths to a neighbor\n")
8686 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8688 return CMD_WARNING_CONFIG_FAILED
;
8690 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8695 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8696 neighbor_addpath_tx_all_paths_hidden_cmd
,
8697 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8698 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8699 "Use addpath to advertise all paths to a neighbor\n")
8701 DEFUN (no_neighbor_addpath_tx_all_paths
,
8702 no_neighbor_addpath_tx_all_paths_cmd
,
8703 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8707 "Use addpath to advertise all paths to a neighbor\n")
8712 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8714 return CMD_WARNING_CONFIG_FAILED
;
8716 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8717 != BGP_ADDPATH_ALL
) {
8719 "%% Peer not currently configured to transmit all paths.");
8720 return CMD_WARNING_CONFIG_FAILED
;
8723 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8729 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8730 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8731 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8732 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8733 "Use addpath to advertise all paths to a neighbor\n")
8735 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8736 neighbor_addpath_tx_bestpath_per_as_cmd
,
8737 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8740 "Use addpath to advertise the bestpath per each neighboring AS\n")
8745 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8747 return CMD_WARNING_CONFIG_FAILED
;
8749 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8750 BGP_ADDPATH_BEST_PER_AS
);
8755 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8756 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8757 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8758 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8759 "Use addpath to advertise the bestpath per each neighboring AS\n")
8761 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8762 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8763 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8767 "Use addpath to advertise the bestpath per each neighboring AS\n")
8772 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8774 return CMD_WARNING_CONFIG_FAILED
;
8776 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8777 != BGP_ADDPATH_BEST_PER_AS
) {
8779 "%% Peer not currently configured to transmit all best path per as.");
8780 return CMD_WARNING_CONFIG_FAILED
;
8783 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8789 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8790 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8791 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8792 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8793 "Use addpath to advertise the bestpath per each neighboring AS\n")
8796 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8797 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8800 "Detect AS loops before sending to neighbor\n")
8804 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8806 return CMD_WARNING_CONFIG_FAILED
;
8808 peer
->as_path_loop_detection
= true;
8814 no_neighbor_aspath_loop_detection
,
8815 no_neighbor_aspath_loop_detection_cmd
,
8816 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8820 "Detect AS loops before sending to neighbor\n")
8824 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8826 return CMD_WARNING_CONFIG_FAILED
;
8828 peer
->as_path_loop_detection
= false;
8833 DEFPY(neighbor_path_attribute_discard
,
8834 neighbor_path_attribute_discard_cmd
,
8835 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...",
8838 "Manipulate path attributes from incoming UPDATE messages\n"
8839 "Drop specified attributes from incoming UPDATE messages\n"
8840 "Attribute number\n")
8844 const char *discard_attrs
= NULL
;
8846 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8848 return CMD_WARNING_CONFIG_FAILED
;
8850 argv_find(argv
, argc
, "(1-255)", &idx
);
8852 discard_attrs
= argv_concat(argv
, argc
, idx
);
8854 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, true);
8859 DEFPY(no_neighbor_path_attribute_discard
,
8860 no_neighbor_path_attribute_discard_cmd
,
8861 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]",
8865 "Manipulate path attributes from incoming UPDATE messages\n"
8866 "Drop specified attributes from incoming UPDATE messages\n"
8867 "Attribute number\n")
8871 const char *discard_attrs
= NULL
;
8873 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8875 return CMD_WARNING_CONFIG_FAILED
;
8877 argv_find(argv
, argc
, "(1-255)", &idx
);
8879 discard_attrs
= argv
[idx
]->arg
;
8881 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, false);
8886 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8887 struct ecommunity
**list
, bool is_rt6
)
8889 struct ecommunity
*ecom
= NULL
;
8890 struct ecommunity
*ecomadd
;
8892 for (; argc
; --argc
, ++argv
) {
8894 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8895 ECOMMUNITY_ROUTE_TARGET
,
8898 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8899 ECOMMUNITY_ROUTE_TARGET
,
8902 vty_out(vty
, "Malformed community-list value\n");
8904 ecommunity_free(&ecom
);
8905 return CMD_WARNING_CONFIG_FAILED
;
8909 ecommunity_merge(ecom
, ecomadd
);
8910 ecommunity_free(&ecomadd
);
8917 ecommunity_free(&*list
);
8925 * v2vimport is true if we are handling a `import vrf ...` command
8927 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8931 switch (vty
->node
) {
8940 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8945 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8946 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8947 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8948 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8950 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8954 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8955 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8956 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8957 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8959 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8966 DEFPY (af_rd_vpn_export
,
8967 af_rd_vpn_export_cmd
,
8968 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8970 "Specify route distinguisher\n"
8971 "Between current address-family and vpn\n"
8972 "For routes leaked from current address-family to vpn\n"
8973 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8976 struct prefix_rd prd
;
8982 if (argv_find(argv
, argc
, "no", &idx
))
8986 ret
= str2prefix_rd(rd_str
, &prd
);
8988 vty_out(vty
, "%% Malformed rd\n");
8989 return CMD_WARNING_CONFIG_FAILED
;
8993 afi
= vpn_policy_getafi(vty
, bgp
, false);
8995 return CMD_WARNING_CONFIG_FAILED
;
8998 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9000 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9001 bgp_get_default(), bgp
);
9004 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
9005 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9006 BGP_VPN_POLICY_TOVPN_RD_SET
);
9008 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9009 BGP_VPN_POLICY_TOVPN_RD_SET
);
9012 /* post-change: re-export vpn routes */
9013 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9014 bgp_get_default(), bgp
);
9019 ALIAS (af_rd_vpn_export
,
9020 af_no_rd_vpn_export_cmd
,
9023 "Specify route distinguisher\n"
9024 "Between current address-family and vpn\n"
9025 "For routes leaked from current address-family to vpn\n")
9027 DEFPY (af_label_vpn_export
,
9028 af_label_vpn_export_cmd
,
9029 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9031 "label value for VRF\n"
9032 "Between current address-family and vpn\n"
9033 "For routes leaked from current address-family to vpn\n"
9034 "Label Value <0-1048575>\n"
9035 "Automatically assign a label\n")
9037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9038 mpls_label_t label
= MPLS_LABEL_NONE
;
9043 if (argv_find(argv
, argc
, "no", &idx
))
9046 /* If "no ...", squash trailing parameter */
9052 label
= label_val
; /* parser should force unsigned */
9055 afi
= vpn_policy_getafi(vty
, bgp
, false);
9057 return CMD_WARNING_CONFIG_FAILED
;
9060 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9061 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9066 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9068 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9069 bgp_get_default(), bgp
);
9071 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9072 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9074 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9077 * label has previously been automatically
9078 * assigned by labelpool: release it
9080 * NB if tovpn_label == MPLS_LABEL_NONE it
9081 * means the automatic assignment is in flight
9082 * and therefore the labelpool callback must
9083 * detect that the auto label is not needed.
9086 bgp_lp_release(LP_TYPE_VRF
,
9087 &bgp
->vpn_policy
[afi
],
9088 bgp
->vpn_policy
[afi
].tovpn_label
);
9090 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9091 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9094 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9096 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9097 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9098 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9099 vpn_leak_label_callback
);
9102 /* post-change: re-export vpn routes */
9103 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9104 bgp_get_default(), bgp
);
9106 hook_call(bgp_snmp_update_last_changed
, bgp
);
9110 DEFPY (af_sid_vpn_export
,
9111 af_sid_vpn_export_cmd
,
9112 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9114 "sid value for VRF\n"
9115 "Between current address-family and vpn\n"
9116 "For routes leaked from current address-family to vpn\n"
9117 "Sid allocation index\n"
9118 "Automatically assign a label\n")
9120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9126 if (argv_find(argv
, argc
, "no", &idx
))
9128 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9129 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9131 afi
= vpn_policy_getafi(vty
, bgp
, false);
9133 return CMD_WARNING_CONFIG_FAILED
;
9137 vty_out(vty
, "It's not implemented\n");
9138 return CMD_WARNING_CONFIG_FAILED
;
9141 if (bgp
->tovpn_sid_index
!= 0 ||
9142 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9144 "per-vrf sid and per-af sid are mutually exclusive\n"
9145 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9146 return CMD_WARNING_CONFIG_FAILED
;
9149 /* skip when it's already configured */
9150 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9151 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9152 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9156 * mode change between sid_idx and sid_auto isn't supported.
9157 * user must negate sid vpn export when they want to change the mode
9159 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9160 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9161 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9162 vty_out(vty
, "it's already configured as %s.\n",
9163 sid_auto
? "auto-mode" : "idx-mode");
9164 return CMD_WARNING_CONFIG_FAILED
;
9168 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9169 bgp_get_default(), bgp
);
9172 /* SID allocation auto-mode */
9174 zlog_debug("%s: auto sid alloc.", __func__
);
9175 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9176 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9178 /* SID allocation index-mode */
9180 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9181 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9185 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9186 bgp_get_default(), bgp
);
9190 DEFPY (bgp_sid_vpn_export
,
9191 bgp_sid_vpn_export_cmd
,
9192 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9194 "sid value for VRF\n"
9195 "Between current vrf and vpn\n"
9196 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9197 "For routes leaked from current vrf to vpn\n"
9198 "Sid allocation index\n"
9199 "Automatically assign a label\n")
9201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9204 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9205 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9208 /* when per-VRF SID is not set, do nothing */
9209 if (bgp
->tovpn_sid_index
== 0 &&
9210 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9215 bgp
->tovpn_sid_index
= 0;
9216 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9219 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9220 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9221 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9222 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9223 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9224 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9226 "per-vrf sid and per-af sid are mutually exclusive\n"
9227 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9228 return CMD_WARNING_CONFIG_FAILED
;
9231 /* skip when it's already configured */
9232 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9233 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9237 * mode change between sid_idx and sid_auto isn't supported.
9238 * user must negate sid vpn export when they want to change the mode
9240 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9242 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9243 vty_out(vty
, "it's already configured as %s.\n",
9244 sid_auto
? "auto-mode" : "idx-mode");
9245 return CMD_WARNING_CONFIG_FAILED
;
9249 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9251 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9255 /* SID allocation auto-mode */
9257 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9258 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9259 } else if (sid_idx
!= 0) {
9260 /* SID allocation index-mode */
9262 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9264 bgp
->tovpn_sid_index
= sid_idx
;
9268 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9270 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9271 bgp_get_default(), bgp
);
9276 ALIAS (af_label_vpn_export
,
9277 af_no_label_vpn_export_cmd
,
9278 "no label vpn export",
9280 "label value for VRF\n"
9281 "Between current address-family and vpn\n"
9282 "For routes leaked from current address-family to vpn\n")
9284 ALIAS (bgp_sid_vpn_export
,
9285 no_bgp_sid_vpn_export_cmd
,
9286 "no$no sid vpn per-vrf export",
9288 "sid value for VRF\n"
9289 "Between current vrf and vpn\n"
9290 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9291 "For routes leaked from current vrf to vpn\n")
9293 DEFPY (af_nexthop_vpn_export
,
9294 af_nexthop_vpn_export_cmd
,
9295 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9297 "Specify next hop to use for VRF advertised prefixes\n"
9298 "Between current address-family and vpn\n"
9299 "For routes leaked from current address-family to vpn\n"
9303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9309 vty_out(vty
, "%% Nexthop required\n");
9310 return CMD_WARNING_CONFIG_FAILED
;
9312 if (!sockunion2hostprefix(nexthop_su
, &p
))
9313 return CMD_WARNING_CONFIG_FAILED
;
9316 afi
= vpn_policy_getafi(vty
, bgp
, false);
9318 return CMD_WARNING_CONFIG_FAILED
;
9321 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9323 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9324 bgp_get_default(), bgp
);
9327 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9328 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9329 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9331 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9332 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9335 /* post-change: re-export vpn routes */
9336 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9337 bgp_get_default(), bgp
);
9342 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9344 if (!strcmp(dstr
, "import")) {
9345 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9346 } else if (!strcmp(dstr
, "export")) {
9347 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9348 } else if (!strcmp(dstr
, "both")) {
9349 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9350 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9352 vty_out(vty
, "%% direction parse error\n");
9353 return CMD_WARNING_CONFIG_FAILED
;
9358 DEFPY (af_rt_vpn_imexport
,
9359 af_rt_vpn_imexport_cmd
,
9360 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9362 "Specify route target list\n"
9363 "Specify route target list\n"
9364 "Between current address-family and vpn\n"
9365 "For routes leaked from vpn to current address-family: match any\n"
9366 "For routes leaked from current address-family to vpn: set\n"
9367 "both import: match any and export: set\n"
9368 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9372 struct ecommunity
*ecom
= NULL
;
9373 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9374 enum vpn_policy_direction dir
;
9379 if (argv_find(argv
, argc
, "no", &idx
))
9382 afi
= vpn_policy_getafi(vty
, bgp
, false);
9384 return CMD_WARNING_CONFIG_FAILED
;
9386 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9387 if (ret
!= CMD_SUCCESS
)
9391 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9392 vty_out(vty
, "%% Missing RTLIST\n");
9393 return CMD_WARNING_CONFIG_FAILED
;
9395 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9396 if (ret
!= CMD_SUCCESS
) {
9401 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9405 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9408 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9410 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9411 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9412 ecommunity_dup(ecom
);
9414 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9416 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9417 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9420 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9424 ecommunity_free(&ecom
);
9429 ALIAS (af_rt_vpn_imexport
,
9430 af_no_rt_vpn_imexport_cmd
,
9431 "no <rt|route-target> vpn <import|export|both>$direction_str",
9433 "Specify route target list\n"
9434 "Specify route target list\n"
9435 "Between current address-family and vpn\n"
9436 "For routes leaked from vpn to current address-family\n"
9437 "For routes leaked from current address-family to vpn\n"
9438 "both import and export\n")
9440 DEFPY (af_route_map_vpn_imexport
,
9441 af_route_map_vpn_imexport_cmd
,
9442 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9443 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9445 "Specify route map\n"
9446 "Between current address-family and vpn\n"
9447 "For routes leaked from vpn to current address-family\n"
9448 "For routes leaked from current address-family to vpn\n"
9449 "name of route-map\n")
9451 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9453 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9454 enum vpn_policy_direction dir
;
9459 if (argv_find(argv
, argc
, "no", &idx
))
9462 afi
= vpn_policy_getafi(vty
, bgp
, false);
9464 return CMD_WARNING_CONFIG_FAILED
;
9466 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9467 if (ret
!= CMD_SUCCESS
)
9470 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9474 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9477 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9478 XFREE(MTYPE_ROUTE_MAP_NAME
,
9479 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9480 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9481 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9482 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9483 route_map_lookup_warn_noexist(vty
, rmap_str
);
9484 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9487 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9488 XFREE(MTYPE_ROUTE_MAP_NAME
,
9489 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9490 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9491 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9494 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9500 ALIAS (af_route_map_vpn_imexport
,
9501 af_no_route_map_vpn_imexport_cmd
,
9502 "no route-map vpn <import|export>$direction_str",
9504 "Specify route map\n"
9505 "Between current address-family and vpn\n"
9506 "For routes leaked from vpn to current address-family\n"
9507 "For routes leaked from current address-family to vpn\n")
9509 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9510 "import vrf route-map RMAP$rmap_str",
9511 "Import routes from another VRF\n"
9512 "Vrf routes being filtered\n"
9513 "Specify route map\n"
9514 "name of route-map\n")
9516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9517 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9519 struct bgp
*bgp_default
;
9521 afi
= vpn_policy_getafi(vty
, bgp
, true);
9523 return CMD_WARNING_CONFIG_FAILED
;
9525 bgp_default
= bgp_get_default();
9530 /* Auto-create assuming the same AS */
9531 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9532 BGP_INSTANCE_TYPE_DEFAULT
, NULL
);
9536 "VRF default is not configured as a bgp instance\n");
9541 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9543 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9544 XFREE(MTYPE_ROUTE_MAP_NAME
,
9545 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9546 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9547 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9548 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9549 route_map_lookup_warn_noexist(vty
, rmap_str
);
9550 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9553 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9554 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9556 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9561 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9562 "no import vrf route-map [RMAP$rmap_str]",
9564 "Import routes from another VRF\n"
9565 "Vrf routes being filtered\n"
9566 "Specify route map\n"
9567 "name of route-map\n")
9569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9570 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9573 afi
= vpn_policy_getafi(vty
, bgp
, true);
9575 return CMD_WARNING_CONFIG_FAILED
;
9577 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9579 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9580 XFREE(MTYPE_ROUTE_MAP_NAME
,
9581 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9582 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9583 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9585 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9586 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9587 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9589 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9594 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9595 "[no] import vrf VIEWVRFNAME$import_name",
9597 "Import routes from another VRF\n"
9598 "VRF to import from\n"
9599 "The name of the VRF\n")
9601 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9602 struct listnode
*node
;
9603 struct bgp
*vrf_bgp
, *bgp_default
;
9606 bool remove
= false;
9609 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9613 if (import_name
== NULL
) {
9614 vty_out(vty
, "%% Missing import name\n");
9618 if (strcmp(import_name
, "route-map") == 0) {
9619 vty_out(vty
, "%% Must include route-map name\n");
9623 if (argv_find(argv
, argc
, "no", &idx
))
9626 afi
= vpn_policy_getafi(vty
, bgp
, true);
9628 return CMD_WARNING_CONFIG_FAILED
;
9630 safi
= bgp_node_safi(vty
);
9632 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9633 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9634 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9635 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9636 remove
? "unimport" : "import", import_name
);
9640 bgp_default
= bgp_get_default();
9642 /* Auto-create assuming the same AS */
9643 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9644 BGP_INSTANCE_TYPE_DEFAULT
, NULL
);
9648 "VRF default is not configured as a bgp instance\n");
9653 vrf_bgp
= bgp_lookup_by_name(import_name
);
9655 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9656 vrf_bgp
= bgp_default
;
9658 /* Auto-create assuming the same AS */
9659 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
, NULL
);
9663 "VRF %s is not configured as a bgp instance\n",
9670 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9672 /* Already importing from "import_vrf"? */
9673 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9675 if (strcmp(vname
, import_name
) == 0)
9679 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9685 /* This command is valid only in a bgp vrf instance or the default instance */
9686 DEFPY (bgp_imexport_vpn
,
9687 bgp_imexport_vpn_cmd
,
9688 "[no] <import|export>$direction_str vpn",
9690 "Import routes to this address-family\n"
9691 "Export routes from this address-family\n"
9692 "to/from default instance VPN RIB\n")
9694 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9701 enum vpn_policy_direction dir
;
9703 if (argv_find(argv
, argc
, "no", &idx
))
9706 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9707 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9709 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9710 return CMD_WARNING_CONFIG_FAILED
;
9713 afi
= bgp_node_afi(vty
);
9714 safi
= bgp_node_safi(vty
);
9715 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9716 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9717 return CMD_WARNING_CONFIG_FAILED
;
9720 if (!strcmp(direction_str
, "import")) {
9721 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9722 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9723 } else if (!strcmp(direction_str
, "export")) {
9724 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9725 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9727 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9728 return CMD_WARNING_CONFIG_FAILED
;
9731 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9734 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9735 if (!previous_state
) {
9736 /* trigger export current vrf */
9737 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9740 if (previous_state
) {
9741 /* trigger un-export current vrf */
9742 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9744 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9747 hook_call(bgp_snmp_init_stats
, bgp
);
9752 DEFPY (af_routetarget_import
,
9753 af_routetarget_import_cmd
,
9754 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9756 "Specify route target list\n"
9757 "Specify route target list\n"
9758 "Specify route target list\n"
9759 "Specify route target list\n"
9760 "Flow-spec redirect type route target\n"
9761 "Import routes to this address-family\n"
9762 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9766 struct ecommunity
*ecom
= NULL
;
9768 int idx
= 0, idx_unused
= 0;
9772 if (argv_find(argv
, argc
, "no", &idx
))
9775 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9776 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9779 afi
= vpn_policy_getafi(vty
, bgp
, false);
9781 return CMD_WARNING_CONFIG_FAILED
;
9783 if (rt6
&& afi
!= AFI_IP6
)
9784 return CMD_WARNING_CONFIG_FAILED
;
9787 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9788 vty_out(vty
, "%% Missing RTLIST\n");
9789 return CMD_WARNING_CONFIG_FAILED
;
9791 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9792 if (ret
!= CMD_SUCCESS
)
9797 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9798 ecommunity_free(&bgp
->vpn_policy
[afi
]
9799 .import_redirect_rtlist
);
9800 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9801 ecommunity_dup(ecom
);
9803 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9804 ecommunity_free(&bgp
->vpn_policy
[afi
]
9805 .import_redirect_rtlist
);
9806 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9810 ecommunity_free(&ecom
);
9815 DEFUN_NOSH (address_family_ipv4_safi
,
9816 address_family_ipv4_safi_cmd
,
9817 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9818 "Enter Address Family command mode\n"
9820 BGP_SAFI_WITH_LABEL_HELP_STR
)
9824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9825 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9826 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9827 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9828 && safi
!= SAFI_EVPN
) {
9830 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9831 return CMD_WARNING_CONFIG_FAILED
;
9833 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9835 vty
->node
= BGP_IPV4_NODE
;
9840 DEFUN_NOSH (address_family_ipv6_safi
,
9841 address_family_ipv6_safi_cmd
,
9842 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9843 "Enter Address Family command mode\n"
9845 BGP_SAFI_WITH_LABEL_HELP_STR
)
9848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9849 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9850 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9851 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9852 && safi
!= SAFI_EVPN
) {
9854 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9855 return CMD_WARNING_CONFIG_FAILED
;
9857 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9859 vty
->node
= BGP_IPV6_NODE
;
9864 #ifdef KEEP_OLD_VPN_COMMANDS
9865 DEFUN_NOSH (address_family_vpnv4
,
9866 address_family_vpnv4_cmd
,
9867 "address-family vpnv4 [unicast]",
9868 "Enter Address Family command mode\n"
9870 BGP_AF_MODIFIER_STR
)
9872 vty
->node
= BGP_VPNV4_NODE
;
9876 DEFUN_NOSH (address_family_vpnv6
,
9877 address_family_vpnv6_cmd
,
9878 "address-family vpnv6 [unicast]",
9879 "Enter Address Family command mode\n"
9881 BGP_AF_MODIFIER_STR
)
9883 vty
->node
= BGP_VPNV6_NODE
;
9886 #endif /* KEEP_OLD_VPN_COMMANDS */
9888 DEFUN_NOSH (address_family_evpn
,
9889 address_family_evpn_cmd
,
9890 "address-family l2vpn evpn",
9891 "Enter Address Family command mode\n"
9893 BGP_AF_MODIFIER_STR
)
9895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9896 vty
->node
= BGP_EVPN_NODE
;
9900 DEFUN_NOSH (bgp_segment_routing_srv6
,
9901 bgp_segment_routing_srv6_cmd
,
9902 "segment-routing srv6",
9903 "Segment-Routing configuration\n"
9904 "Segment-Routing SRv6 configuration\n")
9906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9907 bgp
->srv6_enabled
= true;
9908 vty
->node
= BGP_SRV6_NODE
;
9912 DEFUN (no_bgp_segment_routing_srv6
,
9913 no_bgp_segment_routing_srv6_cmd
,
9914 "no segment-routing srv6",
9916 "Segment-Routing configuration\n"
9917 "Segment-Routing SRv6 configuration\n")
9919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9921 if (strlen(bgp
->srv6_locator_name
) > 0)
9922 if (bgp_srv6_locator_unset(bgp
) < 0)
9923 return CMD_WARNING_CONFIG_FAILED
;
9925 bgp
->srv6_enabled
= false;
9929 DEFPY (bgp_srv6_locator
,
9930 bgp_srv6_locator_cmd
,
9931 "locator NAME$name",
9932 "Specify SRv6 locator\n"
9933 "Specify SRv6 locator\n")
9935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9938 if (strlen(bgp
->srv6_locator_name
) > 0
9939 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9940 vty_out(vty
, "srv6 locator is already configured\n");
9941 return CMD_WARNING_CONFIG_FAILED
;
9944 snprintf(bgp
->srv6_locator_name
,
9945 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9947 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9949 return CMD_WARNING_CONFIG_FAILED
;
9954 DEFPY (no_bgp_srv6_locator
,
9955 no_bgp_srv6_locator_cmd
,
9956 "no locator NAME$name",
9958 "Specify SRv6 locator\n"
9959 "Specify SRv6 locator\n")
9961 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9963 /* when locator isn't configured, do nothing */
9964 if (strlen(bgp
->srv6_locator_name
) < 1)
9967 /* name validation */
9968 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9969 vty_out(vty
, "%% No srv6 locator is configured\n");
9970 return CMD_WARNING_CONFIG_FAILED
;
9974 if (bgp_srv6_locator_unset(bgp
) < 0)
9975 return CMD_WARNING_CONFIG_FAILED
;
9980 DEFPY (show_bgp_srv6
,
9982 "show bgp segment-routing srv6",
9985 "BGP Segment Routing\n"
9986 "BGP Segment Routing SRv6\n")
9989 struct listnode
*node
;
9990 struct srv6_locator_chunk
*chunk
;
9991 struct bgp_srv6_function
*func
;
9993 bgp
= bgp_get_default();
9997 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9998 vty_out(vty
, "locator_chunks:\n");
9999 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10000 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
10001 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
10002 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
10003 vty_out(vty
, " func-length: %d\n",
10004 chunk
->function_bits_length
);
10005 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
10008 vty_out(vty
, "functions:\n");
10009 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10010 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
10011 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10014 vty_out(vty
, "bgps:\n");
10015 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10016 vty_out(vty
, "- name: %s\n",
10017 bgp
->name
? bgp
->name
: "default");
10019 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
10020 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
10021 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
10022 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
10023 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
10026 return CMD_SUCCESS
;
10029 DEFUN_NOSH (exit_address_family
,
10030 exit_address_family_cmd
,
10031 "exit-address-family",
10032 "Exit from Address Family configuration mode\n")
10034 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10035 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10036 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10037 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10038 || vty
->node
== BGP_EVPN_NODE
10039 || vty
->node
== BGP_FLOWSPECV4_NODE
10040 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10041 vty
->node
= BGP_NODE
;
10042 return CMD_SUCCESS
;
10045 /* Recalculate bestpath and re-advertise a prefix */
10046 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10047 const char *ip_str
, afi_t afi
, safi_t safi
,
10048 struct prefix_rd
*prd
)
10051 struct prefix match
;
10052 struct bgp_dest
*dest
;
10053 struct bgp_dest
*rm
;
10055 struct bgp_table
*table
;
10056 struct bgp_table
*rib
;
10058 /* BGP structure lookup. */
10060 bgp
= bgp_lookup_by_name(view_name
);
10062 vty_out(vty
, "%% Can't find BGP instance %s\n",
10064 return CMD_WARNING
;
10067 bgp
= bgp_get_default();
10069 vty_out(vty
, "%% No BGP process is configured\n");
10070 return CMD_WARNING
;
10074 /* Check IP address argument. */
10075 ret
= str2prefix(ip_str
, &match
);
10077 vty_out(vty
, "%% address is malformed\n");
10078 return CMD_WARNING
;
10081 match
.family
= afi2family(afi
);
10082 rib
= bgp
->rib
[afi
][safi
];
10084 if (safi
== SAFI_MPLS_VPN
) {
10085 for (dest
= bgp_table_top(rib
); dest
;
10086 dest
= bgp_route_next(dest
)) {
10087 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10089 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10092 table
= bgp_dest_get_bgp_table_info(dest
);
10096 rm
= bgp_node_match(table
, &match
);
10098 const struct prefix
*rm_p
=
10099 bgp_dest_get_prefix(rm
);
10101 if (rm_p
->prefixlen
== match
.prefixlen
) {
10102 SET_FLAG(rm
->flags
,
10103 BGP_NODE_USER_CLEAR
);
10104 bgp_process(bgp
, rm
, afi
, safi
);
10106 bgp_dest_unlock_node(rm
);
10110 dest
= bgp_node_match(rib
, &match
);
10111 if (dest
!= NULL
) {
10112 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10114 if (dest_p
->prefixlen
== match
.prefixlen
) {
10115 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10116 bgp_process(bgp
, dest
, afi
, safi
);
10118 bgp_dest_unlock_node(dest
);
10122 return CMD_SUCCESS
;
10125 /* one clear bgp command to rule them all */
10126 DEFUN (clear_ip_bgp_all
,
10127 clear_ip_bgp_all_cmd
,
10128 "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|ASNUM|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]",
10132 BGP_INSTANCE_HELP_STR
10135 BGP_SAFI_WITH_LABEL_HELP_STR
10136 BGP_AF_MODIFIER_STR
10137 "Clear all peers\n"
10138 "BGP IPv4 neighbor to clear\n"
10139 "BGP IPv6 neighbor to clear\n"
10140 "BGP neighbor on interface to clear\n"
10141 "Clear peers with the AS number in plain or dotted format\n"
10142 "Clear all external peers\n"
10143 "Clear all members of peer-group\n"
10144 "BGP peer-group name\n"
10149 "Push out prefix-list ORF and do inbound soft reconfig\n"
10151 "Reset message statistics\n")
10155 afi_t afi
= AFI_UNSPEC
;
10156 safi_t safi
= SAFI_UNSPEC
;
10157 enum clear_sort clr_sort
= clear_peer
;
10158 enum bgp_clear_type clr_type
;
10159 char *clr_arg
= NULL
;
10163 /* clear [ip] bgp */
10164 if (argv_find(argv
, argc
, "ip", &idx
))
10167 /* [<vrf> VIEWVRFNAME] */
10168 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10169 vrf
= argv
[idx
+ 1]->arg
;
10171 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10173 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10174 /* [<view> VIEWVRFNAME] */
10175 vrf
= argv
[idx
+ 1]->arg
;
10178 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10179 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10180 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10182 /* <*|A.B.C.D|X:X::X:X|WORD|ASNUM|external|peer-group PGNAME> */
10183 if (argv_find(argv
, argc
, "*", &idx
)) {
10184 clr_sort
= clear_all
;
10185 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10186 clr_sort
= clear_peer
;
10187 clr_arg
= argv
[idx
]->arg
;
10188 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10189 clr_sort
= clear_peer
;
10190 clr_arg
= argv
[idx
]->arg
;
10191 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10192 clr_sort
= clear_group
;
10194 clr_arg
= argv
[idx
]->arg
;
10195 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10196 clr_sort
= clear_peer
;
10197 clr_arg
= argv
[idx
]->arg
;
10198 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10199 clr_sort
= clear_peer
;
10200 clr_arg
= argv
[idx
]->arg
;
10201 } else if (argv_find(argv
, argc
, "ASNUM", &idx
)) {
10202 clr_sort
= clear_as
;
10203 clr_arg
= argv
[idx
]->arg
;
10204 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10205 clr_sort
= clear_external
;
10208 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10209 if (argv_find(argv
, argc
, "soft", &idx
)) {
10210 if (argv_find(argv
, argc
, "in", &idx
)
10211 || argv_find(argv
, argc
, "out", &idx
))
10212 clr_type
= strmatch(argv
[idx
]->text
, "in")
10213 ? BGP_CLEAR_SOFT_IN
10214 : BGP_CLEAR_SOFT_OUT
;
10216 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10217 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10218 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10219 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10220 : BGP_CLEAR_SOFT_IN
;
10221 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10222 clr_type
= BGP_CLEAR_SOFT_OUT
;
10223 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10224 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10226 clr_type
= BGP_CLEAR_SOFT_NONE
;
10228 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10231 DEFUN (clear_ip_bgp_prefix
,
10232 clear_ip_bgp_prefix_cmd
,
10233 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10237 BGP_INSTANCE_HELP_STR
10238 "Clear bestpath and re-advertise\n"
10242 char *prefix
= NULL
;
10246 /* [<view|vrf> VIEWVRFNAME] */
10247 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10248 vrf
= argv
[idx
+ 1]->arg
;
10250 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10252 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10253 /* [<view> VIEWVRFNAME] */
10254 vrf
= argv
[idx
+ 1]->arg
;
10258 prefix
= argv
[argc
- 1]->arg
;
10260 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10263 DEFUN (clear_bgp_ipv6_safi_prefix
,
10264 clear_bgp_ipv6_safi_prefix_cmd
,
10265 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10271 "Clear bestpath and re-advertise\n"
10275 int idx_ipv6_prefix
= 0;
10276 safi_t safi
= SAFI_UNICAST
;
10277 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10278 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10280 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10281 return bgp_clear_prefix(
10282 vty
, NULL
, prefix
, AFI_IP6
,
10286 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10287 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10288 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10292 BGP_INSTANCE_HELP_STR
10295 "Clear bestpath and re-advertise\n"
10299 int idx_vrfview
= 0;
10300 int idx_ipv6_prefix
= 0;
10301 safi_t safi
= SAFI_UNICAST
;
10302 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10303 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10304 char *vrfview
= NULL
;
10306 /* [<view|vrf> VIEWVRFNAME] */
10307 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10308 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10309 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10311 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10312 /* [<view> VIEWVRFNAME] */
10313 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10315 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10317 return bgp_clear_prefix(
10318 vty
, vrfview
, prefix
,
10319 AFI_IP6
, safi
, NULL
);
10322 DEFUN (show_bgp_views
,
10323 show_bgp_views_cmd
,
10324 "show [ip] bgp views",
10328 "Show the defined BGP views\n")
10330 struct list
*inst
= bm
->bgp
;
10331 struct listnode
*node
;
10334 vty_out(vty
, "Defined BGP views:\n");
10335 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10337 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10339 vty_out(vty
, "\t%s (AS%s)\n", bgp
->name
? bgp
->name
: "(null)",
10343 return CMD_SUCCESS
;
10346 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10350 struct listnode
*node
;
10352 *peers_cfgd
= *peers_estbd
= 0;
10353 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10354 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10357 if (peer_established(peer
))
10362 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10365 int peers_cfg
, peers_estb
;
10367 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10370 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10372 : (int64_t)bgp
->vrf_id
;
10373 json_object_string_add(json
, "type", type
);
10374 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10375 json_object_string_addf(json
, "routerId", "%pI4",
10377 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10378 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10379 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10380 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10381 json_object_string_add(
10383 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10387 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10388 json_object
*json
, const char *name
,
10389 const char *type
, bool use_vrf
)
10391 int peers_cfg
, peers_estb
;
10393 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10397 print_bgp_vrfs(bgp
, vty
, json
, type
);
10399 vty_out(vty
, "BGP instance %s VRF id %d\n",
10401 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10402 : (int)bgp
->vrf_id
);
10403 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10405 "Num Configured Peers %d, Established %d\n",
10406 peers_cfg
, peers_estb
);
10409 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10411 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10418 print_bgp_vrfs(bgp
, vty
, json
, type
);
10420 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10422 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10423 : (int)bgp
->vrf_id
,
10424 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10425 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10426 bgp
->l3vni
, &bgp
->rmac
,
10427 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10432 return CMD_SUCCESS
;
10435 DEFPY (show_bgp_vrfs
,
10437 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10442 "Specific VRF name\n"
10445 struct list
*inst
= bm
->bgp
;
10446 struct listnode
*node
;
10448 bool uj
= use_json(argc
, argv
);
10449 json_object
*json
= NULL
;
10450 json_object
*json_vrfs
= NULL
;
10451 json_object
*json_vrf
= NULL
;
10453 const char *name
= vrf_name
;
10457 json
= json_object_new_object();
10460 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10461 bgp
= bgp_get_default();
10464 bgp
= bgp_lookup_by_name(name
);
10469 vty_json(vty
, json
);
10472 "%% Specified BGP instance not found\n");
10474 return CMD_WARNING
;
10480 json_vrf
= json_object_new_object();
10482 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10486 json_object_object_add(json
, name
, json_vrf
);
10487 vty_json(vty
, json
);
10490 return CMD_SUCCESS
;
10494 json_vrfs
= json_object_new_object();
10496 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10500 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10504 if (!uj
&& count
== 1) {
10506 "%4s %-5s %-16s %9s %10s %-37s\n",
10507 "Type", "Id", "routerId", "#PeersCfg",
10508 "#PeersEstb", "Name");
10509 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10510 "L3-VNI", "RouterMAC", "Interface");
10513 json_vrf
= json_object_new_object();
10515 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10516 name
= VRF_DEFAULT_NAME
;
10523 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10527 json_object_object_add(json_vrfs
, name
, json_vrf
);
10531 json_object_object_add(json
, "vrfs", json_vrfs
);
10532 json_object_int_add(json
, "totalVrfs", count
);
10533 vty_json(vty
, json
);
10537 "\nTotal number of VRFs (including default): %d\n",
10541 return CMD_SUCCESS
;
10544 DEFUN (show_bgp_mac_hash
,
10545 show_bgp_mac_hash_cmd
,
10546 "show bgp mac hash",
10550 "Mac Address database\n")
10552 bgp_mac_dump_table(vty
);
10554 return CMD_SUCCESS
;
10557 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10559 struct vty
*vty
= (struct vty
*)args
;
10560 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10562 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10565 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10567 vty_out(vty
, "self nexthop database:\n");
10568 bgp_nexthop_show_address_hash(vty
, bgp
);
10570 vty_out(vty
, "Tunnel-ip database:\n");
10571 hash_iterate(bgp
->tip_hash
,
10572 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10576 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10577 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10578 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10579 "martian next-hops\n"
10580 "martian next-hop database\n")
10582 struct bgp
*bgp
= NULL
;
10586 /* [<vrf> VIEWVRFNAME] */
10587 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10588 name
= argv
[idx
+ 1]->arg
;
10589 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10591 } else if (argv_find(argv
, argc
, "view", &idx
))
10592 /* [<view> VIEWVRFNAME] */
10593 name
= argv
[idx
+ 1]->arg
;
10595 bgp
= bgp_lookup_by_name(name
);
10597 bgp
= bgp_get_default();
10600 vty_out(vty
, "%% No BGP process is configured\n");
10601 return CMD_WARNING
;
10603 bgp_show_martian_nexthops(vty
, bgp
);
10605 return CMD_SUCCESS
;
10608 DEFUN (show_bgp_memory
,
10609 show_bgp_memory_cmd
,
10610 "show [ip] bgp memory",
10614 "Global BGP memory statistics\n")
10616 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10617 unsigned long count
;
10619 /* RIB related usage stats */
10620 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10621 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10622 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10623 count
* sizeof(struct bgp_dest
)));
10625 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10626 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10627 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10628 count
* sizeof(struct bgp_path_info
)));
10629 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10630 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10633 memstrbuf
, sizeof(memstrbuf
),
10634 count
* sizeof(struct bgp_path_info_extra
)));
10636 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10637 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10638 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10639 count
* sizeof(struct bgp_static
)));
10641 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10642 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10643 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10644 count
* sizeof(struct bpacket
)));
10647 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10648 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10649 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10650 count
* sizeof(struct bgp_adj_in
)));
10651 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10652 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10653 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10654 count
* sizeof(struct bgp_adj_out
)));
10656 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10657 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10659 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10660 count
* sizeof(struct bgp_nexthop_cache
)));
10662 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10663 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10665 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10666 count
* sizeof(struct bgp_damp_info
)));
10669 count
= attr_count();
10670 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10671 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10672 count
* sizeof(struct attr
)));
10674 if ((count
= attr_unknown_count()))
10675 vty_out(vty
, "%ld unknown attributes\n", count
);
10677 /* AS_PATH attributes */
10678 count
= aspath_count();
10679 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10680 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10681 count
* sizeof(struct aspath
)));
10683 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10684 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10685 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10686 count
* sizeof(struct assegment
)));
10688 /* Other attributes */
10689 if ((count
= community_count()))
10690 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10691 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10692 count
* sizeof(struct community
)));
10693 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10695 "%ld BGP ext-community entries, using %s of memory\n",
10697 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10698 count
* sizeof(struct ecommunity
)));
10699 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10701 "%ld BGP large-community entries, using %s of memory\n",
10702 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10703 count
* sizeof(struct lcommunity
)));
10705 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10706 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10707 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10708 count
* sizeof(struct cluster_list
)));
10710 /* Peer related usage */
10711 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10712 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10713 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10714 count
* sizeof(struct peer
)));
10716 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10717 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10718 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10719 count
* sizeof(struct peer_group
)));
10722 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10723 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10724 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10725 count
* sizeof(regex_t
)));
10726 return CMD_SUCCESS
;
10729 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10731 json_object
*bestpath
= json_object_new_object();
10733 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10734 json_object_string_add(bestpath
, "asPath", "ignore");
10736 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10737 json_object_string_add(bestpath
, "asPath", "confed");
10739 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10740 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10741 json_object_string_add(bestpath
, "multiPathRelax",
10744 json_object_string_add(bestpath
, "multiPathRelax",
10747 json_object_string_add(bestpath
, "multiPathRelax", "false");
10749 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10750 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10752 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10753 json_object_string_add(bestpath
, "compareRouterId", "true");
10754 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10755 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10756 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10757 json_object_string_add(bestpath
, "med", "confed");
10758 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10759 json_object_string_add(bestpath
, "med",
10760 "missing-as-worst");
10762 json_object_string_add(bestpath
, "med", "true");
10765 json_object_object_add(json
, "bestPath", bestpath
);
10768 /* Print the error code/subcode for why the peer is down */
10769 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10770 json_object
*json_peer
, bool use_json
)
10772 const char *code_str
;
10773 const char *subcode_str
;
10776 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10777 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10778 char errorcodesubcode_hexstr
[5];
10779 char errorcodesubcode_str
[256];
10781 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10782 subcode_str
= bgp_notify_subcode_str(
10784 peer
->notify
.subcode
);
10786 snprintf(errorcodesubcode_hexstr
,
10787 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10788 peer
->notify
.code
, peer
->notify
.subcode
);
10789 json_object_string_add(json_peer
,
10790 "lastErrorCodeSubcode",
10791 errorcodesubcode_hexstr
);
10792 snprintf(errorcodesubcode_str
, 255, "%s%s",
10793 code_str
, subcode_str
);
10794 json_object_string_add(json_peer
,
10795 "lastNotificationReason",
10796 errorcodesubcode_str
);
10797 json_object_boolean_add(json_peer
,
10798 "lastNotificationHardReset",
10799 peer
->notify
.hard_reset
);
10800 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10801 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10802 && (peer
->notify
.subcode
10803 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10804 || peer
->notify
.subcode
10805 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10806 && peer
->notify
.length
) {
10808 const char *msg_str
;
10810 msg_str
= bgp_notify_admin_message(
10811 msgbuf
, sizeof(msgbuf
),
10812 (uint8_t *)peer
->notify
.data
,
10813 peer
->notify
.length
);
10815 json_object_string_add(
10817 "lastShutdownDescription",
10822 json_object_string_add(json_peer
, "lastResetDueTo",
10823 peer_down_str
[(int)peer
->last_reset
]);
10824 json_object_int_add(json_peer
, "lastResetCode",
10827 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10828 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10829 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10831 bgp_notify_subcode_str(peer
->notify
.code
,
10832 peer
->notify
.subcode
);
10833 vty_out(vty
, " Notification %s (%s%s%s)\n",
10834 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10837 code_str
, subcode_str
,
10838 peer
->notify
.hard_reset
10839 ? bgp_notify_subcode_str(
10841 BGP_NOTIFY_CEASE_HARD_RESET
)
10844 vty_out(vty
, " %s\n",
10845 peer_down_str
[(int)peer
->last_reset
]);
10850 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10853 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10856 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10857 struct peer
*peer
, json_object
*json_peer
,
10858 int max_neighbor_width
, bool use_json
)
10860 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10864 if (peer_dynamic_neighbor(peer
))
10865 json_object_boolean_true_add(json_peer
,
10867 if (peer
->hostname
)
10868 json_object_string_add(json_peer
, "hostname",
10871 if (peer
->domainname
)
10872 json_object_string_add(json_peer
, "domainname",
10874 json_object_int_add(json_peer
, "connectionsEstablished",
10875 peer
->established
);
10876 json_object_int_add(json_peer
, "connectionsDropped",
10878 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10879 use_json
, json_peer
);
10880 if (peer_established(peer
))
10881 json_object_string_add(json_peer
, "lastResetDueTo",
10882 "AFI/SAFI Not Negotiated");
10884 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10887 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10889 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10890 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10891 peer
->hostname
, peer
->host
);
10893 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10895 /* pad the neighbor column with spaces */
10896 if (len
< max_neighbor_width
)
10897 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10899 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10901 peer_uptime(peer
->uptime
, timebuf
,
10902 BGP_UPTIME_LEN
, 0, NULL
));
10903 if (peer_established(peer
))
10904 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10906 bgp_show_peer_reset(vty
, peer
, NULL
,
10911 /* Strip peer's description to the given size. */
10912 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10914 static char stripped
[BUFSIZ
];
10916 uint32_t last_space
= 0;
10919 if (*(desc
+ i
) == 0) {
10920 stripped
[i
] = '\0';
10923 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10925 stripped
[i
] = *(desc
+ i
);
10929 if (last_space
> size
)
10930 stripped
[size
+ 1] = '\0';
10932 stripped
[last_space
] = '\0';
10937 /* Determine whether var peer should be filtered out of the summary. */
10938 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10939 struct peer
*fpeer
, int as_type
,
10943 /* filter neighbor XXXX */
10944 if (fpeer
&& fpeer
!= peer
)
10947 /* filter remote-as (internal|external) */
10948 if (as_type
!= AS_UNSPECIFIED
) {
10949 if (peer
->as_type
== AS_SPECIFIED
) {
10950 if (as_type
== AS_INTERNAL
) {
10951 if (peer
->as
!= peer
->local_as
)
10953 } else if (peer
->as
== peer
->local_as
)
10955 } else if (as_type
!= peer
->as_type
)
10957 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10963 /* Show BGP peer's summary information.
10965 * Peer's description is stripped according to if `wide` option is given
10968 * When adding new columns to `show bgp summary` output, please make
10969 * sure `Desc` is the lastest column to show because it can contain
10970 * whitespaces and the whole output will be tricky.
10972 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10973 struct peer
*fpeer
, int as_type
, as_t as
,
10974 uint16_t show_flags
)
10977 struct listnode
*node
, *nnode
;
10978 unsigned int count
= 0, dn_count
= 0;
10979 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10980 char neighbor_buf
[VTY_BUFSIZ
];
10981 int neighbor_col_default_width
= 16;
10982 int len
, failed_count
= 0;
10983 unsigned int filtered_count
= 0;
10984 int max_neighbor_width
= 0;
10986 json_object
*json
= NULL
;
10987 json_object
*json_peer
= NULL
;
10988 json_object
*json_peers
= NULL
;
10989 struct peer_af
*paf
;
10990 struct bgp_filter
*filter
;
10991 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10992 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10993 bool show_established
=
10994 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10995 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10996 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10998 /* labeled-unicast routes are installed in the unicast table so in order
11000 * display the correct PfxRcd value we must look at SAFI_UNICAST
11003 if (safi
== SAFI_LABELED_UNICAST
)
11004 pfx_rcd_safi
= SAFI_UNICAST
;
11006 pfx_rcd_safi
= safi
;
11009 json
= json_object_new_object();
11010 json_peers
= json_object_new_object();
11011 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11012 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11019 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11022 if (peer
->afc
[afi
][safi
]) {
11023 /* See if we have at least a single failed peer */
11024 if (bgp_has_peer_failed(peer
, afi
, safi
))
11028 if (peer_dynamic_neighbor(peer
))
11033 /* Loop over all neighbors that will be displayed to determine
11035 * characters are needed for the Neighbor column
11037 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11038 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11045 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11048 if (peer
->afc
[afi
][safi
]) {
11049 memset(dn_flag
, '\0', sizeof(dn_flag
));
11050 if (peer_dynamic_neighbor(peer
))
11054 && CHECK_FLAG(bgp
->flags
,
11055 BGP_FLAG_SHOW_HOSTNAME
))
11056 snprintf(neighbor_buf
,
11057 sizeof(neighbor_buf
),
11058 "%s%s(%s) ", dn_flag
,
11059 peer
->hostname
, peer
->host
);
11061 snprintf(neighbor_buf
,
11062 sizeof(neighbor_buf
), "%s%s ",
11063 dn_flag
, peer
->host
);
11065 len
= strlen(neighbor_buf
);
11067 if (len
> max_neighbor_width
)
11068 max_neighbor_width
= len
;
11070 /* See if we have at least a single failed peer */
11071 if (bgp_has_peer_failed(peer
, afi
, safi
))
11077 /* Originally we displayed the Neighbor column as 16
11078 * characters wide so make that the default
11080 if (max_neighbor_width
< neighbor_col_default_width
)
11081 max_neighbor_width
= neighbor_col_default_width
;
11084 if (show_failed
&& !failed_count
) {
11086 json_object_int_add(json
, "failedPeersCount", 0);
11087 json_object_int_add(json
, "dynamicPeers", dn_count
);
11088 json_object_int_add(json
, "totalPeers", count
);
11090 vty_json(vty
, json
);
11092 vty_out(vty
, "%% No failed BGP neighbors found\n");
11094 return CMD_SUCCESS
;
11097 count
= 0; /* Reset the value as its used again */
11098 filtered_count
= 0;
11100 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11101 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11104 if (!peer
->afc
[afi
][safi
])
11108 unsigned long ents
;
11109 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11112 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11114 : (int64_t)bgp
->vrf_id
;
11116 /* Usage summary and header */
11118 json_object_string_addf(json
, "routerId",
11121 json_object_int_add(json
, "as", bgp
->as
);
11122 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11123 json_object_string_add(
11126 == BGP_INSTANCE_TYPE_DEFAULT
)
11131 "BGP router identifier %pI4, local AS number %s vrf-id %d",
11132 &bgp
->router_id
, bgp
->as_pretty
,
11133 bgp
->vrf_id
== VRF_UNKNOWN
11135 : (int)bgp
->vrf_id
);
11136 vty_out(vty
, "\n");
11139 if (bgp_update_delay_configured(bgp
)) {
11141 json_object_int_add(
11142 json
, "updateDelayLimit",
11143 bgp
->v_update_delay
);
11145 if (bgp
->v_update_delay
11146 != bgp
->v_establish_wait
)
11147 json_object_int_add(
11149 "updateDelayEstablishWait",
11150 bgp
->v_establish_wait
);
11152 if (bgp_update_delay_active(bgp
)) {
11153 json_object_string_add(
11155 "updateDelayFirstNeighbor",
11156 bgp
->update_delay_begin_time
);
11157 json_object_boolean_true_add(
11159 "updateDelayInProgress");
11161 if (bgp
->update_delay_over
) {
11162 json_object_string_add(
11164 "updateDelayFirstNeighbor",
11165 bgp
->update_delay_begin_time
);
11166 json_object_string_add(
11168 "updateDelayBestpathResumed",
11169 bgp
->update_delay_end_time
);
11170 json_object_string_add(
11172 "updateDelayZebraUpdateResume",
11173 bgp
->update_delay_zebra_resume_time
);
11174 json_object_string_add(
11176 "updateDelayPeerUpdateResume",
11177 bgp
->update_delay_peers_resume_time
);
11182 "Read-only mode update-delay limit: %d seconds\n",
11183 bgp
->v_update_delay
);
11184 if (bgp
->v_update_delay
11185 != bgp
->v_establish_wait
)
11187 " Establish wait: %d seconds\n",
11188 bgp
->v_establish_wait
);
11190 if (bgp_update_delay_active(bgp
)) {
11192 " First neighbor established: %s\n",
11193 bgp
->update_delay_begin_time
);
11195 " Delay in progress\n");
11197 if (bgp
->update_delay_over
) {
11199 " First neighbor established: %s\n",
11200 bgp
->update_delay_begin_time
);
11202 " Best-paths resumed: %s\n",
11203 bgp
->update_delay_end_time
);
11205 " zebra update resumed: %s\n",
11206 bgp
->update_delay_zebra_resume_time
);
11208 " peers update resumed: %s\n",
11209 bgp
->update_delay_peers_resume_time
);
11216 if (bgp_maxmed_onstartup_configured(bgp
)
11217 && bgp
->maxmed_active
)
11218 json_object_boolean_true_add(
11219 json
, "maxMedOnStartup");
11220 if (bgp
->v_maxmed_admin
)
11221 json_object_boolean_true_add(
11222 json
, "maxMedAdministrative");
11224 json_object_int_add(
11225 json
, "tableVersion",
11226 bgp_table_version(bgp
->rib
[afi
][safi
]));
11228 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11229 json_object_int_add(json
, "ribCount", ents
);
11230 json_object_int_add(
11232 ents
* sizeof(struct bgp_dest
));
11234 ents
= bgp
->af_peer_count
[afi
][safi
];
11235 json_object_int_add(json
, "peerCount", ents
);
11236 json_object_int_add(json
, "peerMemory",
11237 ents
* sizeof(struct peer
));
11239 if ((ents
= listcount(bgp
->group
))) {
11240 json_object_int_add(
11241 json
, "peerGroupCount", ents
);
11242 json_object_int_add(
11243 json
, "peerGroupMemory",
11244 ents
* sizeof(struct
11248 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11249 BGP_CONFIG_DAMPENING
))
11250 json_object_boolean_true_add(
11251 json
, "dampeningEnabled");
11254 if (bgp_maxmed_onstartup_configured(bgp
)
11255 && bgp
->maxmed_active
)
11257 "Max-med on-startup active\n");
11258 if (bgp
->v_maxmed_admin
)
11260 "Max-med administrative active\n");
11263 "BGP table version %" PRIu64
11266 bgp
->rib
[afi
][safi
]));
11268 ents
= bgp_table_count(
11269 bgp
->rib
[afi
][safi
]);
11271 "RIB entries %ld, using %s of memory\n",
11281 /* Peer related usage */
11282 ents
= bgp
->af_peer_count
[afi
][safi
];
11284 "Peers %ld, using %s of memory\n",
11294 if ((ents
= listcount(bgp
->group
)))
11296 "Peer groups %ld, using %s of memory\n",
11306 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11307 BGP_CONFIG_DAMPENING
))
11309 "Dampening enabled.\n");
11312 vty_out(vty
, "\n");
11314 /* Subtract 8 here because 'Neighbor' is
11316 vty_out(vty
, "Neighbor");
11317 vty_out(vty
, "%*s",
11318 max_neighbor_width
- 8, " ");
11320 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11325 paf
= peer_af_find(peer
, afi
, safi
);
11326 filter
= &peer
->filter
[afi
][safi
];
11329 /* Works for both failed & successful cases */
11330 if (peer_dynamic_neighbor(peer
))
11335 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11341 bgp_has_peer_failed(peer
, afi
, safi
)) {
11342 json_peer
= json_object_new_object();
11343 bgp_show_failed_summary(vty
, bgp
, peer
,
11344 json_peer
, 0, use_json
);
11345 } else if (!show_failed
) {
11346 if (show_established
11347 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11352 json_peer
= json_object_new_object();
11353 if (peer_dynamic_neighbor(peer
)) {
11354 json_object_boolean_true_add(json_peer
,
11358 if (peer
->hostname
)
11359 json_object_string_add(json_peer
, "hostname",
11362 if (peer
->domainname
)
11363 json_object_string_add(json_peer
, "domainname",
11366 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11367 json_object_int_add(
11368 json_peer
, "localAs",
11369 peer
->change_local_as
11370 ? peer
->change_local_as
11372 json_object_int_add(json_peer
, "version", 4);
11373 json_object_int_add(json_peer
, "msgRcvd",
11374 PEER_TOTAL_RX(peer
));
11375 json_object_int_add(json_peer
, "msgSent",
11376 PEER_TOTAL_TX(peer
));
11378 atomic_size_t outq_count
, inq_count
;
11379 outq_count
= atomic_load_explicit(
11380 &peer
->obuf
->count
,
11381 memory_order_relaxed
);
11382 inq_count
= atomic_load_explicit(
11383 &peer
->ibuf
->count
,
11384 memory_order_relaxed
);
11386 json_object_int_add(json_peer
, "tableVersion",
11387 peer
->version
[afi
][safi
]);
11388 json_object_int_add(json_peer
, "outq",
11390 json_object_int_add(json_peer
, "inq",
11392 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11393 use_json
, json_peer
);
11395 json_object_int_add(json_peer
, "pfxRcd",
11396 peer
->pcount
[afi
][pfx_rcd_safi
]);
11398 if (paf
&& PAF_SUBGRP(paf
))
11399 json_object_int_add(
11400 json_peer
, "pfxSnt",
11401 (PAF_SUBGRP(paf
))->scount
);
11403 json_object_int_add(json_peer
, "pfxSnt",
11406 /* BGP FSM state */
11407 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11408 || CHECK_FLAG(peer
->bgp
->flags
,
11409 BGP_FLAG_SHUTDOWN
))
11410 json_object_string_add(json_peer
,
11413 else if (peer
->afc_recv
[afi
][safi
])
11414 json_object_string_add(
11415 json_peer
, "state",
11416 lookup_msg(bgp_status_msg
,
11417 peer
->status
, NULL
));
11418 else if (CHECK_FLAG(
11420 PEER_STATUS_PREFIX_OVERFLOW
))
11421 json_object_string_add(json_peer
,
11425 json_object_string_add(
11426 json_peer
, "state",
11427 lookup_msg(bgp_status_msg
,
11428 peer
->status
, NULL
));
11430 /* BGP peer state */
11431 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11432 || CHECK_FLAG(peer
->bgp
->flags
,
11433 BGP_FLAG_SHUTDOWN
))
11434 json_object_string_add(json_peer
,
11437 else if (CHECK_FLAG(
11439 PEER_STATUS_PREFIX_OVERFLOW
))
11440 json_object_string_add(json_peer
,
11443 else if (CHECK_FLAG(peer
->flags
,
11444 PEER_FLAG_PASSIVE
))
11445 json_object_string_add(json_peer
,
11448 else if (CHECK_FLAG(peer
->sflags
,
11449 PEER_STATUS_NSF_WAIT
))
11450 json_object_string_add(json_peer
,
11453 else if (CHECK_FLAG(
11455 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11456 && (!bgp_inbound_policy_exists(peer
,
11458 || !bgp_outbound_policy_exists(
11460 json_object_string_add(json_peer
,
11464 json_object_string_add(
11465 json_peer
, "peerState", "OK");
11467 json_object_int_add(json_peer
, "connectionsEstablished",
11468 peer
->established
);
11469 json_object_int_add(json_peer
, "connectionsDropped",
11472 json_object_string_add(
11473 json_peer
, "desc", peer
->desc
);
11475 /* Avoid creating empty peer dicts in JSON */
11476 if (json_peer
== NULL
)
11480 json_object_string_add(json_peer
, "idType",
11482 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11483 json_object_string_add(json_peer
, "idType",
11485 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11486 json_object_string_add(json_peer
, "idType",
11488 json_object_object_add(json_peers
, peer
->host
,
11491 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11497 bgp_has_peer_failed(peer
, afi
, safi
)) {
11498 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11499 max_neighbor_width
,
11501 } else if (!show_failed
) {
11502 if (show_established
11503 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11508 if ((count
- filtered_count
) == 1) {
11509 /* display headline before the first
11511 vty_out(vty
, "\n");
11513 /* Subtract 8 here because 'Neighbor' is
11515 vty_out(vty
, "Neighbor");
11516 vty_out(vty
, "%*s",
11517 max_neighbor_width
- 8, " ");
11520 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11521 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11524 memset(dn_flag
, '\0', sizeof(dn_flag
));
11525 if (peer_dynamic_neighbor(peer
)) {
11530 && CHECK_FLAG(bgp
->flags
,
11531 BGP_FLAG_SHOW_HOSTNAME
))
11532 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11536 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11538 /* pad the neighbor column with spaces */
11539 if (len
< max_neighbor_width
)
11540 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11543 atomic_size_t outq_count
, inq_count
;
11544 outq_count
= atomic_load_explicit(
11545 &peer
->obuf
->count
,
11546 memory_order_relaxed
);
11547 inq_count
= atomic_load_explicit(
11548 &peer
->ibuf
->count
,
11549 memory_order_relaxed
);
11553 "4 %10u %10u %9u %9u %8" PRIu64
11556 peer
->change_local_as
11557 ? peer
->change_local_as
11559 PEER_TOTAL_RX(peer
),
11560 PEER_TOTAL_TX(peer
),
11561 peer
->version
[afi
][safi
],
11562 inq_count
, outq_count
,
11563 peer_uptime(peer
->uptime
,
11568 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11570 peer
->as
, PEER_TOTAL_RX(peer
),
11571 PEER_TOTAL_TX(peer
),
11572 peer
->version
[afi
][safi
],
11573 inq_count
, outq_count
,
11574 peer_uptime(peer
->uptime
,
11579 if (peer_established(peer
)) {
11580 if (peer
->afc_recv
[afi
][safi
]) {
11583 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11584 && !bgp_inbound_policy_exists(
11586 vty_out(vty
, " %12s",
11595 vty_out(vty
, " NoNeg");
11598 if (paf
&& PAF_SUBGRP(paf
)) {
11601 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11602 && !bgp_outbound_policy_exists(
11604 vty_out(vty
, " %8s",
11613 vty_out(vty
, " NoNeg");
11616 if (CHECK_FLAG(peer
->flags
,
11617 PEER_FLAG_SHUTDOWN
)
11618 || CHECK_FLAG(peer
->bgp
->flags
,
11619 BGP_FLAG_SHUTDOWN
))
11620 vty_out(vty
, " Idle (Admin)");
11621 else if (CHECK_FLAG(
11623 PEER_STATUS_PREFIX_OVERFLOW
))
11624 vty_out(vty
, " Idle (PfxCt)");
11626 vty_out(vty
, " %12s",
11627 lookup_msg(bgp_status_msg
,
11628 peer
->status
, NULL
));
11630 vty_out(vty
, " %8u", 0);
11632 /* Make sure `Desc` column is the lastest in
11636 vty_out(vty
, " %s",
11637 bgp_peer_description_stripped(
11639 show_wide
? 64 : 20));
11641 vty_out(vty
, " N/A");
11642 vty_out(vty
, "\n");
11649 json_object_object_add(json
, "peers", json_peers
);
11650 json_object_int_add(json
, "failedPeers", failed_count
);
11651 json_object_int_add(json
, "displayedPeers",
11652 count
- filtered_count
);
11653 json_object_int_add(json
, "totalPeers", count
);
11654 json_object_int_add(json
, "dynamicPeers", dn_count
);
11657 bgp_show_bestpath_json(bgp
, json
);
11659 vty_json(vty
, json
);
11662 if (filtered_count
== count
)
11663 vty_out(vty
, "\n%% No matching neighbor\n");
11666 vty_out(vty
, "\nDisplayed neighbors %d",
11668 else if (as_type
!= AS_UNSPECIFIED
|| as
11669 || fpeer
|| show_established
)
11670 vty_out(vty
, "\nDisplayed neighbors %d",
11671 count
- filtered_count
);
11673 vty_out(vty
, "\nTotal number of neighbors %d\n",
11677 vty_out(vty
, "No %s neighbor is configured\n",
11678 get_afi_safi_str(afi
, safi
, false));
11682 vty_out(vty
, "* - dynamic neighbor\n");
11683 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11684 dn_count
, bgp
->dynamic_neighbors_limit
);
11688 return CMD_SUCCESS
;
11691 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11692 int safi
, struct peer
*fpeer
, int as_type
,
11693 as_t as
, uint16_t show_flags
)
11696 int afi_wildcard
= (afi
== AFI_MAX
);
11697 int safi_wildcard
= (safi
== SAFI_MAX
);
11698 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11699 bool nbr_output
= false;
11700 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11702 if (use_json
&& is_wildcard
)
11703 vty_out(vty
, "{\n");
11705 afi
= 1; /* AFI_IP */
11706 while (afi
< AFI_MAX
) {
11708 safi
= 1; /* SAFI_UNICAST */
11709 while (safi
< SAFI_MAX
) {
11710 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11715 * So limit output to those afi/safi
11717 * actualy have something interesting in
11722 vty_out(vty
, ",\n");
11726 vty_out(vty
, "\"%s\":",
11727 get_afi_safi_str(afi
,
11732 "\n%s Summary (%s):\n",
11733 get_afi_safi_str(afi
,
11739 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11740 as_type
, as
, show_flags
);
11743 if (!safi_wildcard
)
11751 if (use_json
&& is_wildcard
)
11752 vty_out(vty
, "}\n");
11753 else if (!nbr_output
) {
11755 vty_out(vty
, "{}\n");
11757 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11762 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11764 const char *neighbor
,
11765 int as_type
, as_t as
,
11766 uint16_t show_flags
)
11768 struct listnode
*node
, *nnode
;
11770 struct peer
*fpeer
= NULL
;
11772 bool nbr_output
= false;
11773 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11776 vty_out(vty
, "{\n");
11778 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11782 vty_out(vty
, ",\n");
11786 vty_out(vty
, "\"%s\":",
11787 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11792 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11797 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11802 vty_out(vty
, "}\n");
11803 else if (!nbr_output
)
11804 vty_out(vty
, "%% BGP instance not found\n");
11807 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11808 safi_t safi
, const char *neighbor
, int as_type
,
11809 as_t as
, uint16_t show_flags
)
11812 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11813 struct peer
*fpeer
= NULL
;
11816 if (strmatch(name
, "all")) {
11817 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11820 return CMD_SUCCESS
;
11822 bgp
= bgp_lookup_by_name(name
);
11826 vty_out(vty
, "{}\n");
11829 "%% BGP instance not found\n");
11830 return CMD_WARNING
;
11834 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11837 return CMD_WARNING
;
11839 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11840 as_type
, as
, show_flags
);
11841 return CMD_SUCCESS
;
11845 bgp
= bgp_get_default();
11849 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11852 return CMD_WARNING
;
11854 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11858 vty_out(vty
, "{}\n");
11860 vty_out(vty
, "%% BGP instance not found\n");
11861 return CMD_WARNING
;
11864 return CMD_SUCCESS
;
11867 /* `show [ip] bgp summary' commands. */
11868 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11869 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11870 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11871 "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <ASNUM|internal|external>>] [terse] [wide] [json$uj]",
11872 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11873 BGP_SAFI_WITH_LABEL_HELP_STR
11874 "Display the entries for all address families\n"
11875 "Summary of BGP neighbor status\n"
11876 "Show only sessions in Established state\n"
11877 "Show only sessions not in Established state\n"
11878 "Show only the specified neighbor session\n"
11879 "Neighbor to display information about\n"
11880 "Neighbor to display information about\n"
11881 "Neighbor on BGP configured interface\n"
11882 "Show only the specified remote AS sessions\n" AS_STR
11883 "Internal (iBGP) AS sessions\n"
11884 "External (eBGP) AS sessions\n"
11885 "Shorten the information on BGP instances\n"
11886 "Increase table width for longer output\n" JSON_STR
)
11889 afi_t afi
= AFI_MAX
;
11890 safi_t safi
= SAFI_MAX
;
11891 as_t as
= 0; /* 0 means AS filter not set */
11892 int as_type
= AS_UNSPECIFIED
;
11893 uint16_t show_flags
= 0;
11897 /* show [ip] bgp */
11898 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11900 /* [<vrf> VIEWVRFNAME] */
11901 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11902 vrf
= argv
[idx
+ 1]->arg
;
11903 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11905 } else if (argv_find(argv
, argc
, "view", &idx
))
11906 /* [<view> VIEWVRFNAME] */
11907 vrf
= argv
[idx
+ 1]->arg
;
11908 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11909 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11910 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11913 if (argv_find(argv
, argc
, "failed", &idx
))
11914 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11916 if (argv_find(argv
, argc
, "established", &idx
))
11917 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11919 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11920 if (argv
[idx
+ 1]->arg
[0] == 'i')
11921 as_type
= AS_INTERNAL
;
11922 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11923 as_type
= AS_EXTERNAL
;
11924 else if (!asn_str2asn(argv
[idx
+ 1]->arg
, &as
)) {
11926 "%% Invalid neighbor remote-as value: %s\n",
11927 argv
[idx
+ 1]->arg
);
11928 return CMD_SUCCESS
;
11932 if (argv_find(argv
, argc
, "terse", &idx
))
11933 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11935 if (argv_find(argv
, argc
, "wide", &idx
))
11936 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11938 if (argv_find(argv
, argc
, "json", &idx
))
11939 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11941 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11945 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11948 return get_afi_safi_json_str(afi
, safi
);
11950 return get_afi_safi_vty_str(afi
, safi
);
11954 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11955 afi_t afi
, safi_t safi
,
11956 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11957 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11958 bool use_json
, json_object
*json_pref
)
11961 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11962 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11964 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11965 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11966 json_object_string_add(json_pref
, "sendMode",
11967 "advertisedAndReceived");
11968 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11969 json_object_string_add(json_pref
, "sendMode",
11971 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11972 json_object_string_add(json_pref
, "sendMode",
11975 vty_out(vty
, " Send-mode: ");
11976 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11977 vty_out(vty
, "advertised");
11978 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11979 vty_out(vty
, "%sreceived",
11980 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11984 vty_out(vty
, "\n");
11989 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11990 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11992 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11993 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11994 json_object_string_add(json_pref
, "recvMode",
11995 "advertisedAndReceived");
11996 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11997 json_object_string_add(json_pref
, "recvMode",
11999 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12000 json_object_string_add(json_pref
, "recvMode",
12003 vty_out(vty
, " Receive-mode: ");
12004 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12005 vty_out(vty
, "advertised");
12006 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12007 vty_out(vty
, "%sreceived",
12008 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12012 vty_out(vty
, "\n");
12017 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
12024 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12025 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12026 && (peer_established(p
))) {
12027 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
12028 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
12032 json_object_boolean_add(json
, "rBit", rbit
);
12033 json_object_boolean_add(json
, "nBit", nbit
);
12035 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
12036 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
12040 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12044 const char *mode
= "NotApplicable";
12047 vty_out(vty
, "\n Remote GR Mode: ");
12049 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12050 && (peer_established(peer
))) {
12052 if ((peer
->nsf_af_count
== 0)
12053 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12057 } else if (peer
->nsf_af_count
== 0
12058 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12062 } else if (peer
->nsf_af_count
!= 0
12063 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12070 json_object_string_add(json
, "remoteGrMode", mode
);
12072 vty_out(vty
, "%s\n", mode
);
12075 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12079 const char *mode
= "Invalid";
12082 vty_out(vty
, " Local GR Mode: ");
12084 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12086 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12088 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12090 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12091 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12093 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12095 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12102 json_object_string_add(json
, "localGrMode", mode
);
12104 vty_out(vty
, "%s\n", mode
);
12107 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12108 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12112 json_object
*json_afi_safi
= NULL
;
12113 json_object
*json_timer
= NULL
;
12114 json_object
*json_endofrib_status
= NULL
;
12115 bool eor_flag
= false;
12117 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12118 if (!peer
->afc
[afi
][safi
])
12121 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12122 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12126 json_afi_safi
= json_object_new_object();
12127 json_endofrib_status
= json_object_new_object();
12128 json_timer
= json_object_new_object();
12131 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12137 vty_out(vty
, " %s:\n",
12138 get_afi_safi_str(afi
, safi
, false));
12140 vty_out(vty
, " F bit: ");
12143 if (peer
->nsf
[afi
][safi
] &&
12144 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12145 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12148 json_object_boolean_true_add(json_afi_safi
,
12151 vty_out(vty
, "True\n");
12154 json_object_boolean_false_add(json_afi_safi
,
12157 vty_out(vty
, "False\n");
12161 vty_out(vty
, " End-of-RIB sent: ");
12163 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12164 PEER_STATUS_EOR_SEND
)) {
12166 json_object_boolean_true_add(
12167 json_endofrib_status
, "endOfRibSend");
12169 PRINT_EOR_JSON(eor_flag
);
12171 vty_out(vty
, "Yes\n");
12173 " End-of-RIB sent after update: ");
12175 PRINT_EOR(eor_flag
);
12179 json_object_boolean_false_add(
12180 json_endofrib_status
, "endOfRibSend");
12181 json_object_boolean_false_add(
12182 json_endofrib_status
,
12183 "endOfRibSentAfterUpdate");
12185 vty_out(vty
, "No\n");
12187 " End-of-RIB sent after update: ");
12188 vty_out(vty
, "No\n");
12193 vty_out(vty
, " End-of-RIB received: ");
12195 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12196 PEER_STATUS_EOR_RECEIVED
)) {
12198 json_object_boolean_true_add(
12199 json_endofrib_status
, "endOfRibRecv");
12201 vty_out(vty
, "Yes\n");
12204 json_object_boolean_false_add(
12205 json_endofrib_status
, "endOfRibRecv");
12207 vty_out(vty
, "No\n");
12211 json_object_int_add(json_timer
, "stalePathTimer",
12212 peer
->bgp
->stalepath_time
);
12214 if (peer
->t_gr_stale
!= NULL
) {
12215 json_object_int_add(json_timer
,
12216 "stalePathTimerRemaining",
12217 thread_timer_remain_second(
12218 peer
->t_gr_stale
));
12221 /* Display Configured Selection
12222 * Deferral only when when
12223 * Gr mode is enabled.
12225 if (CHECK_FLAG(peer
->flags
,
12226 PEER_FLAG_GRACEFUL_RESTART
)) {
12227 json_object_int_add(json_timer
,
12228 "selectionDeferralTimer",
12229 peer
->bgp
->stalepath_time
);
12232 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12235 json_object_int_add(
12237 "selectionDeferralTimerRemaining",
12238 thread_timer_remain_second(
12239 peer
->bgp
->gr_info
[afi
][safi
]
12240 .t_select_deferral
));
12243 vty_out(vty
, " Timers:\n");
12245 " Configured Stale Path Time(sec): %u\n",
12246 peer
->bgp
->stalepath_time
);
12248 if (peer
->t_gr_stale
!= NULL
)
12250 " Stale Path Remaining(sec): %ld\n",
12251 thread_timer_remain_second(
12252 peer
->t_gr_stale
));
12253 /* Display Configured Selection
12254 * Deferral only when when
12255 * Gr mode is enabled.
12257 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12259 " Configured Selection Deferral Time(sec): %u\n",
12260 peer
->bgp
->select_defer_time
);
12262 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12265 " Selection Deferral Time Remaining(sec): %ld\n",
12266 thread_timer_remain_second(
12267 peer
->bgp
->gr_info
[afi
][safi
]
12268 .t_select_deferral
));
12271 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12272 json_endofrib_status
);
12273 json_object_object_add(json_afi_safi
, "timers",
12275 json_object_object_add(
12276 json
, get_afi_safi_str(afi
, safi
, true),
12282 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12287 json_object
*json_timer
= NULL
;
12289 json_timer
= json_object_new_object();
12291 json_object_int_add(json_timer
, "configuredRestartTimer",
12292 p
->bgp
->restart_time
);
12294 json_object_int_add(json_timer
, "receivedRestartTimer",
12297 if (p
->t_gr_restart
!= NULL
)
12298 json_object_int_add(
12299 json_timer
, "restartTimerRemaining",
12300 thread_timer_remain_second(p
->t_gr_restart
));
12302 json_object_object_add(json
, "timers", json_timer
);
12305 vty_out(vty
, " Timers:\n");
12306 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12307 p
->bgp
->restart_time
);
12309 vty_out(vty
, " Received Restart Time(sec): %u\n",
12311 if (p
->t_gr_restart
!= NULL
)
12312 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12313 thread_timer_remain_second(p
->t_gr_restart
));
12314 if (p
->t_gr_restart
!= NULL
) {
12315 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12316 thread_timer_remain_second(p
->t_gr_restart
));
12321 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12324 char dn_flag
[2] = {0};
12325 /* '*' + v6 address of neighbor */
12326 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12328 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12333 json_object_string_addf(json
, "neighborAddr", "%pSU",
12336 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12339 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12343 json_object_string_add(json
, "neighborAddr",
12346 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12349 /* more gr info in new format */
12350 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12353 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12354 safi_t safi
, bool use_json
,
12355 json_object
*json_neigh
)
12357 struct bgp_filter
*filter
;
12358 struct peer_af
*paf
;
12359 char orf_pfx_name
[BUFSIZ
];
12361 json_object
*json_af
= NULL
;
12362 json_object
*json_prefA
= NULL
;
12363 json_object
*json_prefB
= NULL
;
12364 json_object
*json_addr
= NULL
;
12365 json_object
*json_advmap
= NULL
;
12368 json_addr
= json_object_new_object();
12369 json_af
= json_object_new_object();
12370 filter
= &p
->filter
[afi
][safi
];
12372 if (peer_group_active(p
))
12373 json_object_string_add(json_addr
, "peerGroupMember",
12376 paf
= peer_af_find(p
, afi
, safi
);
12377 if (paf
&& PAF_SUBGRP(paf
)) {
12378 json_object_int_add(json_addr
, "updateGroupId",
12379 PAF_UPDGRP(paf
)->id
);
12380 json_object_int_add(json_addr
, "subGroupId",
12381 PAF_SUBGRP(paf
)->id
);
12382 json_object_int_add(json_addr
, "packetQueueLength",
12383 bpacket_queue_virtual_length(paf
));
12386 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12387 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12388 PEER_CAP_ORF_PREFIX_SM_RCV
)
12389 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12390 PEER_CAP_ORF_PREFIX_RM_ADV
)
12391 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12392 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12393 json_object_int_add(json_af
, "orfType",
12395 json_prefA
= json_object_new_object();
12396 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12397 PEER_CAP_ORF_PREFIX_SM_ADV
,
12398 PEER_CAP_ORF_PREFIX_RM_ADV
,
12399 PEER_CAP_ORF_PREFIX_SM_RCV
,
12400 PEER_CAP_ORF_PREFIX_RM_RCV
,
12401 use_json
, json_prefA
);
12402 json_object_object_add(json_af
, "orfPrefixList",
12406 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12407 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12408 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12409 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12410 PEER_CAP_ORF_PREFIX_RM_ADV
)
12411 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12412 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12413 json_object_int_add(json_af
, "orfOldType",
12414 ORF_TYPE_PREFIX_OLD
);
12415 json_prefB
= json_object_new_object();
12416 bgp_show_peer_afi_orf_cap(
12417 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12418 PEER_CAP_ORF_PREFIX_RM_ADV
,
12419 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12420 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12422 json_object_object_add(json_af
, "orfOldPrefixList",
12426 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12427 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12428 PEER_CAP_ORF_PREFIX_SM_RCV
)
12429 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12430 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12431 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12432 PEER_CAP_ORF_PREFIX_RM_ADV
)
12433 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12434 PEER_CAP_ORF_PREFIX_RM_RCV
)
12435 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12436 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12437 json_object_object_add(json_addr
, "afDependentCap",
12440 json_object_free(json_af
);
12442 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12443 p
->host
, afi
, safi
);
12444 orf_pfx_count
= prefix_bgp_show_prefix_list(
12445 NULL
, afi
, orf_pfx_name
, use_json
);
12447 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12448 PEER_STATUS_ORF_PREFIX_SEND
)
12449 || orf_pfx_count
) {
12450 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12451 PEER_STATUS_ORF_PREFIX_SEND
))
12452 json_object_boolean_true_add(json_neigh
,
12455 json_object_int_add(json_addr
, "orfRecvCounter",
12458 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12459 PEER_STATUS_ORF_WAIT_REFRESH
))
12460 json_object_string_add(
12461 json_addr
, "orfFirstUpdate",
12462 "deferredUntilORFOrRouteRefreshRecvd");
12464 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12465 PEER_FLAG_REFLECTOR_CLIENT
))
12466 json_object_boolean_true_add(json_addr
,
12467 "routeReflectorClient");
12468 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12469 PEER_FLAG_RSERVER_CLIENT
))
12470 json_object_boolean_true_add(json_addr
,
12471 "routeServerClient");
12472 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12473 json_object_boolean_true_add(json_addr
,
12474 "inboundSoftConfigPermit");
12476 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12477 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12478 json_object_boolean_true_add(
12480 "privateAsNumsAllReplacedInUpdatesToNbr");
12481 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12482 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12483 json_object_boolean_true_add(
12485 "privateAsNumsReplacedInUpdatesToNbr");
12486 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12487 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12488 json_object_boolean_true_add(
12490 "privateAsNumsAllRemovedInUpdatesToNbr");
12491 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12492 PEER_FLAG_REMOVE_PRIVATE_AS
))
12493 json_object_boolean_true_add(
12495 "privateAsNumsRemovedInUpdatesToNbr");
12497 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12498 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12499 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12500 json_object_boolean_true_add(json_addr
,
12501 "allowAsInOrigin");
12503 json_object_int_add(json_addr
, "allowAsInCount",
12504 p
->allowas_in
[afi
][safi
]);
12507 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12508 json_object_boolean_true_add(
12510 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12513 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12514 json_object_string_add(json_addr
,
12515 "overrideASNsInOutboundUpdates",
12516 "ifAspathEqualRemoteAs");
12518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12519 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12520 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12521 json_object_boolean_true_add(json_addr
,
12522 "routerAlwaysNextHop");
12523 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12524 PEER_FLAG_AS_PATH_UNCHANGED
))
12525 json_object_boolean_true_add(
12526 json_addr
, "unchangedAsPathPropogatedToNbr");
12527 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12528 PEER_FLAG_NEXTHOP_UNCHANGED
))
12529 json_object_boolean_true_add(
12530 json_addr
, "unchangedNextHopPropogatedToNbr");
12531 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12532 json_object_boolean_true_add(
12533 json_addr
, "unchangedMedPropogatedToNbr");
12534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12535 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12536 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12537 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12538 PEER_FLAG_SEND_COMMUNITY
)
12539 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12540 PEER_FLAG_SEND_EXT_COMMUNITY
))
12541 json_object_string_add(json_addr
,
12542 "commAttriSentToNbr",
12543 "extendedAndStandard");
12544 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12545 PEER_FLAG_SEND_EXT_COMMUNITY
))
12546 json_object_string_add(json_addr
,
12547 "commAttriSentToNbr",
12550 json_object_string_add(json_addr
,
12551 "commAttriSentToNbr",
12554 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12555 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12556 if (p
->default_rmap
[afi
][safi
].name
)
12557 json_object_string_add(
12558 json_addr
, "defaultRouteMap",
12559 p
->default_rmap
[afi
][safi
].name
);
12561 if (paf
&& PAF_SUBGRP(paf
)
12562 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12563 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12564 json_object_boolean_true_add(json_addr
,
12567 json_object_boolean_true_add(json_addr
,
12571 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12572 if (is_evpn_enabled())
12573 json_object_boolean_true_add(
12574 json_addr
, "advertiseAllVnis");
12577 if (filter
->plist
[FILTER_IN
].name
12578 || filter
->dlist
[FILTER_IN
].name
12579 || filter
->aslist
[FILTER_IN
].name
12580 || filter
->map
[RMAP_IN
].name
)
12581 json_object_boolean_true_add(json_addr
,
12582 "inboundPathPolicyConfig");
12583 if (filter
->plist
[FILTER_OUT
].name
12584 || filter
->dlist
[FILTER_OUT
].name
12585 || filter
->aslist
[FILTER_OUT
].name
12586 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12587 json_object_boolean_true_add(
12588 json_addr
, "outboundPathPolicyConfig");
12591 if (filter
->plist
[FILTER_IN
].name
)
12592 json_object_string_add(json_addr
,
12593 "incomingUpdatePrefixFilterList",
12594 filter
->plist
[FILTER_IN
].name
);
12595 if (filter
->plist
[FILTER_OUT
].name
)
12596 json_object_string_add(json_addr
,
12597 "outgoingUpdatePrefixFilterList",
12598 filter
->plist
[FILTER_OUT
].name
);
12600 /* distribute-list */
12601 if (filter
->dlist
[FILTER_IN
].name
)
12602 json_object_string_add(
12603 json_addr
, "incomingUpdateNetworkFilterList",
12604 filter
->dlist
[FILTER_IN
].name
);
12605 if (filter
->dlist
[FILTER_OUT
].name
)
12606 json_object_string_add(
12607 json_addr
, "outgoingUpdateNetworkFilterList",
12608 filter
->dlist
[FILTER_OUT
].name
);
12611 if (filter
->aslist
[FILTER_IN
].name
)
12612 json_object_string_add(json_addr
,
12613 "incomingUpdateAsPathFilterList",
12614 filter
->aslist
[FILTER_IN
].name
);
12615 if (filter
->aslist
[FILTER_OUT
].name
)
12616 json_object_string_add(json_addr
,
12617 "outgoingUpdateAsPathFilterList",
12618 filter
->aslist
[FILTER_OUT
].name
);
12621 if (filter
->map
[RMAP_IN
].name
)
12622 json_object_string_add(
12623 json_addr
, "routeMapForIncomingAdvertisements",
12624 filter
->map
[RMAP_IN
].name
);
12625 if (filter
->map
[RMAP_OUT
].name
)
12626 json_object_string_add(
12627 json_addr
, "routeMapForOutgoingAdvertisements",
12628 filter
->map
[RMAP_OUT
].name
);
12630 /* ebgp-requires-policy (inbound) */
12631 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12632 && !bgp_inbound_policy_exists(p
, filter
))
12633 json_object_string_add(
12634 json_addr
, "inboundEbgpRequiresPolicy",
12635 "Inbound updates discarded due to missing policy");
12637 /* ebgp-requires-policy (outbound) */
12638 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12639 && (!bgp_outbound_policy_exists(p
, filter
)))
12640 json_object_string_add(
12641 json_addr
, "outboundEbgpRequiresPolicy",
12642 "Outbound updates discarded due to missing policy");
12644 /* unsuppress-map */
12645 if (filter
->usmap
.name
)
12646 json_object_string_add(json_addr
,
12647 "selectiveUnsuppressRouteMap",
12648 filter
->usmap
.name
);
12650 /* advertise-map */
12651 if (filter
->advmap
.aname
) {
12652 json_advmap
= json_object_new_object();
12653 json_object_string_add(json_advmap
, "condition",
12654 filter
->advmap
.condition
12657 json_object_string_add(json_advmap
, "conditionMap",
12658 filter
->advmap
.cname
);
12659 json_object_string_add(json_advmap
, "advertiseMap",
12660 filter
->advmap
.aname
);
12661 json_object_string_add(
12662 json_advmap
, "advertiseStatus",
12663 filter
->advmap
.update_type
==
12664 UPDATE_TYPE_ADVERTISE
12667 json_object_object_add(json_addr
, "advertiseMap",
12671 /* Receive prefix count */
12672 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12673 p
->pcount
[afi
][safi
]);
12674 if (paf
&& PAF_SUBGRP(paf
))
12675 json_object_int_add(json_addr
, "sentPrefixCounter",
12676 (PAF_SUBGRP(paf
))->scount
);
12678 /* Maximum prefix */
12679 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12680 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12681 p
->pmax_out
[afi
][safi
]);
12683 /* Maximum prefix */
12684 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12685 json_object_int_add(json_addr
, "prefixAllowedMax",
12686 p
->pmax
[afi
][safi
]);
12687 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12688 PEER_FLAG_MAX_PREFIX_WARNING
))
12689 json_object_boolean_true_add(
12690 json_addr
, "prefixAllowedMaxWarning");
12691 json_object_int_add(json_addr
,
12692 "prefixAllowedWarningThresh",
12693 p
->pmax_threshold
[afi
][safi
]);
12694 if (p
->pmax_restart
[afi
][safi
])
12695 json_object_int_add(
12697 "prefixAllowedRestartIntervalMsecs",
12698 p
->pmax_restart
[afi
][safi
] * 60000);
12700 json_object_object_add(json_neigh
,
12701 get_afi_safi_str(afi
, safi
, true),
12705 filter
= &p
->filter
[afi
][safi
];
12707 vty_out(vty
, " For address family: %s\n",
12708 get_afi_safi_str(afi
, safi
, false));
12710 if (peer_group_active(p
))
12711 vty_out(vty
, " %s peer-group member\n",
12714 paf
= peer_af_find(p
, afi
, safi
);
12715 if (paf
&& PAF_SUBGRP(paf
)) {
12716 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12717 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12718 vty_out(vty
, " Packet Queue length %d\n",
12719 bpacket_queue_virtual_length(paf
));
12721 vty_out(vty
, " Not part of any update group\n");
12723 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12724 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12725 PEER_CAP_ORF_PREFIX_SM_RCV
)
12726 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12727 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12728 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12729 PEER_CAP_ORF_PREFIX_RM_ADV
)
12730 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12731 PEER_CAP_ORF_PREFIX_RM_RCV
)
12732 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12733 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12734 vty_out(vty
, " AF-dependant capabilities:\n");
12736 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12737 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12738 PEER_CAP_ORF_PREFIX_SM_RCV
)
12739 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12740 PEER_CAP_ORF_PREFIX_RM_ADV
)
12741 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12742 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12744 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12746 bgp_show_peer_afi_orf_cap(
12747 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12748 PEER_CAP_ORF_PREFIX_RM_ADV
,
12749 PEER_CAP_ORF_PREFIX_SM_RCV
,
12750 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12752 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12753 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12754 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12755 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12756 PEER_CAP_ORF_PREFIX_RM_ADV
)
12757 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12758 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12760 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12761 ORF_TYPE_PREFIX_OLD
);
12762 bgp_show_peer_afi_orf_cap(
12763 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12764 PEER_CAP_ORF_PREFIX_RM_ADV
,
12765 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12766 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12769 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12770 p
->host
, afi
, safi
);
12771 orf_pfx_count
= prefix_bgp_show_prefix_list(
12772 NULL
, afi
, orf_pfx_name
, use_json
);
12774 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12775 PEER_STATUS_ORF_PREFIX_SEND
)
12776 || orf_pfx_count
) {
12777 vty_out(vty
, " Outbound Route Filter (ORF):");
12778 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12779 PEER_STATUS_ORF_PREFIX_SEND
))
12780 vty_out(vty
, " sent;");
12782 vty_out(vty
, " received (%d entries)",
12784 vty_out(vty
, "\n");
12786 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12787 PEER_STATUS_ORF_WAIT_REFRESH
))
12789 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12791 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12792 PEER_FLAG_REFLECTOR_CLIENT
))
12793 vty_out(vty
, " Route-Reflector Client\n");
12794 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12795 PEER_FLAG_RSERVER_CLIENT
))
12796 vty_out(vty
, " Route-Server Client\n");
12797 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12799 " Inbound soft reconfiguration allowed\n");
12801 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12802 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12804 " Private AS numbers (all) replaced in updates to this neighbor\n");
12805 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12806 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12808 " Private AS numbers replaced in updates to this neighbor\n");
12809 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12810 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12812 " Private AS numbers (all) removed in updates to this neighbor\n");
12813 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12814 PEER_FLAG_REMOVE_PRIVATE_AS
))
12816 " Private AS numbers removed in updates to this neighbor\n");
12818 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12820 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12822 " Local AS allowed as path origin\n");
12825 " Local AS allowed in path, %d occurrences\n",
12826 p
->allowas_in
[afi
][safi
]);
12829 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12830 vty_out(vty
, " %s\n",
12831 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12832 ->human_description
);
12834 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12836 " Override ASNs in outbound updates if aspath equals remote-as\n");
12838 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12839 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12840 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12841 vty_out(vty
, " NEXT_HOP is always this router\n");
12842 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12843 PEER_FLAG_AS_PATH_UNCHANGED
))
12845 " AS_PATH is propagated unchanged to this neighbor\n");
12846 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12847 PEER_FLAG_NEXTHOP_UNCHANGED
))
12849 " NEXT_HOP is propagated unchanged to this neighbor\n");
12850 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12852 " MED is propagated unchanged to this neighbor\n");
12853 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12854 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12855 PEER_FLAG_SEND_EXT_COMMUNITY
)
12856 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12857 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12859 " Community attribute sent to this neighbor");
12860 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12861 PEER_FLAG_SEND_COMMUNITY
)
12862 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12863 PEER_FLAG_SEND_EXT_COMMUNITY
)
12864 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12865 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12866 vty_out(vty
, "(all)\n");
12867 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12868 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12869 vty_out(vty
, "(large)\n");
12870 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12871 PEER_FLAG_SEND_EXT_COMMUNITY
))
12872 vty_out(vty
, "(extended)\n");
12874 vty_out(vty
, "(standard)\n");
12876 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12877 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12878 vty_out(vty
, " Default information originate,");
12880 if (p
->default_rmap
[afi
][safi
].name
)
12881 vty_out(vty
, " default route-map %s%s,",
12882 p
->default_rmap
[afi
][safi
].map
? "*"
12884 p
->default_rmap
[afi
][safi
].name
);
12885 if (paf
&& PAF_SUBGRP(paf
)
12886 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12887 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12888 vty_out(vty
, " default sent\n");
12890 vty_out(vty
, " default not sent\n");
12893 /* advertise-vni-all */
12894 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12895 if (is_evpn_enabled())
12896 vty_out(vty
, " advertise-all-vni\n");
12899 if (filter
->plist
[FILTER_IN
].name
12900 || filter
->dlist
[FILTER_IN
].name
12901 || filter
->aslist
[FILTER_IN
].name
12902 || filter
->map
[RMAP_IN
].name
)
12903 vty_out(vty
, " Inbound path policy configured\n");
12904 if (filter
->plist
[FILTER_OUT
].name
12905 || filter
->dlist
[FILTER_OUT
].name
12906 || filter
->aslist
[FILTER_OUT
].name
12907 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12908 vty_out(vty
, " Outbound path policy configured\n");
12911 if (filter
->plist
[FILTER_IN
].name
)
12913 " Incoming update prefix filter list is %s%s\n",
12914 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12915 filter
->plist
[FILTER_IN
].name
);
12916 if (filter
->plist
[FILTER_OUT
].name
)
12918 " Outgoing update prefix filter list is %s%s\n",
12919 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12920 filter
->plist
[FILTER_OUT
].name
);
12922 /* distribute-list */
12923 if (filter
->dlist
[FILTER_IN
].name
)
12925 " Incoming update network filter list is %s%s\n",
12926 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12927 filter
->dlist
[FILTER_IN
].name
);
12928 if (filter
->dlist
[FILTER_OUT
].name
)
12930 " Outgoing update network filter list is %s%s\n",
12931 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12932 filter
->dlist
[FILTER_OUT
].name
);
12935 if (filter
->aslist
[FILTER_IN
].name
)
12937 " Incoming update AS path filter list is %s%s\n",
12938 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12939 filter
->aslist
[FILTER_IN
].name
);
12940 if (filter
->aslist
[FILTER_OUT
].name
)
12942 " Outgoing update AS path filter list is %s%s\n",
12943 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12944 filter
->aslist
[FILTER_OUT
].name
);
12947 if (filter
->map
[RMAP_IN
].name
)
12949 " Route map for incoming advertisements is %s%s\n",
12950 filter
->map
[RMAP_IN
].map
? "*" : "",
12951 filter
->map
[RMAP_IN
].name
);
12952 if (filter
->map
[RMAP_OUT
].name
)
12954 " Route map for outgoing advertisements is %s%s\n",
12955 filter
->map
[RMAP_OUT
].map
? "*" : "",
12956 filter
->map
[RMAP_OUT
].name
);
12958 /* ebgp-requires-policy (inbound) */
12959 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12960 && !bgp_inbound_policy_exists(p
, filter
))
12962 " Inbound updates discarded due to missing policy\n");
12964 /* ebgp-requires-policy (outbound) */
12965 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12966 && !bgp_outbound_policy_exists(p
, filter
))
12968 " Outbound updates discarded due to missing policy\n");
12970 /* unsuppress-map */
12971 if (filter
->usmap
.name
)
12973 " Route map for selective unsuppress is %s%s\n",
12974 filter
->usmap
.map
? "*" : "",
12975 filter
->usmap
.name
);
12977 /* advertise-map */
12978 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12980 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12981 filter
->advmap
.condition
? "EXIST"
12983 filter
->advmap
.cmap
? "*" : "",
12984 filter
->advmap
.cname
,
12985 filter
->advmap
.amap
? "*" : "",
12986 filter
->advmap
.aname
,
12987 filter
->advmap
.update_type
==
12988 UPDATE_TYPE_ADVERTISE
12992 /* Receive prefix count */
12993 vty_out(vty
, " %u accepted prefixes\n",
12994 p
->pcount
[afi
][safi
]);
12996 /* maximum-prefix-out */
12997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12998 PEER_FLAG_MAX_PREFIX_OUT
))
13000 " Maximum allowed prefixes sent %u\n",
13001 p
->pmax_out
[afi
][safi
]);
13003 /* Maximum prefix */
13004 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13006 " Maximum prefixes allowed %u%s\n",
13007 p
->pmax
[afi
][safi
],
13008 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13009 PEER_FLAG_MAX_PREFIX_WARNING
)
13010 ? " (warning-only)"
13012 vty_out(vty
, " Threshold for warning message %d%%",
13013 p
->pmax_threshold
[afi
][safi
]);
13014 if (p
->pmax_restart
[afi
][safi
])
13015 vty_out(vty
, ", restart interval %d min",
13016 p
->pmax_restart
[afi
][safi
]);
13017 vty_out(vty
, "\n");
13020 vty_out(vty
, "\n");
13024 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13028 char timebuf
[BGP_UPTIME_LEN
];
13034 json_object
*json_neigh
= NULL
;
13036 uint32_t sync_tcp_mss
;
13041 json_neigh
= json_object_new_object();
13043 memset(dn_flag
, '\0', sizeof(dn_flag
));
13044 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13048 if (p
->conf_if
) /* Configured interface name. */
13049 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
13051 else /* Configured IP address. */
13052 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13057 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13058 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13060 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13061 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
13064 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13066 if (p
->change_local_as
)
13067 json_object_int_add(json_neigh
, "localAs",
13068 p
->change_local_as
);
13070 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13072 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13073 json_object_boolean_true_add(json_neigh
,
13074 "localAsNoPrepend");
13076 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13077 json_object_boolean_true_add(json_neigh
,
13078 "localAsReplaceAs");
13080 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13081 || (p
->as_type
== AS_INTERNAL
))
13082 vty_out(vty
, "remote AS %u, ", p
->as
);
13084 vty_out(vty
, "remote AS Unspecified, ");
13085 vty_out(vty
, "local AS %u%s%s, ",
13086 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13087 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13090 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13094 /* peer type internal or confed-internal */
13095 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13097 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13098 json_object_boolean_true_add(
13099 json_neigh
, "nbrConfedInternalLink");
13101 json_object_boolean_true_add(json_neigh
,
13102 "nbrInternalLink");
13104 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13105 vty_out(vty
, "confed-internal link\n");
13107 vty_out(vty
, "internal link\n");
13109 /* peer type external or confed-external */
13110 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13112 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13113 json_object_boolean_true_add(
13114 json_neigh
, "nbrConfedExternalLink");
13116 json_object_boolean_true_add(json_neigh
,
13117 "nbrExternalLink");
13119 if (bgp_confederation_peers_check(bgp
, p
->as
))
13120 vty_out(vty
, "confed-external link\n");
13122 vty_out(vty
, "external link\n");
13126 json_object_boolean_true_add(json_neigh
,
13127 "nbrUnspecifiedLink");
13129 vty_out(vty
, "unspecified link\n");
13134 json_object_string_add(json_neigh
, "localRole",
13135 bgp_get_name_by_role(p
->local_role
));
13136 json_object_string_add(json_neigh
, "remoteRole",
13137 bgp_get_name_by_role(p
->remote_role
));
13139 vty_out(vty
, " Local Role: %s\n",
13140 bgp_get_name_by_role(p
->local_role
));
13141 vty_out(vty
, " Remote Role: %s\n",
13142 bgp_get_name_by_role(p
->remote_role
));
13149 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13151 vty_out(vty
, " Description: %s\n", p
->desc
);
13156 json_object_string_add(json_neigh
, "hostname",
13160 json_object_string_add(json_neigh
, "domainname",
13163 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13164 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13167 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13171 json_object_string_add(json_neigh
, "hostname",
13178 json_object_string_add(json_neigh
, "peerGroup",
13182 struct prefix prefix
, *range
= NULL
;
13184 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13185 range
= peer_group_lookup_dynamic_neighbor_range(
13186 p
->group
, &prefix
);
13189 json_object_string_addf(
13191 "peerSubnetRangeGroup", "%pFX",
13197 " Member of peer-group %s for session parameters\n",
13201 struct prefix prefix
, *range
= NULL
;
13203 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13204 range
= peer_group_lookup_dynamic_neighbor_range(
13205 p
->group
, &prefix
);
13209 " Belongs to the subnet range group: %pFX\n",
13217 /* Administrative shutdown. */
13218 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13219 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13220 json_object_boolean_true_add(json_neigh
,
13224 json_object_int_add(json_neigh
, "bgpVersion", 4);
13225 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13227 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13230 /* Confederation */
13231 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13232 && bgp_confederation_peers_check(bgp
, p
->as
))
13233 json_object_boolean_true_add(json_neigh
,
13237 json_object_string_add(
13238 json_neigh
, "bgpState",
13239 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13241 if (peer_established(p
)) {
13244 uptime
= monotime(NULL
);
13245 uptime
-= p
->uptime
;
13246 epoch_tbuf
= time(NULL
) - uptime
;
13248 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13250 json_object_string_add(json_neigh
, "bgpTimerUpString",
13251 peer_uptime(p
->uptime
, timebuf
,
13254 json_object_int_add(json_neigh
,
13255 "bgpTimerUpEstablishedEpoch",
13259 else if (p
->status
== Active
) {
13260 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13261 json_object_string_add(json_neigh
, "bgpStateIs",
13263 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13264 json_object_string_add(json_neigh
, "bgpStateIs",
13272 uptime
= monotime(NULL
);
13273 uptime
-= p
->readtime
;
13274 gmtime_r(&uptime
, &tm
);
13276 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13277 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13278 + (tm
.tm_hour
* 3600000));
13280 uptime
= monotime(NULL
);
13281 uptime
-= p
->last_write
;
13282 gmtime_r(&uptime
, &tm
);
13284 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13285 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13286 + (tm
.tm_hour
* 3600000));
13288 uptime
= monotime(NULL
);
13289 uptime
-= p
->update_time
;
13290 gmtime_r(&uptime
, &tm
);
13292 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13293 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13294 + (tm
.tm_hour
* 3600000));
13296 /* Configured timer values. */
13297 json_object_int_add(json_neigh
,
13298 "bgpTimerConfiguredHoldTimeMsecs",
13299 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13300 ? p
->holdtime
* 1000
13301 : bgp
->default_holdtime
* 1000);
13302 json_object_int_add(json_neigh
,
13303 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13304 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13305 ? p
->keepalive
* 1000
13306 : bgp
->default_keepalive
* 1000);
13307 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13308 p
->v_holdtime
* 1000);
13309 json_object_int_add(json_neigh
,
13310 "bgpTimerKeepAliveIntervalMsecs",
13311 p
->v_keepalive
* 1000);
13312 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13313 json_object_int_add(json_neigh
,
13314 "bgpTimerDelayOpenTimeMsecs",
13315 p
->v_delayopen
* 1000);
13318 /* Configured and Synced tcp-mss value for peer */
13319 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13320 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13321 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13323 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13327 /* Extended Optional Parameters Length for BGP OPEN Message */
13328 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13329 json_object_boolean_true_add(
13330 json_neigh
, "extendedOptionalParametersLength");
13332 json_object_boolean_false_add(
13333 json_neigh
, "extendedOptionalParametersLength");
13335 /* Conditional advertisements */
13336 json_object_int_add(
13338 "bgpTimerConfiguredConditionalAdvertisementsSec",
13339 bgp
->condition_check_period
);
13340 if (thread_is_scheduled(bgp
->t_condition_check
))
13341 json_object_int_add(
13343 "bgpTimerUntilConditionalAdvertisementsSec",
13344 thread_timer_remain_second(
13345 bgp
->t_condition_check
));
13347 /* Administrative shutdown. */
13348 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13349 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13350 vty_out(vty
, " Administratively shut down\n");
13353 vty_out(vty
, " BGP version 4");
13354 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13355 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13357 /* Confederation */
13358 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13359 && bgp_confederation_peers_check(bgp
, p
->as
))
13361 " Neighbor under common administration\n");
13364 vty_out(vty
, " BGP state = %s",
13365 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13367 if (peer_established(p
))
13368 vty_out(vty
, ", up for %8s",
13369 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13372 else if (p
->status
== Active
) {
13373 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13374 vty_out(vty
, " (passive)");
13375 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13376 vty_out(vty
, " (NSF passive)");
13378 vty_out(vty
, "\n");
13381 vty_out(vty
, " Last read %s",
13382 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13384 vty_out(vty
, ", Last write %s\n",
13385 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13388 /* Configured timer values. */
13390 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13391 p
->v_holdtime
, p
->v_keepalive
);
13392 vty_out(vty
, " Configured hold time is %d seconds",
13393 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13395 : bgp
->default_holdtime
);
13396 vty_out(vty
, ", keepalive interval is %d seconds\n",
13397 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13399 : bgp
->default_keepalive
);
13400 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13402 " Configured DelayOpenTime is %d seconds\n",
13405 /* Configured and synced tcp-mss value for peer */
13406 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13407 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13408 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13409 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13412 /* Extended Optional Parameters Length for BGP OPEN Message */
13413 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13415 " Extended Optional Parameters Length is enabled\n");
13417 /* Conditional advertisements */
13419 " Configured conditional advertisements interval is %d seconds\n",
13420 bgp
->condition_check_period
);
13421 if (thread_is_scheduled(bgp
->t_condition_check
))
13423 " Time until conditional advertisements begin is %lu seconds\n",
13424 thread_timer_remain_second(
13425 bgp
->t_condition_check
));
13428 if (peer_established(p
) &&
13429 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13431 json_object
*json_cap
= NULL
;
13433 json_cap
= json_object_new_object();
13436 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13437 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13438 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13439 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13440 json_object_string_add(
13441 json_cap
, "4byteAs",
13442 "advertisedAndReceived");
13443 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13444 json_object_string_add(json_cap
,
13447 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13448 json_object_string_add(json_cap
,
13453 /* Extended Message Support */
13454 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13455 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13456 json_object_string_add(json_cap
,
13458 "advertisedAndReceived");
13459 else if (CHECK_FLAG(p
->cap
,
13460 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13461 json_object_string_add(json_cap
,
13464 else if (CHECK_FLAG(p
->cap
,
13465 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13466 json_object_string_add(json_cap
,
13471 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13472 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13473 json_object
*json_add
= NULL
;
13474 const char *print_store
;
13476 json_add
= json_object_new_object();
13478 FOREACH_AFI_SAFI (afi
, safi
) {
13479 json_object
*json_sub
= NULL
;
13480 json_sub
= json_object_new_object();
13481 print_store
= get_afi_safi_str(
13485 p
->af_cap
[afi
][safi
],
13486 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13488 p
->af_cap
[afi
][safi
],
13489 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13493 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13497 PEER_CAP_ADDPATH_AF_TX_RCV
))
13498 json_object_boolean_true_add(
13500 "txAdvertisedAndReceived");
13505 PEER_CAP_ADDPATH_AF_TX_ADV
))
13506 json_object_boolean_true_add(
13513 PEER_CAP_ADDPATH_AF_TX_RCV
))
13514 json_object_boolean_true_add(
13520 p
->af_cap
[afi
][safi
],
13521 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13523 p
->af_cap
[afi
][safi
],
13524 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13528 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13532 PEER_CAP_ADDPATH_AF_RX_RCV
))
13533 json_object_boolean_true_add(
13535 "rxAdvertisedAndReceived");
13540 PEER_CAP_ADDPATH_AF_RX_ADV
))
13541 json_object_boolean_true_add(
13548 PEER_CAP_ADDPATH_AF_RX_RCV
))
13549 json_object_boolean_true_add(
13555 p
->af_cap
[afi
][safi
],
13556 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13558 p
->af_cap
[afi
][safi
],
13559 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13561 p
->af_cap
[afi
][safi
],
13562 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13564 p
->af_cap
[afi
][safi
],
13565 PEER_CAP_ADDPATH_AF_RX_RCV
))
13566 json_object_object_add(
13567 json_add
, print_store
,
13570 json_object_free(json_sub
);
13573 json_object_object_add(json_cap
, "addPath",
13578 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13579 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13580 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13581 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13582 json_object_string_add(
13583 json_cap
, "dynamic",
13584 "advertisedAndReceived");
13585 else if (CHECK_FLAG(p
->cap
,
13586 PEER_CAP_DYNAMIC_ADV
))
13587 json_object_string_add(json_cap
,
13590 else if (CHECK_FLAG(p
->cap
,
13591 PEER_CAP_DYNAMIC_RCV
))
13592 json_object_string_add(json_cap
,
13598 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13599 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13600 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13601 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13602 json_object_string_add(
13604 "advertisedAndReceived");
13605 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13606 json_object_string_add(json_cap
, "role",
13608 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13609 json_object_string_add(json_cap
, "role",
13613 /* Extended nexthop */
13614 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13615 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13616 json_object
*json_nxt
= NULL
;
13617 const char *print_store
;
13620 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13621 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13622 json_object_string_add(
13623 json_cap
, "extendedNexthop",
13624 "advertisedAndReceived");
13625 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13626 json_object_string_add(
13627 json_cap
, "extendedNexthop",
13629 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13630 json_object_string_add(
13631 json_cap
, "extendedNexthop",
13634 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13635 json_nxt
= json_object_new_object();
13637 for (safi
= SAFI_UNICAST
;
13638 safi
< SAFI_MAX
; safi
++) {
13642 PEER_CAP_ENHE_AF_RCV
)) {
13648 json_object_string_add(
13651 "recieved"); /* misspelled for compatibility */
13654 json_object_object_add(
13656 "extendedNexthopFamililesByPeer",
13661 /* Long-lived Graceful Restart */
13662 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13663 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13664 json_object
*json_llgr
= NULL
;
13665 const char *afi_safi_str
;
13667 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13668 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13669 json_object_string_add(
13671 "longLivedGracefulRestart",
13672 "advertisedAndReceived");
13673 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13674 json_object_string_add(
13676 "longLivedGracefulRestart",
13678 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13679 json_object_string_add(
13681 "longLivedGracefulRestart",
13684 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13685 json_llgr
= json_object_new_object();
13687 FOREACH_AFI_SAFI (afi
, safi
) {
13691 PEER_CAP_ENHE_AF_RCV
)) {
13697 json_object_string_add(
13703 json_object_object_add(
13705 "longLivedGracefulRestartByPeer",
13710 /* Route Refresh */
13711 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13712 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13713 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13714 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13715 (CHECK_FLAG(p
->cap
,
13716 PEER_CAP_REFRESH_NEW_RCV
) ||
13718 PEER_CAP_REFRESH_OLD_RCV
))) {
13721 PEER_CAP_REFRESH_OLD_RCV
) &&
13724 PEER_CAP_REFRESH_NEW_RCV
))
13725 json_object_string_add(
13728 "advertisedAndReceivedOldNew");
13732 PEER_CAP_REFRESH_OLD_RCV
))
13733 json_object_string_add(
13736 "advertisedAndReceivedOld");
13738 json_object_string_add(
13741 "advertisedAndReceivedNew");
13743 } else if (CHECK_FLAG(p
->cap
,
13744 PEER_CAP_REFRESH_ADV
))
13745 json_object_string_add(json_cap
,
13748 else if (CHECK_FLAG(p
->cap
,
13749 PEER_CAP_REFRESH_NEW_RCV
) ||
13751 PEER_CAP_REFRESH_OLD_RCV
))
13752 json_object_string_add(json_cap
,
13757 /* Enhanced Route Refresh */
13758 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13759 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13760 if (CHECK_FLAG(p
->cap
,
13761 PEER_CAP_ENHANCED_RR_ADV
) &&
13763 PEER_CAP_ENHANCED_RR_RCV
))
13764 json_object_string_add(
13766 "enhancedRouteRefresh",
13767 "advertisedAndReceived");
13768 else if (CHECK_FLAG(p
->cap
,
13769 PEER_CAP_ENHANCED_RR_ADV
))
13770 json_object_string_add(
13772 "enhancedRouteRefresh",
13774 else if (CHECK_FLAG(p
->cap
,
13775 PEER_CAP_ENHANCED_RR_RCV
))
13776 json_object_string_add(
13778 "enhancedRouteRefresh",
13782 /* Multiprotocol Extensions */
13783 json_object
*json_multi
= NULL
;
13785 json_multi
= json_object_new_object();
13787 FOREACH_AFI_SAFI (afi
, safi
) {
13788 if (p
->afc_adv
[afi
][safi
] ||
13789 p
->afc_recv
[afi
][safi
]) {
13790 json_object
*json_exten
= NULL
;
13791 json_exten
= json_object_new_object();
13793 if (p
->afc_adv
[afi
][safi
] &&
13794 p
->afc_recv
[afi
][safi
])
13795 json_object_boolean_true_add(
13797 "advertisedAndReceived");
13798 else if (p
->afc_adv
[afi
][safi
])
13799 json_object_boolean_true_add(
13802 else if (p
->afc_recv
[afi
][safi
])
13803 json_object_boolean_true_add(
13804 json_exten
, "received");
13806 json_object_object_add(
13808 get_afi_safi_str(afi
, safi
,
13813 json_object_object_add(json_cap
,
13814 "multiprotocolExtensions",
13817 /* Hostname capabilities */
13818 json_object
*json_hname
= NULL
;
13820 json_hname
= json_object_new_object();
13822 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13823 json_object_string_add(
13824 json_hname
, "advHostName",
13825 bgp
->peer_self
->hostname
13826 ? bgp
->peer_self
->hostname
13828 json_object_string_add(
13829 json_hname
, "advDomainName",
13830 bgp
->peer_self
->domainname
13831 ? bgp
->peer_self
->domainname
13836 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13837 json_object_string_add(
13838 json_hname
, "rcvHostName",
13839 p
->hostname
? p
->hostname
: "n/a");
13840 json_object_string_add(
13841 json_hname
, "rcvDomainName",
13842 p
->domainname
? p
->domainname
: "n/a");
13845 json_object_object_add(json_cap
, "hostName",
13848 /* Graceful Restart */
13849 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13850 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13851 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13852 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13853 json_object_string_add(
13854 json_cap
, "gracefulRestart",
13855 "advertisedAndReceived");
13856 else if (CHECK_FLAG(p
->cap
,
13857 PEER_CAP_RESTART_ADV
))
13858 json_object_string_add(
13860 "gracefulRestartCapability",
13862 else if (CHECK_FLAG(p
->cap
,
13863 PEER_CAP_RESTART_RCV
))
13864 json_object_string_add(
13866 "gracefulRestartCapability",
13869 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13870 int restart_af_count
= 0;
13871 json_object
*json_restart
= NULL
;
13872 json_restart
= json_object_new_object();
13874 json_object_int_add(
13876 "gracefulRestartRemoteTimerMsecs",
13877 p
->v_gr_restart
* 1000);
13879 FOREACH_AFI_SAFI (afi
, safi
) {
13883 PEER_CAP_RESTART_AF_RCV
)) {
13884 json_object
*json_sub
=
13887 json_object_new_object();
13893 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13894 json_object_boolean_true_add(
13897 restart_af_count
++;
13898 json_object_object_add(
13907 if (!restart_af_count
) {
13908 json_object_string_add(
13910 "addressFamiliesByPeer",
13912 json_object_free(json_restart
);
13914 json_object_object_add(
13916 "addressFamiliesByPeer",
13920 json_object_object_add(
13921 json_neigh
, "neighborCapabilities", json_cap
);
13923 vty_out(vty
, " Neighbor capabilities:\n");
13926 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13927 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13928 vty_out(vty
, " 4 Byte AS:");
13929 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13930 vty_out(vty
, " advertised");
13931 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13932 vty_out(vty
, " %sreceived",
13937 vty_out(vty
, "\n");
13940 /* Extended Message Support */
13941 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13942 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13943 vty_out(vty
, " Extended Message:");
13944 if (CHECK_FLAG(p
->cap
,
13945 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13946 vty_out(vty
, " advertised");
13947 if (CHECK_FLAG(p
->cap
,
13948 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13949 vty_out(vty
, " %sreceived",
13952 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13955 vty_out(vty
, "\n");
13959 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13960 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13961 vty_out(vty
, " AddPath:\n");
13963 FOREACH_AFI_SAFI (afi
, safi
) {
13965 p
->af_cap
[afi
][safi
],
13966 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13968 p
->af_cap
[afi
][safi
],
13969 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13970 vty_out(vty
, " %s: TX ",
13978 PEER_CAP_ADDPATH_AF_TX_ADV
))
13985 PEER_CAP_ADDPATH_AF_TX_RCV
))
13992 PEER_CAP_ADDPATH_AF_TX_ADV
)
13996 vty_out(vty
, "\n");
14000 p
->af_cap
[afi
][safi
],
14001 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
14003 p
->af_cap
[afi
][safi
],
14004 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14005 vty_out(vty
, " %s: RX ",
14013 PEER_CAP_ADDPATH_AF_RX_ADV
))
14020 PEER_CAP_ADDPATH_AF_RX_RCV
))
14027 PEER_CAP_ADDPATH_AF_RX_ADV
)
14031 vty_out(vty
, "\n");
14037 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
14038 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
14039 vty_out(vty
, " Dynamic:");
14040 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
14041 vty_out(vty
, " advertised");
14042 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
14043 vty_out(vty
, " %sreceived",
14045 PEER_CAP_DYNAMIC_ADV
)
14048 vty_out(vty
, "\n");
14052 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
14053 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
14054 vty_out(vty
, " Role:");
14055 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
14056 vty_out(vty
, " advertised");
14057 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
14058 vty_out(vty
, " %sreceived",
14063 vty_out(vty
, "\n");
14066 /* Extended nexthop */
14067 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14068 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14069 vty_out(vty
, " Extended nexthop:");
14070 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14071 vty_out(vty
, " advertised");
14072 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14073 vty_out(vty
, " %sreceived",
14078 vty_out(vty
, "\n");
14080 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14082 " Address families by peer:\n ");
14083 for (safi
= SAFI_UNICAST
;
14084 safi
< SAFI_MAX
; safi
++)
14088 PEER_CAP_ENHE_AF_RCV
))
14098 /* Long-lived Graceful Restart */
14099 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14100 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14102 " Long-lived Graceful Restart:");
14103 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14104 vty_out(vty
, " advertised");
14105 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14106 vty_out(vty
, " %sreceived",
14111 vty_out(vty
, "\n");
14113 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14115 " Address families by peer:\n");
14116 FOREACH_AFI_SAFI (afi
, safi
)
14120 PEER_CAP_LLGR_AF_RCV
))
14130 /* Route Refresh */
14131 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14132 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14133 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14134 vty_out(vty
, " Route refresh:");
14135 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14136 vty_out(vty
, " advertised");
14137 if (CHECK_FLAG(p
->cap
,
14138 PEER_CAP_REFRESH_NEW_RCV
) ||
14140 PEER_CAP_REFRESH_OLD_RCV
))
14141 vty_out(vty
, " %sreceived(%s)",
14143 PEER_CAP_REFRESH_ADV
)
14148 PEER_CAP_REFRESH_OLD_RCV
) &&
14151 PEER_CAP_REFRESH_NEW_RCV
))
14155 PEER_CAP_REFRESH_OLD_RCV
)
14159 vty_out(vty
, "\n");
14162 /* Enhanced Route Refresh */
14163 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14164 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14165 vty_out(vty
, " Enhanced Route Refresh:");
14166 if (CHECK_FLAG(p
->cap
,
14167 PEER_CAP_ENHANCED_RR_ADV
))
14168 vty_out(vty
, " advertised");
14169 if (CHECK_FLAG(p
->cap
,
14170 PEER_CAP_ENHANCED_RR_RCV
))
14171 vty_out(vty
, " %sreceived",
14173 PEER_CAP_REFRESH_ADV
)
14176 vty_out(vty
, "\n");
14179 /* Multiprotocol Extensions */
14180 FOREACH_AFI_SAFI (afi
, safi
)
14181 if (p
->afc_adv
[afi
][safi
] ||
14182 p
->afc_recv
[afi
][safi
]) {
14183 vty_out(vty
, " Address Family %s:",
14184 get_afi_safi_str(afi
, safi
,
14186 if (p
->afc_adv
[afi
][safi
])
14187 vty_out(vty
, " advertised");
14188 if (p
->afc_recv
[afi
][safi
])
14189 vty_out(vty
, " %sreceived",
14190 p
->afc_adv
[afi
][safi
]
14193 vty_out(vty
, "\n");
14196 /* Hostname capability */
14197 vty_out(vty
, " Hostname Capability:");
14199 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14201 " advertised (name: %s,domain name: %s)",
14202 bgp
->peer_self
->hostname
14203 ? bgp
->peer_self
->hostname
14205 bgp
->peer_self
->domainname
14206 ? bgp
->peer_self
->domainname
14209 vty_out(vty
, " not advertised");
14212 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14214 " received (name: %s,domain name: %s)",
14215 p
->hostname
? p
->hostname
: "n/a",
14216 p
->domainname
? p
->domainname
: "n/a");
14218 vty_out(vty
, " not received");
14221 vty_out(vty
, "\n");
14223 /* Graceful Restart */
14224 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14225 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14227 " Graceful Restart Capability:");
14228 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14229 vty_out(vty
, " advertised");
14230 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14231 vty_out(vty
, " %sreceived",
14233 PEER_CAP_RESTART_ADV
)
14236 vty_out(vty
, "\n");
14238 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14239 int restart_af_count
= 0;
14242 " Remote Restart timer is %d seconds\n",
14245 " Address families by peer:\n ");
14247 FOREACH_AFI_SAFI (afi
, safi
)
14251 PEER_CAP_RESTART_AF_RCV
)) {
14252 vty_out(vty
, "%s%s(%s)",
14264 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14266 : "not preserved");
14267 restart_af_count
++;
14269 if (!restart_af_count
)
14270 vty_out(vty
, "none");
14271 vty_out(vty
, "\n");
14273 } /* Graceful Restart */
14277 /* graceful restart information */
14278 json_object
*json_grace
= NULL
;
14279 json_object
*json_grace_send
= NULL
;
14280 json_object
*json_grace_recv
= NULL
;
14281 int eor_send_af_count
= 0;
14282 int eor_receive_af_count
= 0;
14285 json_grace
= json_object_new_object();
14286 json_grace_send
= json_object_new_object();
14287 json_grace_recv
= json_object_new_object();
14289 if ((peer_established(p
)) &&
14290 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14291 FOREACH_AFI_SAFI (afi
, safi
) {
14292 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14293 PEER_STATUS_EOR_SEND
)) {
14294 json_object_boolean_true_add(
14296 get_afi_safi_str(afi
, safi
,
14298 eor_send_af_count
++;
14301 FOREACH_AFI_SAFI (afi
, safi
) {
14302 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14303 PEER_STATUS_EOR_RECEIVED
)) {
14304 json_object_boolean_true_add(
14306 get_afi_safi_str(afi
, safi
,
14308 eor_receive_af_count
++;
14312 json_object_object_add(json_grace
, "endOfRibSend",
14314 json_object_object_add(json_grace
, "endOfRibRecv",
14318 if (p
->t_gr_restart
)
14319 json_object_int_add(
14320 json_grace
, "gracefulRestartTimerMsecs",
14321 thread_timer_remain_second(p
->t_gr_restart
) *
14325 json_object_int_add(
14326 json_grace
, "gracefulStalepathTimerMsecs",
14327 thread_timer_remain_second(p
->t_gr_stale
) *
14329 /* more gr info in new format */
14330 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14331 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14334 vty_out(vty
, " Graceful restart information:\n");
14335 if ((peer_established(p
)) &&
14336 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14338 vty_out(vty
, " End-of-RIB send: ");
14339 FOREACH_AFI_SAFI (afi
, safi
) {
14340 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14341 PEER_STATUS_EOR_SEND
)) {
14342 vty_out(vty
, "%s%s",
14343 eor_send_af_count
? ", " : "",
14344 get_afi_safi_str(afi
, safi
,
14346 eor_send_af_count
++;
14349 vty_out(vty
, "\n");
14350 vty_out(vty
, " End-of-RIB received: ");
14351 FOREACH_AFI_SAFI (afi
, safi
) {
14352 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14353 PEER_STATUS_EOR_RECEIVED
)) {
14354 vty_out(vty
, "%s%s",
14355 eor_receive_af_count
? ", "
14357 get_afi_safi_str(afi
, safi
,
14359 eor_receive_af_count
++;
14362 vty_out(vty
, "\n");
14365 if (p
->t_gr_restart
)
14367 " The remaining time of restart timer is %ld\n",
14368 thread_timer_remain_second(p
->t_gr_restart
));
14372 " The remaining time of stalepath timer is %ld\n",
14373 thread_timer_remain_second(p
->t_gr_stale
));
14375 /* more gr info in new format */
14376 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14380 json_object
*json_stat
= NULL
;
14381 json_stat
= json_object_new_object();
14382 /* Packet counts. */
14384 atomic_size_t outq_count
, inq_count
;
14385 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14386 memory_order_relaxed
);
14387 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14388 memory_order_relaxed
);
14390 json_object_int_add(json_stat
, "depthInq",
14391 (unsigned long)inq_count
);
14392 json_object_int_add(json_stat
, "depthOutq",
14393 (unsigned long)outq_count
);
14394 json_object_int_add(json_stat
, "opensSent",
14395 atomic_load_explicit(&p
->open_out
,
14396 memory_order_relaxed
));
14397 json_object_int_add(json_stat
, "opensRecv",
14398 atomic_load_explicit(&p
->open_in
,
14399 memory_order_relaxed
));
14400 json_object_int_add(json_stat
, "notificationsSent",
14401 atomic_load_explicit(&p
->notify_out
,
14402 memory_order_relaxed
));
14403 json_object_int_add(json_stat
, "notificationsRecv",
14404 atomic_load_explicit(&p
->notify_in
,
14405 memory_order_relaxed
));
14406 json_object_int_add(json_stat
, "updatesSent",
14407 atomic_load_explicit(&p
->update_out
,
14408 memory_order_relaxed
));
14409 json_object_int_add(json_stat
, "updatesRecv",
14410 atomic_load_explicit(&p
->update_in
,
14411 memory_order_relaxed
));
14412 json_object_int_add(json_stat
, "keepalivesSent",
14413 atomic_load_explicit(&p
->keepalive_out
,
14414 memory_order_relaxed
));
14415 json_object_int_add(json_stat
, "keepalivesRecv",
14416 atomic_load_explicit(&p
->keepalive_in
,
14417 memory_order_relaxed
));
14418 json_object_int_add(json_stat
, "routeRefreshSent",
14419 atomic_load_explicit(&p
->refresh_out
,
14420 memory_order_relaxed
));
14421 json_object_int_add(json_stat
, "routeRefreshRecv",
14422 atomic_load_explicit(&p
->refresh_in
,
14423 memory_order_relaxed
));
14424 json_object_int_add(json_stat
, "capabilitySent",
14425 atomic_load_explicit(&p
->dynamic_cap_out
,
14426 memory_order_relaxed
));
14427 json_object_int_add(json_stat
, "capabilityRecv",
14428 atomic_load_explicit(&p
->dynamic_cap_in
,
14429 memory_order_relaxed
));
14430 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14431 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14432 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14434 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14435 notify_out
, notify_in
, update_out
, update_in
,
14436 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14437 dynamic_cap_out
, dynamic_cap_in
;
14438 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14439 memory_order_relaxed
);
14440 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14441 memory_order_relaxed
);
14442 open_out
= atomic_load_explicit(&p
->open_out
,
14443 memory_order_relaxed
);
14445 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14446 notify_out
= atomic_load_explicit(&p
->notify_out
,
14447 memory_order_relaxed
);
14448 notify_in
= atomic_load_explicit(&p
->notify_in
,
14449 memory_order_relaxed
);
14450 update_out
= atomic_load_explicit(&p
->update_out
,
14451 memory_order_relaxed
);
14452 update_in
= atomic_load_explicit(&p
->update_in
,
14453 memory_order_relaxed
);
14454 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14455 memory_order_relaxed
);
14456 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14457 memory_order_relaxed
);
14458 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14459 memory_order_relaxed
);
14460 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14461 memory_order_relaxed
);
14462 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14463 memory_order_relaxed
);
14464 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14465 memory_order_relaxed
);
14467 /* Packet counts. */
14468 vty_out(vty
, " Message statistics:\n");
14469 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14470 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14471 vty_out(vty
, " Sent Rcvd\n");
14472 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14474 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14476 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14478 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14480 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14482 vty_out(vty
, " Capability: %10zu %10zu\n",
14483 dynamic_cap_out
, dynamic_cap_in
);
14484 vty_out(vty
, " Total: %10u %10u\n",
14485 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14489 /* advertisement-interval */
14490 json_object_int_add(json_neigh
,
14491 "minBtwnAdvertisementRunsTimerMsecs",
14492 p
->v_routeadv
* 1000);
14494 /* Update-source. */
14495 if (p
->update_if
|| p
->update_source
) {
14497 json_object_string_add(json_neigh
,
14500 else if (p
->update_source
)
14501 json_object_string_addf(json_neigh
,
14502 "updateSource", "%pSU",
14506 /* advertisement-interval */
14508 " Minimum time between advertisement runs is %d seconds\n",
14511 /* Update-source. */
14512 if (p
->update_if
|| p
->update_source
) {
14513 vty_out(vty
, " Update source is ");
14515 vty_out(vty
, "%s", p
->update_if
);
14516 else if (p
->update_source
)
14517 vty_out(vty
, "%pSU", p
->update_source
);
14518 vty_out(vty
, "\n");
14521 vty_out(vty
, "\n");
14524 /* Address Family Information */
14525 json_object
*json_hold
= NULL
;
14528 json_hold
= json_object_new_object();
14530 FOREACH_AFI_SAFI (afi
, safi
)
14531 if (p
->afc
[afi
][safi
])
14532 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14536 json_object_object_add(json_neigh
, "addressFamilyInfo",
14538 json_object_int_add(json_neigh
, "connectionsEstablished",
14540 json_object_int_add(json_neigh
, "connectionsDropped",
14543 vty_out(vty
, " Connections established %d; dropped %d\n",
14544 p
->established
, p
->dropped
);
14546 if (!p
->last_reset
) {
14548 json_object_string_add(json_neigh
, "lastReset",
14551 vty_out(vty
, " Last reset never\n");
14557 uptime
= monotime(NULL
);
14558 uptime
-= p
->resettime
;
14559 gmtime_r(&uptime
, &tm
);
14561 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14563 + (tm
.tm_min
* 60000)
14564 + (tm
.tm_hour
* 3600000));
14565 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14567 vty_out(vty
, " Last reset %s, ",
14568 peer_uptime(p
->resettime
, timebuf
,
14569 BGP_UPTIME_LEN
, 0, NULL
));
14571 bgp_show_peer_reset(vty
, p
, NULL
, false);
14572 if (p
->last_reset_cause_size
) {
14573 msg
= p
->last_reset_cause
;
14575 " Message received that caused BGP to send a NOTIFICATION:\n ");
14576 for (i
= 1; i
<= p
->last_reset_cause_size
;
14578 vty_out(vty
, "%02X", *msg
++);
14580 if (i
!= p
->last_reset_cause_size
) {
14582 vty_out(vty
, "\n ");
14583 } else if (i
% 4 == 0) {
14588 vty_out(vty
, "\n");
14593 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14595 json_object_boolean_true_add(json_neigh
,
14596 "prefixesConfigExceedMax");
14599 " Peer had exceeded the max. no. of prefixes configured.\n");
14601 if (p
->t_pmax_restart
) {
14603 json_object_boolean_true_add(
14604 json_neigh
, "reducePrefixNumFrom");
14605 json_object_int_add(json_neigh
,
14606 "restartInTimerMsec",
14607 thread_timer_remain_second(
14612 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14613 p
->host
, thread_timer_remain_second(
14614 p
->t_pmax_restart
));
14617 json_object_boolean_true_add(
14619 "reducePrefixNumAndClearIpBgp");
14622 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14627 /* EBGP Multihop and GTSM */
14628 if (p
->sort
!= BGP_PEER_IBGP
) {
14630 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14631 json_object_int_add(json_neigh
,
14632 "externalBgpNbrMaxHopsAway",
14635 json_object_int_add(json_neigh
,
14636 "externalBgpNbrMaxHopsAway",
14639 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14641 " External BGP neighbor may be up to %d hops away.\n",
14645 " External BGP neighbor may be up to %d hops away.\n",
14650 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14651 json_object_int_add(json_neigh
,
14652 "internalBgpNbrMaxHopsAway",
14655 json_object_int_add(json_neigh
,
14656 "internalBgpNbrMaxHopsAway",
14659 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14661 " Internal BGP neighbor may be up to %d hops away.\n",
14665 " Internal BGP neighbor may be up to %d hops away.\n",
14670 /* Local address. */
14673 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14675 json_object_int_add(json_neigh
, "portLocal",
14676 ntohs(p
->su_local
->sin
.sin_port
));
14678 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14679 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14682 json_object_string_add(json_neigh
, "hostLocal",
14684 json_object_int_add(json_neigh
, "portLocal", -1);
14688 /* Remote address. */
14689 if (p
->su_remote
) {
14691 json_object_string_addf(json_neigh
, "hostForeign",
14692 "%pSU", p
->su_remote
);
14693 json_object_int_add(json_neigh
, "portForeign",
14694 ntohs(p
->su_remote
->sin
.sin_port
));
14696 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14698 ntohs(p
->su_remote
->sin
.sin_port
));
14701 json_object_string_add(json_neigh
, "hostForeign",
14703 json_object_int_add(json_neigh
, "portForeign", -1);
14707 /* Nexthop display. */
14710 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14712 json_object_string_addf(json_neigh
, "nexthopGlobal",
14713 "%pI6", &p
->nexthop
.v6_global
);
14714 json_object_string_addf(json_neigh
, "nexthopLocal",
14715 "%pI6", &p
->nexthop
.v6_local
);
14716 if (p
->shared_network
)
14717 json_object_string_add(json_neigh
,
14721 json_object_string_add(json_neigh
,
14723 "nonSharedNetwork");
14725 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14726 vty_out(vty
, "Nexthop global: %pI6\n",
14727 &p
->nexthop
.v6_global
);
14728 vty_out(vty
, "Nexthop local: %pI6\n",
14729 &p
->nexthop
.v6_local
);
14730 vty_out(vty
, "BGP connection: %s\n",
14731 p
->shared_network
? "shared network"
14732 : "non shared network");
14736 json_object_string_add(json_neigh
, "nexthop",
14738 json_object_string_add(json_neigh
, "nexthopGlobal",
14740 json_object_string_add(json_neigh
, "nexthopLocal",
14742 json_object_string_add(json_neigh
, "bgpConnection",
14747 /* Timer information. */
14749 json_object_int_add(json_neigh
, "connectRetryTimer",
14751 if (peer_established(p
)) {
14752 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14754 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14755 json_object_int_add(json_neigh
,
14756 "shutdownRttInMsecs",
14758 json_object_int_add(json_neigh
,
14759 "shutdownRttAfterCount",
14760 p
->rtt_keepalive_rcv
);
14764 json_object_int_add(
14765 json_neigh
, "nextStartTimerDueInMsecs",
14766 thread_timer_remain_second(p
->t_start
) * 1000);
14768 json_object_int_add(
14769 json_neigh
, "nextConnectTimerDueInMsecs",
14770 thread_timer_remain_second(p
->t_connect
)
14772 if (p
->t_routeadv
) {
14773 json_object_int_add(json_neigh
, "mraiInterval",
14775 json_object_int_add(
14776 json_neigh
, "mraiTimerExpireInMsecs",
14777 thread_timer_remain_second(p
->t_routeadv
)
14781 json_object_int_add(json_neigh
, "authenticationEnabled",
14785 json_object_string_add(json_neigh
, "readThread", "on");
14787 json_object_string_add(json_neigh
, "readThread", "off");
14789 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14790 json_object_string_add(json_neigh
, "writeThread", "on");
14792 json_object_string_add(json_neigh
, "writeThread",
14795 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14797 if (peer_established(p
)) {
14798 vty_out(vty
, "Estimated round trip time: %d ms\n",
14800 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14802 "Shutdown when RTT > %dms, count > %u\n",
14803 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14806 vty_out(vty
, "Next start timer due in %ld seconds\n",
14807 thread_timer_remain_second(p
->t_start
));
14809 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14810 thread_timer_remain_second(p
->t_connect
));
14813 "MRAI (interval %u) timer expires in %ld seconds\n",
14815 thread_timer_remain_second(p
->t_routeadv
));
14817 vty_out(vty
, "Peer Authentication Enabled\n");
14819 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14820 p
->t_read
? "on" : "off",
14821 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14826 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14827 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14828 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14831 vty_out(vty
, "\n");
14833 /* BFD information. */
14835 bgp_bfd_show_info(vty
, p
, json_neigh
);
14838 if (p
->conf_if
) /* Configured interface name. */
14839 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14840 else /* Configured IP address. */
14841 json_object_object_add(json
, p
->host
, json_neigh
);
14845 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14846 enum show_type type
,
14847 union sockunion
*su
,
14848 const char *conf_if
, afi_t afi
,
14851 struct listnode
*node
, *nnode
;
14853 bool found
= false;
14854 safi_t safi
= SAFI_UNICAST
;
14855 json_object
*json_neighbor
= NULL
;
14857 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14859 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14862 if ((peer
->afc
[afi
][safi
]) == 0)
14866 json_neighbor
= json_object_new_object();
14868 if (type
== show_all
) {
14869 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14872 json_object_object_add(json
, peer
->host
,
14875 } else if (type
== show_peer
) {
14878 && !strcmp(peer
->conf_if
, conf_if
))
14880 && !strcmp(peer
->hostname
, conf_if
))) {
14882 bgp_show_peer_gr_status(vty
, peer
,
14886 if (sockunion_same(&peer
->su
, su
)) {
14888 bgp_show_peer_gr_status(vty
, peer
,
14894 json_object_object_add(json
, peer
->host
,
14897 json_object_free(json_neighbor
);
14905 if (type
== show_peer
&& !found
) {
14907 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14909 vty_out(vty
, "%% No such neighbor\n");
14913 vty_out(vty
, "\n");
14915 return CMD_SUCCESS
;
14918 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14919 enum show_type type
, union sockunion
*su
,
14920 const char *conf_if
, bool use_json
,
14923 struct listnode
*node
, *nnode
;
14926 bool nbr_output
= false;
14927 afi_t afi
= AFI_MAX
;
14928 safi_t safi
= SAFI_MAX
;
14930 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14932 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14936 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14937 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14942 bgp_show_peer(vty
, peer
, use_json
, json
);
14948 && !strcmp(peer
->conf_if
, conf_if
))
14950 && !strcmp(peer
->hostname
, conf_if
))) {
14952 bgp_show_peer(vty
, peer
, use_json
,
14956 if (sockunion_same(&peer
->su
, su
)) {
14958 bgp_show_peer(vty
, peer
, use_json
,
14963 case show_ipv4_peer
:
14964 case show_ipv6_peer
:
14965 FOREACH_SAFI (safi
) {
14966 if (peer
->afc
[afi
][safi
]) {
14969 && !strcmp(peer
->conf_if
, conf_if
))
14971 && !strcmp(peer
->hostname
, conf_if
))) {
14973 bgp_show_peer(vty
, peer
, use_json
,
14978 if (sockunion_same(&peer
->su
, su
)) {
14980 bgp_show_peer(vty
, peer
, use_json
,
14988 case show_ipv4_all
:
14989 case show_ipv6_all
:
14990 FOREACH_SAFI (safi
) {
14991 if (peer
->afc
[afi
][safi
]) {
14992 bgp_show_peer(vty
, peer
, use_json
, json
);
15001 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15002 type
== show_ipv6_peer
) && !find
) {
15004 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15006 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15009 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15010 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15011 vty_out(vty
, "%% No BGP neighbors found\n");
15014 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15015 json
, JSON_C_TO_STRING_PRETTY
));
15017 vty_out(vty
, "\n");
15020 return CMD_SUCCESS
;
15023 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15024 enum show_type type
,
15025 const char *ip_str
,
15026 afi_t afi
, json_object
*json
)
15031 union sockunion su
;
15033 bgp
= bgp_get_default();
15039 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
15042 ret
= str2sockunion(ip_str
, &su
);
15044 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
15045 ip_str
, afi
, json
);
15047 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15050 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15054 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15055 enum show_type type
,
15056 const char *ip_str
,
15059 struct listnode
*node
, *nnode
;
15061 union sockunion su
;
15062 json_object
*json
= NULL
;
15063 int ret
, is_first
= 1;
15064 bool nbr_output
= false;
15067 vty_out(vty
, "{\n");
15069 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15072 if (!(json
= json_object_new_object())) {
15074 EC_BGP_JSON_MEM_ERROR
,
15075 "Unable to allocate memory for JSON object");
15077 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15081 json_object_int_add(json
, "vrfId",
15082 (bgp
->vrf_id
== VRF_UNKNOWN
)
15084 : (int64_t)bgp
->vrf_id
);
15085 json_object_string_add(
15087 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15092 vty_out(vty
, ",\n");
15096 vty_out(vty
, "\"%s\":",
15097 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15101 vty_out(vty
, "\nInstance %s:\n",
15102 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15107 if (type
== show_peer
|| type
== show_ipv4_peer
||
15108 type
== show_ipv6_peer
) {
15109 ret
= str2sockunion(ip_str
, &su
);
15111 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15114 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15117 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15120 json_object_free(json
);
15125 vty_out(vty
, "}\n");
15126 else if (!nbr_output
)
15127 vty_out(vty
, "%% BGP instance not found\n");
15130 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15131 enum show_type type
, const char *ip_str
,
15136 union sockunion su
;
15137 json_object
*json
= NULL
;
15140 if (strmatch(name
, "all")) {
15141 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15143 return CMD_SUCCESS
;
15145 bgp
= bgp_lookup_by_name(name
);
15148 json
= json_object_new_object();
15149 vty_json(vty
, json
);
15152 "%% BGP instance not found\n");
15154 return CMD_WARNING
;
15158 bgp
= bgp_get_default();
15162 json
= json_object_new_object();
15164 ret
= str2sockunion(ip_str
, &su
);
15166 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15169 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15172 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15175 json_object_free(json
);
15178 vty_out(vty
, "{}\n");
15180 vty_out(vty
, "%% BGP instance not found\n");
15183 return CMD_SUCCESS
;
15188 /* "show [ip] bgp neighbors graceful-restart" commands. */
15189 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15190 show_ip_bgp_neighbors_graceful_restart_cmd
,
15191 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15197 "Neighbor to display information about\n"
15198 "Neighbor to display information about\n"
15199 "Neighbor on BGP configured interface\n"
15203 char *sh_arg
= NULL
;
15204 enum show_type sh_type
;
15206 afi_t afi
= AFI_MAX
;
15207 bool uj
= use_json(argc
, argv
);
15209 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15214 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15215 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15216 || argv_find(argv
, argc
, "WORD", &idx
)) {
15217 sh_type
= show_peer
;
15218 sh_arg
= argv
[idx
]->arg
;
15220 sh_type
= show_all
;
15222 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15223 return CMD_SUCCESS
;
15226 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15230 /* "show [ip] bgp neighbors" commands. */
15231 DEFUN (show_ip_bgp_neighbors
,
15232 show_ip_bgp_neighbors_cmd
,
15233 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15237 BGP_INSTANCE_HELP_STR
15240 "Detailed information on TCP and BGP neighbor connections\n"
15241 "Neighbor to display information about\n"
15242 "Neighbor to display information about\n"
15243 "Neighbor on BGP configured interface\n"
15247 char *sh_arg
= NULL
;
15248 enum show_type sh_type
;
15249 afi_t afi
= AFI_MAX
;
15251 bool uj
= use_json(argc
, argv
);
15255 /* [<vrf> VIEWVRFNAME] */
15256 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15257 vrf
= argv
[idx
+ 1]->arg
;
15258 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15260 } else if (argv_find(argv
, argc
, "view", &idx
))
15261 /* [<view> VIEWVRFNAME] */
15262 vrf
= argv
[idx
+ 1]->arg
;
15266 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15267 sh_type
= show_ipv4_all
;
15269 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15270 sh_type
= show_ipv6_all
;
15273 sh_type
= show_all
;
15276 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15277 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15278 || argv_find(argv
, argc
, "WORD", &idx
)) {
15279 sh_type
= show_peer
;
15280 sh_arg
= argv
[idx
]->arg
;
15283 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15284 sh_type
= show_ipv4_peer
;
15285 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15286 sh_type
= show_ipv6_peer
;
15289 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15292 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15293 paths' and `show ip mbgp paths'. Those functions results are the
15295 DEFUN (show_ip_bgp_paths
,
15296 show_ip_bgp_paths_cmd
,
15297 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15302 "Path information\n")
15304 vty_out(vty
, "Address Refcnt Path\n");
15305 aspath_print_all_vty(vty
);
15306 return CMD_SUCCESS
;
15311 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15314 struct community
*com
;
15316 com
= (struct community
*)bucket
->data
;
15317 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15318 community_str(com
, false, false));
15321 /* Show BGP's community internal data. */
15322 DEFUN (show_ip_bgp_community_info
,
15323 show_ip_bgp_community_info_cmd
,
15324 "show [ip] bgp community-info",
15328 "List all bgp community information\n")
15330 vty_out(vty
, "Address Refcnt Community\n");
15332 hash_iterate(community_hash(),
15333 (void (*)(struct hash_bucket
*,
15334 void *))community_show_all_iterator
,
15337 return CMD_SUCCESS
;
15340 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15343 struct lcommunity
*lcom
;
15345 lcom
= (struct lcommunity
*)bucket
->data
;
15346 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15347 lcommunity_str(lcom
, false, false));
15350 /* Show BGP's community internal data. */
15351 DEFUN (show_ip_bgp_lcommunity_info
,
15352 show_ip_bgp_lcommunity_info_cmd
,
15353 "show ip bgp large-community-info",
15357 "List all bgp large-community information\n")
15359 vty_out(vty
, "Address Refcnt Large-community\n");
15361 hash_iterate(lcommunity_hash(),
15362 (void (*)(struct hash_bucket
*,
15363 void *))lcommunity_show_all_iterator
,
15366 return CMD_SUCCESS
;
15368 /* Graceful Restart */
15370 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15375 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15377 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15379 switch (bgp_global_gr_mode
) {
15381 case GLOBAL_HELPER
:
15382 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15386 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15389 case GLOBAL_DISABLE
:
15390 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15393 case GLOBAL_INVALID
:
15395 "Global BGP GR Mode Invalid\n");
15398 vty_out(vty
, "\n");
15401 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15402 enum show_type type
,
15403 const char *ip_str
,
15404 afi_t afi
, bool use_json
)
15406 json_object
*json
= NULL
;
15409 json
= json_object_new_object();
15411 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15414 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15416 bgp_show_neighbor_graceful_restart_vty(
15417 vty
, type
, ip_str
, afi
, json
);
15420 } else if (afi
!= AFI_MAX
) {
15421 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15425 json_object_free(json
);
15426 return CMD_ERR_INCOMPLETE
;
15430 vty_json(vty
, json
);
15432 return CMD_SUCCESS
;
15434 /* Graceful Restart */
15436 DEFUN (show_ip_bgp_attr_info
,
15437 show_ip_bgp_attr_info_cmd
,
15438 "show [ip] bgp attribute-info",
15442 "List all bgp attribute information\n")
15444 attr_show_all(vty
);
15445 return CMD_SUCCESS
;
15448 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15449 afi_t afi
, safi_t safi
,
15450 bool use_json
, json_object
*json
)
15453 struct listnode
*node
;
15456 enum vpn_policy_direction dir
;
15459 json_object
*json_import_vrfs
= NULL
;
15460 json_object
*json_export_vrfs
= NULL
;
15462 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15465 vty_json(vty
, json
);
15467 return CMD_WARNING
;
15470 /* Provide context for the block */
15471 json_object_string_add(json
, "vrf", name
? name
: "default");
15472 json_object_string_add(json
, "afiSafi",
15473 get_afi_safi_str(afi
, safi
, true));
15475 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15476 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15477 json_object_string_add(json
, "importFromVrfs", "none");
15478 json_object_string_add(json
, "importRts", "none");
15480 json_import_vrfs
= json_object_new_array();
15482 for (ALL_LIST_ELEMENTS_RO(
15483 bgp
->vpn_policy
[afi
].import_vrf
,
15485 json_object_array_add(json_import_vrfs
,
15486 json_object_new_string(vname
));
15488 json_object_object_add(json
, "importFromVrfs",
15490 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15491 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15492 ecom_str
= ecommunity_ecom2str(
15493 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15494 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15495 json_object_string_add(json
, "importRts",
15497 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15499 json_object_string_add(json
, "importRts",
15503 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15504 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15505 json_object_string_add(json
, "exportToVrfs", "none");
15506 json_object_string_add(json
, "routeDistinguisher",
15508 json_object_string_add(json
, "exportRts", "none");
15510 json_export_vrfs
= json_object_new_array();
15512 for (ALL_LIST_ELEMENTS_RO(
15513 bgp
->vpn_policy
[afi
].export_vrf
,
15515 json_object_array_add(json_export_vrfs
,
15516 json_object_new_string(vname
));
15517 json_object_object_add(json
, "exportToVrfs",
15519 json_object_string_addf(json
, "routeDistinguisher",
15521 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15523 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15524 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15525 ecom_str
= ecommunity_ecom2str(
15526 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15527 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15528 json_object_string_add(json
, "exportRts",
15530 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15532 json_object_string_add(json
, "exportRts",
15537 vty_json(vty
, json
);
15540 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15543 vty_out(vty
, "%% No such BGP instance exist\n");
15544 return CMD_WARNING
;
15547 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15548 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15550 "This VRF is not importing %s routes from any other VRF\n",
15551 get_afi_safi_str(afi
, safi
, false));
15554 "This VRF is importing %s routes from the following VRFs:\n",
15555 get_afi_safi_str(afi
, safi
, false));
15557 for (ALL_LIST_ELEMENTS_RO(
15558 bgp
->vpn_policy
[afi
].import_vrf
,
15560 vty_out(vty
, " %s\n", vname
);
15562 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15564 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15565 ecom_str
= ecommunity_ecom2str(
15566 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15567 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15568 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15570 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15572 vty_out(vty
, "Import RT(s):\n");
15575 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15576 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15578 "This VRF is not exporting %s routes to any other VRF\n",
15579 get_afi_safi_str(afi
, safi
, false));
15582 "This VRF is exporting %s routes to the following VRFs:\n",
15583 get_afi_safi_str(afi
, safi
, false));
15585 for (ALL_LIST_ELEMENTS_RO(
15586 bgp
->vpn_policy
[afi
].export_vrf
,
15588 vty_out(vty
, " %s\n", vname
);
15590 vty_out(vty
, "RD: %pRD\n",
15591 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15593 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15594 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15595 ecom_str
= ecommunity_ecom2str(
15596 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15597 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15598 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15599 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15601 vty_out(vty
, "Import RT(s):\n");
15605 return CMD_SUCCESS
;
15608 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15609 safi_t safi
, bool use_json
)
15611 struct listnode
*node
, *nnode
;
15613 char *vrf_name
= NULL
;
15614 json_object
*json
= NULL
;
15615 json_object
*json_vrf
= NULL
;
15616 json_object
*json_vrfs
= NULL
;
15619 json
= json_object_new_object();
15620 json_vrfs
= json_object_new_object();
15623 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15625 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15626 vrf_name
= bgp
->name
;
15629 json_vrf
= json_object_new_object();
15631 vty_out(vty
, "\nInstance %s:\n",
15632 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15633 ? VRF_DEFAULT_NAME
: bgp
->name
);
15635 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15637 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15638 json_object_object_add(json_vrfs
,
15639 VRF_DEFAULT_NAME
, json_vrf
);
15641 json_object_object_add(json_vrfs
, vrf_name
,
15647 json_object_object_add(json
, "vrfs", json_vrfs
);
15648 vty_json(vty
, json
);
15651 return CMD_SUCCESS
;
15654 /* "show [ip] bgp route-leak" command. */
15655 DEFUN (show_ip_bgp_route_leak
,
15656 show_ip_bgp_route_leak_cmd
,
15657 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15661 BGP_INSTANCE_HELP_STR
15664 "Route leaking information\n"
15668 afi_t afi
= AFI_MAX
;
15669 safi_t safi
= SAFI_MAX
;
15671 bool uj
= use_json(argc
, argv
);
15673 json_object
*json
= NULL
;
15675 /* show [ip] bgp */
15676 if (argv_find(argv
, argc
, "ip", &idx
)) {
15678 safi
= SAFI_UNICAST
;
15680 /* [vrf VIEWVRFNAME] */
15681 if (argv_find(argv
, argc
, "view", &idx
)) {
15683 "%% This command is not applicable to BGP views\n");
15684 return CMD_WARNING
;
15687 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15688 vrf
= argv
[idx
+ 1]->arg
;
15689 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15692 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15693 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15694 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15696 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15698 "%% This command is applicable only for unicast ipv4|ipv6\n");
15699 return CMD_WARNING
;
15702 if (vrf
&& strmatch(vrf
, "all"))
15703 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15706 json
= json_object_new_object();
15708 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15711 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15712 safi_t safi
, bool uj
)
15714 struct listnode
*node
, *nnode
;
15717 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15719 vty_out(vty
, "\nInstance %s:\n",
15720 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15724 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15728 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15729 int safi
, uint64_t subgrp_id
, bool uj
)
15734 if (strmatch(name
, "all")) {
15735 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15736 return CMD_SUCCESS
;
15738 bgp
= bgp_lookup_by_name(name
);
15741 bgp
= bgp_get_default();
15745 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15746 return CMD_SUCCESS
;
15749 DEFUN (show_ip_bgp_updgrps
,
15750 show_ip_bgp_updgrps_cmd
,
15751 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15755 BGP_INSTANCE_HELP_STR
15757 BGP_SAFI_WITH_LABEL_HELP_STR
15758 "Detailed info about dynamic update groups\n"
15759 "Specific subgroup to display detailed info for\n"
15763 afi_t afi
= AFI_IP6
;
15764 safi_t safi
= SAFI_UNICAST
;
15765 uint64_t subgrp_id
= 0;
15769 bool uj
= use_json(argc
, argv
);
15771 /* show [ip] bgp */
15772 if (argv_find(argv
, argc
, "ip", &idx
))
15774 /* [<vrf> VIEWVRFNAME] */
15775 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15776 vrf
= argv
[idx
+ 1]->arg
;
15777 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15779 } else if (argv_find(argv
, argc
, "view", &idx
))
15780 /* [<view> VIEWVRFNAME] */
15781 vrf
= argv
[idx
+ 1]->arg
;
15782 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15783 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15784 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15787 /* get subgroup id, if provided */
15789 if (argv
[idx
]->type
== VARIABLE_TKN
)
15790 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15792 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15795 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15796 show_bgp_instance_all_ipv6_updgrps_cmd
,
15797 "show [ip] bgp <view|vrf> all update-groups [json]",
15801 BGP_INSTANCE_ALL_HELP_STR
15802 "Detailed info about dynamic update groups\n"
15805 bool uj
= use_json(argc
, argv
);
15807 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15808 return CMD_SUCCESS
;
15811 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15812 show_bgp_l2vpn_evpn_updgrps_cmd
,
15813 "show [ip] bgp l2vpn evpn update-groups",
15817 "l2vpn address family\n"
15818 "evpn sub-address family\n"
15819 "Detailed info about dynamic update groups\n")
15822 uint64_t subgrp_id
= 0;
15824 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15825 return CMD_SUCCESS
;
15828 DEFUN (show_bgp_updgrps_stats
,
15829 show_bgp_updgrps_stats_cmd
,
15830 "show [ip] bgp update-groups statistics",
15834 "Detailed info about dynamic update groups\n"
15839 bgp
= bgp_get_default();
15841 update_group_show_stats(bgp
, vty
);
15843 return CMD_SUCCESS
;
15846 DEFUN (show_bgp_instance_updgrps_stats
,
15847 show_bgp_instance_updgrps_stats_cmd
,
15848 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15852 BGP_INSTANCE_HELP_STR
15853 "Detailed info about dynamic update groups\n"
15859 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15861 update_group_show_stats(bgp
, vty
);
15863 return CMD_SUCCESS
;
15866 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15867 afi_t afi
, safi_t safi
,
15868 const char *what
, uint64_t subgrp_id
)
15873 bgp
= bgp_lookup_by_name(name
);
15875 bgp
= bgp_get_default();
15878 if (!strcmp(what
, "advertise-queue"))
15879 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15881 else if (!strcmp(what
, "advertised-routes"))
15882 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15884 else if (!strcmp(what
, "packet-queue"))
15885 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15890 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15891 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15892 "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",
15893 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15895 "Detailed info about dynamic update groups\n"
15896 "Specific subgroup to display info for\n"
15897 "Advertisement queue\n"
15898 "Announced routes\n"
15901 uint64_t subgrp_id
= 0;
15905 subgrp_id
= strtoull(sgid
, NULL
, 10);
15910 afiz
= bgp_vty_afi_from_str(afi
);
15914 afiz
= bgp_vty_afi_from_str(afi
);
15915 if (afiz
!= AFI_IP
)
15917 "%% Cannot specify both 'ip' and 'ipv6'\n");
15918 return CMD_WARNING
;
15921 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15923 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15924 return CMD_SUCCESS
;
15927 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15930 struct listnode
*node
, *nnode
;
15931 struct prefix
*range
;
15936 const char *peer_status
;
15940 json_object
*json_peer_group
= NULL
;
15941 json_object
*json_peer_group_afc
= NULL
;
15942 json_object
*json_peer_group_members
= NULL
;
15943 json_object
*json_peer_group_dynamic
= NULL
;
15944 json_object
*json_peer_group_dynamic_af
= NULL
;
15945 json_object
*json_peer_group_ranges
= NULL
;
15947 conf
= group
->conf
;
15950 json_peer_group
= json_object_new_object();
15951 json_peer_group_afc
= json_object_new_array();
15954 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15956 json_object_int_add(json_peer_group
, "remoteAs",
15959 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15960 group
->name
, conf
->as
);
15961 } else if (conf
->as_type
== AS_INTERNAL
) {
15963 json_object_int_add(json_peer_group
, "remoteAs",
15966 vty_out(vty
, "\nBGP peer-group %s, remote AS %s\n",
15967 group
->name
, group
->bgp
->as_pretty
);
15970 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15973 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15975 json_object_string_add(json_peer_group
, "type",
15978 vty_out(vty
, " Peer-group type is internal\n");
15981 json_object_string_add(json_peer_group
, "type",
15984 vty_out(vty
, " Peer-group type is external\n");
15987 /* Display AFs configured. */
15989 vty_out(vty
, " Configured address-families:");
15991 FOREACH_AFI_SAFI (afi
, safi
) {
15992 if (conf
->afc
[afi
][safi
]) {
15995 json_object_array_add(
15996 json_peer_group_afc
,
15997 json_object_new_string(get_afi_safi_str(
15998 afi
, safi
, false)));
16000 vty_out(vty
, " %s;",
16001 get_afi_safi_str(afi
, safi
, false));
16006 json_object_object_add(json_peer_group
,
16007 "addressFamiliesConfigured",
16008 json_peer_group_afc
);
16011 vty_out(vty
, " none\n");
16013 vty_out(vty
, "\n");
16016 /* Display listen ranges (for dynamic neighbors), if any */
16017 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16018 lr_count
= listcount(group
->listen_range
[afi
]);
16021 if (!json_peer_group_dynamic
)
16022 json_peer_group_dynamic
=
16023 json_object_new_object();
16025 json_peer_group_dynamic_af
=
16026 json_object_new_object();
16027 json_peer_group_ranges
=
16028 json_object_new_array();
16029 json_object_int_add(json_peer_group_dynamic_af
,
16030 "count", lr_count
);
16032 vty_out(vty
, " %d %s listen range(s)\n",
16033 lr_count
, afi2str(afi
));
16036 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16041 snprintfrr(buf
, sizeof(buf
), "%pFX",
16044 json_object_array_add(
16045 json_peer_group_ranges
,
16046 json_object_new_string(buf
));
16048 vty_out(vty
, " %pFX\n", range
);
16053 json_object_object_add(
16054 json_peer_group_dynamic_af
, "ranges",
16055 json_peer_group_ranges
);
16057 json_object_object_add(
16058 json_peer_group_dynamic
, afi2str(afi
),
16059 json_peer_group_dynamic_af
);
16064 if (json_peer_group_dynamic
)
16065 json_object_object_add(json_peer_group
, "dynamicRanges",
16066 json_peer_group_dynamic
);
16068 /* Display group members and their status */
16069 if (listcount(group
->peer
)) {
16071 json_peer_group_members
= json_object_new_object();
16073 vty_out(vty
, " Peer-group members:\n");
16074 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16075 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16076 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16077 peer_status
= "Idle (Admin)";
16078 else if (CHECK_FLAG(peer
->sflags
,
16079 PEER_STATUS_PREFIX_OVERFLOW
))
16080 peer_status
= "Idle (PfxCt)";
16082 peer_status
= lookup_msg(bgp_status_msg
,
16083 peer
->status
, NULL
);
16085 dynamic
= peer_dynamic_neighbor(peer
);
16088 json_object
*json_peer_group_member
=
16089 json_object_new_object();
16091 json_object_string_add(json_peer_group_member
,
16092 "status", peer_status
);
16095 json_object_boolean_true_add(
16096 json_peer_group_member
,
16099 json_object_object_add(json_peer_group_members
,
16101 json_peer_group_member
);
16103 vty_out(vty
, " %s %s %s \n", peer
->host
,
16104 dynamic
? "(dynamic)" : "",
16109 json_object_object_add(json_peer_group
, "members",
16110 json_peer_group_members
);
16114 json_object_object_add(json
, group
->name
, json_peer_group
);
16116 return CMD_SUCCESS
;
16119 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16120 const char *group_name
, bool uj
)
16123 struct listnode
*node
, *nnode
;
16124 struct peer_group
*group
;
16125 bool found
= false;
16126 json_object
*json
= NULL
;
16129 json
= json_object_new_object();
16131 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16135 vty_json(vty
, json
);
16137 vty_out(vty
, "%% BGP instance not found\n");
16139 return CMD_WARNING
;
16142 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16144 if (strmatch(group
->name
, group_name
)) {
16145 bgp_show_one_peer_group(vty
, group
, json
);
16150 bgp_show_one_peer_group(vty
, group
, json
);
16154 if (group_name
&& !found
&& !uj
)
16155 vty_out(vty
, "%% No such peer-group\n");
16158 vty_json(vty
, json
);
16160 return CMD_SUCCESS
;
16163 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16164 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16165 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16166 "Detailed information on BGP peer groups\n"
16167 "Peer group name\n" JSON_STR
)
16171 bool uj
= use_json(argc
, argv
);
16173 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16175 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16177 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16181 /* Redistribute VTY commands. */
16183 DEFUN (bgp_redistribute_ipv4
,
16184 bgp_redistribute_ipv4_cmd
,
16185 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16186 "Redistribute information from another routing protocol\n"
16187 FRR_IP_REDIST_HELP_STR_BGPD
)
16189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16190 int idx_protocol
= 1;
16193 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16195 vty_out(vty
, "%% Invalid route type\n");
16196 return CMD_WARNING_CONFIG_FAILED
;
16199 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16200 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16204 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16205 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16206 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16208 DEFUN (bgp_redistribute_ipv4_rmap
,
16209 bgp_redistribute_ipv4_rmap_cmd
,
16210 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16211 "Redistribute information from another routing protocol\n"
16212 FRR_IP_REDIST_HELP_STR_BGPD
16213 "Route map reference\n"
16214 "Pointer to route-map entries\n")
16216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16217 int idx_protocol
= 1;
16220 struct bgp_redist
*red
;
16222 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16223 vty
, argv
[idx_word
]->arg
);
16225 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16227 vty_out(vty
, "%% Invalid route type\n");
16228 return CMD_WARNING_CONFIG_FAILED
;
16231 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16233 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16234 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16238 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16239 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16240 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16241 "Route map reference\n"
16242 "Pointer to route-map entries\n")
16244 DEFUN (bgp_redistribute_ipv4_metric
,
16245 bgp_redistribute_ipv4_metric_cmd
,
16246 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16247 "Redistribute information from another routing protocol\n"
16248 FRR_IP_REDIST_HELP_STR_BGPD
16249 "Metric for redistributed routes\n"
16250 "Default metric\n")
16252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16253 int idx_protocol
= 1;
16254 int idx_number
= 3;
16257 struct bgp_redist
*red
;
16260 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16262 vty_out(vty
, "%% Invalid route type\n");
16263 return CMD_WARNING_CONFIG_FAILED
;
16265 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16267 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16268 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16269 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16273 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16274 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16275 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16276 "Metric for redistributed routes\n"
16277 "Default metric\n")
16279 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16280 bgp_redistribute_ipv4_rmap_metric_cmd
,
16281 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16282 "Redistribute information from another routing protocol\n"
16283 FRR_IP_REDIST_HELP_STR_BGPD
16284 "Route map reference\n"
16285 "Pointer to route-map entries\n"
16286 "Metric for redistributed routes\n"
16287 "Default metric\n")
16289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16290 int idx_protocol
= 1;
16292 int idx_number
= 5;
16295 struct bgp_redist
*red
;
16297 struct route_map
*route_map
=
16298 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16300 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16302 vty_out(vty
, "%% Invalid route type\n");
16303 return CMD_WARNING_CONFIG_FAILED
;
16305 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16307 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16309 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16310 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16311 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16315 bgp_redistribute_ipv4_rmap_metric
,
16316 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16317 "redistribute " FRR_IP_REDIST_STR_BGPD
16318 " route-map RMAP_NAME metric (0-4294967295)",
16319 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16320 "Route map reference\n"
16321 "Pointer to route-map entries\n"
16322 "Metric for redistributed routes\n"
16323 "Default metric\n")
16325 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16326 bgp_redistribute_ipv4_metric_rmap_cmd
,
16327 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16328 "Redistribute information from another routing protocol\n"
16329 FRR_IP_REDIST_HELP_STR_BGPD
16330 "Metric for redistributed routes\n"
16332 "Route map reference\n"
16333 "Pointer to route-map entries\n")
16335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16336 int idx_protocol
= 1;
16337 int idx_number
= 3;
16341 struct bgp_redist
*red
;
16343 struct route_map
*route_map
=
16344 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16346 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16348 vty_out(vty
, "%% Invalid route type\n");
16349 return CMD_WARNING_CONFIG_FAILED
;
16351 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16353 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16354 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16356 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16357 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16361 bgp_redistribute_ipv4_metric_rmap
,
16362 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16363 "redistribute " FRR_IP_REDIST_STR_BGPD
16364 " metric (0-4294967295) route-map RMAP_NAME",
16365 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16366 "Metric for redistributed routes\n"
16368 "Route map reference\n"
16369 "Pointer to route-map entries\n")
16371 DEFUN (bgp_redistribute_ipv4_ospf
,
16372 bgp_redistribute_ipv4_ospf_cmd
,
16373 "redistribute <ospf|table> (1-65535)",
16374 "Redistribute information from another routing protocol\n"
16375 "Open Shortest Path First (OSPFv2)\n"
16376 "Non-main Kernel Routing Table\n"
16377 "Instance ID/Table ID\n")
16379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16380 int idx_ospf_table
= 1;
16381 int idx_number
= 2;
16382 unsigned short instance
;
16383 unsigned short protocol
;
16385 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16387 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16388 protocol
= ZEBRA_ROUTE_OSPF
;
16390 protocol
= ZEBRA_ROUTE_TABLE
;
16392 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16393 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16396 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16397 "redistribute <ospf|table> (1-65535)",
16398 "Redistribute information from another routing protocol\n"
16399 "Open Shortest Path First (OSPFv2)\n"
16400 "Non-main Kernel Routing Table\n"
16401 "Instance ID/Table ID\n")
16403 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16404 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16405 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16406 "Redistribute information from another routing protocol\n"
16407 "Open Shortest Path First (OSPFv2)\n"
16408 "Non-main Kernel Routing Table\n"
16409 "Instance ID/Table ID\n"
16410 "Route map reference\n"
16411 "Pointer to route-map entries\n")
16413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16414 int idx_ospf_table
= 1;
16415 int idx_number
= 2;
16417 struct bgp_redist
*red
;
16418 unsigned short instance
;
16421 struct route_map
*route_map
=
16422 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16424 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16425 protocol
= ZEBRA_ROUTE_OSPF
;
16427 protocol
= ZEBRA_ROUTE_TABLE
;
16429 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16430 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16432 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16433 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16436 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16437 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16438 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16439 "Redistribute information from another routing protocol\n"
16440 "Open Shortest Path First (OSPFv2)\n"
16441 "Non-main Kernel Routing Table\n"
16442 "Instance ID/Table ID\n"
16443 "Route map reference\n"
16444 "Pointer to route-map entries\n")
16446 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16447 bgp_redistribute_ipv4_ospf_metric_cmd
,
16448 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16449 "Redistribute information from another routing protocol\n"
16450 "Open Shortest Path First (OSPFv2)\n"
16451 "Non-main Kernel Routing Table\n"
16452 "Instance ID/Table ID\n"
16453 "Metric for redistributed routes\n"
16454 "Default metric\n")
16456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16457 int idx_ospf_table
= 1;
16458 int idx_number
= 2;
16459 int idx_number_2
= 4;
16461 struct bgp_redist
*red
;
16462 unsigned short instance
;
16466 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16467 protocol
= ZEBRA_ROUTE_OSPF
;
16469 protocol
= ZEBRA_ROUTE_TABLE
;
16471 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16472 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16474 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16475 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16477 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16480 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16481 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16482 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16483 "Redistribute information from another routing protocol\n"
16484 "Open Shortest Path First (OSPFv2)\n"
16485 "Non-main Kernel Routing Table\n"
16486 "Instance ID/Table ID\n"
16487 "Metric for redistributed routes\n"
16488 "Default metric\n")
16490 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16491 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16492 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16493 "Redistribute information from another routing protocol\n"
16494 "Open Shortest Path First (OSPFv2)\n"
16495 "Non-main Kernel Routing Table\n"
16496 "Instance ID/Table ID\n"
16497 "Route map reference\n"
16498 "Pointer to route-map entries\n"
16499 "Metric for redistributed routes\n"
16500 "Default metric\n")
16502 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16503 int idx_ospf_table
= 1;
16504 int idx_number
= 2;
16506 int idx_number_2
= 6;
16508 struct bgp_redist
*red
;
16509 unsigned short instance
;
16512 struct route_map
*route_map
=
16513 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16515 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16516 protocol
= ZEBRA_ROUTE_OSPF
;
16518 protocol
= ZEBRA_ROUTE_TABLE
;
16520 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16521 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16523 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16525 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16526 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16528 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16532 bgp_redistribute_ipv4_ospf_rmap_metric
,
16533 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16534 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16535 "Redistribute information from another routing protocol\n"
16536 "Open Shortest Path First (OSPFv2)\n"
16537 "Non-main Kernel Routing Table\n"
16538 "Instance ID/Table ID\n"
16539 "Route map reference\n"
16540 "Pointer to route-map entries\n"
16541 "Metric for redistributed routes\n"
16542 "Default metric\n")
16544 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16545 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16546 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16547 "Redistribute information from another routing protocol\n"
16548 "Open Shortest Path First (OSPFv2)\n"
16549 "Non-main Kernel Routing Table\n"
16550 "Instance ID/Table ID\n"
16551 "Metric for redistributed routes\n"
16553 "Route map reference\n"
16554 "Pointer to route-map entries\n")
16556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16557 int idx_ospf_table
= 1;
16558 int idx_number
= 2;
16559 int idx_number_2
= 4;
16562 struct bgp_redist
*red
;
16563 unsigned short instance
;
16566 struct route_map
*route_map
=
16567 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16569 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16570 protocol
= ZEBRA_ROUTE_OSPF
;
16572 protocol
= ZEBRA_ROUTE_TABLE
;
16574 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16575 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16577 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16578 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16581 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16582 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16586 bgp_redistribute_ipv4_ospf_metric_rmap
,
16587 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16588 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16589 "Redistribute information from another routing protocol\n"
16590 "Open Shortest Path First (OSPFv2)\n"
16591 "Non-main Kernel Routing Table\n"
16592 "Instance ID/Table ID\n"
16593 "Metric for redistributed routes\n"
16595 "Route map reference\n"
16596 "Pointer to route-map entries\n")
16598 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16599 no_bgp_redistribute_ipv4_ospf_cmd
,
16600 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16602 "Redistribute information from another routing protocol\n"
16603 "Open Shortest Path First (OSPFv2)\n"
16604 "Non-main Kernel Routing Table\n"
16605 "Instance ID/Table ID\n"
16606 "Metric for redistributed routes\n"
16608 "Route map reference\n"
16609 "Pointer to route-map entries\n")
16611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16612 int idx_ospf_table
= 2;
16613 int idx_number
= 3;
16614 unsigned short instance
;
16617 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16618 protocol
= ZEBRA_ROUTE_OSPF
;
16620 protocol
= ZEBRA_ROUTE_TABLE
;
16622 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16623 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16627 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16628 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16630 "Redistribute information from another routing protocol\n"
16631 "Open Shortest Path First (OSPFv2)\n"
16632 "Non-main Kernel Routing Table\n"
16633 "Instance ID/Table ID\n"
16634 "Metric for redistributed routes\n"
16636 "Route map reference\n"
16637 "Pointer to route-map entries\n")
16639 DEFUN (no_bgp_redistribute_ipv4
,
16640 no_bgp_redistribute_ipv4_cmd
,
16641 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16643 "Redistribute information from another routing protocol\n"
16644 FRR_IP_REDIST_HELP_STR_BGPD
16645 "Metric for redistributed routes\n"
16647 "Route map reference\n"
16648 "Pointer to route-map entries\n")
16650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16651 int idx_protocol
= 2;
16654 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16656 vty_out(vty
, "%% Invalid route type\n");
16657 return CMD_WARNING_CONFIG_FAILED
;
16659 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16663 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16664 "no redistribute " FRR_IP_REDIST_STR_BGPD
16665 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16667 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16668 "Metric for redistributed routes\n"
16670 "Route map reference\n"
16671 "Pointer to route-map entries\n")
16673 DEFUN (bgp_redistribute_ipv6
,
16674 bgp_redistribute_ipv6_cmd
,
16675 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16676 "Redistribute information from another routing protocol\n"
16677 FRR_IP6_REDIST_HELP_STR_BGPD
)
16679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16680 int idx_protocol
= 1;
16683 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16685 vty_out(vty
, "%% Invalid route type\n");
16686 return CMD_WARNING_CONFIG_FAILED
;
16689 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16690 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16693 DEFUN (bgp_redistribute_ipv6_rmap
,
16694 bgp_redistribute_ipv6_rmap_cmd
,
16695 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16696 "Redistribute information from another routing protocol\n"
16697 FRR_IP6_REDIST_HELP_STR_BGPD
16698 "Route map reference\n"
16699 "Pointer to route-map entries\n")
16701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16702 int idx_protocol
= 1;
16705 struct bgp_redist
*red
;
16707 struct route_map
*route_map
=
16708 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16710 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16712 vty_out(vty
, "%% Invalid route type\n");
16713 return CMD_WARNING_CONFIG_FAILED
;
16716 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16718 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16719 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16722 DEFUN (bgp_redistribute_ipv6_metric
,
16723 bgp_redistribute_ipv6_metric_cmd
,
16724 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16725 "Redistribute information from another routing protocol\n"
16726 FRR_IP6_REDIST_HELP_STR_BGPD
16727 "Metric for redistributed routes\n"
16728 "Default metric\n")
16730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16731 int idx_protocol
= 1;
16732 int idx_number
= 3;
16735 struct bgp_redist
*red
;
16738 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16740 vty_out(vty
, "%% Invalid route type\n");
16741 return CMD_WARNING_CONFIG_FAILED
;
16743 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16745 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16746 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16747 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16750 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16751 bgp_redistribute_ipv6_rmap_metric_cmd
,
16752 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16753 "Redistribute information from another routing protocol\n"
16754 FRR_IP6_REDIST_HELP_STR_BGPD
16755 "Route map reference\n"
16756 "Pointer to route-map entries\n"
16757 "Metric for redistributed routes\n"
16758 "Default metric\n")
16760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16761 int idx_protocol
= 1;
16763 int idx_number
= 5;
16766 struct bgp_redist
*red
;
16768 struct route_map
*route_map
=
16769 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16771 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16773 vty_out(vty
, "%% Invalid route type\n");
16774 return CMD_WARNING_CONFIG_FAILED
;
16776 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16778 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16780 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16781 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16783 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16786 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16787 bgp_redistribute_ipv6_metric_rmap_cmd
,
16788 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16789 "Redistribute information from another routing protocol\n"
16790 FRR_IP6_REDIST_HELP_STR_BGPD
16791 "Metric for redistributed routes\n"
16793 "Route map reference\n"
16794 "Pointer to route-map entries\n")
16796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16797 int idx_protocol
= 1;
16798 int idx_number
= 3;
16802 struct bgp_redist
*red
;
16804 struct route_map
*route_map
=
16805 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16807 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16809 vty_out(vty
, "%% Invalid route type\n");
16810 return CMD_WARNING_CONFIG_FAILED
;
16812 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16814 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16815 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16818 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16819 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16822 DEFUN (no_bgp_redistribute_ipv6
,
16823 no_bgp_redistribute_ipv6_cmd
,
16824 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16826 "Redistribute information from another routing protocol\n"
16827 FRR_IP6_REDIST_HELP_STR_BGPD
16828 "Metric for redistributed routes\n"
16830 "Route map reference\n"
16831 "Pointer to route-map entries\n")
16833 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16834 int idx_protocol
= 2;
16837 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16839 vty_out(vty
, "%% Invalid route type\n");
16840 return CMD_WARNING_CONFIG_FAILED
;
16843 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16846 /* Neighbor update tcp-mss. */
16847 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16848 const char *tcp_mss_str
)
16851 uint32_t tcp_mss_val
= 0;
16853 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16855 return CMD_WARNING_CONFIG_FAILED
;
16858 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16859 peer_tcp_mss_set(peer
, tcp_mss_val
);
16861 peer_tcp_mss_unset(peer
);
16864 return CMD_SUCCESS
;
16867 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16868 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16869 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16870 "TCP max segment size\n"
16873 int peer_index
= 1;
16877 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16878 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16879 argv
[mss_index
]->arg
);
16882 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16883 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16884 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16885 "TCP max segment size\n"
16888 int peer_index
= 2;
16891 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16892 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16895 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16896 "[no$no] bgp retain route-target all",
16898 "Retain BGP updates\n"
16899 "Retain BGP updates based on route-target values\n"
16900 "Retain all BGP updates\n")
16903 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16905 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16906 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16907 if (check
!= !no
) {
16909 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16910 [bgp_node_safi(vty
)],
16911 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16913 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16914 [bgp_node_safi(vty
)],
16915 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16916 /* trigger a flush to re-sync with ADJ-RIB-in */
16917 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16918 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16920 return CMD_SUCCESS
;
16923 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16924 afi_t afi
, safi_t safi
)
16928 /* Unicast redistribution only. */
16929 if (safi
!= SAFI_UNICAST
)
16932 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16933 /* Redistribute BGP does not make sense. */
16934 if (i
!= ZEBRA_ROUTE_BGP
) {
16935 struct list
*red_list
;
16936 struct listnode
*node
;
16937 struct bgp_redist
*red
;
16939 red_list
= bgp
->redist
[afi
][i
];
16943 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16944 /* "redistribute" configuration. */
16945 vty_out(vty
, " redistribute %s",
16946 zebra_route_string(i
));
16948 vty_out(vty
, " %d", red
->instance
);
16949 if (red
->redist_metric_flag
)
16950 vty_out(vty
, " metric %u",
16951 red
->redist_metric
);
16952 if (red
->rmap
.name
)
16953 vty_out(vty
, " route-map %s",
16955 vty_out(vty
, "\n");
16961 /* peer-group helpers for config-write */
16963 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16965 if (!peer_group_active(peer
)) {
16966 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16967 return !CHECK_FLAG(peer
->flags
, flag
);
16969 return !!CHECK_FLAG(peer
->flags
, flag
);
16972 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16975 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16978 if (!peer_group_active(peer
)) {
16979 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16980 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16982 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16985 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16988 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16989 uint8_t type
, int direct
)
16991 struct bgp_filter
*filter
;
16993 if (peer_group_active(peer
))
16994 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16997 filter
= &peer
->filter
[afi
][safi
];
16999 case PEER_FT_DISTRIBUTE_LIST
:
17000 return !!(filter
->dlist
[direct
].name
);
17001 case PEER_FT_FILTER_LIST
:
17002 return !!(filter
->aslist
[direct
].name
);
17003 case PEER_FT_PREFIX_LIST
:
17004 return !!(filter
->plist
[direct
].name
);
17005 case PEER_FT_ROUTE_MAP
:
17006 return !!(filter
->map
[direct
].name
);
17007 case PEER_FT_UNSUPPRESS_MAP
:
17008 return !!(filter
->usmap
.name
);
17009 case PEER_FT_ADVERTISE_MAP
:
17010 return !!(filter
->advmap
.aname
17011 && ((filter
->advmap
.condition
== direct
)
17012 && filter
->advmap
.cname
));
17018 /* Return true if the addpath type is set for peer and different from
17021 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
17024 enum bgp_addpath_strat type
, g_type
;
17026 type
= peer
->addpath_type
[afi
][safi
];
17028 if (type
!= BGP_ADDPATH_NONE
) {
17029 if (peer_group_active(peer
)) {
17030 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
17032 if (type
!= g_type
)
17044 /* This is part of the address-family block (unicast only) */
17045 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17049 uint32_t tovpn_sid_index
= 0;
17051 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17052 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17053 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17054 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17055 bgp
->vpn_policy
[afi
]
17056 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17058 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17059 bgp
->vpn_policy
[afi
]
17060 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17062 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17063 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17064 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17065 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17068 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17069 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17071 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17074 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17075 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17076 bgp
->vpn_policy
[afi
].tovpn_label
);
17080 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17081 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17082 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17083 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17084 } else if (tovpn_sid_index
!= 0) {
17085 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17089 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17090 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
17091 &bgp
->vpn_policy
[afi
].tovpn_rd
);
17093 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17094 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17096 char buf
[PREFIX_STRLEN
];
17097 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17098 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17101 vty_out(vty
, "%*snexthop vpn export %s\n",
17105 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17106 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17108 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17109 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17111 char *b
= ecommunity_ecom2str(
17112 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17113 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17114 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17115 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17117 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17118 char *b
= ecommunity_ecom2str(
17119 bgp
->vpn_policy
[afi
]
17120 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17121 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17122 ECOMMUNITY_ROUTE_TARGET
);
17123 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17124 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17126 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17127 char *b
= ecommunity_ecom2str(
17128 bgp
->vpn_policy
[afi
]
17129 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17130 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17131 ECOMMUNITY_ROUTE_TARGET
);
17132 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17133 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17137 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17138 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17139 bgp
->vpn_policy
[afi
]
17140 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17142 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17143 char *b
= ecommunity_ecom2str(
17144 bgp
->vpn_policy
[afi
]
17145 .import_redirect_rtlist
,
17146 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17147 ECOMMUNITY_ROUTE_TARGET
);
17149 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17150 != ECOMMUNITY_SIZE
)
17151 vty_out(vty
, "%*srt6 redirect import %s\n",
17154 vty_out(vty
, "%*srt redirect import %s\n",
17156 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17160 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17161 afi_t afi
, safi_t safi
)
17163 struct bgp_filter
*filter
;
17167 filter
= &peer
->filter
[afi
][safi
];
17169 /* distribute-list. */
17170 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17172 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17173 filter
->dlist
[FILTER_IN
].name
);
17175 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17177 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17178 filter
->dlist
[FILTER_OUT
].name
);
17181 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17183 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17184 filter
->plist
[FILTER_IN
].name
);
17186 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17188 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17189 filter
->plist
[FILTER_OUT
].name
);
17192 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17193 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17194 filter
->map
[RMAP_IN
].name
);
17196 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17198 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17199 filter
->map
[RMAP_OUT
].name
);
17201 /* unsuppress-map */
17202 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17203 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17204 filter
->usmap
.name
);
17206 /* advertise-map : always applied in OUT direction*/
17207 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17208 CONDITION_NON_EXIST
))
17210 " neighbor %s advertise-map %s non-exist-map %s\n",
17211 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17213 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17215 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17216 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17219 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17221 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17222 filter
->aslist
[FILTER_IN
].name
);
17224 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17226 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17227 filter
->aslist
[FILTER_OUT
].name
);
17230 /* BGP peer configuration display function. */
17231 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17234 struct peer
*g_peer
= NULL
;
17236 int if_pg_printed
= false;
17237 int if_ras_printed
= false;
17239 /* Skip dynamic neighbors. */
17240 if (peer_dynamic_neighbor(peer
))
17244 addr
= peer
->conf_if
;
17248 /************************************
17249 ****** Global to the neighbor ******
17250 ************************************/
17251 if (peer
->conf_if
) {
17252 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17253 vty_out(vty
, " neighbor %s interface v6only", addr
);
17255 vty_out(vty
, " neighbor %s interface", addr
);
17257 if (peer_group_active(peer
)) {
17258 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17259 if_pg_printed
= true;
17260 } else if (peer
->as_type
== AS_SPECIFIED
) {
17261 vty_out(vty
, " remote-as %u", peer
->as
);
17262 if_ras_printed
= true;
17263 } else if (peer
->as_type
== AS_INTERNAL
) {
17264 vty_out(vty
, " remote-as internal");
17265 if_ras_printed
= true;
17266 } else if (peer
->as_type
== AS_EXTERNAL
) {
17267 vty_out(vty
, " remote-as external");
17268 if_ras_printed
= true;
17271 vty_out(vty
, "\n");
17274 /* remote-as and peer-group */
17275 /* peer is a member of a peer-group */
17276 if (peer_group_active(peer
)) {
17277 g_peer
= peer
->group
->conf
;
17279 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17280 if (peer
->as_type
== AS_SPECIFIED
) {
17281 vty_out(vty
, " neighbor %s remote-as %u\n",
17283 } else if (peer
->as_type
== AS_INTERNAL
) {
17285 " neighbor %s remote-as internal\n",
17287 } else if (peer
->as_type
== AS_EXTERNAL
) {
17289 " neighbor %s remote-as external\n",
17294 /* For swpX peers we displayed the peer-group
17295 * via 'neighbor swpX interface peer-group PGNAME' */
17296 if (!if_pg_printed
)
17297 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17298 peer
->group
->name
);
17301 /* peer is NOT a member of a peer-group */
17303 /* peer is a peer-group, declare the peer-group */
17304 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17305 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17308 if (!if_ras_printed
) {
17309 if (peer
->as_type
== AS_SPECIFIED
) {
17310 vty_out(vty
, " neighbor %s remote-as %u\n",
17312 } else if (peer
->as_type
== AS_INTERNAL
) {
17314 " neighbor %s remote-as internal\n",
17316 } else if (peer
->as_type
== AS_EXTERNAL
) {
17318 " neighbor %s remote-as external\n",
17325 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17326 vty_out(vty
, " neighbor %s local-as %u", addr
,
17327 peer
->change_local_as
);
17328 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17329 vty_out(vty
, " no-prepend");
17330 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17331 vty_out(vty
, " replace-as");
17332 vty_out(vty
, "\n");
17337 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17341 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17342 if (peer
->tx_shutdown_message
)
17343 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17344 peer
->tx_shutdown_message
);
17346 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17349 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17350 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17351 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17354 if (peer
->bfd_config
)
17355 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17358 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17359 vty_out(vty
, " neighbor %s password %s\n", addr
,
17362 /* neighbor solo */
17363 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17364 if (!peer_group_active(peer
)) {
17365 vty_out(vty
, " neighbor %s solo\n", addr
);
17370 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17371 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17374 /* Local interface name */
17375 if (peer
->ifname
) {
17376 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17379 /* TCP max segment size */
17380 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17381 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17384 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17385 vty_out(vty
, " neighbor %s passive\n", addr
);
17387 /* ebgp-multihop */
17388 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17389 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17390 && peer
->ttl
== MAXTTL
)) {
17391 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17392 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17398 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17399 vty_out(vty
, " neighbor %s aigp\n", addr
);
17401 /* graceful-shutdown */
17402 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17403 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17406 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17407 peer
->local_role
!= ROLE_UNDEFINED
)
17408 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17409 bgp_get_name_by_role(peer
->local_role
),
17410 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17414 /* ttl-security hops */
17415 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17416 if (!peer_group_active(peer
)
17417 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17418 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17419 addr
, peer
->gtsm_hops
);
17423 /* disable-connected-check */
17424 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17425 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17427 /* link-bw-encoding-ieee */
17428 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17429 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17432 /* extended-optional-parameters */
17433 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17434 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17437 /* enforce-first-as */
17438 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17439 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17441 /* update-source */
17442 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17443 if (peer
->update_source
)
17444 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17445 peer
->update_source
);
17446 else if (peer
->update_if
)
17447 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17451 /* advertisement-interval */
17452 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17453 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17457 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17458 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17459 peer
->keepalive
, peer
->holdtime
);
17461 /* timers connect */
17462 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17463 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17465 /* need special-case handling for changed default values due to
17466 * config profile / version (because there is no "timers bgp connect"
17467 * command, we need to save this per-peer :/)
17469 else if (!peer_group_active(peer
) && !peer
->connect
&&
17470 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17471 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17472 peer
->bgp
->default_connect_retry
);
17474 /* timers delayopen */
17475 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17476 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17478 /* Save config even though flag is not set if default values have been
17481 else if (!peer_group_active(peer
) && !peer
->delayopen
17482 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17483 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17484 peer
->bgp
->default_delayopen
);
17486 /* capability dynamic */
17487 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17488 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17490 /* capability extended-nexthop */
17491 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17492 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17495 " no neighbor %s capability extended-nexthop\n",
17497 else if (!peer
->conf_if
)
17499 " neighbor %s capability extended-nexthop\n",
17503 /* dont-capability-negotiation */
17504 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17505 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17507 /* override-capability */
17508 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17509 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17511 /* strict-capability-match */
17512 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17513 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17515 /* Sender side AS path loop detection. */
17516 if (peer
->as_path_loop_detection
)
17517 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17520 /* path-attribute discard */
17521 char discard_attrs_str
[BUFSIZ
] = {0};
17522 bool discard_attrs
= bgp_path_attribute_discard(
17523 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17526 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17527 discard_attrs_str
);
17529 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17530 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17532 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17533 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17535 " neighbor %s graceful-restart-helper\n", addr
);
17536 } else if (CHECK_FLAG(
17537 peer
->peer_gr_new_status_flag
,
17538 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17540 " neighbor %s graceful-restart\n", addr
);
17542 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17543 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17545 peer
->peer_gr_new_status_flag
,
17546 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17547 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17553 /* BGP peer configuration display function. */
17554 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17555 struct peer
*peer
, afi_t afi
, safi_t safi
)
17557 struct peer
*g_peer
= NULL
;
17559 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17561 /* Skip dynamic neighbors. */
17562 if (peer_dynamic_neighbor(peer
))
17566 addr
= peer
->conf_if
;
17570 /************************************
17571 ****** Per AF to the neighbor ******
17572 ************************************/
17573 if (peer_group_active(peer
)) {
17574 g_peer
= peer
->group
->conf
;
17576 /* If the peer-group is active but peer is not, print a 'no
17578 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17579 vty_out(vty
, " no neighbor %s activate\n", addr
);
17582 /* If the peer-group is not active but peer is, print an
17584 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17585 vty_out(vty
, " neighbor %s activate\n", addr
);
17588 if (peer
->afc
[afi
][safi
]) {
17589 if (safi
== SAFI_ENCAP
)
17590 vty_out(vty
, " neighbor %s activate\n", addr
);
17591 else if (!bgp
->default_af
[afi
][safi
])
17592 vty_out(vty
, " neighbor %s activate\n", addr
);
17594 if (bgp
->default_af
[afi
][safi
])
17595 vty_out(vty
, " no neighbor %s activate\n",
17600 /* addpath TX knobs */
17601 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17602 switch (peer
->addpath_type
[afi
][safi
]) {
17603 case BGP_ADDPATH_ALL
:
17604 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17607 case BGP_ADDPATH_BEST_PER_AS
:
17609 " neighbor %s addpath-tx-bestpath-per-AS\n",
17612 case BGP_ADDPATH_MAX
:
17613 case BGP_ADDPATH_NONE
:
17618 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17619 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17621 /* ORF capability. */
17622 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17623 || peergroup_af_flag_check(peer
, afi
, safi
,
17624 PEER_FLAG_ORF_PREFIX_RM
)) {
17625 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17627 if (peergroup_af_flag_check(peer
, afi
, safi
,
17628 PEER_FLAG_ORF_PREFIX_SM
)
17629 && peergroup_af_flag_check(peer
, afi
, safi
,
17630 PEER_FLAG_ORF_PREFIX_RM
))
17631 vty_out(vty
, " both");
17632 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17633 PEER_FLAG_ORF_PREFIX_SM
))
17634 vty_out(vty
, " send");
17636 vty_out(vty
, " receive");
17637 vty_out(vty
, "\n");
17640 /* Route reflector client. */
17641 if (peergroup_af_flag_check(peer
, afi
, safi
,
17642 PEER_FLAG_REFLECTOR_CLIENT
)) {
17643 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17646 /* next-hop-self force */
17647 if (peergroup_af_flag_check(peer
, afi
, safi
,
17648 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17649 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17652 /* next-hop-self */
17653 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17654 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17657 /* remove-private-AS */
17658 if (peergroup_af_flag_check(peer
, afi
, safi
,
17659 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17660 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17664 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17665 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17666 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17670 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17671 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17672 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17675 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17676 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17677 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17681 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17682 vty_out(vty
, " neighbor %s as-override\n", addr
);
17685 /* send-community print. */
17686 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17687 PEER_FLAG_SEND_COMMUNITY
);
17688 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17689 PEER_FLAG_SEND_EXT_COMMUNITY
);
17690 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17691 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17693 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17694 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17697 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17700 " no neighbor %s send-community extended\n",
17704 vty_out(vty
, " no neighbor %s send-community large\n",
17708 /* Default information */
17709 if (peergroup_af_flag_check(peer
, afi
, safi
,
17710 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17711 vty_out(vty
, " neighbor %s default-originate", addr
);
17713 if (peer
->default_rmap
[afi
][safi
].name
)
17714 vty_out(vty
, " route-map %s",
17715 peer
->default_rmap
[afi
][safi
].name
);
17717 vty_out(vty
, "\n");
17720 /* Soft reconfiguration inbound. */
17721 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17722 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17726 /* maximum-prefix. */
17727 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17728 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17729 peer
->pmax
[afi
][safi
]);
17731 if (peer
->pmax_threshold
[afi
][safi
]
17732 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17733 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17734 if (peer_af_flag_check(peer
, afi
, safi
,
17735 PEER_FLAG_MAX_PREFIX_WARNING
))
17736 vty_out(vty
, " warning-only");
17737 if (peer
->pmax_restart
[afi
][safi
])
17738 vty_out(vty
, " restart %u",
17739 peer
->pmax_restart
[afi
][safi
]);
17740 if (peer_af_flag_check(peer
, afi
, safi
,
17741 PEER_FLAG_MAX_PREFIX_FORCE
))
17742 vty_out(vty
, " force");
17744 vty_out(vty
, "\n");
17747 /* maximum-prefix-out */
17748 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17749 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17750 addr
, peer
->pmax_out
[afi
][safi
]);
17752 /* Route server client. */
17753 if (peergroup_af_flag_check(peer
, afi
, safi
,
17754 PEER_FLAG_RSERVER_CLIENT
)) {
17755 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17758 /* Nexthop-local unchanged. */
17759 if (peergroup_af_flag_check(peer
, afi
, safi
,
17760 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17761 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17764 /* allowas-in <1-10> */
17765 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17766 if (peer_af_flag_check(peer
, afi
, safi
,
17767 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17768 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17769 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17770 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17772 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17773 peer
->allowas_in
[afi
][safi
]);
17778 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17779 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17782 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17783 char *soo_str
= ecommunity_ecom2str(
17784 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17786 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17787 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17791 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17792 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17793 peer
->weight
[afi
][safi
]);
17796 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17798 /* atribute-unchanged. */
17799 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17800 || (safi
!= SAFI_EVPN
17801 && peer_af_flag_check(peer
, afi
, safi
,
17802 PEER_FLAG_NEXTHOP_UNCHANGED
))
17803 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17805 if (!peer_group_active(peer
)
17806 || peergroup_af_flag_check(peer
, afi
, safi
,
17807 PEER_FLAG_AS_PATH_UNCHANGED
)
17808 || peergroup_af_flag_check(peer
, afi
, safi
,
17809 PEER_FLAG_NEXTHOP_UNCHANGED
)
17810 || peergroup_af_flag_check(peer
, afi
, safi
,
17811 PEER_FLAG_MED_UNCHANGED
)) {
17814 " neighbor %s attribute-unchanged%s%s%s\n",
17816 peer_af_flag_check(peer
, afi
, safi
,
17817 PEER_FLAG_AS_PATH_UNCHANGED
)
17820 peer_af_flag_check(peer
, afi
, safi
,
17821 PEER_FLAG_NEXTHOP_UNCHANGED
)
17824 peer_af_flag_check(peer
, afi
, safi
,
17825 PEER_FLAG_MED_UNCHANGED
)
17832 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17835 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17836 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17837 vty_out(vty
, " no bgp retain route-target all\n");
17840 /* Address family based peer configuration display. */
17841 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17845 struct peer_group
*group
;
17846 struct listnode
*node
, *nnode
;
17849 vty_frame(vty
, " !\n address-family ");
17850 if (afi
== AFI_IP
) {
17851 if (safi
== SAFI_UNICAST
)
17852 vty_frame(vty
, "ipv4 unicast");
17853 else if (safi
== SAFI_LABELED_UNICAST
)
17854 vty_frame(vty
, "ipv4 labeled-unicast");
17855 else if (safi
== SAFI_MULTICAST
)
17856 vty_frame(vty
, "ipv4 multicast");
17857 else if (safi
== SAFI_MPLS_VPN
)
17858 vty_frame(vty
, "ipv4 vpn");
17859 else if (safi
== SAFI_ENCAP
)
17860 vty_frame(vty
, "ipv4 encap");
17861 else if (safi
== SAFI_FLOWSPEC
)
17862 vty_frame(vty
, "ipv4 flowspec");
17863 } else if (afi
== AFI_IP6
) {
17864 if (safi
== SAFI_UNICAST
)
17865 vty_frame(vty
, "ipv6 unicast");
17866 else if (safi
== SAFI_LABELED_UNICAST
)
17867 vty_frame(vty
, "ipv6 labeled-unicast");
17868 else if (safi
== SAFI_MULTICAST
)
17869 vty_frame(vty
, "ipv6 multicast");
17870 else if (safi
== SAFI_MPLS_VPN
)
17871 vty_frame(vty
, "ipv6 vpn");
17872 else if (safi
== SAFI_ENCAP
)
17873 vty_frame(vty
, "ipv6 encap");
17874 else if (safi
== SAFI_FLOWSPEC
)
17875 vty_frame(vty
, "ipv6 flowspec");
17876 } else if (afi
== AFI_L2VPN
) {
17877 if (safi
== SAFI_EVPN
)
17878 vty_frame(vty
, "l2vpn evpn");
17880 vty_frame(vty
, "\n");
17882 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17884 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17886 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17888 /* BGP flag dampening. */
17889 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17890 bgp_config_write_damp(vty
, afi
, safi
);
17892 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17893 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17895 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17896 /* Do not display doppelganger peers */
17897 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17898 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17901 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17902 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17904 if (safi
== SAFI_EVPN
)
17905 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17907 if (safi
== SAFI_FLOWSPEC
)
17908 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17910 if (safi
== SAFI_MPLS_VPN
)
17911 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17913 if (safi
== SAFI_UNICAST
) {
17914 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17915 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17916 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17918 vty_out(vty
, " export vpn\n");
17920 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17921 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17923 vty_out(vty
, " import vpn\n");
17925 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17926 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17929 for (ALL_LIST_ELEMENTS_RO(
17930 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17932 vty_out(vty
, " import vrf %s\n", name
);
17936 vty_endframe(vty
, " exit-address-family\n");
17939 int bgp_config_write(struct vty
*vty
)
17942 struct peer_group
*group
;
17944 struct listnode
*node
, *nnode
;
17945 struct listnode
*mnode
, *mnnode
;
17948 uint32_t tovpn_sid_index
= 0;
17950 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17951 vty_out(vty
, "bgp route-map delay-timer %u\n",
17952 bm
->rmap_update_timer
);
17954 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17955 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17956 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17957 vty_out(vty
, " %d", bm
->v_establish_wait
);
17958 vty_out(vty
, "\n");
17961 if (bm
->wait_for_fib
)
17962 vty_out(vty
, "bgp suppress-fib-pending\n");
17964 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17965 vty_out(vty
, "bgp graceful-shutdown\n");
17967 /* No-RIB (Zebra) option flag configuration */
17968 if (bgp_option_check(BGP_OPT_NO_FIB
))
17969 vty_out(vty
, "bgp no-rib\n");
17971 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17972 vty_out(vty
, "bgp send-extra-data zebra\n");
17974 /* BGP session DSCP value */
17975 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17976 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17978 /* BGP InQ limit */
17979 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
17980 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17982 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
17983 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
17985 /* BGP configuration. */
17986 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17988 /* skip all auto created vrf as they dont have user config */
17989 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17992 /* Router bgp ASN */
17993 vty_out(vty
, "router bgp %s", bgp
->as_pretty
);
17996 vty_out(vty
, " %s %s",
17997 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17998 ? "view" : "vrf", bgp
->name
);
17999 vty_out(vty
, "\n");
18001 /* BGP fast-external-failover. */
18002 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
18003 vty_out(vty
, " no bgp fast-external-failover\n");
18005 /* BGP router ID. */
18006 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
18007 vty_out(vty
, " bgp router-id %pI4\n",
18008 &bgp
->router_id_static
);
18010 /* Suppress fib pending */
18011 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
18012 vty_out(vty
, " bgp suppress-fib-pending\n");
18014 /* BGP log-neighbor-changes. */
18015 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18016 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
18017 vty_out(vty
, " %sbgp log-neighbor-changes\n",
18018 CHECK_FLAG(bgp
->flags
,
18019 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18023 /* BGP configuration. */
18024 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
18025 vty_out(vty
, " bgp always-compare-med\n");
18027 /* RFC8212 default eBGP policy. */
18028 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
18029 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
18030 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
18031 CHECK_FLAG(bgp
->flags
,
18032 BGP_FLAG_EBGP_REQUIRES_POLICY
)
18036 /* draft-ietf-idr-deprecate-as-set-confed-set */
18037 if (bgp
->reject_as_sets
)
18038 vty_out(vty
, " bgp reject-as-sets\n");
18040 /* Suppress duplicate updates if the route actually not changed
18042 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
18043 != SAVE_BGP_SUPPRESS_DUPLICATES
)
18044 vty_out(vty
, " %sbgp suppress-duplicates\n",
18045 CHECK_FLAG(bgp
->flags
,
18046 BGP_FLAG_SUPPRESS_DUPLICATES
)
18050 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
18052 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
18053 SAVE_BGP_HARD_ADMIN_RESET
)
18054 vty_out(vty
, " %sbgp hard-administrative-reset\n",
18055 CHECK_FLAG(bgp
->flags
,
18056 BGP_FLAG_HARD_ADMIN_RESET
)
18060 /* BGP default <afi>-<safi> */
18061 FOREACH_AFI_SAFI (afi
, safi
) {
18062 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
18063 if (!bgp
->default_af
[afi
][safi
])
18064 vty_out(vty
, " no bgp default %s\n",
18065 get_bgp_default_af_flag(afi
,
18067 } else if (bgp
->default_af
[afi
][safi
])
18068 vty_out(vty
, " bgp default %s\n",
18069 get_bgp_default_af_flag(afi
, safi
));
18072 /* BGP default local-preference. */
18073 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18074 vty_out(vty
, " bgp default local-preference %u\n",
18075 bgp
->default_local_pref
);
18077 /* BGP default show-hostname */
18078 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18079 != SAVE_BGP_SHOW_HOSTNAME
)
18080 vty_out(vty
, " %sbgp default show-hostname\n",
18081 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18085 /* BGP default show-nexthop-hostname */
18086 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18087 != SAVE_BGP_SHOW_HOSTNAME
)
18088 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18089 CHECK_FLAG(bgp
->flags
,
18090 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18094 /* BGP default subgroup-pkt-queue-max. */
18095 if (bgp
->default_subgroup_pkt_queue_max
18096 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18097 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18098 bgp
->default_subgroup_pkt_queue_max
);
18100 /* BGP client-to-client reflection. */
18101 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18102 vty_out(vty
, " no bgp client-to-client reflection\n");
18104 /* BGP cluster ID. */
18105 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18106 vty_out(vty
, " bgp cluster-id %pI4\n",
18109 /* Disable ebgp connected nexthop check */
18110 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18112 " bgp disable-ebgp-connected-route-check\n");
18114 /* Confederation identifier*/
18115 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18116 vty_out(vty
, " bgp confederation identifier %u\n",
18119 /* Confederation peer */
18120 if (bgp
->confed_peers_cnt
> 0) {
18123 vty_out(vty
, " bgp confederation peers");
18125 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18126 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18128 vty_out(vty
, "\n");
18131 /* BGP deterministic-med. */
18132 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18133 != SAVE_BGP_DETERMINISTIC_MED
)
18134 vty_out(vty
, " %sbgp deterministic-med\n",
18135 CHECK_FLAG(bgp
->flags
,
18136 BGP_FLAG_DETERMINISTIC_MED
)
18140 /* BGP update-delay. */
18141 bgp_config_write_update_delay(vty
, bgp
);
18143 if (bgp
->v_maxmed_onstartup
18144 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18145 vty_out(vty
, " bgp max-med on-startup %u",
18146 bgp
->v_maxmed_onstartup
);
18147 if (bgp
->maxmed_onstartup_value
18148 != BGP_MAXMED_VALUE_DEFAULT
)
18149 vty_out(vty
, " %u",
18150 bgp
->maxmed_onstartup_value
);
18151 vty_out(vty
, "\n");
18153 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18154 vty_out(vty
, " bgp max-med administrative");
18155 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18156 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18157 vty_out(vty
, "\n");
18161 bgp_config_write_wpkt_quanta(vty
, bgp
);
18163 bgp_config_write_rpkt_quanta(vty
, bgp
);
18165 /* coalesce time */
18166 bgp_config_write_coalesce_time(vty
, bgp
);
18168 /* BGP per-instance graceful-shutdown */
18169 /* BGP-wide settings and per-instance settings are mutually
18172 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18173 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18174 vty_out(vty
, " bgp graceful-shutdown\n");
18176 /* Long-lived Graceful Restart */
18177 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18179 " bgp long-lived-graceful-restart stale-time %u\n",
18180 bgp
->llgr_stale_time
);
18182 /* BGP graceful-restart. */
18183 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18185 " bgp graceful-restart stalepath-time %u\n",
18186 bgp
->stalepath_time
);
18188 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18189 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18190 bgp
->restart_time
);
18192 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18193 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18194 vty_out(vty
, " %sbgp graceful-restart notification\n",
18195 CHECK_FLAG(bgp
->flags
,
18196 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18200 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18202 " bgp graceful-restart select-defer-time %u\n",
18203 bgp
->select_defer_time
);
18205 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18206 vty_out(vty
, " bgp graceful-restart\n");
18208 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18209 vty_out(vty
, " bgp graceful-restart-disable\n");
18211 /* BGP graceful-restart Preserve State F bit. */
18212 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18214 " bgp graceful-restart preserve-fw-state\n");
18216 /* BGP TCP keepalive */
18217 bgp_config_tcp_keepalive(vty
, bgp
);
18219 /* Stale timer for RIB */
18220 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18222 " bgp graceful-restart rib-stale-time %u\n",
18223 bgp
->rib_stale_time
);
18225 /* BGP bestpath method. */
18226 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18227 vty_out(vty
, " bgp bestpath as-path ignore\n");
18228 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18229 vty_out(vty
, " bgp bestpath as-path confed\n");
18231 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18232 if (CHECK_FLAG(bgp
->flags
,
18233 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18235 " bgp bestpath as-path multipath-relax as-set\n");
18238 " bgp bestpath as-path multipath-relax\n");
18242 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18244 " bgp route-reflector allow-outbound-policy\n");
18246 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18247 vty_out(vty
, " bgp bestpath compare-routerid\n");
18248 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18249 vty_out(vty
, " bgp bestpath aigp\n");
18250 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18251 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18252 vty_out(vty
, " bgp bestpath med");
18253 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18254 vty_out(vty
, " confed");
18255 if (CHECK_FLAG(bgp
->flags
,
18256 BGP_FLAG_MED_MISSING_AS_WORST
))
18257 vty_out(vty
, " missing-as-worst");
18258 vty_out(vty
, "\n");
18261 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18263 " bgp bestpath peer-type multipath-relax\n");
18265 /* Link bandwidth handling. */
18266 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18267 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18268 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18269 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18270 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18271 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18273 /* BGP network import check. */
18274 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18275 != SAVE_BGP_IMPORT_CHECK
)
18276 vty_out(vty
, " %sbgp network import-check\n",
18277 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18281 /* BGP timers configuration. */
18282 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18283 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18284 vty_out(vty
, " timers bgp %u %u\n",
18285 bgp
->default_keepalive
, bgp
->default_holdtime
);
18287 /* BGP minimum holdtime configuration. */
18288 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18289 && bgp
->default_min_holdtime
!= 0)
18290 vty_out(vty
, " bgp minimum-holdtime %u\n",
18291 bgp
->default_min_holdtime
);
18293 /* Conditional advertisement timer configuration */
18294 if (bgp
->condition_check_period
18295 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18297 " bgp conditional-advertisement timer %u\n",
18298 bgp
->condition_check_period
);
18301 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18302 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18305 /* Normal neighbor configuration. */
18306 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18307 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18308 bgp_config_write_peer_global(vty
, bgp
, peer
);
18311 /* listen range and limit for dynamic BGP neighbors */
18312 bgp_config_write_listen(vty
, bgp
);
18315 * BGP default autoshutdown neighbors
18317 * This must be placed after any peer and peer-group
18318 * configuration, to avoid setting all peers to shutdown after
18319 * a daemon restart, which is undesired behavior. (see #2286)
18321 if (bgp
->autoshutdown
)
18322 vty_out(vty
, " bgp default shutdown\n");
18324 /* BGP instance administrative shutdown */
18325 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18326 vty_out(vty
, " bgp shutdown\n");
18328 if (bgp
->allow_martian
)
18329 vty_out(vty
, " bgp allow-martian-nexthop\n");
18331 if (bgp
->fast_convergence
)
18332 vty_out(vty
, " bgp fast-convergence\n");
18334 if (bgp
->srv6_enabled
) {
18335 vty_frame(vty
, " !\n segment-routing srv6\n");
18336 if (strlen(bgp
->srv6_locator_name
))
18337 vty_out(vty
, " locator %s\n",
18338 bgp
->srv6_locator_name
);
18339 vty_endframe(vty
, " exit\n");
18342 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18343 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18344 vty_out(vty
, " sid vpn per-vrf export auto\n");
18345 } else if (tovpn_sid_index
!= 0) {
18346 vty_out(vty
, " sid vpn per-vrf export %d\n",
18350 /* IPv4 unicast configuration. */
18351 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18353 /* IPv4 multicast configuration. */
18354 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18356 /* IPv4 labeled-unicast configuration. */
18357 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18359 /* IPv4 VPN configuration. */
18360 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18362 /* ENCAPv4 configuration. */
18363 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18365 /* FLOWSPEC v4 configuration. */
18366 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18368 /* IPv6 unicast configuration. */
18369 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18371 /* IPv6 multicast configuration. */
18372 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18374 /* IPv6 labeled-unicast configuration. */
18375 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18376 SAFI_LABELED_UNICAST
);
18378 /* IPv6 VPN configuration. */
18379 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18381 /* ENCAPv6 configuration. */
18382 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18384 /* FLOWSPEC v6 configuration. */
18385 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18387 /* EVPN configuration. */
18388 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18390 hook_call(bgp_inst_config_write
, bgp
, vty
);
18392 #ifdef ENABLE_BGP_VNC
18393 bgp_rfapi_cfg_write(vty
, bgp
);
18396 vty_out(vty
, "exit\n");
18397 vty_out(vty
, "!\n");
18403 /* BGP node structure. */
18404 static struct cmd_node bgp_node
= {
18407 .parent_node
= CONFIG_NODE
,
18408 .prompt
= "%s(config-router)# ",
18409 .config_write
= bgp_config_write
,
18412 static struct cmd_node bgp_ipv4_unicast_node
= {
18413 .name
= "bgp ipv4 unicast",
18414 .node
= BGP_IPV4_NODE
,
18415 .parent_node
= BGP_NODE
,
18416 .prompt
= "%s(config-router-af)# ",
18420 static struct cmd_node bgp_ipv4_multicast_node
= {
18421 .name
= "bgp ipv4 multicast",
18422 .node
= BGP_IPV4M_NODE
,
18423 .parent_node
= BGP_NODE
,
18424 .prompt
= "%s(config-router-af)# ",
18428 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18429 .name
= "bgp ipv4 labeled unicast",
18430 .node
= BGP_IPV4L_NODE
,
18431 .parent_node
= BGP_NODE
,
18432 .prompt
= "%s(config-router-af)# ",
18436 static struct cmd_node bgp_ipv6_unicast_node
= {
18437 .name
= "bgp ipv6 unicast",
18438 .node
= BGP_IPV6_NODE
,
18439 .parent_node
= BGP_NODE
,
18440 .prompt
= "%s(config-router-af)# ",
18444 static struct cmd_node bgp_ipv6_multicast_node
= {
18445 .name
= "bgp ipv6 multicast",
18446 .node
= BGP_IPV6M_NODE
,
18447 .parent_node
= BGP_NODE
,
18448 .prompt
= "%s(config-router-af)# ",
18452 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18453 .name
= "bgp ipv6 labeled unicast",
18454 .node
= BGP_IPV6L_NODE
,
18455 .parent_node
= BGP_NODE
,
18456 .prompt
= "%s(config-router-af)# ",
18460 static struct cmd_node bgp_vpnv4_node
= {
18461 .name
= "bgp vpnv4",
18462 .node
= BGP_VPNV4_NODE
,
18463 .parent_node
= BGP_NODE
,
18464 .prompt
= "%s(config-router-af)# ",
18468 static struct cmd_node bgp_vpnv6_node
= {
18469 .name
= "bgp vpnv6",
18470 .node
= BGP_VPNV6_NODE
,
18471 .parent_node
= BGP_NODE
,
18472 .prompt
= "%s(config-router-af-vpnv6)# ",
18476 static struct cmd_node bgp_evpn_node
= {
18477 .name
= "bgp evpn",
18478 .node
= BGP_EVPN_NODE
,
18479 .parent_node
= BGP_NODE
,
18480 .prompt
= "%s(config-router-evpn)# ",
18484 static struct cmd_node bgp_evpn_vni_node
= {
18485 .name
= "bgp evpn vni",
18486 .node
= BGP_EVPN_VNI_NODE
,
18487 .parent_node
= BGP_EVPN_NODE
,
18488 .prompt
= "%s(config-router-af-vni)# ",
18491 static struct cmd_node bgp_flowspecv4_node
= {
18492 .name
= "bgp ipv4 flowspec",
18493 .node
= BGP_FLOWSPECV4_NODE
,
18494 .parent_node
= BGP_NODE
,
18495 .prompt
= "%s(config-router-af)# ",
18499 static struct cmd_node bgp_flowspecv6_node
= {
18500 .name
= "bgp ipv6 flowspec",
18501 .node
= BGP_FLOWSPECV6_NODE
,
18502 .parent_node
= BGP_NODE
,
18503 .prompt
= "%s(config-router-af-vpnv6)# ",
18507 static struct cmd_node bgp_srv6_node
= {
18508 .name
= "bgp srv6",
18509 .node
= BGP_SRV6_NODE
,
18510 .parent_node
= BGP_NODE
,
18511 .prompt
= "%s(config-router-srv6)# ",
18514 static void community_list_vty(void);
18516 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18519 struct peer_group
*group
;
18520 struct listnode
*lnbgp
, *lnpeer
;
18522 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18523 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18525 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18529 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18533 struct listnode
*lnbgp
, *lnpeer
;
18535 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18536 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18537 /* only provide suggestions on the appropriate input
18539 * they'll otherwise show up multiple times */
18540 enum cmd_token_type match_type
;
18541 char *name
= peer
->host
;
18543 if (peer
->conf_if
) {
18544 match_type
= VARIABLE_TKN
;
18545 name
= peer
->conf_if
;
18546 } else if (strchr(peer
->host
, ':'))
18547 match_type
= IPV6_TKN
;
18549 match_type
= IPV4_TKN
;
18551 if (token
->type
!= match_type
)
18554 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18559 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18561 bgp_ac_peer(comps
, token
);
18563 if (token
->type
== VARIABLE_TKN
)
18564 bgp_ac_peergroup(comps
, token
);
18567 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18568 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18569 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18570 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18571 {.completions
= NULL
}};
18573 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18574 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18575 {.completions
= NULL
} };
18577 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18579 static struct thread
*t_bgp_cfg
;
18581 bool bgp_config_inprocess(void)
18583 return thread_is_scheduled(t_bgp_cfg
);
18586 static void bgp_config_finish(struct thread
*t
)
18588 struct listnode
*node
;
18591 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18592 hook_call(bgp_config_end
, bgp
);
18595 static void bgp_config_start(void)
18597 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18598 THREAD_OFF(t_bgp_cfg
);
18599 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18600 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18603 /* When we receive a hook the configuration is read,
18604 * we start a timer to make sure we postpone sending
18605 * EoR before route-maps are processed.
18606 * This is especially valid if using `bgp route-map delay-timer`.
18608 static void bgp_config_end(void)
18610 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18611 uint32_t bgp_post_config_delay
=
18612 thread_is_scheduled(bm
->t_rmap_update
)
18613 ? thread_timer_remain_second(bm
->t_rmap_update
)
18614 : BGP_POST_CONFIG_DELAY_SECONDS
;
18616 /* If BGP config processing thread isn't running, then
18617 * we can return and rely it's properly handled.
18619 if (!bgp_config_inprocess())
18622 THREAD_OFF(t_bgp_cfg
);
18624 /* Start a new timer to make sure we don't send EoR
18625 * before route-maps are processed.
18627 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18628 bgp_post_config_delay
, &t_bgp_cfg
);
18631 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18634 struct interface
*ifp
;
18635 struct bgp_interface
*iifp
;
18637 FOR_ALL_INTERFACES (vrf
, ifp
) {
18642 if_vty_config_start(vty
, ifp
);
18644 if (CHECK_FLAG(iifp
->flags
,
18645 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18646 vty_out(vty
, " mpls bgp forwarding\n");
18650 if_vty_config_end(vty
);
18656 /* Configuration write function for bgpd. */
18657 static int config_write_interface(struct vty
*vty
)
18660 struct vrf
*vrf
= NULL
;
18662 /* Display all VRF aware OSPF interface configuration */
18663 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18664 write
+= config_write_interface_one(vty
, vrf
);
18670 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18671 "[no$no] mpls bgp forwarding",
18672 NO_STR MPLS_STR BGP_STR
18673 "Enable MPLS forwarding for eBGP directly connected peers\n")
18676 struct bgp_interface
*iifp
;
18678 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18681 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18682 return CMD_WARNING_CONFIG_FAILED
;
18684 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18685 if (check
!= !no
) {
18687 UNSET_FLAG(iifp
->flags
,
18688 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18690 SET_FLAG(iifp
->flags
,
18691 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18692 /* trigger a nht update on eBGP sessions */
18693 if (if_is_operative(ifp
))
18694 bgp_nht_ifp_up(ifp
);
18696 return CMD_SUCCESS
;
18699 DEFPY (bgp_inq_limit
,
18701 "bgp input-queue-limit (1-4294967295)$limit",
18703 "Set the BGP Input Queue limit for all peers when message parsing\n"
18704 "Input-Queue limit\n")
18706 bm
->inq_limit
= limit
;
18708 return CMD_SUCCESS
;
18711 DEFPY (no_bgp_inq_limit
,
18712 no_bgp_inq_limit_cmd
,
18713 "no bgp input-queue-limit [(1-4294967295)$limit]",
18716 "Set the BGP Input Queue limit for all peers when message parsing\n"
18717 "Input-Queue limit\n")
18719 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18721 return CMD_SUCCESS
;
18724 DEFPY (bgp_outq_limit
,
18725 bgp_outq_limit_cmd
,
18726 "bgp output-queue-limit (1-4294967295)$limit",
18728 "Set the BGP Output Queue limit for all peers when message parsing\n"
18729 "Output-Queue limit\n")
18731 bm
->outq_limit
= limit
;
18733 return CMD_SUCCESS
;
18736 DEFPY (no_bgp_outq_limit
,
18737 no_bgp_outq_limit_cmd
,
18738 "no bgp output-queue-limit [(1-4294967295)$limit]",
18741 "Set the BGP Output Queue limit for all peers when message parsing\n"
18742 "Output-Queue limit\n")
18744 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18746 return CMD_SUCCESS
;
18750 /* Initialization of BGP interface. */
18751 static void bgp_vty_if_init(void)
18753 /* Install interface node. */
18754 if_cmd_init(config_write_interface
);
18756 /* "mpls bgp forwarding" commands. */
18757 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18760 void bgp_vty_init(void)
18762 cmd_variable_handler_register(bgp_var_neighbor
);
18763 cmd_variable_handler_register(bgp_var_peergroup
);
18765 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18767 /* Install bgp top node. */
18768 install_node(&bgp_node
);
18769 install_node(&bgp_ipv4_unicast_node
);
18770 install_node(&bgp_ipv4_multicast_node
);
18771 install_node(&bgp_ipv4_labeled_unicast_node
);
18772 install_node(&bgp_ipv6_unicast_node
);
18773 install_node(&bgp_ipv6_multicast_node
);
18774 install_node(&bgp_ipv6_labeled_unicast_node
);
18775 install_node(&bgp_vpnv4_node
);
18776 install_node(&bgp_vpnv6_node
);
18777 install_node(&bgp_evpn_node
);
18778 install_node(&bgp_evpn_vni_node
);
18779 install_node(&bgp_flowspecv4_node
);
18780 install_node(&bgp_flowspecv6_node
);
18781 install_node(&bgp_srv6_node
);
18783 /* Install default VTY commands to new nodes. */
18784 install_default(BGP_NODE
);
18785 install_default(BGP_IPV4_NODE
);
18786 install_default(BGP_IPV4M_NODE
);
18787 install_default(BGP_IPV4L_NODE
);
18788 install_default(BGP_IPV6_NODE
);
18789 install_default(BGP_IPV6M_NODE
);
18790 install_default(BGP_IPV6L_NODE
);
18791 install_default(BGP_VPNV4_NODE
);
18792 install_default(BGP_VPNV6_NODE
);
18793 install_default(BGP_FLOWSPECV4_NODE
);
18794 install_default(BGP_FLOWSPECV6_NODE
);
18795 install_default(BGP_EVPN_NODE
);
18796 install_default(BGP_EVPN_VNI_NODE
);
18797 install_default(BGP_SRV6_NODE
);
18799 /* "global bgp inq-limit command */
18800 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18801 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18802 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18803 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18805 /* "bgp local-mac" hidden commands. */
18806 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18807 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18809 /* "bgp suppress-fib-pending" global */
18810 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18812 /* bgp route-map delay-timer commands. */
18813 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18814 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18816 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18818 /* bgp fast-convergence command */
18819 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18820 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18822 /* global bgp update-delay command */
18823 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18824 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18826 /* global bgp graceful-shutdown command */
18827 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18828 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18830 /* Dummy commands (Currently not supported) */
18831 install_element(BGP_NODE
, &no_synchronization_cmd
);
18832 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18834 /* "router bgp" commands. */
18835 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18837 /* "no router bgp" commands. */
18838 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18840 /* "bgp session-dscp command */
18841 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18842 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18844 /* "bgp router-id" commands. */
18845 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18846 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18848 /* "bgp suppress-fib-pending" command */
18849 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18851 /* "bgp cluster-id" commands. */
18852 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18853 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18855 /* "bgp no-rib" commands. */
18856 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18857 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18859 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18861 /* "bgp confederation" commands. */
18862 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18863 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18865 /* "bgp confederation peers" commands. */
18866 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18867 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18869 /* bgp max-med command */
18870 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18871 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18872 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18873 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18874 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18876 /* "neighbor role" commands. */
18877 install_element(BGP_NODE
, &neighbor_role_cmd
);
18878 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18879 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18881 /* "neighbor aigp" commands. */
18882 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18884 /* "neighbor graceful-shutdown" command */
18885 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18887 /* bgp disable-ebgp-connected-nh-check */
18888 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18889 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18891 /* bgp update-delay command */
18892 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18893 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18895 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18896 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18898 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18899 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18901 /* "maximum-paths" commands. */
18902 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18903 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18904 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18905 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18906 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18907 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18908 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18909 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18910 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18911 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18912 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18913 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18914 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18915 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18916 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18918 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18919 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18921 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18922 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18923 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18924 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18925 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18926 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18927 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18929 /* "timers bgp" commands. */
18930 install_element(BGP_NODE
, &bgp_timers_cmd
);
18931 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18933 /* "minimum-holdtime" commands. */
18934 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18935 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18937 /* route-map delay-timer commands - per instance for backwards compat.
18939 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18940 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18942 /* "bgp client-to-client reflection" commands */
18943 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18944 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18946 /* "bgp always-compare-med" commands */
18947 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18948 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18950 /* bgp ebgp-requires-policy */
18951 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18952 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18954 /* bgp suppress-duplicates */
18955 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18956 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18958 /* bgp reject-as-sets */
18959 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18960 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18962 /* "bgp deterministic-med" commands */
18963 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18964 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18966 /* "bgp graceful-restart" command */
18967 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18968 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18970 /* "bgp graceful-restart-disable" command */
18971 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18972 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18974 /* "neighbor a:b:c:d graceful-restart" command */
18975 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18976 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18978 /* "neighbor a:b:c:d graceful-restart-disable" command */
18979 install_element(BGP_NODE
,
18980 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18981 install_element(BGP_NODE
,
18982 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18984 /* "neighbor a:b:c:d graceful-restart-helper" command */
18985 install_element(BGP_NODE
,
18986 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18987 install_element(BGP_NODE
,
18988 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18990 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18991 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18992 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18993 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18994 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18995 install_element(BGP_NODE
,
18996 &no_bgp_graceful_restart_select_defer_time_cmd
);
18997 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18998 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18999 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
19001 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
19002 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
19003 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
19004 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
19006 /* "bgp graceful-shutdown" commands */
19007 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
19008 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
19010 /* "bgp hard-administrative-reset" commands */
19011 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
19013 /* "bgp long-lived-graceful-restart" commands */
19014 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
19015 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
19017 /* "bgp fast-external-failover" commands */
19018 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
19019 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
19021 /* "bgp bestpath aigp" commands */
19022 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
19024 /* "bgp bestpath compare-routerid" commands */
19025 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
19026 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
19028 /* "bgp bestpath as-path ignore" commands */
19029 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
19030 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
19032 /* "bgp bestpath as-path confed" commands */
19033 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
19034 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
19036 /* "bgp bestpath as-path multipath-relax" commands */
19037 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
19038 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
19040 /* "bgp bestpath peer-type multipath-relax" commands */
19041 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
19042 install_element(BGP_NODE
,
19043 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
19045 /* "bgp log-neighbor-changes" commands */
19046 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
19047 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
19049 /* "bgp bestpath med" commands */
19050 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
19051 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
19053 /* "bgp bestpath bandwidth" commands */
19054 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
19055 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
19057 /* "no bgp default <afi>-<safi>" commands. */
19058 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
19060 /* "bgp network import-check" commands. */
19061 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
19062 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
19063 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
19065 /* "bgp default local-preference" commands. */
19066 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19067 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19069 /* bgp default show-hostname */
19070 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19071 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19073 /* bgp default show-nexthop-hostname */
19074 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19075 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19077 /* "bgp default subgroup-pkt-queue-max" commands. */
19078 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19079 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19081 /* bgp ibgp-allow-policy-mods command */
19082 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19083 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19085 /* "bgp listen limit" commands. */
19086 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19087 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19089 /* "bgp listen range" commands. */
19090 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19091 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19093 /* "bgp default shutdown" command */
19094 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19096 /* "bgp shutdown" commands */
19097 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19098 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19099 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19100 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19102 /* "neighbor remote-as" commands. */
19103 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19104 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19105 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19106 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19107 install_element(BGP_NODE
,
19108 &neighbor_interface_v6only_config_remote_as_cmd
);
19109 install_element(BGP_NODE
, &no_neighbor_cmd
);
19110 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19112 /* "neighbor peer-group" commands. */
19113 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19114 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19115 install_element(BGP_NODE
,
19116 &no_neighbor_interface_peer_group_remote_as_cmd
);
19118 /* "neighbor local-as" commands. */
19119 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19120 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19121 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19122 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19124 /* "neighbor solo" commands. */
19125 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19126 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19128 /* "neighbor password" commands. */
19129 install_element(BGP_NODE
, &neighbor_password_cmd
);
19130 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19132 /* "neighbor activate" commands. */
19133 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19134 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19135 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19136 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19137 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19138 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19139 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19140 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19141 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19142 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19143 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19144 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19146 /* "no neighbor activate" commands. */
19147 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19148 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19149 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19150 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19151 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19152 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19153 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19154 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19155 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19156 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19157 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19158 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19160 /* "neighbor peer-group" set commands. */
19161 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19162 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19163 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19164 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19165 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19166 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19167 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19168 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19169 install_element(BGP_FLOWSPECV4_NODE
,
19170 &neighbor_set_peer_group_hidden_cmd
);
19171 install_element(BGP_FLOWSPECV6_NODE
,
19172 &neighbor_set_peer_group_hidden_cmd
);
19174 /* "no neighbor peer-group unset" commands. */
19175 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19176 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19177 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19178 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19179 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19180 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19181 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19182 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19183 install_element(BGP_FLOWSPECV4_NODE
,
19184 &no_neighbor_set_peer_group_hidden_cmd
);
19185 install_element(BGP_FLOWSPECV6_NODE
,
19186 &no_neighbor_set_peer_group_hidden_cmd
);
19188 /* "neighbor softreconfiguration inbound" commands.*/
19189 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19190 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19191 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19192 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19193 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19194 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19195 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19196 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19197 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19198 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19199 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19200 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19201 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19202 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19203 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19204 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19205 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19206 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19207 install_element(BGP_FLOWSPECV4_NODE
,
19208 &neighbor_soft_reconfiguration_cmd
);
19209 install_element(BGP_FLOWSPECV4_NODE
,
19210 &no_neighbor_soft_reconfiguration_cmd
);
19211 install_element(BGP_FLOWSPECV6_NODE
,
19212 &neighbor_soft_reconfiguration_cmd
);
19213 install_element(BGP_FLOWSPECV6_NODE
,
19214 &no_neighbor_soft_reconfiguration_cmd
);
19215 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19216 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19218 /* "neighbor attribute-unchanged" commands. */
19219 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19220 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19221 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19222 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19223 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19224 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19225 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19226 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19227 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19228 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19229 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19230 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19231 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19232 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19233 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19234 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19235 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19236 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19238 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19239 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19241 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19242 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19243 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19244 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19246 /* "nexthop-local unchanged" commands */
19247 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19248 install_element(BGP_IPV6_NODE
,
19249 &no_neighbor_nexthop_local_unchanged_cmd
);
19251 /* "neighbor next-hop-self" commands. */
19252 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19253 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19254 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19255 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19256 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19257 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19258 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19259 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19260 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19261 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19262 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19263 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19264 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19265 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19266 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19267 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19268 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19269 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19270 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19271 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19273 /* "neighbor next-hop-self force" commands. */
19274 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19275 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19276 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19277 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19278 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19279 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19280 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19281 install_element(BGP_IPV4_NODE
,
19282 &no_neighbor_nexthop_self_all_hidden_cmd
);
19283 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19284 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19285 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19286 install_element(BGP_IPV4M_NODE
,
19287 &no_neighbor_nexthop_self_all_hidden_cmd
);
19288 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19289 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19290 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19291 install_element(BGP_IPV4L_NODE
,
19292 &no_neighbor_nexthop_self_all_hidden_cmd
);
19293 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19294 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19295 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19296 install_element(BGP_IPV6_NODE
,
19297 &no_neighbor_nexthop_self_all_hidden_cmd
);
19298 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19299 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19300 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19301 install_element(BGP_IPV6M_NODE
,
19302 &no_neighbor_nexthop_self_all_hidden_cmd
);
19303 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19304 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19305 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19306 install_element(BGP_IPV6L_NODE
,
19307 &no_neighbor_nexthop_self_all_hidden_cmd
);
19308 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19309 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19310 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19311 install_element(BGP_VPNV4_NODE
,
19312 &no_neighbor_nexthop_self_all_hidden_cmd
);
19313 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19314 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19315 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19316 install_element(BGP_VPNV6_NODE
,
19317 &no_neighbor_nexthop_self_all_hidden_cmd
);
19318 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19319 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19321 /* "neighbor as-override" commands. */
19322 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19323 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19324 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19325 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19326 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19327 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19328 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19329 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19330 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19331 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19332 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19333 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19334 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19335 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19336 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19337 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19338 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19339 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19341 /* "neighbor remove-private-AS" commands. */
19342 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19343 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19344 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19345 install_element(BGP_NODE
,
19346 &no_neighbor_remove_private_as_all_hidden_cmd
);
19347 install_element(BGP_NODE
,
19348 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19349 install_element(BGP_NODE
,
19350 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19351 install_element(BGP_NODE
,
19352 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19355 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19356 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19357 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19358 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19359 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19360 install_element(BGP_IPV4_NODE
,
19361 &neighbor_remove_private_as_replace_as_cmd
);
19362 install_element(BGP_IPV4_NODE
,
19363 &no_neighbor_remove_private_as_replace_as_cmd
);
19364 install_element(BGP_IPV4_NODE
,
19365 &neighbor_remove_private_as_all_replace_as_cmd
);
19366 install_element(BGP_IPV4_NODE
,
19367 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19368 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19369 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19370 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19371 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19372 install_element(BGP_IPV4M_NODE
,
19373 &neighbor_remove_private_as_replace_as_cmd
);
19374 install_element(BGP_IPV4M_NODE
,
19375 &no_neighbor_remove_private_as_replace_as_cmd
);
19376 install_element(BGP_IPV4M_NODE
,
19377 &neighbor_remove_private_as_all_replace_as_cmd
);
19378 install_element(BGP_IPV4M_NODE
,
19379 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19380 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19381 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19382 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19383 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19384 install_element(BGP_IPV4L_NODE
,
19385 &neighbor_remove_private_as_replace_as_cmd
);
19386 install_element(BGP_IPV4L_NODE
,
19387 &no_neighbor_remove_private_as_replace_as_cmd
);
19388 install_element(BGP_IPV4L_NODE
,
19389 &neighbor_remove_private_as_all_replace_as_cmd
);
19390 install_element(BGP_IPV4L_NODE
,
19391 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19392 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19393 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19394 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19395 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19396 install_element(BGP_IPV6_NODE
,
19397 &neighbor_remove_private_as_replace_as_cmd
);
19398 install_element(BGP_IPV6_NODE
,
19399 &no_neighbor_remove_private_as_replace_as_cmd
);
19400 install_element(BGP_IPV6_NODE
,
19401 &neighbor_remove_private_as_all_replace_as_cmd
);
19402 install_element(BGP_IPV6_NODE
,
19403 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19404 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19405 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19406 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19407 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19408 install_element(BGP_IPV6M_NODE
,
19409 &neighbor_remove_private_as_replace_as_cmd
);
19410 install_element(BGP_IPV6M_NODE
,
19411 &no_neighbor_remove_private_as_replace_as_cmd
);
19412 install_element(BGP_IPV6M_NODE
,
19413 &neighbor_remove_private_as_all_replace_as_cmd
);
19414 install_element(BGP_IPV6M_NODE
,
19415 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19416 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19417 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19418 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19419 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19420 install_element(BGP_IPV6L_NODE
,
19421 &neighbor_remove_private_as_replace_as_cmd
);
19422 install_element(BGP_IPV6L_NODE
,
19423 &no_neighbor_remove_private_as_replace_as_cmd
);
19424 install_element(BGP_IPV6L_NODE
,
19425 &neighbor_remove_private_as_all_replace_as_cmd
);
19426 install_element(BGP_IPV6L_NODE
,
19427 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19428 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19429 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19430 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19431 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19432 install_element(BGP_VPNV4_NODE
,
19433 &neighbor_remove_private_as_replace_as_cmd
);
19434 install_element(BGP_VPNV4_NODE
,
19435 &no_neighbor_remove_private_as_replace_as_cmd
);
19436 install_element(BGP_VPNV4_NODE
,
19437 &neighbor_remove_private_as_all_replace_as_cmd
);
19438 install_element(BGP_VPNV4_NODE
,
19439 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19440 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19441 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19442 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19443 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19444 install_element(BGP_VPNV6_NODE
,
19445 &neighbor_remove_private_as_replace_as_cmd
);
19446 install_element(BGP_VPNV6_NODE
,
19447 &no_neighbor_remove_private_as_replace_as_cmd
);
19448 install_element(BGP_VPNV6_NODE
,
19449 &neighbor_remove_private_as_all_replace_as_cmd
);
19450 install_element(BGP_VPNV6_NODE
,
19451 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19453 /* "neighbor send-community" commands.*/
19454 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19455 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19456 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19457 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19458 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19459 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19460 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19461 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19462 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19463 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19464 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19465 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19466 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19467 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19468 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19469 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19470 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19471 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19472 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19473 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19474 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19475 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19476 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19477 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19478 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19479 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19480 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19481 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19482 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19483 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19484 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19485 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19486 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19487 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19488 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19489 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19491 /* "neighbor route-reflector" commands.*/
19492 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19493 install_element(BGP_NODE
,
19494 &no_neighbor_route_reflector_client_hidden_cmd
);
19495 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19496 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19497 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19498 install_element(BGP_IPV4M_NODE
,
19499 &no_neighbor_route_reflector_client_cmd
);
19500 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19501 install_element(BGP_IPV4L_NODE
,
19502 &no_neighbor_route_reflector_client_cmd
);
19503 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19504 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19505 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19506 install_element(BGP_IPV6M_NODE
,
19507 &no_neighbor_route_reflector_client_cmd
);
19508 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19509 install_element(BGP_IPV6L_NODE
,
19510 &no_neighbor_route_reflector_client_cmd
);
19511 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19512 install_element(BGP_VPNV4_NODE
,
19513 &no_neighbor_route_reflector_client_cmd
);
19514 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19515 install_element(BGP_VPNV6_NODE
,
19516 &no_neighbor_route_reflector_client_cmd
);
19517 install_element(BGP_FLOWSPECV4_NODE
,
19518 &neighbor_route_reflector_client_cmd
);
19519 install_element(BGP_FLOWSPECV4_NODE
,
19520 &no_neighbor_route_reflector_client_cmd
);
19521 install_element(BGP_FLOWSPECV6_NODE
,
19522 &neighbor_route_reflector_client_cmd
);
19523 install_element(BGP_FLOWSPECV6_NODE
,
19524 &no_neighbor_route_reflector_client_cmd
);
19525 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19526 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19528 /* "neighbor route-server" commands.*/
19529 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19530 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19531 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19532 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19533 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19534 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19535 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19536 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19537 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19538 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19539 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19540 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19541 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19542 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19543 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19544 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19545 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19546 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19547 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19548 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19549 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19550 install_element(BGP_FLOWSPECV4_NODE
,
19551 &no_neighbor_route_server_client_cmd
);
19552 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19553 install_element(BGP_FLOWSPECV6_NODE
,
19554 &no_neighbor_route_server_client_cmd
);
19556 /* "neighbor disable-addpath-rx" commands. */
19557 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19558 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19559 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19560 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19561 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19562 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19563 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19564 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19565 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19566 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19567 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19568 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19569 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19570 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19571 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19572 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19574 /* "neighbor addpath-tx-all-paths" commands.*/
19575 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19576 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19577 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19578 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19579 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19580 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19581 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19582 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19583 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19584 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19585 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19586 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19587 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19588 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19589 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19590 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19591 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19592 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19594 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19595 install_element(BGP_NODE
,
19596 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19597 install_element(BGP_NODE
,
19598 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19599 install_element(BGP_IPV4_NODE
,
19600 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19601 install_element(BGP_IPV4_NODE
,
19602 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19603 install_element(BGP_IPV4M_NODE
,
19604 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19605 install_element(BGP_IPV4M_NODE
,
19606 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19607 install_element(BGP_IPV4L_NODE
,
19608 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19609 install_element(BGP_IPV4L_NODE
,
19610 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19611 install_element(BGP_IPV6_NODE
,
19612 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19613 install_element(BGP_IPV6_NODE
,
19614 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19615 install_element(BGP_IPV6M_NODE
,
19616 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19617 install_element(BGP_IPV6M_NODE
,
19618 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19619 install_element(BGP_IPV6L_NODE
,
19620 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19621 install_element(BGP_IPV6L_NODE
,
19622 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19623 install_element(BGP_VPNV4_NODE
,
19624 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19625 install_element(BGP_VPNV4_NODE
,
19626 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19627 install_element(BGP_VPNV6_NODE
,
19628 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19629 install_element(BGP_VPNV6_NODE
,
19630 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19632 /* "neighbor sender-as-path-loop-detection" commands. */
19633 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19634 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19636 /* "neighbor path-attribute discard" commands. */
19637 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19638 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19640 /* "neighbor passive" commands. */
19641 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19642 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19645 /* "neighbor shutdown" commands. */
19646 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19647 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19648 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19649 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19650 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19651 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19653 /* "neighbor capability extended-nexthop" commands.*/
19654 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19655 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19657 /* "neighbor capability orf prefix-list" commands.*/
19658 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19659 install_element(BGP_NODE
,
19660 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19661 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19662 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19663 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19664 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19665 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19666 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19667 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19668 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19669 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19670 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19671 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19672 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19674 /* "neighbor capability dynamic" commands.*/
19675 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19676 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19678 /* "neighbor dont-capability-negotiate" commands. */
19679 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19680 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19682 /* "neighbor ebgp-multihop" commands. */
19683 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19684 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19685 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19687 /* "neighbor disable-connected-check" commands. */
19688 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19689 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19691 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19692 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19693 install_element(BGP_NODE
,
19694 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19696 /* "neighbor extended-optional-parameters" commands. */
19697 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19698 install_element(BGP_NODE
,
19699 &no_neighbor_extended_optional_parameters_cmd
);
19701 /* "neighbor enforce-first-as" commands. */
19702 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19703 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19705 /* "neighbor description" commands. */
19706 install_element(BGP_NODE
, &neighbor_description_cmd
);
19707 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19708 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19710 /* "neighbor update-source" commands. "*/
19711 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19712 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19714 /* "neighbor default-originate" commands. */
19715 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19716 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19717 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19718 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19719 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19720 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19721 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19722 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19723 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19724 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19725 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19726 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19727 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19728 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19729 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19730 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19731 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19732 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19733 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19734 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19735 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19737 /* "neighbor port" commands. */
19738 install_element(BGP_NODE
, &neighbor_port_cmd
);
19739 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19741 /* "neighbor weight" commands. */
19742 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19743 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19745 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19746 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19747 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19748 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19749 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19750 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19751 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19752 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19753 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19754 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19755 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19756 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19757 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19758 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19759 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19760 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19762 /* "neighbor override-capability" commands. */
19763 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19764 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19766 /* "neighbor strict-capability-match" commands. */
19767 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19768 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19770 /* "neighbor timers" commands. */
19771 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19772 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19774 /* "neighbor timers connect" commands. */
19775 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19776 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19778 /* "neighbor timers delayopen" commands. */
19779 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19780 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19782 /* "neighbor advertisement-interval" commands. */
19783 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19784 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19786 /* "neighbor interface" commands. */
19787 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19788 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19790 /* "neighbor distribute" commands. */
19791 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19792 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19793 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19794 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19795 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19796 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19797 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19798 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19799 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19800 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19801 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19802 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19803 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19804 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19805 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19806 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19807 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19808 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19810 /* "neighbor prefix-list" commands. */
19811 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19812 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19813 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19814 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19815 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19816 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19817 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19818 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19819 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19820 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19821 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19822 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19823 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19824 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19825 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19826 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19827 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19828 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19829 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19830 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19831 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19832 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19834 /* "neighbor filter-list" commands. */
19835 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19836 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19837 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19838 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19839 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19840 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19841 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19842 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19843 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19844 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19845 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19846 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19847 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19848 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19849 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19850 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19851 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19852 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19853 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19854 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19855 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19856 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19858 /* "neighbor route-map" commands. */
19859 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19860 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19861 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19862 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19863 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19864 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19865 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19866 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19867 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19868 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19869 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19870 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19871 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19872 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19873 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19874 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19875 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19876 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19877 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19878 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19879 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19880 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19881 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19882 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19884 /* "neighbor unsuppress-map" commands. */
19885 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19886 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19887 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19888 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19889 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19890 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19891 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19892 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19893 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19894 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19895 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19896 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19897 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19898 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19899 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19900 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19901 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19902 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19904 /* "neighbor advertise-map" commands. */
19905 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19906 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19907 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19908 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19909 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19910 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19911 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19912 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19913 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19914 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19916 /* neighbor maximum-prefix-out commands. */
19917 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19918 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19919 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19920 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19921 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19922 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19923 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19924 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19925 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19926 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19927 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19928 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19929 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19930 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19931 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19932 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19933 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19934 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19936 /* "neighbor maximum-prefix" commands. */
19937 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19938 install_element(BGP_NODE
,
19939 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19940 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19941 install_element(BGP_NODE
,
19942 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19943 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19944 install_element(BGP_NODE
,
19945 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19946 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19947 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19948 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19949 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19950 install_element(BGP_IPV4_NODE
,
19951 &neighbor_maximum_prefix_threshold_warning_cmd
);
19952 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19953 install_element(BGP_IPV4_NODE
,
19954 &neighbor_maximum_prefix_threshold_restart_cmd
);
19955 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19956 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19957 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19958 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19959 install_element(BGP_IPV4M_NODE
,
19960 &neighbor_maximum_prefix_threshold_warning_cmd
);
19961 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19962 install_element(BGP_IPV4M_NODE
,
19963 &neighbor_maximum_prefix_threshold_restart_cmd
);
19964 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19965 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19966 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19967 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19968 install_element(BGP_IPV4L_NODE
,
19969 &neighbor_maximum_prefix_threshold_warning_cmd
);
19970 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19971 install_element(BGP_IPV4L_NODE
,
19972 &neighbor_maximum_prefix_threshold_restart_cmd
);
19973 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19974 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19975 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19976 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19977 install_element(BGP_IPV6_NODE
,
19978 &neighbor_maximum_prefix_threshold_warning_cmd
);
19979 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19980 install_element(BGP_IPV6_NODE
,
19981 &neighbor_maximum_prefix_threshold_restart_cmd
);
19982 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19983 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19984 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19985 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19986 install_element(BGP_IPV6M_NODE
,
19987 &neighbor_maximum_prefix_threshold_warning_cmd
);
19988 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19989 install_element(BGP_IPV6M_NODE
,
19990 &neighbor_maximum_prefix_threshold_restart_cmd
);
19991 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19992 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19993 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19994 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19995 install_element(BGP_IPV6L_NODE
,
19996 &neighbor_maximum_prefix_threshold_warning_cmd
);
19997 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19998 install_element(BGP_IPV6L_NODE
,
19999 &neighbor_maximum_prefix_threshold_restart_cmd
);
20000 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20001 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
20002 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20003 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20004 install_element(BGP_VPNV4_NODE
,
20005 &neighbor_maximum_prefix_threshold_warning_cmd
);
20006 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20007 install_element(BGP_VPNV4_NODE
,
20008 &neighbor_maximum_prefix_threshold_restart_cmd
);
20009 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20010 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
20011 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20012 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20013 install_element(BGP_VPNV6_NODE
,
20014 &neighbor_maximum_prefix_threshold_warning_cmd
);
20015 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20016 install_element(BGP_VPNV6_NODE
,
20017 &neighbor_maximum_prefix_threshold_restart_cmd
);
20018 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20020 /* "neighbor allowas-in" */
20021 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
20022 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
20023 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
20024 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
20025 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
20026 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
20027 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
20028 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
20029 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
20030 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
20031 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
20032 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
20033 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
20034 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
20035 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
20036 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
20037 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
20038 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
20039 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
20040 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
20042 /* neighbor accept-own */
20043 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
20044 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
20046 /* "neighbor soo" */
20047 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
20048 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
20049 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
20050 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
20051 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
20052 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
20053 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
20054 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
20055 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
20056 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
20057 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
20058 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
20059 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
20060 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
20061 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
20062 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
20063 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
20064 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
20066 /* address-family commands. */
20067 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20068 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20069 #ifdef KEEP_OLD_VPN_COMMANDS
20070 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20071 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20072 #endif /* KEEP_OLD_VPN_COMMANDS */
20074 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20076 /* "exit-address-family" command. */
20077 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20078 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20079 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20080 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20081 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20082 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20083 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20084 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20085 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20086 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20087 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20089 /* BGP retain all route-target */
20090 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20091 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20093 /* "clear ip bgp commands" */
20094 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20096 /* clear ip bgp prefix */
20097 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20098 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20099 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20101 /* "show [ip] bgp summary" commands. */
20102 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20103 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20104 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20105 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20106 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20107 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20108 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20110 /* "show [ip] bgp neighbors" commands. */
20111 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20113 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20115 /* "show [ip] bgp peer-group" commands. */
20116 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20118 /* "show [ip] bgp paths" commands. */
20119 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20121 /* "show [ip] bgp community" commands. */
20122 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20124 /* "show ip bgp large-community" commands. */
20125 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20126 /* "show [ip] bgp attribute-info" commands. */
20127 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20128 /* "show [ip] bgp route-leak" command */
20129 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20131 /* "redistribute" commands. */
20132 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20133 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20134 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20135 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20136 install_element(BGP_NODE
,
20137 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20138 install_element(BGP_NODE
,
20139 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20140 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20141 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20142 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20143 install_element(BGP_NODE
,
20144 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20145 install_element(BGP_NODE
,
20146 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20147 install_element(BGP_NODE
,
20148 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20149 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20150 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20151 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20152 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20153 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20154 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20155 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20156 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20157 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20158 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20159 install_element(BGP_IPV4_NODE
,
20160 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20161 install_element(BGP_IPV4_NODE
,
20162 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20163 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20164 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20165 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20166 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20167 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20168 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20170 /* import|export vpn [route-map RMAP_NAME] */
20171 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20172 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20174 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20175 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20177 /* ttl_security commands */
20178 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20179 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20181 /* "bgp tcp-keepalive" commands */
20182 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20183 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20185 /* "show [ip] bgp memory" commands. */
20186 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20188 /* "show bgp martian next-hop" */
20189 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20191 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20193 /* "show [ip] bgp views" commands. */
20194 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20196 /* "show [ip] bgp vrfs" commands. */
20197 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20199 /* Community-list. */
20200 community_list_vty();
20202 community_alias_vty();
20204 /* vpn-policy commands */
20205 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20206 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20207 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20208 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20209 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20210 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20211 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20212 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20213 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20214 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20215 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20216 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20218 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20219 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20221 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20222 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20223 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20224 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20225 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20226 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20227 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20228 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20229 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20230 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20232 /* tcp-mss command */
20233 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20234 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20236 /* srv6 commands */
20237 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20238 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20239 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20240 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20241 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20242 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20243 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20244 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20245 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20250 #include "memory.h"
20251 #include "bgp_regex.h"
20252 #include "bgp_clist.h"
20253 #include "bgp_ecommunity.h"
20255 /* VTY functions. */
20257 /* Direction value to string conversion. */
20258 static const char *community_direct_str(int direct
)
20261 case COMMUNITY_DENY
:
20263 case COMMUNITY_PERMIT
:
20270 /* Display error string. */
20271 static void community_list_perror(struct vty
*vty
, int ret
)
20274 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20275 vty_out(vty
, "%% Can't find community-list\n");
20277 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20278 vty_out(vty
, "%% Malformed community-list value\n");
20280 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20282 "%% Community name conflict, previously defined as standard community\n");
20284 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20286 "%% Community name conflict, previously defined as expanded community\n");
20291 /* "community-list" keyword help string. */
20292 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20294 /*community-list standard */
20295 DEFUN (community_list_standard
,
20296 bgp_community_list_standard_cmd
,
20297 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20300 "Community list number (standard)\n"
20301 "Add an standard community-list entry\n"
20302 "Community list name\n"
20303 "Sequence number of an entry\n"
20304 "Sequence number\n"
20305 "Specify community to reject\n"
20306 "Specify community to accept\n"
20309 char *cl_name_or_number
= NULL
;
20312 int style
= COMMUNITY_LIST_STANDARD
;
20315 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20316 seq
= argv
[idx
]->arg
;
20319 argv_find(argv
, argc
, "(1-99)", &idx
);
20320 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20321 cl_name_or_number
= argv
[idx
]->arg
;
20322 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20324 argv_find(argv
, argc
, "AA:NN", &idx
);
20325 char *str
= argv_concat(argv
, argc
, idx
);
20327 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20330 XFREE(MTYPE_TMP
, str
);
20333 /* Display error string. */
20334 community_list_perror(vty
, ret
);
20335 return CMD_WARNING_CONFIG_FAILED
;
20338 return CMD_SUCCESS
;
20341 DEFUN (no_community_list_standard_all
,
20342 no_bgp_community_list_standard_all_cmd
,
20343 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20347 "Community list number (standard)\n"
20348 "Add an standard community-list entry\n"
20349 "Community list name\n"
20350 "Sequence number of an entry\n"
20351 "Sequence number\n"
20352 "Specify community to reject\n"
20353 "Specify community to accept\n"
20356 char *cl_name_or_number
= NULL
;
20359 int style
= COMMUNITY_LIST_STANDARD
;
20363 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20364 seq
= argv
[idx
]->arg
;
20367 argv_find(argv
, argc
, "permit", &idx
);
20368 argv_find(argv
, argc
, "deny", &idx
);
20371 direct
= argv_find(argv
, argc
, "permit", &idx
)
20376 argv_find(argv
, argc
, "AA:NN", &idx
);
20377 str
= argv_concat(argv
, argc
, idx
);
20381 argv_find(argv
, argc
, "(1-99)", &idx
);
20382 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20383 cl_name_or_number
= argv
[idx
]->arg
;
20385 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20388 XFREE(MTYPE_TMP
, str
);
20391 community_list_perror(vty
, ret
);
20392 return CMD_WARNING_CONFIG_FAILED
;
20395 return CMD_SUCCESS
;
20398 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20399 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20400 NO_STR BGP_STR COMMUNITY_LIST_STR
20401 "Community list number (standard)\n"
20402 "Add an standard community-list entry\n"
20403 "Community list name\n")
20405 /*community-list expanded */
20406 DEFUN (community_list_expanded_all
,
20407 bgp_community_list_expanded_all_cmd
,
20408 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20411 "Community list number (expanded)\n"
20412 "Add an expanded community-list entry\n"
20413 "Community list name\n"
20414 "Sequence number of an entry\n"
20415 "Sequence number\n"
20416 "Specify community to reject\n"
20417 "Specify community to accept\n"
20420 char *cl_name_or_number
= NULL
;
20423 int style
= COMMUNITY_LIST_EXPANDED
;
20426 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20427 seq
= argv
[idx
]->arg
;
20431 argv_find(argv
, argc
, "(100-500)", &idx
);
20432 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20433 cl_name_or_number
= argv
[idx
]->arg
;
20434 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20436 argv_find(argv
, argc
, "AA:NN", &idx
);
20437 char *str
= argv_concat(argv
, argc
, idx
);
20439 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20442 XFREE(MTYPE_TMP
, str
);
20445 /* Display error string. */
20446 community_list_perror(vty
, ret
);
20447 return CMD_WARNING_CONFIG_FAILED
;
20450 return CMD_SUCCESS
;
20453 DEFUN (no_community_list_expanded_all
,
20454 no_bgp_community_list_expanded_all_cmd
,
20455 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20459 "Community list number (expanded)\n"
20460 "Add an expanded community-list entry\n"
20461 "Community list name\n"
20462 "Sequence number of an entry\n"
20463 "Sequence number\n"
20464 "Specify community to reject\n"
20465 "Specify community to accept\n"
20468 char *cl_name_or_number
= NULL
;
20472 int style
= COMMUNITY_LIST_EXPANDED
;
20475 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20476 seq
= argv
[idx
]->arg
;
20479 argv_find(argv
, argc
, "permit", &idx
);
20480 argv_find(argv
, argc
, "deny", &idx
);
20483 direct
= argv_find(argv
, argc
, "permit", &idx
)
20488 argv_find(argv
, argc
, "AA:NN", &idx
);
20489 str
= argv_concat(argv
, argc
, idx
);
20493 argv_find(argv
, argc
, "(100-500)", &idx
);
20494 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20495 cl_name_or_number
= argv
[idx
]->arg
;
20497 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20500 XFREE(MTYPE_TMP
, str
);
20503 community_list_perror(vty
, ret
);
20504 return CMD_WARNING_CONFIG_FAILED
;
20507 return CMD_SUCCESS
;
20510 ALIAS(no_community_list_expanded_all
,
20511 no_bgp_community_list_expanded_all_list_cmd
,
20512 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20513 NO_STR BGP_STR COMMUNITY_LIST_STR
20514 "Community list number (expanded)\n"
20515 "Add an expanded community-list entry\n"
20516 "Community list name\n")
20518 /* Return configuration string of community-list entry. */
20519 static const char *community_list_config_str(struct community_entry
*entry
)
20526 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20527 str
= community_str(entry
->u
.com
, false, false);
20528 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20529 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20531 str
= entry
->config
;
20536 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20538 struct community_entry
*entry
;
20540 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20541 if (entry
== list
->head
) {
20542 if (all_digit(list
->name
))
20543 vty_out(vty
, "Community %s list %s\n",
20544 entry
->style
== COMMUNITY_LIST_STANDARD
20546 : "(expanded) access",
20549 vty_out(vty
, "Named Community %s list %s\n",
20550 entry
->style
== COMMUNITY_LIST_STANDARD
20556 vty_out(vty
, " %s\n",
20557 community_direct_str(entry
->direct
));
20559 vty_out(vty
, " %s %s\n",
20560 community_direct_str(entry
->direct
),
20561 community_list_config_str(entry
));
20565 DEFUN (show_community_list
,
20566 show_bgp_community_list_cmd
,
20567 "show bgp community-list",
20570 "List community-list\n")
20572 struct community_list
*list
;
20573 struct community_list_master
*cm
;
20575 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20577 return CMD_SUCCESS
;
20579 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20580 community_list_show(vty
, list
);
20582 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20583 community_list_show(vty
, list
);
20585 return CMD_SUCCESS
;
20588 DEFUN (show_community_list_arg
,
20589 show_bgp_community_list_arg_cmd
,
20590 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20593 "List community-list\n"
20594 "Community-list number\n"
20595 "Community-list name\n"
20596 "Detailed information on community-list\n")
20598 int idx_comm_list
= 3;
20599 struct community_list
*list
;
20601 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20602 COMMUNITY_LIST_MASTER
);
20604 vty_out(vty
, "%% Can't find community-list\n");
20605 return CMD_WARNING
;
20608 community_list_show(vty
, list
);
20610 return CMD_SUCCESS
;
20614 * Large Community code.
20616 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20617 struct cmd_token
**argv
, int style
,
20618 int reject_all_digit_name
)
20627 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20628 seq
= argv
[idx
]->arg
;
20631 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20634 /* All digit name check. */
20636 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20637 argv_find(argv
, argc
, "(1-99)", &idx
);
20638 argv_find(argv
, argc
, "(100-500)", &idx
);
20639 cl_name
= argv
[idx
]->arg
;
20640 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20641 vty_out(vty
, "%% Community name cannot have all digits\n");
20642 return CMD_WARNING_CONFIG_FAILED
;
20646 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20647 argv_find(argv
, argc
, "LINE", &idx
);
20648 /* Concat community string argument. */
20650 str
= argv_concat(argv
, argc
, idx
);
20654 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20656 /* Free temporary community list string allocated by
20658 XFREE(MTYPE_TMP
, str
);
20661 community_list_perror(vty
, ret
);
20662 return CMD_WARNING_CONFIG_FAILED
;
20664 return CMD_SUCCESS
;
20667 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20668 struct cmd_token
**argv
, int style
)
20676 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20677 seq
= argv
[idx
]->arg
;
20680 argv_find(argv
, argc
, "permit", &idx
);
20681 argv_find(argv
, argc
, "deny", &idx
);
20684 /* Check the list direct. */
20685 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20686 direct
= COMMUNITY_PERMIT
;
20688 direct
= COMMUNITY_DENY
;
20691 argv_find(argv
, argc
, "LINE", &idx
);
20692 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20693 /* Concat community string argument. */
20694 str
= argv_concat(argv
, argc
, idx
);
20698 argv_find(argv
, argc
, "(1-99)", &idx
);
20699 argv_find(argv
, argc
, "(100-500)", &idx
);
20700 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20702 /* Unset community list. */
20703 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20706 /* Free temporary community list string allocated by
20708 XFREE(MTYPE_TMP
, str
);
20711 community_list_perror(vty
, ret
);
20712 return CMD_WARNING_CONFIG_FAILED
;
20715 return CMD_SUCCESS
;
20718 /* "large-community-list" keyword help string. */
20719 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20720 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20722 DEFUN (lcommunity_list_standard
,
20723 bgp_lcommunity_list_standard_cmd
,
20724 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20726 LCOMMUNITY_LIST_STR
20727 "Large Community list number (standard)\n"
20728 "Sequence number of an entry\n"
20729 "Sequence number\n"
20730 "Specify large community to reject\n"
20731 "Specify large community to accept\n"
20732 LCOMMUNITY_VAL_STR
)
20734 return lcommunity_list_set_vty(vty
, argc
, argv
,
20735 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20738 DEFUN (lcommunity_list_expanded
,
20739 bgp_lcommunity_list_expanded_cmd
,
20740 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20742 LCOMMUNITY_LIST_STR
20743 "Large Community list number (expanded)\n"
20744 "Sequence number of an entry\n"
20745 "Sequence number\n"
20746 "Specify large community to reject\n"
20747 "Specify large community to accept\n"
20748 "An ordered list as a regular-expression\n")
20750 return lcommunity_list_set_vty(vty
, argc
, argv
,
20751 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20754 DEFUN (lcommunity_list_name_standard
,
20755 bgp_lcommunity_list_name_standard_cmd
,
20756 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20758 LCOMMUNITY_LIST_STR
20759 "Specify standard large-community-list\n"
20760 "Large Community list name\n"
20761 "Sequence number of an entry\n"
20762 "Sequence number\n"
20763 "Specify large community to reject\n"
20764 "Specify large community to accept\n"
20765 LCOMMUNITY_VAL_STR
)
20767 return lcommunity_list_set_vty(vty
, argc
, argv
,
20768 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20771 DEFUN (lcommunity_list_name_expanded
,
20772 bgp_lcommunity_list_name_expanded_cmd
,
20773 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20775 LCOMMUNITY_LIST_STR
20776 "Specify expanded large-community-list\n"
20777 "Large Community list name\n"
20778 "Sequence number of an entry\n"
20779 "Sequence number\n"
20780 "Specify large community to reject\n"
20781 "Specify large community to accept\n"
20782 "An ordered list as a regular-expression\n")
20784 return lcommunity_list_set_vty(vty
, argc
, argv
,
20785 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20788 DEFUN (no_lcommunity_list_all
,
20789 no_bgp_lcommunity_list_all_cmd
,
20790 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20793 LCOMMUNITY_LIST_STR
20794 "Large Community list number (standard)\n"
20795 "Large Community list number (expanded)\n"
20796 "Large Community list name\n")
20798 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20799 LARGE_COMMUNITY_LIST_STANDARD
);
20802 DEFUN (no_lcommunity_list_name_standard_all
,
20803 no_bgp_lcommunity_list_name_standard_all_cmd
,
20804 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20807 LCOMMUNITY_LIST_STR
20808 "Specify standard large-community-list\n"
20809 "Large Community list name\n")
20811 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20812 LARGE_COMMUNITY_LIST_STANDARD
);
20815 DEFUN (no_lcommunity_list_name_expanded_all
,
20816 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20817 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20820 LCOMMUNITY_LIST_STR
20821 "Specify expanded large-community-list\n"
20822 "Large Community list name\n")
20824 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20825 LARGE_COMMUNITY_LIST_EXPANDED
);
20828 DEFUN (no_lcommunity_list_standard
,
20829 no_bgp_lcommunity_list_standard_cmd
,
20830 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20833 LCOMMUNITY_LIST_STR
20834 "Large Community list number (standard)\n"
20835 "Sequence number of an entry\n"
20836 "Sequence number\n"
20837 "Specify large community to reject\n"
20838 "Specify large community to accept\n"
20839 LCOMMUNITY_VAL_STR
)
20841 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20842 LARGE_COMMUNITY_LIST_STANDARD
);
20845 DEFUN (no_lcommunity_list_expanded
,
20846 no_bgp_lcommunity_list_expanded_cmd
,
20847 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20850 LCOMMUNITY_LIST_STR
20851 "Large Community list number (expanded)\n"
20852 "Sequence number of an entry\n"
20853 "Sequence number\n"
20854 "Specify large community to reject\n"
20855 "Specify large community to accept\n"
20856 "An ordered list as a regular-expression\n")
20858 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20859 LARGE_COMMUNITY_LIST_EXPANDED
);
20862 DEFUN (no_lcommunity_list_name_standard
,
20863 no_bgp_lcommunity_list_name_standard_cmd
,
20864 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20867 LCOMMUNITY_LIST_STR
20868 "Specify standard large-community-list\n"
20869 "Large Community list name\n"
20870 "Sequence number of an entry\n"
20871 "Sequence number\n"
20872 "Specify large community to reject\n"
20873 "Specify large community to accept\n"
20874 LCOMMUNITY_VAL_STR
)
20876 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20877 LARGE_COMMUNITY_LIST_STANDARD
);
20880 DEFUN (no_lcommunity_list_name_expanded
,
20881 no_bgp_lcommunity_list_name_expanded_cmd
,
20882 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20885 LCOMMUNITY_LIST_STR
20886 "Specify expanded large-community-list\n"
20887 "Large community list name\n"
20888 "Sequence number of an entry\n"
20889 "Sequence number\n"
20890 "Specify large community to reject\n"
20891 "Specify large community to accept\n"
20892 "An ordered list as a regular-expression\n")
20894 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20895 LARGE_COMMUNITY_LIST_EXPANDED
);
20898 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20900 struct community_entry
*entry
;
20902 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20903 if (entry
== list
->head
) {
20904 if (all_digit(list
->name
))
20905 vty_out(vty
, "Large community %s list %s\n",
20907 LARGE_COMMUNITY_LIST_STANDARD
20909 : "(expanded) access",
20913 "Named large community %s list %s\n",
20915 LARGE_COMMUNITY_LIST_STANDARD
20921 vty_out(vty
, " %s\n",
20922 community_direct_str(entry
->direct
));
20924 vty_out(vty
, " %s %s\n",
20925 community_direct_str(entry
->direct
),
20926 community_list_config_str(entry
));
20930 DEFUN (show_lcommunity_list
,
20931 show_bgp_lcommunity_list_cmd
,
20932 "show bgp large-community-list",
20935 "List large-community list\n")
20937 struct community_list
*list
;
20938 struct community_list_master
*cm
;
20940 cm
= community_list_master_lookup(bgp_clist
,
20941 LARGE_COMMUNITY_LIST_MASTER
);
20943 return CMD_SUCCESS
;
20945 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20946 lcommunity_list_show(vty
, list
);
20948 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20949 lcommunity_list_show(vty
, list
);
20951 return CMD_SUCCESS
;
20954 DEFUN (show_lcommunity_list_arg
,
20955 show_bgp_lcommunity_list_arg_cmd
,
20956 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20959 "List large-community list\n"
20960 "Large-community-list number\n"
20961 "Large-community-list name\n"
20962 "Detailed information on large-community-list\n")
20964 struct community_list
*list
;
20966 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20967 LARGE_COMMUNITY_LIST_MASTER
);
20969 vty_out(vty
, "%% Can't find large-community-list\n");
20970 return CMD_WARNING
;
20973 lcommunity_list_show(vty
, list
);
20975 return CMD_SUCCESS
;
20978 /* "extcommunity-list" keyword help string. */
20979 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20980 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20982 DEFUN (extcommunity_list_standard
,
20983 bgp_extcommunity_list_standard_cmd
,
20984 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20986 EXTCOMMUNITY_LIST_STR
20987 "Extended Community list number (standard)\n"
20988 "Specify standard extcommunity-list\n"
20989 "Community list name\n"
20990 "Sequence number of an entry\n"
20991 "Sequence number\n"
20992 "Specify community to reject\n"
20993 "Specify community to accept\n"
20994 EXTCOMMUNITY_VAL_STR
)
20996 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20998 char *cl_number_or_name
= NULL
;
21003 argv_find(argv
, argc
, "(1-99)", &idx
);
21004 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21005 cl_number_or_name
= argv
[idx
]->arg
;
21007 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21008 seq
= argv
[idx
]->arg
;
21010 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21012 argv_find(argv
, argc
, "AA:NN", &idx
);
21013 char *str
= argv_concat(argv
, argc
, idx
);
21015 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21018 XFREE(MTYPE_TMP
, str
);
21021 community_list_perror(vty
, ret
);
21022 return CMD_WARNING_CONFIG_FAILED
;
21025 return CMD_SUCCESS
;
21028 DEFUN (extcommunity_list_name_expanded
,
21029 bgp_extcommunity_list_name_expanded_cmd
,
21030 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21032 EXTCOMMUNITY_LIST_STR
21033 "Extended Community list number (expanded)\n"
21034 "Specify expanded extcommunity-list\n"
21035 "Extended Community list name\n"
21036 "Sequence number of an entry\n"
21037 "Sequence number\n"
21038 "Specify community to reject\n"
21039 "Specify community to accept\n"
21040 "An ordered list as a regular-expression\n")
21042 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21044 char *cl_number_or_name
= NULL
;
21048 argv_find(argv
, argc
, "(100-500)", &idx
);
21049 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21050 cl_number_or_name
= argv
[idx
]->arg
;
21052 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21053 seq
= argv
[idx
]->arg
;
21055 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21057 argv_find(argv
, argc
, "LINE", &idx
);
21058 char *str
= argv_concat(argv
, argc
, idx
);
21060 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21063 XFREE(MTYPE_TMP
, str
);
21066 community_list_perror(vty
, ret
);
21067 return CMD_WARNING_CONFIG_FAILED
;
21070 return CMD_SUCCESS
;
21073 DEFUN (no_extcommunity_list_standard_all
,
21074 no_bgp_extcommunity_list_standard_all_cmd
,
21075 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21078 EXTCOMMUNITY_LIST_STR
21079 "Extended Community list number (standard)\n"
21080 "Specify standard extcommunity-list\n"
21081 "Community list name\n"
21082 "Sequence number of an entry\n"
21083 "Sequence number\n"
21084 "Specify community to reject\n"
21085 "Specify community to accept\n"
21086 EXTCOMMUNITY_VAL_STR
)
21088 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21090 char *cl_number_or_name
= NULL
;
21095 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21096 seq
= argv
[idx
]->arg
;
21099 argv_find(argv
, argc
, "permit", &idx
);
21100 argv_find(argv
, argc
, "deny", &idx
);
21102 direct
= argv_find(argv
, argc
, "permit", &idx
)
21107 argv_find(argv
, argc
, "AA:NN", &idx
);
21108 str
= argv_concat(argv
, argc
, idx
);
21112 argv_find(argv
, argc
, "(1-99)", &idx
);
21113 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21114 cl_number_or_name
= argv
[idx
]->arg
;
21116 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21117 seq
, direct
, style
);
21119 XFREE(MTYPE_TMP
, str
);
21122 community_list_perror(vty
, ret
);
21123 return CMD_WARNING_CONFIG_FAILED
;
21126 return CMD_SUCCESS
;
21129 ALIAS(no_extcommunity_list_standard_all
,
21130 no_bgp_extcommunity_list_standard_all_list_cmd
,
21131 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21132 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21133 "Extended Community list number (standard)\n"
21134 "Specify standard extcommunity-list\n"
21135 "Community list name\n")
21137 DEFUN (no_extcommunity_list_expanded_all
,
21138 no_bgp_extcommunity_list_expanded_all_cmd
,
21139 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21142 EXTCOMMUNITY_LIST_STR
21143 "Extended Community list number (expanded)\n"
21144 "Specify expanded extcommunity-list\n"
21145 "Extended Community list name\n"
21146 "Sequence number of an entry\n"
21147 "Sequence number\n"
21148 "Specify community to reject\n"
21149 "Specify community to accept\n"
21150 "An ordered list as a regular-expression\n")
21152 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21154 char *cl_number_or_name
= NULL
;
21159 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21160 seq
= argv
[idx
]->arg
;
21163 argv_find(argv
, argc
, "permit", &idx
);
21164 argv_find(argv
, argc
, "deny", &idx
);
21167 direct
= argv_find(argv
, argc
, "permit", &idx
)
21172 argv_find(argv
, argc
, "LINE", &idx
);
21173 str
= argv_concat(argv
, argc
, idx
);
21177 argv_find(argv
, argc
, "(100-500)", &idx
);
21178 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21179 cl_number_or_name
= argv
[idx
]->arg
;
21181 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21182 seq
, direct
, style
);
21184 XFREE(MTYPE_TMP
, str
);
21187 community_list_perror(vty
, ret
);
21188 return CMD_WARNING_CONFIG_FAILED
;
21191 return CMD_SUCCESS
;
21194 ALIAS(no_extcommunity_list_expanded_all
,
21195 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21196 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21197 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21198 "Extended Community list number (expanded)\n"
21199 "Specify expanded extcommunity-list\n"
21200 "Extended Community list name\n")
21202 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21204 struct community_entry
*entry
;
21206 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21207 if (entry
== list
->head
) {
21208 if (all_digit(list
->name
))
21209 vty_out(vty
, "Extended community %s list %s\n",
21210 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21212 : "(expanded) access",
21216 "Named extended community %s list %s\n",
21217 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21223 vty_out(vty
, " %s\n",
21224 community_direct_str(entry
->direct
));
21226 vty_out(vty
, " %s %s\n",
21227 community_direct_str(entry
->direct
),
21228 community_list_config_str(entry
));
21232 DEFUN (show_extcommunity_list
,
21233 show_bgp_extcommunity_list_cmd
,
21234 "show bgp extcommunity-list",
21237 "List extended-community list\n")
21239 struct community_list
*list
;
21240 struct community_list_master
*cm
;
21242 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21244 return CMD_SUCCESS
;
21246 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21247 extcommunity_list_show(vty
, list
);
21249 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21250 extcommunity_list_show(vty
, list
);
21252 return CMD_SUCCESS
;
21255 DEFUN (show_extcommunity_list_arg
,
21256 show_bgp_extcommunity_list_arg_cmd
,
21257 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21260 "List extended-community list\n"
21261 "Extcommunity-list number\n"
21262 "Extcommunity-list name\n"
21263 "Detailed information on extcommunity-list\n")
21265 int idx_comm_list
= 3;
21266 struct community_list
*list
;
21268 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21269 EXTCOMMUNITY_LIST_MASTER
);
21271 vty_out(vty
, "%% Can't find extcommunity-list\n");
21272 return CMD_WARNING
;
21275 extcommunity_list_show(vty
, list
);
21277 return CMD_SUCCESS
;
21280 /* Display community-list and extcommunity-list configuration. */
21281 static int community_list_config_write(struct vty
*vty
)
21283 struct community_list
*list
;
21284 struct community_entry
*entry
;
21285 struct community_list_master
*cm
;
21288 /* Community-list. */
21289 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21291 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21292 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21294 "bgp community-list %s seq %" PRId64
" %s %s\n",
21295 list
->name
, entry
->seq
,
21296 community_direct_str(entry
->direct
),
21297 community_list_config_str(entry
));
21300 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21301 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21303 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21304 entry
->style
== COMMUNITY_LIST_STANDARD
21307 list
->name
, entry
->seq
,
21308 community_direct_str(entry
->direct
),
21309 community_list_config_str(entry
));
21313 /* Extcommunity-list. */
21314 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21316 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21317 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21319 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21320 list
->name
, entry
->seq
,
21321 community_direct_str(entry
->direct
),
21322 community_list_config_str(entry
));
21325 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21326 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21328 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21329 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21332 list
->name
, entry
->seq
,
21333 community_direct_str(entry
->direct
),
21334 community_list_config_str(entry
));
21339 /* lcommunity-list. */
21340 cm
= community_list_master_lookup(bgp_clist
,
21341 LARGE_COMMUNITY_LIST_MASTER
);
21343 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21344 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21346 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21347 list
->name
, entry
->seq
,
21348 community_direct_str(entry
->direct
),
21349 community_list_config_str(entry
));
21352 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21353 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21355 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21357 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21360 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21361 community_list_config_str(entry
));
21368 static int community_list_config_write(struct vty
*vty
);
21369 static struct cmd_node community_list_node
= {
21370 .name
= "community list",
21371 .node
= COMMUNITY_LIST_NODE
,
21373 .config_write
= community_list_config_write
,
21376 static void community_list_vty(void)
21378 install_node(&community_list_node
);
21380 /* Community-list. */
21381 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21382 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21383 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21384 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21385 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21386 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21387 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21388 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21390 /* Extcommunity-list. */
21391 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21392 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21393 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21394 install_element(CONFIG_NODE
,
21395 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21396 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21397 install_element(CONFIG_NODE
,
21398 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21399 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21400 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21402 /* Large Community List */
21403 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21404 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21405 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21406 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21407 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21408 install_element(CONFIG_NODE
,
21409 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21410 install_element(CONFIG_NODE
,
21411 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21412 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21413 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21414 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21415 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21416 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21417 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21419 bgp_community_list_command_completion_setup();
21422 static struct cmd_node community_alias_node
= {
21423 .name
= "community alias",
21424 .node
= COMMUNITY_ALIAS_NODE
,
21426 .config_write
= bgp_community_alias_write
,
21429 void community_alias_vty(void)
21431 install_node(&community_alias_node
);
21433 /* Community-list. */
21434 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21436 bgp_community_alias_command_completion_setup();