2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
163 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
166 afi_t afi
, bool use_json
);
168 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
174 return BGP_IPV4_NODE
;
176 return BGP_IPV4M_NODE
;
177 case SAFI_LABELED_UNICAST
:
178 return BGP_IPV4L_NODE
;
180 return BGP_VPNV4_NODE
;
182 return BGP_FLOWSPECV4_NODE
;
185 return BGP_IPV4_NODE
;
190 return BGP_IPV6_NODE
;
192 return BGP_IPV6M_NODE
;
193 case SAFI_LABELED_UNICAST
:
194 return BGP_IPV6L_NODE
;
196 return BGP_VPNV6_NODE
;
198 return BGP_FLOWSPECV6_NODE
;
201 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* unset srv6 locator */
294 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
297 struct listnode
*node
, *nnode
;
298 struct srv6_locator_chunk
*chunk
;
299 struct bgp_srv6_function
*func
;
302 /* release chunk notification via ZAPI */
303 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
304 bgp
->srv6_locator_name
);
309 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
310 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
311 srv6_locator_chunk_free(chunk
);
314 /* refresh functions */
315 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
316 listnode_delete(bgp
->srv6_functions
, func
);
317 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
320 /* refresh tovpn_sid */
321 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
322 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
325 /* refresh vpnv4 tovpn_sid */
326 XFREE(MTYPE_BGP_SRV6_SID
,
327 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
329 /* refresh vpnv6 tovpn_sid */
330 XFREE(MTYPE_BGP_SRV6_SID
,
331 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
334 /* update vpn bgp processes */
335 vpn_leak_postchange_all();
337 /* refresh tovpn_sid_locator */
338 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
339 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
342 /* refresh vpnv4 tovpn_sid_locator */
343 XFREE(MTYPE_BGP_SRV6_SID
,
344 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
346 /* refresh vpnv6 tovpn_sid_locator */
347 XFREE(MTYPE_BGP_SRV6_SID
,
348 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
351 /* clear locator name */
352 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
357 /* Utility function to get address family from current node. */
358 afi_t
bgp_node_afi(struct vty
*vty
)
366 case BGP_FLOWSPECV6_NODE
:
379 /* Utility function to get subsequent address family from current
381 safi_t
bgp_node_safi(struct vty
*vty
)
387 safi
= SAFI_MPLS_VPN
;
391 safi
= SAFI_MULTICAST
;
398 safi
= SAFI_LABELED_UNICAST
;
400 case BGP_FLOWSPECV4_NODE
:
401 case BGP_FLOWSPECV6_NODE
:
402 safi
= SAFI_FLOWSPEC
;
412 * Converts an AFI in string form to afi_t
414 * @param afi string, one of
418 * @return the corresponding afi_t
420 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
422 afi_t afi
= AFI_MAX
; /* unknown */
423 if (strmatch(afi_str
, "ipv4"))
425 else if (strmatch(afi_str
, "ipv6"))
427 else if (strmatch(afi_str
, "l2vpn"))
432 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
436 if (argv_find(argv
, argc
, "ipv4", index
)) {
440 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
444 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
452 /* supports <unicast|multicast|vpn|labeled-unicast> */
453 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
455 safi_t safi
= SAFI_MAX
; /* unknown */
456 if (strmatch(safi_str
, "multicast"))
457 safi
= SAFI_MULTICAST
;
458 else if (strmatch(safi_str
, "unicast"))
460 else if (strmatch(safi_str
, "vpn"))
461 safi
= SAFI_MPLS_VPN
;
462 else if (strmatch(safi_str
, "evpn"))
464 else if (strmatch(safi_str
, "labeled-unicast"))
465 safi
= SAFI_LABELED_UNICAST
;
466 else if (strmatch(safi_str
, "flowspec"))
467 safi
= SAFI_FLOWSPEC
;
471 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
475 if (argv_find(argv
, argc
, "unicast", index
)) {
478 *safi
= SAFI_UNICAST
;
479 } else if (argv_find(argv
, argc
, "multicast", index
)) {
482 *safi
= SAFI_MULTICAST
;
483 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
486 *safi
= SAFI_LABELED_UNICAST
;
487 } else if (argv_find(argv
, argc
, "vpn", index
)) {
490 *safi
= SAFI_MPLS_VPN
;
491 } else if (argv_find(argv
, argc
, "evpn", index
)) {
495 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
498 *safi
= SAFI_FLOWSPEC
;
504 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
507 * address-family identifier
510 * subsequent address-family identifier
513 * default_af string corresponding to the supplied afi/safi pair.
514 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
517 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
523 return "ipv4-unicast";
525 return "ipv4-multicast";
530 case SAFI_LABELED_UNICAST
:
531 return "ipv4-labeled-unicast";
533 return "ipv4-flowspec";
535 return "unknown-afi/safi";
541 return "ipv6-unicast";
543 return "ipv6-multicast";
548 case SAFI_LABELED_UNICAST
:
549 return "ipv6-labeled-unicast";
551 return "ipv6-flowspec";
553 return "unknown-afi/safi";
561 return "unknown-afi/safi";
565 return "unknown-afi/safi";
567 /* all AFIs are accounted for above, so this shouldn't happen */
568 return "unknown-afi/safi";
571 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
572 enum bgp_instance_type inst_type
)
574 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
576 if (ret
== BGP_CREATED
) {
577 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
578 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
580 if (DFLT_BGP_IMPORT_CHECK
)
581 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
582 if (DFLT_BGP_SHOW_HOSTNAME
)
583 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
584 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
585 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
586 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
587 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
588 if (DFLT_BGP_DETERMINISTIC_MED
)
589 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
590 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
592 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
594 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
596 if (DFLT_BGP_HARD_ADMIN_RESET
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
605 * bgp_vty_find_and_parse_afi_safi_bgp
607 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
608 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
609 * to appropriate values for the calling function. This is to allow the
610 * calling function to make decisions appropriate for the show command
611 * that is being parsed.
613 * The show commands are generally of the form:
614 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
615 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
617 * Since we use argv_find if the show command in particular doesn't have:
619 * [<view|vrf> VIEWVRFNAME]
620 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
621 * The command parsing should still be ok.
623 * vty -> The vty for the command so we can output some useful data in
624 * the event of a parse error in the vrf.
625 * argv -> The command tokens
626 * argc -> How many command tokens we have
627 * idx -> The current place in the command, generally should be 0 for this
629 * afi -> The parsed afi if it was included in the show command, returned here
630 * safi -> The parsed safi if it was included in the show command, returned here
631 * bgp -> Pointer to the bgp data structure we need to fill in.
632 * use_json -> json is configured or not
634 * The function returns the correct location in the parse tree for the
637 * Returns 0 for failure to parse correctly, else the idx position of where
638 * it found the last token.
640 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
641 struct cmd_token
**argv
, int argc
,
642 int *idx
, afi_t
*afi
, safi_t
*safi
,
643 struct bgp
**bgp
, bool use_json
)
645 char *vrf_name
= NULL
;
651 if (argv_find(argv
, argc
, "ip", idx
))
654 if (argv_find(argv
, argc
, "view", idx
))
655 vrf_name
= argv
[*idx
+ 1]->arg
;
656 else if (argv_find(argv
, argc
, "vrf", idx
)) {
657 vrf_name
= argv
[*idx
+ 1]->arg
;
658 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
662 if (strmatch(vrf_name
, "all"))
665 *bgp
= bgp_lookup_by_name(vrf_name
);
668 json_object
*json
= NULL
;
669 json
= json_object_new_object();
670 json_object_string_add(
672 "View/Vrf is unknown");
676 vty_out(vty
, "View/Vrf %s is unknown\n",
683 *bgp
= bgp_get_default();
686 json_object
*json
= NULL
;
687 json
= json_object_new_object();
688 json_object_string_add(
690 "Default BGP instance not found");
695 "Default BGP instance not found\n");
701 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
702 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
708 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
710 struct interface
*ifp
= NULL
;
711 struct listnode
*node
;
712 struct bgp_listener
*listener
;
713 union sockunion all_su
;
715 if (su
->sa
.sa_family
== AF_INET
) {
716 (void)str2sockunion("0.0.0.0", &all_su
);
717 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
718 } else if (su
->sa
.sa_family
== AF_INET6
) {
719 (void)str2sockunion("::", &all_su
);
720 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
721 su
->sin6
.sin6_scope_id
,
726 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
727 if (sockunion_family(su
) !=
728 sockunion_family(&listener
->su
))
731 /* If 0.0.0.0/:: is a listener, then treat as self and
734 if (!sockunion_cmp(&listener
->su
, su
) ||
735 !sockunion_cmp(&listener
->su
, &all_su
))
743 /* Utility function for looking up peer from VTY. */
744 /* This is used only for configuration, so disallow if attempted on
745 * a dynamic neighbor.
747 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
749 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
758 ret
= str2sockunion(ip_str
, &su
);
760 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
762 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
765 "%% Malformed address or name: %s\n",
771 peer
= peer_lookup(bgp
, &su
);
774 "%% Specify remote-as or peer-group commands first\n");
777 if (peer_dynamic_neighbor(peer
)) {
779 "%% Operation not allowed on a dynamic neighbor\n");
786 /* Utility function for looking up peer or peer group. */
787 /* This is used only for configuration, so disallow if attempted on
788 * a dynamic neighbor.
790 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
792 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
795 struct peer
*peer
= NULL
;
796 struct peer_group
*group
= NULL
;
802 ret
= str2sockunion(peer_str
, &su
);
804 /* IP address, locate peer. */
805 peer
= peer_lookup(bgp
, &su
);
807 /* Not IP, could match either peer configured on interface or a
809 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
811 group
= peer_group_lookup(bgp
, peer_str
);
815 if (peer_dynamic_neighbor(peer
)) {
817 "%% Operation not allowed on a dynamic neighbor\n");
827 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
832 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
834 const char *str
= NULL
;
839 case BGP_GR_NO_OPERATION
:
841 case BGP_ERR_INVALID_VALUE
:
842 str
= "Invalid value";
844 case BGP_ERR_INVALID_FLAG
:
845 str
= "Invalid flag";
847 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
848 str
= "Peer-group has been shutdown. Activate the peer-group first";
850 case BGP_ERR_PEER_FLAG_CONFLICT
:
851 str
= "Can't set override-capability and strict-capability-match at the same time";
853 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
854 str
= "Specify remote-as or peer-group remote AS first";
856 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
857 str
= "Cannot change the peer-group. Deconfigure first";
859 case BGP_ERR_PEER_GROUP_MISMATCH
:
860 str
= "Peer is not a member of this peer-group";
862 case BGP_ERR_PEER_FILTER_CONFLICT
:
863 str
= "Prefix/distribute list can not co-exist";
865 case BGP_ERR_NOT_INTERNAL_PEER
:
866 str
= "Invalid command. Not an internal neighbor";
868 case BGP_ERR_REMOVE_PRIVATE_AS
:
869 str
= "remove-private-AS cannot be configured for IBGP peers";
871 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
872 str
= "Cannot have local-as same as BGP AS number";
874 case BGP_ERR_TCPSIG_FAILED
:
875 str
= "Error while applying TCP-Sig to session(s)";
877 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
878 str
= "ebgp-multihop and ttl-security cannot be configured together";
880 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
881 str
= "ttl-security only allowed for EBGP peers";
883 case BGP_ERR_AS_OVERRIDE
:
884 str
= "as-override cannot be configured for IBGP peers";
886 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
887 str
= "Invalid limit for number of dynamic neighbors";
889 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
890 str
= "Dynamic neighbor listen range already exists";
892 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
893 str
= "Operation not allowed on a dynamic neighbor";
895 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
896 str
= "Operation not allowed on a directly connected neighbor";
898 case BGP_ERR_PEER_SAFI_CONFLICT
:
899 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
901 case BGP_ERR_GR_INVALID_CMD
:
902 str
= "The Graceful Restart command used is not valid at this moment.";
904 case BGP_ERR_GR_OPERATION_FAILED
:
905 str
= "The Graceful Restart Operation failed due to an err.";
907 case BGP_ERR_PEER_GROUP_MEMBER
:
908 str
= "Peer-group member cannot override remote-as of peer-group.";
910 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
911 str
= "Peer-group members must be all internal or all external.";
913 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
914 str
= "Range specified cannot be deleted because it is not part of current config.";
916 case BGP_ERR_INSTANCE_MISMATCH
:
917 str
= "Instance specified does not match the current instance.";
919 case BGP_ERR_NO_INTERFACE_CONFIG
:
920 str
= "Interface specified is not being used for interface based peer.";
922 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
923 str
= "No configuration already specified for soft reconfiguration.";
925 case BGP_ERR_AS_MISMATCH
:
926 str
= "BGP is already running.";
928 case BGP_ERR_AF_UNCONFIGURED
:
929 str
= "AFI/SAFI specified is not currently configured.";
931 case BGP_ERR_INVALID_AS
:
932 str
= "Confederation AS specified is the same AS as our AS.";
934 case BGP_ERR_INVALID_ROLE_NAME
:
935 str
= "Invalid role name";
937 case BGP_ERR_INVALID_INTERNAL_ROLE
:
938 str
= "External roles can be set only on eBGP session";
942 vty_out(vty
, "%% %s\n", str
);
943 return CMD_WARNING_CONFIG_FAILED
;
948 /* BGP clear sort. */
957 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
958 safi_t safi
, int error
)
961 case BGP_ERR_AF_UNCONFIGURED
:
964 "%% BGP: Enable %s address family for the neighbor %s\n",
965 get_afi_safi_str(afi
, safi
, false), peer
->host
);
968 "%% BGP: Enable %s address family for the neighbor %s",
969 get_afi_safi_str(afi
, safi
, false), peer
->host
);
971 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
974 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
978 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
986 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
987 struct listnode
**nnode
, enum bgp_clear_type stype
)
992 /* if afi/.safi not specified, spin thru all of them */
993 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
996 enum bgp_af_index index
;
998 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
999 paf
= peer
->peer_af_array
[index
];
1003 if (paf
&& paf
->subgroup
)
1004 SET_FLAG(paf
->subgroup
->sflags
,
1005 SUBGRP_STATUS_FORCE_UPDATES
);
1008 tmp_safi
= paf
->safi
;
1009 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1012 if (stype
== BGP_CLEAR_SOFT_NONE
)
1013 ret
= peer_clear(peer
, nnode
);
1015 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1018 /* if afi specified and safi not, spin thru safis on this afi */
1019 } else if (safi
== SAFI_UNSPEC
) {
1022 for (tmp_safi
= SAFI_UNICAST
;
1023 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1024 if (!peer
->afc
[afi
][tmp_safi
])
1027 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1028 if (paf
&& paf
->subgroup
)
1029 SET_FLAG(paf
->subgroup
->sflags
,
1030 SUBGRP_STATUS_FORCE_UPDATES
);
1032 if (stype
== BGP_CLEAR_SOFT_NONE
)
1033 ret
= peer_clear(peer
, nnode
);
1035 ret
= peer_clear_soft(peer
, afi
,
1038 /* both afi/safi specified, let the caller know if not defined */
1040 if (!peer
->afc
[afi
][safi
])
1043 paf
= peer_af_find(peer
, afi
, safi
);
1044 if (paf
&& paf
->subgroup
)
1045 SET_FLAG(paf
->subgroup
->sflags
,
1046 SUBGRP_STATUS_FORCE_UPDATES
);
1048 if (stype
== BGP_CLEAR_SOFT_NONE
)
1049 ret
= peer_clear(peer
, nnode
);
1051 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1057 /* `clear ip bgp' functions. */
1058 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1059 enum clear_sort sort
, enum bgp_clear_type stype
,
1066 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1068 /* Clear all neighbors. */
1070 * Pass along pointer to next node to peer_clear() when walking all
1071 * nodes on the BGP instance as that may get freed if it is a
1074 if (sort
== clear_all
) {
1075 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1077 bgp_peer_gr_flags_update(peer
);
1079 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1080 gr_router_detected
= true;
1082 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1086 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1089 if (gr_router_detected
1090 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1091 bgp_zebra_send_capabilities(bgp
, false);
1092 } else if (!gr_router_detected
1093 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1094 bgp_zebra_send_capabilities(bgp
, true);
1097 /* This is to apply read-only mode on this clear. */
1098 if (stype
== BGP_CLEAR_SOFT_NONE
)
1099 bgp
->update_delay_over
= 0;
1104 /* Clear specified neighbor. */
1105 if (sort
== clear_peer
) {
1108 /* Make sockunion for lookup. */
1109 ret
= str2sockunion(arg
, &su
);
1111 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1113 peer
= peer_lookup_by_hostname(bgp
, arg
);
1116 "Malformed address or name: %s\n",
1122 peer
= peer_lookup(bgp
, &su
);
1125 "%% BGP: Unknown neighbor - \"%s\"\n",
1131 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1132 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1134 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1136 /* if afi/safi not defined for this peer, let caller know */
1138 ret
= BGP_ERR_AF_UNCONFIGURED
;
1141 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1146 /* Clear all neighbors belonging to a specific peer-group. */
1147 if (sort
== clear_group
) {
1148 struct peer_group
*group
;
1150 group
= peer_group_lookup(bgp
, arg
);
1152 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1156 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1157 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1160 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1167 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1168 get_afi_safi_str(afi
, safi
, false), arg
);
1173 /* Clear all external (eBGP) neighbors. */
1174 if (sort
== clear_external
) {
1175 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1176 if (peer
->sort
== BGP_PEER_IBGP
)
1179 bgp_peer_gr_flags_update(peer
);
1181 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1182 gr_router_detected
= true;
1184 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1187 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1192 if (gr_router_detected
1193 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1194 bgp_zebra_send_capabilities(bgp
, false);
1195 } else if (!gr_router_detected
1196 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1197 bgp_zebra_send_capabilities(bgp
, true);
1202 "%% BGP: No external %s peer is configured\n",
1203 get_afi_safi_str(afi
, safi
, false));
1208 /* Clear all neighbors belonging to a specific AS. */
1209 if (sort
== clear_as
) {
1210 as_t as
= strtoul(arg
, NULL
, 10);
1212 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1216 bgp_peer_gr_flags_update(peer
);
1218 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1219 gr_router_detected
= true;
1221 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1224 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1229 if (gr_router_detected
1230 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1231 bgp_zebra_send_capabilities(bgp
, false);
1232 } else if (!gr_router_detected
1233 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1234 bgp_zebra_send_capabilities(bgp
, true);
1239 "%% BGP: No %s peer is configured with AS %s\n",
1240 get_afi_safi_str(afi
, safi
, false), arg
);
1248 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1249 safi_t safi
, enum clear_sort sort
,
1250 enum bgp_clear_type stype
, const char *arg
)
1254 /* BGP structure lookup. */
1256 bgp
= bgp_lookup_by_name(name
);
1258 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1262 bgp
= bgp_get_default();
1264 vty_out(vty
, "No BGP process is configured\n");
1269 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1272 /* clear soft inbound */
1273 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1278 FOREACH_AFI_SAFI (afi
, safi
)
1279 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1280 BGP_CLEAR_SOFT_IN
, NULL
);
1283 /* clear soft outbound */
1284 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1289 FOREACH_AFI_SAFI (afi
, safi
)
1290 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1291 BGP_CLEAR_SOFT_OUT
, NULL
);
1295 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1297 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1300 #ifndef VTYSH_EXTRACT_PL
1301 #include "bgpd/bgp_vty_clippy.c"
1304 DEFUN_HIDDEN (bgp_local_mac
,
1306 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1308 "Local MAC config\n"
1309 "VxLAN Network Identifier\n"
1313 "mac-mobility sequence\n"
1323 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1324 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1325 vty_out(vty
, "%% Malformed MAC address\n");
1328 memset(&ip
, 0, sizeof(ip
));
1329 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1331 bgp
= bgp_get_default();
1333 vty_out(vty
, "Default BGP instance is not there\n");
1337 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1340 vty_out(vty
, "Internal error\n");
1347 DEFUN_HIDDEN (no_bgp_local_mac
,
1348 no_bgp_local_mac_cmd
,
1349 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1352 "Local MAC config\n"
1353 "VxLAN Network Identifier\n"
1364 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1365 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1366 vty_out(vty
, "%% Malformed MAC address\n");
1369 memset(&ip
, 0, sizeof(ip
));
1371 bgp
= bgp_get_default();
1373 vty_out(vty
, "Default BGP instance is not there\n");
1377 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1379 vty_out(vty
, "Internal error\n");
1386 DEFUN (no_synchronization
,
1387 no_synchronization_cmd
,
1388 "no synchronization",
1390 "Perform IGP synchronization\n")
1395 DEFUN (no_auto_summary
,
1396 no_auto_summary_cmd
,
1399 "Enable automatic network number summarization\n")
1404 /* "router bgp" commands. */
1405 DEFUN_NOSH (router_bgp
,
1407 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1411 BGP_INSTANCE_HELP_STR
)
1414 int idx_view_vrf
= 3;
1420 const char *name
= NULL
;
1421 enum bgp_instance_type inst_type
;
1423 // "router bgp" without an ASN
1425 // Pending: Make VRF option available for ASN less config
1426 bgp
= bgp_get_default();
1429 vty_out(vty
, "%% No BGP process is configured\n");
1430 return CMD_WARNING_CONFIG_FAILED
;
1433 if (listcount(bm
->bgp
) > 1) {
1434 vty_out(vty
, "%% Please specify ASN and VRF\n");
1435 return CMD_WARNING_CONFIG_FAILED
;
1441 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1443 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1444 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1445 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1447 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1449 name
= argv
[idx_vrf
]->arg
;
1451 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1452 if (strmatch(name
, VRF_DEFAULT_NAME
))
1455 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1456 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1457 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1460 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1461 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1463 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1465 case BGP_ERR_AS_MISMATCH
:
1466 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1467 return CMD_WARNING_CONFIG_FAILED
;
1468 case BGP_ERR_INSTANCE_MISMATCH
:
1470 "BGP instance name and AS number mismatch\n");
1472 "BGP instance is already running; AS is %u\n",
1474 return CMD_WARNING_CONFIG_FAILED
;
1478 * If we just instantiated the default instance, complete
1479 * any pending VRF-VPN leaking that was configured via
1480 * earlier "router bgp X vrf FOO" blocks.
1482 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1483 vpn_leak_postchange_all();
1485 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1486 bgp_vpn_leak_export(bgp
);
1487 /* Pending: handle when user tries to change a view to vrf n vv.
1491 /* unset the auto created flag as the user config is now present */
1492 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1493 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1498 /* "no router bgp" commands. */
1499 DEFUN (no_router_bgp
,
1501 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1506 BGP_INSTANCE_HELP_STR
)
1512 const char *name
= NULL
;
1514 // "no router bgp" without an ASN
1516 // Pending: Make VRF option available for ASN less config
1517 bgp
= bgp_get_default();
1520 vty_out(vty
, "%% No BGP process is configured\n");
1521 return CMD_WARNING_CONFIG_FAILED
;
1524 if (listcount(bm
->bgp
) > 1) {
1525 vty_out(vty
, "%% Please specify ASN and VRF\n");
1526 return CMD_WARNING_CONFIG_FAILED
;
1530 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1532 return CMD_WARNING_CONFIG_FAILED
;
1535 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1538 name
= argv
[idx_vrf
]->arg
;
1539 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1540 && strmatch(name
, VRF_DEFAULT_NAME
))
1544 /* Lookup bgp structure. */
1545 bgp
= bgp_lookup(as
, name
);
1547 vty_out(vty
, "%% Can't find BGP instance\n");
1548 return CMD_WARNING_CONFIG_FAILED
;
1552 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1554 return CMD_WARNING_CONFIG_FAILED
;
1557 /* Cannot delete default instance if vrf instances exist */
1558 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1559 struct listnode
*node
;
1560 struct bgp
*tmp_bgp
;
1562 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1563 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1565 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1566 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1567 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1568 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1569 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1570 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1571 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1572 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1573 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1574 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1575 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1576 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1577 (bgp
== bgp_get_evpn() &&
1578 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1579 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1581 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1582 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1583 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1584 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1585 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1586 (hashcount(tmp_bgp
->vnihash
))) {
1588 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1589 return CMD_WARNING_CONFIG_FAILED
;
1600 /* bgp session-dscp */
1602 DEFPY (bgp_session_dscp
,
1603 bgp_session_dscp_cmd
,
1604 "bgp session-dscp (0-63)$dscp",
1606 "Override default (C6) bgp TCP session DSCP value\n"
1607 "Manually configured dscp parameter\n")
1609 bm
->tcp_dscp
= dscp
<< 2;
1614 DEFPY (no_bgp_session_dscp
,
1615 no_bgp_session_dscp_cmd
,
1616 "no bgp session-dscp [(0-63)]",
1619 "Override default (C6) bgp TCP session DSCP value\n"
1620 "Manually configured dscp parameter\n")
1622 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1627 /* BGP router-id. */
1629 DEFPY (bgp_router_id
,
1631 "bgp router-id A.B.C.D",
1633 "Override configured router identifier\n"
1634 "Manually configured router identifier\n")
1636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1637 bgp_router_id_static_set(bgp
, router_id
);
1641 DEFPY (no_bgp_router_id
,
1642 no_bgp_router_id_cmd
,
1643 "no bgp router-id [A.B.C.D]",
1646 "Override configured router identifier\n"
1647 "Manually configured router identifier\n")
1649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1651 if (router_id_str
) {
1652 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1653 vty_out(vty
, "%% BGP router-id doesn't match\n");
1654 return CMD_WARNING_CONFIG_FAILED
;
1658 router_id
.s_addr
= 0;
1659 bgp_router_id_static_set(bgp
, router_id
);
1664 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1665 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1667 "Add community specific parameters\n"
1668 "Create an alias for a community\n"
1669 "Community (AA:BB or AA:BB:CC)\n"
1672 struct community_alias ca
= {};
1673 struct community_alias
*lookup_community
;
1674 struct community_alias
*lookup_alias
;
1675 struct community
*comm
;
1676 struct lcommunity
*lcomm
;
1677 uint8_t invalid
= 0;
1679 comm
= community_str2com(community
);
1682 community_free(&comm
);
1684 lcomm
= lcommunity_str2com(community
);
1687 lcommunity_free(&lcomm
);
1690 vty_out(vty
, "Invalid community format\n");
1694 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1695 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1697 lookup_community
= bgp_ca_community_lookup(&ca
);
1698 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1701 bgp_ca_alias_delete(&ca
);
1702 bgp_ca_community_delete(&ca
);
1705 /* Lookup if community hash table has an item
1706 * with the same alias name.
1708 strlcpy(ca
.community
, lookup_alias
->community
,
1709 sizeof(ca
.community
));
1710 if (bgp_ca_community_lookup(&ca
)) {
1712 "community (%s) already has this alias (%s)\n",
1713 lookup_alias
->community
,
1714 lookup_alias
->alias
);
1717 bgp_ca_alias_delete(&ca
);
1720 if (lookup_community
) {
1721 /* Lookup if alias hash table has an item
1722 * with the same community.
1724 strlcpy(ca
.alias
, lookup_community
->alias
,
1726 if (bgp_ca_alias_lookup(&ca
)) {
1728 "alias (%s) already has this community (%s)\n",
1729 lookup_community
->alias
,
1730 lookup_community
->community
);
1733 bgp_ca_community_delete(&ca
);
1736 bgp_ca_alias_insert(&ca
);
1737 bgp_ca_community_insert(&ca
);
1743 DEFPY (bgp_global_suppress_fib_pending
,
1744 bgp_global_suppress_fib_pending_cmd
,
1745 "[no] bgp suppress-fib-pending",
1748 "Advertise only routes that are programmed in kernel to peers globally\n")
1750 bm_wait_for_fib_set(!no
);
1755 DEFPY (bgp_suppress_fib_pending
,
1756 bgp_suppress_fib_pending_cmd
,
1757 "[no] bgp suppress-fib-pending",
1760 "Advertise only routes that are programmed in kernel to peers\n")
1762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1764 bgp_suppress_fib_pending_set(bgp
, !no
);
1769 /* BGP Cluster ID. */
1770 DEFUN (bgp_cluster_id
,
1772 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1774 "Configure Route-Reflector Cluster-id\n"
1775 "Route-Reflector Cluster-id in IP address format\n"
1776 "Route-Reflector Cluster-id as 32 bit quantity\n")
1778 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1781 struct in_addr cluster
;
1783 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1785 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1786 return CMD_WARNING_CONFIG_FAILED
;
1789 bgp_cluster_id_set(bgp
, &cluster
);
1790 bgp_clear_star_soft_out(vty
, bgp
->name
);
1795 DEFUN (no_bgp_cluster_id
,
1796 no_bgp_cluster_id_cmd
,
1797 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1800 "Configure Route-Reflector Cluster-id\n"
1801 "Route-Reflector Cluster-id in IP address format\n"
1802 "Route-Reflector Cluster-id as 32 bit quantity\n")
1804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1805 bgp_cluster_id_unset(bgp
);
1806 bgp_clear_star_soft_out(vty
, bgp
->name
);
1815 "Disable BGP route installation to RIB (Zebra)\n")
1817 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1819 "%% No-RIB option is already set, nothing to do here.\n");
1823 bgp_option_norib_set_runtime();
1828 DEFPY (no_bgp_norib
,
1833 "Disable BGP route installation to RIB (Zebra)\n")
1835 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1837 "%% No-RIB option is not set, nothing to do here.\n");
1841 bgp_option_norib_unset_runtime();
1846 DEFPY (no_bgp_send_extra_data
,
1847 no_bgp_send_extra_data_cmd
,
1848 "[no] bgp send-extra-data zebra",
1851 "Extra data to Zebra for display/use\n"
1855 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1857 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1862 DEFUN (bgp_confederation_identifier
,
1863 bgp_confederation_identifier_cmd
,
1864 "bgp confederation identifier (1-4294967295)",
1866 "AS confederation parameters\n"
1868 "Set routing domain confederation AS\n")
1870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1874 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1876 bgp_confederation_id_set(bgp
, as
);
1881 DEFUN (no_bgp_confederation_identifier
,
1882 no_bgp_confederation_identifier_cmd
,
1883 "no bgp confederation identifier [(1-4294967295)]",
1886 "AS confederation parameters\n"
1888 "Set routing domain confederation AS\n")
1890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1891 bgp_confederation_id_unset(bgp
);
1896 DEFUN (bgp_confederation_peers
,
1897 bgp_confederation_peers_cmd
,
1898 "bgp confederation peers (1-4294967295)...",
1900 "AS confederation parameters\n"
1901 "Peer ASs in BGP confederation\n"
1904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1909 for (i
= idx_asn
; i
< argc
; i
++) {
1910 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1912 if (bgp
->as
== as
) {
1914 "%% Local member-AS not allowed in confed peer list\n");
1918 bgp_confederation_peers_add(bgp
, as
);
1923 DEFUN (no_bgp_confederation_peers
,
1924 no_bgp_confederation_peers_cmd
,
1925 "no bgp confederation peers (1-4294967295)...",
1928 "AS confederation parameters\n"
1929 "Peer ASs in BGP confederation\n"
1932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1937 for (i
= idx_asn
; i
< argc
; i
++) {
1938 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1940 bgp_confederation_peers_remove(bgp
, as
);
1946 * Central routine for maximum-paths configuration.
1947 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1948 * @set: 1 for setting values, 0 for removing the max-paths config.
1950 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1951 const char *mpaths
, uint16_t options
,
1954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1955 uint16_t maxpaths
= 0;
1960 afi
= bgp_node_afi(vty
);
1961 safi
= bgp_node_safi(vty
);
1964 maxpaths
= strtol(mpaths
, NULL
, 10);
1965 if (maxpaths
> multipath_num
) {
1967 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1968 maxpaths
, multipath_num
);
1969 return CMD_WARNING_CONFIG_FAILED
;
1971 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1974 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1978 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1979 (set
== 1) ? "" : "un",
1980 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1981 maxpaths
, afi
, safi
);
1982 return CMD_WARNING_CONFIG_FAILED
;
1985 bgp_recalculate_all_bestpaths(bgp
);
1990 DEFUN (bgp_maxmed_admin
,
1991 bgp_maxmed_admin_cmd
,
1992 "bgp max-med administrative ",
1994 "Advertise routes with max-med\n"
1995 "Administratively applied, for an indefinite period\n")
1997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1999 bgp
->v_maxmed_admin
= 1;
2000 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2002 bgp_maxmed_update(bgp
);
2007 DEFUN (bgp_maxmed_admin_medv
,
2008 bgp_maxmed_admin_medv_cmd
,
2009 "bgp max-med administrative (0-4294967295)",
2011 "Advertise routes with max-med\n"
2012 "Administratively applied, for an indefinite period\n"
2013 "Max MED value to be used\n")
2015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp
->v_maxmed_admin
= 1;
2019 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2021 bgp_maxmed_update(bgp
);
2026 DEFUN (no_bgp_maxmed_admin
,
2027 no_bgp_maxmed_admin_cmd
,
2028 "no bgp max-med administrative [(0-4294967295)]",
2031 "Advertise routes with max-med\n"
2032 "Administratively applied, for an indefinite period\n"
2033 "Max MED value to be used\n")
2035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2036 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2037 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2038 bgp_maxmed_update(bgp
);
2043 DEFUN (bgp_maxmed_onstartup
,
2044 bgp_maxmed_onstartup_cmd
,
2045 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2047 "Advertise routes with max-med\n"
2048 "Effective on a startup\n"
2049 "Time (seconds) period for max-med\n"
2050 "Max MED value to be used\n")
2052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2055 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2056 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2057 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2058 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2060 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2062 bgp_maxmed_update(bgp
);
2067 DEFUN (no_bgp_maxmed_onstartup
,
2068 no_bgp_maxmed_onstartup_cmd
,
2069 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2072 "Advertise routes with max-med\n"
2073 "Effective on a startup\n"
2074 "Time (seconds) period for max-med\n"
2075 "Max MED value to be used\n")
2077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 /* Cancel max-med onstartup if its on */
2080 if (bgp
->t_maxmed_onstartup
) {
2081 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2082 bgp
->maxmed_onstartup_over
= 1;
2085 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2086 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2088 bgp_maxmed_update(bgp
);
2093 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2094 uint16_t update_delay
,
2095 uint16_t establish_wait
)
2097 struct listnode
*node
, *nnode
;
2099 bool vrf_cfg
= false;
2102 * See if update-delay is set per-vrf and warn user to delete it
2103 * Note that we only need to check this if this is the first time
2104 * setting the global config.
2106 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2107 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2108 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2110 "%% update-delay configuration found in vrf %s\n",
2111 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2121 "%%Failed: global update-delay config not permitted\n");
2125 if (!establish_wait
) { /* update-delay <delay> */
2126 bm
->v_update_delay
= update_delay
;
2127 bm
->v_establish_wait
= bm
->v_update_delay
;
2129 /* update-delay <delay> <establish-wait> */
2130 if (update_delay
< establish_wait
) {
2132 "%%Failed: update-delay less than the establish-wait!\n");
2133 return CMD_WARNING_CONFIG_FAILED
;
2136 bm
->v_update_delay
= update_delay
;
2137 bm
->v_establish_wait
= establish_wait
;
2140 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2141 bgp
->v_update_delay
= bm
->v_update_delay
;
2142 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2148 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2150 struct listnode
*node
, *nnode
;
2153 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2154 bm
->v_establish_wait
= bm
->v_update_delay
;
2156 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2157 bgp
->v_update_delay
= bm
->v_update_delay
;
2158 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2164 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2165 uint16_t establish_wait
)
2167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2169 /* if configured globally, per-instance config is not allowed */
2170 if (bm
->v_update_delay
) {
2172 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2173 return CMD_WARNING_CONFIG_FAILED
;
2177 if (!establish_wait
) /* update-delay <delay> */
2179 bgp
->v_update_delay
= update_delay
;
2180 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2184 /* update-delay <delay> <establish-wait> */
2185 if (update_delay
< establish_wait
) {
2187 "%%Failed: update-delay less than the establish-wait!\n");
2188 return CMD_WARNING_CONFIG_FAILED
;
2191 bgp
->v_update_delay
= update_delay
;
2192 bgp
->v_establish_wait
= establish_wait
;
2197 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2201 /* If configured globally, cannot remove from one bgp instance */
2202 if (bm
->v_update_delay
) {
2204 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2205 return CMD_WARNING_CONFIG_FAILED
;
2207 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2208 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2213 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2215 /* If configured globally, no need to display per-instance value */
2216 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2217 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2218 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2219 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2224 /* Global update-delay configuration */
2225 DEFPY (bgp_global_update_delay
,
2226 bgp_global_update_delay_cmd
,
2227 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2229 "Force initial delay for best-path and updates for all bgp instances\n"
2230 "Max delay in seconds\n"
2231 "Establish wait in seconds\n")
2233 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2236 /* Global update-delay deconfiguration */
2237 DEFPY (no_bgp_global_update_delay
,
2238 no_bgp_global_update_delay_cmd
,
2239 "no bgp update-delay [(0-3600) [(1-3600)]]",
2242 "Force initial delay for best-path and updates\n"
2243 "Max delay in seconds\n"
2244 "Establish wait in seconds\n")
2246 return bgp_global_update_delay_deconfig_vty(vty
);
2249 /* Update-delay configuration */
2251 DEFPY (bgp_update_delay
,
2252 bgp_update_delay_cmd
,
2253 "update-delay (0-3600)$delay [(1-3600)$wait]",
2254 "Force initial delay for best-path and updates\n"
2255 "Max delay in seconds\n"
2256 "Establish wait in seconds\n")
2258 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2261 /* Update-delay deconfiguration */
2262 DEFPY (no_bgp_update_delay
,
2263 no_bgp_update_delay_cmd
,
2264 "no update-delay [(0-3600) [(1-3600)]]",
2266 "Force initial delay for best-path and updates\n"
2267 "Max delay in seconds\n"
2268 "Establish wait in seconds\n")
2270 return bgp_update_delay_deconfig_vty(vty
);
2274 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2279 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2280 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2285 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2290 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2291 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2296 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2299 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2300 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2301 vty_out(vty
, " write-quanta %d\n", quanta
);
2304 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2307 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2308 if (quanta
!= BGP_READ_PACKET_MAX
)
2309 vty_out(vty
, " read-quanta %d\n", quanta
);
2312 /* Packet quanta configuration
2314 * XXX: The value set here controls the size of a stack buffer in the IO
2315 * thread. When changing these limits be careful to prevent stack overflow.
2317 * Furthermore, the maximums used here should correspond to
2318 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2320 DEFPY (bgp_wpkt_quanta
,
2321 bgp_wpkt_quanta_cmd
,
2322 "[no] write-quanta (1-64)$quanta",
2324 "How many packets to write to peer socket per run\n"
2325 "Number of packets\n")
2327 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2330 DEFPY (bgp_rpkt_quanta
,
2331 bgp_rpkt_quanta_cmd
,
2332 "[no] read-quanta (1-10)$quanta",
2334 "How many packets to read from peer socket per I/O cycle\n"
2335 "Number of packets\n")
2337 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2340 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2342 if (!bgp
->heuristic_coalesce
)
2343 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2346 /* BGP TCP keepalive */
2347 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2349 if (bgp
->tcp_keepalive_idle
) {
2350 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2351 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2352 bgp
->tcp_keepalive_probes
);
2356 DEFUN (bgp_coalesce_time
,
2357 bgp_coalesce_time_cmd
,
2358 "coalesce-time (0-4294967295)",
2359 "Subgroup coalesce timer\n"
2360 "Subgroup coalesce timer value (in ms)\n")
2362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2366 bgp
->heuristic_coalesce
= false;
2368 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2369 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2374 DEFUN (no_bgp_coalesce_time
,
2375 no_bgp_coalesce_time_cmd
,
2376 "no coalesce-time (0-4294967295)",
2378 "Subgroup coalesce timer\n"
2379 "Subgroup coalesce timer value (in ms)\n")
2381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2383 bgp
->heuristic_coalesce
= true;
2384 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2388 /* Maximum-paths configuration */
2389 DEFUN (bgp_maxpaths
,
2391 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2392 "Forward packets over multiple paths\n"
2393 "Number of paths\n")
2396 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2397 argv
[idx_number
]->arg
, 0, 1);
2400 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2401 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2402 "Forward packets over multiple paths\n"
2403 "Number of paths\n")
2405 DEFUN (bgp_maxpaths_ibgp
,
2406 bgp_maxpaths_ibgp_cmd
,
2407 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2408 "Forward packets over multiple paths\n"
2410 "Number of paths\n")
2413 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2414 argv
[idx_number
]->arg
, 0, 1);
2417 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2418 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2419 "Forward packets over multiple paths\n"
2421 "Number of paths\n")
2423 DEFUN (bgp_maxpaths_ibgp_cluster
,
2424 bgp_maxpaths_ibgp_cluster_cmd
,
2425 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2426 "Forward packets over multiple paths\n"
2429 "Match the cluster length\n")
2432 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2433 argv
[idx_number
]->arg
, true, 1);
2436 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2437 "maximum-paths ibgp " CMD_RANGE_STR(
2438 1, MULTIPATH_NUM
) " equal-cluster-length",
2439 "Forward packets over multiple paths\n"
2442 "Match the cluster length\n")
2444 DEFUN (no_bgp_maxpaths
,
2445 no_bgp_maxpaths_cmd
,
2446 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2448 "Forward packets over multiple paths\n"
2449 "Number of paths\n")
2451 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2454 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2455 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2456 "Forward packets over multiple paths\n"
2457 "Number of paths\n")
2459 DEFUN (no_bgp_maxpaths_ibgp
,
2460 no_bgp_maxpaths_ibgp_cmd
,
2461 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2463 "Forward packets over multiple paths\n"
2466 "Match the cluster length\n")
2468 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2471 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2472 "no maximum-paths ibgp [" CMD_RANGE_STR(
2473 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2475 "Forward packets over multiple paths\n"
2478 "Match the cluster length\n")
2480 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2481 afi_t afi
, safi_t safi
)
2483 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2484 vty_out(vty
, " maximum-paths %d\n",
2485 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2488 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2489 vty_out(vty
, " maximum-paths ibgp %d",
2490 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2491 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2492 vty_out(vty
, " equal-cluster-length");
2501 "timers bgp (0-65535) (0-65535)",
2502 "Adjust routing timers\n"
2504 "Keepalive interval\n"
2507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2509 int idx_number_2
= 3;
2510 unsigned long keepalive
= 0;
2511 unsigned long holdtime
= 0;
2513 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2514 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2516 /* Holdtime value check. */
2517 if (holdtime
< 3 && holdtime
!= 0) {
2519 "%% hold time value must be either 0 or greater than 3\n");
2520 return CMD_WARNING_CONFIG_FAILED
;
2523 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2524 BGP_DEFAULT_DELAYOPEN
);
2529 DEFUN (no_bgp_timers
,
2531 "no timers bgp [(0-65535) (0-65535)]",
2533 "Adjust routing timers\n"
2535 "Keepalive interval\n"
2538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2539 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2540 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2545 /* BGP minimum holdtime. */
2547 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2548 "bgp minimum-holdtime (1-65535)",
2549 "BGP specific commands\n"
2550 "BGP minimum holdtime\n"
2553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2555 unsigned long min_holdtime
;
2557 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2559 bgp
->default_min_holdtime
= min_holdtime
;
2564 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2565 "no bgp minimum-holdtime [(1-65535)]",
2567 "BGP specific commands\n"
2568 "BGP minimum holdtime\n"
2571 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2573 bgp
->default_min_holdtime
= 0;
2578 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2579 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2581 "TCP keepalive parameters\n"
2582 "TCP keepalive idle time (seconds)\n"
2583 "TCP keepalive interval (seconds)\n"
2584 "TCP keepalive maximum probes\n")
2586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2588 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2594 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2595 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2598 "TCP keepalive parameters\n"
2599 "TCP keepalive idle time (seconds)\n"
2600 "TCP keepalive interval (seconds)\n"
2601 "TCP keepalive maximum probes\n")
2603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2605 bgp_tcp_keepalive_unset(bgp
);
2610 DEFUN (bgp_client_to_client_reflection
,
2611 bgp_client_to_client_reflection_cmd
,
2612 "bgp client-to-client reflection",
2614 "Configure client to client route reflection\n"
2615 "reflection of routes allowed\n")
2617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2618 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2619 bgp_clear_star_soft_out(vty
, bgp
->name
);
2624 DEFUN (no_bgp_client_to_client_reflection
,
2625 no_bgp_client_to_client_reflection_cmd
,
2626 "no bgp client-to-client reflection",
2629 "Configure client to client route reflection\n"
2630 "reflection of routes allowed\n")
2632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2633 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2634 bgp_clear_star_soft_out(vty
, bgp
->name
);
2639 /* "bgp always-compare-med" configuration. */
2640 DEFUN (bgp_always_compare_med
,
2641 bgp_always_compare_med_cmd
,
2642 "bgp always-compare-med",
2644 "Allow comparing MED from different neighbors\n")
2646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2647 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2648 bgp_recalculate_all_bestpaths(bgp
);
2653 DEFUN (no_bgp_always_compare_med
,
2654 no_bgp_always_compare_med_cmd
,
2655 "no bgp always-compare-med",
2658 "Allow comparing MED from different neighbors\n")
2660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2661 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2662 bgp_recalculate_all_bestpaths(bgp
);
2668 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2669 "bgp ebgp-requires-policy",
2671 "Require in and out policy for eBGP peers (RFC8212)\n")
2673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2674 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2678 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2679 "no bgp ebgp-requires-policy",
2682 "Require in and out policy for eBGP peers (RFC8212)\n")
2684 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2685 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2689 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2690 "bgp suppress-duplicates",
2692 "Suppress duplicate updates if the route actually not changed\n")
2694 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2695 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2699 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2700 "no bgp suppress-duplicates",
2703 "Suppress duplicate updates if the route actually not changed\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2710 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2711 "bgp reject-as-sets",
2713 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2716 struct listnode
*node
, *nnode
;
2719 bgp
->reject_as_sets
= true;
2721 /* Reset existing BGP sessions to reject routes
2722 * with aspath containing AS_SET or AS_CONFED_SET.
2724 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2725 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2726 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2727 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2728 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2735 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2736 "no bgp reject-as-sets",
2739 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2742 struct listnode
*node
, *nnode
;
2745 bgp
->reject_as_sets
= false;
2747 /* Reset existing BGP sessions to reject routes
2748 * with aspath containing AS_SET or AS_CONFED_SET.
2750 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2751 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2752 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2753 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2754 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2761 /* "bgp deterministic-med" configuration. */
2762 DEFUN (bgp_deterministic_med
,
2763 bgp_deterministic_med_cmd
,
2764 "bgp deterministic-med",
2766 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2770 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2771 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2772 bgp_recalculate_all_bestpaths(bgp
);
2778 DEFUN (no_bgp_deterministic_med
,
2779 no_bgp_deterministic_med_cmd
,
2780 "no bgp deterministic-med",
2783 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2785 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2786 int bestpath_per_as_used
;
2790 struct listnode
*node
, *nnode
;
2792 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2793 bestpath_per_as_used
= 0;
2795 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2796 FOREACH_AFI_SAFI (afi
, safi
)
2797 if (bgp_addpath_dmed_required(
2798 peer
->addpath_type
[afi
][safi
])) {
2799 bestpath_per_as_used
= 1;
2803 if (bestpath_per_as_used
)
2807 if (bestpath_per_as_used
) {
2809 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2810 return CMD_WARNING_CONFIG_FAILED
;
2812 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2813 bgp_recalculate_all_bestpaths(bgp
);
2820 /* "bgp graceful-restart mode" configuration. */
2821 DEFUN (bgp_graceful_restart
,
2822 bgp_graceful_restart_cmd
,
2823 "bgp graceful-restart",
2828 int ret
= BGP_GR_FAILURE
;
2830 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2831 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2833 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2835 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2837 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2840 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2841 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2843 "Graceful restart configuration changed, reset all peers to take effect\n");
2844 return bgp_vty_return(vty
, ret
);
2847 DEFUN (no_bgp_graceful_restart
,
2848 no_bgp_graceful_restart_cmd
,
2849 "no bgp graceful-restart",
2855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2857 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2858 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2860 int ret
= BGP_GR_FAILURE
;
2862 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2864 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2867 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2868 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2870 "Graceful restart configuration changed, reset all peers to take effect\n");
2872 return bgp_vty_return(vty
, ret
);
2875 DEFUN (bgp_graceful_restart_stalepath_time
,
2876 bgp_graceful_restart_stalepath_time_cmd
,
2877 "bgp graceful-restart stalepath-time (1-4095)",
2879 "Graceful restart capability parameters\n"
2880 "Set the max time to hold onto restarting peer's stale paths\n"
2881 "Delay value (seconds)\n")
2883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2887 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2888 bgp
->stalepath_time
= stalepath
;
2892 DEFUN (bgp_graceful_restart_restart_time
,
2893 bgp_graceful_restart_restart_time_cmd
,
2894 "bgp graceful-restart restart-time (0-4095)",
2896 "Graceful restart capability parameters\n"
2897 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2898 "Delay value (seconds)\n")
2900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2904 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2905 bgp
->restart_time
= restart
;
2909 DEFUN (bgp_graceful_restart_select_defer_time
,
2910 bgp_graceful_restart_select_defer_time_cmd
,
2911 "bgp graceful-restart select-defer-time (0-3600)",
2913 "Graceful restart capability parameters\n"
2914 "Set the time to defer the BGP route selection after restart\n"
2915 "Delay value (seconds, 0 - disable)\n")
2917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2919 uint32_t defer_time
;
2921 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2922 bgp
->select_defer_time
= defer_time
;
2923 if (defer_time
== 0)
2924 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2926 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2931 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2932 no_bgp_graceful_restart_stalepath_time_cmd
,
2933 "no bgp graceful-restart stalepath-time [(1-4095)]",
2936 "Graceful restart capability parameters\n"
2937 "Set the max time to hold onto restarting peer's stale paths\n"
2938 "Delay value (seconds)\n")
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2942 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2946 DEFUN (no_bgp_graceful_restart_restart_time
,
2947 no_bgp_graceful_restart_restart_time_cmd
,
2948 "no bgp graceful-restart restart-time [(0-4095)]",
2951 "Graceful restart capability parameters\n"
2952 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2953 "Delay value (seconds)\n")
2955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2957 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2961 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2962 no_bgp_graceful_restart_select_defer_time_cmd
,
2963 "no bgp graceful-restart select-defer-time [(0-3600)]",
2966 "Graceful restart capability parameters\n"
2967 "Set the time to defer the BGP route selection after restart\n"
2968 "Delay value (seconds)\n")
2970 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2972 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2973 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2978 DEFUN (bgp_graceful_restart_preserve_fw
,
2979 bgp_graceful_restart_preserve_fw_cmd
,
2980 "bgp graceful-restart preserve-fw-state",
2982 "Graceful restart capability parameters\n"
2983 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2986 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2990 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2991 no_bgp_graceful_restart_preserve_fw_cmd
,
2992 "no bgp graceful-restart preserve-fw-state",
2995 "Graceful restart capability parameters\n"
2996 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2999 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3003 DEFPY (bgp_graceful_restart_notification
,
3004 bgp_graceful_restart_notification_cmd
,
3005 "[no$no] bgp graceful-restart notification",
3008 "Graceful restart capability parameters\n"
3009 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3014 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3016 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3021 DEFPY (bgp_administrative_reset
,
3022 bgp_administrative_reset_cmd
,
3023 "[no$no] bgp hard-administrative-reset",
3026 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3031 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3033 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3038 DEFUN (bgp_graceful_restart_disable
,
3039 bgp_graceful_restart_disable_cmd
,
3040 "bgp graceful-restart-disable",
3044 int ret
= BGP_GR_FAILURE
;
3046 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3048 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3052 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3054 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3057 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3059 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3061 "Graceful restart configuration changed, reset all peers to take effect\n");
3063 return bgp_vty_return(vty
, ret
);
3066 DEFUN (no_bgp_graceful_restart_disable
,
3067 no_bgp_graceful_restart_disable_cmd
,
3068 "no bgp graceful-restart-disable",
3074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3076 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3078 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3080 int ret
= BGP_GR_FAILURE
;
3082 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3084 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3091 "Graceful restart configuration changed, reset all peers to take effect\n");
3093 return bgp_vty_return(vty
, ret
);
3096 DEFUN (bgp_neighbor_graceful_restart_set
,
3097 bgp_neighbor_graceful_restart_set_cmd
,
3098 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3106 int ret
= BGP_GR_FAILURE
;
3108 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3110 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3112 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3114 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3116 return CMD_WARNING_CONFIG_FAILED
;
3118 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3120 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3121 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3123 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3125 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3127 "Graceful restart configuration changed, reset this peer to take effect\n");
3129 return bgp_vty_return(vty
, ret
);
3132 DEFUN (no_bgp_neighbor_graceful_restart
,
3133 no_bgp_neighbor_graceful_restart_set_cmd
,
3134 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3142 int ret
= BGP_GR_FAILURE
;
3145 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3147 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3149 return CMD_WARNING_CONFIG_FAILED
;
3151 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3153 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3155 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3157 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3158 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3160 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3162 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3164 "Graceful restart configuration changed, reset this peer to take effect\n");
3166 return bgp_vty_return(vty
, ret
);
3169 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3170 bgp_neighbor_graceful_restart_helper_set_cmd
,
3171 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3174 GR_NEIGHBOR_HELPER_CMD
3179 int ret
= BGP_GR_FAILURE
;
3181 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3183 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3185 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3187 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3190 return CMD_WARNING_CONFIG_FAILED
;
3193 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3195 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3196 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3198 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3200 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3202 "Graceful restart configuration changed, reset this peer to take effect\n");
3204 return bgp_vty_return(vty
, ret
);
3207 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3208 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3209 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3213 NO_GR_NEIGHBOR_HELPER_CMD
3217 int ret
= BGP_GR_FAILURE
;
3220 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3222 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3224 return CMD_WARNING_CONFIG_FAILED
;
3226 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3228 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3230 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3232 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3233 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3235 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3237 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3239 "Graceful restart configuration changed, reset this peer to take effect\n");
3241 return bgp_vty_return(vty
, ret
);
3244 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3245 bgp_neighbor_graceful_restart_disable_set_cmd
,
3246 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3249 GR_NEIGHBOR_DISABLE_CMD
3254 int ret
= BGP_GR_FAILURE
;
3256 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3258 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3260 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3262 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3264 return CMD_WARNING_CONFIG_FAILED
;
3266 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3268 if (peer
->bgp
->t_startup
)
3269 bgp_peer_gr_flags_update(peer
);
3271 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3272 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3274 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3276 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3278 "Graceful restart configuration changed, reset this peer to take effect\n");
3280 return bgp_vty_return(vty
, ret
);
3283 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3284 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3285 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3289 NO_GR_NEIGHBOR_DISABLE_CMD
3293 int ret
= BGP_GR_FAILURE
;
3296 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3298 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3300 return CMD_WARNING_CONFIG_FAILED
;
3302 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3304 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3306 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3308 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3309 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3311 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3313 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3315 "Graceful restart configuration changed, reset this peer to take effect\n");
3317 return bgp_vty_return(vty
, ret
);
3320 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3321 bgp_graceful_restart_disable_eor_cmd
,
3322 "bgp graceful-restart disable-eor",
3324 "Graceful restart configuration parameters\n"
3325 "Disable EOR Check\n")
3327 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3328 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3333 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3334 no_bgp_graceful_restart_disable_eor_cmd
,
3335 "no bgp graceful-restart disable-eor",
3338 "Graceful restart configuration parameters\n"
3339 "Disable EOR Check\n")
3341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3342 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3347 DEFUN (bgp_graceful_restart_rib_stale_time
,
3348 bgp_graceful_restart_rib_stale_time_cmd
,
3349 "bgp graceful-restart rib-stale-time (1-3600)",
3351 "Graceful restart configuration parameters\n"
3352 "Specify the stale route removal timer in rib\n"
3353 "Delay value (seconds)\n")
3355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3357 uint32_t stale_time
;
3359 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3360 bgp
->rib_stale_time
= stale_time
;
3361 /* Send the stale timer update message to RIB */
3362 if (bgp_zebra_stale_timer_update(bgp
))
3368 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3369 no_bgp_graceful_restart_rib_stale_time_cmd
,
3370 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3373 "Graceful restart configuration parameters\n"
3374 "Specify the stale route removal timer in rib\n"
3375 "Delay value (seconds)\n")
3377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3379 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3380 /* Send the stale timer update message to RIB */
3381 if (bgp_zebra_stale_timer_update(bgp
))
3387 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3388 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3390 "Enable Long-lived Graceful Restart\n"
3391 "Specifies maximum time to wait before purging long-lived stale routes\n"
3392 "Stale time value (seconds)\n")
3394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3396 uint32_t llgr_stale_time
;
3398 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3399 bgp
->llgr_stale_time
= llgr_stale_time
;
3404 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3405 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3407 "Enable Long-lived Graceful Restart\n"
3408 "Specifies maximum time to wait before purging long-lived stale routes\n"
3409 "Stale time value (seconds)\n")
3411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3413 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3418 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3421 bgp_static_redo_import_check(bgp
);
3422 bgp_redistribute_redo(bgp
);
3423 bgp_clear_star_soft_out(vty
, bgp
->name
);
3424 bgp_clear_star_soft_in(vty
, bgp
->name
);
3427 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3429 struct listnode
*node
, *nnode
;
3431 bool vrf_cfg
= false;
3433 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3436 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3437 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3438 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3440 "%% graceful-shutdown configuration found in vrf %s\n",
3441 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3442 VRF_DEFAULT_NAME
: bgp
->name
);
3449 "%%Failed: global graceful-shutdown not permitted\n");
3453 /* Set flag globally */
3454 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3456 /* Initiate processing for all BGP instances. */
3457 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3458 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3463 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3465 struct listnode
*node
, *nnode
;
3468 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3471 /* Unset flag globally */
3472 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3474 /* Initiate processing for all BGP instances. */
3475 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3476 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3481 /* "bgp graceful-shutdown" configuration */
3482 DEFUN (bgp_graceful_shutdown
,
3483 bgp_graceful_shutdown_cmd
,
3484 "bgp graceful-shutdown",
3486 "Graceful shutdown parameters\n")
3488 if (vty
->node
== CONFIG_NODE
)
3489 return bgp_global_graceful_shutdown_config_vty(vty
);
3491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3493 /* if configured globally, per-instance config is not allowed */
3494 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3496 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3497 return CMD_WARNING_CONFIG_FAILED
;
3500 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3501 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3502 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3508 DEFUN (no_bgp_graceful_shutdown
,
3509 no_bgp_graceful_shutdown_cmd
,
3510 "no bgp graceful-shutdown",
3513 "Graceful shutdown parameters\n")
3515 if (vty
->node
== CONFIG_NODE
)
3516 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3520 /* If configured globally, cannot remove from one bgp instance */
3521 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3523 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3524 return CMD_WARNING_CONFIG_FAILED
;
3527 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3528 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3529 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3535 /* "bgp fast-external-failover" configuration. */
3536 DEFUN (bgp_fast_external_failover
,
3537 bgp_fast_external_failover_cmd
,
3538 "bgp fast-external-failover",
3540 "Immediately reset session if a link to a directly connected external peer goes down\n")
3542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3543 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3547 DEFUN (no_bgp_fast_external_failover
,
3548 no_bgp_fast_external_failover_cmd
,
3549 "no bgp fast-external-failover",
3552 "Immediately reset session if a link to a directly connected external peer goes down\n")
3554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3555 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3559 /* "bgp bestpath compare-routerid" configuration. */
3560 DEFUN (bgp_bestpath_compare_router_id
,
3561 bgp_bestpath_compare_router_id_cmd
,
3562 "bgp bestpath compare-routerid",
3564 "Change the default bestpath selection\n"
3565 "Compare router-id for identical EBGP paths\n")
3567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3568 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3569 bgp_recalculate_all_bestpaths(bgp
);
3574 DEFUN (no_bgp_bestpath_compare_router_id
,
3575 no_bgp_bestpath_compare_router_id_cmd
,
3576 "no bgp bestpath compare-routerid",
3579 "Change the default bestpath selection\n"
3580 "Compare router-id for identical EBGP paths\n")
3582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3583 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3584 bgp_recalculate_all_bestpaths(bgp
);
3589 /* "bgp bestpath as-path ignore" configuration. */
3590 DEFUN (bgp_bestpath_aspath_ignore
,
3591 bgp_bestpath_aspath_ignore_cmd
,
3592 "bgp bestpath as-path ignore",
3594 "Change the default bestpath selection\n"
3595 "AS-path attribute\n"
3596 "Ignore as-path length in selecting a route\n")
3598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3599 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3600 bgp_recalculate_all_bestpaths(bgp
);
3605 DEFUN (no_bgp_bestpath_aspath_ignore
,
3606 no_bgp_bestpath_aspath_ignore_cmd
,
3607 "no bgp bestpath as-path ignore",
3610 "Change the default bestpath selection\n"
3611 "AS-path attribute\n"
3612 "Ignore as-path length in selecting a route\n")
3614 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3615 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3616 bgp_recalculate_all_bestpaths(bgp
);
3621 /* "bgp bestpath as-path confed" configuration. */
3622 DEFUN (bgp_bestpath_aspath_confed
,
3623 bgp_bestpath_aspath_confed_cmd
,
3624 "bgp bestpath as-path confed",
3626 "Change the default bestpath selection\n"
3627 "AS-path attribute\n"
3628 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3631 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3632 bgp_recalculate_all_bestpaths(bgp
);
3637 DEFUN (no_bgp_bestpath_aspath_confed
,
3638 no_bgp_bestpath_aspath_confed_cmd
,
3639 "no bgp bestpath as-path confed",
3642 "Change the default bestpath selection\n"
3643 "AS-path attribute\n"
3644 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3647 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3648 bgp_recalculate_all_bestpaths(bgp
);
3653 /* "bgp bestpath as-path multipath-relax" configuration. */
3654 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3655 bgp_bestpath_aspath_multipath_relax_cmd
,
3656 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3658 "Change the default bestpath selection\n"
3659 "AS-path attribute\n"
3660 "Allow load sharing across routes that have different AS paths (but same length)\n"
3661 "Generate an AS_SET\n"
3662 "Do not generate an AS_SET\n")
3664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3666 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3668 /* no-as-set is now the default behavior so we can silently
3670 if (argv_find(argv
, argc
, "as-set", &idx
))
3671 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3673 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3675 bgp_recalculate_all_bestpaths(bgp
);
3680 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3681 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3682 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3685 "Change the default bestpath selection\n"
3686 "AS-path attribute\n"
3687 "Allow load sharing across routes that have different AS paths (but same length)\n"
3688 "Generate an AS_SET\n"
3689 "Do not generate an AS_SET\n")
3691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3692 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3693 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3694 bgp_recalculate_all_bestpaths(bgp
);
3699 /* "bgp bestpath peer-type multipath-relax" configuration. */
3700 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3701 bgp_bestpath_peer_type_multipath_relax_cmd
,
3702 "bgp bestpath peer-type multipath-relax",
3704 "Change the default bestpath selection\n"
3706 "Allow load sharing across routes learned from different peer types\n")
3708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3709 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3710 bgp_recalculate_all_bestpaths(bgp
);
3715 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3716 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3717 "no bgp bestpath peer-type multipath-relax",
3719 "Change the default bestpath selection\n"
3721 "Allow load sharing across routes learned from different peer types\n")
3723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3724 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3725 bgp_recalculate_all_bestpaths(bgp
);
3730 /* "bgp log-neighbor-changes" configuration. */
3731 DEFUN (bgp_log_neighbor_changes
,
3732 bgp_log_neighbor_changes_cmd
,
3733 "bgp log-neighbor-changes",
3735 "Log neighbor up/down and reset reason\n")
3737 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3738 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3742 DEFUN (no_bgp_log_neighbor_changes
,
3743 no_bgp_log_neighbor_changes_cmd
,
3744 "no bgp log-neighbor-changes",
3747 "Log neighbor up/down and reset reason\n")
3749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3750 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3754 /* "bgp bestpath med" configuration. */
3755 DEFUN (bgp_bestpath_med
,
3756 bgp_bestpath_med_cmd
,
3757 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3759 "Change the default bestpath selection\n"
3761 "Compare MED among confederation paths\n"
3762 "Treat missing MED as the least preferred one\n"
3763 "Treat missing MED as the least preferred one\n"
3764 "Compare MED among confederation paths\n")
3766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3769 if (argv_find(argv
, argc
, "confed", &idx
))
3770 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3772 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3773 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3775 bgp_recalculate_all_bestpaths(bgp
);
3780 DEFUN (no_bgp_bestpath_med
,
3781 no_bgp_bestpath_med_cmd
,
3782 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3785 "Change the default bestpath selection\n"
3787 "Compare MED among confederation paths\n"
3788 "Treat missing MED as the least preferred one\n"
3789 "Treat missing MED as the least preferred one\n"
3790 "Compare MED among confederation paths\n")
3792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3795 if (argv_find(argv
, argc
, "confed", &idx
))
3796 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3798 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3799 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3801 bgp_recalculate_all_bestpaths(bgp
);
3806 /* "bgp bestpath bandwidth" configuration. */
3807 DEFPY (bgp_bestpath_bw
,
3808 bgp_bestpath_bw_cmd
,
3809 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3811 "Change the default bestpath selection\n"
3812 "Link Bandwidth attribute\n"
3813 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3814 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3815 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3822 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3823 return CMD_ERR_INCOMPLETE
;
3825 if (!strcmp(bw_cfg
, "ignore"))
3826 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3827 else if (!strcmp(bw_cfg
, "skip-missing"))
3828 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3829 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3830 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3832 return CMD_ERR_NO_MATCH
;
3834 /* This config is used in route install, so redo that. */
3835 FOREACH_AFI_SAFI (afi
, safi
) {
3836 if (!bgp_fibupd_safi(safi
))
3838 bgp_zebra_announce_table(bgp
, afi
, safi
);
3844 DEFPY (no_bgp_bestpath_bw
,
3845 no_bgp_bestpath_bw_cmd
,
3846 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3849 "Change the default bestpath selection\n"
3850 "Link Bandwidth attribute\n"
3851 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3852 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3853 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3859 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3861 /* This config is used in route install, so redo that. */
3862 FOREACH_AFI_SAFI (afi
, safi
) {
3863 if (!bgp_fibupd_safi(safi
))
3865 bgp_zebra_announce_table(bgp
, afi
, safi
);
3870 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3871 "[no] bgp default <ipv4-unicast|"
3874 "ipv4-labeled-unicast|"
3879 "ipv6-labeled-unicast|"
3881 "l2vpn-evpn>$afi_safi",
3884 "Configure BGP defaults\n"
3885 "Activate ipv4-unicast for a peer by default\n"
3886 "Activate ipv4-multicast for a peer by default\n"
3887 "Activate ipv4-vpn for a peer by default\n"
3888 "Activate ipv4-labeled-unicast for a peer by default\n"
3889 "Activate ipv4-flowspec for a peer by default\n"
3890 "Activate ipv6-unicast for a peer by default\n"
3891 "Activate ipv6-multicast for a peer by default\n"
3892 "Activate ipv6-vpn for a peer by default\n"
3893 "Activate ipv6-labeled-unicast for a peer by default\n"
3894 "Activate ipv6-flowspec for a peer by default\n"
3895 "Activate l2vpn-evpn for a peer by default\n")
3897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3898 char afi_safi_str
[strlen(afi_safi
) + 1];
3899 char *afi_safi_str_tok
;
3901 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3902 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3903 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3904 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3908 * Impossible situation but making coverity happy
3910 assert(afi
!= AFI_MAX
);
3912 if (strmatch(safi_str
, "labeled"))
3913 safi
= bgp_vty_safi_from_str("labeled-unicast");
3915 safi
= bgp_vty_safi_from_str(safi_str
);
3917 assert(safi
!= SAFI_MAX
);
3919 bgp
->default_af
[afi
][safi
] = false;
3921 if ((safi
== SAFI_LABELED_UNICAST
3922 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3923 || (safi
== SAFI_UNICAST
3924 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3925 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3927 bgp
->default_af
[afi
][safi
] = true;
3933 /* Display hostname in certain command outputs */
3934 DEFUN (bgp_default_show_hostname
,
3935 bgp_default_show_hostname_cmd
,
3936 "bgp default show-hostname",
3938 "Configure BGP defaults\n"
3939 "Show hostname in certain command outputs\n")
3941 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3942 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3946 DEFUN (no_bgp_default_show_hostname
,
3947 no_bgp_default_show_hostname_cmd
,
3948 "no bgp default show-hostname",
3951 "Configure BGP defaults\n"
3952 "Show hostname in certain command outputs\n")
3954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3955 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3959 /* Display hostname in certain command outputs */
3960 DEFUN (bgp_default_show_nexthop_hostname
,
3961 bgp_default_show_nexthop_hostname_cmd
,
3962 "bgp default show-nexthop-hostname",
3964 "Configure BGP defaults\n"
3965 "Show hostname for nexthop in certain command outputs\n")
3967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3968 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3972 DEFUN (no_bgp_default_show_nexthop_hostname
,
3973 no_bgp_default_show_nexthop_hostname_cmd
,
3974 "no bgp default show-nexthop-hostname",
3977 "Configure BGP defaults\n"
3978 "Show hostname for nexthop in certain command outputs\n")
3980 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3981 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3985 /* "bgp network import-check" configuration. */
3986 DEFUN (bgp_network_import_check
,
3987 bgp_network_import_check_cmd
,
3988 "bgp network import-check",
3990 "BGP network command\n"
3991 "Check BGP network route exists in IGP\n")
3993 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3994 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3995 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3996 bgp_static_redo_import_check(bgp
);
4002 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4003 "bgp network import-check exact",
4005 "BGP network command\n"
4006 "Check BGP network route exists in IGP\n"
4007 "Match route precisely\n")
4009 DEFUN (no_bgp_network_import_check
,
4010 no_bgp_network_import_check_cmd
,
4011 "no bgp network import-check",
4014 "BGP network command\n"
4015 "Check BGP network route exists in IGP\n")
4017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4018 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4019 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4020 bgp_static_redo_import_check(bgp
);
4026 DEFUN (bgp_default_local_preference
,
4027 bgp_default_local_preference_cmd
,
4028 "bgp default local-preference (0-4294967295)",
4030 "Configure BGP defaults\n"
4031 "local preference (higher=more preferred)\n"
4032 "Configure default local preference value\n")
4034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4036 uint32_t local_pref
;
4038 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4040 bgp_default_local_preference_set(bgp
, local_pref
);
4041 bgp_clear_star_soft_in(vty
, bgp
->name
);
4046 DEFUN (no_bgp_default_local_preference
,
4047 no_bgp_default_local_preference_cmd
,
4048 "no bgp default local-preference [(0-4294967295)]",
4051 "Configure BGP defaults\n"
4052 "local preference (higher=more preferred)\n"
4053 "Configure default local preference value\n")
4055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4056 bgp_default_local_preference_unset(bgp
);
4057 bgp_clear_star_soft_in(vty
, bgp
->name
);
4063 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4064 bgp_default_subgroup_pkt_queue_max_cmd
,
4065 "bgp default subgroup-pkt-queue-max (20-100)",
4067 "Configure BGP defaults\n"
4068 "subgroup-pkt-queue-max\n"
4069 "Configure subgroup packet queue max\n")
4071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4075 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4077 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4082 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4083 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4084 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4087 "Configure BGP defaults\n"
4088 "subgroup-pkt-queue-max\n"
4089 "Configure subgroup packet queue max\n")
4091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4092 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4097 DEFUN (bgp_rr_allow_outbound_policy
,
4098 bgp_rr_allow_outbound_policy_cmd
,
4099 "bgp route-reflector allow-outbound-policy",
4101 "Allow modifications made by out route-map\n"
4102 "on ibgp neighbors\n")
4104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4106 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4107 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4108 update_group_announce_rrclients(bgp
);
4109 bgp_clear_star_soft_out(vty
, bgp
->name
);
4115 DEFUN (no_bgp_rr_allow_outbound_policy
,
4116 no_bgp_rr_allow_outbound_policy_cmd
,
4117 "no bgp route-reflector allow-outbound-policy",
4120 "Allow modifications made by out route-map\n"
4121 "on ibgp neighbors\n")
4123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4125 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4126 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4127 update_group_announce_rrclients(bgp
);
4128 bgp_clear_star_soft_out(vty
, bgp
->name
);
4134 DEFUN (bgp_listen_limit
,
4135 bgp_listen_limit_cmd
,
4136 "bgp listen limit (1-65535)",
4138 "BGP Dynamic Neighbors listen commands\n"
4139 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4140 "Configure Dynamic Neighbors listen limit value\n")
4142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4146 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4148 bgp_listen_limit_set(bgp
, listen_limit
);
4153 DEFUN (no_bgp_listen_limit
,
4154 no_bgp_listen_limit_cmd
,
4155 "no bgp listen limit [(1-65535)]",
4158 "BGP Dynamic Neighbors listen commands\n"
4159 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4160 "Configure Dynamic Neighbors listen limit value\n")
4162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4163 bgp_listen_limit_unset(bgp
);
4169 * Check if this listen range is already configured. Check for exact
4170 * match or overlap based on input.
4172 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4173 struct prefix
*range
, int exact
)
4175 struct listnode
*node
, *nnode
;
4176 struct listnode
*node1
, *nnode1
;
4177 struct peer_group
*group
;
4182 afi
= family2afi(range
->family
);
4183 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4184 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4187 match
= prefix_same(range
, lr
);
4189 match
= (prefix_match(range
, lr
)
4190 || prefix_match(lr
, range
));
4199 DEFUN (bgp_listen_range
,
4200 bgp_listen_range_cmd
,
4201 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4203 "Configure BGP dynamic neighbors listen range\n"
4204 "Configure BGP dynamic neighbors listen range\n"
4206 "Member of the peer-group\n"
4207 "Peer-group name\n")
4209 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4210 struct prefix range
;
4211 struct peer_group
*group
, *existing_group
;
4216 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4217 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4218 char *prefix
= argv
[idx
]->arg
;
4219 argv_find(argv
, argc
, "PGNAME", &idx
);
4220 char *peergroup
= argv
[idx
]->arg
;
4222 /* Convert IP prefix string to struct prefix. */
4223 ret
= str2prefix(prefix
, &range
);
4225 vty_out(vty
, "%% Malformed listen range\n");
4226 return CMD_WARNING_CONFIG_FAILED
;
4229 afi
= family2afi(range
.family
);
4231 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4233 "%% Malformed listen range (link-local address)\n");
4234 return CMD_WARNING_CONFIG_FAILED
;
4239 /* Check if same listen range is already configured. */
4240 existing_group
= listen_range_exists(bgp
, &range
, 1);
4241 if (existing_group
) {
4242 if (strcmp(existing_group
->name
, peergroup
) == 0)
4246 "%% Same listen range is attached to peer-group %s\n",
4247 existing_group
->name
);
4248 return CMD_WARNING_CONFIG_FAILED
;
4252 /* Check if an overlapping listen range exists. */
4253 if (listen_range_exists(bgp
, &range
, 0)) {
4255 "%% Listen range overlaps with existing listen range\n");
4256 return CMD_WARNING_CONFIG_FAILED
;
4259 group
= peer_group_lookup(bgp
, peergroup
);
4261 vty_out(vty
, "%% Configure the peer-group first\n");
4262 return CMD_WARNING_CONFIG_FAILED
;
4265 ret
= peer_group_listen_range_add(group
, &range
);
4266 return bgp_vty_return(vty
, ret
);
4269 DEFUN (no_bgp_listen_range
,
4270 no_bgp_listen_range_cmd
,
4271 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4274 "Unconfigure BGP dynamic neighbors listen range\n"
4275 "Unconfigure BGP dynamic neighbors listen range\n"
4277 "Member of the peer-group\n"
4278 "Peer-group name\n")
4280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4281 struct prefix range
;
4282 struct peer_group
*group
;
4287 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4288 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4289 char *prefix
= argv
[idx
]->arg
;
4290 argv_find(argv
, argc
, "PGNAME", &idx
);
4291 char *peergroup
= argv
[idx
]->arg
;
4293 /* Convert IP prefix string to struct prefix. */
4294 ret
= str2prefix(prefix
, &range
);
4296 vty_out(vty
, "%% Malformed listen range\n");
4297 return CMD_WARNING_CONFIG_FAILED
;
4300 afi
= family2afi(range
.family
);
4302 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4304 "%% Malformed listen range (link-local address)\n");
4305 return CMD_WARNING_CONFIG_FAILED
;
4310 group
= peer_group_lookup(bgp
, peergroup
);
4312 vty_out(vty
, "%% Peer-group does not exist\n");
4313 return CMD_WARNING_CONFIG_FAILED
;
4316 ret
= peer_group_listen_range_del(group
, &range
);
4317 return bgp_vty_return(vty
, ret
);
4320 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4322 struct peer_group
*group
;
4323 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4324 struct prefix
*range
;
4327 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4328 vty_out(vty
, " bgp listen limit %d\n",
4329 bgp
->dynamic_neighbors_limit
);
4331 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4332 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4333 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4336 " bgp listen range %pFX peer-group %s\n",
4337 range
, group
->name
);
4344 DEFUN (bgp_disable_connected_route_check
,
4345 bgp_disable_connected_route_check_cmd
,
4346 "bgp disable-ebgp-connected-route-check",
4348 "Disable checking if nexthop is connected on ebgp sessions\n")
4350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4351 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4352 bgp_clear_star_soft_in(vty
, bgp
->name
);
4357 DEFUN (no_bgp_disable_connected_route_check
,
4358 no_bgp_disable_connected_route_check_cmd
,
4359 "no bgp disable-ebgp-connected-route-check",
4362 "Disable checking if nexthop is connected on ebgp sessions\n")
4364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4365 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4366 bgp_clear_star_soft_in(vty
, bgp
->name
);
4372 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4378 int as_type
= AS_SPECIFIED
;
4381 if (as_str
[0] == 'i') {
4383 as_type
= AS_INTERNAL
;
4384 } else if (as_str
[0] == 'e') {
4386 as_type
= AS_EXTERNAL
;
4388 /* Get AS number. */
4389 as
= strtoul(as_str
, NULL
, 10);
4392 /* If peer is peer group or interface peer, call proper function. */
4393 ret
= str2sockunion(peer_str
, &su
);
4397 /* Check if existing interface peer */
4398 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4400 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4402 /* if not interface peer, check peer-group settings */
4403 if (ret
< 0 && !peer
) {
4404 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4407 "%% Create the peer-group or interface first\n");
4408 return CMD_WARNING_CONFIG_FAILED
;
4413 if (peer_address_self_check(bgp
, &su
)) {
4415 "%% Can not configure the local system as neighbor\n");
4416 return CMD_WARNING_CONFIG_FAILED
;
4418 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4421 return bgp_vty_return(vty
, ret
);
4424 DEFUN (bgp_default_shutdown
,
4425 bgp_default_shutdown_cmd
,
4426 "[no] bgp default shutdown",
4429 "Configure BGP defaults\n"
4430 "Apply administrative shutdown to newly configured peers\n")
4432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4433 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4437 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4439 "Administrative shutdown of the BGP instance\n"
4440 "Add a shutdown message (RFC 8203)\n"
4441 "Shutdown message\n")
4443 char *msgstr
= NULL
;
4445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4448 msgstr
= argv_concat(argv
, argc
, 3);
4450 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4451 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4452 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4453 return CMD_WARNING_CONFIG_FAILED
;
4456 bgp_shutdown_enable(bgp
, msgstr
);
4457 XFREE(MTYPE_TMP
, msgstr
);
4462 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4463 BGP_STR
"Administrative shutdown of the BGP instance\n")
4465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4467 bgp_shutdown_enable(bgp
, NULL
);
4472 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4473 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4477 bgp_shutdown_disable(bgp
);
4482 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4483 "no bgp shutdown message MSG...", NO_STR BGP_STR
4484 "Administrative shutdown of the BGP instance\n"
4485 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4487 DEFUN (neighbor_remote_as
,
4488 neighbor_remote_as_cmd
,
4489 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4492 "Specify a BGP neighbor\n"
4494 "Internal BGP peer\n"
4495 "External BGP peer\n")
4498 int idx_remote_as
= 3;
4499 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4500 argv
[idx_remote_as
]->arg
);
4503 DEFPY (bgp_allow_martian
,
4504 bgp_allow_martian_cmd
,
4505 "[no]$no bgp allow-martian-nexthop",
4508 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4513 bgp
->allow_martian
= false;
4515 bgp
->allow_martian
= true;
4520 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4521 * sessions do not wait for hold timer expiry to bring down the sessions
4522 * when nexthop becomes unreachable
4524 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4525 BGP_STR
"Fast convergence for bgp sessions\n")
4527 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4528 bgp
->fast_convergence
= true;
4533 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4534 "no bgp fast-convergence",
4535 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4538 bgp
->fast_convergence
= false;
4543 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4545 const char *peer_group_name
,
4548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4550 int as_type
= AS_UNSPECIFIED
;
4552 struct peer_group
*group
;
4555 group
= peer_group_lookup(bgp
, conf_if
);
4558 vty_out(vty
, "%% Name conflict with peer-group \n");
4559 return CMD_WARNING_CONFIG_FAILED
;
4563 if (as_str
[0] == 'i') {
4564 as_type
= AS_INTERNAL
;
4565 } else if (as_str
[0] == 'e') {
4566 as_type
= AS_EXTERNAL
;
4568 /* Get AS number. */
4569 as
= strtoul(as_str
, NULL
, 10);
4570 as_type
= AS_SPECIFIED
;
4574 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4577 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4579 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4583 vty_out(vty
, "%% BGP failed to create peer\n");
4584 return CMD_WARNING_CONFIG_FAILED
;
4588 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4590 /* Request zebra to initiate IPv6 RAs on this interface. We do
4592 * any unnumbered peer in order to not worry about run-time
4594 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4596 * gets deleted later etc.)
4599 bgp_zebra_initiate_radv(bgp
, peer
);
4602 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4603 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4605 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4607 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4609 /* v6only flag changed. Reset bgp seesion */
4610 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4611 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4612 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4613 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4615 bgp_session_reset(peer
);
4618 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4619 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4620 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4621 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4624 if (peer_group_name
) {
4625 group
= peer_group_lookup(bgp
, peer_group_name
);
4627 vty_out(vty
, "%% Configure the peer-group first\n");
4628 return CMD_WARNING_CONFIG_FAILED
;
4631 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4634 return bgp_vty_return(vty
, ret
);
4637 DEFUN (neighbor_interface_config
,
4638 neighbor_interface_config_cmd
,
4639 "neighbor WORD interface [peer-group PGNAME]",
4641 "Interface name or neighbor tag\n"
4642 "Enable BGP on interface\n"
4643 "Member of the peer-group\n"
4644 "Peer-group name\n")
4647 int idx_peer_group_word
= 4;
4649 if (argc
> idx_peer_group_word
)
4650 return peer_conf_interface_get(
4651 vty
, argv
[idx_word
]->arg
, 0,
4652 argv
[idx_peer_group_word
]->arg
, NULL
);
4654 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4658 DEFUN (neighbor_interface_config_v6only
,
4659 neighbor_interface_config_v6only_cmd
,
4660 "neighbor WORD interface v6only [peer-group PGNAME]",
4662 "Interface name or neighbor tag\n"
4663 "Enable BGP on interface\n"
4664 "Enable BGP with v6 link-local only\n"
4665 "Member of the peer-group\n"
4666 "Peer-group name\n")
4669 int idx_peer_group_word
= 5;
4671 if (argc
> idx_peer_group_word
)
4672 return peer_conf_interface_get(
4673 vty
, argv
[idx_word
]->arg
, 1,
4674 argv
[idx_peer_group_word
]->arg
, NULL
);
4676 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4680 DEFUN (neighbor_interface_config_remote_as
,
4681 neighbor_interface_config_remote_as_cmd
,
4682 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4684 "Interface name or neighbor tag\n"
4685 "Enable BGP on interface\n"
4686 "Specify a BGP neighbor\n"
4688 "Internal BGP peer\n"
4689 "External BGP peer\n")
4692 int idx_remote_as
= 4;
4693 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4694 argv
[idx_remote_as
]->arg
);
4697 DEFUN (neighbor_interface_v6only_config_remote_as
,
4698 neighbor_interface_v6only_config_remote_as_cmd
,
4699 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4701 "Interface name or neighbor tag\n"
4702 "Enable BGP with v6 link-local only\n"
4703 "Enable BGP on interface\n"
4704 "Specify a BGP neighbor\n"
4706 "Internal BGP peer\n"
4707 "External BGP peer\n")
4710 int idx_remote_as
= 5;
4711 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4712 argv
[idx_remote_as
]->arg
);
4715 DEFUN (neighbor_peer_group
,
4716 neighbor_peer_group_cmd
,
4717 "neighbor WORD peer-group",
4719 "Interface name or neighbor tag\n"
4720 "Configure peer-group\n")
4722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4725 struct peer_group
*group
;
4727 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4729 vty_out(vty
, "%% Name conflict with interface: \n");
4730 return CMD_WARNING_CONFIG_FAILED
;
4733 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4735 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4736 return CMD_WARNING_CONFIG_FAILED
;
4744 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4748 "Specify a BGP neighbor\n"
4750 "Internal BGP peer\n"
4751 "External BGP peer\n")
4753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4757 struct peer_group
*group
;
4761 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4763 /* look up for neighbor by interface name config. */
4764 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4766 /* Request zebra to terminate IPv6 RAs on this
4769 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4770 peer_notify_unconfig(peer
);
4775 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4777 peer_group_notify_unconfig(group
);
4778 peer_group_delete(group
);
4780 vty_out(vty
, "%% Create the peer-group first\n");
4781 return CMD_WARNING_CONFIG_FAILED
;
4784 peer
= peer_lookup(bgp
, &su
);
4786 if (peer_dynamic_neighbor(peer
)) {
4788 "%% Operation not allowed on a dynamic neighbor\n");
4789 return CMD_WARNING_CONFIG_FAILED
;
4792 other
= peer
->doppelganger
;
4794 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4795 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4797 peer_notify_unconfig(peer
);
4799 if (other
&& other
->status
!= Deleted
) {
4800 peer_notify_unconfig(other
);
4809 DEFUN (no_neighbor_interface_config
,
4810 no_neighbor_interface_config_cmd
,
4811 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4815 "Configure BGP on interface\n"
4816 "Enable BGP with v6 link-local only\n"
4817 "Member of the peer-group\n"
4819 "Specify a BGP neighbor\n"
4821 "Internal BGP peer\n"
4822 "External BGP peer\n")
4824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4828 /* look up for neighbor by interface name config. */
4829 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4831 /* Request zebra to terminate IPv6 RAs on this interface. */
4833 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4834 peer_notify_unconfig(peer
);
4837 vty_out(vty
, "%% Create the bgp interface first\n");
4838 return CMD_WARNING_CONFIG_FAILED
;
4843 DEFUN (no_neighbor_peer_group
,
4844 no_neighbor_peer_group_cmd
,
4845 "no neighbor WORD peer-group",
4849 "Configure peer-group\n")
4851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4853 struct peer_group
*group
;
4855 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4857 peer_group_notify_unconfig(group
);
4858 peer_group_delete(group
);
4860 vty_out(vty
, "%% Create the peer-group first\n");
4861 return CMD_WARNING_CONFIG_FAILED
;
4866 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4867 no_neighbor_interface_peer_group_remote_as_cmd
,
4868 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4871 "Interface name or neighbor tag\n"
4872 "Specify a BGP neighbor\n"
4874 "Internal BGP peer\n"
4875 "External BGP peer\n")
4877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4879 struct peer_group
*group
;
4882 /* look up for neighbor by interface name config. */
4883 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4885 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4889 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4891 peer_group_remote_as_delete(group
);
4893 vty_out(vty
, "%% Create the peer-group or interface first\n");
4894 return CMD_WARNING_CONFIG_FAILED
;
4899 DEFUN (neighbor_local_as
,
4900 neighbor_local_as_cmd
,
4901 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4904 "Specify a local-as number\n"
4905 "AS number used as local AS\n")
4913 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4915 return CMD_WARNING_CONFIG_FAILED
;
4917 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4918 ret
= peer_local_as_set(peer
, as
, 0, 0);
4919 return bgp_vty_return(vty
, ret
);
4922 DEFUN (neighbor_local_as_no_prepend
,
4923 neighbor_local_as_no_prepend_cmd
,
4924 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4927 "Specify a local-as number\n"
4928 "AS number used as local AS\n"
4929 "Do not prepend local-as to updates from ebgp peers\n")
4937 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4939 return CMD_WARNING_CONFIG_FAILED
;
4941 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4942 ret
= peer_local_as_set(peer
, as
, 1, 0);
4943 return bgp_vty_return(vty
, ret
);
4946 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4947 neighbor_local_as_no_prepend_replace_as_cmd
,
4948 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4951 "Specify a local-as number\n"
4952 "AS number used as local AS\n"
4953 "Do not prepend local-as to updates from ebgp peers\n"
4954 "Do not prepend local-as to updates from ibgp peers\n")
4962 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4964 return CMD_WARNING_CONFIG_FAILED
;
4966 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4967 ret
= peer_local_as_set(peer
, as
, 1, 1);
4968 return bgp_vty_return(vty
, ret
);
4971 DEFUN (no_neighbor_local_as
,
4972 no_neighbor_local_as_cmd
,
4973 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4977 "Specify a local-as number\n"
4978 "AS number used as local AS\n"
4979 "Do not prepend local-as to updates from ebgp peers\n"
4980 "Do not prepend local-as to updates from ibgp peers\n")
4986 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4988 return CMD_WARNING_CONFIG_FAILED
;
4990 ret
= peer_local_as_unset(peer
);
4991 return bgp_vty_return(vty
, ret
);
4995 DEFUN (neighbor_solo
,
4997 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5000 "Solo peer - part of its own update group\n")
5006 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5008 return CMD_WARNING_CONFIG_FAILED
;
5010 ret
= update_group_adjust_soloness(peer
, 1);
5011 return bgp_vty_return(vty
, ret
);
5014 DEFUN (no_neighbor_solo
,
5015 no_neighbor_solo_cmd
,
5016 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5020 "Solo peer - part of its own update group\n")
5026 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5028 return CMD_WARNING_CONFIG_FAILED
;
5030 ret
= update_group_adjust_soloness(peer
, 0);
5031 return bgp_vty_return(vty
, ret
);
5034 DEFUN (neighbor_password
,
5035 neighbor_password_cmd
,
5036 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5047 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5049 return CMD_WARNING_CONFIG_FAILED
;
5051 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5052 return bgp_vty_return(vty
, ret
);
5055 DEFUN (no_neighbor_password
,
5056 no_neighbor_password_cmd
,
5057 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5068 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5070 return CMD_WARNING_CONFIG_FAILED
;
5072 ret
= peer_password_unset(peer
);
5073 return bgp_vty_return(vty
, ret
);
5076 DEFUN (neighbor_activate
,
5077 neighbor_activate_cmd
,
5078 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5081 "Enable the Address Family for this Neighbor\n")
5087 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5089 return CMD_WARNING_CONFIG_FAILED
;
5091 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5092 return bgp_vty_return(vty
, ret
);
5095 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5096 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5097 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5098 "Enable the Address Family for this Neighbor\n")
5100 DEFUN (no_neighbor_activate
,
5101 no_neighbor_activate_cmd
,
5102 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5106 "Enable the Address Family for this Neighbor\n")
5113 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5115 return CMD_WARNING_CONFIG_FAILED
;
5117 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5118 return bgp_vty_return(vty
, ret
);
5121 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5122 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5123 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5124 "Enable the Address Family for this Neighbor\n")
5126 DEFUN (neighbor_set_peer_group
,
5127 neighbor_set_peer_group_cmd
,
5128 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5131 "Member of the peer-group\n"
5132 "Peer-group name\n")
5134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5141 struct peer_group
*group
;
5143 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5145 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5147 vty_out(vty
, "%% Malformed address or name: %s\n",
5148 argv
[idx_peer
]->arg
);
5149 return CMD_WARNING_CONFIG_FAILED
;
5152 if (peer_address_self_check(bgp
, &su
)) {
5154 "%% Can not configure the local system as neighbor\n");
5155 return CMD_WARNING_CONFIG_FAILED
;
5158 /* Disallow for dynamic neighbor. */
5159 peer
= peer_lookup(bgp
, &su
);
5160 if (peer
&& peer_dynamic_neighbor(peer
)) {
5162 "%% Operation not allowed on a dynamic neighbor\n");
5163 return CMD_WARNING_CONFIG_FAILED
;
5167 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5169 vty_out(vty
, "%% Configure the peer-group first\n");
5170 return CMD_WARNING_CONFIG_FAILED
;
5173 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5175 return bgp_vty_return(vty
, ret
);
5178 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5179 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5180 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5181 "Member of the peer-group\n"
5182 "Peer-group name\n")
5184 DEFUN (no_neighbor_set_peer_group
,
5185 no_neighbor_set_peer_group_cmd
,
5186 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5190 "Member of the peer-group\n"
5191 "Peer-group name\n")
5193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5198 struct peer_group
*group
;
5200 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5202 return CMD_WARNING_CONFIG_FAILED
;
5204 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5206 vty_out(vty
, "%% Configure the peer-group first\n");
5207 return CMD_WARNING_CONFIG_FAILED
;
5210 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5211 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5213 peer_notify_unconfig(peer
);
5214 ret
= peer_delete(peer
);
5216 return bgp_vty_return(vty
, ret
);
5219 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5220 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5221 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5222 "Member of the peer-group\n"
5223 "Peer-group name\n")
5225 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5226 uint64_t flag
, int set
)
5231 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5233 return CMD_WARNING_CONFIG_FAILED
;
5236 * If 'neighbor <interface>', then this is for directly connected peers,
5237 * we should not accept disable-connected-check.
5239 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5241 "%s is directly connected peer, cannot accept disable-connected-check\n",
5243 return CMD_WARNING_CONFIG_FAILED
;
5246 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5247 peer_tx_shutdown_message_unset(peer
);
5250 ret
= peer_flag_set(peer
, flag
);
5252 ret
= peer_flag_unset(peer
, flag
);
5254 return bgp_vty_return(vty
, ret
);
5257 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5259 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5262 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5265 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5268 /* neighbor passive. */
5269 DEFUN (neighbor_passive
,
5270 neighbor_passive_cmd
,
5271 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5274 "Don't send open messages to this neighbor\n")
5277 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5280 DEFUN (no_neighbor_passive
,
5281 no_neighbor_passive_cmd
,
5282 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5286 "Don't send open messages to this neighbor\n")
5289 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5292 /* neighbor shutdown. */
5293 DEFUN (neighbor_shutdown_msg
,
5294 neighbor_shutdown_msg_cmd
,
5295 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5298 "Administratively shut down this neighbor\n"
5299 "Add a shutdown message (RFC 8203)\n"
5300 "Shutdown message\n")
5306 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5310 return CMD_WARNING_CONFIG_FAILED
;
5311 message
= argv_concat(argv
, argc
, 4);
5312 peer_tx_shutdown_message_set(peer
, message
);
5313 XFREE(MTYPE_TMP
, message
);
5316 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5319 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5320 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5321 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5322 "Administratively shut down this neighbor\n")
5324 DEFUN (no_neighbor_shutdown_msg
,
5325 no_neighbor_shutdown_msg_cmd
,
5326 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5330 "Administratively shut down this neighbor\n"
5331 "Remove a shutdown message (RFC 8203)\n"
5332 "Shutdown message\n")
5336 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5337 PEER_FLAG_SHUTDOWN
);
5340 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5341 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5342 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5343 "Administratively shut down this neighbor\n")
5345 DEFUN(neighbor_shutdown_rtt
,
5346 neighbor_shutdown_rtt_cmd
,
5347 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5350 "Administratively shut down this neighbor\n"
5351 "Shutdown if round-trip-time is higher than expected\n"
5352 "Round-trip-time in milliseconds\n"
5353 "Specify the number of keepalives before shutdown\n"
5354 "The number of keepalives with higher RTT to shutdown\n")
5361 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5364 return CMD_WARNING_CONFIG_FAILED
;
5366 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5368 if (argv_find(argv
, argc
, "count", &idx_count
))
5369 peer
->rtt_keepalive_conf
=
5370 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5372 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5373 PEER_FLAG_RTT_SHUTDOWN
);
5376 DEFUN(no_neighbor_shutdown_rtt
,
5377 no_neighbor_shutdown_rtt_cmd
,
5378 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5382 "Administratively shut down this neighbor\n"
5383 "Shutdown if round-trip-time is higher than expected\n"
5384 "Round-trip-time in milliseconds\n"
5385 "Specify the number of keepalives before shutdown\n"
5386 "The number of keepalives with higher RTT to shutdown\n")
5391 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5394 return CMD_WARNING_CONFIG_FAILED
;
5396 peer
->rtt_expected
= 0;
5397 peer
->rtt_keepalive_conf
= 1;
5399 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5400 PEER_FLAG_RTT_SHUTDOWN
);
5403 /* neighbor capability dynamic. */
5404 DEFUN (neighbor_capability_dynamic
,
5405 neighbor_capability_dynamic_cmd
,
5406 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5409 "Advertise capability to the peer\n"
5410 "Advertise dynamic capability to this neighbor\n")
5413 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5414 PEER_FLAG_DYNAMIC_CAPABILITY
);
5417 DEFUN (no_neighbor_capability_dynamic
,
5418 no_neighbor_capability_dynamic_cmd
,
5419 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5423 "Advertise capability to the peer\n"
5424 "Advertise dynamic capability to this neighbor\n")
5427 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5428 PEER_FLAG_DYNAMIC_CAPABILITY
);
5431 /* neighbor dont-capability-negotiate */
5432 DEFUN (neighbor_dont_capability_negotiate
,
5433 neighbor_dont_capability_negotiate_cmd
,
5434 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5437 "Do not perform capability negotiation\n")
5440 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5441 PEER_FLAG_DONT_CAPABILITY
);
5444 DEFUN (no_neighbor_dont_capability_negotiate
,
5445 no_neighbor_dont_capability_negotiate_cmd
,
5446 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5450 "Do not perform capability negotiation\n")
5453 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5454 PEER_FLAG_DONT_CAPABILITY
);
5457 /* neighbor capability extended next hop encoding */
5458 DEFUN (neighbor_capability_enhe
,
5459 neighbor_capability_enhe_cmd
,
5460 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5463 "Advertise capability to the peer\n"
5464 "Advertise extended next-hop capability to the peer\n")
5469 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5470 if (peer
&& peer
->conf_if
)
5473 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5474 PEER_FLAG_CAPABILITY_ENHE
);
5477 DEFUN (no_neighbor_capability_enhe
,
5478 no_neighbor_capability_enhe_cmd
,
5479 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5483 "Advertise capability to the peer\n"
5484 "Advertise extended next-hop capability to the peer\n")
5489 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5490 if (peer
&& peer
->conf_if
) {
5492 "Peer %s cannot have capability extended-nexthop turned off\n",
5493 argv
[idx_peer
]->arg
);
5494 return CMD_WARNING_CONFIG_FAILED
;
5497 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5498 PEER_FLAG_CAPABILITY_ENHE
);
5501 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5502 afi_t afi
, safi_t safi
, uint32_t flag
,
5508 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5510 return CMD_WARNING_CONFIG_FAILED
;
5513 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5515 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5517 return bgp_vty_return(vty
, ret
);
5520 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5521 afi_t afi
, safi_t safi
, uint32_t flag
)
5523 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5526 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5527 afi_t afi
, safi_t safi
, uint32_t flag
)
5529 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5532 /* neighbor capability orf prefix-list. */
5533 DEFUN (neighbor_capability_orf_prefix
,
5534 neighbor_capability_orf_prefix_cmd
,
5535 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5538 "Advertise capability to the peer\n"
5539 "Advertise ORF capability to the peer\n"
5540 "Advertise prefixlist ORF capability to this neighbor\n"
5541 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5542 "Capability to RECEIVE the ORF from this neighbor\n"
5543 "Capability to SEND the ORF to this neighbor\n")
5545 int idx_send_recv
= 5;
5546 char *peer_str
= argv
[1]->arg
;
5548 afi_t afi
= bgp_node_afi(vty
);
5549 safi_t safi
= bgp_node_safi(vty
);
5551 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5553 return CMD_WARNING_CONFIG_FAILED
;
5555 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5556 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5557 PEER_FLAG_ORF_PREFIX_SM
);
5559 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5560 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5561 PEER_FLAG_ORF_PREFIX_RM
);
5563 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5564 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5565 PEER_FLAG_ORF_PREFIX_SM
)
5566 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5567 PEER_FLAG_ORF_PREFIX_RM
);
5569 return CMD_WARNING_CONFIG_FAILED
;
5573 neighbor_capability_orf_prefix
,
5574 neighbor_capability_orf_prefix_hidden_cmd
,
5575 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5576 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5577 "Advertise capability to the peer\n"
5578 "Advertise ORF capability to the peer\n"
5579 "Advertise prefixlist ORF capability to this neighbor\n"
5580 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5581 "Capability to RECEIVE the ORF from this neighbor\n"
5582 "Capability to SEND the ORF to this neighbor\n")
5584 DEFUN (no_neighbor_capability_orf_prefix
,
5585 no_neighbor_capability_orf_prefix_cmd
,
5586 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5590 "Advertise capability to the peer\n"
5591 "Advertise ORF capability to the peer\n"
5592 "Advertise prefixlist ORF capability to this neighbor\n"
5593 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5594 "Capability to RECEIVE the ORF from this neighbor\n"
5595 "Capability to SEND the ORF to this neighbor\n")
5597 int idx_send_recv
= 6;
5598 char *peer_str
= argv
[2]->arg
;
5600 afi_t afi
= bgp_node_afi(vty
);
5601 safi_t safi
= bgp_node_safi(vty
);
5603 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5605 return CMD_WARNING_CONFIG_FAILED
;
5607 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5608 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5609 PEER_FLAG_ORF_PREFIX_SM
);
5611 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5612 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5613 PEER_FLAG_ORF_PREFIX_RM
);
5615 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5616 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5617 PEER_FLAG_ORF_PREFIX_SM
)
5618 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5619 PEER_FLAG_ORF_PREFIX_RM
);
5621 return CMD_WARNING_CONFIG_FAILED
;
5625 no_neighbor_capability_orf_prefix
,
5626 no_neighbor_capability_orf_prefix_hidden_cmd
,
5627 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5628 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5629 "Advertise capability to the peer\n"
5630 "Advertise ORF capability to the peer\n"
5631 "Advertise prefixlist ORF capability to this neighbor\n"
5632 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5633 "Capability to RECEIVE the ORF from this neighbor\n"
5634 "Capability to SEND the ORF to this neighbor\n")
5636 /* neighbor next-hop-self. */
5637 DEFUN (neighbor_nexthop_self
,
5638 neighbor_nexthop_self_cmd
,
5639 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5642 "Disable the next hop calculation for this neighbor\n")
5645 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5646 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5649 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5650 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5651 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5652 "Disable the next hop calculation for this neighbor\n")
5654 /* neighbor next-hop-self. */
5655 DEFUN (neighbor_nexthop_self_force
,
5656 neighbor_nexthop_self_force_cmd
,
5657 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5660 "Disable the next hop calculation for this neighbor\n"
5661 "Set the next hop to self for reflected routes\n")
5664 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5666 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5669 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5670 neighbor_nexthop_self_force_hidden_cmd
,
5671 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5672 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5673 "Disable the next hop calculation for this neighbor\n"
5674 "Set the next hop to self for reflected routes\n")
5676 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5677 neighbor_nexthop_self_all_hidden_cmd
,
5678 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5679 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5680 "Disable the next hop calculation for this neighbor\n"
5681 "Set the next hop to self for reflected routes\n")
5683 DEFUN (no_neighbor_nexthop_self
,
5684 no_neighbor_nexthop_self_cmd
,
5685 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5689 "Disable the next hop calculation for this neighbor\n")
5692 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5693 bgp_node_afi(vty
), bgp_node_safi(vty
),
5694 PEER_FLAG_NEXTHOP_SELF
);
5697 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5698 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5699 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5700 "Disable the next hop calculation for this neighbor\n")
5702 DEFUN (no_neighbor_nexthop_self_force
,
5703 no_neighbor_nexthop_self_force_cmd
,
5704 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5708 "Disable the next hop calculation for this neighbor\n"
5709 "Set the next hop to self for reflected routes\n")
5712 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5713 bgp_node_afi(vty
), bgp_node_safi(vty
),
5714 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5717 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5718 no_neighbor_nexthop_self_force_hidden_cmd
,
5719 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5721 "Disable the next hop calculation for this neighbor\n"
5722 "Set the next hop to self for reflected routes\n")
5724 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5725 no_neighbor_nexthop_self_all_hidden_cmd
,
5726 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5727 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5728 "Disable the next hop calculation for this neighbor\n"
5729 "Set the next hop to self for reflected routes\n")
5731 /* neighbor as-override */
5732 DEFUN (neighbor_as_override
,
5733 neighbor_as_override_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5737 "Override ASNs in outbound updates if aspath equals remote-as\n")
5740 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5741 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5744 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5745 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5746 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Override ASNs in outbound updates if aspath equals remote-as\n")
5749 DEFUN (no_neighbor_as_override
,
5750 no_neighbor_as_override_cmd
,
5751 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5755 "Override ASNs in outbound updates if aspath equals remote-as\n")
5758 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5759 bgp_node_afi(vty
), bgp_node_safi(vty
),
5760 PEER_FLAG_AS_OVERRIDE
);
5763 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5764 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5765 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5766 "Override ASNs in outbound updates if aspath equals remote-as\n")
5768 /* neighbor remove-private-AS. */
5769 DEFUN (neighbor_remove_private_as
,
5770 neighbor_remove_private_as_cmd
,
5771 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5774 "Remove private ASNs in outbound updates\n")
5777 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5779 PEER_FLAG_REMOVE_PRIVATE_AS
);
5782 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5783 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5784 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5785 "Remove private ASNs in outbound updates\n")
5787 DEFUN (neighbor_remove_private_as_all
,
5788 neighbor_remove_private_as_all_cmd
,
5789 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5792 "Remove private ASNs in outbound updates\n"
5793 "Apply to all AS numbers\n")
5796 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5798 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5801 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5802 neighbor_remove_private_as_all_hidden_cmd
,
5803 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5804 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5805 "Remove private ASNs in outbound updates\n"
5806 "Apply to all AS numbers")
5808 DEFUN (neighbor_remove_private_as_replace_as
,
5809 neighbor_remove_private_as_replace_as_cmd
,
5810 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5813 "Remove private ASNs in outbound updates\n"
5814 "Replace private ASNs with our ASN in outbound updates\n")
5817 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5819 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5822 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5823 neighbor_remove_private_as_replace_as_hidden_cmd
,
5824 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5825 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5826 "Remove private ASNs in outbound updates\n"
5827 "Replace private ASNs with our ASN in outbound updates\n")
5829 DEFUN (neighbor_remove_private_as_all_replace_as
,
5830 neighbor_remove_private_as_all_replace_as_cmd
,
5831 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5834 "Remove private ASNs in outbound updates\n"
5835 "Apply to all AS numbers\n"
5836 "Replace private ASNs with our ASN in outbound updates\n")
5839 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5841 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5845 neighbor_remove_private_as_all_replace_as
,
5846 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5847 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5848 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5849 "Remove private ASNs in outbound updates\n"
5850 "Apply to all AS numbers\n"
5851 "Replace private ASNs with our ASN in outbound updates\n")
5853 DEFUN (no_neighbor_remove_private_as
,
5854 no_neighbor_remove_private_as_cmd
,
5855 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5859 "Remove private ASNs in outbound updates\n")
5862 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5863 bgp_node_afi(vty
), bgp_node_safi(vty
),
5864 PEER_FLAG_REMOVE_PRIVATE_AS
);
5867 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5868 no_neighbor_remove_private_as_hidden_cmd
,
5869 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5870 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5871 "Remove private ASNs in outbound updates\n")
5873 DEFUN (no_neighbor_remove_private_as_all
,
5874 no_neighbor_remove_private_as_all_cmd
,
5875 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5879 "Remove private ASNs in outbound updates\n"
5880 "Apply to all AS numbers\n")
5883 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5884 bgp_node_afi(vty
), bgp_node_safi(vty
),
5885 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5888 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5889 no_neighbor_remove_private_as_all_hidden_cmd
,
5890 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5891 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5892 "Remove private ASNs in outbound updates\n"
5893 "Apply to all AS numbers\n")
5895 DEFUN (no_neighbor_remove_private_as_replace_as
,
5896 no_neighbor_remove_private_as_replace_as_cmd
,
5897 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5901 "Remove private ASNs in outbound updates\n"
5902 "Replace private ASNs with our ASN in outbound updates\n")
5905 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5906 bgp_node_afi(vty
), bgp_node_safi(vty
),
5907 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5910 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5911 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5912 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5913 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5914 "Remove private ASNs in outbound updates\n"
5915 "Replace private ASNs with our ASN in outbound updates\n")
5917 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5918 no_neighbor_remove_private_as_all_replace_as_cmd
,
5919 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5923 "Remove private ASNs in outbound updates\n"
5924 "Apply to all AS numbers\n"
5925 "Replace private ASNs with our ASN in outbound updates\n")
5928 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5929 bgp_node_afi(vty
), bgp_node_safi(vty
),
5930 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5934 no_neighbor_remove_private_as_all_replace_as
,
5935 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5936 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5937 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5938 "Remove private ASNs in outbound updates\n"
5939 "Apply to all AS numbers\n"
5940 "Replace private ASNs with our ASN in outbound updates\n")
5943 /* neighbor send-community. */
5944 DEFUN (neighbor_send_community
,
5945 neighbor_send_community_cmd
,
5946 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5949 "Send Community attribute to this neighbor\n")
5953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5955 PEER_FLAG_SEND_COMMUNITY
);
5958 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5959 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5960 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5961 "Send Community attribute to this neighbor\n")
5963 DEFUN (no_neighbor_send_community
,
5964 no_neighbor_send_community_cmd
,
5965 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5969 "Send Community attribute to this neighbor\n")
5973 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5974 bgp_node_afi(vty
), bgp_node_safi(vty
),
5975 PEER_FLAG_SEND_COMMUNITY
);
5978 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5979 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5980 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5981 "Send Community attribute to this neighbor\n")
5983 /* neighbor send-community extended. */
5984 DEFUN (neighbor_send_community_type
,
5985 neighbor_send_community_type_cmd
,
5986 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5989 "Send Community attribute to this neighbor\n"
5990 "Send Standard and Extended Community attributes\n"
5991 "Send Standard, Large and Extended Community attributes\n"
5992 "Send Extended Community attributes\n"
5993 "Send Standard Community attributes\n"
5994 "Send Large Community attributes\n")
5996 const char *type
= argv
[argc
- 1]->text
;
5997 char *peer_str
= argv
[1]->arg
;
5999 afi_t afi
= bgp_node_afi(vty
);
6000 safi_t safi
= bgp_node_safi(vty
);
6002 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6004 return CMD_WARNING_CONFIG_FAILED
;
6006 if (strmatch(type
, "standard"))
6007 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6008 PEER_FLAG_SEND_COMMUNITY
);
6010 if (strmatch(type
, "extended"))
6011 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6012 PEER_FLAG_SEND_EXT_COMMUNITY
);
6014 if (strmatch(type
, "large"))
6015 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6016 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6018 if (strmatch(type
, "both")) {
6019 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6020 PEER_FLAG_SEND_COMMUNITY
)
6021 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6022 PEER_FLAG_SEND_EXT_COMMUNITY
);
6024 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6025 PEER_FLAG_SEND_COMMUNITY
)
6026 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6027 PEER_FLAG_SEND_EXT_COMMUNITY
)
6028 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6029 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6033 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6034 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6035 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6036 "Send Community attribute to this neighbor\n"
6037 "Send Standard and Extended Community attributes\n"
6038 "Send Standard, Large and Extended Community attributes\n"
6039 "Send Extended Community attributes\n"
6040 "Send Standard Community attributes\n"
6041 "Send Large Community attributes\n")
6043 DEFUN (no_neighbor_send_community_type
,
6044 no_neighbor_send_community_type_cmd
,
6045 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6049 "Send Community attribute to this neighbor\n"
6050 "Send Standard and Extended Community attributes\n"
6051 "Send Standard, Large and Extended Community attributes\n"
6052 "Send Extended Community attributes\n"
6053 "Send Standard Community attributes\n"
6054 "Send Large Community attributes\n")
6056 const char *type
= argv
[argc
- 1]->text
;
6057 char *peer_str
= argv
[2]->arg
;
6059 afi_t afi
= bgp_node_afi(vty
);
6060 safi_t safi
= bgp_node_safi(vty
);
6062 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6064 return CMD_WARNING_CONFIG_FAILED
;
6066 if (strmatch(type
, "standard"))
6067 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6068 PEER_FLAG_SEND_COMMUNITY
);
6070 if (strmatch(type
, "extended"))
6071 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6072 PEER_FLAG_SEND_EXT_COMMUNITY
);
6074 if (strmatch(type
, "large"))
6075 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6076 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6078 if (strmatch(type
, "both")) {
6080 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6081 PEER_FLAG_SEND_COMMUNITY
)
6082 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6083 PEER_FLAG_SEND_EXT_COMMUNITY
);
6086 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6087 PEER_FLAG_SEND_COMMUNITY
)
6088 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6089 PEER_FLAG_SEND_EXT_COMMUNITY
)
6090 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6091 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6095 no_neighbor_send_community_type
,
6096 no_neighbor_send_community_type_hidden_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6098 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6099 "Send Community attribute to this neighbor\n"
6100 "Send Standard and Extended Community attributes\n"
6101 "Send Standard, Large and Extended Community attributes\n"
6102 "Send Extended Community attributes\n"
6103 "Send Standard Community attributes\n"
6104 "Send Large Community attributes\n")
6106 /* neighbor soft-reconfig. */
6107 DEFUN (neighbor_soft_reconfiguration
,
6108 neighbor_soft_reconfiguration_cmd
,
6109 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6112 "Per neighbor soft reconfiguration\n"
6113 "Allow inbound soft reconfiguration for this neighbor\n")
6116 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6118 PEER_FLAG_SOFT_RECONFIG
);
6121 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6122 neighbor_soft_reconfiguration_hidden_cmd
,
6123 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6124 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6125 "Per neighbor soft reconfiguration\n"
6126 "Allow inbound soft reconfiguration for this neighbor\n")
6128 DEFUN (no_neighbor_soft_reconfiguration
,
6129 no_neighbor_soft_reconfiguration_cmd
,
6130 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6134 "Per neighbor soft reconfiguration\n"
6135 "Allow inbound soft reconfiguration for this neighbor\n")
6138 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6139 bgp_node_afi(vty
), bgp_node_safi(vty
),
6140 PEER_FLAG_SOFT_RECONFIG
);
6143 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6144 no_neighbor_soft_reconfiguration_hidden_cmd
,
6145 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6146 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6147 "Per neighbor soft reconfiguration\n"
6148 "Allow inbound soft reconfiguration for this neighbor\n")
6150 DEFUN (neighbor_route_reflector_client
,
6151 neighbor_route_reflector_client_cmd
,
6152 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6155 "Configure a neighbor as Route Reflector client\n")
6161 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6163 return CMD_WARNING_CONFIG_FAILED
;
6165 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6167 PEER_FLAG_REFLECTOR_CLIENT
);
6170 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6171 neighbor_route_reflector_client_hidden_cmd
,
6172 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6173 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6174 "Configure a neighbor as Route Reflector client\n")
6176 DEFUN (no_neighbor_route_reflector_client
,
6177 no_neighbor_route_reflector_client_cmd
,
6178 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6182 "Configure a neighbor as Route Reflector client\n")
6185 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6186 bgp_node_afi(vty
), bgp_node_safi(vty
),
6187 PEER_FLAG_REFLECTOR_CLIENT
);
6190 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6191 no_neighbor_route_reflector_client_hidden_cmd
,
6192 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6194 "Configure a neighbor as Route Reflector client\n")
6196 /* neighbor route-server-client. */
6197 DEFUN (neighbor_route_server_client
,
6198 neighbor_route_server_client_cmd
,
6199 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6202 "Configure a neighbor as Route Server client\n")
6207 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6209 return CMD_WARNING_CONFIG_FAILED
;
6210 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6212 PEER_FLAG_RSERVER_CLIENT
);
6215 ALIAS_HIDDEN(neighbor_route_server_client
,
6216 neighbor_route_server_client_hidden_cmd
,
6217 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6218 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6219 "Configure a neighbor as Route Server client\n")
6221 DEFUN (no_neighbor_route_server_client
,
6222 no_neighbor_route_server_client_cmd
,
6223 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6227 "Configure a neighbor as Route Server client\n")
6230 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6231 bgp_node_afi(vty
), bgp_node_safi(vty
),
6232 PEER_FLAG_RSERVER_CLIENT
);
6235 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6236 no_neighbor_route_server_client_hidden_cmd
,
6237 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6238 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6239 "Configure a neighbor as Route Server client\n")
6241 DEFUN (neighbor_nexthop_local_unchanged
,
6242 neighbor_nexthop_local_unchanged_cmd
,
6243 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6246 "Configure treatment of outgoing link-local nexthop attribute\n"
6247 "Leave link-local nexthop unchanged for this peer\n")
6250 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6252 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6255 DEFUN (no_neighbor_nexthop_local_unchanged
,
6256 no_neighbor_nexthop_local_unchanged_cmd
,
6257 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6261 "Configure treatment of outgoing link-local-nexthop attribute\n"
6262 "Leave link-local nexthop unchanged for this peer\n")
6265 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6266 bgp_node_afi(vty
), bgp_node_safi(vty
),
6267 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6270 DEFUN (neighbor_attr_unchanged
,
6271 neighbor_attr_unchanged_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6275 "BGP attribute is propagated unchanged to this neighbor\n"
6276 "As-path attribute\n"
6277 "Nexthop attribute\n"
6281 char *peer_str
= argv
[1]->arg
;
6283 bool aspath
= false;
6284 bool nexthop
= false;
6286 afi_t afi
= bgp_node_afi(vty
);
6287 safi_t safi
= bgp_node_safi(vty
);
6290 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6292 return CMD_WARNING_CONFIG_FAILED
;
6294 if (argv_find(argv
, argc
, "as-path", &idx
))
6298 if (argv_find(argv
, argc
, "next-hop", &idx
))
6302 if (argv_find(argv
, argc
, "med", &idx
))
6305 /* no flags means all of them! */
6306 if (!aspath
&& !nexthop
&& !med
) {
6307 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6308 PEER_FLAG_AS_PATH_UNCHANGED
);
6309 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6310 PEER_FLAG_NEXTHOP_UNCHANGED
);
6311 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6312 PEER_FLAG_MED_UNCHANGED
);
6315 if (peer_af_flag_check(peer
, afi
, safi
,
6316 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6317 ret
|= peer_af_flag_unset_vty(
6318 vty
, peer_str
, afi
, safi
,
6319 PEER_FLAG_AS_PATH_UNCHANGED
);
6322 ret
|= peer_af_flag_set_vty(
6323 vty
, peer_str
, afi
, safi
,
6324 PEER_FLAG_AS_PATH_UNCHANGED
);
6327 if (peer_af_flag_check(peer
, afi
, safi
,
6328 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6329 ret
|= peer_af_flag_unset_vty(
6330 vty
, peer_str
, afi
, safi
,
6331 PEER_FLAG_NEXTHOP_UNCHANGED
);
6334 ret
|= peer_af_flag_set_vty(
6335 vty
, peer_str
, afi
, safi
,
6336 PEER_FLAG_NEXTHOP_UNCHANGED
);
6339 if (peer_af_flag_check(peer
, afi
, safi
,
6340 PEER_FLAG_MED_UNCHANGED
)) {
6341 ret
|= peer_af_flag_unset_vty(
6342 vty
, peer_str
, afi
, safi
,
6343 PEER_FLAG_MED_UNCHANGED
);
6346 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6347 PEER_FLAG_MED_UNCHANGED
);
6354 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6355 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6356 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6357 "BGP attribute is propagated unchanged to this neighbor\n"
6358 "As-path attribute\n"
6359 "Nexthop attribute\n"
6362 DEFUN (no_neighbor_attr_unchanged
,
6363 no_neighbor_attr_unchanged_cmd
,
6364 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6368 "BGP attribute is propagated unchanged to this neighbor\n"
6369 "As-path attribute\n"
6370 "Nexthop attribute\n"
6374 char *peer_str
= argv
[2]->arg
;
6376 bool aspath
= false;
6377 bool nexthop
= false;
6379 afi_t afi
= bgp_node_afi(vty
);
6380 safi_t safi
= bgp_node_safi(vty
);
6383 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6385 return CMD_WARNING_CONFIG_FAILED
;
6387 if (argv_find(argv
, argc
, "as-path", &idx
))
6391 if (argv_find(argv
, argc
, "next-hop", &idx
))
6395 if (argv_find(argv
, argc
, "med", &idx
))
6398 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6399 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6400 PEER_FLAG_AS_PATH_UNCHANGED
)
6401 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6402 PEER_FLAG_NEXTHOP_UNCHANGED
)
6403 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6404 PEER_FLAG_MED_UNCHANGED
);
6407 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6408 PEER_FLAG_AS_PATH_UNCHANGED
);
6411 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6412 PEER_FLAG_NEXTHOP_UNCHANGED
);
6415 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6416 PEER_FLAG_MED_UNCHANGED
);
6422 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6423 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6424 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6425 "BGP attribute is propagated unchanged to this neighbor\n"
6426 "As-path attribute\n"
6427 "Nexthop attribute\n"
6430 /* EBGP multihop configuration. */
6431 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6432 const char *ttl_str
)
6437 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6439 return CMD_WARNING_CONFIG_FAILED
;
6442 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6447 ttl
= strtoul(ttl_str
, NULL
, 10);
6449 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6452 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6456 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6458 return CMD_WARNING_CONFIG_FAILED
;
6460 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6463 /* neighbor ebgp-multihop. */
6464 DEFUN (neighbor_ebgp_multihop
,
6465 neighbor_ebgp_multihop_cmd
,
6466 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6469 "Allow EBGP neighbors not on directly connected networks\n")
6472 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6475 DEFUN (neighbor_ebgp_multihop_ttl
,
6476 neighbor_ebgp_multihop_ttl_cmd
,
6477 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6480 "Allow EBGP neighbors not on directly connected networks\n"
6481 "maximum hop count\n")
6485 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6486 argv
[idx_number
]->arg
);
6489 DEFUN (no_neighbor_ebgp_multihop
,
6490 no_neighbor_ebgp_multihop_cmd
,
6491 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6495 "Allow EBGP neighbors not on directly connected networks\n"
6496 "maximum hop count\n")
6499 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6502 static uint8_t get_role_by_name(const char *role_str
)
6504 if (strncmp(role_str
, "peer", 2) == 0)
6506 if (strncmp(role_str
, "provider", 2) == 0)
6507 return ROLE_PROVIDER
;
6508 if (strncmp(role_str
, "customer", 2) == 0)
6509 return ROLE_CUSTOMER
;
6510 if (strncmp(role_str
, "rs-server", 4) == 0)
6511 return ROLE_RS_SERVER
;
6512 if (strncmp(role_str
, "rs-client", 4) == 0)
6513 return ROLE_RS_CLIENT
;
6514 return ROLE_UNDEFINED
;
6517 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6518 const char *role_str
, bool strict_mode
)
6522 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6524 return CMD_WARNING_CONFIG_FAILED
;
6525 uint8_t role
= get_role_by_name(role_str
);
6527 if (role
== ROLE_UNDEFINED
)
6528 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6529 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6532 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6536 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6538 return CMD_WARNING_CONFIG_FAILED
;
6539 return bgp_vty_return(vty
, peer_role_unset(peer
));
6542 DEFPY(neighbor_role
,
6544 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6547 "Set session role\n"
6553 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6557 DEFPY(neighbor_role_strict
,
6558 neighbor_role_strict_cmd
,
6559 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6562 "Set session role\n"
6564 "Use additional restriction on peer\n")
6569 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6573 DEFPY(no_neighbor_role
,
6574 no_neighbor_role_cmd
,
6575 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6579 "Set session role\n"
6581 "Use additional restriction on peer\n")
6585 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6588 /* disable-connected-check */
6589 DEFUN (neighbor_disable_connected_check
,
6590 neighbor_disable_connected_check_cmd
,
6591 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6594 "one-hop away EBGP peer using loopback address\n"
6595 "Enforce EBGP neighbors perform multihop\n")
6598 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6599 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6602 DEFUN (no_neighbor_disable_connected_check
,
6603 no_neighbor_disable_connected_check_cmd
,
6604 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6608 "one-hop away EBGP peer using loopback address\n"
6609 "Enforce EBGP neighbors perform multihop\n")
6612 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6613 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6616 /* disable-link-bw-encoding-ieee */
6617 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6618 neighbor_disable_link_bw_encoding_ieee_cmd
,
6619 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6620 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6621 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6625 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6626 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6629 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6630 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6631 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6632 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6633 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6637 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6638 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6641 /* extended-optional-parameters */
6642 DEFUN(neighbor_extended_optional_parameters
,
6643 neighbor_extended_optional_parameters_cmd
,
6644 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6645 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6646 "Force the extended optional parameters format for OPEN messages\n")
6650 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6651 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6654 DEFUN(no_neighbor_extended_optional_parameters
,
6655 no_neighbor_extended_optional_parameters_cmd
,
6656 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6657 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6658 "Force the extended optional parameters format for OPEN messages\n")
6662 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6663 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6666 /* enforce-first-as */
6667 DEFUN (neighbor_enforce_first_as
,
6668 neighbor_enforce_first_as_cmd
,
6669 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6672 "Enforce the first AS for EBGP routes\n")
6676 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6677 PEER_FLAG_ENFORCE_FIRST_AS
);
6680 DEFUN (no_neighbor_enforce_first_as
,
6681 no_neighbor_enforce_first_as_cmd
,
6682 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6686 "Enforce the first AS for EBGP routes\n")
6690 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6691 PEER_FLAG_ENFORCE_FIRST_AS
);
6695 DEFUN (neighbor_description
,
6696 neighbor_description_cmd
,
6697 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6700 "Neighbor specific description\n"
6701 "Up to 80 characters describing this neighbor\n")
6708 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6710 return CMD_WARNING_CONFIG_FAILED
;
6712 str
= argv_concat(argv
, argc
, idx_line
);
6714 peer_description_set(peer
, str
);
6716 XFREE(MTYPE_TMP
, str
);
6721 DEFUN (no_neighbor_description
,
6722 no_neighbor_description_cmd
,
6723 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6727 "Neighbor specific description\n")
6732 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6734 return CMD_WARNING_CONFIG_FAILED
;
6736 peer_description_unset(peer
);
6741 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6742 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6743 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6744 "Neighbor specific description\n"
6745 "Up to 80 characters describing this neighbor\n")
6747 /* Neighbor update-source. */
6748 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6749 const char *source_str
)
6755 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6757 return CMD_WARNING_CONFIG_FAILED
;
6763 if (str2sockunion(source_str
, &su
) == 0)
6764 peer_update_source_addr_set(peer
, &su
);
6766 if (str2prefix(source_str
, &p
)) {
6768 "%% Invalid update-source, remove prefix length \n");
6769 return CMD_WARNING_CONFIG_FAILED
;
6771 peer_update_source_if_set(peer
, source_str
);
6774 peer_update_source_unset(peer
);
6779 #define BGP_UPDATE_SOURCE_HELP_STR \
6782 "Interface name (requires zebra to be running)\n"
6784 DEFUN (neighbor_update_source
,
6785 neighbor_update_source_cmd
,
6786 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6789 "Source of routing updates\n"
6790 BGP_UPDATE_SOURCE_HELP_STR
)
6794 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6795 argv
[idx_peer_2
]->arg
);
6798 DEFUN (no_neighbor_update_source
,
6799 no_neighbor_update_source_cmd
,
6800 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6804 "Source of routing updates\n"
6805 BGP_UPDATE_SOURCE_HELP_STR
)
6808 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6811 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6812 afi_t afi
, safi_t safi
,
6813 const char *rmap
, int set
)
6817 struct route_map
*route_map
= NULL
;
6819 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6821 return CMD_WARNING_CONFIG_FAILED
;
6825 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6826 ret
= peer_default_originate_set(peer
, afi
, safi
,
6829 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6831 return bgp_vty_return(vty
, ret
);
6834 /* neighbor default-originate. */
6835 DEFUN (neighbor_default_originate
,
6836 neighbor_default_originate_cmd
,
6837 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6840 "Originate default route to this neighbor\n")
6843 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6845 bgp_node_safi(vty
), NULL
, 1);
6848 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6849 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6850 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6851 "Originate default route to this neighbor\n")
6853 DEFUN (neighbor_default_originate_rmap
,
6854 neighbor_default_originate_rmap_cmd
,
6855 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6858 "Originate default route to this neighbor\n"
6859 "Route-map to specify criteria to originate default\n"
6864 return peer_default_originate_set_vty(
6865 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6866 argv
[idx_word
]->arg
, 1);
6870 neighbor_default_originate_rmap
,
6871 neighbor_default_originate_rmap_hidden_cmd
,
6872 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6873 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6874 "Originate default route to this neighbor\n"
6875 "Route-map to specify criteria to originate default\n"
6878 DEFUN (no_neighbor_default_originate
,
6879 no_neighbor_default_originate_cmd
,
6880 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6884 "Originate default route to this neighbor\n"
6885 "Route-map to specify criteria to originate default\n"
6889 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6891 bgp_node_safi(vty
), NULL
, 0);
6895 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6896 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6897 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6898 "Originate default route to this neighbor\n"
6899 "Route-map to specify criteria to originate default\n"
6903 /* Set neighbor's BGP port. */
6904 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6905 const char *port_str
)
6911 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6913 return CMD_WARNING_CONFIG_FAILED
;
6916 sp
= getservbyname("bgp", "tcp");
6917 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6919 port
= strtoul(port_str
, NULL
, 10);
6922 peer_port_set(peer
, port
);
6927 /* Set specified peer's BGP port. */
6928 DEFUN (neighbor_port
,
6930 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6933 "Neighbor's BGP port\n"
6934 "TCP port number\n")
6938 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6939 argv
[idx_number
]->arg
);
6942 DEFUN (no_neighbor_port
,
6943 no_neighbor_port_cmd
,
6944 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6948 "Neighbor's BGP port\n"
6949 "TCP port number\n")
6952 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6956 /* neighbor weight. */
6957 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6958 safi_t safi
, const char *weight_str
)
6962 unsigned long weight
;
6964 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6966 return CMD_WARNING_CONFIG_FAILED
;
6968 weight
= strtoul(weight_str
, NULL
, 10);
6970 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6971 return bgp_vty_return(vty
, ret
);
6974 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6980 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6982 return CMD_WARNING_CONFIG_FAILED
;
6984 ret
= peer_weight_unset(peer
, afi
, safi
);
6985 return bgp_vty_return(vty
, ret
);
6988 DEFUN (neighbor_weight
,
6989 neighbor_weight_cmd
,
6990 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6993 "Set default weight for routes from this neighbor\n"
6998 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6999 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7002 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7003 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7004 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7005 "Set default weight for routes from this neighbor\n"
7008 DEFUN (no_neighbor_weight
,
7009 no_neighbor_weight_cmd
,
7010 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7014 "Set default weight for routes from this neighbor\n"
7018 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7019 bgp_node_afi(vty
), bgp_node_safi(vty
));
7022 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7023 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7024 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7025 "Set default weight for routes from this neighbor\n"
7029 /* Override capability negotiation. */
7030 DEFUN (neighbor_override_capability
,
7031 neighbor_override_capability_cmd
,
7032 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7035 "Override capability negotiation result\n")
7038 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7039 PEER_FLAG_OVERRIDE_CAPABILITY
);
7042 DEFUN (no_neighbor_override_capability
,
7043 no_neighbor_override_capability_cmd
,
7044 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7048 "Override capability negotiation result\n")
7051 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7052 PEER_FLAG_OVERRIDE_CAPABILITY
);
7055 DEFUN (neighbor_strict_capability
,
7056 neighbor_strict_capability_cmd
,
7057 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7060 "Strict capability negotiation match\n")
7064 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7065 PEER_FLAG_STRICT_CAP_MATCH
);
7068 DEFUN (no_neighbor_strict_capability
,
7069 no_neighbor_strict_capability_cmd
,
7070 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7074 "Strict capability negotiation match\n")
7078 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7079 PEER_FLAG_STRICT_CAP_MATCH
);
7082 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7083 const char *keep_str
, const char *hold_str
)
7090 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7092 return CMD_WARNING_CONFIG_FAILED
;
7094 keepalive
= strtoul(keep_str
, NULL
, 10);
7095 holdtime
= strtoul(hold_str
, NULL
, 10);
7097 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7099 return bgp_vty_return(vty
, ret
);
7102 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7107 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7109 return CMD_WARNING_CONFIG_FAILED
;
7111 ret
= peer_timers_unset(peer
);
7113 return bgp_vty_return(vty
, ret
);
7116 DEFUN (neighbor_timers
,
7117 neighbor_timers_cmd
,
7118 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7121 "BGP per neighbor timers\n"
7122 "Keepalive interval\n"
7127 int idx_number_2
= 4;
7128 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7129 argv
[idx_number
]->arg
,
7130 argv
[idx_number_2
]->arg
);
7133 DEFUN (no_neighbor_timers
,
7134 no_neighbor_timers_cmd
,
7135 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7139 "BGP per neighbor timers\n"
7140 "Keepalive interval\n"
7144 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7148 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7149 const char *time_str
)
7155 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7157 return CMD_WARNING_CONFIG_FAILED
;
7159 connect
= strtoul(time_str
, NULL
, 10);
7161 ret
= peer_timers_connect_set(peer
, connect
);
7163 return bgp_vty_return(vty
, ret
);
7166 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7171 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7173 return CMD_WARNING_CONFIG_FAILED
;
7175 ret
= peer_timers_connect_unset(peer
);
7177 return bgp_vty_return(vty
, ret
);
7180 DEFUN (neighbor_timers_connect
,
7181 neighbor_timers_connect_cmd
,
7182 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7185 "BGP per neighbor timers\n"
7186 "BGP connect timer\n"
7191 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7192 argv
[idx_number
]->arg
);
7195 DEFUN (no_neighbor_timers_connect
,
7196 no_neighbor_timers_connect_cmd
,
7197 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7201 "BGP per neighbor timers\n"
7202 "BGP connect timer\n"
7206 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7209 DEFPY (neighbor_timers_delayopen
,
7210 neighbor_timers_delayopen_cmd
,
7211 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7214 "BGP per neighbor timers\n"
7215 "RFC 4271 DelayOpenTimer\n"
7216 "DelayOpenTime timer interval\n")
7220 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7222 return CMD_WARNING_CONFIG_FAILED
;
7225 if (peer_timers_delayopen_unset(peer
))
7226 return CMD_WARNING_CONFIG_FAILED
;
7228 if (peer_timers_delayopen_set(peer
, interval
))
7229 return CMD_WARNING_CONFIG_FAILED
;
7235 DEFPY (no_neighbor_timers_delayopen
,
7236 no_neighbor_timers_delayopen_cmd
,
7237 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7241 "BGP per neighbor timers\n"
7242 "RFC 4271 DelayOpenTimer\n"
7243 "DelayOpenTime timer interval\n")
7247 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7249 return CMD_WARNING_CONFIG_FAILED
;
7251 if (peer_timers_delayopen_unset(peer
))
7252 return CMD_WARNING_CONFIG_FAILED
;
7257 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7258 const char *time_str
, int set
)
7262 uint32_t routeadv
= 0;
7264 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7266 return CMD_WARNING_CONFIG_FAILED
;
7269 routeadv
= strtoul(time_str
, NULL
, 10);
7272 ret
= peer_advertise_interval_set(peer
, routeadv
);
7274 ret
= peer_advertise_interval_unset(peer
);
7276 return bgp_vty_return(vty
, ret
);
7279 DEFUN (neighbor_advertise_interval
,
7280 neighbor_advertise_interval_cmd
,
7281 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7284 "Minimum interval between sending BGP routing updates\n"
7285 "time in seconds\n")
7289 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7290 argv
[idx_number
]->arg
, 1);
7293 DEFUN (no_neighbor_advertise_interval
,
7294 no_neighbor_advertise_interval_cmd
,
7295 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7299 "Minimum interval between sending BGP routing updates\n"
7300 "time in seconds\n")
7303 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7307 /* Time to wait before processing route-map updates */
7308 DEFUN (bgp_set_route_map_delay_timer
,
7309 bgp_set_route_map_delay_timer_cmd
,
7310 "bgp route-map delay-timer (0-600)",
7312 "BGP route-map delay timer\n"
7313 "Time in secs to wait before processing route-map changes\n"
7314 "0 disables the timer, no route updates happen when route-maps change\n")
7317 uint32_t rmap_delay_timer
;
7319 if (argv
[idx_number
]->arg
) {
7320 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7321 bm
->rmap_update_timer
= rmap_delay_timer
;
7323 /* if the dynamic update handling is being disabled, and a timer
7325 * running, stop the timer and act as if the timer has already
7328 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7329 THREAD_OFF(bm
->t_rmap_update
);
7330 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7335 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7336 return CMD_WARNING_CONFIG_FAILED
;
7340 DEFUN (no_bgp_set_route_map_delay_timer
,
7341 no_bgp_set_route_map_delay_timer_cmd
,
7342 "no bgp route-map delay-timer [(0-600)]",
7345 "Default BGP route-map delay timer\n"
7346 "Reset to default time to wait for processing route-map changes\n"
7347 "0 disables the timer, no route updates happen when route-maps change\n")
7350 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7355 /* neighbor interface */
7356 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7361 peer
= peer_lookup_vty(vty
, ip_str
);
7362 if (!peer
|| peer
->conf_if
) {
7363 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7364 return CMD_WARNING_CONFIG_FAILED
;
7368 peer_interface_set(peer
, str
);
7370 peer_interface_unset(peer
);
7375 DEFUN (neighbor_interface
,
7376 neighbor_interface_cmd
,
7377 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7386 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7389 DEFUN (no_neighbor_interface
,
7390 no_neighbor_interface_cmd
,
7391 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7400 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7403 DEFUN (neighbor_distribute_list
,
7404 neighbor_distribute_list_cmd
,
7405 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7408 "Filter updates to/from this neighbor\n"
7409 "IP Access-list name\n"
7410 "Filter incoming updates\n"
7411 "Filter outgoing updates\n")
7418 const char *pstr
= argv
[idx_peer
]->arg
;
7419 const char *acl
= argv
[idx_acl
]->arg
;
7420 const char *inout
= argv
[argc
- 1]->text
;
7422 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7424 return CMD_WARNING_CONFIG_FAILED
;
7426 /* Check filter direction. */
7427 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7428 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7431 return bgp_vty_return(vty
, ret
);
7435 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7436 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7437 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7438 "Filter updates to/from this neighbor\n"
7439 "IP Access-list name\n"
7440 "Filter incoming updates\n"
7441 "Filter outgoing updates\n")
7443 DEFUN (no_neighbor_distribute_list
,
7444 no_neighbor_distribute_list_cmd
,
7445 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7449 "Filter updates to/from this neighbor\n"
7450 "IP Access-list name\n"
7451 "Filter incoming updates\n"
7452 "Filter outgoing updates\n")
7458 const char *pstr
= argv
[idx_peer
]->arg
;
7459 const char *inout
= argv
[argc
- 1]->text
;
7461 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7463 return CMD_WARNING_CONFIG_FAILED
;
7465 /* Check filter direction. */
7466 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7467 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7470 return bgp_vty_return(vty
, ret
);
7474 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7475 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7476 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7477 "Filter updates to/from this neighbor\n"
7478 "IP Access-list name\n"
7479 "Filter incoming updates\n"
7480 "Filter outgoing updates\n")
7482 /* Set prefix list to the peer. */
7483 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7484 afi_t afi
, safi_t safi
,
7485 const char *name_str
,
7486 const char *direct_str
)
7489 int direct
= FILTER_IN
;
7492 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7494 return CMD_WARNING_CONFIG_FAILED
;
7496 /* Check filter direction. */
7497 if (strncmp(direct_str
, "i", 1) == 0)
7499 else if (strncmp(direct_str
, "o", 1) == 0)
7500 direct
= FILTER_OUT
;
7502 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7504 return bgp_vty_return(vty
, ret
);
7507 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7508 afi_t afi
, safi_t safi
,
7509 const char *direct_str
)
7513 int direct
= FILTER_IN
;
7515 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7517 return CMD_WARNING_CONFIG_FAILED
;
7519 /* Check filter direction. */
7520 if (strncmp(direct_str
, "i", 1) == 0)
7522 else if (strncmp(direct_str
, "o", 1) == 0)
7523 direct
= FILTER_OUT
;
7525 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7527 return bgp_vty_return(vty
, ret
);
7530 DEFUN (neighbor_prefix_list
,
7531 neighbor_prefix_list_cmd
,
7532 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7535 "Filter updates to/from this neighbor\n"
7536 "Name of a prefix list\n"
7537 "Filter incoming updates\n"
7538 "Filter outgoing updates\n")
7543 return peer_prefix_list_set_vty(
7544 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7545 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7548 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7549 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7550 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7551 "Filter updates to/from this neighbor\n"
7552 "Name of a prefix list\n"
7553 "Filter incoming updates\n"
7554 "Filter outgoing updates\n")
7556 DEFUN (no_neighbor_prefix_list
,
7557 no_neighbor_prefix_list_cmd
,
7558 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7562 "Filter updates to/from this neighbor\n"
7563 "Name of a prefix list\n"
7564 "Filter incoming updates\n"
7565 "Filter outgoing updates\n")
7569 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7570 bgp_node_afi(vty
), bgp_node_safi(vty
),
7571 argv
[idx_in_out
]->arg
);
7574 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7575 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7576 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7577 "Filter updates to/from this neighbor\n"
7578 "Name of a prefix list\n"
7579 "Filter incoming updates\n"
7580 "Filter outgoing updates\n")
7582 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7583 safi_t safi
, const char *name_str
,
7584 const char *direct_str
)
7588 int direct
= FILTER_IN
;
7590 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7592 return CMD_WARNING_CONFIG_FAILED
;
7594 /* Check filter direction. */
7595 if (strncmp(direct_str
, "i", 1) == 0)
7597 else if (strncmp(direct_str
, "o", 1) == 0)
7598 direct
= FILTER_OUT
;
7600 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7602 return bgp_vty_return(vty
, ret
);
7605 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7606 safi_t safi
, const char *direct_str
)
7610 int direct
= FILTER_IN
;
7612 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7614 return CMD_WARNING_CONFIG_FAILED
;
7616 /* Check filter direction. */
7617 if (strncmp(direct_str
, "i", 1) == 0)
7619 else if (strncmp(direct_str
, "o", 1) == 0)
7620 direct
= FILTER_OUT
;
7622 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7624 return bgp_vty_return(vty
, ret
);
7627 DEFUN (neighbor_filter_list
,
7628 neighbor_filter_list_cmd
,
7629 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7632 "Establish BGP filters\n"
7633 "AS path access-list name\n"
7634 "Filter incoming routes\n"
7635 "Filter outgoing routes\n")
7640 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7641 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7642 argv
[idx_in_out
]->arg
);
7645 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7646 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7647 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7648 "Establish BGP filters\n"
7649 "AS path access-list name\n"
7650 "Filter incoming routes\n"
7651 "Filter outgoing routes\n")
7653 DEFUN (no_neighbor_filter_list
,
7654 no_neighbor_filter_list_cmd
,
7655 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7659 "Establish BGP filters\n"
7660 "AS path access-list name\n"
7661 "Filter incoming routes\n"
7662 "Filter outgoing routes\n")
7666 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7667 bgp_node_afi(vty
), bgp_node_safi(vty
),
7668 argv
[idx_in_out
]->arg
);
7671 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7672 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7673 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7674 "Establish BGP filters\n"
7675 "AS path access-list name\n"
7676 "Filter incoming routes\n"
7677 "Filter outgoing routes\n")
7679 /* Set advertise-map to the peer. */
7680 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7681 afi_t afi
, safi_t safi
,
7682 const char *advertise_str
,
7683 const char *condition_str
, bool condition
,
7686 int ret
= CMD_WARNING_CONFIG_FAILED
;
7688 struct route_map
*advertise_map
;
7689 struct route_map
*condition_map
;
7691 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7695 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7696 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7699 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7700 advertise_map
, condition_str
,
7701 condition_map
, condition
);
7703 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7704 advertise_map
, condition_str
,
7705 condition_map
, condition
);
7707 return bgp_vty_return(vty
, ret
);
7710 DEFPY (bgp_condadv_period
,
7711 bgp_condadv_period_cmd
,
7712 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7715 "Conditional advertisement settings\n"
7716 "Set period to rescan BGP table to check if condition is met\n"
7717 "Period between BGP table scans, in seconds; default 60\n")
7719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7721 bgp
->condition_check_period
=
7722 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7727 DEFPY (neighbor_advertise_map
,
7728 neighbor_advertise_map_cmd
,
7729 "[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",
7733 "Route-map to conditionally advertise routes\n"
7734 "Name of advertise map\n"
7735 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7736 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7737 "Name of the exist or non exist map\n")
7739 bool condition
= CONDITION_EXIST
;
7741 if (!strcmp(exist
, "non-exist-map"))
7742 condition
= CONDITION_NON_EXIST
;
7744 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7745 bgp_node_safi(vty
), advertise_str
,
7746 condition_str
, condition
, !no
);
7749 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7750 "[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",
7751 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7752 "Route-map to conditionally advertise routes\n"
7753 "Name of advertise map\n"
7754 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7755 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7756 "Name of the exist or non exist map\n")
7758 /* Set route-map to the peer. */
7759 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7760 afi_t afi
, safi_t safi
, const char *name_str
,
7761 const char *direct_str
)
7765 int direct
= RMAP_IN
;
7766 struct route_map
*route_map
;
7768 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7770 return CMD_WARNING_CONFIG_FAILED
;
7772 /* Check filter direction. */
7773 if (strncmp(direct_str
, "in", 2) == 0)
7775 else if (strncmp(direct_str
, "o", 1) == 0)
7778 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7779 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7781 return bgp_vty_return(vty
, ret
);
7784 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7785 afi_t afi
, safi_t safi
,
7786 const char *direct_str
)
7790 int direct
= RMAP_IN
;
7792 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7794 return CMD_WARNING_CONFIG_FAILED
;
7796 /* Check filter direction. */
7797 if (strncmp(direct_str
, "in", 2) == 0)
7799 else if (strncmp(direct_str
, "o", 1) == 0)
7802 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7804 return bgp_vty_return(vty
, ret
);
7807 DEFUN (neighbor_route_map
,
7808 neighbor_route_map_cmd
,
7809 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7812 "Apply route map to neighbor\n"
7813 "Name of route map\n"
7814 "Apply map to incoming routes\n"
7815 "Apply map to outbound routes\n")
7820 return peer_route_map_set_vty(
7821 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7822 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7825 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7826 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7827 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7828 "Apply route map to neighbor\n"
7829 "Name of route map\n"
7830 "Apply map to incoming routes\n"
7831 "Apply map to outbound routes\n")
7833 DEFUN (no_neighbor_route_map
,
7834 no_neighbor_route_map_cmd
,
7835 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7839 "Apply route map to neighbor\n"
7840 "Name of route map\n"
7841 "Apply map to incoming routes\n"
7842 "Apply map to outbound routes\n")
7846 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7847 bgp_node_afi(vty
), bgp_node_safi(vty
),
7848 argv
[idx_in_out
]->arg
);
7851 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7852 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7853 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7854 "Apply route map to neighbor\n"
7855 "Name of route map\n"
7856 "Apply map to incoming routes\n"
7857 "Apply map to outbound routes\n")
7859 /* Set unsuppress-map to the peer. */
7860 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7861 afi_t afi
, safi_t safi
,
7862 const char *name_str
)
7866 struct route_map
*route_map
;
7868 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7870 return CMD_WARNING_CONFIG_FAILED
;
7872 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7873 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7875 return bgp_vty_return(vty
, ret
);
7878 /* Unset route-map from the peer. */
7879 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7880 afi_t afi
, safi_t safi
)
7885 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7887 return CMD_WARNING_CONFIG_FAILED
;
7889 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7891 return bgp_vty_return(vty
, ret
);
7894 DEFUN (neighbor_unsuppress_map
,
7895 neighbor_unsuppress_map_cmd
,
7896 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7899 "Route-map to selectively unsuppress suppressed routes\n"
7900 "Name of route map\n")
7904 return peer_unsuppress_map_set_vty(
7905 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7906 argv
[idx_word
]->arg
);
7909 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7910 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7911 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7912 "Route-map to selectively unsuppress suppressed routes\n"
7913 "Name of route map\n")
7915 DEFUN (no_neighbor_unsuppress_map
,
7916 no_neighbor_unsuppress_map_cmd
,
7917 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7921 "Route-map to selectively unsuppress suppressed routes\n"
7922 "Name of route map\n")
7925 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7927 bgp_node_safi(vty
));
7930 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7931 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7932 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7933 "Route-map to selectively unsuppress suppressed routes\n"
7934 "Name of route map\n")
7936 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7937 afi_t afi
, safi_t safi
,
7938 const char *num_str
,
7939 const char *threshold_str
, int warning
,
7940 const char *restart_str
,
7941 const char *force_str
)
7949 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7951 return CMD_WARNING_CONFIG_FAILED
;
7953 max
= strtoul(num_str
, NULL
, 10);
7955 threshold
= atoi(threshold_str
);
7957 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7960 restart
= atoi(restart_str
);
7964 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7965 restart
, force_str
? true : false);
7967 return bgp_vty_return(vty
, ret
);
7970 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7971 afi_t afi
, safi_t safi
)
7976 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7978 return CMD_WARNING_CONFIG_FAILED
;
7980 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7982 return bgp_vty_return(vty
, ret
);
7985 /* Maximum number of prefix to be sent to the neighbor. */
7986 DEFUN(neighbor_maximum_prefix_out
,
7987 neighbor_maximum_prefix_out_cmd
,
7988 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7991 "Maximum number of prefixes to be sent to this peer\n"
7992 "Maximum no. of prefix limit\n")
7999 afi_t afi
= bgp_node_afi(vty
);
8000 safi_t safi
= bgp_node_safi(vty
);
8002 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8004 return CMD_WARNING_CONFIG_FAILED
;
8006 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8008 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8010 return bgp_vty_return(vty
, ret
);
8013 DEFUN(no_neighbor_maximum_prefix_out
,
8014 no_neighbor_maximum_prefix_out_cmd
,
8015 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8019 "Maximum number of prefixes to be sent to this peer\n"
8020 "Maximum no. of prefix limit\n")
8025 afi_t afi
= bgp_node_afi(vty
);
8026 safi_t safi
= bgp_node_safi(vty
);
8028 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8030 return CMD_WARNING_CONFIG_FAILED
;
8032 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8034 return bgp_vty_return(vty
, ret
);
8037 /* Maximum number of prefix configuration. Prefix count is different
8038 for each peer configuration. So this configuration can be set for
8039 each peer configuration. */
8040 DEFUN (neighbor_maximum_prefix
,
8041 neighbor_maximum_prefix_cmd
,
8042 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8045 "Maximum number of prefix accept from this peer\n"
8046 "maximum no. of prefix limit\n"
8047 "Force checking all received routes not only accepted\n")
8054 if (argv_find(argv
, argc
, "force", &idx_force
))
8055 force
= argv
[idx_force
]->arg
;
8057 return peer_maximum_prefix_set_vty(
8058 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8059 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8062 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8063 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8064 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8065 "Maximum number of prefix accept from this peer\n"
8066 "maximum no. of prefix limit\n"
8067 "Force checking all received routes not only accepted\n")
8069 DEFUN (neighbor_maximum_prefix_threshold
,
8070 neighbor_maximum_prefix_threshold_cmd
,
8071 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8074 "Maximum number of prefix accept from this peer\n"
8075 "maximum no. of prefix limit\n"
8076 "Threshold value (%) at which to generate a warning msg\n"
8077 "Force checking all received routes not only accepted\n")
8081 int idx_number_2
= 4;
8085 if (argv_find(argv
, argc
, "force", &idx_force
))
8086 force
= argv
[idx_force
]->arg
;
8088 return peer_maximum_prefix_set_vty(
8089 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8090 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8094 neighbor_maximum_prefix_threshold
,
8095 neighbor_maximum_prefix_threshold_hidden_cmd
,
8096 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8097 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8098 "Maximum number of prefix accept from this peer\n"
8099 "maximum no. of prefix limit\n"
8100 "Threshold value (%) at which to generate a warning msg\n"
8101 "Force checking all received routes not only accepted\n")
8103 DEFUN (neighbor_maximum_prefix_warning
,
8104 neighbor_maximum_prefix_warning_cmd
,
8105 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8108 "Maximum number of prefix accept from this peer\n"
8109 "maximum no. of prefix limit\n"
8110 "Only give warning message when limit is exceeded\n"
8111 "Force checking all received routes not only accepted\n")
8118 if (argv_find(argv
, argc
, "force", &idx_force
))
8119 force
= argv
[idx_force
]->arg
;
8121 return peer_maximum_prefix_set_vty(
8122 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8123 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8127 neighbor_maximum_prefix_warning
,
8128 neighbor_maximum_prefix_warning_hidden_cmd
,
8129 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8130 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8131 "Maximum number of prefix accept from this peer\n"
8132 "maximum no. of prefix limit\n"
8133 "Only give warning message when limit is exceeded\n"
8134 "Force checking all received routes not only accepted\n")
8136 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8137 neighbor_maximum_prefix_threshold_warning_cmd
,
8138 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8141 "Maximum number of prefix accept from this peer\n"
8142 "maximum no. of prefix limit\n"
8143 "Threshold value (%) at which to generate a warning msg\n"
8144 "Only give warning message when limit is exceeded\n"
8145 "Force checking all received routes not only accepted\n")
8149 int idx_number_2
= 4;
8153 if (argv_find(argv
, argc
, "force", &idx_force
))
8154 force
= argv
[idx_force
]->arg
;
8156 return peer_maximum_prefix_set_vty(
8157 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8158 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8162 neighbor_maximum_prefix_threshold_warning
,
8163 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8164 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8165 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8166 "Maximum number of prefix accept from this peer\n"
8167 "maximum no. of prefix limit\n"
8168 "Threshold value (%) at which to generate a warning msg\n"
8169 "Only give warning message when limit is exceeded\n"
8170 "Force checking all received routes not only accepted\n")
8172 DEFUN (neighbor_maximum_prefix_restart
,
8173 neighbor_maximum_prefix_restart_cmd
,
8174 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8177 "Maximum number of prefix accept from this peer\n"
8178 "maximum no. of prefix limit\n"
8179 "Restart bgp connection after limit is exceeded\n"
8180 "Restart interval in minutes\n"
8181 "Force checking all received routes not only accepted\n")
8185 int idx_number_2
= 5;
8189 if (argv_find(argv
, argc
, "force", &idx_force
))
8190 force
= argv
[idx_force
]->arg
;
8192 return peer_maximum_prefix_set_vty(
8193 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8194 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8198 neighbor_maximum_prefix_restart
,
8199 neighbor_maximum_prefix_restart_hidden_cmd
,
8200 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8201 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8202 "Maximum number of prefix accept from this peer\n"
8203 "maximum no. of prefix limit\n"
8204 "Restart bgp connection after limit is exceeded\n"
8205 "Restart interval in minutes\n"
8206 "Force checking all received routes not only accepted\n")
8208 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8209 neighbor_maximum_prefix_threshold_restart_cmd
,
8210 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8213 "Maximum number of prefixes to accept from this peer\n"
8214 "maximum no. of prefix limit\n"
8215 "Threshold value (%) at which to generate a warning msg\n"
8216 "Restart bgp connection after limit is exceeded\n"
8217 "Restart interval in minutes\n"
8218 "Force checking all received routes not only accepted\n")
8222 int idx_number_2
= 4;
8223 int idx_number_3
= 6;
8227 if (argv_find(argv
, argc
, "force", &idx_force
))
8228 force
= argv
[idx_force
]->arg
;
8230 return peer_maximum_prefix_set_vty(
8231 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8232 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8233 argv
[idx_number_3
]->arg
, force
);
8237 neighbor_maximum_prefix_threshold_restart
,
8238 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8239 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8240 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8241 "Maximum number of prefixes to accept from this peer\n"
8242 "maximum no. of prefix limit\n"
8243 "Threshold value (%) at which to generate a warning msg\n"
8244 "Restart bgp connection after limit is exceeded\n"
8245 "Restart interval in minutes\n"
8246 "Force checking all received routes not only accepted\n")
8248 DEFUN (no_neighbor_maximum_prefix
,
8249 no_neighbor_maximum_prefix_cmd
,
8250 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8254 "Maximum number of prefixes to accept from this peer\n"
8255 "maximum no. of prefix limit\n"
8256 "Threshold value (%) at which to generate a warning msg\n"
8257 "Restart bgp connection after limit is exceeded\n"
8258 "Restart interval in minutes\n"
8259 "Only give warning message when limit is exceeded\n"
8260 "Force checking all received routes not only accepted\n")
8263 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8265 bgp_node_safi(vty
));
8269 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8270 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8271 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8272 "Maximum number of prefixes to accept from this peer\n"
8273 "maximum no. of prefix limit\n"
8274 "Threshold value (%) at which to generate a warning msg\n"
8275 "Restart bgp connection after limit is exceeded\n"
8276 "Restart interval in minutes\n"
8277 "Only give warning message when limit is exceeded\n"
8278 "Force checking all received routes not only accepted\n")
8280 /* "neighbor soo" */
8281 DEFPY (neighbor_soo
,
8283 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8286 "Set the Site-of-Origin (SoO) extended community\n"
8287 "VPN extended community\n")
8290 afi_t afi
= bgp_node_afi(vty
);
8291 safi_t safi
= bgp_node_safi(vty
);
8292 struct ecommunity
*ecomm_soo
;
8294 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8296 return CMD_WARNING_CONFIG_FAILED
;
8298 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8300 vty_out(vty
, "%% Malformed SoO extended community\n");
8303 ecommunity_str(ecomm_soo
);
8305 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8306 ecommunity_free(&peer
->soo
[afi
][safi
]);
8307 peer
->soo
[afi
][safi
] = ecomm_soo
;
8308 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8311 return bgp_vty_return(vty
,
8312 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8315 DEFPY (no_neighbor_soo
,
8316 no_neighbor_soo_cmd
,
8317 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8321 "Set the Site-of-Origin (SoO) extended community\n"
8322 "VPN extended community\n")
8325 afi_t afi
= bgp_node_afi(vty
);
8326 safi_t safi
= bgp_node_safi(vty
);
8328 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8330 return CMD_WARNING_CONFIG_FAILED
;
8332 ecommunity_free(&peer
->soo
[afi
][safi
]);
8334 return bgp_vty_return(
8335 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8338 /* "neighbor allowas-in" */
8339 DEFUN (neighbor_allowas_in
,
8340 neighbor_allowas_in_cmd
,
8341 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8344 "Accept as-path with my AS present in it\n"
8345 "Number of occurrences of AS number\n"
8346 "Only accept my AS in the as-path if the route was originated in my AS\n")
8349 int idx_number_origin
= 3;
8355 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8357 return CMD_WARNING_CONFIG_FAILED
;
8359 if (argc
<= idx_number_origin
)
8362 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8365 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8368 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8371 return bgp_vty_return(vty
, ret
);
8375 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8376 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8377 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8378 "Accept as-path with my AS present in it\n"
8379 "Number of occurrences of AS number\n"
8380 "Only accept my AS in the as-path if the route was originated in my AS\n")
8382 DEFUN (no_neighbor_allowas_in
,
8383 no_neighbor_allowas_in_cmd
,
8384 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8388 "allow local ASN appears in aspath attribute\n"
8389 "Number of occurrences of AS number\n"
8390 "Only accept my AS in the as-path if the route was originated in my AS\n")
8396 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8398 return CMD_WARNING_CONFIG_FAILED
;
8400 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8401 bgp_node_safi(vty
));
8403 return bgp_vty_return(vty
, ret
);
8407 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8408 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8409 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8410 "allow local ASN appears in aspath attribute\n"
8411 "Number of occurrences of AS number\n"
8412 "Only accept my AS in the as-path if the route was originated in my AS\n")
8414 DEFUN (neighbor_ttl_security
,
8415 neighbor_ttl_security_cmd
,
8416 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8419 "BGP ttl-security parameters\n"
8420 "Specify the maximum number of hops to the BGP peer\n"
8421 "Number of hops to BGP peer\n")
8428 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8430 return CMD_WARNING_CONFIG_FAILED
;
8432 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8435 * If 'neighbor swpX', then this is for directly connected peers,
8436 * we should not accept a ttl-security hops value greater than 1.
8438 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8440 "%s is directly connected peer, hops cannot exceed 1\n",
8441 argv
[idx_peer
]->arg
);
8442 return CMD_WARNING_CONFIG_FAILED
;
8445 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8448 DEFUN (no_neighbor_ttl_security
,
8449 no_neighbor_ttl_security_cmd
,
8450 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8454 "BGP ttl-security parameters\n"
8455 "Specify the maximum number of hops to the BGP peer\n"
8456 "Number of hops to BGP peer\n")
8461 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8463 return CMD_WARNING_CONFIG_FAILED
;
8465 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8468 /* disable-addpath-rx */
8469 DEFUN(neighbor_disable_addpath_rx
,
8470 neighbor_disable_addpath_rx_cmd
,
8471 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8474 "Do not accept additional paths\n")
8476 char *peer_str
= argv
[1]->arg
;
8478 afi_t afi
= bgp_node_afi(vty
);
8479 safi_t safi
= bgp_node_safi(vty
);
8481 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8483 return CMD_WARNING_CONFIG_FAILED
;
8485 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8486 PEER_FLAG_DISABLE_ADDPATH_RX
);
8489 DEFUN(no_neighbor_disable_addpath_rx
,
8490 no_neighbor_disable_addpath_rx_cmd
,
8491 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8495 "Do not accept additional paths\n")
8497 char *peer_str
= argv
[2]->arg
;
8499 afi_t afi
= bgp_node_afi(vty
);
8500 safi_t safi
= bgp_node_safi(vty
);
8502 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8504 return CMD_WARNING_CONFIG_FAILED
;
8506 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8507 PEER_FLAG_DISABLE_ADDPATH_RX
);
8510 DEFUN (neighbor_addpath_tx_all_paths
,
8511 neighbor_addpath_tx_all_paths_cmd
,
8512 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8515 "Use addpath to advertise all paths to a neighbor\n")
8520 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8522 return CMD_WARNING_CONFIG_FAILED
;
8524 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8529 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8530 neighbor_addpath_tx_all_paths_hidden_cmd
,
8531 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8532 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8533 "Use addpath to advertise all paths to a neighbor\n")
8535 DEFUN (no_neighbor_addpath_tx_all_paths
,
8536 no_neighbor_addpath_tx_all_paths_cmd
,
8537 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8541 "Use addpath to advertise all paths to a neighbor\n")
8546 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8548 return CMD_WARNING_CONFIG_FAILED
;
8550 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8551 != BGP_ADDPATH_ALL
) {
8553 "%% Peer not currently configured to transmit all paths.");
8554 return CMD_WARNING_CONFIG_FAILED
;
8557 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8563 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8564 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8565 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8566 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8567 "Use addpath to advertise all paths to a neighbor\n")
8569 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8570 neighbor_addpath_tx_bestpath_per_as_cmd
,
8571 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8574 "Use addpath to advertise the bestpath per each neighboring AS\n")
8579 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8581 return CMD_WARNING_CONFIG_FAILED
;
8583 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8584 BGP_ADDPATH_BEST_PER_AS
);
8589 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8590 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8591 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8592 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8593 "Use addpath to advertise the bestpath per each neighboring AS\n")
8595 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8596 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8597 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8601 "Use addpath to advertise the bestpath per each neighboring AS\n")
8606 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8608 return CMD_WARNING_CONFIG_FAILED
;
8610 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8611 != BGP_ADDPATH_BEST_PER_AS
) {
8613 "%% Peer not currently configured to transmit all best path per as.");
8614 return CMD_WARNING_CONFIG_FAILED
;
8617 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8623 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8624 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8625 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8626 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8627 "Use addpath to advertise the bestpath per each neighboring AS\n")
8630 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8631 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8634 "Detect AS loops before sending to neighbor\n")
8638 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8640 return CMD_WARNING_CONFIG_FAILED
;
8642 peer
->as_path_loop_detection
= true;
8648 no_neighbor_aspath_loop_detection
,
8649 no_neighbor_aspath_loop_detection_cmd
,
8650 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8654 "Detect AS loops before sending to neighbor\n")
8658 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8660 return CMD_WARNING_CONFIG_FAILED
;
8662 peer
->as_path_loop_detection
= false;
8667 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8668 struct ecommunity
**list
, bool is_rt6
)
8670 struct ecommunity
*ecom
= NULL
;
8671 struct ecommunity
*ecomadd
;
8673 for (; argc
; --argc
, ++argv
) {
8675 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8676 ECOMMUNITY_ROUTE_TARGET
,
8679 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8680 ECOMMUNITY_ROUTE_TARGET
,
8683 vty_out(vty
, "Malformed community-list value\n");
8685 ecommunity_free(&ecom
);
8686 return CMD_WARNING_CONFIG_FAILED
;
8690 ecommunity_merge(ecom
, ecomadd
);
8691 ecommunity_free(&ecomadd
);
8698 ecommunity_free(&*list
);
8706 * v2vimport is true if we are handling a `import vrf ...` command
8708 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8712 switch (vty
->node
) {
8721 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8726 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8727 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8728 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8729 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8731 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8735 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8736 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8737 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8738 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8740 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8747 DEFPY (af_rd_vpn_export
,
8748 af_rd_vpn_export_cmd
,
8749 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8751 "Specify route distinguisher\n"
8752 "Between current address-family and vpn\n"
8753 "For routes leaked from current address-family to vpn\n"
8754 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8757 struct prefix_rd prd
;
8763 if (argv_find(argv
, argc
, "no", &idx
))
8767 ret
= str2prefix_rd(rd_str
, &prd
);
8769 vty_out(vty
, "%% Malformed rd\n");
8770 return CMD_WARNING_CONFIG_FAILED
;
8774 afi
= vpn_policy_getafi(vty
, bgp
, false);
8776 return CMD_WARNING_CONFIG_FAILED
;
8779 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8781 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8782 bgp_get_default(), bgp
);
8785 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8786 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8787 BGP_VPN_POLICY_TOVPN_RD_SET
);
8789 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8790 BGP_VPN_POLICY_TOVPN_RD_SET
);
8793 /* post-change: re-export vpn routes */
8794 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8795 bgp_get_default(), bgp
);
8800 ALIAS (af_rd_vpn_export
,
8801 af_no_rd_vpn_export_cmd
,
8804 "Specify route distinguisher\n"
8805 "Between current address-family and vpn\n"
8806 "For routes leaked from current address-family to vpn\n")
8808 DEFPY (af_label_vpn_export
,
8809 af_label_vpn_export_cmd
,
8810 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8812 "label value for VRF\n"
8813 "Between current address-family and vpn\n"
8814 "For routes leaked from current address-family to vpn\n"
8815 "Label Value <0-1048575>\n"
8816 "Automatically assign a label\n")
8818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8819 mpls_label_t label
= MPLS_LABEL_NONE
;
8824 if (argv_find(argv
, argc
, "no", &idx
))
8827 /* If "no ...", squash trailing parameter */
8833 label
= label_val
; /* parser should force unsigned */
8836 afi
= vpn_policy_getafi(vty
, bgp
, false);
8838 return CMD_WARNING_CONFIG_FAILED
;
8841 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8842 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8847 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8849 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8850 bgp_get_default(), bgp
);
8852 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8853 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8855 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8858 * label has previously been automatically
8859 * assigned by labelpool: release it
8861 * NB if tovpn_label == MPLS_LABEL_NONE it
8862 * means the automatic assignment is in flight
8863 * and therefore the labelpool callback must
8864 * detect that the auto label is not needed.
8867 bgp_lp_release(LP_TYPE_VRF
,
8868 &bgp
->vpn_policy
[afi
],
8869 bgp
->vpn_policy
[afi
].tovpn_label
);
8871 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8872 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8875 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8877 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8878 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8879 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8880 vpn_leak_label_callback
);
8883 /* post-change: re-export vpn routes */
8884 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8885 bgp_get_default(), bgp
);
8887 hook_call(bgp_snmp_update_last_changed
, bgp
);
8891 DEFPY (af_sid_vpn_export
,
8892 af_sid_vpn_export_cmd
,
8893 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8895 "sid value for VRF\n"
8896 "Between current address-family and vpn\n"
8897 "For routes leaked from current address-family to vpn\n"
8898 "Sid allocation index\n"
8899 "Automatically assign a label\n")
8901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8907 if (argv_find(argv
, argc
, "no", &idx
))
8909 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8910 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8912 afi
= vpn_policy_getafi(vty
, bgp
, false);
8914 return CMD_WARNING_CONFIG_FAILED
;
8918 vty_out(vty
, "It's not implemented\n");
8919 return CMD_WARNING_CONFIG_FAILED
;
8922 /* skip when it's already configured */
8923 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8924 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8925 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8929 * mode change between sid_idx and sid_auto isn't supported.
8930 * user must negate sid vpn export when they want to change the mode
8932 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8933 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8934 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8935 vty_out(vty
, "it's already configured as %s.\n",
8936 sid_auto
? "auto-mode" : "idx-mode");
8937 return CMD_WARNING_CONFIG_FAILED
;
8941 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8942 bgp_get_default(), bgp
);
8945 /* SID allocation auto-mode */
8947 zlog_debug("%s: auto sid alloc.", __func__
);
8948 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8949 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8951 /* SID allocation index-mode */
8953 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8954 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8958 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8959 bgp_get_default(), bgp
);
8963 ALIAS (af_label_vpn_export
,
8964 af_no_label_vpn_export_cmd
,
8965 "no label vpn export",
8967 "label value for VRF\n"
8968 "Between current address-family and vpn\n"
8969 "For routes leaked from current address-family to vpn\n")
8971 DEFPY (af_nexthop_vpn_export
,
8972 af_nexthop_vpn_export_cmd
,
8973 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8975 "Specify next hop to use for VRF advertised prefixes\n"
8976 "Between current address-family and vpn\n"
8977 "For routes leaked from current address-family to vpn\n"
8981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8987 vty_out(vty
, "%% Nexthop required\n");
8988 return CMD_WARNING_CONFIG_FAILED
;
8990 if (!sockunion2hostprefix(nexthop_su
, &p
))
8991 return CMD_WARNING_CONFIG_FAILED
;
8994 afi
= vpn_policy_getafi(vty
, bgp
, false);
8996 return CMD_WARNING_CONFIG_FAILED
;
8999 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9001 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9002 bgp_get_default(), bgp
);
9005 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9006 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9007 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9009 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9010 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9013 /* post-change: re-export vpn routes */
9014 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9015 bgp_get_default(), bgp
);
9020 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9022 if (!strcmp(dstr
, "import")) {
9023 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9024 } else if (!strcmp(dstr
, "export")) {
9025 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9026 } else if (!strcmp(dstr
, "both")) {
9027 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9028 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9030 vty_out(vty
, "%% direction parse error\n");
9031 return CMD_WARNING_CONFIG_FAILED
;
9036 DEFPY (af_rt_vpn_imexport
,
9037 af_rt_vpn_imexport_cmd
,
9038 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9040 "Specify route target list\n"
9041 "Specify route target list\n"
9042 "Between current address-family and vpn\n"
9043 "For routes leaked from vpn to current address-family: match any\n"
9044 "For routes leaked from current address-family to vpn: set\n"
9045 "both import: match any and export: set\n"
9046 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9050 struct ecommunity
*ecom
= NULL
;
9051 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9052 enum vpn_policy_direction dir
;
9057 if (argv_find(argv
, argc
, "no", &idx
))
9060 afi
= vpn_policy_getafi(vty
, bgp
, false);
9062 return CMD_WARNING_CONFIG_FAILED
;
9064 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9065 if (ret
!= CMD_SUCCESS
)
9069 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9070 vty_out(vty
, "%% Missing RTLIST\n");
9071 return CMD_WARNING_CONFIG_FAILED
;
9073 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9074 if (ret
!= CMD_SUCCESS
) {
9079 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9083 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9086 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9088 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9089 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9090 ecommunity_dup(ecom
);
9092 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9094 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9095 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9098 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9102 ecommunity_free(&ecom
);
9107 ALIAS (af_rt_vpn_imexport
,
9108 af_no_rt_vpn_imexport_cmd
,
9109 "no <rt|route-target> vpn <import|export|both>$direction_str",
9111 "Specify route target list\n"
9112 "Specify route target list\n"
9113 "Between current address-family and vpn\n"
9114 "For routes leaked from vpn to current address-family\n"
9115 "For routes leaked from current address-family to vpn\n"
9116 "both import and export\n")
9118 DEFPY (af_route_map_vpn_imexport
,
9119 af_route_map_vpn_imexport_cmd
,
9120 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9121 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9123 "Specify route map\n"
9124 "Between current address-family and vpn\n"
9125 "For routes leaked from vpn to current address-family\n"
9126 "For routes leaked from current address-family to vpn\n"
9127 "name of route-map\n")
9129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9131 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9132 enum vpn_policy_direction dir
;
9137 if (argv_find(argv
, argc
, "no", &idx
))
9140 afi
= vpn_policy_getafi(vty
, bgp
, false);
9142 return CMD_WARNING_CONFIG_FAILED
;
9144 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9145 if (ret
!= CMD_SUCCESS
)
9148 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9152 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9155 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9156 XFREE(MTYPE_ROUTE_MAP_NAME
,
9157 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9158 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9159 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9160 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9161 route_map_lookup_warn_noexist(vty
, rmap_str
);
9162 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9165 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9166 XFREE(MTYPE_ROUTE_MAP_NAME
,
9167 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9168 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9169 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9172 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9178 ALIAS (af_route_map_vpn_imexport
,
9179 af_no_route_map_vpn_imexport_cmd
,
9180 "no route-map vpn <import|export>$direction_str",
9182 "Specify route map\n"
9183 "Between current address-family and vpn\n"
9184 "For routes leaked from vpn to current address-family\n"
9185 "For routes leaked from current address-family to vpn\n")
9187 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9188 "import vrf route-map RMAP$rmap_str",
9189 "Import routes from another VRF\n"
9190 "Vrf routes being filtered\n"
9191 "Specify route map\n"
9192 "name of route-map\n")
9194 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9195 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9197 struct bgp
*bgp_default
;
9199 afi
= vpn_policy_getafi(vty
, bgp
, true);
9201 return CMD_WARNING_CONFIG_FAILED
;
9203 bgp_default
= bgp_get_default();
9208 /* Auto-create assuming the same AS */
9209 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9210 BGP_INSTANCE_TYPE_DEFAULT
);
9214 "VRF default is not configured as a bgp instance\n");
9219 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9221 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9222 XFREE(MTYPE_ROUTE_MAP_NAME
,
9223 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9224 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9225 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9226 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9227 route_map_lookup_warn_noexist(vty
, rmap_str
);
9228 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9231 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9232 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9234 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9239 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9240 "no import vrf route-map [RMAP$rmap_str]",
9242 "Import routes from another VRF\n"
9243 "Vrf routes being filtered\n"
9244 "Specify route map\n"
9245 "name of route-map\n")
9247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9248 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9251 afi
= vpn_policy_getafi(vty
, bgp
, true);
9253 return CMD_WARNING_CONFIG_FAILED
;
9255 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9257 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9258 XFREE(MTYPE_ROUTE_MAP_NAME
,
9259 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9260 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9261 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9263 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9264 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9265 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9267 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9272 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9273 "[no] import vrf VIEWVRFNAME$import_name",
9275 "Import routes from another VRF\n"
9276 "VRF to import from\n"
9277 "The name of the VRF\n")
9279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9280 struct listnode
*node
;
9281 struct bgp
*vrf_bgp
, *bgp_default
;
9284 bool remove
= false;
9287 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9291 if (import_name
== NULL
) {
9292 vty_out(vty
, "%% Missing import name\n");
9296 if (strcmp(import_name
, "route-map") == 0) {
9297 vty_out(vty
, "%% Must include route-map name\n");
9301 if (argv_find(argv
, argc
, "no", &idx
))
9304 afi
= vpn_policy_getafi(vty
, bgp
, true);
9306 return CMD_WARNING_CONFIG_FAILED
;
9308 safi
= bgp_node_safi(vty
);
9310 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9311 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9312 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9313 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9314 remove
? "unimport" : "import", import_name
);
9318 bgp_default
= bgp_get_default();
9320 /* Auto-create assuming the same AS */
9321 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9322 BGP_INSTANCE_TYPE_DEFAULT
);
9326 "VRF default is not configured as a bgp instance\n");
9331 vrf_bgp
= bgp_lookup_by_name(import_name
);
9333 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9334 vrf_bgp
= bgp_default
;
9336 /* Auto-create assuming the same AS */
9337 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9341 "VRF %s is not configured as a bgp instance\n",
9348 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9350 /* Already importing from "import_vrf"? */
9351 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9353 if (strcmp(vname
, import_name
) == 0)
9357 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9363 /* This command is valid only in a bgp vrf instance or the default instance */
9364 DEFPY (bgp_imexport_vpn
,
9365 bgp_imexport_vpn_cmd
,
9366 "[no] <import|export>$direction_str vpn",
9368 "Import routes to this address-family\n"
9369 "Export routes from this address-family\n"
9370 "to/from default instance VPN RIB\n")
9372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9379 enum vpn_policy_direction dir
;
9381 if (argv_find(argv
, argc
, "no", &idx
))
9384 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9385 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9387 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9388 return CMD_WARNING_CONFIG_FAILED
;
9391 afi
= bgp_node_afi(vty
);
9392 safi
= bgp_node_safi(vty
);
9393 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9394 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9395 return CMD_WARNING_CONFIG_FAILED
;
9398 if (!strcmp(direction_str
, "import")) {
9399 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9400 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9401 } else if (!strcmp(direction_str
, "export")) {
9402 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9403 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9405 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9406 return CMD_WARNING_CONFIG_FAILED
;
9409 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9412 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9413 if (!previous_state
) {
9414 /* trigger export current vrf */
9415 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9418 if (previous_state
) {
9419 /* trigger un-export current vrf */
9420 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9422 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9425 hook_call(bgp_snmp_init_stats
, bgp
);
9430 DEFPY (af_routetarget_import
,
9431 af_routetarget_import_cmd
,
9432 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9434 "Specify route target list\n"
9435 "Specify route target list\n"
9436 "Specify route target list\n"
9437 "Specify route target list\n"
9438 "Flow-spec redirect type route target\n"
9439 "Import routes to this address-family\n"
9440 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9444 struct ecommunity
*ecom
= NULL
;
9446 int idx
= 0, idx_unused
= 0;
9450 if (argv_find(argv
, argc
, "no", &idx
))
9453 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9454 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9457 afi
= vpn_policy_getafi(vty
, bgp
, false);
9459 return CMD_WARNING_CONFIG_FAILED
;
9461 if (rt6
&& afi
!= AFI_IP6
)
9462 return CMD_WARNING_CONFIG_FAILED
;
9465 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9466 vty_out(vty
, "%% Missing RTLIST\n");
9467 return CMD_WARNING_CONFIG_FAILED
;
9469 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9470 if (ret
!= CMD_SUCCESS
)
9475 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9476 ecommunity_free(&bgp
->vpn_policy
[afi
]
9477 .import_redirect_rtlist
);
9478 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9479 ecommunity_dup(ecom
);
9481 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9482 ecommunity_free(&bgp
->vpn_policy
[afi
]
9483 .import_redirect_rtlist
);
9484 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9488 ecommunity_free(&ecom
);
9493 DEFUN_NOSH (address_family_ipv4_safi
,
9494 address_family_ipv4_safi_cmd
,
9495 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9496 "Enter Address Family command mode\n"
9498 BGP_SAFI_WITH_LABEL_HELP_STR
)
9502 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9503 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9504 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9505 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9506 && safi
!= SAFI_EVPN
) {
9508 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9509 return CMD_WARNING_CONFIG_FAILED
;
9511 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9513 vty
->node
= BGP_IPV4_NODE
;
9518 DEFUN_NOSH (address_family_ipv6_safi
,
9519 address_family_ipv6_safi_cmd
,
9520 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9521 "Enter Address Family command mode\n"
9523 BGP_SAFI_WITH_LABEL_HELP_STR
)
9526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9527 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9528 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9529 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9530 && safi
!= SAFI_EVPN
) {
9532 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9533 return CMD_WARNING_CONFIG_FAILED
;
9535 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9537 vty
->node
= BGP_IPV6_NODE
;
9542 #ifdef KEEP_OLD_VPN_COMMANDS
9543 DEFUN_NOSH (address_family_vpnv4
,
9544 address_family_vpnv4_cmd
,
9545 "address-family vpnv4 [unicast]",
9546 "Enter Address Family command mode\n"
9548 BGP_AF_MODIFIER_STR
)
9550 vty
->node
= BGP_VPNV4_NODE
;
9554 DEFUN_NOSH (address_family_vpnv6
,
9555 address_family_vpnv6_cmd
,
9556 "address-family vpnv6 [unicast]",
9557 "Enter Address Family command mode\n"
9559 BGP_AF_MODIFIER_STR
)
9561 vty
->node
= BGP_VPNV6_NODE
;
9564 #endif /* KEEP_OLD_VPN_COMMANDS */
9566 DEFUN_NOSH (address_family_evpn
,
9567 address_family_evpn_cmd
,
9568 "address-family l2vpn evpn",
9569 "Enter Address Family command mode\n"
9571 BGP_AF_MODIFIER_STR
)
9573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9574 vty
->node
= BGP_EVPN_NODE
;
9578 DEFUN_NOSH (bgp_segment_routing_srv6
,
9579 bgp_segment_routing_srv6_cmd
,
9580 "segment-routing srv6",
9581 "Segment-Routing configuration\n"
9582 "Segment-Routing SRv6 configuration\n")
9584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9585 bgp
->srv6_enabled
= true;
9586 vty
->node
= BGP_SRV6_NODE
;
9590 DEFUN (no_bgp_segment_routing_srv6
,
9591 no_bgp_segment_routing_srv6_cmd
,
9592 "no segment-routing srv6",
9594 "Segment-Routing configuration\n"
9595 "Segment-Routing SRv6 configuration\n")
9597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9599 if (strlen(bgp
->srv6_locator_name
) > 0)
9600 if (bgp_srv6_locator_unset(bgp
) < 0)
9601 return CMD_WARNING_CONFIG_FAILED
;
9603 bgp
->srv6_enabled
= false;
9607 DEFPY (bgp_srv6_locator
,
9608 bgp_srv6_locator_cmd
,
9609 "locator NAME$name",
9610 "Specify SRv6 locator\n"
9611 "Specify SRv6 locator\n")
9613 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9616 if (strlen(bgp
->srv6_locator_name
) > 0
9617 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9618 vty_out(vty
, "srv6 locator is already configured\n");
9619 return CMD_WARNING_CONFIG_FAILED
;
9622 snprintf(bgp
->srv6_locator_name
,
9623 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9625 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9627 return CMD_WARNING_CONFIG_FAILED
;
9632 DEFPY (no_bgp_srv6_locator
,
9633 no_bgp_srv6_locator_cmd
,
9634 "no locator NAME$name",
9636 "Specify SRv6 locator\n"
9637 "Specify SRv6 locator\n")
9639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9641 /* when locator isn't configured, do nothing */
9642 if (strlen(bgp
->srv6_locator_name
) < 1)
9645 /* name validation */
9646 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9647 vty_out(vty
, "%% No srv6 locator is configured\n");
9648 return CMD_WARNING_CONFIG_FAILED
;
9652 if (bgp_srv6_locator_unset(bgp
) < 0)
9653 return CMD_WARNING_CONFIG_FAILED
;
9658 DEFPY (show_bgp_srv6
,
9660 "show bgp segment-routing srv6",
9663 "BGP Segment Routing\n"
9664 "BGP Segment Routing SRv6\n")
9667 struct listnode
*node
;
9668 struct srv6_locator_chunk
*chunk
;
9669 struct bgp_srv6_function
*func
;
9672 bgp
= bgp_get_default();
9676 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9677 vty_out(vty
, "locator_chunks:\n");
9678 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9679 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9681 vty_out(vty
, "functions:\n");
9682 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9683 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9684 vty_out(vty
, "- sid: %s\n", buf
);
9685 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9688 vty_out(vty
, "bgps:\n");
9689 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9690 vty_out(vty
, "- name: %s\n",
9691 bgp
->name
? bgp
->name
: "default");
9693 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9694 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9695 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9696 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9702 DEFUN_NOSH (exit_address_family
,
9703 exit_address_family_cmd
,
9704 "exit-address-family",
9705 "Exit from Address Family configuration mode\n")
9707 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9708 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9709 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9710 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9711 || vty
->node
== BGP_EVPN_NODE
9712 || vty
->node
== BGP_FLOWSPECV4_NODE
9713 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9714 vty
->node
= BGP_NODE
;
9718 /* Recalculate bestpath and re-advertise a prefix */
9719 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9720 const char *ip_str
, afi_t afi
, safi_t safi
,
9721 struct prefix_rd
*prd
)
9724 struct prefix match
;
9725 struct bgp_dest
*dest
;
9726 struct bgp_dest
*rm
;
9728 struct bgp_table
*table
;
9729 struct bgp_table
*rib
;
9731 /* BGP structure lookup. */
9733 bgp
= bgp_lookup_by_name(view_name
);
9735 vty_out(vty
, "%% Can't find BGP instance %s\n",
9740 bgp
= bgp_get_default();
9742 vty_out(vty
, "%% No BGP process is configured\n");
9747 /* Check IP address argument. */
9748 ret
= str2prefix(ip_str
, &match
);
9750 vty_out(vty
, "%% address is malformed\n");
9754 match
.family
= afi2family(afi
);
9755 rib
= bgp
->rib
[afi
][safi
];
9757 if (safi
== SAFI_MPLS_VPN
) {
9758 for (dest
= bgp_table_top(rib
); dest
;
9759 dest
= bgp_route_next(dest
)) {
9760 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9762 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9765 table
= bgp_dest_get_bgp_table_info(dest
);
9769 rm
= bgp_node_match(table
, &match
);
9771 const struct prefix
*rm_p
=
9772 bgp_dest_get_prefix(rm
);
9774 if (rm_p
->prefixlen
== match
.prefixlen
) {
9776 BGP_NODE_USER_CLEAR
);
9777 bgp_process(bgp
, rm
, afi
, safi
);
9779 bgp_dest_unlock_node(rm
);
9783 dest
= bgp_node_match(rib
, &match
);
9785 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9787 if (dest_p
->prefixlen
== match
.prefixlen
) {
9788 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9789 bgp_process(bgp
, dest
, afi
, safi
);
9791 bgp_dest_unlock_node(dest
);
9798 /* one clear bgp command to rule them all */
9799 DEFUN (clear_ip_bgp_all
,
9800 clear_ip_bgp_all_cmd
,
9801 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]",
9805 BGP_INSTANCE_HELP_STR
9808 BGP_SAFI_WITH_LABEL_HELP_STR
9811 "BGP IPv4 neighbor to clear\n"
9812 "BGP IPv6 neighbor to clear\n"
9813 "BGP neighbor on interface to clear\n"
9814 "Clear peers with the AS number\n"
9815 "Clear all external peers\n"
9816 "Clear all members of peer-group\n"
9817 "BGP peer-group name\n"
9822 "Push out prefix-list ORF and do inbound soft reconfig\n"
9824 "Reset message statistics\n")
9828 afi_t afi
= AFI_UNSPEC
;
9829 safi_t safi
= SAFI_UNSPEC
;
9830 enum clear_sort clr_sort
= clear_peer
;
9831 enum bgp_clear_type clr_type
;
9832 char *clr_arg
= NULL
;
9836 /* clear [ip] bgp */
9837 if (argv_find(argv
, argc
, "ip", &idx
))
9840 /* [<vrf> VIEWVRFNAME] */
9841 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9842 vrf
= argv
[idx
+ 1]->arg
;
9844 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9846 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9847 /* [<view> VIEWVRFNAME] */
9848 vrf
= argv
[idx
+ 1]->arg
;
9851 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9852 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9853 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9855 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9856 if (argv_find(argv
, argc
, "*", &idx
)) {
9857 clr_sort
= clear_all
;
9858 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9859 clr_sort
= clear_peer
;
9860 clr_arg
= argv
[idx
]->arg
;
9861 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9862 clr_sort
= clear_peer
;
9863 clr_arg
= argv
[idx
]->arg
;
9864 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9865 clr_sort
= clear_group
;
9867 clr_arg
= argv
[idx
]->arg
;
9868 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9869 clr_sort
= clear_peer
;
9870 clr_arg
= argv
[idx
]->arg
;
9871 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9872 clr_sort
= clear_peer
;
9873 clr_arg
= argv
[idx
]->arg
;
9874 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9875 clr_sort
= clear_as
;
9876 clr_arg
= argv
[idx
]->arg
;
9877 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9878 clr_sort
= clear_external
;
9881 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9882 if (argv_find(argv
, argc
, "soft", &idx
)) {
9883 if (argv_find(argv
, argc
, "in", &idx
)
9884 || argv_find(argv
, argc
, "out", &idx
))
9885 clr_type
= strmatch(argv
[idx
]->text
, "in")
9887 : BGP_CLEAR_SOFT_OUT
;
9889 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9890 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9891 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9892 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9893 : BGP_CLEAR_SOFT_IN
;
9894 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9895 clr_type
= BGP_CLEAR_SOFT_OUT
;
9896 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9897 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9899 clr_type
= BGP_CLEAR_SOFT_NONE
;
9901 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9904 DEFUN (clear_ip_bgp_prefix
,
9905 clear_ip_bgp_prefix_cmd
,
9906 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9910 BGP_INSTANCE_HELP_STR
9911 "Clear bestpath and re-advertise\n"
9915 char *prefix
= NULL
;
9919 /* [<view|vrf> VIEWVRFNAME] */
9920 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9921 vrf
= argv
[idx
+ 1]->arg
;
9923 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9925 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9926 /* [<view> VIEWVRFNAME] */
9927 vrf
= argv
[idx
+ 1]->arg
;
9931 prefix
= argv
[argc
- 1]->arg
;
9933 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9936 DEFUN (clear_bgp_ipv6_safi_prefix
,
9937 clear_bgp_ipv6_safi_prefix_cmd
,
9938 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9944 "Clear bestpath and re-advertise\n"
9948 int idx_ipv6_prefix
= 0;
9949 safi_t safi
= SAFI_UNICAST
;
9950 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9951 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9953 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9954 return bgp_clear_prefix(
9955 vty
, NULL
, prefix
, AFI_IP6
,
9959 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9960 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9961 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9965 BGP_INSTANCE_HELP_STR
9968 "Clear bestpath and re-advertise\n"
9972 int idx_vrfview
= 0;
9973 int idx_ipv6_prefix
= 0;
9974 safi_t safi
= SAFI_UNICAST
;
9975 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9976 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9977 char *vrfview
= NULL
;
9979 /* [<view|vrf> VIEWVRFNAME] */
9980 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9981 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9982 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9984 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9985 /* [<view> VIEWVRFNAME] */
9986 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9988 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9990 return bgp_clear_prefix(
9991 vty
, vrfview
, prefix
,
9992 AFI_IP6
, safi
, NULL
);
9995 DEFUN (show_bgp_views
,
9997 "show [ip] bgp views",
10001 "Show the defined BGP views\n")
10003 struct list
*inst
= bm
->bgp
;
10004 struct listnode
*node
;
10007 vty_out(vty
, "Defined BGP views:\n");
10008 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10010 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10012 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10016 return CMD_SUCCESS
;
10019 DEFUN (show_bgp_vrfs
,
10021 "show [ip] bgp vrfs [json]",
10028 char buf
[ETHER_ADDR_STRLEN
];
10029 struct list
*inst
= bm
->bgp
;
10030 struct listnode
*node
;
10032 bool uj
= use_json(argc
, argv
);
10033 json_object
*json
= NULL
;
10034 json_object
*json_vrfs
= NULL
;
10038 json
= json_object_new_object();
10039 json_vrfs
= json_object_new_object();
10042 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10043 const char *name
, *type
;
10045 struct listnode
*node2
, *nnode2
;
10046 int peers_cfg
, peers_estb
;
10047 json_object
*json_vrf
= NULL
;
10050 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10054 if (!uj
&& count
== 1) {
10056 "%4s %-5s %-16s %9s %10s %-37s\n",
10057 "Type", "Id", "routerId", "#PeersCfg",
10058 "#PeersEstb", "Name");
10059 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10060 "L3-VNI", "RouterMAC", "Interface");
10063 peers_cfg
= peers_estb
= 0;
10065 json_vrf
= json_object_new_object();
10068 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10069 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10072 if (peer_established(peer
))
10076 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10077 name
= VRF_DEFAULT_NAME
;
10086 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10088 : (int64_t)bgp
->vrf_id
;
10089 char buf
[BUFSIZ
] = {0};
10091 json_object_string_add(json_vrf
, "type", type
);
10092 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10093 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10095 json_object_int_add(json_vrf
, "numConfiguredPeers",
10097 json_object_int_add(json_vrf
, "numEstablishedPeers",
10100 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10101 json_object_string_add(
10103 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10104 json_object_string_add(json_vrf
, "interface",
10105 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10107 json_object_object_add(json_vrfs
, name
, json_vrf
);
10109 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10111 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10112 : (int)bgp
->vrf_id
,
10113 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10114 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10116 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10117 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10123 json_object_object_add(json
, "vrfs", json_vrfs
);
10125 json_object_int_add(json
, "totalVrfs", count
);
10127 vty_json(vty
, json
);
10131 "\nTotal number of VRFs (including default): %d\n",
10135 return CMD_SUCCESS
;
10138 DEFUN (show_bgp_mac_hash
,
10139 show_bgp_mac_hash_cmd
,
10140 "show bgp mac hash",
10144 "Mac Address database\n")
10146 bgp_mac_dump_table(vty
);
10148 return CMD_SUCCESS
;
10151 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10153 struct vty
*vty
= (struct vty
*)args
;
10154 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10156 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10159 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10161 vty_out(vty
, "self nexthop database:\n");
10162 bgp_nexthop_show_address_hash(vty
, bgp
);
10164 vty_out(vty
, "Tunnel-ip database:\n");
10165 hash_iterate(bgp
->tip_hash
,
10166 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10170 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10171 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10172 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10173 "martian next-hops\n"
10174 "martian next-hop database\n")
10176 struct bgp
*bgp
= NULL
;
10180 /* [<vrf> VIEWVRFNAME] */
10181 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10182 name
= argv
[idx
+ 1]->arg
;
10183 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10185 } else if (argv_find(argv
, argc
, "view", &idx
))
10186 /* [<view> VIEWVRFNAME] */
10187 name
= argv
[idx
+ 1]->arg
;
10189 bgp
= bgp_lookup_by_name(name
);
10191 bgp
= bgp_get_default();
10194 vty_out(vty
, "%% No BGP process is configured\n");
10195 return CMD_WARNING
;
10197 bgp_show_martian_nexthops(vty
, bgp
);
10199 return CMD_SUCCESS
;
10202 DEFUN (show_bgp_memory
,
10203 show_bgp_memory_cmd
,
10204 "show [ip] bgp memory",
10208 "Global BGP memory statistics\n")
10210 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10211 unsigned long count
;
10213 /* RIB related usage stats */
10214 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10215 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10216 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10217 count
* sizeof(struct bgp_dest
)));
10219 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10220 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10221 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10222 count
* sizeof(struct bgp_path_info
)));
10223 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10224 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10227 memstrbuf
, sizeof(memstrbuf
),
10228 count
* sizeof(struct bgp_path_info_extra
)));
10230 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10231 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10232 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10233 count
* sizeof(struct bgp_static
)));
10235 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10236 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10237 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10238 count
* sizeof(struct bpacket
)));
10241 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10242 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10243 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10244 count
* sizeof(struct bgp_adj_in
)));
10245 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10246 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10247 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10248 count
* sizeof(struct bgp_adj_out
)));
10250 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10251 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10253 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10254 count
* sizeof(struct bgp_nexthop_cache
)));
10256 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10257 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10259 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10260 count
* sizeof(struct bgp_damp_info
)));
10263 count
= attr_count();
10264 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10265 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10266 count
* sizeof(struct attr
)));
10268 if ((count
= attr_unknown_count()))
10269 vty_out(vty
, "%ld unknown attributes\n", count
);
10271 /* AS_PATH attributes */
10272 count
= aspath_count();
10273 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10274 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10275 count
* sizeof(struct aspath
)));
10277 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10278 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10279 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10280 count
* sizeof(struct assegment
)));
10282 /* Other attributes */
10283 if ((count
= community_count()))
10284 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10285 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10286 count
* sizeof(struct community
)));
10287 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10289 "%ld BGP ext-community entries, using %s of memory\n",
10291 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10292 count
* sizeof(struct ecommunity
)));
10293 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10295 "%ld BGP large-community entries, using %s of memory\n",
10296 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10297 count
* sizeof(struct lcommunity
)));
10299 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10300 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10301 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10302 count
* sizeof(struct cluster_list
)));
10304 /* Peer related usage */
10305 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10306 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10307 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10308 count
* sizeof(struct peer
)));
10310 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10311 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10312 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10313 count
* sizeof(struct peer_group
)));
10316 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10317 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10318 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10319 count
* sizeof(regex_t
)));
10320 return CMD_SUCCESS
;
10323 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10325 json_object
*bestpath
= json_object_new_object();
10327 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10328 json_object_string_add(bestpath
, "asPath", "ignore");
10330 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10331 json_object_string_add(bestpath
, "asPath", "confed");
10333 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10334 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10335 json_object_string_add(bestpath
, "multiPathRelax",
10338 json_object_string_add(bestpath
, "multiPathRelax",
10341 json_object_string_add(bestpath
, "multiPathRelax", "false");
10343 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10344 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10346 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10347 json_object_string_add(bestpath
, "compareRouterId", "true");
10348 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10349 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10350 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10351 json_object_string_add(bestpath
, "med", "confed");
10352 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10353 json_object_string_add(bestpath
, "med",
10354 "missing-as-worst");
10356 json_object_string_add(bestpath
, "med", "true");
10359 json_object_object_add(json
, "bestPath", bestpath
);
10362 /* Print the error code/subcode for why the peer is down */
10363 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10364 json_object
*json_peer
, bool use_json
)
10366 const char *code_str
;
10367 const char *subcode_str
;
10370 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10371 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10372 char errorcodesubcode_hexstr
[5];
10373 char errorcodesubcode_str
[256];
10375 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10376 subcode_str
= bgp_notify_subcode_str(
10378 peer
->notify
.subcode
);
10380 snprintf(errorcodesubcode_hexstr
,
10381 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10382 peer
->notify
.code
, peer
->notify
.subcode
);
10383 json_object_string_add(json_peer
,
10384 "lastErrorCodeSubcode",
10385 errorcodesubcode_hexstr
);
10386 snprintf(errorcodesubcode_str
, 255, "%s%s",
10387 code_str
, subcode_str
);
10388 json_object_string_add(json_peer
,
10389 "lastNotificationReason",
10390 errorcodesubcode_str
);
10391 json_object_boolean_add(json_peer
,
10392 "lastNotificationHardReset",
10393 peer
->notify
.hard_reset
);
10394 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10395 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10396 && (peer
->notify
.subcode
10397 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10398 || peer
->notify
.subcode
10399 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10400 && peer
->notify
.length
) {
10402 const char *msg_str
;
10404 msg_str
= bgp_notify_admin_message(
10405 msgbuf
, sizeof(msgbuf
),
10406 (uint8_t *)peer
->notify
.data
,
10407 peer
->notify
.length
);
10409 json_object_string_add(
10411 "lastShutdownDescription",
10416 json_object_string_add(json_peer
, "lastResetDueTo",
10417 peer_down_str
[(int)peer
->last_reset
]);
10418 json_object_int_add(json_peer
, "lastResetCode",
10421 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10422 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10423 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10425 bgp_notify_subcode_str(peer
->notify
.code
,
10426 peer
->notify
.subcode
);
10427 vty_out(vty
, " Notification %s (%s%s%s)\n",
10428 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10431 code_str
, subcode_str
,
10432 peer
->notify
.hard_reset
10433 ? bgp_notify_subcode_str(
10435 BGP_NOTIFY_CEASE_HARD_RESET
)
10438 vty_out(vty
, " %s\n",
10439 peer_down_str
[(int)peer
->last_reset
]);
10444 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10447 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10450 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10451 struct peer
*peer
, json_object
*json_peer
,
10452 int max_neighbor_width
, bool use_json
)
10454 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10458 if (peer_dynamic_neighbor(peer
))
10459 json_object_boolean_true_add(json_peer
,
10461 if (peer
->hostname
)
10462 json_object_string_add(json_peer
, "hostname",
10465 if (peer
->domainname
)
10466 json_object_string_add(json_peer
, "domainname",
10468 json_object_int_add(json_peer
, "connectionsEstablished",
10469 peer
->established
);
10470 json_object_int_add(json_peer
, "connectionsDropped",
10472 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10473 use_json
, json_peer
);
10474 if (peer_established(peer
))
10475 json_object_string_add(json_peer
, "lastResetDueTo",
10476 "AFI/SAFI Not Negotiated");
10478 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10481 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10483 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10484 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10485 peer
->hostname
, peer
->host
);
10487 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10489 /* pad the neighbor column with spaces */
10490 if (len
< max_neighbor_width
)
10491 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10493 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10495 peer_uptime(peer
->uptime
, timebuf
,
10496 BGP_UPTIME_LEN
, 0, NULL
));
10497 if (peer_established(peer
))
10498 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10500 bgp_show_peer_reset(vty
, peer
, NULL
,
10505 /* Strip peer's description to the given size. */
10506 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10508 static char stripped
[BUFSIZ
];
10510 uint32_t last_space
= 0;
10513 if (*(desc
+ i
) == 0) {
10514 stripped
[i
] = '\0';
10517 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10519 stripped
[i
] = *(desc
+ i
);
10523 if (last_space
> size
)
10524 stripped
[size
+ 1] = '\0';
10526 stripped
[last_space
] = '\0';
10531 /* Determine whether var peer should be filtered out of the summary. */
10532 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10533 struct peer
*fpeer
, int as_type
,
10537 /* filter neighbor XXXX */
10538 if (fpeer
&& fpeer
!= peer
)
10541 /* filter remote-as (internal|external) */
10542 if (as_type
!= AS_UNSPECIFIED
) {
10543 if (peer
->as_type
== AS_SPECIFIED
) {
10544 if (as_type
== AS_INTERNAL
) {
10545 if (peer
->as
!= peer
->local_as
)
10547 } else if (peer
->as
== peer
->local_as
)
10549 } else if (as_type
!= peer
->as_type
)
10551 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10557 /* Show BGP peer's summary information.
10559 * Peer's description is stripped according to if `wide` option is given
10562 * When adding new columns to `show bgp summary` output, please make
10563 * sure `Desc` is the lastest column to show because it can contain
10564 * whitespaces and the whole output will be tricky.
10566 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10567 struct peer
*fpeer
, int as_type
, as_t as
,
10568 uint16_t show_flags
)
10571 struct listnode
*node
, *nnode
;
10572 unsigned int count
= 0, dn_count
= 0;
10573 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10574 char neighbor_buf
[VTY_BUFSIZ
];
10575 int neighbor_col_default_width
= 16;
10576 int len
, failed_count
= 0;
10577 unsigned int filtered_count
= 0;
10578 int max_neighbor_width
= 0;
10580 json_object
*json
= NULL
;
10581 json_object
*json_peer
= NULL
;
10582 json_object
*json_peers
= NULL
;
10583 struct peer_af
*paf
;
10584 struct bgp_filter
*filter
;
10585 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10586 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10587 bool show_established
=
10588 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10589 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10590 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10592 /* labeled-unicast routes are installed in the unicast table so in order
10594 * display the correct PfxRcd value we must look at SAFI_UNICAST
10597 if (safi
== SAFI_LABELED_UNICAST
)
10598 pfx_rcd_safi
= SAFI_UNICAST
;
10600 pfx_rcd_safi
= safi
;
10603 json
= json_object_new_object();
10604 json_peers
= json_object_new_object();
10605 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10606 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10613 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10616 if (peer
->afc
[afi
][safi
]) {
10617 /* See if we have at least a single failed peer */
10618 if (bgp_has_peer_failed(peer
, afi
, safi
))
10622 if (peer_dynamic_neighbor(peer
))
10627 /* Loop over all neighbors that will be displayed to determine
10629 * characters are needed for the Neighbor column
10631 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10632 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10639 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10642 if (peer
->afc
[afi
][safi
]) {
10643 memset(dn_flag
, '\0', sizeof(dn_flag
));
10644 if (peer_dynamic_neighbor(peer
))
10648 && CHECK_FLAG(bgp
->flags
,
10649 BGP_FLAG_SHOW_HOSTNAME
))
10650 snprintf(neighbor_buf
,
10651 sizeof(neighbor_buf
),
10652 "%s%s(%s) ", dn_flag
,
10653 peer
->hostname
, peer
->host
);
10655 snprintf(neighbor_buf
,
10656 sizeof(neighbor_buf
), "%s%s ",
10657 dn_flag
, peer
->host
);
10659 len
= strlen(neighbor_buf
);
10661 if (len
> max_neighbor_width
)
10662 max_neighbor_width
= len
;
10664 /* See if we have at least a single failed peer */
10665 if (bgp_has_peer_failed(peer
, afi
, safi
))
10671 /* Originally we displayed the Neighbor column as 16
10672 * characters wide so make that the default
10674 if (max_neighbor_width
< neighbor_col_default_width
)
10675 max_neighbor_width
= neighbor_col_default_width
;
10678 if (show_failed
&& !failed_count
) {
10680 json_object_int_add(json
, "failedPeersCount", 0);
10681 json_object_int_add(json
, "dynamicPeers", dn_count
);
10682 json_object_int_add(json
, "totalPeers", count
);
10684 vty_json(vty
, json
);
10686 vty_out(vty
, "%% No failed BGP neighbors found\n");
10688 return CMD_SUCCESS
;
10691 count
= 0; /* Reset the value as its used again */
10692 filtered_count
= 0;
10694 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10695 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10698 if (!peer
->afc
[afi
][safi
])
10702 unsigned long ents
;
10703 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10706 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10708 : (int64_t)bgp
->vrf_id
;
10710 /* Usage summary and header */
10712 json_object_string_addf(json
, "routerId",
10715 json_object_int_add(json
, "as", bgp
->as
);
10716 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10717 json_object_string_add(
10720 == BGP_INSTANCE_TYPE_DEFAULT
)
10725 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10726 &bgp
->router_id
, bgp
->as
,
10727 bgp
->vrf_id
== VRF_UNKNOWN
10729 : (int)bgp
->vrf_id
);
10730 vty_out(vty
, "\n");
10733 if (bgp_update_delay_configured(bgp
)) {
10735 json_object_int_add(
10736 json
, "updateDelayLimit",
10737 bgp
->v_update_delay
);
10739 if (bgp
->v_update_delay
10740 != bgp
->v_establish_wait
)
10741 json_object_int_add(
10743 "updateDelayEstablishWait",
10744 bgp
->v_establish_wait
);
10746 if (bgp_update_delay_active(bgp
)) {
10747 json_object_string_add(
10749 "updateDelayFirstNeighbor",
10750 bgp
->update_delay_begin_time
);
10751 json_object_boolean_true_add(
10753 "updateDelayInProgress");
10755 if (bgp
->update_delay_over
) {
10756 json_object_string_add(
10758 "updateDelayFirstNeighbor",
10759 bgp
->update_delay_begin_time
);
10760 json_object_string_add(
10762 "updateDelayBestpathResumed",
10763 bgp
->update_delay_end_time
);
10764 json_object_string_add(
10766 "updateDelayZebraUpdateResume",
10767 bgp
->update_delay_zebra_resume_time
);
10768 json_object_string_add(
10770 "updateDelayPeerUpdateResume",
10771 bgp
->update_delay_peers_resume_time
);
10776 "Read-only mode update-delay limit: %d seconds\n",
10777 bgp
->v_update_delay
);
10778 if (bgp
->v_update_delay
10779 != bgp
->v_establish_wait
)
10781 " Establish wait: %d seconds\n",
10782 bgp
->v_establish_wait
);
10784 if (bgp_update_delay_active(bgp
)) {
10786 " First neighbor established: %s\n",
10787 bgp
->update_delay_begin_time
);
10789 " Delay in progress\n");
10791 if (bgp
->update_delay_over
) {
10793 " First neighbor established: %s\n",
10794 bgp
->update_delay_begin_time
);
10796 " Best-paths resumed: %s\n",
10797 bgp
->update_delay_end_time
);
10799 " zebra update resumed: %s\n",
10800 bgp
->update_delay_zebra_resume_time
);
10802 " peers update resumed: %s\n",
10803 bgp
->update_delay_peers_resume_time
);
10810 if (bgp_maxmed_onstartup_configured(bgp
)
10811 && bgp
->maxmed_active
)
10812 json_object_boolean_true_add(
10813 json
, "maxMedOnStartup");
10814 if (bgp
->v_maxmed_admin
)
10815 json_object_boolean_true_add(
10816 json
, "maxMedAdministrative");
10818 json_object_int_add(
10819 json
, "tableVersion",
10820 bgp_table_version(bgp
->rib
[afi
][safi
]));
10822 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10823 json_object_int_add(json
, "ribCount", ents
);
10824 json_object_int_add(
10826 ents
* sizeof(struct bgp_dest
));
10828 ents
= bgp
->af_peer_count
[afi
][safi
];
10829 json_object_int_add(json
, "peerCount", ents
);
10830 json_object_int_add(json
, "peerMemory",
10831 ents
* sizeof(struct peer
));
10833 if ((ents
= listcount(bgp
->group
))) {
10834 json_object_int_add(
10835 json
, "peerGroupCount", ents
);
10836 json_object_int_add(
10837 json
, "peerGroupMemory",
10838 ents
* sizeof(struct
10842 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10843 BGP_CONFIG_DAMPENING
))
10844 json_object_boolean_true_add(
10845 json
, "dampeningEnabled");
10848 if (bgp_maxmed_onstartup_configured(bgp
)
10849 && bgp
->maxmed_active
)
10851 "Max-med on-startup active\n");
10852 if (bgp
->v_maxmed_admin
)
10854 "Max-med administrative active\n");
10857 "BGP table version %" PRIu64
10860 bgp
->rib
[afi
][safi
]));
10862 ents
= bgp_table_count(
10863 bgp
->rib
[afi
][safi
]);
10865 "RIB entries %ld, using %s of memory\n",
10875 /* Peer related usage */
10876 ents
= bgp
->af_peer_count
[afi
][safi
];
10878 "Peers %ld, using %s of memory\n",
10888 if ((ents
= listcount(bgp
->group
)))
10890 "Peer groups %ld, using %s of memory\n",
10900 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10901 BGP_CONFIG_DAMPENING
))
10903 "Dampening enabled.\n");
10906 vty_out(vty
, "\n");
10908 /* Subtract 8 here because 'Neighbor' is
10910 vty_out(vty
, "Neighbor");
10911 vty_out(vty
, "%*s",
10912 max_neighbor_width
- 8, " ");
10914 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10919 paf
= peer_af_find(peer
, afi
, safi
);
10920 filter
= &peer
->filter
[afi
][safi
];
10923 /* Works for both failed & successful cases */
10924 if (peer_dynamic_neighbor(peer
))
10929 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10935 bgp_has_peer_failed(peer
, afi
, safi
)) {
10936 json_peer
= json_object_new_object();
10937 bgp_show_failed_summary(vty
, bgp
, peer
,
10938 json_peer
, 0, use_json
);
10939 } else if (!show_failed
) {
10940 if (show_established
10941 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10946 json_peer
= json_object_new_object();
10947 if (peer_dynamic_neighbor(peer
)) {
10948 json_object_boolean_true_add(json_peer
,
10952 if (peer
->hostname
)
10953 json_object_string_add(json_peer
, "hostname",
10956 if (peer
->domainname
)
10957 json_object_string_add(json_peer
, "domainname",
10960 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10961 json_object_int_add(
10962 json_peer
, "localAs",
10963 peer
->change_local_as
10964 ? peer
->change_local_as
10966 json_object_int_add(json_peer
, "version", 4);
10967 json_object_int_add(json_peer
, "msgRcvd",
10968 PEER_TOTAL_RX(peer
));
10969 json_object_int_add(json_peer
, "msgSent",
10970 PEER_TOTAL_TX(peer
));
10972 atomic_size_t outq_count
, inq_count
;
10973 outq_count
= atomic_load_explicit(
10974 &peer
->obuf
->count
,
10975 memory_order_relaxed
);
10976 inq_count
= atomic_load_explicit(
10977 &peer
->ibuf
->count
,
10978 memory_order_relaxed
);
10980 json_object_int_add(json_peer
, "tableVersion",
10981 peer
->version
[afi
][safi
]);
10982 json_object_int_add(json_peer
, "outq",
10984 json_object_int_add(json_peer
, "inq",
10986 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10987 use_json
, json_peer
);
10989 json_object_int_add(json_peer
, "pfxRcd",
10990 peer
->pcount
[afi
][pfx_rcd_safi
]);
10992 if (paf
&& PAF_SUBGRP(paf
))
10993 json_object_int_add(
10994 json_peer
, "pfxSnt",
10995 (PAF_SUBGRP(paf
))->scount
);
10997 json_object_int_add(json_peer
, "pfxSnt",
11000 /* BGP FSM state */
11001 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11002 || CHECK_FLAG(peer
->bgp
->flags
,
11003 BGP_FLAG_SHUTDOWN
))
11004 json_object_string_add(json_peer
,
11007 else if (peer
->afc_recv
[afi
][safi
])
11008 json_object_string_add(
11009 json_peer
, "state",
11010 lookup_msg(bgp_status_msg
,
11011 peer
->status
, NULL
));
11012 else if (CHECK_FLAG(
11014 PEER_STATUS_PREFIX_OVERFLOW
))
11015 json_object_string_add(json_peer
,
11019 json_object_string_add(
11020 json_peer
, "state",
11021 lookup_msg(bgp_status_msg
,
11022 peer
->status
, NULL
));
11024 /* BGP peer state */
11025 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11026 || CHECK_FLAG(peer
->bgp
->flags
,
11027 BGP_FLAG_SHUTDOWN
))
11028 json_object_string_add(json_peer
,
11031 else if (CHECK_FLAG(
11033 PEER_STATUS_PREFIX_OVERFLOW
))
11034 json_object_string_add(json_peer
,
11037 else if (CHECK_FLAG(peer
->flags
,
11038 PEER_FLAG_PASSIVE
))
11039 json_object_string_add(json_peer
,
11042 else if (CHECK_FLAG(peer
->sflags
,
11043 PEER_STATUS_NSF_WAIT
))
11044 json_object_string_add(json_peer
,
11047 else if (CHECK_FLAG(
11049 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11050 && (!bgp_inbound_policy_exists(peer
,
11052 || !bgp_outbound_policy_exists(
11054 json_object_string_add(json_peer
,
11058 json_object_string_add(
11059 json_peer
, "peerState", "OK");
11061 json_object_int_add(json_peer
, "connectionsEstablished",
11062 peer
->established
);
11063 json_object_int_add(json_peer
, "connectionsDropped",
11066 json_object_string_add(
11067 json_peer
, "desc", peer
->desc
);
11069 /* Avoid creating empty peer dicts in JSON */
11070 if (json_peer
== NULL
)
11074 json_object_string_add(json_peer
, "idType",
11076 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11077 json_object_string_add(json_peer
, "idType",
11079 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11080 json_object_string_add(json_peer
, "idType",
11082 json_object_object_add(json_peers
, peer
->host
,
11085 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11091 bgp_has_peer_failed(peer
, afi
, safi
)) {
11092 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11093 max_neighbor_width
,
11095 } else if (!show_failed
) {
11096 if (show_established
11097 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11102 if ((count
- filtered_count
) == 1) {
11103 /* display headline before the first
11105 vty_out(vty
, "\n");
11107 /* Subtract 8 here because 'Neighbor' is
11109 vty_out(vty
, "Neighbor");
11110 vty_out(vty
, "%*s",
11111 max_neighbor_width
- 8, " ");
11114 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11115 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11118 memset(dn_flag
, '\0', sizeof(dn_flag
));
11119 if (peer_dynamic_neighbor(peer
)) {
11124 && CHECK_FLAG(bgp
->flags
,
11125 BGP_FLAG_SHOW_HOSTNAME
))
11126 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11130 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11132 /* pad the neighbor column with spaces */
11133 if (len
< max_neighbor_width
)
11134 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11137 atomic_size_t outq_count
, inq_count
;
11138 outq_count
= atomic_load_explicit(
11139 &peer
->obuf
->count
,
11140 memory_order_relaxed
);
11141 inq_count
= atomic_load_explicit(
11142 &peer
->ibuf
->count
,
11143 memory_order_relaxed
);
11147 "4 %10u %10u %9u %9u %8" PRIu64
11150 peer
->change_local_as
11151 ? peer
->change_local_as
11153 PEER_TOTAL_RX(peer
),
11154 PEER_TOTAL_TX(peer
),
11155 peer
->version
[afi
][safi
],
11156 inq_count
, outq_count
,
11157 peer_uptime(peer
->uptime
,
11162 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11164 peer
->as
, PEER_TOTAL_RX(peer
),
11165 PEER_TOTAL_TX(peer
),
11166 peer
->version
[afi
][safi
],
11167 inq_count
, outq_count
,
11168 peer_uptime(peer
->uptime
,
11173 if (peer_established(peer
)) {
11174 if (peer
->afc_recv
[afi
][safi
]) {
11177 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11178 && !bgp_inbound_policy_exists(
11180 vty_out(vty
, " %12s",
11189 vty_out(vty
, " NoNeg");
11192 if (paf
&& PAF_SUBGRP(paf
)) {
11195 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11196 && !bgp_outbound_policy_exists(
11198 vty_out(vty
, " %8s",
11207 vty_out(vty
, " NoNeg");
11210 if (CHECK_FLAG(peer
->flags
,
11211 PEER_FLAG_SHUTDOWN
)
11212 || CHECK_FLAG(peer
->bgp
->flags
,
11213 BGP_FLAG_SHUTDOWN
))
11214 vty_out(vty
, " Idle (Admin)");
11215 else if (CHECK_FLAG(
11217 PEER_STATUS_PREFIX_OVERFLOW
))
11218 vty_out(vty
, " Idle (PfxCt)");
11220 vty_out(vty
, " %12s",
11221 lookup_msg(bgp_status_msg
,
11222 peer
->status
, NULL
));
11224 vty_out(vty
, " %8u", 0);
11226 /* Make sure `Desc` column is the lastest in
11230 vty_out(vty
, " %s",
11231 bgp_peer_description_stripped(
11233 show_wide
? 64 : 20));
11235 vty_out(vty
, " N/A");
11236 vty_out(vty
, "\n");
11243 json_object_object_add(json
, "peers", json_peers
);
11244 json_object_int_add(json
, "failedPeers", failed_count
);
11245 json_object_int_add(json
, "displayedPeers",
11246 count
- filtered_count
);
11247 json_object_int_add(json
, "totalPeers", count
);
11248 json_object_int_add(json
, "dynamicPeers", dn_count
);
11251 bgp_show_bestpath_json(bgp
, json
);
11253 vty_json(vty
, json
);
11256 if (filtered_count
== count
)
11257 vty_out(vty
, "\n%% No matching neighbor\n");
11260 vty_out(vty
, "\nDisplayed neighbors %d",
11262 else if (as_type
!= AS_UNSPECIFIED
|| as
11263 || fpeer
|| show_established
)
11264 vty_out(vty
, "\nDisplayed neighbors %d",
11265 count
- filtered_count
);
11267 vty_out(vty
, "\nTotal number of neighbors %d\n",
11271 vty_out(vty
, "No %s neighbor is configured\n",
11272 get_afi_safi_str(afi
, safi
, false));
11276 vty_out(vty
, "* - dynamic neighbor\n");
11277 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11278 dn_count
, bgp
->dynamic_neighbors_limit
);
11282 return CMD_SUCCESS
;
11285 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11286 int safi
, struct peer
*fpeer
, int as_type
,
11287 as_t as
, uint16_t show_flags
)
11290 int afi_wildcard
= (afi
== AFI_MAX
);
11291 int safi_wildcard
= (safi
== SAFI_MAX
);
11292 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11293 bool nbr_output
= false;
11294 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11296 if (use_json
&& is_wildcard
)
11297 vty_out(vty
, "{\n");
11299 afi
= 1; /* AFI_IP */
11300 while (afi
< AFI_MAX
) {
11302 safi
= 1; /* SAFI_UNICAST */
11303 while (safi
< SAFI_MAX
) {
11304 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11309 * So limit output to those afi/safi
11311 * actualy have something interesting in
11316 vty_out(vty
, ",\n");
11320 vty_out(vty
, "\"%s\":",
11321 get_afi_safi_str(afi
,
11326 "\n%s Summary (%s):\n",
11327 get_afi_safi_str(afi
,
11333 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11334 as_type
, as
, show_flags
);
11337 if (!safi_wildcard
)
11345 if (use_json
&& is_wildcard
)
11346 vty_out(vty
, "}\n");
11347 else if (!nbr_output
) {
11349 vty_out(vty
, "{}\n");
11351 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11356 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11358 const char *neighbor
,
11359 int as_type
, as_t as
,
11360 uint16_t show_flags
)
11362 struct listnode
*node
, *nnode
;
11364 struct peer
*fpeer
= NULL
;
11366 bool nbr_output
= false;
11367 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11370 vty_out(vty
, "{\n");
11372 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11376 vty_out(vty
, ",\n");
11380 vty_out(vty
, "\"%s\":",
11381 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11386 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11391 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11396 vty_out(vty
, "}\n");
11397 else if (!nbr_output
)
11398 vty_out(vty
, "%% BGP instance not found\n");
11401 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11402 safi_t safi
, const char *neighbor
, int as_type
,
11403 as_t as
, uint16_t show_flags
)
11406 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11407 struct peer
*fpeer
= NULL
;
11410 if (strmatch(name
, "all")) {
11411 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11414 return CMD_SUCCESS
;
11416 bgp
= bgp_lookup_by_name(name
);
11420 vty_out(vty
, "{}\n");
11423 "%% BGP instance not found\n");
11424 return CMD_WARNING
;
11428 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11431 return CMD_WARNING
;
11433 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11434 as_type
, as
, show_flags
);
11435 return CMD_SUCCESS
;
11439 bgp
= bgp_get_default();
11443 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11446 return CMD_WARNING
;
11448 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11452 vty_out(vty
, "{}\n");
11454 vty_out(vty
, "%% BGP instance not found\n");
11455 return CMD_WARNING
;
11458 return CMD_SUCCESS
;
11461 /* `show [ip] bgp summary' commands. */
11462 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11463 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11464 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11465 "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <(1-4294967295)|internal|external>>] [terse] [wide] [json$uj]",
11466 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11467 BGP_SAFI_WITH_LABEL_HELP_STR
11468 "Display the entries for all address families\n"
11469 "Summary of BGP neighbor status\n"
11470 "Show only sessions in Established state\n"
11471 "Show only sessions not in Established state\n"
11472 "Show only the specified neighbor session\n"
11473 "Neighbor to display information about\n"
11474 "Neighbor to display information about\n"
11475 "Neighbor on BGP configured interface\n"
11476 "Show only the specified remote AS sessions\n"
11478 "Internal (iBGP) AS sessions\n"
11479 "External (eBGP) AS sessions\n"
11480 "Shorten the information on BGP instances\n"
11481 "Increase table width for longer output\n" JSON_STR
)
11484 afi_t afi
= AFI_MAX
;
11485 safi_t safi
= SAFI_MAX
;
11486 as_t as
= 0; /* 0 means AS filter not set */
11487 int as_type
= AS_UNSPECIFIED
;
11488 uint16_t show_flags
= 0;
11492 /* show [ip] bgp */
11493 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11495 /* [<vrf> VIEWVRFNAME] */
11496 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11497 vrf
= argv
[idx
+ 1]->arg
;
11498 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11500 } else if (argv_find(argv
, argc
, "view", &idx
))
11501 /* [<view> VIEWVRFNAME] */
11502 vrf
= argv
[idx
+ 1]->arg
;
11503 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11504 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11505 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11508 if (argv_find(argv
, argc
, "failed", &idx
))
11509 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11511 if (argv_find(argv
, argc
, "established", &idx
))
11512 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11514 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11515 if (argv
[idx
+ 1]->arg
[0] == 'i')
11516 as_type
= AS_INTERNAL
;
11517 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11518 as_type
= AS_EXTERNAL
;
11520 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11523 if (argv_find(argv
, argc
, "terse", &idx
))
11524 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11526 if (argv_find(argv
, argc
, "wide", &idx
))
11527 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11529 if (argv_find(argv
, argc
, "json", &idx
))
11530 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11532 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11536 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11539 return get_afi_safi_json_str(afi
, safi
);
11541 return get_afi_safi_vty_str(afi
, safi
);
11545 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11546 afi_t afi
, safi_t safi
,
11547 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11548 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11549 bool use_json
, json_object
*json_pref
)
11552 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11553 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11555 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11556 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11557 json_object_string_add(json_pref
, "sendMode",
11558 "advertisedAndReceived");
11559 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11560 json_object_string_add(json_pref
, "sendMode",
11562 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11563 json_object_string_add(json_pref
, "sendMode",
11566 vty_out(vty
, " Send-mode: ");
11567 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11568 vty_out(vty
, "advertised");
11569 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11570 vty_out(vty
, "%sreceived",
11571 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11575 vty_out(vty
, "\n");
11580 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11581 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11583 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11584 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11585 json_object_string_add(json_pref
, "recvMode",
11586 "advertisedAndReceived");
11587 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11588 json_object_string_add(json_pref
, "recvMode",
11590 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11591 json_object_string_add(json_pref
, "recvMode",
11594 vty_out(vty
, " Receive-mode: ");
11595 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11596 vty_out(vty
, "advertised");
11597 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11598 vty_out(vty
, "%sreceived",
11599 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11603 vty_out(vty
, "\n");
11608 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11616 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11617 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11618 && (peer_established(p
))) {
11619 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11620 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11624 json_object_boolean_add(json
, "rBit", rbit
);
11625 json_object_boolean_add(json
, "nBit", nbit
);
11627 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11628 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11632 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11637 const char *mode
= "NotApplicable";
11640 vty_out(vty
, "\n Remote GR Mode: ");
11642 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11643 && (peer_established(peer
))) {
11645 if ((peer
->nsf_af_count
== 0)
11646 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11650 } else if (peer
->nsf_af_count
== 0
11651 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11655 } else if (peer
->nsf_af_count
!= 0
11656 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11663 json_object_string_add(json
, "remoteGrMode", mode
);
11665 vty_out(vty
, mode
, "\n");
11668 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11673 const char *mode
= "Invalid";
11676 vty_out(vty
, " Local GR Mode: ");
11678 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11680 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11682 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11684 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11685 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11687 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11689 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11696 json_object_string_add(json
, "localGrMode", mode
);
11698 vty_out(vty
, mode
, "\n");
11702 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11703 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11707 json_object
*json_afi_safi
= NULL
;
11708 json_object
*json_timer
= NULL
;
11709 json_object
*json_endofrib_status
= NULL
;
11710 bool eor_flag
= false;
11712 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11713 if (!peer
->afc
[afi
][safi
])
11716 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11717 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11721 json_afi_safi
= json_object_new_object();
11722 json_endofrib_status
= json_object_new_object();
11723 json_timer
= json_object_new_object();
11726 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11732 vty_out(vty
, " %s:\n",
11733 get_afi_safi_str(afi
, safi
, false));
11735 vty_out(vty
, " F bit: ");
11738 if (peer
->nsf
[afi
][safi
] &&
11739 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11740 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11743 json_object_boolean_true_add(json_afi_safi
,
11746 vty_out(vty
, "True\n");
11749 json_object_boolean_false_add(json_afi_safi
,
11752 vty_out(vty
, "False\n");
11756 vty_out(vty
, " End-of-RIB sent: ");
11758 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11759 PEER_STATUS_EOR_SEND
)) {
11761 json_object_boolean_true_add(
11762 json_endofrib_status
, "endOfRibSend");
11764 PRINT_EOR_JSON(eor_flag
);
11766 vty_out(vty
, "Yes\n");
11768 " End-of-RIB sent after update: ");
11770 PRINT_EOR(eor_flag
);
11774 json_object_boolean_false_add(
11775 json_endofrib_status
, "endOfRibSend");
11776 json_object_boolean_false_add(
11777 json_endofrib_status
,
11778 "endOfRibSentAfterUpdate");
11780 vty_out(vty
, "No\n");
11782 " End-of-RIB sent after update: ");
11783 vty_out(vty
, "No\n");
11788 vty_out(vty
, " End-of-RIB received: ");
11790 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11791 PEER_STATUS_EOR_RECEIVED
)) {
11793 json_object_boolean_true_add(
11794 json_endofrib_status
, "endOfRibRecv");
11796 vty_out(vty
, "Yes\n");
11799 json_object_boolean_false_add(
11800 json_endofrib_status
, "endOfRibRecv");
11802 vty_out(vty
, "No\n");
11806 json_object_int_add(json_timer
, "stalePathTimer",
11807 peer
->bgp
->stalepath_time
);
11809 if (peer
->t_gr_stale
!= NULL
) {
11810 json_object_int_add(json_timer
,
11811 "stalePathTimerRemaining",
11812 thread_timer_remain_second(
11813 peer
->t_gr_stale
));
11816 /* Display Configured Selection
11817 * Deferral only when when
11818 * Gr mode is enabled.
11820 if (CHECK_FLAG(peer
->flags
,
11821 PEER_FLAG_GRACEFUL_RESTART
)) {
11822 json_object_int_add(json_timer
,
11823 "selectionDeferralTimer",
11824 peer
->bgp
->stalepath_time
);
11827 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11830 json_object_int_add(
11832 "selectionDeferralTimerRemaining",
11833 thread_timer_remain_second(
11834 peer
->bgp
->gr_info
[afi
][safi
]
11835 .t_select_deferral
));
11838 vty_out(vty
, " Timers:\n");
11840 " Configured Stale Path Time(sec): %u\n",
11841 peer
->bgp
->stalepath_time
);
11843 if (peer
->t_gr_stale
!= NULL
)
11845 " Stale Path Remaining(sec): %ld\n",
11846 thread_timer_remain_second(
11847 peer
->t_gr_stale
));
11848 /* Display Configured Selection
11849 * Deferral only when when
11850 * Gr mode is enabled.
11852 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11854 " Configured Selection Deferral Time(sec): %u\n",
11855 peer
->bgp
->select_defer_time
);
11857 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11860 " Selection Deferral Time Remaining(sec): %ld\n",
11861 thread_timer_remain_second(
11862 peer
->bgp
->gr_info
[afi
][safi
]
11863 .t_select_deferral
));
11866 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11867 json_endofrib_status
);
11868 json_object_object_add(json_afi_safi
, "timers",
11870 json_object_object_add(
11871 json
, get_afi_safi_str(afi
, safi
, true),
11877 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11883 json_object
*json_timer
= NULL
;
11885 json_timer
= json_object_new_object();
11887 json_object_int_add(json_timer
, "configuredRestartTimer",
11888 p
->bgp
->restart_time
);
11890 json_object_int_add(json_timer
, "receivedRestartTimer",
11893 if (p
->t_gr_restart
!= NULL
)
11894 json_object_int_add(
11895 json_timer
, "restartTimerRemaining",
11896 thread_timer_remain_second(p
->t_gr_restart
));
11898 json_object_object_add(json
, "timers", json_timer
);
11901 vty_out(vty
, " Timers:\n");
11902 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11903 p
->bgp
->restart_time
);
11905 vty_out(vty
, " Received Restart Time(sec): %u\n",
11907 if (p
->t_gr_restart
!= NULL
)
11908 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11909 thread_timer_remain_second(p
->t_gr_restart
));
11910 if (p
->t_gr_restart
!= NULL
) {
11911 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11912 thread_timer_remain_second(p
->t_gr_restart
));
11917 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11918 bool use_json
, json_object
*json
)
11920 char dn_flag
[2] = {0};
11921 /* '*' + v6 address of neighbor */
11922 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11924 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11929 json_object_string_addf(json
, "neighborAddr", "%pSU",
11932 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11935 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11939 json_object_string_add(json
, "neighborAddr",
11942 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11945 /* more gr info in new format */
11946 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11949 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11950 safi_t safi
, bool use_json
,
11951 json_object
*json_neigh
)
11953 struct bgp_filter
*filter
;
11954 struct peer_af
*paf
;
11955 char orf_pfx_name
[BUFSIZ
];
11957 json_object
*json_af
= NULL
;
11958 json_object
*json_prefA
= NULL
;
11959 json_object
*json_prefB
= NULL
;
11960 json_object
*json_addr
= NULL
;
11961 json_object
*json_advmap
= NULL
;
11964 json_addr
= json_object_new_object();
11965 json_af
= json_object_new_object();
11966 filter
= &p
->filter
[afi
][safi
];
11968 if (peer_group_active(p
))
11969 json_object_string_add(json_addr
, "peerGroupMember",
11972 paf
= peer_af_find(p
, afi
, safi
);
11973 if (paf
&& PAF_SUBGRP(paf
)) {
11974 json_object_int_add(json_addr
, "updateGroupId",
11975 PAF_UPDGRP(paf
)->id
);
11976 json_object_int_add(json_addr
, "subGroupId",
11977 PAF_SUBGRP(paf
)->id
);
11978 json_object_int_add(json_addr
, "packetQueueLength",
11979 bpacket_queue_virtual_length(paf
));
11982 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11983 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11984 PEER_CAP_ORF_PREFIX_SM_RCV
)
11985 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11986 PEER_CAP_ORF_PREFIX_RM_ADV
)
11987 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11988 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11989 json_object_int_add(json_af
, "orfType",
11991 json_prefA
= json_object_new_object();
11992 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11993 PEER_CAP_ORF_PREFIX_SM_ADV
,
11994 PEER_CAP_ORF_PREFIX_RM_ADV
,
11995 PEER_CAP_ORF_PREFIX_SM_RCV
,
11996 PEER_CAP_ORF_PREFIX_RM_RCV
,
11997 use_json
, json_prefA
);
11998 json_object_object_add(json_af
, "orfPrefixList",
12002 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12003 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12004 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12005 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12006 PEER_CAP_ORF_PREFIX_RM_ADV
)
12007 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12008 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12009 json_object_int_add(json_af
, "orfOldType",
12010 ORF_TYPE_PREFIX_OLD
);
12011 json_prefB
= json_object_new_object();
12012 bgp_show_peer_afi_orf_cap(
12013 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12014 PEER_CAP_ORF_PREFIX_RM_ADV
,
12015 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12016 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12018 json_object_object_add(json_af
, "orfOldPrefixList",
12022 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12023 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12024 PEER_CAP_ORF_PREFIX_SM_RCV
)
12025 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12026 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12027 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12028 PEER_CAP_ORF_PREFIX_RM_ADV
)
12029 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12030 PEER_CAP_ORF_PREFIX_RM_RCV
)
12031 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12032 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12033 json_object_object_add(json_addr
, "afDependentCap",
12036 json_object_free(json_af
);
12038 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12039 p
->host
, afi
, safi
);
12040 orf_pfx_count
= prefix_bgp_show_prefix_list(
12041 NULL
, afi
, orf_pfx_name
, use_json
);
12043 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12044 PEER_STATUS_ORF_PREFIX_SEND
)
12045 || orf_pfx_count
) {
12046 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12047 PEER_STATUS_ORF_PREFIX_SEND
))
12048 json_object_boolean_true_add(json_neigh
,
12051 json_object_int_add(json_addr
, "orfRecvCounter",
12054 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12055 PEER_STATUS_ORF_WAIT_REFRESH
))
12056 json_object_string_add(
12057 json_addr
, "orfFirstUpdate",
12058 "deferredUntilORFOrRouteRefreshRecvd");
12060 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12061 PEER_FLAG_REFLECTOR_CLIENT
))
12062 json_object_boolean_true_add(json_addr
,
12063 "routeReflectorClient");
12064 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12065 PEER_FLAG_RSERVER_CLIENT
))
12066 json_object_boolean_true_add(json_addr
,
12067 "routeServerClient");
12068 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12069 json_object_boolean_true_add(json_addr
,
12070 "inboundSoftConfigPermit");
12072 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12073 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12074 json_object_boolean_true_add(
12076 "privateAsNumsAllReplacedInUpdatesToNbr");
12077 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12078 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12079 json_object_boolean_true_add(
12081 "privateAsNumsReplacedInUpdatesToNbr");
12082 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12083 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12084 json_object_boolean_true_add(
12086 "privateAsNumsAllRemovedInUpdatesToNbr");
12087 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12088 PEER_FLAG_REMOVE_PRIVATE_AS
))
12089 json_object_boolean_true_add(
12091 "privateAsNumsRemovedInUpdatesToNbr");
12093 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12094 json_object_boolean_true_add(
12096 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12099 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12100 json_object_string_add(json_addr
,
12101 "overrideASNsInOutboundUpdates",
12102 "ifAspathEqualRemoteAs");
12104 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12105 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12106 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12107 json_object_boolean_true_add(json_addr
,
12108 "routerAlwaysNextHop");
12109 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12110 PEER_FLAG_AS_PATH_UNCHANGED
))
12111 json_object_boolean_true_add(
12112 json_addr
, "unchangedAsPathPropogatedToNbr");
12113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12114 PEER_FLAG_NEXTHOP_UNCHANGED
))
12115 json_object_boolean_true_add(
12116 json_addr
, "unchangedNextHopPropogatedToNbr");
12117 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12118 json_object_boolean_true_add(
12119 json_addr
, "unchangedMedPropogatedToNbr");
12120 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12121 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12122 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12123 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12124 PEER_FLAG_SEND_COMMUNITY
)
12125 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12126 PEER_FLAG_SEND_EXT_COMMUNITY
))
12127 json_object_string_add(json_addr
,
12128 "commAttriSentToNbr",
12129 "extendedAndStandard");
12130 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12131 PEER_FLAG_SEND_EXT_COMMUNITY
))
12132 json_object_string_add(json_addr
,
12133 "commAttriSentToNbr",
12136 json_object_string_add(json_addr
,
12137 "commAttriSentToNbr",
12140 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12141 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12142 if (p
->default_rmap
[afi
][safi
].name
)
12143 json_object_string_add(
12144 json_addr
, "defaultRouteMap",
12145 p
->default_rmap
[afi
][safi
].name
);
12147 if (paf
&& PAF_SUBGRP(paf
)
12148 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12149 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12150 json_object_boolean_true_add(json_addr
,
12153 json_object_boolean_true_add(json_addr
,
12157 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12158 if (is_evpn_enabled())
12159 json_object_boolean_true_add(
12160 json_addr
, "advertiseAllVnis");
12163 if (filter
->plist
[FILTER_IN
].name
12164 || filter
->dlist
[FILTER_IN
].name
12165 || filter
->aslist
[FILTER_IN
].name
12166 || filter
->map
[RMAP_IN
].name
)
12167 json_object_boolean_true_add(json_addr
,
12168 "inboundPathPolicyConfig");
12169 if (filter
->plist
[FILTER_OUT
].name
12170 || filter
->dlist
[FILTER_OUT
].name
12171 || filter
->aslist
[FILTER_OUT
].name
12172 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12173 json_object_boolean_true_add(
12174 json_addr
, "outboundPathPolicyConfig");
12177 if (filter
->plist
[FILTER_IN
].name
)
12178 json_object_string_add(json_addr
,
12179 "incomingUpdatePrefixFilterList",
12180 filter
->plist
[FILTER_IN
].name
);
12181 if (filter
->plist
[FILTER_OUT
].name
)
12182 json_object_string_add(json_addr
,
12183 "outgoingUpdatePrefixFilterList",
12184 filter
->plist
[FILTER_OUT
].name
);
12186 /* distribute-list */
12187 if (filter
->dlist
[FILTER_IN
].name
)
12188 json_object_string_add(
12189 json_addr
, "incomingUpdateNetworkFilterList",
12190 filter
->dlist
[FILTER_IN
].name
);
12191 if (filter
->dlist
[FILTER_OUT
].name
)
12192 json_object_string_add(
12193 json_addr
, "outgoingUpdateNetworkFilterList",
12194 filter
->dlist
[FILTER_OUT
].name
);
12197 if (filter
->aslist
[FILTER_IN
].name
)
12198 json_object_string_add(json_addr
,
12199 "incomingUpdateAsPathFilterList",
12200 filter
->aslist
[FILTER_IN
].name
);
12201 if (filter
->aslist
[FILTER_OUT
].name
)
12202 json_object_string_add(json_addr
,
12203 "outgoingUpdateAsPathFilterList",
12204 filter
->aslist
[FILTER_OUT
].name
);
12207 if (filter
->map
[RMAP_IN
].name
)
12208 json_object_string_add(
12209 json_addr
, "routeMapForIncomingAdvertisements",
12210 filter
->map
[RMAP_IN
].name
);
12211 if (filter
->map
[RMAP_OUT
].name
)
12212 json_object_string_add(
12213 json_addr
, "routeMapForOutgoingAdvertisements",
12214 filter
->map
[RMAP_OUT
].name
);
12216 /* ebgp-requires-policy (inbound) */
12217 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12218 && !bgp_inbound_policy_exists(p
, filter
))
12219 json_object_string_add(
12220 json_addr
, "inboundEbgpRequiresPolicy",
12221 "Inbound updates discarded due to missing policy");
12223 /* ebgp-requires-policy (outbound) */
12224 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12225 && (!bgp_outbound_policy_exists(p
, filter
)))
12226 json_object_string_add(
12227 json_addr
, "outboundEbgpRequiresPolicy",
12228 "Outbound updates discarded due to missing policy");
12230 /* unsuppress-map */
12231 if (filter
->usmap
.name
)
12232 json_object_string_add(json_addr
,
12233 "selectiveUnsuppressRouteMap",
12234 filter
->usmap
.name
);
12236 /* advertise-map */
12237 if (filter
->advmap
.aname
) {
12238 json_advmap
= json_object_new_object();
12239 json_object_string_add(json_advmap
, "condition",
12240 filter
->advmap
.condition
12243 json_object_string_add(json_advmap
, "conditionMap",
12244 filter
->advmap
.cname
);
12245 json_object_string_add(json_advmap
, "advertiseMap",
12246 filter
->advmap
.aname
);
12247 json_object_string_add(
12248 json_advmap
, "advertiseStatus",
12249 filter
->advmap
.update_type
==
12250 UPDATE_TYPE_ADVERTISE
12253 json_object_object_add(json_addr
, "advertiseMap",
12257 /* Receive prefix count */
12258 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12259 p
->pcount
[afi
][safi
]);
12260 if (paf
&& PAF_SUBGRP(paf
))
12261 json_object_int_add(json_addr
, "sentPrefixCounter",
12262 (PAF_SUBGRP(paf
))->scount
);
12264 /* Maximum prefix */
12265 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12266 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12267 p
->pmax_out
[afi
][safi
]);
12269 /* Maximum prefix */
12270 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12271 json_object_int_add(json_addr
, "prefixAllowedMax",
12272 p
->pmax
[afi
][safi
]);
12273 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12274 PEER_FLAG_MAX_PREFIX_WARNING
))
12275 json_object_boolean_true_add(
12276 json_addr
, "prefixAllowedMaxWarning");
12277 json_object_int_add(json_addr
,
12278 "prefixAllowedWarningThresh",
12279 p
->pmax_threshold
[afi
][safi
]);
12280 if (p
->pmax_restart
[afi
][safi
])
12281 json_object_int_add(
12283 "prefixAllowedRestartIntervalMsecs",
12284 p
->pmax_restart
[afi
][safi
] * 60000);
12286 json_object_object_add(json_neigh
,
12287 get_afi_safi_str(afi
, safi
, true),
12291 filter
= &p
->filter
[afi
][safi
];
12293 vty_out(vty
, " For address family: %s\n",
12294 get_afi_safi_str(afi
, safi
, false));
12296 if (peer_group_active(p
))
12297 vty_out(vty
, " %s peer-group member\n",
12300 paf
= peer_af_find(p
, afi
, safi
);
12301 if (paf
&& PAF_SUBGRP(paf
)) {
12302 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12303 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12304 vty_out(vty
, " Packet Queue length %d\n",
12305 bpacket_queue_virtual_length(paf
));
12307 vty_out(vty
, " Not part of any update group\n");
12309 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12310 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12311 PEER_CAP_ORF_PREFIX_SM_RCV
)
12312 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12313 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12314 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12315 PEER_CAP_ORF_PREFIX_RM_ADV
)
12316 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12317 PEER_CAP_ORF_PREFIX_RM_RCV
)
12318 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12319 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12320 vty_out(vty
, " AF-dependant capabilities:\n");
12322 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12323 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12324 PEER_CAP_ORF_PREFIX_SM_RCV
)
12325 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12326 PEER_CAP_ORF_PREFIX_RM_ADV
)
12327 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12328 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12330 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12332 bgp_show_peer_afi_orf_cap(
12333 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12334 PEER_CAP_ORF_PREFIX_RM_ADV
,
12335 PEER_CAP_ORF_PREFIX_SM_RCV
,
12336 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12338 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12339 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12340 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12341 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12342 PEER_CAP_ORF_PREFIX_RM_ADV
)
12343 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12344 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12346 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12347 ORF_TYPE_PREFIX_OLD
);
12348 bgp_show_peer_afi_orf_cap(
12349 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12350 PEER_CAP_ORF_PREFIX_RM_ADV
,
12351 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12352 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12355 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12356 p
->host
, afi
, safi
);
12357 orf_pfx_count
= prefix_bgp_show_prefix_list(
12358 NULL
, afi
, orf_pfx_name
, use_json
);
12360 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12361 PEER_STATUS_ORF_PREFIX_SEND
)
12362 || orf_pfx_count
) {
12363 vty_out(vty
, " Outbound Route Filter (ORF):");
12364 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12365 PEER_STATUS_ORF_PREFIX_SEND
))
12366 vty_out(vty
, " sent;");
12368 vty_out(vty
, " received (%d entries)",
12370 vty_out(vty
, "\n");
12372 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12373 PEER_STATUS_ORF_WAIT_REFRESH
))
12375 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12377 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12378 PEER_FLAG_REFLECTOR_CLIENT
))
12379 vty_out(vty
, " Route-Reflector Client\n");
12380 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12381 PEER_FLAG_RSERVER_CLIENT
))
12382 vty_out(vty
, " Route-Server Client\n");
12383 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12385 " Inbound soft reconfiguration allowed\n");
12387 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12388 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12390 " Private AS numbers (all) replaced in updates to this neighbor\n");
12391 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12392 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12394 " Private AS numbers replaced in updates to this neighbor\n");
12395 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12396 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12398 " Private AS numbers (all) removed in updates to this neighbor\n");
12399 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12400 PEER_FLAG_REMOVE_PRIVATE_AS
))
12402 " Private AS numbers removed in updates to this neighbor\n");
12404 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12405 vty_out(vty
, " %s\n",
12406 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12407 ->human_description
);
12409 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12411 " Override ASNs in outbound updates if aspath equals remote-as\n");
12413 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12414 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12416 vty_out(vty
, " NEXT_HOP is always this router\n");
12417 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12418 PEER_FLAG_AS_PATH_UNCHANGED
))
12420 " AS_PATH is propagated unchanged to this neighbor\n");
12421 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12422 PEER_FLAG_NEXTHOP_UNCHANGED
))
12424 " NEXT_HOP is propagated unchanged to this neighbor\n");
12425 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12427 " MED is propagated unchanged to this neighbor\n");
12428 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12429 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12430 PEER_FLAG_SEND_EXT_COMMUNITY
)
12431 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12432 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12434 " Community attribute sent to this neighbor");
12435 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12436 PEER_FLAG_SEND_COMMUNITY
)
12437 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12438 PEER_FLAG_SEND_EXT_COMMUNITY
)
12439 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12440 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12441 vty_out(vty
, "(all)\n");
12442 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12443 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12444 vty_out(vty
, "(large)\n");
12445 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_SEND_EXT_COMMUNITY
))
12447 vty_out(vty
, "(extended)\n");
12449 vty_out(vty
, "(standard)\n");
12451 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12452 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12453 vty_out(vty
, " Default information originate,");
12455 if (p
->default_rmap
[afi
][safi
].name
)
12456 vty_out(vty
, " default route-map %s%s,",
12457 p
->default_rmap
[afi
][safi
].map
? "*"
12459 p
->default_rmap
[afi
][safi
].name
);
12460 if (paf
&& PAF_SUBGRP(paf
)
12461 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12462 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12463 vty_out(vty
, " default sent\n");
12465 vty_out(vty
, " default not sent\n");
12468 /* advertise-vni-all */
12469 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12470 if (is_evpn_enabled())
12471 vty_out(vty
, " advertise-all-vni\n");
12474 if (filter
->plist
[FILTER_IN
].name
12475 || filter
->dlist
[FILTER_IN
].name
12476 || filter
->aslist
[FILTER_IN
].name
12477 || filter
->map
[RMAP_IN
].name
)
12478 vty_out(vty
, " Inbound path policy configured\n");
12479 if (filter
->plist
[FILTER_OUT
].name
12480 || filter
->dlist
[FILTER_OUT
].name
12481 || filter
->aslist
[FILTER_OUT
].name
12482 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12483 vty_out(vty
, " Outbound path policy configured\n");
12486 if (filter
->plist
[FILTER_IN
].name
)
12488 " Incoming update prefix filter list is %s%s\n",
12489 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12490 filter
->plist
[FILTER_IN
].name
);
12491 if (filter
->plist
[FILTER_OUT
].name
)
12493 " Outgoing update prefix filter list is %s%s\n",
12494 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12495 filter
->plist
[FILTER_OUT
].name
);
12497 /* distribute-list */
12498 if (filter
->dlist
[FILTER_IN
].name
)
12500 " Incoming update network filter list is %s%s\n",
12501 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12502 filter
->dlist
[FILTER_IN
].name
);
12503 if (filter
->dlist
[FILTER_OUT
].name
)
12505 " Outgoing update network filter list is %s%s\n",
12506 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12507 filter
->dlist
[FILTER_OUT
].name
);
12510 if (filter
->aslist
[FILTER_IN
].name
)
12512 " Incoming update AS path filter list is %s%s\n",
12513 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12514 filter
->aslist
[FILTER_IN
].name
);
12515 if (filter
->aslist
[FILTER_OUT
].name
)
12517 " Outgoing update AS path filter list is %s%s\n",
12518 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12519 filter
->aslist
[FILTER_OUT
].name
);
12522 if (filter
->map
[RMAP_IN
].name
)
12524 " Route map for incoming advertisements is %s%s\n",
12525 filter
->map
[RMAP_IN
].map
? "*" : "",
12526 filter
->map
[RMAP_IN
].name
);
12527 if (filter
->map
[RMAP_OUT
].name
)
12529 " Route map for outgoing advertisements is %s%s\n",
12530 filter
->map
[RMAP_OUT
].map
? "*" : "",
12531 filter
->map
[RMAP_OUT
].name
);
12533 /* ebgp-requires-policy (inbound) */
12534 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12535 && !bgp_inbound_policy_exists(p
, filter
))
12537 " Inbound updates discarded due to missing policy\n");
12539 /* ebgp-requires-policy (outbound) */
12540 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12541 && !bgp_outbound_policy_exists(p
, filter
))
12543 " Outbound updates discarded due to missing policy\n");
12545 /* unsuppress-map */
12546 if (filter
->usmap
.name
)
12548 " Route map for selective unsuppress is %s%s\n",
12549 filter
->usmap
.map
? "*" : "",
12550 filter
->usmap
.name
);
12552 /* advertise-map */
12553 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12555 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12556 filter
->advmap
.condition
? "EXIST"
12558 filter
->advmap
.cmap
? "*" : "",
12559 filter
->advmap
.cname
,
12560 filter
->advmap
.amap
? "*" : "",
12561 filter
->advmap
.aname
,
12562 filter
->advmap
.update_type
==
12563 UPDATE_TYPE_ADVERTISE
12567 /* Receive prefix count */
12568 vty_out(vty
, " %u accepted prefixes\n",
12569 p
->pcount
[afi
][safi
]);
12571 /* maximum-prefix-out */
12572 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12573 PEER_FLAG_MAX_PREFIX_OUT
))
12575 " Maximum allowed prefixes sent %u\n",
12576 p
->pmax_out
[afi
][safi
]);
12578 /* Maximum prefix */
12579 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12581 " Maximum prefixes allowed %u%s\n",
12582 p
->pmax
[afi
][safi
],
12583 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12584 PEER_FLAG_MAX_PREFIX_WARNING
)
12585 ? " (warning-only)"
12587 vty_out(vty
, " Threshold for warning message %d%%",
12588 p
->pmax_threshold
[afi
][safi
]);
12589 if (p
->pmax_restart
[afi
][safi
])
12590 vty_out(vty
, ", restart interval %d min",
12591 p
->pmax_restart
[afi
][safi
]);
12592 vty_out(vty
, "\n");
12595 vty_out(vty
, "\n");
12599 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12603 char buf1
[PREFIX2STR_BUFFER
];
12604 char timebuf
[BGP_UPTIME_LEN
];
12610 json_object
*json_neigh
= NULL
;
12612 uint32_t sync_tcp_mss
;
12617 json_neigh
= json_object_new_object();
12619 memset(dn_flag
, '\0', sizeof(dn_flag
));
12620 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12624 if (p
->conf_if
) /* Configured interface name. */
12625 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12627 else /* Configured IP address. */
12628 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12633 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12634 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12636 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12637 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12640 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12642 if (p
->change_local_as
)
12643 json_object_int_add(json_neigh
, "localAs",
12644 p
->change_local_as
);
12646 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12648 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12649 json_object_boolean_true_add(json_neigh
,
12650 "localAsNoPrepend");
12652 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12653 json_object_boolean_true_add(json_neigh
,
12654 "localAsReplaceAs");
12656 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12657 || (p
->as_type
== AS_INTERNAL
))
12658 vty_out(vty
, "remote AS %u, ", p
->as
);
12660 vty_out(vty
, "remote AS Unspecified, ");
12661 vty_out(vty
, "local AS %u%s%s, ",
12662 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12663 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12666 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12670 /* peer type internal or confed-internal */
12671 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12673 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12674 json_object_boolean_true_add(
12675 json_neigh
, "nbrConfedInternalLink");
12677 json_object_boolean_true_add(json_neigh
,
12678 "nbrInternalLink");
12680 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12681 vty_out(vty
, "confed-internal link\n");
12683 vty_out(vty
, "internal link\n");
12685 /* peer type external or confed-external */
12686 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12688 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12689 json_object_boolean_true_add(
12690 json_neigh
, "nbrConfedExternalLink");
12692 json_object_boolean_true_add(json_neigh
,
12693 "nbrExternalLink");
12695 if (bgp_confederation_peers_check(bgp
, p
->as
))
12696 vty_out(vty
, "confed-external link\n");
12698 vty_out(vty
, "external link\n");
12702 json_object_boolean_true_add(json_neigh
,
12703 "nbrUnspecifiedLink");
12705 vty_out(vty
, "unspecified link\n");
12710 json_object_string_add(json_neigh
, "localRole",
12711 bgp_get_name_by_role(p
->local_role
));
12712 json_object_string_add(json_neigh
, "remoteRole",
12713 bgp_get_name_by_role(p
->remote_role
));
12715 vty_out(vty
, " Local Role: %s\n",
12716 bgp_get_name_by_role(p
->local_role
));
12717 vty_out(vty
, " Remote Role: %s\n",
12718 bgp_get_name_by_role(p
->remote_role
));
12725 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12727 vty_out(vty
, " Description: %s\n", p
->desc
);
12733 json_object_string_add(json_neigh
, "hostname",
12737 json_object_string_add(json_neigh
, "domainname",
12740 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12741 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12744 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12751 json_object_string_add(json_neigh
, "peerGroup",
12755 struct prefix prefix
, *range
= NULL
;
12757 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12758 range
= peer_group_lookup_dynamic_neighbor_range(
12759 p
->group
, &prefix
);
12762 json_object_string_addf(
12764 "peerSubnetRangeGroup", "%pFX",
12770 " Member of peer-group %s for session parameters\n",
12774 struct prefix prefix
, *range
= NULL
;
12776 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12777 range
= peer_group_lookup_dynamic_neighbor_range(
12778 p
->group
, &prefix
);
12782 " Belongs to the subnet range group: %pFX\n",
12790 /* Administrative shutdown. */
12791 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12792 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12793 json_object_boolean_true_add(json_neigh
,
12797 json_object_int_add(json_neigh
, "bgpVersion", 4);
12798 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12800 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12803 /* Confederation */
12804 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12805 && bgp_confederation_peers_check(bgp
, p
->as
))
12806 json_object_boolean_true_add(json_neigh
,
12810 json_object_string_add(
12811 json_neigh
, "bgpState",
12812 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12814 if (peer_established(p
)) {
12817 uptime
= monotime(NULL
);
12818 uptime
-= p
->uptime
;
12819 epoch_tbuf
= time(NULL
) - uptime
;
12821 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12823 json_object_string_add(json_neigh
, "bgpTimerUpString",
12824 peer_uptime(p
->uptime
, timebuf
,
12827 json_object_int_add(json_neigh
,
12828 "bgpTimerUpEstablishedEpoch",
12832 else if (p
->status
== Active
) {
12833 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12834 json_object_string_add(json_neigh
, "bgpStateIs",
12836 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12837 json_object_string_add(json_neigh
, "bgpStateIs",
12845 uptime
= monotime(NULL
);
12846 uptime
-= p
->readtime
;
12847 gmtime_r(&uptime
, &tm
);
12849 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12850 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12851 + (tm
.tm_hour
* 3600000));
12853 uptime
= monotime(NULL
);
12854 uptime
-= p
->last_write
;
12855 gmtime_r(&uptime
, &tm
);
12857 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12858 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12859 + (tm
.tm_hour
* 3600000));
12861 uptime
= monotime(NULL
);
12862 uptime
-= p
->update_time
;
12863 gmtime_r(&uptime
, &tm
);
12865 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12866 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12867 + (tm
.tm_hour
* 3600000));
12869 /* Configured timer values. */
12870 json_object_int_add(json_neigh
,
12871 "bgpTimerConfiguredHoldTimeMsecs",
12872 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12873 ? p
->holdtime
* 1000
12874 : bgp
->default_holdtime
* 1000);
12875 json_object_int_add(json_neigh
,
12876 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12877 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12878 ? p
->keepalive
* 1000
12879 : bgp
->default_keepalive
* 1000);
12880 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12881 p
->v_holdtime
* 1000);
12882 json_object_int_add(json_neigh
,
12883 "bgpTimerKeepAliveIntervalMsecs",
12884 p
->v_keepalive
* 1000);
12885 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12886 json_object_int_add(json_neigh
,
12887 "bgpTimerDelayOpenTimeMsecs",
12888 p
->v_delayopen
* 1000);
12891 /* Configured and Synced tcp-mss value for peer */
12892 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12893 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12894 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12896 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12900 /* Extended Optional Parameters Length for BGP OPEN Message */
12901 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12902 json_object_boolean_true_add(
12903 json_neigh
, "extendedOptionalParametersLength");
12905 json_object_boolean_false_add(
12906 json_neigh
, "extendedOptionalParametersLength");
12908 /* Conditional advertisements */
12909 json_object_int_add(
12911 "bgpTimerConfiguredConditionalAdvertisementsSec",
12912 bgp
->condition_check_period
);
12913 if (thread_is_scheduled(bgp
->t_condition_check
))
12914 json_object_int_add(
12916 "bgpTimerUntilConditionalAdvertisementsSec",
12917 thread_timer_remain_second(
12918 bgp
->t_condition_check
));
12920 /* Administrative shutdown. */
12921 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12922 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12923 vty_out(vty
, " Administratively shut down\n");
12926 vty_out(vty
, " BGP version 4");
12927 vty_out(vty
, ", remote router ID %s",
12928 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12929 vty_out(vty
, ", local router ID %s\n",
12930 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12933 /* Confederation */
12934 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12935 && bgp_confederation_peers_check(bgp
, p
->as
))
12937 " Neighbor under common administration\n");
12940 vty_out(vty
, " BGP state = %s",
12941 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12943 if (peer_established(p
))
12944 vty_out(vty
, ", up for %8s",
12945 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12948 else if (p
->status
== Active
) {
12949 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12950 vty_out(vty
, " (passive)");
12951 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12952 vty_out(vty
, " (NSF passive)");
12954 vty_out(vty
, "\n");
12957 vty_out(vty
, " Last read %s",
12958 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12960 vty_out(vty
, ", Last write %s\n",
12961 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12964 /* Configured timer values. */
12966 " Hold time is %d seconds, keepalive interval is %d seconds\n",
12967 p
->v_holdtime
, p
->v_keepalive
);
12968 vty_out(vty
, " Configured hold time is %d seconds",
12969 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12971 : bgp
->default_holdtime
);
12972 vty_out(vty
, ", keepalive interval is %d seconds\n",
12973 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12975 : bgp
->default_keepalive
);
12976 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12978 " Configured DelayOpenTime is %d seconds\n",
12981 /* Configured and synced tcp-mss value for peer */
12982 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12983 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12984 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12985 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12988 /* Extended Optional Parameters Length for BGP OPEN Message */
12989 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12991 " Extended Optional Parameters Length is enabled\n");
12993 /* Conditional advertisements */
12995 " Configured conditional advertisements interval is %d seconds\n",
12996 bgp
->condition_check_period
);
12997 if (thread_is_scheduled(bgp
->t_condition_check
))
12999 " Time until conditional advertisements begin is %lu seconds\n",
13000 thread_timer_remain_second(
13001 bgp
->t_condition_check
));
13004 if (peer_established(p
) &&
13005 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13007 json_object
*json_cap
= NULL
;
13009 json_cap
= json_object_new_object();
13012 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13013 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13014 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13015 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13016 json_object_string_add(
13017 json_cap
, "4byteAs",
13018 "advertisedAndReceived");
13019 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13020 json_object_string_add(json_cap
,
13023 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13024 json_object_string_add(json_cap
,
13029 /* Extended Message Support */
13030 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13031 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13032 json_object_string_add(json_cap
,
13034 "advertisedAndReceived");
13035 else if (CHECK_FLAG(p
->cap
,
13036 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13037 json_object_string_add(json_cap
,
13040 else if (CHECK_FLAG(p
->cap
,
13041 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13042 json_object_string_add(json_cap
,
13047 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13048 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13049 json_object
*json_add
= NULL
;
13050 const char *print_store
;
13052 json_add
= json_object_new_object();
13054 FOREACH_AFI_SAFI (afi
, safi
) {
13055 json_object
*json_sub
= NULL
;
13056 json_sub
= json_object_new_object();
13057 print_store
= get_afi_safi_str(
13061 p
->af_cap
[afi
][safi
],
13062 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13064 p
->af_cap
[afi
][safi
],
13065 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13069 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13073 PEER_CAP_ADDPATH_AF_TX_RCV
))
13074 json_object_boolean_true_add(
13076 "txAdvertisedAndReceived");
13081 PEER_CAP_ADDPATH_AF_TX_ADV
))
13082 json_object_boolean_true_add(
13089 PEER_CAP_ADDPATH_AF_TX_RCV
))
13090 json_object_boolean_true_add(
13096 p
->af_cap
[afi
][safi
],
13097 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13099 p
->af_cap
[afi
][safi
],
13100 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13104 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13108 PEER_CAP_ADDPATH_AF_RX_RCV
))
13109 json_object_boolean_true_add(
13111 "rxAdvertisedAndReceived");
13116 PEER_CAP_ADDPATH_AF_RX_ADV
))
13117 json_object_boolean_true_add(
13124 PEER_CAP_ADDPATH_AF_RX_RCV
))
13125 json_object_boolean_true_add(
13131 p
->af_cap
[afi
][safi
],
13132 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13134 p
->af_cap
[afi
][safi
],
13135 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13137 p
->af_cap
[afi
][safi
],
13138 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13140 p
->af_cap
[afi
][safi
],
13141 PEER_CAP_ADDPATH_AF_RX_RCV
))
13142 json_object_object_add(
13143 json_add
, print_store
,
13146 json_object_free(json_sub
);
13149 json_object_object_add(json_cap
, "addPath",
13154 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13155 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13156 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13157 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13158 json_object_string_add(
13159 json_cap
, "dynamic",
13160 "advertisedAndReceived");
13161 else if (CHECK_FLAG(p
->cap
,
13162 PEER_CAP_DYNAMIC_ADV
))
13163 json_object_string_add(json_cap
,
13166 else if (CHECK_FLAG(p
->cap
,
13167 PEER_CAP_DYNAMIC_RCV
))
13168 json_object_string_add(json_cap
,
13174 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13175 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13176 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13177 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13178 json_object_string_add(
13180 "advertisedAndReceived");
13181 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13182 json_object_string_add(json_cap
, "role",
13184 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13185 json_object_string_add(json_cap
, "role",
13189 /* Extended nexthop */
13190 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13191 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13192 json_object
*json_nxt
= NULL
;
13193 const char *print_store
;
13196 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13197 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13198 json_object_string_add(
13199 json_cap
, "extendedNexthop",
13200 "advertisedAndReceived");
13201 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13202 json_object_string_add(
13203 json_cap
, "extendedNexthop",
13205 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13206 json_object_string_add(
13207 json_cap
, "extendedNexthop",
13210 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13211 json_nxt
= json_object_new_object();
13213 for (safi
= SAFI_UNICAST
;
13214 safi
< SAFI_MAX
; safi
++) {
13218 PEER_CAP_ENHE_AF_RCV
)) {
13224 json_object_string_add(
13227 "recieved"); /* misspelled for compatibility */
13230 json_object_object_add(
13232 "extendedNexthopFamililesByPeer",
13237 /* Long-lived Graceful Restart */
13238 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13239 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13240 json_object
*json_llgr
= NULL
;
13241 const char *afi_safi_str
;
13243 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13244 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13245 json_object_string_add(
13247 "longLivedGracefulRestart",
13248 "advertisedAndReceived");
13249 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13250 json_object_string_add(
13252 "longLivedGracefulRestart",
13254 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13255 json_object_string_add(
13257 "longLivedGracefulRestart",
13260 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13261 json_llgr
= json_object_new_object();
13263 FOREACH_AFI_SAFI (afi
, safi
) {
13267 PEER_CAP_ENHE_AF_RCV
)) {
13273 json_object_string_add(
13279 json_object_object_add(
13281 "longLivedGracefulRestartByPeer",
13286 /* Route Refresh */
13287 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13288 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13289 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13290 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13291 (CHECK_FLAG(p
->cap
,
13292 PEER_CAP_REFRESH_NEW_RCV
) ||
13294 PEER_CAP_REFRESH_OLD_RCV
))) {
13297 PEER_CAP_REFRESH_OLD_RCV
) &&
13300 PEER_CAP_REFRESH_NEW_RCV
))
13301 json_object_string_add(
13304 "advertisedAndReceivedOldNew");
13308 PEER_CAP_REFRESH_OLD_RCV
))
13309 json_object_string_add(
13312 "advertisedAndReceivedOld");
13314 json_object_string_add(
13317 "advertisedAndReceivedNew");
13319 } else if (CHECK_FLAG(p
->cap
,
13320 PEER_CAP_REFRESH_ADV
))
13321 json_object_string_add(json_cap
,
13324 else if (CHECK_FLAG(p
->cap
,
13325 PEER_CAP_REFRESH_NEW_RCV
) ||
13327 PEER_CAP_REFRESH_OLD_RCV
))
13328 json_object_string_add(json_cap
,
13333 /* Enhanced Route Refresh */
13334 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13335 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13336 if (CHECK_FLAG(p
->cap
,
13337 PEER_CAP_ENHANCED_RR_ADV
) &&
13339 PEER_CAP_ENHANCED_RR_RCV
))
13340 json_object_string_add(
13342 "enhancedRouteRefresh",
13343 "advertisedAndReceived");
13344 else if (CHECK_FLAG(p
->cap
,
13345 PEER_CAP_ENHANCED_RR_ADV
))
13346 json_object_string_add(
13348 "enhancedRouteRefresh",
13350 else if (CHECK_FLAG(p
->cap
,
13351 PEER_CAP_ENHANCED_RR_RCV
))
13352 json_object_string_add(
13354 "enhancedRouteRefresh",
13358 /* Multiprotocol Extensions */
13359 json_object
*json_multi
= NULL
;
13361 json_multi
= json_object_new_object();
13363 FOREACH_AFI_SAFI (afi
, safi
) {
13364 if (p
->afc_adv
[afi
][safi
] ||
13365 p
->afc_recv
[afi
][safi
]) {
13366 json_object
*json_exten
= NULL
;
13367 json_exten
= json_object_new_object();
13369 if (p
->afc_adv
[afi
][safi
] &&
13370 p
->afc_recv
[afi
][safi
])
13371 json_object_boolean_true_add(
13373 "advertisedAndReceived");
13374 else if (p
->afc_adv
[afi
][safi
])
13375 json_object_boolean_true_add(
13378 else if (p
->afc_recv
[afi
][safi
])
13379 json_object_boolean_true_add(
13380 json_exten
, "received");
13382 json_object_object_add(
13384 get_afi_safi_str(afi
, safi
,
13389 json_object_object_add(json_cap
,
13390 "multiprotocolExtensions",
13393 /* Hostname capabilities */
13394 json_object
*json_hname
= NULL
;
13396 json_hname
= json_object_new_object();
13398 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13399 json_object_string_add(
13400 json_hname
, "advHostName",
13401 bgp
->peer_self
->hostname
13402 ? bgp
->peer_self
->hostname
13404 json_object_string_add(
13405 json_hname
, "advDomainName",
13406 bgp
->peer_self
->domainname
13407 ? bgp
->peer_self
->domainname
13412 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13413 json_object_string_add(
13414 json_hname
, "rcvHostName",
13415 p
->hostname
? p
->hostname
: "n/a");
13416 json_object_string_add(
13417 json_hname
, "rcvDomainName",
13418 p
->domainname
? p
->domainname
: "n/a");
13421 json_object_object_add(json_cap
, "hostName",
13424 /* Graceful Restart */
13425 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13426 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13427 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13428 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13429 json_object_string_add(
13430 json_cap
, "gracefulRestart",
13431 "advertisedAndReceived");
13432 else if (CHECK_FLAG(p
->cap
,
13433 PEER_CAP_RESTART_ADV
))
13434 json_object_string_add(
13436 "gracefulRestartCapability",
13438 else if (CHECK_FLAG(p
->cap
,
13439 PEER_CAP_RESTART_RCV
))
13440 json_object_string_add(
13442 "gracefulRestartCapability",
13445 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13446 int restart_af_count
= 0;
13447 json_object
*json_restart
= NULL
;
13448 json_restart
= json_object_new_object();
13450 json_object_int_add(
13452 "gracefulRestartRemoteTimerMsecs",
13453 p
->v_gr_restart
* 1000);
13455 FOREACH_AFI_SAFI (afi
, safi
) {
13459 PEER_CAP_RESTART_AF_RCV
)) {
13460 json_object
*json_sub
=
13463 json_object_new_object();
13469 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13470 json_object_boolean_true_add(
13473 restart_af_count
++;
13474 json_object_object_add(
13483 if (!restart_af_count
) {
13484 json_object_string_add(
13486 "addressFamiliesByPeer",
13488 json_object_free(json_restart
);
13490 json_object_object_add(
13492 "addressFamiliesByPeer",
13496 json_object_object_add(
13497 json_neigh
, "neighborCapabilities", json_cap
);
13499 vty_out(vty
, " Neighbor capabilities:\n");
13502 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13503 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13504 vty_out(vty
, " 4 Byte AS:");
13505 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13506 vty_out(vty
, " advertised");
13507 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13508 vty_out(vty
, " %sreceived",
13513 vty_out(vty
, "\n");
13516 /* Extended Message Support */
13517 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13518 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13519 vty_out(vty
, " Extended Message:");
13520 if (CHECK_FLAG(p
->cap
,
13521 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13522 vty_out(vty
, " advertised");
13523 if (CHECK_FLAG(p
->cap
,
13524 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13525 vty_out(vty
, " %sreceived",
13528 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13531 vty_out(vty
, "\n");
13535 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13536 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13537 vty_out(vty
, " AddPath:\n");
13539 FOREACH_AFI_SAFI (afi
, safi
) {
13541 p
->af_cap
[afi
][safi
],
13542 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13544 p
->af_cap
[afi
][safi
],
13545 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13546 vty_out(vty
, " %s: TX ",
13554 PEER_CAP_ADDPATH_AF_TX_ADV
))
13561 PEER_CAP_ADDPATH_AF_TX_RCV
))
13568 PEER_CAP_ADDPATH_AF_TX_ADV
)
13572 vty_out(vty
, "\n");
13576 p
->af_cap
[afi
][safi
],
13577 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13579 p
->af_cap
[afi
][safi
],
13580 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13581 vty_out(vty
, " %s: RX ",
13589 PEER_CAP_ADDPATH_AF_RX_ADV
))
13596 PEER_CAP_ADDPATH_AF_RX_RCV
))
13603 PEER_CAP_ADDPATH_AF_RX_ADV
)
13607 vty_out(vty
, "\n");
13613 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13614 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13615 vty_out(vty
, " Dynamic:");
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13617 vty_out(vty
, " advertised");
13618 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13619 vty_out(vty
, " %sreceived",
13621 PEER_CAP_DYNAMIC_ADV
)
13624 vty_out(vty
, "\n");
13628 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13629 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13630 vty_out(vty
, " Role:");
13631 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13632 vty_out(vty
, " advertised");
13633 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13634 vty_out(vty
, " %sreceived",
13639 vty_out(vty
, "\n");
13642 /* Extended nexthop */
13643 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13644 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13645 vty_out(vty
, " Extended nexthop:");
13646 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13647 vty_out(vty
, " advertised");
13648 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13649 vty_out(vty
, " %sreceived",
13654 vty_out(vty
, "\n");
13656 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13658 " Address families by peer:\n ");
13659 for (safi
= SAFI_UNICAST
;
13660 safi
< SAFI_MAX
; safi
++)
13664 PEER_CAP_ENHE_AF_RCV
))
13674 /* Long-lived Graceful Restart */
13675 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13676 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13678 " Long-lived Graceful Restart:");
13679 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13680 vty_out(vty
, " advertised");
13681 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13682 vty_out(vty
, " %sreceived",
13687 vty_out(vty
, "\n");
13689 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13691 " Address families by peer:\n");
13692 FOREACH_AFI_SAFI (afi
, safi
)
13696 PEER_CAP_LLGR_AF_RCV
))
13706 /* Route Refresh */
13707 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13708 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13709 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13710 vty_out(vty
, " Route refresh:");
13711 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13712 vty_out(vty
, " advertised");
13713 if (CHECK_FLAG(p
->cap
,
13714 PEER_CAP_REFRESH_NEW_RCV
) ||
13716 PEER_CAP_REFRESH_OLD_RCV
))
13717 vty_out(vty
, " %sreceived(%s)",
13719 PEER_CAP_REFRESH_ADV
)
13724 PEER_CAP_REFRESH_OLD_RCV
) &&
13727 PEER_CAP_REFRESH_NEW_RCV
))
13731 PEER_CAP_REFRESH_OLD_RCV
)
13735 vty_out(vty
, "\n");
13738 /* Enhanced Route Refresh */
13739 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13740 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13741 vty_out(vty
, " Enhanced Route Refresh:");
13742 if (CHECK_FLAG(p
->cap
,
13743 PEER_CAP_ENHANCED_RR_ADV
))
13744 vty_out(vty
, " advertised");
13745 if (CHECK_FLAG(p
->cap
,
13746 PEER_CAP_ENHANCED_RR_RCV
))
13747 vty_out(vty
, " %sreceived",
13749 PEER_CAP_REFRESH_ADV
)
13752 vty_out(vty
, "\n");
13755 /* Multiprotocol Extensions */
13756 FOREACH_AFI_SAFI (afi
, safi
)
13757 if (p
->afc_adv
[afi
][safi
] ||
13758 p
->afc_recv
[afi
][safi
]) {
13759 vty_out(vty
, " Address Family %s:",
13760 get_afi_safi_str(afi
, safi
,
13762 if (p
->afc_adv
[afi
][safi
])
13763 vty_out(vty
, " advertised");
13764 if (p
->afc_recv
[afi
][safi
])
13765 vty_out(vty
, " %sreceived",
13766 p
->afc_adv
[afi
][safi
]
13769 vty_out(vty
, "\n");
13772 /* Hostname capability */
13773 vty_out(vty
, " Hostname Capability:");
13775 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13777 " advertised (name: %s,domain name: %s)",
13778 bgp
->peer_self
->hostname
13779 ? bgp
->peer_self
->hostname
13781 bgp
->peer_self
->domainname
13782 ? bgp
->peer_self
->domainname
13785 vty_out(vty
, " not advertised");
13788 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13790 " received (name: %s,domain name: %s)",
13791 p
->hostname
? p
->hostname
: "n/a",
13792 p
->domainname
? p
->domainname
: "n/a");
13794 vty_out(vty
, " not received");
13797 vty_out(vty
, "\n");
13799 /* Graceful Restart */
13800 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13801 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13803 " Graceful Restart Capability:");
13804 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13805 vty_out(vty
, " advertised");
13806 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13807 vty_out(vty
, " %sreceived",
13809 PEER_CAP_RESTART_ADV
)
13812 vty_out(vty
, "\n");
13814 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13815 int restart_af_count
= 0;
13818 " Remote Restart timer is %d seconds\n",
13821 " Address families by peer:\n ");
13823 FOREACH_AFI_SAFI (afi
, safi
)
13827 PEER_CAP_RESTART_AF_RCV
)) {
13828 vty_out(vty
, "%s%s(%s)",
13840 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13842 : "not preserved");
13843 restart_af_count
++;
13845 if (!restart_af_count
)
13846 vty_out(vty
, "none");
13847 vty_out(vty
, "\n");
13849 } /* Graceful Restart */
13853 /* graceful restart information */
13854 json_object
*json_grace
= NULL
;
13855 json_object
*json_grace_send
= NULL
;
13856 json_object
*json_grace_recv
= NULL
;
13857 int eor_send_af_count
= 0;
13858 int eor_receive_af_count
= 0;
13861 json_grace
= json_object_new_object();
13862 json_grace_send
= json_object_new_object();
13863 json_grace_recv
= json_object_new_object();
13865 if ((peer_established(p
)) &&
13866 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13867 FOREACH_AFI_SAFI (afi
, safi
) {
13868 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13869 PEER_STATUS_EOR_SEND
)) {
13870 json_object_boolean_true_add(
13872 get_afi_safi_str(afi
, safi
,
13874 eor_send_af_count
++;
13877 FOREACH_AFI_SAFI (afi
, safi
) {
13878 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13879 PEER_STATUS_EOR_RECEIVED
)) {
13880 json_object_boolean_true_add(
13882 get_afi_safi_str(afi
, safi
,
13884 eor_receive_af_count
++;
13888 json_object_object_add(json_grace
, "endOfRibSend",
13890 json_object_object_add(json_grace
, "endOfRibRecv",
13894 if (p
->t_gr_restart
)
13895 json_object_int_add(
13896 json_grace
, "gracefulRestartTimerMsecs",
13897 thread_timer_remain_second(p
->t_gr_restart
) *
13901 json_object_int_add(
13902 json_grace
, "gracefulStalepathTimerMsecs",
13903 thread_timer_remain_second(p
->t_gr_stale
) *
13905 /* more gr info in new format */
13906 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13907 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13910 vty_out(vty
, " Graceful restart information:\n");
13911 if ((peer_established(p
)) &&
13912 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13914 vty_out(vty
, " End-of-RIB send: ");
13915 FOREACH_AFI_SAFI (afi
, safi
) {
13916 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13917 PEER_STATUS_EOR_SEND
)) {
13918 vty_out(vty
, "%s%s",
13919 eor_send_af_count
? ", " : "",
13920 get_afi_safi_str(afi
, safi
,
13922 eor_send_af_count
++;
13925 vty_out(vty
, "\n");
13926 vty_out(vty
, " End-of-RIB received: ");
13927 FOREACH_AFI_SAFI (afi
, safi
) {
13928 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13929 PEER_STATUS_EOR_RECEIVED
)) {
13930 vty_out(vty
, "%s%s",
13931 eor_receive_af_count
? ", "
13933 get_afi_safi_str(afi
, safi
,
13935 eor_receive_af_count
++;
13938 vty_out(vty
, "\n");
13941 if (p
->t_gr_restart
)
13943 " The remaining time of restart timer is %ld\n",
13944 thread_timer_remain_second(p
->t_gr_restart
));
13948 " The remaining time of stalepath timer is %ld\n",
13949 thread_timer_remain_second(p
->t_gr_stale
));
13951 /* more gr info in new format */
13952 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13956 json_object
*json_stat
= NULL
;
13957 json_stat
= json_object_new_object();
13958 /* Packet counts. */
13960 atomic_size_t outq_count
, inq_count
;
13961 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13962 memory_order_relaxed
);
13963 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13964 memory_order_relaxed
);
13966 json_object_int_add(json_stat
, "depthInq",
13967 (unsigned long)inq_count
);
13968 json_object_int_add(json_stat
, "depthOutq",
13969 (unsigned long)outq_count
);
13970 json_object_int_add(json_stat
, "opensSent",
13971 atomic_load_explicit(&p
->open_out
,
13972 memory_order_relaxed
));
13973 json_object_int_add(json_stat
, "opensRecv",
13974 atomic_load_explicit(&p
->open_in
,
13975 memory_order_relaxed
));
13976 json_object_int_add(json_stat
, "notificationsSent",
13977 atomic_load_explicit(&p
->notify_out
,
13978 memory_order_relaxed
));
13979 json_object_int_add(json_stat
, "notificationsRecv",
13980 atomic_load_explicit(&p
->notify_in
,
13981 memory_order_relaxed
));
13982 json_object_int_add(json_stat
, "updatesSent",
13983 atomic_load_explicit(&p
->update_out
,
13984 memory_order_relaxed
));
13985 json_object_int_add(json_stat
, "updatesRecv",
13986 atomic_load_explicit(&p
->update_in
,
13987 memory_order_relaxed
));
13988 json_object_int_add(json_stat
, "keepalivesSent",
13989 atomic_load_explicit(&p
->keepalive_out
,
13990 memory_order_relaxed
));
13991 json_object_int_add(json_stat
, "keepalivesRecv",
13992 atomic_load_explicit(&p
->keepalive_in
,
13993 memory_order_relaxed
));
13994 json_object_int_add(json_stat
, "routeRefreshSent",
13995 atomic_load_explicit(&p
->refresh_out
,
13996 memory_order_relaxed
));
13997 json_object_int_add(json_stat
, "routeRefreshRecv",
13998 atomic_load_explicit(&p
->refresh_in
,
13999 memory_order_relaxed
));
14000 json_object_int_add(json_stat
, "capabilitySent",
14001 atomic_load_explicit(&p
->dynamic_cap_out
,
14002 memory_order_relaxed
));
14003 json_object_int_add(json_stat
, "capabilityRecv",
14004 atomic_load_explicit(&p
->dynamic_cap_in
,
14005 memory_order_relaxed
));
14006 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14007 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14008 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14010 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14011 notify_out
, notify_in
, update_out
, update_in
,
14012 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14013 dynamic_cap_out
, dynamic_cap_in
;
14014 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14015 memory_order_relaxed
);
14016 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14017 memory_order_relaxed
);
14018 open_out
= atomic_load_explicit(&p
->open_out
,
14019 memory_order_relaxed
);
14021 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14022 notify_out
= atomic_load_explicit(&p
->notify_out
,
14023 memory_order_relaxed
);
14024 notify_in
= atomic_load_explicit(&p
->notify_in
,
14025 memory_order_relaxed
);
14026 update_out
= atomic_load_explicit(&p
->update_out
,
14027 memory_order_relaxed
);
14028 update_in
= atomic_load_explicit(&p
->update_in
,
14029 memory_order_relaxed
);
14030 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14031 memory_order_relaxed
);
14032 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14033 memory_order_relaxed
);
14034 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14035 memory_order_relaxed
);
14036 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14037 memory_order_relaxed
);
14038 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14039 memory_order_relaxed
);
14040 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14041 memory_order_relaxed
);
14043 /* Packet counts. */
14044 vty_out(vty
, " Message statistics:\n");
14045 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14046 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14047 vty_out(vty
, " Sent Rcvd\n");
14048 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14050 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14052 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14054 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14056 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14058 vty_out(vty
, " Capability: %10zu %10zu\n",
14059 dynamic_cap_out
, dynamic_cap_in
);
14060 vty_out(vty
, " Total: %10u %10u\n",
14061 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14065 /* advertisement-interval */
14066 json_object_int_add(json_neigh
,
14067 "minBtwnAdvertisementRunsTimerMsecs",
14068 p
->v_routeadv
* 1000);
14070 /* Update-source. */
14071 if (p
->update_if
|| p
->update_source
) {
14073 json_object_string_add(json_neigh
,
14076 else if (p
->update_source
)
14077 json_object_string_addf(json_neigh
,
14078 "updateSource", "%pSU",
14082 /* advertisement-interval */
14084 " Minimum time between advertisement runs is %d seconds\n",
14087 /* Update-source. */
14088 if (p
->update_if
|| p
->update_source
) {
14089 vty_out(vty
, " Update source is ");
14091 vty_out(vty
, "%s", p
->update_if
);
14092 else if (p
->update_source
)
14093 vty_out(vty
, "%pSU", p
->update_source
);
14094 vty_out(vty
, "\n");
14097 vty_out(vty
, "\n");
14100 /* Address Family Information */
14101 json_object
*json_hold
= NULL
;
14104 json_hold
= json_object_new_object();
14106 FOREACH_AFI_SAFI (afi
, safi
)
14107 if (p
->afc
[afi
][safi
])
14108 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14112 json_object_object_add(json_neigh
, "addressFamilyInfo",
14114 json_object_int_add(json_neigh
, "connectionsEstablished",
14116 json_object_int_add(json_neigh
, "connectionsDropped",
14119 vty_out(vty
, " Connections established %d; dropped %d\n",
14120 p
->established
, p
->dropped
);
14122 if (!p
->last_reset
) {
14124 json_object_string_add(json_neigh
, "lastReset",
14127 vty_out(vty
, " Last reset never\n");
14133 uptime
= monotime(NULL
);
14134 uptime
-= p
->resettime
;
14135 gmtime_r(&uptime
, &tm
);
14137 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14139 + (tm
.tm_min
* 60000)
14140 + (tm
.tm_hour
* 3600000));
14141 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14143 vty_out(vty
, " Last reset %s, ",
14144 peer_uptime(p
->resettime
, timebuf
,
14145 BGP_UPTIME_LEN
, 0, NULL
));
14147 bgp_show_peer_reset(vty
, p
, NULL
, false);
14148 if (p
->last_reset_cause_size
) {
14149 msg
= p
->last_reset_cause
;
14151 " Message received that caused BGP to send a NOTIFICATION:\n ");
14152 for (i
= 1; i
<= p
->last_reset_cause_size
;
14154 vty_out(vty
, "%02X", *msg
++);
14156 if (i
!= p
->last_reset_cause_size
) {
14158 vty_out(vty
, "\n ");
14159 } else if (i
% 4 == 0) {
14164 vty_out(vty
, "\n");
14169 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14171 json_object_boolean_true_add(json_neigh
,
14172 "prefixesConfigExceedMax");
14175 " Peer had exceeded the max. no. of prefixes configured.\n");
14177 if (p
->t_pmax_restart
) {
14179 json_object_boolean_true_add(
14180 json_neigh
, "reducePrefixNumFrom");
14181 json_object_int_add(json_neigh
,
14182 "restartInTimerMsec",
14183 thread_timer_remain_second(
14188 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14189 p
->host
, thread_timer_remain_second(
14190 p
->t_pmax_restart
));
14193 json_object_boolean_true_add(
14195 "reducePrefixNumAndClearIpBgp");
14198 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14203 /* EBGP Multihop and GTSM */
14204 if (p
->sort
!= BGP_PEER_IBGP
) {
14206 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14207 json_object_int_add(json_neigh
,
14208 "externalBgpNbrMaxHopsAway",
14211 json_object_int_add(json_neigh
,
14212 "externalBgpNbrMaxHopsAway",
14215 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14217 " External BGP neighbor may be up to %d hops away.\n",
14221 " External BGP neighbor may be up to %d hops away.\n",
14226 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14227 json_object_int_add(json_neigh
,
14228 "internalBgpNbrMaxHopsAway",
14231 json_object_int_add(json_neigh
,
14232 "internalBgpNbrMaxHopsAway",
14235 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14237 " Internal BGP neighbor may be up to %d hops away.\n",
14241 " Internal BGP neighbor may be up to %d hops away.\n",
14246 /* Local address. */
14249 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14251 json_object_int_add(json_neigh
, "portLocal",
14252 ntohs(p
->su_local
->sin
.sin_port
));
14254 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14255 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14258 json_object_string_add(json_neigh
, "hostLocal",
14260 json_object_int_add(json_neigh
, "portLocal", -1);
14264 /* Remote address. */
14265 if (p
->su_remote
) {
14267 json_object_string_addf(json_neigh
, "hostForeign",
14268 "%pSU", p
->su_remote
);
14269 json_object_int_add(json_neigh
, "portForeign",
14270 ntohs(p
->su_remote
->sin
.sin_port
));
14272 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14274 ntohs(p
->su_remote
->sin
.sin_port
));
14277 json_object_string_add(json_neigh
, "hostForeign",
14279 json_object_int_add(json_neigh
, "portForeign", -1);
14283 /* Nexthop display. */
14286 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14288 json_object_string_addf(json_neigh
, "nexthopGlobal",
14289 "%pI6", &p
->nexthop
.v6_global
);
14290 json_object_string_addf(json_neigh
, "nexthopLocal",
14291 "%pI6", &p
->nexthop
.v6_local
);
14292 if (p
->shared_network
)
14293 json_object_string_add(json_neigh
,
14297 json_object_string_add(json_neigh
,
14299 "nonSharedNetwork");
14301 vty_out(vty
, "Nexthop: %s\n",
14302 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14304 vty_out(vty
, "Nexthop global: %s\n",
14305 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14307 vty_out(vty
, "Nexthop local: %s\n",
14308 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14310 vty_out(vty
, "BGP connection: %s\n",
14311 p
->shared_network
? "shared network"
14312 : "non shared network");
14316 /* Timer information. */
14318 json_object_int_add(json_neigh
, "connectRetryTimer",
14320 if (peer_established(p
) && p
->rtt
)
14321 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14324 json_object_int_add(
14325 json_neigh
, "nextStartTimerDueInMsecs",
14326 thread_timer_remain_second(p
->t_start
) * 1000);
14328 json_object_int_add(
14329 json_neigh
, "nextConnectTimerDueInMsecs",
14330 thread_timer_remain_second(p
->t_connect
)
14332 if (p
->t_routeadv
) {
14333 json_object_int_add(json_neigh
, "mraiInterval",
14335 json_object_int_add(
14336 json_neigh
, "mraiTimerExpireInMsecs",
14337 thread_timer_remain_second(p
->t_routeadv
)
14341 json_object_int_add(json_neigh
, "authenticationEnabled",
14345 json_object_string_add(json_neigh
, "readThread", "on");
14347 json_object_string_add(json_neigh
, "readThread", "off");
14349 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14350 json_object_string_add(json_neigh
, "writeThread", "on");
14352 json_object_string_add(json_neigh
, "writeThread",
14355 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14357 if (peer_established(p
) && p
->rtt
)
14358 vty_out(vty
, "Estimated round trip time: %d ms\n",
14361 vty_out(vty
, "Next start timer due in %ld seconds\n",
14362 thread_timer_remain_second(p
->t_start
));
14364 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14365 thread_timer_remain_second(p
->t_connect
));
14368 "MRAI (interval %u) timer expires in %ld seconds\n",
14370 thread_timer_remain_second(p
->t_routeadv
));
14372 vty_out(vty
, "Peer Authentication Enabled\n");
14374 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14375 p
->t_read
? "on" : "off",
14376 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14381 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14382 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14383 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14386 vty_out(vty
, "\n");
14388 /* BFD information. */
14390 bgp_bfd_show_info(vty
, p
, json_neigh
);
14393 if (p
->conf_if
) /* Configured interface name. */
14394 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14395 else /* Configured IP address. */
14396 json_object_object_add(json
, p
->host
, json_neigh
);
14400 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14401 enum show_type type
,
14402 union sockunion
*su
,
14403 const char *conf_if
, afi_t afi
,
14406 struct listnode
*node
, *nnode
;
14409 safi_t safi
= SAFI_UNICAST
;
14410 json_object
*json
= NULL
;
14411 json_object
*json_neighbor
= NULL
;
14414 json
= json_object_new_object();
14415 json_neighbor
= json_object_new_object();
14418 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14420 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14423 if ((peer
->afc
[afi
][safi
]) == 0)
14426 if (type
== show_all
) {
14427 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14431 json_object_object_add(json
, peer
->host
,
14433 json_neighbor
= NULL
;
14436 } else if (type
== show_peer
) {
14439 && !strcmp(peer
->conf_if
, conf_if
))
14441 && !strcmp(peer
->hostname
, conf_if
))) {
14443 bgp_show_peer_gr_status(vty
, peer
,
14448 if (sockunion_same(&peer
->su
, su
)) {
14450 bgp_show_peer_gr_status(vty
, peer
,
14455 if (use_json
&& find
)
14456 json_object_object_add(json
, peer
->host
,
14461 json_neighbor
= NULL
;
14466 if (type
== show_peer
&& !find
) {
14468 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14470 vty_out(vty
, "%% No such neighbor\n");
14474 json_object_free(json_neighbor
);
14475 vty_json(vty
, json
);
14477 vty_out(vty
, "\n");
14480 return CMD_SUCCESS
;
14483 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14484 enum show_type type
, union sockunion
*su
,
14485 const char *conf_if
, bool use_json
,
14488 struct listnode
*node
, *nnode
;
14491 bool nbr_output
= false;
14492 afi_t afi
= AFI_MAX
;
14493 safi_t safi
= SAFI_MAX
;
14495 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14497 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14501 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14502 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14507 bgp_show_peer(vty
, peer
, use_json
, json
);
14513 && !strcmp(peer
->conf_if
, conf_if
))
14515 && !strcmp(peer
->hostname
, conf_if
))) {
14517 bgp_show_peer(vty
, peer
, use_json
,
14521 if (sockunion_same(&peer
->su
, su
)) {
14523 bgp_show_peer(vty
, peer
, use_json
,
14528 case show_ipv4_peer
:
14529 case show_ipv6_peer
:
14530 FOREACH_SAFI (safi
) {
14531 if (peer
->afc
[afi
][safi
]) {
14534 && !strcmp(peer
->conf_if
, conf_if
))
14536 && !strcmp(peer
->hostname
, conf_if
))) {
14538 bgp_show_peer(vty
, peer
, use_json
,
14543 if (sockunion_same(&peer
->su
, su
)) {
14545 bgp_show_peer(vty
, peer
, use_json
,
14553 case show_ipv4_all
:
14554 case show_ipv6_all
:
14555 FOREACH_SAFI (safi
) {
14556 if (peer
->afc
[afi
][safi
]) {
14557 bgp_show_peer(vty
, peer
, use_json
, json
);
14566 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14567 type
== show_ipv6_peer
) && !find
) {
14569 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14571 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14574 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14575 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14576 vty_out(vty
, "%% No BGP neighbors found\n");
14579 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14580 json
, JSON_C_TO_STRING_PRETTY
));
14582 vty_out(vty
, "\n");
14585 return CMD_SUCCESS
;
14588 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14589 enum show_type type
,
14590 const char *ip_str
,
14591 afi_t afi
, bool use_json
)
14596 union sockunion su
;
14598 bgp
= bgp_get_default();
14604 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14608 ret
= str2sockunion(ip_str
, &su
);
14610 bgp_show_neighbor_graceful_restart(
14611 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14613 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14614 NULL
, afi
, use_json
);
14616 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14620 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14621 enum show_type type
,
14622 const char *ip_str
,
14625 struct listnode
*node
, *nnode
;
14627 union sockunion su
;
14628 json_object
*json
= NULL
;
14629 int ret
, is_first
= 1;
14630 bool nbr_output
= false;
14633 vty_out(vty
, "{\n");
14635 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14638 if (!(json
= json_object_new_object())) {
14640 EC_BGP_JSON_MEM_ERROR
,
14641 "Unable to allocate memory for JSON object");
14643 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14647 json_object_int_add(json
, "vrfId",
14648 (bgp
->vrf_id
== VRF_UNKNOWN
)
14650 : (int64_t)bgp
->vrf_id
);
14651 json_object_string_add(
14653 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14658 vty_out(vty
, ",\n");
14662 vty_out(vty
, "\"%s\":",
14663 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14667 vty_out(vty
, "\nInstance %s:\n",
14668 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14673 if (type
== show_peer
|| type
== show_ipv4_peer
||
14674 type
== show_ipv6_peer
) {
14675 ret
= str2sockunion(ip_str
, &su
);
14677 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14680 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14683 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14686 json_object_free(json
);
14691 vty_out(vty
, "}\n");
14692 else if (!nbr_output
)
14693 vty_out(vty
, "%% BGP instance not found\n");
14696 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14697 enum show_type type
, const char *ip_str
,
14702 union sockunion su
;
14703 json_object
*json
= NULL
;
14706 if (strmatch(name
, "all")) {
14707 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14709 return CMD_SUCCESS
;
14711 bgp
= bgp_lookup_by_name(name
);
14714 json
= json_object_new_object();
14715 vty_json(vty
, json
);
14718 "%% BGP instance not found\n");
14720 return CMD_WARNING
;
14724 bgp
= bgp_get_default();
14728 json
= json_object_new_object();
14730 ret
= str2sockunion(ip_str
, &su
);
14732 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14735 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14738 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14741 json_object_free(json
);
14744 vty_out(vty
, "{}\n");
14746 vty_out(vty
, "%% BGP instance not found\n");
14749 return CMD_SUCCESS
;
14754 /* "show [ip] bgp neighbors graceful-restart" commands. */
14755 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14756 show_ip_bgp_neighbors_graceful_restart_cmd
,
14757 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14763 "Neighbor to display information about\n"
14764 "Neighbor to display information about\n"
14765 "Neighbor on BGP configured interface\n"
14769 char *sh_arg
= NULL
;
14770 enum show_type sh_type
;
14772 afi_t afi
= AFI_MAX
;
14773 bool uj
= use_json(argc
, argv
);
14775 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14780 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14781 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14782 || argv_find(argv
, argc
, "WORD", &idx
)) {
14783 sh_type
= show_peer
;
14784 sh_arg
= argv
[idx
]->arg
;
14786 sh_type
= show_all
;
14788 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14789 return CMD_SUCCESS
;
14792 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14796 /* "show [ip] bgp neighbors" commands. */
14797 DEFUN (show_ip_bgp_neighbors
,
14798 show_ip_bgp_neighbors_cmd
,
14799 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14803 BGP_INSTANCE_HELP_STR
14806 "Detailed information on TCP and BGP neighbor connections\n"
14807 "Neighbor to display information about\n"
14808 "Neighbor to display information about\n"
14809 "Neighbor on BGP configured interface\n"
14813 char *sh_arg
= NULL
;
14814 enum show_type sh_type
;
14815 afi_t afi
= AFI_MAX
;
14817 bool uj
= use_json(argc
, argv
);
14821 /* [<vrf> VIEWVRFNAME] */
14822 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14823 vrf
= argv
[idx
+ 1]->arg
;
14824 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14826 } else if (argv_find(argv
, argc
, "view", &idx
))
14827 /* [<view> VIEWVRFNAME] */
14828 vrf
= argv
[idx
+ 1]->arg
;
14832 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14833 sh_type
= show_ipv4_all
;
14835 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14836 sh_type
= show_ipv6_all
;
14839 sh_type
= show_all
;
14842 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14843 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14844 || argv_find(argv
, argc
, "WORD", &idx
)) {
14845 sh_type
= show_peer
;
14846 sh_arg
= argv
[idx
]->arg
;
14849 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14850 sh_type
= show_ipv4_peer
;
14851 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14852 sh_type
= show_ipv6_peer
;
14855 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14858 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14859 paths' and `show ip mbgp paths'. Those functions results are the
14861 DEFUN (show_ip_bgp_paths
,
14862 show_ip_bgp_paths_cmd
,
14863 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14868 "Path information\n")
14870 vty_out(vty
, "Address Refcnt Path\n");
14871 aspath_print_all_vty(vty
);
14872 return CMD_SUCCESS
;
14877 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14880 struct community
*com
;
14882 com
= (struct community
*)bucket
->data
;
14883 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14884 community_str(com
, false, false));
14887 /* Show BGP's community internal data. */
14888 DEFUN (show_ip_bgp_community_info
,
14889 show_ip_bgp_community_info_cmd
,
14890 "show [ip] bgp community-info",
14894 "List all bgp community information\n")
14896 vty_out(vty
, "Address Refcnt Community\n");
14898 hash_iterate(community_hash(),
14899 (void (*)(struct hash_bucket
*,
14900 void *))community_show_all_iterator
,
14903 return CMD_SUCCESS
;
14906 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14909 struct lcommunity
*lcom
;
14911 lcom
= (struct lcommunity
*)bucket
->data
;
14912 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14913 lcommunity_str(lcom
, false, false));
14916 /* Show BGP's community internal data. */
14917 DEFUN (show_ip_bgp_lcommunity_info
,
14918 show_ip_bgp_lcommunity_info_cmd
,
14919 "show ip bgp large-community-info",
14923 "List all bgp large-community information\n")
14925 vty_out(vty
, "Address Refcnt Large-community\n");
14927 hash_iterate(lcommunity_hash(),
14928 (void (*)(struct hash_bucket
*,
14929 void *))lcommunity_show_all_iterator
,
14932 return CMD_SUCCESS
;
14934 /* Graceful Restart */
14936 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14943 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14945 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14947 switch (bgp_global_gr_mode
) {
14949 case GLOBAL_HELPER
:
14950 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14954 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14957 case GLOBAL_DISABLE
:
14958 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14961 case GLOBAL_INVALID
:
14963 "Global BGP GR Mode Invalid\n");
14966 vty_out(vty
, "\n");
14969 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14970 enum show_type type
,
14971 const char *ip_str
,
14972 afi_t afi
, bool use_json
)
14974 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14977 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14979 bgp_show_neighbor_graceful_restart_vty(
14980 vty
, type
, ip_str
, afi
, use_json
);
14983 } else if (afi
!= AFI_MAX
) {
14984 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14987 return CMD_ERR_INCOMPLETE
;
14990 return CMD_SUCCESS
;
14992 /* Graceful Restart */
14994 DEFUN (show_ip_bgp_attr_info
,
14995 show_ip_bgp_attr_info_cmd
,
14996 "show [ip] bgp attribute-info",
15000 "List all bgp attribute information\n")
15002 attr_show_all(vty
);
15003 return CMD_SUCCESS
;
15006 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15007 afi_t afi
, safi_t safi
,
15008 bool use_json
, json_object
*json
)
15011 struct listnode
*node
;
15014 enum vpn_policy_direction dir
;
15017 json_object
*json_import_vrfs
= NULL
;
15018 json_object
*json_export_vrfs
= NULL
;
15020 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15023 vty_json(vty
, json
);
15025 return CMD_WARNING
;
15028 /* Provide context for the block */
15029 json_object_string_add(json
, "vrf", name
? name
: "default");
15030 json_object_string_add(json
, "afiSafi",
15031 get_afi_safi_str(afi
, safi
, true));
15033 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15034 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15035 json_object_string_add(json
, "importFromVrfs", "none");
15036 json_object_string_add(json
, "importRts", "none");
15038 json_import_vrfs
= json_object_new_array();
15040 for (ALL_LIST_ELEMENTS_RO(
15041 bgp
->vpn_policy
[afi
].import_vrf
,
15043 json_object_array_add(json_import_vrfs
,
15044 json_object_new_string(vname
));
15046 json_object_object_add(json
, "importFromVrfs",
15048 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15049 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15050 ecom_str
= ecommunity_ecom2str(
15051 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15052 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15053 json_object_string_add(json
, "importRts",
15055 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15057 json_object_string_add(json
, "importRts",
15061 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15062 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15063 json_object_string_add(json
, "exportToVrfs", "none");
15064 json_object_string_add(json
, "routeDistinguisher",
15066 json_object_string_add(json
, "exportRts", "none");
15068 json_export_vrfs
= json_object_new_array();
15070 for (ALL_LIST_ELEMENTS_RO(
15071 bgp
->vpn_policy
[afi
].export_vrf
,
15073 json_object_array_add(json_export_vrfs
,
15074 json_object_new_string(vname
));
15075 json_object_object_add(json
, "exportToVrfs",
15077 json_object_string_addf(json
, "routeDistinguisher",
15079 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15081 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15082 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15083 ecom_str
= ecommunity_ecom2str(
15084 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15085 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15086 json_object_string_add(json
, "exportRts",
15088 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15090 json_object_string_add(json
, "exportRts",
15095 vty_json(vty
, json
);
15098 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15101 vty_out(vty
, "%% No such BGP instance exist\n");
15102 return CMD_WARNING
;
15105 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15106 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15108 "This VRF is not importing %s routes from any other VRF\n",
15109 get_afi_safi_str(afi
, safi
, false));
15112 "This VRF is importing %s routes from the following VRFs:\n",
15113 get_afi_safi_str(afi
, safi
, false));
15115 for (ALL_LIST_ELEMENTS_RO(
15116 bgp
->vpn_policy
[afi
].import_vrf
,
15118 vty_out(vty
, " %s\n", vname
);
15120 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15122 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15123 ecom_str
= ecommunity_ecom2str(
15124 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15125 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15126 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15128 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15130 vty_out(vty
, "Import RT(s):\n");
15133 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15134 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15136 "This VRF is not exporting %s routes to any other VRF\n",
15137 get_afi_safi_str(afi
, safi
, false));
15140 "This VRF is exporting %s routes to the following VRFs:\n",
15141 get_afi_safi_str(afi
, safi
, false));
15143 for (ALL_LIST_ELEMENTS_RO(
15144 bgp
->vpn_policy
[afi
].export_vrf
,
15146 vty_out(vty
, " %s\n", vname
);
15148 vty_out(vty
, "RD: %pRD\n",
15149 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15151 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15152 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15153 ecom_str
= ecommunity_ecom2str(
15154 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15155 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15156 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15157 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15159 vty_out(vty
, "Import RT(s):\n");
15163 return CMD_SUCCESS
;
15166 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15167 safi_t safi
, bool use_json
)
15169 struct listnode
*node
, *nnode
;
15171 char *vrf_name
= NULL
;
15172 json_object
*json
= NULL
;
15173 json_object
*json_vrf
= NULL
;
15174 json_object
*json_vrfs
= NULL
;
15177 json
= json_object_new_object();
15178 json_vrfs
= json_object_new_object();
15181 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15183 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15184 vrf_name
= bgp
->name
;
15187 json_vrf
= json_object_new_object();
15189 vty_out(vty
, "\nInstance %s:\n",
15190 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15191 ? VRF_DEFAULT_NAME
: bgp
->name
);
15193 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15195 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15196 json_object_object_add(json_vrfs
,
15197 VRF_DEFAULT_NAME
, json_vrf
);
15199 json_object_object_add(json_vrfs
, vrf_name
,
15205 json_object_object_add(json
, "vrfs", json_vrfs
);
15206 vty_json(vty
, json
);
15209 return CMD_SUCCESS
;
15212 /* "show [ip] bgp route-leak" command. */
15213 DEFUN (show_ip_bgp_route_leak
,
15214 show_ip_bgp_route_leak_cmd
,
15215 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15219 BGP_INSTANCE_HELP_STR
15222 "Route leaking information\n"
15226 afi_t afi
= AFI_MAX
;
15227 safi_t safi
= SAFI_MAX
;
15229 bool uj
= use_json(argc
, argv
);
15231 json_object
*json
= NULL
;
15233 /* show [ip] bgp */
15234 if (argv_find(argv
, argc
, "ip", &idx
)) {
15236 safi
= SAFI_UNICAST
;
15238 /* [vrf VIEWVRFNAME] */
15239 if (argv_find(argv
, argc
, "view", &idx
)) {
15241 "%% This command is not applicable to BGP views\n");
15242 return CMD_WARNING
;
15245 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15246 vrf
= argv
[idx
+ 1]->arg
;
15247 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15250 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15251 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15252 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15254 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15256 "%% This command is applicable only for unicast ipv4|ipv6\n");
15257 return CMD_WARNING
;
15260 if (vrf
&& strmatch(vrf
, "all"))
15261 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15264 json
= json_object_new_object();
15266 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15269 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15272 struct listnode
*node
, *nnode
;
15275 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15276 vty_out(vty
, "\nInstance %s:\n",
15277 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15280 update_group_show(bgp
, afi
, safi
, vty
, 0);
15284 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15285 int safi
, uint64_t subgrp_id
)
15290 if (strmatch(name
, "all")) {
15291 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15292 return CMD_SUCCESS
;
15294 bgp
= bgp_lookup_by_name(name
);
15297 bgp
= bgp_get_default();
15301 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15302 return CMD_SUCCESS
;
15305 DEFUN (show_ip_bgp_updgrps
,
15306 show_ip_bgp_updgrps_cmd
,
15307 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15311 BGP_INSTANCE_HELP_STR
15313 BGP_SAFI_WITH_LABEL_HELP_STR
15314 "Detailed info about dynamic update groups\n"
15315 "Specific subgroup to display detailed info for\n")
15318 afi_t afi
= AFI_IP6
;
15319 safi_t safi
= SAFI_UNICAST
;
15320 uint64_t subgrp_id
= 0;
15324 /* show [ip] bgp */
15325 if (argv_find(argv
, argc
, "ip", &idx
))
15327 /* [<vrf> VIEWVRFNAME] */
15328 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15329 vrf
= argv
[idx
+ 1]->arg
;
15330 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15332 } else if (argv_find(argv
, argc
, "view", &idx
))
15333 /* [<view> VIEWVRFNAME] */
15334 vrf
= argv
[idx
+ 1]->arg
;
15335 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15336 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15337 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15340 /* get subgroup id, if provided */
15342 if (argv
[idx
]->type
== VARIABLE_TKN
)
15343 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15345 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15348 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15349 show_bgp_instance_all_ipv6_updgrps_cmd
,
15350 "show [ip] bgp <view|vrf> all update-groups",
15354 BGP_INSTANCE_ALL_HELP_STR
15355 "Detailed info about dynamic update groups\n")
15357 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15358 return CMD_SUCCESS
;
15361 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15362 show_bgp_l2vpn_evpn_updgrps_cmd
,
15363 "show [ip] bgp l2vpn evpn update-groups",
15367 "l2vpn address family\n"
15368 "evpn sub-address family\n"
15369 "Detailed info about dynamic update groups\n")
15372 uint64_t subgrp_id
= 0;
15374 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15375 return CMD_SUCCESS
;
15378 DEFUN (show_bgp_updgrps_stats
,
15379 show_bgp_updgrps_stats_cmd
,
15380 "show [ip] bgp update-groups statistics",
15384 "Detailed info about dynamic update groups\n"
15389 bgp
= bgp_get_default();
15391 update_group_show_stats(bgp
, vty
);
15393 return CMD_SUCCESS
;
15396 DEFUN (show_bgp_instance_updgrps_stats
,
15397 show_bgp_instance_updgrps_stats_cmd
,
15398 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15402 BGP_INSTANCE_HELP_STR
15403 "Detailed info about dynamic update groups\n"
15409 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15411 update_group_show_stats(bgp
, vty
);
15413 return CMD_SUCCESS
;
15416 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15417 afi_t afi
, safi_t safi
,
15418 const char *what
, uint64_t subgrp_id
)
15423 bgp
= bgp_lookup_by_name(name
);
15425 bgp
= bgp_get_default();
15428 if (!strcmp(what
, "advertise-queue"))
15429 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15431 else if (!strcmp(what
, "advertised-routes"))
15432 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15434 else if (!strcmp(what
, "packet-queue"))
15435 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15440 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15441 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15442 "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",
15443 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15445 "Detailed info about dynamic update groups\n"
15446 "Specific subgroup to display info for\n"
15447 "Advertisement queue\n"
15448 "Announced routes\n"
15451 uint64_t subgrp_id
= 0;
15455 subgrp_id
= strtoull(sgid
, NULL
, 10);
15460 afiz
= bgp_vty_afi_from_str(afi
);
15464 afiz
= bgp_vty_afi_from_str(afi
);
15465 if (afiz
!= AFI_IP
)
15467 "%% Cannot specify both 'ip' and 'ipv6'\n");
15468 return CMD_WARNING
;
15471 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15473 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15474 return CMD_SUCCESS
;
15477 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15480 struct listnode
*node
, *nnode
;
15481 struct prefix
*range
;
15486 const char *peer_status
;
15490 json_object
*json_peer_group
= NULL
;
15491 json_object
*json_peer_group_afc
= NULL
;
15492 json_object
*json_peer_group_members
= NULL
;
15493 json_object
*json_peer_group_dynamic
= NULL
;
15494 json_object
*json_peer_group_dynamic_af
= NULL
;
15495 json_object
*json_peer_group_ranges
= NULL
;
15497 conf
= group
->conf
;
15500 json_peer_group
= json_object_new_object();
15501 json_peer_group_afc
= json_object_new_array();
15504 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15506 json_object_int_add(json_peer_group
, "remoteAs",
15509 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15510 group
->name
, conf
->as
);
15511 } else if (conf
->as_type
== AS_INTERNAL
) {
15513 json_object_int_add(json_peer_group
, "remoteAs",
15516 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15517 group
->name
, group
->bgp
->as
);
15520 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15523 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15525 json_object_string_add(json_peer_group
, "type",
15528 vty_out(vty
, " Peer-group type is internal\n");
15531 json_object_string_add(json_peer_group
, "type",
15534 vty_out(vty
, " Peer-group type is external\n");
15537 /* Display AFs configured. */
15539 vty_out(vty
, " Configured address-families:");
15541 FOREACH_AFI_SAFI (afi
, safi
) {
15542 if (conf
->afc
[afi
][safi
]) {
15545 json_object_array_add(
15546 json_peer_group_afc
,
15547 json_object_new_string(get_afi_safi_str(
15548 afi
, safi
, false)));
15550 vty_out(vty
, " %s;",
15551 get_afi_safi_str(afi
, safi
, false));
15556 json_object_object_add(json_peer_group
,
15557 "addressFamiliesConfigured",
15558 json_peer_group_afc
);
15561 vty_out(vty
, " none\n");
15563 vty_out(vty
, "\n");
15566 /* Display listen ranges (for dynamic neighbors), if any */
15567 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15568 lr_count
= listcount(group
->listen_range
[afi
]);
15571 if (!json_peer_group_dynamic
)
15572 json_peer_group_dynamic
=
15573 json_object_new_object();
15575 json_peer_group_dynamic_af
=
15576 json_object_new_object();
15577 json_peer_group_ranges
=
15578 json_object_new_array();
15579 json_object_int_add(json_peer_group_dynamic_af
,
15580 "count", lr_count
);
15582 vty_out(vty
, " %d %s listen range(s)\n",
15583 lr_count
, afi2str(afi
));
15586 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15591 snprintfrr(buf
, sizeof(buf
), "%pFX",
15594 json_object_array_add(
15595 json_peer_group_ranges
,
15596 json_object_new_string(buf
));
15598 vty_out(vty
, " %pFX\n", range
);
15603 json_object_object_add(
15604 json_peer_group_dynamic_af
, "ranges",
15605 json_peer_group_ranges
);
15607 json_object_object_add(
15608 json_peer_group_dynamic
, afi2str(afi
),
15609 json_peer_group_dynamic_af
);
15614 if (json_peer_group_dynamic
)
15615 json_object_object_add(json_peer_group
, "dynamicRanges",
15616 json_peer_group_dynamic
);
15618 /* Display group members and their status */
15619 if (listcount(group
->peer
)) {
15621 json_peer_group_members
= json_object_new_object();
15623 vty_out(vty
, " Peer-group members:\n");
15624 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15625 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15626 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15627 peer_status
= "Idle (Admin)";
15628 else if (CHECK_FLAG(peer
->sflags
,
15629 PEER_STATUS_PREFIX_OVERFLOW
))
15630 peer_status
= "Idle (PfxCt)";
15632 peer_status
= lookup_msg(bgp_status_msg
,
15633 peer
->status
, NULL
);
15635 dynamic
= peer_dynamic_neighbor(peer
);
15638 json_object
*json_peer_group_member
=
15639 json_object_new_object();
15641 json_object_string_add(json_peer_group_member
,
15642 "status", peer_status
);
15645 json_object_boolean_true_add(
15646 json_peer_group_member
,
15649 json_object_object_add(json_peer_group_members
,
15651 json_peer_group_member
);
15653 vty_out(vty
, " %s %s %s \n", peer
->host
,
15654 dynamic
? "(dynamic)" : "",
15659 json_object_object_add(json_peer_group
, "members",
15660 json_peer_group_members
);
15664 json_object_object_add(json
, group
->name
, json_peer_group
);
15666 return CMD_SUCCESS
;
15669 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15670 const char *group_name
, bool uj
)
15673 struct listnode
*node
, *nnode
;
15674 struct peer_group
*group
;
15675 bool found
= false;
15676 json_object
*json
= NULL
;
15679 json
= json_object_new_object();
15681 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15685 vty_json(vty
, json
);
15687 vty_out(vty
, "%% BGP instance not found\n");
15689 return CMD_WARNING
;
15692 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15694 if (strmatch(group
->name
, group_name
)) {
15695 bgp_show_one_peer_group(vty
, group
, json
);
15700 bgp_show_one_peer_group(vty
, group
, json
);
15704 if (group_name
&& !found
&& !uj
)
15705 vty_out(vty
, "%% No such peer-group\n");
15708 vty_json(vty
, json
);
15710 return CMD_SUCCESS
;
15713 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15714 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15715 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15716 "Detailed information on BGP peer groups\n"
15717 "Peer group name\n" JSON_STR
)
15721 bool uj
= use_json(argc
, argv
);
15723 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15725 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15727 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15731 /* Redistribute VTY commands. */
15733 DEFUN (bgp_redistribute_ipv4
,
15734 bgp_redistribute_ipv4_cmd
,
15735 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15736 "Redistribute information from another routing protocol\n"
15737 FRR_IP_REDIST_HELP_STR_BGPD
)
15739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15740 int idx_protocol
= 1;
15743 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15745 vty_out(vty
, "%% Invalid route type\n");
15746 return CMD_WARNING_CONFIG_FAILED
;
15749 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15750 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15754 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15755 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15756 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15758 DEFUN (bgp_redistribute_ipv4_rmap
,
15759 bgp_redistribute_ipv4_rmap_cmd
,
15760 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15761 "Redistribute information from another routing protocol\n"
15762 FRR_IP_REDIST_HELP_STR_BGPD
15763 "Route map reference\n"
15764 "Pointer to route-map entries\n")
15766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15767 int idx_protocol
= 1;
15770 struct bgp_redist
*red
;
15772 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15773 vty
, argv
[idx_word
]->arg
);
15775 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15777 vty_out(vty
, "%% Invalid route type\n");
15778 return CMD_WARNING_CONFIG_FAILED
;
15781 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15783 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15784 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15788 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15789 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15790 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15791 "Route map reference\n"
15792 "Pointer to route-map entries\n")
15794 DEFUN (bgp_redistribute_ipv4_metric
,
15795 bgp_redistribute_ipv4_metric_cmd
,
15796 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15797 "Redistribute information from another routing protocol\n"
15798 FRR_IP_REDIST_HELP_STR_BGPD
15799 "Metric for redistributed routes\n"
15800 "Default metric\n")
15802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15803 int idx_protocol
= 1;
15804 int idx_number
= 3;
15807 struct bgp_redist
*red
;
15810 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15812 vty_out(vty
, "%% Invalid route type\n");
15813 return CMD_WARNING_CONFIG_FAILED
;
15815 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15817 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15818 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15819 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15823 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15824 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15825 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15826 "Metric for redistributed routes\n"
15827 "Default metric\n")
15829 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15830 bgp_redistribute_ipv4_rmap_metric_cmd
,
15831 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15832 "Redistribute information from another routing protocol\n"
15833 FRR_IP_REDIST_HELP_STR_BGPD
15834 "Route map reference\n"
15835 "Pointer to route-map entries\n"
15836 "Metric for redistributed routes\n"
15837 "Default metric\n")
15839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15840 int idx_protocol
= 1;
15842 int idx_number
= 5;
15845 struct bgp_redist
*red
;
15847 struct route_map
*route_map
=
15848 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15850 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15852 vty_out(vty
, "%% Invalid route type\n");
15853 return CMD_WARNING_CONFIG_FAILED
;
15855 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15857 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15859 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15860 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15861 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15865 bgp_redistribute_ipv4_rmap_metric
,
15866 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15867 "redistribute " FRR_IP_REDIST_STR_BGPD
15868 " route-map RMAP_NAME metric (0-4294967295)",
15869 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15870 "Route map reference\n"
15871 "Pointer to route-map entries\n"
15872 "Metric for redistributed routes\n"
15873 "Default metric\n")
15875 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15876 bgp_redistribute_ipv4_metric_rmap_cmd
,
15877 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15878 "Redistribute information from another routing protocol\n"
15879 FRR_IP_REDIST_HELP_STR_BGPD
15880 "Metric for redistributed routes\n"
15882 "Route map reference\n"
15883 "Pointer to route-map entries\n")
15885 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15886 int idx_protocol
= 1;
15887 int idx_number
= 3;
15891 struct bgp_redist
*red
;
15893 struct route_map
*route_map
=
15894 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15896 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15898 vty_out(vty
, "%% Invalid route type\n");
15899 return CMD_WARNING_CONFIG_FAILED
;
15901 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15903 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15904 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15906 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15907 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15911 bgp_redistribute_ipv4_metric_rmap
,
15912 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15913 "redistribute " FRR_IP_REDIST_STR_BGPD
15914 " metric (0-4294967295) route-map RMAP_NAME",
15915 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15916 "Metric for redistributed routes\n"
15918 "Route map reference\n"
15919 "Pointer to route-map entries\n")
15921 DEFUN (bgp_redistribute_ipv4_ospf
,
15922 bgp_redistribute_ipv4_ospf_cmd
,
15923 "redistribute <ospf|table> (1-65535)",
15924 "Redistribute information from another routing protocol\n"
15925 "Open Shortest Path First (OSPFv2)\n"
15926 "Non-main Kernel Routing Table\n"
15927 "Instance ID/Table ID\n")
15929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15930 int idx_ospf_table
= 1;
15931 int idx_number
= 2;
15932 unsigned short instance
;
15933 unsigned short protocol
;
15935 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15937 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15938 protocol
= ZEBRA_ROUTE_OSPF
;
15940 protocol
= ZEBRA_ROUTE_TABLE
;
15942 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15943 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15946 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15947 "redistribute <ospf|table> (1-65535)",
15948 "Redistribute information from another routing protocol\n"
15949 "Open Shortest Path First (OSPFv2)\n"
15950 "Non-main Kernel Routing Table\n"
15951 "Instance ID/Table ID\n")
15953 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15954 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15955 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15956 "Redistribute information from another routing protocol\n"
15957 "Open Shortest Path First (OSPFv2)\n"
15958 "Non-main Kernel Routing Table\n"
15959 "Instance ID/Table ID\n"
15960 "Route map reference\n"
15961 "Pointer to route-map entries\n")
15963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15964 int idx_ospf_table
= 1;
15965 int idx_number
= 2;
15967 struct bgp_redist
*red
;
15968 unsigned short instance
;
15971 struct route_map
*route_map
=
15972 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15974 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15975 protocol
= ZEBRA_ROUTE_OSPF
;
15977 protocol
= ZEBRA_ROUTE_TABLE
;
15979 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15980 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15982 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15983 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15986 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15987 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15988 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
15989 "Redistribute information from another routing protocol\n"
15990 "Open Shortest Path First (OSPFv2)\n"
15991 "Non-main Kernel Routing Table\n"
15992 "Instance ID/Table ID\n"
15993 "Route map reference\n"
15994 "Pointer to route-map entries\n")
15996 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15997 bgp_redistribute_ipv4_ospf_metric_cmd
,
15998 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15999 "Redistribute information from another routing protocol\n"
16000 "Open Shortest Path First (OSPFv2)\n"
16001 "Non-main Kernel Routing Table\n"
16002 "Instance ID/Table ID\n"
16003 "Metric for redistributed routes\n"
16004 "Default metric\n")
16006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16007 int idx_ospf_table
= 1;
16008 int idx_number
= 2;
16009 int idx_number_2
= 4;
16011 struct bgp_redist
*red
;
16012 unsigned short instance
;
16016 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16017 protocol
= ZEBRA_ROUTE_OSPF
;
16019 protocol
= ZEBRA_ROUTE_TABLE
;
16021 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16022 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16024 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16025 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16027 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16030 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16031 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16032 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16033 "Redistribute information from another routing protocol\n"
16034 "Open Shortest Path First (OSPFv2)\n"
16035 "Non-main Kernel Routing Table\n"
16036 "Instance ID/Table ID\n"
16037 "Metric for redistributed routes\n"
16038 "Default metric\n")
16040 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16041 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16042 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16043 "Redistribute information from another routing protocol\n"
16044 "Open Shortest Path First (OSPFv2)\n"
16045 "Non-main Kernel Routing Table\n"
16046 "Instance ID/Table ID\n"
16047 "Route map reference\n"
16048 "Pointer to route-map entries\n"
16049 "Metric for redistributed routes\n"
16050 "Default metric\n")
16052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16053 int idx_ospf_table
= 1;
16054 int idx_number
= 2;
16056 int idx_number_2
= 6;
16058 struct bgp_redist
*red
;
16059 unsigned short instance
;
16062 struct route_map
*route_map
=
16063 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16065 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16066 protocol
= ZEBRA_ROUTE_OSPF
;
16068 protocol
= ZEBRA_ROUTE_TABLE
;
16070 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16071 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16073 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16075 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16076 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16078 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16082 bgp_redistribute_ipv4_ospf_rmap_metric
,
16083 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16084 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16085 "Redistribute information from another routing protocol\n"
16086 "Open Shortest Path First (OSPFv2)\n"
16087 "Non-main Kernel Routing Table\n"
16088 "Instance ID/Table ID\n"
16089 "Route map reference\n"
16090 "Pointer to route-map entries\n"
16091 "Metric for redistributed routes\n"
16092 "Default metric\n")
16094 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16095 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16096 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16097 "Redistribute information from another routing protocol\n"
16098 "Open Shortest Path First (OSPFv2)\n"
16099 "Non-main Kernel Routing Table\n"
16100 "Instance ID/Table ID\n"
16101 "Metric for redistributed routes\n"
16103 "Route map reference\n"
16104 "Pointer to route-map entries\n")
16106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16107 int idx_ospf_table
= 1;
16108 int idx_number
= 2;
16109 int idx_number_2
= 4;
16112 struct bgp_redist
*red
;
16113 unsigned short instance
;
16116 struct route_map
*route_map
=
16117 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16119 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16120 protocol
= ZEBRA_ROUTE_OSPF
;
16122 protocol
= ZEBRA_ROUTE_TABLE
;
16124 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16125 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16127 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16128 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16131 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16132 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16136 bgp_redistribute_ipv4_ospf_metric_rmap
,
16137 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16138 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16139 "Redistribute information from another routing protocol\n"
16140 "Open Shortest Path First (OSPFv2)\n"
16141 "Non-main Kernel Routing Table\n"
16142 "Instance ID/Table ID\n"
16143 "Metric for redistributed routes\n"
16145 "Route map reference\n"
16146 "Pointer to route-map entries\n")
16148 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16149 no_bgp_redistribute_ipv4_ospf_cmd
,
16150 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16152 "Redistribute information from another routing protocol\n"
16153 "Open Shortest Path First (OSPFv2)\n"
16154 "Non-main Kernel Routing Table\n"
16155 "Instance ID/Table ID\n"
16156 "Metric for redistributed routes\n"
16158 "Route map reference\n"
16159 "Pointer to route-map entries\n")
16161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16162 int idx_ospf_table
= 2;
16163 int idx_number
= 3;
16164 unsigned short instance
;
16167 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16168 protocol
= ZEBRA_ROUTE_OSPF
;
16170 protocol
= ZEBRA_ROUTE_TABLE
;
16172 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16173 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16177 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16178 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16180 "Redistribute information from another routing protocol\n"
16181 "Open Shortest Path First (OSPFv2)\n"
16182 "Non-main Kernel Routing Table\n"
16183 "Instance ID/Table ID\n"
16184 "Metric for redistributed routes\n"
16186 "Route map reference\n"
16187 "Pointer to route-map entries\n")
16189 DEFUN (no_bgp_redistribute_ipv4
,
16190 no_bgp_redistribute_ipv4_cmd
,
16191 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16193 "Redistribute information from another routing protocol\n"
16194 FRR_IP_REDIST_HELP_STR_BGPD
16195 "Metric for redistributed routes\n"
16197 "Route map reference\n"
16198 "Pointer to route-map entries\n")
16200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16201 int idx_protocol
= 2;
16204 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16206 vty_out(vty
, "%% Invalid route type\n");
16207 return CMD_WARNING_CONFIG_FAILED
;
16209 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16213 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16214 "no redistribute " FRR_IP_REDIST_STR_BGPD
16215 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16217 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16218 "Metric for redistributed routes\n"
16220 "Route map reference\n"
16221 "Pointer to route-map entries\n")
16223 DEFUN (bgp_redistribute_ipv6
,
16224 bgp_redistribute_ipv6_cmd
,
16225 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16226 "Redistribute information from another routing protocol\n"
16227 FRR_IP6_REDIST_HELP_STR_BGPD
)
16229 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16230 int idx_protocol
= 1;
16233 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16235 vty_out(vty
, "%% Invalid route type\n");
16236 return CMD_WARNING_CONFIG_FAILED
;
16239 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16240 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16243 DEFUN (bgp_redistribute_ipv6_rmap
,
16244 bgp_redistribute_ipv6_rmap_cmd
,
16245 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16246 "Redistribute information from another routing protocol\n"
16247 FRR_IP6_REDIST_HELP_STR_BGPD
16248 "Route map reference\n"
16249 "Pointer to route-map entries\n")
16251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16252 int idx_protocol
= 1;
16255 struct bgp_redist
*red
;
16257 struct route_map
*route_map
=
16258 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16260 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16262 vty_out(vty
, "%% Invalid route type\n");
16263 return CMD_WARNING_CONFIG_FAILED
;
16266 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16268 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16269 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16272 DEFUN (bgp_redistribute_ipv6_metric
,
16273 bgp_redistribute_ipv6_metric_cmd
,
16274 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16275 "Redistribute information from another routing protocol\n"
16276 FRR_IP6_REDIST_HELP_STR_BGPD
16277 "Metric for redistributed routes\n"
16278 "Default metric\n")
16280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16281 int idx_protocol
= 1;
16282 int idx_number
= 3;
16285 struct bgp_redist
*red
;
16288 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16290 vty_out(vty
, "%% Invalid route type\n");
16291 return CMD_WARNING_CONFIG_FAILED
;
16293 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16295 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16296 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16297 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16300 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16301 bgp_redistribute_ipv6_rmap_metric_cmd
,
16302 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16303 "Redistribute information from another routing protocol\n"
16304 FRR_IP6_REDIST_HELP_STR_BGPD
16305 "Route map reference\n"
16306 "Pointer to route-map entries\n"
16307 "Metric for redistributed routes\n"
16308 "Default metric\n")
16310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16311 int idx_protocol
= 1;
16313 int idx_number
= 5;
16316 struct bgp_redist
*red
;
16318 struct route_map
*route_map
=
16319 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16321 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16323 vty_out(vty
, "%% Invalid route type\n");
16324 return CMD_WARNING_CONFIG_FAILED
;
16326 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16328 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16330 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16331 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16333 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16336 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16337 bgp_redistribute_ipv6_metric_rmap_cmd
,
16338 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16339 "Redistribute information from another routing protocol\n"
16340 FRR_IP6_REDIST_HELP_STR_BGPD
16341 "Metric for redistributed routes\n"
16343 "Route map reference\n"
16344 "Pointer to route-map entries\n")
16346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16347 int idx_protocol
= 1;
16348 int idx_number
= 3;
16352 struct bgp_redist
*red
;
16354 struct route_map
*route_map
=
16355 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16357 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16359 vty_out(vty
, "%% Invalid route type\n");
16360 return CMD_WARNING_CONFIG_FAILED
;
16362 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16364 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16365 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16368 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16369 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16372 DEFUN (no_bgp_redistribute_ipv6
,
16373 no_bgp_redistribute_ipv6_cmd
,
16374 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16376 "Redistribute information from another routing protocol\n"
16377 FRR_IP6_REDIST_HELP_STR_BGPD
16378 "Metric for redistributed routes\n"
16380 "Route map reference\n"
16381 "Pointer to route-map entries\n")
16383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16384 int idx_protocol
= 2;
16387 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16389 vty_out(vty
, "%% Invalid route type\n");
16390 return CMD_WARNING_CONFIG_FAILED
;
16393 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16396 /* Neighbor update tcp-mss. */
16397 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16398 const char *tcp_mss_str
)
16401 uint32_t tcp_mss_val
= 0;
16403 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16405 return CMD_WARNING_CONFIG_FAILED
;
16408 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16409 peer_tcp_mss_set(peer
, tcp_mss_val
);
16411 peer_tcp_mss_unset(peer
);
16414 return CMD_SUCCESS
;
16417 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16418 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16419 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16420 "TCP max segment size\n"
16423 int peer_index
= 1;
16427 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16428 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16429 argv
[mss_index
]->arg
);
16432 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16433 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16434 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16435 "TCP max segment size\n"
16438 int peer_index
= 2;
16441 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16442 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16445 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16446 "[no$no] bgp retain route-target all",
16448 "Retain BGP updates\n"
16449 "Retain BGP updates based on route-target values\n"
16450 "Retain all BGP updates\n")
16453 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16455 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16456 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16457 if (check
!= !no
) {
16459 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16460 [bgp_node_safi(vty
)],
16461 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16463 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16464 [bgp_node_safi(vty
)],
16465 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16466 /* trigger a flush to re-sync with ADJ-RIB-in */
16467 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16468 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16470 return CMD_SUCCESS
;
16473 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16474 afi_t afi
, safi_t safi
)
16478 /* Unicast redistribution only. */
16479 if (safi
!= SAFI_UNICAST
)
16482 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16483 /* Redistribute BGP does not make sense. */
16484 if (i
!= ZEBRA_ROUTE_BGP
) {
16485 struct list
*red_list
;
16486 struct listnode
*node
;
16487 struct bgp_redist
*red
;
16489 red_list
= bgp
->redist
[afi
][i
];
16493 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16494 /* "redistribute" configuration. */
16495 vty_out(vty
, " redistribute %s",
16496 zebra_route_string(i
));
16498 vty_out(vty
, " %d", red
->instance
);
16499 if (red
->redist_metric_flag
)
16500 vty_out(vty
, " metric %u",
16501 red
->redist_metric
);
16502 if (red
->rmap
.name
)
16503 vty_out(vty
, " route-map %s",
16505 vty_out(vty
, "\n");
16511 /* peer-group helpers for config-write */
16513 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16515 if (!peer_group_active(peer
)) {
16516 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16517 return !CHECK_FLAG(peer
->flags
, flag
);
16519 return !!CHECK_FLAG(peer
->flags
, flag
);
16522 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16525 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16528 if (!peer_group_active(peer
)) {
16529 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16530 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16532 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16535 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16538 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16539 uint8_t type
, int direct
)
16541 struct bgp_filter
*filter
;
16543 if (peer_group_active(peer
))
16544 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16547 filter
= &peer
->filter
[afi
][safi
];
16549 case PEER_FT_DISTRIBUTE_LIST
:
16550 return !!(filter
->dlist
[direct
].name
);
16551 case PEER_FT_FILTER_LIST
:
16552 return !!(filter
->aslist
[direct
].name
);
16553 case PEER_FT_PREFIX_LIST
:
16554 return !!(filter
->plist
[direct
].name
);
16555 case PEER_FT_ROUTE_MAP
:
16556 return !!(filter
->map
[direct
].name
);
16557 case PEER_FT_UNSUPPRESS_MAP
:
16558 return !!(filter
->usmap
.name
);
16559 case PEER_FT_ADVERTISE_MAP
:
16560 return !!(filter
->advmap
.aname
16561 && ((filter
->advmap
.condition
== direct
)
16562 && filter
->advmap
.cname
));
16568 /* Return true if the addpath type is set for peer and different from
16571 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16574 enum bgp_addpath_strat type
, g_type
;
16576 type
= peer
->addpath_type
[afi
][safi
];
16578 if (type
!= BGP_ADDPATH_NONE
) {
16579 if (peer_group_active(peer
)) {
16580 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16582 if (type
!= g_type
)
16594 /* This is part of the address-family block (unicast only) */
16595 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16599 uint32_t tovpn_sid_index
= 0;
16601 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16602 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16603 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16604 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16605 bgp
->vpn_policy
[afi
]
16606 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16608 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16609 bgp
->vpn_policy
[afi
]
16610 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16612 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16613 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16614 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16615 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16618 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16619 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16621 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16624 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16625 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16626 bgp
->vpn_policy
[afi
].tovpn_label
);
16630 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16631 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16632 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16633 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16634 } else if (tovpn_sid_index
!= 0) {
16635 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16639 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16640 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16641 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16643 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16644 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16646 char buf
[PREFIX_STRLEN
];
16647 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16648 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16651 vty_out(vty
, "%*snexthop vpn export %s\n",
16655 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16656 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16658 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16659 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16661 char *b
= ecommunity_ecom2str(
16662 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16663 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16664 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16665 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16667 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16668 char *b
= ecommunity_ecom2str(
16669 bgp
->vpn_policy
[afi
]
16670 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16671 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16672 ECOMMUNITY_ROUTE_TARGET
);
16673 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16674 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16676 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16677 char *b
= ecommunity_ecom2str(
16678 bgp
->vpn_policy
[afi
]
16679 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16680 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16681 ECOMMUNITY_ROUTE_TARGET
);
16682 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16683 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16687 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16688 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16689 bgp
->vpn_policy
[afi
]
16690 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16692 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16693 char *b
= ecommunity_ecom2str(
16694 bgp
->vpn_policy
[afi
]
16695 .import_redirect_rtlist
,
16696 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16697 ECOMMUNITY_ROUTE_TARGET
);
16699 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16700 != ECOMMUNITY_SIZE
)
16701 vty_out(vty
, "%*srt6 redirect import %s\n",
16704 vty_out(vty
, "%*srt redirect import %s\n",
16706 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16710 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16711 afi_t afi
, safi_t safi
)
16713 struct bgp_filter
*filter
;
16717 filter
= &peer
->filter
[afi
][safi
];
16719 /* distribute-list. */
16720 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16722 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16723 filter
->dlist
[FILTER_IN
].name
);
16725 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16727 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16728 filter
->dlist
[FILTER_OUT
].name
);
16731 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16733 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16734 filter
->plist
[FILTER_IN
].name
);
16736 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16738 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16739 filter
->plist
[FILTER_OUT
].name
);
16742 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16743 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16744 filter
->map
[RMAP_IN
].name
);
16746 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16748 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16749 filter
->map
[RMAP_OUT
].name
);
16751 /* unsuppress-map */
16752 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16753 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16754 filter
->usmap
.name
);
16756 /* advertise-map : always applied in OUT direction*/
16757 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16758 CONDITION_NON_EXIST
))
16760 " neighbor %s advertise-map %s non-exist-map %s\n",
16761 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16763 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16765 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16766 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16769 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16771 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16772 filter
->aslist
[FILTER_IN
].name
);
16774 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16776 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16777 filter
->aslist
[FILTER_OUT
].name
);
16780 /* BGP peer configuration display function. */
16781 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16784 struct peer
*g_peer
= NULL
;
16786 int if_pg_printed
= false;
16787 int if_ras_printed
= false;
16789 /* Skip dynamic neighbors. */
16790 if (peer_dynamic_neighbor(peer
))
16794 addr
= peer
->conf_if
;
16798 /************************************
16799 ****** Global to the neighbor ******
16800 ************************************/
16801 if (peer
->conf_if
) {
16802 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16803 vty_out(vty
, " neighbor %s interface v6only", addr
);
16805 vty_out(vty
, " neighbor %s interface", addr
);
16807 if (peer_group_active(peer
)) {
16808 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16809 if_pg_printed
= true;
16810 } else if (peer
->as_type
== AS_SPECIFIED
) {
16811 vty_out(vty
, " remote-as %u", peer
->as
);
16812 if_ras_printed
= true;
16813 } else if (peer
->as_type
== AS_INTERNAL
) {
16814 vty_out(vty
, " remote-as internal");
16815 if_ras_printed
= true;
16816 } else if (peer
->as_type
== AS_EXTERNAL
) {
16817 vty_out(vty
, " remote-as external");
16818 if_ras_printed
= true;
16821 vty_out(vty
, "\n");
16824 /* remote-as and peer-group */
16825 /* peer is a member of a peer-group */
16826 if (peer_group_active(peer
)) {
16827 g_peer
= peer
->group
->conf
;
16829 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16830 if (peer
->as_type
== AS_SPECIFIED
) {
16831 vty_out(vty
, " neighbor %s remote-as %u\n",
16833 } else if (peer
->as_type
== AS_INTERNAL
) {
16835 " neighbor %s remote-as internal\n",
16837 } else if (peer
->as_type
== AS_EXTERNAL
) {
16839 " neighbor %s remote-as external\n",
16844 /* For swpX peers we displayed the peer-group
16845 * via 'neighbor swpX interface peer-group PGNAME' */
16846 if (!if_pg_printed
)
16847 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16848 peer
->group
->name
);
16851 /* peer is NOT a member of a peer-group */
16853 /* peer is a peer-group, declare the peer-group */
16854 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16855 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16858 if (!if_ras_printed
) {
16859 if (peer
->as_type
== AS_SPECIFIED
) {
16860 vty_out(vty
, " neighbor %s remote-as %u\n",
16862 } else if (peer
->as_type
== AS_INTERNAL
) {
16864 " neighbor %s remote-as internal\n",
16866 } else if (peer
->as_type
== AS_EXTERNAL
) {
16868 " neighbor %s remote-as external\n",
16875 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16876 vty_out(vty
, " neighbor %s local-as %u", addr
,
16877 peer
->change_local_as
);
16878 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16879 vty_out(vty
, " no-prepend");
16880 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16881 vty_out(vty
, " replace-as");
16882 vty_out(vty
, "\n");
16887 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16891 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16892 if (peer
->tx_shutdown_message
)
16893 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16894 peer
->tx_shutdown_message
);
16896 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16899 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16900 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16901 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16904 if (peer
->bfd_config
)
16905 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16908 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16909 vty_out(vty
, " neighbor %s password %s\n", addr
,
16912 /* neighbor solo */
16913 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16914 if (!peer_group_active(peer
)) {
16915 vty_out(vty
, " neighbor %s solo\n", addr
);
16920 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16921 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16924 /* Local interface name */
16925 if (peer
->ifname
) {
16926 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16929 /* TCP max segment size */
16930 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16931 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16934 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16935 vty_out(vty
, " neighbor %s passive\n", addr
);
16937 /* ebgp-multihop */
16938 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16939 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16940 && peer
->ttl
== MAXTTL
)) {
16941 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16942 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16948 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16949 peer
->local_role
!= ROLE_UNDEFINED
)
16950 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16951 bgp_get_name_by_role(peer
->local_role
),
16952 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
16956 /* ttl-security hops */
16957 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16958 if (!peer_group_active(peer
)
16959 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16960 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16961 addr
, peer
->gtsm_hops
);
16965 /* disable-connected-check */
16966 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16967 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16969 /* link-bw-encoding-ieee */
16970 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16971 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16974 /* extended-optional-parameters */
16975 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16976 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16979 /* enforce-first-as */
16980 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16981 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16983 /* update-source */
16984 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16985 if (peer
->update_source
)
16986 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
16987 peer
->update_source
);
16988 else if (peer
->update_if
)
16989 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16993 /* advertisement-interval */
16994 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16995 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16999 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17000 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17001 peer
->keepalive
, peer
->holdtime
);
17003 /* timers connect */
17004 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17005 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17007 /* need special-case handling for changed default values due to
17008 * config profile / version (because there is no "timers bgp connect"
17009 * command, we need to save this per-peer :/)
17011 else if (!peer_group_active(peer
) && !peer
->connect
&&
17012 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17013 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17014 peer
->bgp
->default_connect_retry
);
17016 /* timers delayopen */
17017 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17018 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17020 /* Save config even though flag is not set if default values have been
17023 else if (!peer_group_active(peer
) && !peer
->delayopen
17024 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17025 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17026 peer
->bgp
->default_delayopen
);
17028 /* capability dynamic */
17029 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17030 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17032 /* capability extended-nexthop */
17033 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17034 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17037 " no neighbor %s capability extended-nexthop\n",
17039 else if (!peer
->conf_if
)
17041 " neighbor %s capability extended-nexthop\n",
17045 /* dont-capability-negotiation */
17046 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17047 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17049 /* override-capability */
17050 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17051 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17053 /* strict-capability-match */
17054 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17055 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17057 /* Sender side AS path loop detection. */
17058 if (peer
->as_path_loop_detection
)
17059 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17062 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17063 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17065 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17066 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17068 " neighbor %s graceful-restart-helper\n", addr
);
17069 } else if (CHECK_FLAG(
17070 peer
->peer_gr_new_status_flag
,
17071 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17073 " neighbor %s graceful-restart\n", addr
);
17075 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17076 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17078 peer
->peer_gr_new_status_flag
,
17079 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17080 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17086 /* BGP peer configuration display function. */
17087 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17088 struct peer
*peer
, afi_t afi
, safi_t safi
)
17090 struct peer
*g_peer
= NULL
;
17092 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17094 /* Skip dynamic neighbors. */
17095 if (peer_dynamic_neighbor(peer
))
17099 addr
= peer
->conf_if
;
17103 /************************************
17104 ****** Per AF to the neighbor ******
17105 ************************************/
17106 if (peer_group_active(peer
)) {
17107 g_peer
= peer
->group
->conf
;
17109 /* If the peer-group is active but peer is not, print a 'no
17111 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17112 vty_out(vty
, " no neighbor %s activate\n", addr
);
17115 /* If the peer-group is not active but peer is, print an
17117 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17118 vty_out(vty
, " neighbor %s activate\n", addr
);
17121 if (peer
->afc
[afi
][safi
]) {
17122 if (safi
== SAFI_ENCAP
)
17123 vty_out(vty
, " neighbor %s activate\n", addr
);
17124 else if (!bgp
->default_af
[afi
][safi
])
17125 vty_out(vty
, " neighbor %s activate\n", addr
);
17127 if (bgp
->default_af
[afi
][safi
])
17128 vty_out(vty
, " no neighbor %s activate\n",
17133 /* addpath TX knobs */
17134 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17135 switch (peer
->addpath_type
[afi
][safi
]) {
17136 case BGP_ADDPATH_ALL
:
17137 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17140 case BGP_ADDPATH_BEST_PER_AS
:
17142 " neighbor %s addpath-tx-bestpath-per-AS\n",
17145 case BGP_ADDPATH_MAX
:
17146 case BGP_ADDPATH_NONE
:
17151 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17152 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17154 /* ORF capability. */
17155 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17156 || peergroup_af_flag_check(peer
, afi
, safi
,
17157 PEER_FLAG_ORF_PREFIX_RM
)) {
17158 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17160 if (peergroup_af_flag_check(peer
, afi
, safi
,
17161 PEER_FLAG_ORF_PREFIX_SM
)
17162 && peergroup_af_flag_check(peer
, afi
, safi
,
17163 PEER_FLAG_ORF_PREFIX_RM
))
17164 vty_out(vty
, " both");
17165 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17166 PEER_FLAG_ORF_PREFIX_SM
))
17167 vty_out(vty
, " send");
17169 vty_out(vty
, " receive");
17170 vty_out(vty
, "\n");
17173 /* Route reflector client. */
17174 if (peergroup_af_flag_check(peer
, afi
, safi
,
17175 PEER_FLAG_REFLECTOR_CLIENT
)) {
17176 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17179 /* next-hop-self force */
17180 if (peergroup_af_flag_check(peer
, afi
, safi
,
17181 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17182 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17185 /* next-hop-self */
17186 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17187 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17190 /* remove-private-AS */
17191 if (peergroup_af_flag_check(peer
, afi
, safi
,
17192 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17193 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17197 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17198 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17199 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17203 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17204 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17205 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17208 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17209 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17210 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17214 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17215 vty_out(vty
, " neighbor %s as-override\n", addr
);
17218 /* send-community print. */
17219 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17220 PEER_FLAG_SEND_COMMUNITY
);
17221 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17222 PEER_FLAG_SEND_EXT_COMMUNITY
);
17223 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17224 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17226 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17227 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17230 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17233 " no neighbor %s send-community extended\n",
17237 vty_out(vty
, " no neighbor %s send-community large\n",
17241 /* Default information */
17242 if (peergroup_af_flag_check(peer
, afi
, safi
,
17243 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17244 vty_out(vty
, " neighbor %s default-originate", addr
);
17246 if (peer
->default_rmap
[afi
][safi
].name
)
17247 vty_out(vty
, " route-map %s",
17248 peer
->default_rmap
[afi
][safi
].name
);
17250 vty_out(vty
, "\n");
17253 /* Soft reconfiguration inbound. */
17254 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17255 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17259 /* maximum-prefix. */
17260 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17261 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17262 peer
->pmax
[afi
][safi
]);
17264 if (peer
->pmax_threshold
[afi
][safi
]
17265 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17266 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17267 if (peer_af_flag_check(peer
, afi
, safi
,
17268 PEER_FLAG_MAX_PREFIX_WARNING
))
17269 vty_out(vty
, " warning-only");
17270 if (peer
->pmax_restart
[afi
][safi
])
17271 vty_out(vty
, " restart %u",
17272 peer
->pmax_restart
[afi
][safi
]);
17273 if (peer_af_flag_check(peer
, afi
, safi
,
17274 PEER_FLAG_MAX_PREFIX_FORCE
))
17275 vty_out(vty
, " force");
17277 vty_out(vty
, "\n");
17280 /* maximum-prefix-out */
17281 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17282 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17283 addr
, peer
->pmax_out
[afi
][safi
]);
17285 /* Route server client. */
17286 if (peergroup_af_flag_check(peer
, afi
, safi
,
17287 PEER_FLAG_RSERVER_CLIENT
)) {
17288 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17291 /* Nexthop-local unchanged. */
17292 if (peergroup_af_flag_check(peer
, afi
, safi
,
17293 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17294 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17297 /* allowas-in <1-10> */
17298 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17299 if (peer_af_flag_check(peer
, afi
, safi
,
17300 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17301 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17302 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17303 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17305 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17306 peer
->allowas_in
[afi
][safi
]);
17311 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17312 char *soo_str
= ecommunity_ecom2str(
17313 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17315 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17316 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17320 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17321 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17322 peer
->weight
[afi
][safi
]);
17325 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17327 /* atribute-unchanged. */
17328 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17329 || (safi
!= SAFI_EVPN
17330 && peer_af_flag_check(peer
, afi
, safi
,
17331 PEER_FLAG_NEXTHOP_UNCHANGED
))
17332 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17334 if (!peer_group_active(peer
)
17335 || peergroup_af_flag_check(peer
, afi
, safi
,
17336 PEER_FLAG_AS_PATH_UNCHANGED
)
17337 || peergroup_af_flag_check(peer
, afi
, safi
,
17338 PEER_FLAG_NEXTHOP_UNCHANGED
)
17339 || peergroup_af_flag_check(peer
, afi
, safi
,
17340 PEER_FLAG_MED_UNCHANGED
)) {
17343 " neighbor %s attribute-unchanged%s%s%s\n",
17345 peer_af_flag_check(peer
, afi
, safi
,
17346 PEER_FLAG_AS_PATH_UNCHANGED
)
17349 peer_af_flag_check(peer
, afi
, safi
,
17350 PEER_FLAG_NEXTHOP_UNCHANGED
)
17353 peer_af_flag_check(peer
, afi
, safi
,
17354 PEER_FLAG_MED_UNCHANGED
)
17361 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17364 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17365 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17366 vty_out(vty
, " no bgp retain route-target all\n");
17369 /* Address family based peer configuration display. */
17370 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17374 struct peer_group
*group
;
17375 struct listnode
*node
, *nnode
;
17378 vty_frame(vty
, " !\n address-family ");
17379 if (afi
== AFI_IP
) {
17380 if (safi
== SAFI_UNICAST
)
17381 vty_frame(vty
, "ipv4 unicast");
17382 else if (safi
== SAFI_LABELED_UNICAST
)
17383 vty_frame(vty
, "ipv4 labeled-unicast");
17384 else if (safi
== SAFI_MULTICAST
)
17385 vty_frame(vty
, "ipv4 multicast");
17386 else if (safi
== SAFI_MPLS_VPN
)
17387 vty_frame(vty
, "ipv4 vpn");
17388 else if (safi
== SAFI_ENCAP
)
17389 vty_frame(vty
, "ipv4 encap");
17390 else if (safi
== SAFI_FLOWSPEC
)
17391 vty_frame(vty
, "ipv4 flowspec");
17392 } else if (afi
== AFI_IP6
) {
17393 if (safi
== SAFI_UNICAST
)
17394 vty_frame(vty
, "ipv6 unicast");
17395 else if (safi
== SAFI_LABELED_UNICAST
)
17396 vty_frame(vty
, "ipv6 labeled-unicast");
17397 else if (safi
== SAFI_MULTICAST
)
17398 vty_frame(vty
, "ipv6 multicast");
17399 else if (safi
== SAFI_MPLS_VPN
)
17400 vty_frame(vty
, "ipv6 vpn");
17401 else if (safi
== SAFI_ENCAP
)
17402 vty_frame(vty
, "ipv6 encap");
17403 else if (safi
== SAFI_FLOWSPEC
)
17404 vty_frame(vty
, "ipv6 flowspec");
17405 } else if (afi
== AFI_L2VPN
) {
17406 if (safi
== SAFI_EVPN
)
17407 vty_frame(vty
, "l2vpn evpn");
17409 vty_frame(vty
, "\n");
17411 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17413 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17415 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17417 /* BGP flag dampening. */
17418 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17419 bgp_config_write_damp(vty
, afi
, safi
);
17421 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17422 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17424 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17425 /* Do not display doppelganger peers */
17426 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17427 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17430 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17431 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17433 if (safi
== SAFI_EVPN
)
17434 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17436 if (safi
== SAFI_FLOWSPEC
)
17437 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17439 if (safi
== SAFI_MPLS_VPN
)
17440 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17442 if (safi
== SAFI_UNICAST
) {
17443 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17444 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17445 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17447 vty_out(vty
, " export vpn\n");
17449 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17450 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17452 vty_out(vty
, " import vpn\n");
17454 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17455 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17458 for (ALL_LIST_ELEMENTS_RO(
17459 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17461 vty_out(vty
, " import vrf %s\n", name
);
17465 vty_endframe(vty
, " exit-address-family\n");
17468 int bgp_config_write(struct vty
*vty
)
17471 struct peer_group
*group
;
17473 struct listnode
*node
, *nnode
;
17474 struct listnode
*mnode
, *mnnode
;
17478 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17479 vty_out(vty
, "bgp route-map delay-timer %u\n",
17480 bm
->rmap_update_timer
);
17482 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17483 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17484 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17485 vty_out(vty
, " %d", bm
->v_establish_wait
);
17486 vty_out(vty
, "\n");
17489 if (bm
->wait_for_fib
)
17490 vty_out(vty
, "bgp suppress-fib-pending\n");
17492 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17493 vty_out(vty
, "bgp graceful-shutdown\n");
17495 /* No-RIB (Zebra) option flag configuration */
17496 if (bgp_option_check(BGP_OPT_NO_FIB
))
17497 vty_out(vty
, "bgp no-rib\n");
17499 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17500 vty_out(vty
, "bgp send-extra-data zebra\n");
17502 /* BGP session DSCP value */
17503 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17504 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17506 /* BGP configuration. */
17507 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17509 /* skip all auto created vrf as they dont have user config */
17510 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17513 /* Router bgp ASN */
17514 vty_out(vty
, "router bgp %u", bgp
->as
);
17517 vty_out(vty
, " %s %s",
17518 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17519 ? "view" : "vrf", bgp
->name
);
17520 vty_out(vty
, "\n");
17522 /* BGP fast-external-failover. */
17523 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17524 vty_out(vty
, " no bgp fast-external-failover\n");
17526 /* BGP router ID. */
17527 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17528 vty_out(vty
, " bgp router-id %pI4\n",
17529 &bgp
->router_id_static
);
17531 /* Suppress fib pending */
17532 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17533 vty_out(vty
, " bgp suppress-fib-pending\n");
17535 /* BGP log-neighbor-changes. */
17536 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17537 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17538 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17539 CHECK_FLAG(bgp
->flags
,
17540 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17544 /* BGP configuration. */
17545 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17546 vty_out(vty
, " bgp always-compare-med\n");
17548 /* RFC8212 default eBGP policy. */
17549 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17550 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17551 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17552 CHECK_FLAG(bgp
->flags
,
17553 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17557 /* draft-ietf-idr-deprecate-as-set-confed-set */
17558 if (bgp
->reject_as_sets
)
17559 vty_out(vty
, " bgp reject-as-sets\n");
17561 /* Suppress duplicate updates if the route actually not changed
17563 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17564 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17565 vty_out(vty
, " %sbgp suppress-duplicates\n",
17566 CHECK_FLAG(bgp
->flags
,
17567 BGP_FLAG_SUPPRESS_DUPLICATES
)
17571 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17573 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17574 SAVE_BGP_HARD_ADMIN_RESET
)
17575 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17576 CHECK_FLAG(bgp
->flags
,
17577 BGP_FLAG_HARD_ADMIN_RESET
)
17581 /* BGP default <afi>-<safi> */
17582 FOREACH_AFI_SAFI (afi
, safi
) {
17583 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17584 if (!bgp
->default_af
[afi
][safi
])
17585 vty_out(vty
, " no bgp default %s\n",
17586 get_bgp_default_af_flag(afi
,
17588 } else if (bgp
->default_af
[afi
][safi
])
17589 vty_out(vty
, " bgp default %s\n",
17590 get_bgp_default_af_flag(afi
, safi
));
17593 /* BGP default local-preference. */
17594 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17595 vty_out(vty
, " bgp default local-preference %u\n",
17596 bgp
->default_local_pref
);
17598 /* BGP default show-hostname */
17599 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17600 != SAVE_BGP_SHOW_HOSTNAME
)
17601 vty_out(vty
, " %sbgp default show-hostname\n",
17602 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17606 /* BGP default show-nexthop-hostname */
17607 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17608 != SAVE_BGP_SHOW_HOSTNAME
)
17609 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17610 CHECK_FLAG(bgp
->flags
,
17611 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17615 /* BGP default subgroup-pkt-queue-max. */
17616 if (bgp
->default_subgroup_pkt_queue_max
17617 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17618 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17619 bgp
->default_subgroup_pkt_queue_max
);
17621 /* BGP client-to-client reflection. */
17622 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17623 vty_out(vty
, " no bgp client-to-client reflection\n");
17625 /* BGP cluster ID. */
17626 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17627 vty_out(vty
, " bgp cluster-id %pI4\n",
17630 /* Disable ebgp connected nexthop check */
17631 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17633 " bgp disable-ebgp-connected-route-check\n");
17635 /* Confederation identifier*/
17636 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17637 vty_out(vty
, " bgp confederation identifier %u\n",
17640 /* Confederation peer */
17641 if (bgp
->confed_peers_cnt
> 0) {
17644 vty_out(vty
, " bgp confederation peers");
17646 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17647 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17649 vty_out(vty
, "\n");
17652 /* BGP deterministic-med. */
17653 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17654 != SAVE_BGP_DETERMINISTIC_MED
)
17655 vty_out(vty
, " %sbgp deterministic-med\n",
17656 CHECK_FLAG(bgp
->flags
,
17657 BGP_FLAG_DETERMINISTIC_MED
)
17661 /* BGP update-delay. */
17662 bgp_config_write_update_delay(vty
, bgp
);
17664 if (bgp
->v_maxmed_onstartup
17665 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17666 vty_out(vty
, " bgp max-med on-startup %u",
17667 bgp
->v_maxmed_onstartup
);
17668 if (bgp
->maxmed_onstartup_value
17669 != BGP_MAXMED_VALUE_DEFAULT
)
17670 vty_out(vty
, " %u",
17671 bgp
->maxmed_onstartup_value
);
17672 vty_out(vty
, "\n");
17674 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17675 vty_out(vty
, " bgp max-med administrative");
17676 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17677 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17678 vty_out(vty
, "\n");
17682 bgp_config_write_wpkt_quanta(vty
, bgp
);
17684 bgp_config_write_rpkt_quanta(vty
, bgp
);
17686 /* coalesce time */
17687 bgp_config_write_coalesce_time(vty
, bgp
);
17689 /* BGP per-instance graceful-shutdown */
17690 /* BGP-wide settings and per-instance settings are mutually
17693 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17694 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17695 vty_out(vty
, " bgp graceful-shutdown\n");
17697 /* Long-lived Graceful Restart */
17698 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17700 " bgp long-lived-graceful-restart stale-time %u\n",
17701 bgp
->llgr_stale_time
);
17703 /* BGP graceful-restart. */
17704 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17706 " bgp graceful-restart stalepath-time %u\n",
17707 bgp
->stalepath_time
);
17709 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17710 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17711 bgp
->restart_time
);
17713 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17714 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17715 vty_out(vty
, " %sbgp graceful-restart notification\n",
17716 CHECK_FLAG(bgp
->flags
,
17717 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17721 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17723 " bgp graceful-restart select-defer-time %u\n",
17724 bgp
->select_defer_time
);
17726 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17727 vty_out(vty
, " bgp graceful-restart\n");
17729 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17730 vty_out(vty
, " bgp graceful-restart-disable\n");
17732 /* BGP graceful-restart Preserve State F bit. */
17733 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17735 " bgp graceful-restart preserve-fw-state\n");
17737 /* BGP TCP keepalive */
17738 bgp_config_tcp_keepalive(vty
, bgp
);
17740 /* Stale timer for RIB */
17741 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17743 " bgp graceful-restart rib-stale-time %u\n",
17744 bgp
->rib_stale_time
);
17746 /* BGP bestpath method. */
17747 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17748 vty_out(vty
, " bgp bestpath as-path ignore\n");
17749 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17750 vty_out(vty
, " bgp bestpath as-path confed\n");
17752 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17753 if (CHECK_FLAG(bgp
->flags
,
17754 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17756 " bgp bestpath as-path multipath-relax as-set\n");
17759 " bgp bestpath as-path multipath-relax\n");
17763 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17765 " bgp route-reflector allow-outbound-policy\n");
17767 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17768 vty_out(vty
, " bgp bestpath compare-routerid\n");
17769 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17770 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17771 vty_out(vty
, " bgp bestpath med");
17772 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17773 vty_out(vty
, " confed");
17774 if (CHECK_FLAG(bgp
->flags
,
17775 BGP_FLAG_MED_MISSING_AS_WORST
))
17776 vty_out(vty
, " missing-as-worst");
17777 vty_out(vty
, "\n");
17780 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17782 " bgp bestpath peer-type multipath-relax\n");
17784 /* Link bandwidth handling. */
17785 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17786 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17787 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17788 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17789 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17790 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17792 /* BGP network import check. */
17793 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17794 != SAVE_BGP_IMPORT_CHECK
)
17795 vty_out(vty
, " %sbgp network import-check\n",
17796 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17800 /* BGP timers configuration. */
17801 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17802 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17803 vty_out(vty
, " timers bgp %u %u\n",
17804 bgp
->default_keepalive
, bgp
->default_holdtime
);
17806 /* BGP minimum holdtime configuration. */
17807 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17808 && bgp
->default_min_holdtime
!= 0)
17809 vty_out(vty
, " bgp minimum-holdtime %u\n",
17810 bgp
->default_min_holdtime
);
17812 /* Conditional advertisement timer configuration */
17813 if (bgp
->condition_check_period
17814 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17816 " bgp conditional-advertisement timer %u\n",
17817 bgp
->condition_check_period
);
17820 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17821 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17824 /* Normal neighbor configuration. */
17825 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17826 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17827 bgp_config_write_peer_global(vty
, bgp
, peer
);
17830 /* listen range and limit for dynamic BGP neighbors */
17831 bgp_config_write_listen(vty
, bgp
);
17834 * BGP default autoshutdown neighbors
17836 * This must be placed after any peer and peer-group
17837 * configuration, to avoid setting all peers to shutdown after
17838 * a daemon restart, which is undesired behavior. (see #2286)
17840 if (bgp
->autoshutdown
)
17841 vty_out(vty
, " bgp default shutdown\n");
17843 /* BGP instance administrative shutdown */
17844 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17845 vty_out(vty
, " bgp shutdown\n");
17847 if (bgp
->allow_martian
)
17848 vty_out(vty
, " bgp allow-martian-nexthop\n");
17850 if (bgp
->fast_convergence
)
17851 vty_out(vty
, " bgp fast-convergence\n");
17853 if (bgp
->srv6_enabled
) {
17854 vty_frame(vty
, " !\n segment-routing srv6\n");
17855 if (strlen(bgp
->srv6_locator_name
))
17856 vty_out(vty
, " locator %s\n",
17857 bgp
->srv6_locator_name
);
17858 vty_endframe(vty
, " exit\n");
17862 /* IPv4 unicast configuration. */
17863 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17865 /* IPv4 multicast configuration. */
17866 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17868 /* IPv4 labeled-unicast configuration. */
17869 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17871 /* IPv4 VPN configuration. */
17872 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17874 /* ENCAPv4 configuration. */
17875 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17877 /* FLOWSPEC v4 configuration. */
17878 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17880 /* IPv6 unicast configuration. */
17881 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17883 /* IPv6 multicast configuration. */
17884 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17886 /* IPv6 labeled-unicast configuration. */
17887 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17888 SAFI_LABELED_UNICAST
);
17890 /* IPv6 VPN configuration. */
17891 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17893 /* ENCAPv6 configuration. */
17894 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17896 /* FLOWSPEC v6 configuration. */
17897 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17899 /* EVPN configuration. */
17900 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17902 hook_call(bgp_inst_config_write
, bgp
, vty
);
17904 #ifdef ENABLE_BGP_VNC
17905 bgp_rfapi_cfg_write(vty
, bgp
);
17908 vty_out(vty
, "exit\n");
17909 vty_out(vty
, "!\n");
17915 /* BGP node structure. */
17916 static struct cmd_node bgp_node
= {
17919 .parent_node
= CONFIG_NODE
,
17920 .prompt
= "%s(config-router)# ",
17921 .config_write
= bgp_config_write
,
17924 static struct cmd_node bgp_ipv4_unicast_node
= {
17925 .name
= "bgp ipv4 unicast",
17926 .node
= BGP_IPV4_NODE
,
17927 .parent_node
= BGP_NODE
,
17928 .prompt
= "%s(config-router-af)# ",
17932 static struct cmd_node bgp_ipv4_multicast_node
= {
17933 .name
= "bgp ipv4 multicast",
17934 .node
= BGP_IPV4M_NODE
,
17935 .parent_node
= BGP_NODE
,
17936 .prompt
= "%s(config-router-af)# ",
17940 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17941 .name
= "bgp ipv4 labeled unicast",
17942 .node
= BGP_IPV4L_NODE
,
17943 .parent_node
= BGP_NODE
,
17944 .prompt
= "%s(config-router-af)# ",
17948 static struct cmd_node bgp_ipv6_unicast_node
= {
17949 .name
= "bgp ipv6 unicast",
17950 .node
= BGP_IPV6_NODE
,
17951 .parent_node
= BGP_NODE
,
17952 .prompt
= "%s(config-router-af)# ",
17956 static struct cmd_node bgp_ipv6_multicast_node
= {
17957 .name
= "bgp ipv6 multicast",
17958 .node
= BGP_IPV6M_NODE
,
17959 .parent_node
= BGP_NODE
,
17960 .prompt
= "%s(config-router-af)# ",
17964 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17965 .name
= "bgp ipv6 labeled unicast",
17966 .node
= BGP_IPV6L_NODE
,
17967 .parent_node
= BGP_NODE
,
17968 .prompt
= "%s(config-router-af)# ",
17972 static struct cmd_node bgp_vpnv4_node
= {
17973 .name
= "bgp vpnv4",
17974 .node
= BGP_VPNV4_NODE
,
17975 .parent_node
= BGP_NODE
,
17976 .prompt
= "%s(config-router-af)# ",
17980 static struct cmd_node bgp_vpnv6_node
= {
17981 .name
= "bgp vpnv6",
17982 .node
= BGP_VPNV6_NODE
,
17983 .parent_node
= BGP_NODE
,
17984 .prompt
= "%s(config-router-af-vpnv6)# ",
17988 static struct cmd_node bgp_evpn_node
= {
17989 .name
= "bgp evpn",
17990 .node
= BGP_EVPN_NODE
,
17991 .parent_node
= BGP_NODE
,
17992 .prompt
= "%s(config-router-evpn)# ",
17996 static struct cmd_node bgp_evpn_vni_node
= {
17997 .name
= "bgp evpn vni",
17998 .node
= BGP_EVPN_VNI_NODE
,
17999 .parent_node
= BGP_EVPN_NODE
,
18000 .prompt
= "%s(config-router-af-vni)# ",
18003 static struct cmd_node bgp_flowspecv4_node
= {
18004 .name
= "bgp ipv4 flowspec",
18005 .node
= BGP_FLOWSPECV4_NODE
,
18006 .parent_node
= BGP_NODE
,
18007 .prompt
= "%s(config-router-af)# ",
18011 static struct cmd_node bgp_flowspecv6_node
= {
18012 .name
= "bgp ipv6 flowspec",
18013 .node
= BGP_FLOWSPECV6_NODE
,
18014 .parent_node
= BGP_NODE
,
18015 .prompt
= "%s(config-router-af-vpnv6)# ",
18019 static struct cmd_node bgp_srv6_node
= {
18020 .name
= "bgp srv6",
18021 .node
= BGP_SRV6_NODE
,
18022 .parent_node
= BGP_NODE
,
18023 .prompt
= "%s(config-router-srv6)# ",
18026 static void community_list_vty(void);
18028 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18031 struct peer_group
*group
;
18032 struct listnode
*lnbgp
, *lnpeer
;
18034 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18035 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18037 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18041 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18045 struct listnode
*lnbgp
, *lnpeer
;
18047 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18048 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18049 /* only provide suggestions on the appropriate input
18051 * they'll otherwise show up multiple times */
18052 enum cmd_token_type match_type
;
18053 char *name
= peer
->host
;
18055 if (peer
->conf_if
) {
18056 match_type
= VARIABLE_TKN
;
18057 name
= peer
->conf_if
;
18058 } else if (strchr(peer
->host
, ':'))
18059 match_type
= IPV6_TKN
;
18061 match_type
= IPV4_TKN
;
18063 if (token
->type
!= match_type
)
18066 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18071 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18073 bgp_ac_peer(comps
, token
);
18075 if (token
->type
== VARIABLE_TKN
)
18076 bgp_ac_peergroup(comps
, token
);
18079 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18080 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18081 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18082 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18083 {.completions
= NULL
}};
18085 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18086 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18087 {.completions
= NULL
} };
18089 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18091 static struct thread
*t_bgp_cfg
;
18093 bool bgp_config_inprocess(void)
18095 return thread_is_scheduled(t_bgp_cfg
);
18098 static void bgp_config_finish(struct thread
*t
)
18100 struct listnode
*node
;
18103 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18104 hook_call(bgp_config_end
, bgp
);
18107 static void bgp_config_start(void)
18109 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18110 THREAD_OFF(t_bgp_cfg
);
18111 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18112 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18115 /* When we receive a hook the configuration is read,
18116 * we start a timer to make sure we postpone sending
18117 * EoR before route-maps are processed.
18118 * This is especially valid if using `bgp route-map delay-timer`.
18120 static void bgp_config_end(void)
18122 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18123 uint32_t bgp_post_config_delay
=
18124 thread_is_scheduled(bm
->t_rmap_update
)
18125 ? thread_timer_remain_second(bm
->t_rmap_update
)
18126 : BGP_POST_CONFIG_DELAY_SECONDS
;
18128 /* If BGP config processing thread isn't running, then
18129 * we can return and rely it's properly handled.
18131 if (!bgp_config_inprocess())
18134 THREAD_OFF(t_bgp_cfg
);
18136 /* Start a new timer to make sure we don't send EoR
18137 * before route-maps are processed.
18139 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18140 bgp_post_config_delay
, &t_bgp_cfg
);
18143 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18146 struct interface
*ifp
;
18147 struct bgp_interface
*iifp
;
18149 FOR_ALL_INTERFACES (vrf
, ifp
) {
18154 if_vty_config_start(vty
, ifp
);
18156 if (CHECK_FLAG(iifp
->flags
,
18157 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18158 vty_out(vty
, " mpls bgp forwarding\n");
18162 if_vty_config_end(vty
);
18168 /* Configuration write function for bgpd. */
18169 static int config_write_interface(struct vty
*vty
)
18172 struct vrf
*vrf
= NULL
;
18174 /* Display all VRF aware OSPF interface configuration */
18175 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18176 write
+= config_write_interface_one(vty
, vrf
);
18182 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18183 "[no$no] mpls bgp forwarding",
18184 NO_STR MPLS_STR BGP_STR
18185 "Enable MPLS forwarding for eBGP directly connected peers\n")
18188 struct bgp_interface
*iifp
;
18190 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18193 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18194 return CMD_WARNING_CONFIG_FAILED
;
18196 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18197 if (check
!= !no
) {
18199 UNSET_FLAG(iifp
->flags
,
18200 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18202 SET_FLAG(iifp
->flags
,
18203 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18204 /* trigger a nht update on eBGP sessions */
18205 if (if_is_operative(ifp
))
18206 bgp_nht_ifp_up(ifp
);
18208 return CMD_SUCCESS
;
18211 /* Initialization of BGP interface. */
18212 static void bgp_vty_if_init(void)
18214 /* Install interface node. */
18215 if_cmd_init(config_write_interface
);
18217 /* "mpls bgp forwarding" commands. */
18218 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18221 void bgp_vty_init(void)
18223 cmd_variable_handler_register(bgp_var_neighbor
);
18224 cmd_variable_handler_register(bgp_var_peergroup
);
18226 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18228 /* Install bgp top node. */
18229 install_node(&bgp_node
);
18230 install_node(&bgp_ipv4_unicast_node
);
18231 install_node(&bgp_ipv4_multicast_node
);
18232 install_node(&bgp_ipv4_labeled_unicast_node
);
18233 install_node(&bgp_ipv6_unicast_node
);
18234 install_node(&bgp_ipv6_multicast_node
);
18235 install_node(&bgp_ipv6_labeled_unicast_node
);
18236 install_node(&bgp_vpnv4_node
);
18237 install_node(&bgp_vpnv6_node
);
18238 install_node(&bgp_evpn_node
);
18239 install_node(&bgp_evpn_vni_node
);
18240 install_node(&bgp_flowspecv4_node
);
18241 install_node(&bgp_flowspecv6_node
);
18242 install_node(&bgp_srv6_node
);
18244 /* Install default VTY commands to new nodes. */
18245 install_default(BGP_NODE
);
18246 install_default(BGP_IPV4_NODE
);
18247 install_default(BGP_IPV4M_NODE
);
18248 install_default(BGP_IPV4L_NODE
);
18249 install_default(BGP_IPV6_NODE
);
18250 install_default(BGP_IPV6M_NODE
);
18251 install_default(BGP_IPV6L_NODE
);
18252 install_default(BGP_VPNV4_NODE
);
18253 install_default(BGP_VPNV6_NODE
);
18254 install_default(BGP_FLOWSPECV4_NODE
);
18255 install_default(BGP_FLOWSPECV6_NODE
);
18256 install_default(BGP_EVPN_NODE
);
18257 install_default(BGP_EVPN_VNI_NODE
);
18258 install_default(BGP_SRV6_NODE
);
18260 /* "bgp local-mac" hidden commands. */
18261 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18262 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18264 /* "bgp suppress-fib-pending" global */
18265 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18267 /* bgp route-map delay-timer commands. */
18268 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18269 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18271 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18273 /* bgp fast-convergence command */
18274 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18275 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18277 /* global bgp update-delay command */
18278 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18279 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18281 /* global bgp graceful-shutdown command */
18282 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18283 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18285 /* Dummy commands (Currently not supported) */
18286 install_element(BGP_NODE
, &no_synchronization_cmd
);
18287 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18289 /* "router bgp" commands. */
18290 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18292 /* "no router bgp" commands. */
18293 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18295 /* "bgp session-dscp command */
18296 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18297 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18299 /* "bgp router-id" commands. */
18300 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18301 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18303 /* "bgp suppress-fib-pending" command */
18304 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18306 /* "bgp cluster-id" commands. */
18307 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18308 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18310 /* "bgp no-rib" commands. */
18311 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18312 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18314 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18316 /* "bgp confederation" commands. */
18317 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18318 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18320 /* "bgp confederation peers" commands. */
18321 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18322 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18324 /* bgp max-med command */
18325 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18326 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18327 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18328 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18329 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18331 /* "neighbor role" commands. */
18332 install_element(BGP_NODE
, &neighbor_role_cmd
);
18333 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18334 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18336 /* bgp disable-ebgp-connected-nh-check */
18337 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18338 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18340 /* bgp update-delay command */
18341 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18342 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18344 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18345 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18347 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18348 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18350 /* "maximum-paths" commands. */
18351 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18352 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18353 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18354 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18355 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18356 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18357 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18358 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18359 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18360 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18361 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18362 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18363 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18364 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18365 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18367 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18368 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18369 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18370 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18371 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18372 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18373 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18374 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18375 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18376 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18378 /* "timers bgp" commands. */
18379 install_element(BGP_NODE
, &bgp_timers_cmd
);
18380 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18382 /* "minimum-holdtime" commands. */
18383 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18384 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18386 /* route-map delay-timer commands - per instance for backwards compat.
18388 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18389 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18391 /* "bgp client-to-client reflection" commands */
18392 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18393 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18395 /* "bgp always-compare-med" commands */
18396 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18397 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18399 /* bgp ebgp-requires-policy */
18400 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18401 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18403 /* bgp suppress-duplicates */
18404 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18405 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18407 /* bgp reject-as-sets */
18408 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18409 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18411 /* "bgp deterministic-med" commands */
18412 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18413 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18415 /* "bgp graceful-restart" command */
18416 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18417 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18419 /* "bgp graceful-restart-disable" command */
18420 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18421 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18423 /* "neighbor a:b:c:d graceful-restart" command */
18424 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18425 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18427 /* "neighbor a:b:c:d graceful-restart-disable" command */
18428 install_element(BGP_NODE
,
18429 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18430 install_element(BGP_NODE
,
18431 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18433 /* "neighbor a:b:c:d graceful-restart-helper" command */
18434 install_element(BGP_NODE
,
18435 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18436 install_element(BGP_NODE
,
18437 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18439 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18440 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18441 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18442 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18443 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18444 install_element(BGP_NODE
,
18445 &no_bgp_graceful_restart_select_defer_time_cmd
);
18446 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18447 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18448 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18450 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18451 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18452 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18453 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18455 /* "bgp graceful-shutdown" commands */
18456 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18457 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18459 /* "bgp hard-administrative-reset" commands */
18460 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18462 /* "bgp long-lived-graceful-restart" commands */
18463 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18464 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18466 /* "bgp fast-external-failover" commands */
18467 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18468 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18470 /* "bgp bestpath compare-routerid" commands */
18471 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18472 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18474 /* "bgp bestpath as-path ignore" commands */
18475 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18476 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18478 /* "bgp bestpath as-path confed" commands */
18479 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18480 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18482 /* "bgp bestpath as-path multipath-relax" commands */
18483 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18484 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18486 /* "bgp bestpath peer-type multipath-relax" commands */
18487 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18488 install_element(BGP_NODE
,
18489 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18491 /* "bgp log-neighbor-changes" commands */
18492 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18493 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18495 /* "bgp bestpath med" commands */
18496 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18497 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18499 /* "bgp bestpath bandwidth" commands */
18500 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18501 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18503 /* "no bgp default <afi>-<safi>" commands. */
18504 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18506 /* "bgp network import-check" commands. */
18507 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18508 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18509 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18511 /* "bgp default local-preference" commands. */
18512 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18513 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18515 /* bgp default show-hostname */
18516 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18519 /* bgp default show-nexthop-hostname */
18520 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18521 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18523 /* "bgp default subgroup-pkt-queue-max" commands. */
18524 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18525 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18527 /* bgp ibgp-allow-policy-mods command */
18528 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18529 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18531 /* "bgp listen limit" commands. */
18532 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18533 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18535 /* "bgp listen range" commands. */
18536 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18537 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18539 /* "bgp default shutdown" command */
18540 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18542 /* "bgp shutdown" commands */
18543 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18544 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18545 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18546 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18548 /* "neighbor remote-as" commands. */
18549 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18550 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18551 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18552 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18553 install_element(BGP_NODE
,
18554 &neighbor_interface_v6only_config_remote_as_cmd
);
18555 install_element(BGP_NODE
, &no_neighbor_cmd
);
18556 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18558 /* "neighbor peer-group" commands. */
18559 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18561 install_element(BGP_NODE
,
18562 &no_neighbor_interface_peer_group_remote_as_cmd
);
18564 /* "neighbor local-as" commands. */
18565 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18566 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18567 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18568 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18570 /* "neighbor solo" commands. */
18571 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18572 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18574 /* "neighbor password" commands. */
18575 install_element(BGP_NODE
, &neighbor_password_cmd
);
18576 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18578 /* "neighbor activate" commands. */
18579 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18580 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18581 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18582 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18583 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18584 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18585 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18586 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18587 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18588 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18589 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18590 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18592 /* "no neighbor activate" commands. */
18593 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18594 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18595 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18596 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18597 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18598 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18599 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18600 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18601 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18602 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18603 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18604 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18606 /* "neighbor peer-group" set commands. */
18607 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18608 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18609 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18610 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18611 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18612 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18613 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18614 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18615 install_element(BGP_FLOWSPECV4_NODE
,
18616 &neighbor_set_peer_group_hidden_cmd
);
18617 install_element(BGP_FLOWSPECV6_NODE
,
18618 &neighbor_set_peer_group_hidden_cmd
);
18620 /* "no neighbor peer-group unset" commands. */
18621 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18622 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18623 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18624 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18625 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18626 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18627 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18628 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18629 install_element(BGP_FLOWSPECV4_NODE
,
18630 &no_neighbor_set_peer_group_hidden_cmd
);
18631 install_element(BGP_FLOWSPECV6_NODE
,
18632 &no_neighbor_set_peer_group_hidden_cmd
);
18634 /* "neighbor softreconfiguration inbound" commands.*/
18635 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18636 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18637 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18638 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18639 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18640 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18641 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18642 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18643 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18644 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18645 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18646 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18647 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18648 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18649 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18650 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18651 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18652 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18653 install_element(BGP_FLOWSPECV4_NODE
,
18654 &neighbor_soft_reconfiguration_cmd
);
18655 install_element(BGP_FLOWSPECV4_NODE
,
18656 &no_neighbor_soft_reconfiguration_cmd
);
18657 install_element(BGP_FLOWSPECV6_NODE
,
18658 &neighbor_soft_reconfiguration_cmd
);
18659 install_element(BGP_FLOWSPECV6_NODE
,
18660 &no_neighbor_soft_reconfiguration_cmd
);
18661 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18662 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18664 /* "neighbor attribute-unchanged" commands. */
18665 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18666 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18667 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18668 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18669 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18670 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18671 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18672 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18673 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18674 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18675 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18676 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18677 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18678 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18679 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18680 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18681 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18682 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18684 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18685 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18687 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18688 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18689 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18690 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18692 /* "nexthop-local unchanged" commands */
18693 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18694 install_element(BGP_IPV6_NODE
,
18695 &no_neighbor_nexthop_local_unchanged_cmd
);
18697 /* "neighbor next-hop-self" commands. */
18698 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18699 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18700 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18701 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18702 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18703 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18704 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18705 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18706 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18707 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18708 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18709 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18710 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18711 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18712 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18713 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18714 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18715 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18716 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18717 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18719 /* "neighbor next-hop-self force" commands. */
18720 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18721 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18722 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18723 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18724 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18725 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18726 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18727 install_element(BGP_IPV4_NODE
,
18728 &no_neighbor_nexthop_self_all_hidden_cmd
);
18729 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18730 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18731 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18732 install_element(BGP_IPV4M_NODE
,
18733 &no_neighbor_nexthop_self_all_hidden_cmd
);
18734 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18735 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18736 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18737 install_element(BGP_IPV4L_NODE
,
18738 &no_neighbor_nexthop_self_all_hidden_cmd
);
18739 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18740 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18741 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18742 install_element(BGP_IPV6_NODE
,
18743 &no_neighbor_nexthop_self_all_hidden_cmd
);
18744 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18745 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18746 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18747 install_element(BGP_IPV6M_NODE
,
18748 &no_neighbor_nexthop_self_all_hidden_cmd
);
18749 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18750 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18751 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18752 install_element(BGP_IPV6L_NODE
,
18753 &no_neighbor_nexthop_self_all_hidden_cmd
);
18754 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18755 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18756 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18757 install_element(BGP_VPNV4_NODE
,
18758 &no_neighbor_nexthop_self_all_hidden_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18760 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18761 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18762 install_element(BGP_VPNV6_NODE
,
18763 &no_neighbor_nexthop_self_all_hidden_cmd
);
18764 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18765 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18767 /* "neighbor as-override" commands. */
18768 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18769 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18770 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18771 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18772 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18773 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18774 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18775 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18776 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18777 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18778 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18779 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18780 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18781 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18782 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18783 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18784 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18785 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18787 /* "neighbor remove-private-AS" commands. */
18788 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18789 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18790 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18791 install_element(BGP_NODE
,
18792 &no_neighbor_remove_private_as_all_hidden_cmd
);
18793 install_element(BGP_NODE
,
18794 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18795 install_element(BGP_NODE
,
18796 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18797 install_element(BGP_NODE
,
18798 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18801 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18802 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18803 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18804 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18805 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18806 install_element(BGP_IPV4_NODE
,
18807 &neighbor_remove_private_as_replace_as_cmd
);
18808 install_element(BGP_IPV4_NODE
,
18809 &no_neighbor_remove_private_as_replace_as_cmd
);
18810 install_element(BGP_IPV4_NODE
,
18811 &neighbor_remove_private_as_all_replace_as_cmd
);
18812 install_element(BGP_IPV4_NODE
,
18813 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18814 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18815 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18816 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18817 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18818 install_element(BGP_IPV4M_NODE
,
18819 &neighbor_remove_private_as_replace_as_cmd
);
18820 install_element(BGP_IPV4M_NODE
,
18821 &no_neighbor_remove_private_as_replace_as_cmd
);
18822 install_element(BGP_IPV4M_NODE
,
18823 &neighbor_remove_private_as_all_replace_as_cmd
);
18824 install_element(BGP_IPV4M_NODE
,
18825 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18826 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18827 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18828 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18829 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18830 install_element(BGP_IPV4L_NODE
,
18831 &neighbor_remove_private_as_replace_as_cmd
);
18832 install_element(BGP_IPV4L_NODE
,
18833 &no_neighbor_remove_private_as_replace_as_cmd
);
18834 install_element(BGP_IPV4L_NODE
,
18835 &neighbor_remove_private_as_all_replace_as_cmd
);
18836 install_element(BGP_IPV4L_NODE
,
18837 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18838 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18839 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18840 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18841 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18842 install_element(BGP_IPV6_NODE
,
18843 &neighbor_remove_private_as_replace_as_cmd
);
18844 install_element(BGP_IPV6_NODE
,
18845 &no_neighbor_remove_private_as_replace_as_cmd
);
18846 install_element(BGP_IPV6_NODE
,
18847 &neighbor_remove_private_as_all_replace_as_cmd
);
18848 install_element(BGP_IPV6_NODE
,
18849 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18850 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18851 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18852 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18853 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18854 install_element(BGP_IPV6M_NODE
,
18855 &neighbor_remove_private_as_replace_as_cmd
);
18856 install_element(BGP_IPV6M_NODE
,
18857 &no_neighbor_remove_private_as_replace_as_cmd
);
18858 install_element(BGP_IPV6M_NODE
,
18859 &neighbor_remove_private_as_all_replace_as_cmd
);
18860 install_element(BGP_IPV6M_NODE
,
18861 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18862 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18863 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18864 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18865 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18866 install_element(BGP_IPV6L_NODE
,
18867 &neighbor_remove_private_as_replace_as_cmd
);
18868 install_element(BGP_IPV6L_NODE
,
18869 &no_neighbor_remove_private_as_replace_as_cmd
);
18870 install_element(BGP_IPV6L_NODE
,
18871 &neighbor_remove_private_as_all_replace_as_cmd
);
18872 install_element(BGP_IPV6L_NODE
,
18873 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18874 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18875 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18876 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18877 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18878 install_element(BGP_VPNV4_NODE
,
18879 &neighbor_remove_private_as_replace_as_cmd
);
18880 install_element(BGP_VPNV4_NODE
,
18881 &no_neighbor_remove_private_as_replace_as_cmd
);
18882 install_element(BGP_VPNV4_NODE
,
18883 &neighbor_remove_private_as_all_replace_as_cmd
);
18884 install_element(BGP_VPNV4_NODE
,
18885 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18886 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18887 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18888 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18889 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18890 install_element(BGP_VPNV6_NODE
,
18891 &neighbor_remove_private_as_replace_as_cmd
);
18892 install_element(BGP_VPNV6_NODE
,
18893 &no_neighbor_remove_private_as_replace_as_cmd
);
18894 install_element(BGP_VPNV6_NODE
,
18895 &neighbor_remove_private_as_all_replace_as_cmd
);
18896 install_element(BGP_VPNV6_NODE
,
18897 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18899 /* "neighbor send-community" commands.*/
18900 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18901 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18902 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18903 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18904 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18905 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18906 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18907 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18908 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18909 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18910 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18911 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18912 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18913 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18914 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18915 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18916 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18917 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18918 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18919 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18920 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18921 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18922 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18923 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18924 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18925 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18926 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18927 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18928 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18929 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18930 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18931 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18932 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18933 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18934 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18935 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18937 /* "neighbor route-reflector" commands.*/
18938 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18939 install_element(BGP_NODE
,
18940 &no_neighbor_route_reflector_client_hidden_cmd
);
18941 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18942 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18943 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18944 install_element(BGP_IPV4M_NODE
,
18945 &no_neighbor_route_reflector_client_cmd
);
18946 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18947 install_element(BGP_IPV4L_NODE
,
18948 &no_neighbor_route_reflector_client_cmd
);
18949 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18950 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18951 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18952 install_element(BGP_IPV6M_NODE
,
18953 &no_neighbor_route_reflector_client_cmd
);
18954 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18955 install_element(BGP_IPV6L_NODE
,
18956 &no_neighbor_route_reflector_client_cmd
);
18957 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18958 install_element(BGP_VPNV4_NODE
,
18959 &no_neighbor_route_reflector_client_cmd
);
18960 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18961 install_element(BGP_VPNV6_NODE
,
18962 &no_neighbor_route_reflector_client_cmd
);
18963 install_element(BGP_FLOWSPECV4_NODE
,
18964 &neighbor_route_reflector_client_cmd
);
18965 install_element(BGP_FLOWSPECV4_NODE
,
18966 &no_neighbor_route_reflector_client_cmd
);
18967 install_element(BGP_FLOWSPECV6_NODE
,
18968 &neighbor_route_reflector_client_cmd
);
18969 install_element(BGP_FLOWSPECV6_NODE
,
18970 &no_neighbor_route_reflector_client_cmd
);
18971 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18972 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18974 /* "neighbor route-server" commands.*/
18975 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18976 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18977 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18978 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18979 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18980 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18981 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18982 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18983 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18984 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18985 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18986 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18987 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18988 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18989 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18990 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18991 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18992 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18993 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18994 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18995 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18996 install_element(BGP_FLOWSPECV4_NODE
,
18997 &no_neighbor_route_server_client_cmd
);
18998 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18999 install_element(BGP_FLOWSPECV6_NODE
,
19000 &no_neighbor_route_server_client_cmd
);
19002 /* "neighbor disable-addpath-rx" commands. */
19003 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19004 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19005 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19006 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19007 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19008 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19009 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19010 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19011 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19012 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19013 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19014 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19015 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19016 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19017 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19018 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19020 /* "neighbor addpath-tx-all-paths" commands.*/
19021 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19022 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19023 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19024 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19025 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19026 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19027 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19028 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19029 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19030 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19031 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19032 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19033 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19034 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19035 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19036 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19037 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19038 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19040 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19041 install_element(BGP_NODE
,
19042 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19043 install_element(BGP_NODE
,
19044 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19045 install_element(BGP_IPV4_NODE
,
19046 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19047 install_element(BGP_IPV4_NODE
,
19048 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19049 install_element(BGP_IPV4M_NODE
,
19050 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19051 install_element(BGP_IPV4M_NODE
,
19052 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19053 install_element(BGP_IPV4L_NODE
,
19054 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19055 install_element(BGP_IPV4L_NODE
,
19056 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19057 install_element(BGP_IPV6_NODE
,
19058 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19059 install_element(BGP_IPV6_NODE
,
19060 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19061 install_element(BGP_IPV6M_NODE
,
19062 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19063 install_element(BGP_IPV6M_NODE
,
19064 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19065 install_element(BGP_IPV6L_NODE
,
19066 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19067 install_element(BGP_IPV6L_NODE
,
19068 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19069 install_element(BGP_VPNV4_NODE
,
19070 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19071 install_element(BGP_VPNV4_NODE
,
19072 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19073 install_element(BGP_VPNV6_NODE
,
19074 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19075 install_element(BGP_VPNV6_NODE
,
19076 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19078 /* "neighbor sender-as-path-loop-detection" commands. */
19079 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19080 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19082 /* "neighbor passive" commands. */
19083 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19084 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19087 /* "neighbor shutdown" commands. */
19088 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19089 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19090 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19091 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19092 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19093 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19095 /* "neighbor capability extended-nexthop" commands.*/
19096 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19097 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19099 /* "neighbor capability orf prefix-list" commands.*/
19100 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19101 install_element(BGP_NODE
,
19102 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19103 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19104 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19105 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19106 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19107 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19108 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19109 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19110 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19111 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19112 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19113 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19114 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19116 /* "neighbor capability dynamic" commands.*/
19117 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19118 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19120 /* "neighbor dont-capability-negotiate" commands. */
19121 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19122 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19124 /* "neighbor ebgp-multihop" commands. */
19125 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19126 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19127 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19129 /* "neighbor disable-connected-check" commands. */
19130 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19131 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19133 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19134 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19135 install_element(BGP_NODE
,
19136 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19138 /* "neighbor extended-optional-parameters" commands. */
19139 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19140 install_element(BGP_NODE
,
19141 &no_neighbor_extended_optional_parameters_cmd
);
19143 /* "neighbor enforce-first-as" commands. */
19144 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19145 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19147 /* "neighbor description" commands. */
19148 install_element(BGP_NODE
, &neighbor_description_cmd
);
19149 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19150 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19152 /* "neighbor update-source" commands. "*/
19153 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19154 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19156 /* "neighbor default-originate" commands. */
19157 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19158 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19159 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19160 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19161 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19162 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19163 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19164 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19165 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19166 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19167 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19168 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19169 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19170 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19171 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19172 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19173 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19174 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19175 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19176 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19177 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19179 /* "neighbor port" commands. */
19180 install_element(BGP_NODE
, &neighbor_port_cmd
);
19181 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19183 /* "neighbor weight" commands. */
19184 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19185 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19187 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19188 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19189 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19190 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19191 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19192 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19193 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19194 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19195 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19196 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19197 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19198 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19199 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19200 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19201 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19202 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19204 /* "neighbor override-capability" commands. */
19205 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19206 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19208 /* "neighbor strict-capability-match" commands. */
19209 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19210 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19212 /* "neighbor timers" commands. */
19213 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19214 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19216 /* "neighbor timers connect" commands. */
19217 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19218 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19220 /* "neighbor timers delayopen" commands. */
19221 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19222 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19224 /* "neighbor advertisement-interval" commands. */
19225 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19226 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19228 /* "neighbor interface" commands. */
19229 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19230 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19232 /* "neighbor distribute" commands. */
19233 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19234 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19235 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19236 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19237 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19238 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19239 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19240 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19241 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19242 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19243 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19244 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19245 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19246 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19247 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19248 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19249 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19250 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19252 /* "neighbor prefix-list" commands. */
19253 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19254 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19255 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19256 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19257 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19258 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19259 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19260 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19261 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19262 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19263 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19264 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19265 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19266 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19267 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19268 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19269 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19270 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19271 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19272 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19273 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19274 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19276 /* "neighbor filter-list" commands. */
19277 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19278 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19279 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19280 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19281 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19282 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19283 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19284 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19285 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19286 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19287 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19288 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19289 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19290 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19291 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19292 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19293 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19294 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19295 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19296 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19297 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19298 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19300 /* "neighbor route-map" commands. */
19301 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19302 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19303 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19304 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19305 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19306 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19307 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19308 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19309 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19310 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19311 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19312 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19313 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19314 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19315 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19316 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19317 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19318 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19319 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19320 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19321 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19322 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19323 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19324 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19326 /* "neighbor unsuppress-map" commands. */
19327 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19328 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19329 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19330 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19331 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19332 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19333 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19334 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19335 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19336 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19337 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19338 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19339 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19340 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19341 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19342 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19343 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19344 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19346 /* "neighbor advertise-map" commands. */
19347 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19348 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19349 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19350 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19351 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19352 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19353 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19354 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19355 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19356 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19358 /* neighbor maximum-prefix-out commands. */
19359 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19360 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19361 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19362 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19363 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19364 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19365 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19366 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19367 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19368 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19369 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19370 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19371 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19372 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19373 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19374 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19375 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19376 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19378 /* "neighbor maximum-prefix" commands. */
19379 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19380 install_element(BGP_NODE
,
19381 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19382 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19383 install_element(BGP_NODE
,
19384 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19385 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19386 install_element(BGP_NODE
,
19387 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19388 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19389 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19390 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19391 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19392 install_element(BGP_IPV4_NODE
,
19393 &neighbor_maximum_prefix_threshold_warning_cmd
);
19394 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19395 install_element(BGP_IPV4_NODE
,
19396 &neighbor_maximum_prefix_threshold_restart_cmd
);
19397 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19398 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19399 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19400 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19401 install_element(BGP_IPV4M_NODE
,
19402 &neighbor_maximum_prefix_threshold_warning_cmd
);
19403 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19404 install_element(BGP_IPV4M_NODE
,
19405 &neighbor_maximum_prefix_threshold_restart_cmd
);
19406 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19407 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19408 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19409 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19410 install_element(BGP_IPV4L_NODE
,
19411 &neighbor_maximum_prefix_threshold_warning_cmd
);
19412 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19413 install_element(BGP_IPV4L_NODE
,
19414 &neighbor_maximum_prefix_threshold_restart_cmd
);
19415 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19416 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19417 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19418 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19419 install_element(BGP_IPV6_NODE
,
19420 &neighbor_maximum_prefix_threshold_warning_cmd
);
19421 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19422 install_element(BGP_IPV6_NODE
,
19423 &neighbor_maximum_prefix_threshold_restart_cmd
);
19424 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19425 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19426 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19427 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19428 install_element(BGP_IPV6M_NODE
,
19429 &neighbor_maximum_prefix_threshold_warning_cmd
);
19430 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19431 install_element(BGP_IPV6M_NODE
,
19432 &neighbor_maximum_prefix_threshold_restart_cmd
);
19433 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19434 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19435 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19436 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19437 install_element(BGP_IPV6L_NODE
,
19438 &neighbor_maximum_prefix_threshold_warning_cmd
);
19439 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19440 install_element(BGP_IPV6L_NODE
,
19441 &neighbor_maximum_prefix_threshold_restart_cmd
);
19442 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19443 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19444 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19445 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19446 install_element(BGP_VPNV4_NODE
,
19447 &neighbor_maximum_prefix_threshold_warning_cmd
);
19448 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19449 install_element(BGP_VPNV4_NODE
,
19450 &neighbor_maximum_prefix_threshold_restart_cmd
);
19451 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19452 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19453 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19454 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19455 install_element(BGP_VPNV6_NODE
,
19456 &neighbor_maximum_prefix_threshold_warning_cmd
);
19457 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19458 install_element(BGP_VPNV6_NODE
,
19459 &neighbor_maximum_prefix_threshold_restart_cmd
);
19460 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19462 /* "neighbor allowas-in" */
19463 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19464 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19465 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19466 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19467 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19468 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19469 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19470 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19471 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19472 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19473 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19474 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19475 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19476 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19477 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19478 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19479 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19480 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19481 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19482 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19484 /* "neighbor soo" */
19485 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19486 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19487 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19488 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19489 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19490 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19491 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19492 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19493 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19494 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19495 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19496 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19497 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19498 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19499 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19500 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19501 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19502 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19504 /* address-family commands. */
19505 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19506 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19507 #ifdef KEEP_OLD_VPN_COMMANDS
19508 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19509 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19510 #endif /* KEEP_OLD_VPN_COMMANDS */
19512 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19514 /* "exit-address-family" command. */
19515 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19516 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19517 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19518 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19519 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19520 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19521 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19522 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19523 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19524 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19525 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19527 /* BGP retain all route-target */
19528 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19529 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19531 /* "clear ip bgp commands" */
19532 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19534 /* clear ip bgp prefix */
19535 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19536 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19537 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19539 /* "show [ip] bgp summary" commands. */
19540 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19541 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19542 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19543 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19544 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19545 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19546 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19548 /* "show [ip] bgp neighbors" commands. */
19549 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19551 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19553 /* "show [ip] bgp peer-group" commands. */
19554 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19556 /* "show [ip] bgp paths" commands. */
19557 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19559 /* "show [ip] bgp community" commands. */
19560 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19562 /* "show ip bgp large-community" commands. */
19563 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19564 /* "show [ip] bgp attribute-info" commands. */
19565 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19566 /* "show [ip] bgp route-leak" command */
19567 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19569 /* "redistribute" commands. */
19570 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19571 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19572 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19573 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19574 install_element(BGP_NODE
,
19575 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19576 install_element(BGP_NODE
,
19577 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19578 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19579 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19580 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19581 install_element(BGP_NODE
,
19582 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19583 install_element(BGP_NODE
,
19584 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19585 install_element(BGP_NODE
,
19586 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19587 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19588 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19589 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19590 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19591 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19592 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19593 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19594 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19595 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19596 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19597 install_element(BGP_IPV4_NODE
,
19598 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19599 install_element(BGP_IPV4_NODE
,
19600 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19601 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19602 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19603 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19604 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19605 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19606 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19608 /* import|export vpn [route-map RMAP_NAME] */
19609 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19610 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19612 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19613 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19615 /* ttl_security commands */
19616 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19617 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19619 /* "bgp tcp-keepalive" commands */
19620 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19621 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19623 /* "show [ip] bgp memory" commands. */
19624 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19626 /* "show bgp martian next-hop" */
19627 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19629 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19631 /* "show [ip] bgp views" commands. */
19632 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19634 /* "show [ip] bgp vrfs" commands. */
19635 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19637 /* Community-list. */
19638 community_list_vty();
19640 community_alias_vty();
19642 /* vpn-policy commands */
19643 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19644 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19645 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19646 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19647 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19648 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19649 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19650 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19651 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19652 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19653 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19654 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19656 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19657 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19659 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19660 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19661 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19662 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19663 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19664 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19665 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19666 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19667 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19668 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19670 /* tcp-mss command */
19671 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19672 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19674 /* srv6 commands */
19675 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19676 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19677 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19678 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19679 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19680 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19681 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19686 #include "memory.h"
19687 #include "bgp_regex.h"
19688 #include "bgp_clist.h"
19689 #include "bgp_ecommunity.h"
19691 /* VTY functions. */
19693 /* Direction value to string conversion. */
19694 static const char *community_direct_str(int direct
)
19697 case COMMUNITY_DENY
:
19699 case COMMUNITY_PERMIT
:
19706 /* Display error string. */
19707 static void community_list_perror(struct vty
*vty
, int ret
)
19710 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19711 vty_out(vty
, "%% Can't find community-list\n");
19713 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19714 vty_out(vty
, "%% Malformed community-list value\n");
19716 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19718 "%% Community name conflict, previously defined as standard community\n");
19720 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19722 "%% Community name conflict, previously defined as expanded community\n");
19727 /* "community-list" keyword help string. */
19728 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19730 /*community-list standard */
19731 DEFUN (community_list_standard
,
19732 bgp_community_list_standard_cmd
,
19733 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19736 "Community list number (standard)\n"
19737 "Add an standard community-list entry\n"
19738 "Community list name\n"
19739 "Sequence number of an entry\n"
19740 "Sequence number\n"
19741 "Specify community to reject\n"
19742 "Specify community to accept\n"
19745 char *cl_name_or_number
= NULL
;
19748 int style
= COMMUNITY_LIST_STANDARD
;
19751 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19752 seq
= argv
[idx
]->arg
;
19755 argv_find(argv
, argc
, "(1-99)", &idx
);
19756 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19757 cl_name_or_number
= argv
[idx
]->arg
;
19758 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19760 argv_find(argv
, argc
, "AA:NN", &idx
);
19761 char *str
= argv_concat(argv
, argc
, idx
);
19763 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19766 XFREE(MTYPE_TMP
, str
);
19769 /* Display error string. */
19770 community_list_perror(vty
, ret
);
19771 return CMD_WARNING_CONFIG_FAILED
;
19774 return CMD_SUCCESS
;
19777 DEFUN (no_community_list_standard_all
,
19778 no_bgp_community_list_standard_all_cmd
,
19779 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19783 "Community list number (standard)\n"
19784 "Add an standard community-list entry\n"
19785 "Community list name\n"
19786 "Sequence number of an entry\n"
19787 "Sequence number\n"
19788 "Specify community to reject\n"
19789 "Specify community to accept\n"
19792 char *cl_name_or_number
= NULL
;
19795 int style
= COMMUNITY_LIST_STANDARD
;
19799 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19800 seq
= argv
[idx
]->arg
;
19803 argv_find(argv
, argc
, "permit", &idx
);
19804 argv_find(argv
, argc
, "deny", &idx
);
19807 direct
= argv_find(argv
, argc
, "permit", &idx
)
19812 argv_find(argv
, argc
, "AA:NN", &idx
);
19813 str
= argv_concat(argv
, argc
, idx
);
19817 argv_find(argv
, argc
, "(1-99)", &idx
);
19818 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19819 cl_name_or_number
= argv
[idx
]->arg
;
19821 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19824 XFREE(MTYPE_TMP
, str
);
19827 community_list_perror(vty
, ret
);
19828 return CMD_WARNING_CONFIG_FAILED
;
19831 return CMD_SUCCESS
;
19834 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19835 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19836 NO_STR BGP_STR COMMUNITY_LIST_STR
19837 "Community list number (standard)\n"
19838 "Add an standard community-list entry\n"
19839 "Community list name\n")
19841 /*community-list expanded */
19842 DEFUN (community_list_expanded_all
,
19843 bgp_community_list_expanded_all_cmd
,
19844 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19847 "Community list number (expanded)\n"
19848 "Add an expanded community-list entry\n"
19849 "Community list name\n"
19850 "Sequence number of an entry\n"
19851 "Sequence number\n"
19852 "Specify community to reject\n"
19853 "Specify community to accept\n"
19856 char *cl_name_or_number
= NULL
;
19859 int style
= COMMUNITY_LIST_EXPANDED
;
19862 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19863 seq
= argv
[idx
]->arg
;
19867 argv_find(argv
, argc
, "(100-500)", &idx
);
19868 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19869 cl_name_or_number
= argv
[idx
]->arg
;
19870 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19872 argv_find(argv
, argc
, "AA:NN", &idx
);
19873 char *str
= argv_concat(argv
, argc
, idx
);
19875 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19878 XFREE(MTYPE_TMP
, str
);
19881 /* Display error string. */
19882 community_list_perror(vty
, ret
);
19883 return CMD_WARNING_CONFIG_FAILED
;
19886 return CMD_SUCCESS
;
19889 DEFUN (no_community_list_expanded_all
,
19890 no_bgp_community_list_expanded_all_cmd
,
19891 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19895 "Community list number (expanded)\n"
19896 "Add an expanded community-list entry\n"
19897 "Community list name\n"
19898 "Sequence number of an entry\n"
19899 "Sequence number\n"
19900 "Specify community to reject\n"
19901 "Specify community to accept\n"
19904 char *cl_name_or_number
= NULL
;
19908 int style
= COMMUNITY_LIST_EXPANDED
;
19911 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19912 seq
= argv
[idx
]->arg
;
19915 argv_find(argv
, argc
, "permit", &idx
);
19916 argv_find(argv
, argc
, "deny", &idx
);
19919 direct
= argv_find(argv
, argc
, "permit", &idx
)
19924 argv_find(argv
, argc
, "AA:NN", &idx
);
19925 str
= argv_concat(argv
, argc
, idx
);
19929 argv_find(argv
, argc
, "(100-500)", &idx
);
19930 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19931 cl_name_or_number
= argv
[idx
]->arg
;
19933 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19936 XFREE(MTYPE_TMP
, str
);
19939 community_list_perror(vty
, ret
);
19940 return CMD_WARNING_CONFIG_FAILED
;
19943 return CMD_SUCCESS
;
19946 ALIAS(no_community_list_expanded_all
,
19947 no_bgp_community_list_expanded_all_list_cmd
,
19948 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19949 NO_STR BGP_STR COMMUNITY_LIST_STR
19950 "Community list number (expanded)\n"
19951 "Add an expanded community-list entry\n"
19952 "Community list name\n")
19954 /* Return configuration string of community-list entry. */
19955 static const char *community_list_config_str(struct community_entry
*entry
)
19962 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19963 str
= community_str(entry
->u
.com
, false, false);
19964 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19965 str
= lcommunity_str(entry
->u
.lcom
, false, false);
19967 str
= entry
->config
;
19972 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19974 struct community_entry
*entry
;
19976 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19977 if (entry
== list
->head
) {
19978 if (all_digit(list
->name
))
19979 vty_out(vty
, "Community %s list %s\n",
19980 entry
->style
== COMMUNITY_LIST_STANDARD
19982 : "(expanded) access",
19985 vty_out(vty
, "Named Community %s list %s\n",
19986 entry
->style
== COMMUNITY_LIST_STANDARD
19992 vty_out(vty
, " %s\n",
19993 community_direct_str(entry
->direct
));
19995 vty_out(vty
, " %s %s\n",
19996 community_direct_str(entry
->direct
),
19997 community_list_config_str(entry
));
20001 DEFUN (show_community_list
,
20002 show_bgp_community_list_cmd
,
20003 "show bgp community-list",
20006 "List community-list\n")
20008 struct community_list
*list
;
20009 struct community_list_master
*cm
;
20011 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20013 return CMD_SUCCESS
;
20015 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20016 community_list_show(vty
, list
);
20018 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20019 community_list_show(vty
, list
);
20021 return CMD_SUCCESS
;
20024 DEFUN (show_community_list_arg
,
20025 show_bgp_community_list_arg_cmd
,
20026 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20029 "List community-list\n"
20030 "Community-list number\n"
20031 "Community-list name\n"
20032 "Detailed information on community-list\n")
20034 int idx_comm_list
= 3;
20035 struct community_list
*list
;
20037 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20038 COMMUNITY_LIST_MASTER
);
20040 vty_out(vty
, "%% Can't find community-list\n");
20041 return CMD_WARNING
;
20044 community_list_show(vty
, list
);
20046 return CMD_SUCCESS
;
20050 * Large Community code.
20052 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20053 struct cmd_token
**argv
, int style
,
20054 int reject_all_digit_name
)
20063 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20064 seq
= argv
[idx
]->arg
;
20067 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20070 /* All digit name check. */
20072 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20073 argv_find(argv
, argc
, "(1-99)", &idx
);
20074 argv_find(argv
, argc
, "(100-500)", &idx
);
20075 cl_name
= argv
[idx
]->arg
;
20076 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20077 vty_out(vty
, "%% Community name cannot have all digits\n");
20078 return CMD_WARNING_CONFIG_FAILED
;
20082 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20083 argv_find(argv
, argc
, "LINE", &idx
);
20084 /* Concat community string argument. */
20086 str
= argv_concat(argv
, argc
, idx
);
20090 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20092 /* Free temporary community list string allocated by
20094 XFREE(MTYPE_TMP
, str
);
20097 community_list_perror(vty
, ret
);
20098 return CMD_WARNING_CONFIG_FAILED
;
20100 return CMD_SUCCESS
;
20103 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20104 struct cmd_token
**argv
, int style
)
20112 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20113 seq
= argv
[idx
]->arg
;
20116 argv_find(argv
, argc
, "permit", &idx
);
20117 argv_find(argv
, argc
, "deny", &idx
);
20120 /* Check the list direct. */
20121 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20122 direct
= COMMUNITY_PERMIT
;
20124 direct
= COMMUNITY_DENY
;
20127 argv_find(argv
, argc
, "LINE", &idx
);
20128 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20129 /* Concat community string argument. */
20130 str
= argv_concat(argv
, argc
, idx
);
20134 argv_find(argv
, argc
, "(1-99)", &idx
);
20135 argv_find(argv
, argc
, "(100-500)", &idx
);
20136 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20138 /* Unset community list. */
20139 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20142 /* Free temporary community list string allocated by
20144 XFREE(MTYPE_TMP
, str
);
20147 community_list_perror(vty
, ret
);
20148 return CMD_WARNING_CONFIG_FAILED
;
20151 return CMD_SUCCESS
;
20154 /* "large-community-list" keyword help string. */
20155 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20156 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20158 DEFUN (lcommunity_list_standard
,
20159 bgp_lcommunity_list_standard_cmd
,
20160 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20162 LCOMMUNITY_LIST_STR
20163 "Large Community list number (standard)\n"
20164 "Sequence number of an entry\n"
20165 "Sequence number\n"
20166 "Specify large community to reject\n"
20167 "Specify large community to accept\n"
20168 LCOMMUNITY_VAL_STR
)
20170 return lcommunity_list_set_vty(vty
, argc
, argv
,
20171 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20174 DEFUN (lcommunity_list_expanded
,
20175 bgp_lcommunity_list_expanded_cmd
,
20176 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20178 LCOMMUNITY_LIST_STR
20179 "Large Community list number (expanded)\n"
20180 "Sequence number of an entry\n"
20181 "Sequence number\n"
20182 "Specify large community to reject\n"
20183 "Specify large community to accept\n"
20184 "An ordered list as a regular-expression\n")
20186 return lcommunity_list_set_vty(vty
, argc
, argv
,
20187 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20190 DEFUN (lcommunity_list_name_standard
,
20191 bgp_lcommunity_list_name_standard_cmd
,
20192 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20194 LCOMMUNITY_LIST_STR
20195 "Specify standard large-community-list\n"
20196 "Large Community list name\n"
20197 "Sequence number of an entry\n"
20198 "Sequence number\n"
20199 "Specify large community to reject\n"
20200 "Specify large community to accept\n"
20201 LCOMMUNITY_VAL_STR
)
20203 return lcommunity_list_set_vty(vty
, argc
, argv
,
20204 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20207 DEFUN (lcommunity_list_name_expanded
,
20208 bgp_lcommunity_list_name_expanded_cmd
,
20209 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20211 LCOMMUNITY_LIST_STR
20212 "Specify expanded large-community-list\n"
20213 "Large Community list name\n"
20214 "Sequence number of an entry\n"
20215 "Sequence number\n"
20216 "Specify large community to reject\n"
20217 "Specify large community to accept\n"
20218 "An ordered list as a regular-expression\n")
20220 return lcommunity_list_set_vty(vty
, argc
, argv
,
20221 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20224 DEFUN (no_lcommunity_list_all
,
20225 no_bgp_lcommunity_list_all_cmd
,
20226 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20229 LCOMMUNITY_LIST_STR
20230 "Large Community list number (standard)\n"
20231 "Large Community list number (expanded)\n"
20232 "Large Community list name\n")
20234 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20235 LARGE_COMMUNITY_LIST_STANDARD
);
20238 DEFUN (no_lcommunity_list_name_standard_all
,
20239 no_bgp_lcommunity_list_name_standard_all_cmd
,
20240 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20243 LCOMMUNITY_LIST_STR
20244 "Specify standard large-community-list\n"
20245 "Large Community list name\n")
20247 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20248 LARGE_COMMUNITY_LIST_STANDARD
);
20251 DEFUN (no_lcommunity_list_name_expanded_all
,
20252 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20253 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20256 LCOMMUNITY_LIST_STR
20257 "Specify expanded large-community-list\n"
20258 "Large Community list name\n")
20260 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20261 LARGE_COMMUNITY_LIST_EXPANDED
);
20264 DEFUN (no_lcommunity_list_standard
,
20265 no_bgp_lcommunity_list_standard_cmd
,
20266 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20269 LCOMMUNITY_LIST_STR
20270 "Large Community list number (standard)\n"
20271 "Sequence number of an entry\n"
20272 "Sequence number\n"
20273 "Specify large community to reject\n"
20274 "Specify large community to accept\n"
20275 LCOMMUNITY_VAL_STR
)
20277 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20278 LARGE_COMMUNITY_LIST_STANDARD
);
20281 DEFUN (no_lcommunity_list_expanded
,
20282 no_bgp_lcommunity_list_expanded_cmd
,
20283 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20286 LCOMMUNITY_LIST_STR
20287 "Large Community list number (expanded)\n"
20288 "Sequence number of an entry\n"
20289 "Sequence number\n"
20290 "Specify large community to reject\n"
20291 "Specify large community to accept\n"
20292 "An ordered list as a regular-expression\n")
20294 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20295 LARGE_COMMUNITY_LIST_EXPANDED
);
20298 DEFUN (no_lcommunity_list_name_standard
,
20299 no_bgp_lcommunity_list_name_standard_cmd
,
20300 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20303 LCOMMUNITY_LIST_STR
20304 "Specify standard large-community-list\n"
20305 "Large Community list name\n"
20306 "Sequence number of an entry\n"
20307 "Sequence number\n"
20308 "Specify large community to reject\n"
20309 "Specify large community to accept\n"
20310 LCOMMUNITY_VAL_STR
)
20312 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20313 LARGE_COMMUNITY_LIST_STANDARD
);
20316 DEFUN (no_lcommunity_list_name_expanded
,
20317 no_bgp_lcommunity_list_name_expanded_cmd
,
20318 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20321 LCOMMUNITY_LIST_STR
20322 "Specify expanded large-community-list\n"
20323 "Large community list name\n"
20324 "Sequence number of an entry\n"
20325 "Sequence number\n"
20326 "Specify large community to reject\n"
20327 "Specify large community to accept\n"
20328 "An ordered list as a regular-expression\n")
20330 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20331 LARGE_COMMUNITY_LIST_EXPANDED
);
20334 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20336 struct community_entry
*entry
;
20338 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20339 if (entry
== list
->head
) {
20340 if (all_digit(list
->name
))
20341 vty_out(vty
, "Large community %s list %s\n",
20343 LARGE_COMMUNITY_LIST_STANDARD
20345 : "(expanded) access",
20349 "Named large community %s list %s\n",
20351 LARGE_COMMUNITY_LIST_STANDARD
20357 vty_out(vty
, " %s\n",
20358 community_direct_str(entry
->direct
));
20360 vty_out(vty
, " %s %s\n",
20361 community_direct_str(entry
->direct
),
20362 community_list_config_str(entry
));
20366 DEFUN (show_lcommunity_list
,
20367 show_bgp_lcommunity_list_cmd
,
20368 "show bgp large-community-list",
20371 "List large-community list\n")
20373 struct community_list
*list
;
20374 struct community_list_master
*cm
;
20376 cm
= community_list_master_lookup(bgp_clist
,
20377 LARGE_COMMUNITY_LIST_MASTER
);
20379 return CMD_SUCCESS
;
20381 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20382 lcommunity_list_show(vty
, list
);
20384 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20385 lcommunity_list_show(vty
, list
);
20387 return CMD_SUCCESS
;
20390 DEFUN (show_lcommunity_list_arg
,
20391 show_bgp_lcommunity_list_arg_cmd
,
20392 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20395 "List large-community list\n"
20396 "Large-community-list number\n"
20397 "Large-community-list name\n"
20398 "Detailed information on large-community-list\n")
20400 struct community_list
*list
;
20402 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20403 LARGE_COMMUNITY_LIST_MASTER
);
20405 vty_out(vty
, "%% Can't find large-community-list\n");
20406 return CMD_WARNING
;
20409 lcommunity_list_show(vty
, list
);
20411 return CMD_SUCCESS
;
20414 /* "extcommunity-list" keyword help string. */
20415 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20416 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20418 DEFUN (extcommunity_list_standard
,
20419 bgp_extcommunity_list_standard_cmd
,
20420 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20422 EXTCOMMUNITY_LIST_STR
20423 "Extended Community list number (standard)\n"
20424 "Specify standard extcommunity-list\n"
20425 "Community list name\n"
20426 "Sequence number of an entry\n"
20427 "Sequence number\n"
20428 "Specify community to reject\n"
20429 "Specify community to accept\n"
20430 EXTCOMMUNITY_VAL_STR
)
20432 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20434 char *cl_number_or_name
= NULL
;
20439 argv_find(argv
, argc
, "(1-99)", &idx
);
20440 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20441 cl_number_or_name
= argv
[idx
]->arg
;
20443 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20444 seq
= argv
[idx
]->arg
;
20446 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20448 argv_find(argv
, argc
, "AA:NN", &idx
);
20449 char *str
= argv_concat(argv
, argc
, idx
);
20451 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20454 XFREE(MTYPE_TMP
, str
);
20457 community_list_perror(vty
, ret
);
20458 return CMD_WARNING_CONFIG_FAILED
;
20461 return CMD_SUCCESS
;
20464 DEFUN (extcommunity_list_name_expanded
,
20465 bgp_extcommunity_list_name_expanded_cmd
,
20466 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20468 EXTCOMMUNITY_LIST_STR
20469 "Extended Community list number (expanded)\n"
20470 "Specify expanded extcommunity-list\n"
20471 "Extended Community list name\n"
20472 "Sequence number of an entry\n"
20473 "Sequence number\n"
20474 "Specify community to reject\n"
20475 "Specify community to accept\n"
20476 "An ordered list as a regular-expression\n")
20478 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20480 char *cl_number_or_name
= NULL
;
20484 argv_find(argv
, argc
, "(100-500)", &idx
);
20485 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20486 cl_number_or_name
= argv
[idx
]->arg
;
20488 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20489 seq
= argv
[idx
]->arg
;
20491 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20493 argv_find(argv
, argc
, "LINE", &idx
);
20494 char *str
= argv_concat(argv
, argc
, idx
);
20496 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20499 XFREE(MTYPE_TMP
, str
);
20502 community_list_perror(vty
, ret
);
20503 return CMD_WARNING_CONFIG_FAILED
;
20506 return CMD_SUCCESS
;
20509 DEFUN (no_extcommunity_list_standard_all
,
20510 no_bgp_extcommunity_list_standard_all_cmd
,
20511 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20514 EXTCOMMUNITY_LIST_STR
20515 "Extended Community list number (standard)\n"
20516 "Specify standard extcommunity-list\n"
20517 "Community list name\n"
20518 "Sequence number of an entry\n"
20519 "Sequence number\n"
20520 "Specify community to reject\n"
20521 "Specify community to accept\n"
20522 EXTCOMMUNITY_VAL_STR
)
20524 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20526 char *cl_number_or_name
= NULL
;
20531 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20532 seq
= argv
[idx
]->arg
;
20535 argv_find(argv
, argc
, "permit", &idx
);
20536 argv_find(argv
, argc
, "deny", &idx
);
20538 direct
= argv_find(argv
, argc
, "permit", &idx
)
20543 argv_find(argv
, argc
, "AA:NN", &idx
);
20544 str
= argv_concat(argv
, argc
, idx
);
20548 argv_find(argv
, argc
, "(1-99)", &idx
);
20549 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20550 cl_number_or_name
= argv
[idx
]->arg
;
20552 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20553 seq
, direct
, style
);
20555 XFREE(MTYPE_TMP
, str
);
20558 community_list_perror(vty
, ret
);
20559 return CMD_WARNING_CONFIG_FAILED
;
20562 return CMD_SUCCESS
;
20565 ALIAS(no_extcommunity_list_standard_all
,
20566 no_bgp_extcommunity_list_standard_all_list_cmd
,
20567 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20568 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20569 "Extended Community list number (standard)\n"
20570 "Specify standard extcommunity-list\n"
20571 "Community list name\n")
20573 DEFUN (no_extcommunity_list_expanded_all
,
20574 no_bgp_extcommunity_list_expanded_all_cmd
,
20575 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20578 EXTCOMMUNITY_LIST_STR
20579 "Extended Community list number (expanded)\n"
20580 "Specify expanded extcommunity-list\n"
20581 "Extended Community list name\n"
20582 "Sequence number of an entry\n"
20583 "Sequence number\n"
20584 "Specify community to reject\n"
20585 "Specify community to accept\n"
20586 "An ordered list as a regular-expression\n")
20588 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20590 char *cl_number_or_name
= NULL
;
20595 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20596 seq
= argv
[idx
]->arg
;
20599 argv_find(argv
, argc
, "permit", &idx
);
20600 argv_find(argv
, argc
, "deny", &idx
);
20603 direct
= argv_find(argv
, argc
, "permit", &idx
)
20608 argv_find(argv
, argc
, "LINE", &idx
);
20609 str
= argv_concat(argv
, argc
, idx
);
20613 argv_find(argv
, argc
, "(100-500)", &idx
);
20614 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20615 cl_number_or_name
= argv
[idx
]->arg
;
20617 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20618 seq
, direct
, style
);
20620 XFREE(MTYPE_TMP
, str
);
20623 community_list_perror(vty
, ret
);
20624 return CMD_WARNING_CONFIG_FAILED
;
20627 return CMD_SUCCESS
;
20630 ALIAS(no_extcommunity_list_expanded_all
,
20631 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20632 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20633 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20634 "Extended Community list number (expanded)\n"
20635 "Specify expanded extcommunity-list\n"
20636 "Extended Community list name\n")
20638 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20640 struct community_entry
*entry
;
20642 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20643 if (entry
== list
->head
) {
20644 if (all_digit(list
->name
))
20645 vty_out(vty
, "Extended community %s list %s\n",
20646 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20648 : "(expanded) access",
20652 "Named extended community %s list %s\n",
20653 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20659 vty_out(vty
, " %s\n",
20660 community_direct_str(entry
->direct
));
20662 vty_out(vty
, " %s %s\n",
20663 community_direct_str(entry
->direct
),
20664 community_list_config_str(entry
));
20668 DEFUN (show_extcommunity_list
,
20669 show_bgp_extcommunity_list_cmd
,
20670 "show bgp extcommunity-list",
20673 "List extended-community list\n")
20675 struct community_list
*list
;
20676 struct community_list_master
*cm
;
20678 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20680 return CMD_SUCCESS
;
20682 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20683 extcommunity_list_show(vty
, list
);
20685 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20686 extcommunity_list_show(vty
, list
);
20688 return CMD_SUCCESS
;
20691 DEFUN (show_extcommunity_list_arg
,
20692 show_bgp_extcommunity_list_arg_cmd
,
20693 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20696 "List extended-community list\n"
20697 "Extcommunity-list number\n"
20698 "Extcommunity-list name\n"
20699 "Detailed information on extcommunity-list\n")
20701 int idx_comm_list
= 3;
20702 struct community_list
*list
;
20704 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20705 EXTCOMMUNITY_LIST_MASTER
);
20707 vty_out(vty
, "%% Can't find extcommunity-list\n");
20708 return CMD_WARNING
;
20711 extcommunity_list_show(vty
, list
);
20713 return CMD_SUCCESS
;
20716 /* Display community-list and extcommunity-list configuration. */
20717 static int community_list_config_write(struct vty
*vty
)
20719 struct community_list
*list
;
20720 struct community_entry
*entry
;
20721 struct community_list_master
*cm
;
20724 /* Community-list. */
20725 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20727 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20728 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20730 "bgp community-list %s seq %" PRId64
" %s %s\n",
20731 list
->name
, entry
->seq
,
20732 community_direct_str(entry
->direct
),
20733 community_list_config_str(entry
));
20736 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20737 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20739 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20740 entry
->style
== COMMUNITY_LIST_STANDARD
20743 list
->name
, entry
->seq
,
20744 community_direct_str(entry
->direct
),
20745 community_list_config_str(entry
));
20749 /* Extcommunity-list. */
20750 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20752 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20753 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20755 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20756 list
->name
, entry
->seq
,
20757 community_direct_str(entry
->direct
),
20758 community_list_config_str(entry
));
20761 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20762 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20764 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20765 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20768 list
->name
, entry
->seq
,
20769 community_direct_str(entry
->direct
),
20770 community_list_config_str(entry
));
20775 /* lcommunity-list. */
20776 cm
= community_list_master_lookup(bgp_clist
,
20777 LARGE_COMMUNITY_LIST_MASTER
);
20779 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20780 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20782 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20783 list
->name
, entry
->seq
,
20784 community_direct_str(entry
->direct
),
20785 community_list_config_str(entry
));
20788 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20789 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20791 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20793 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20796 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20797 community_list_config_str(entry
));
20804 static int community_list_config_write(struct vty
*vty
);
20805 static struct cmd_node community_list_node
= {
20806 .name
= "community list",
20807 .node
= COMMUNITY_LIST_NODE
,
20809 .config_write
= community_list_config_write
,
20812 static void community_list_vty(void)
20814 install_node(&community_list_node
);
20816 /* Community-list. */
20817 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20818 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20819 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20820 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20821 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20822 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20823 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20824 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20826 /* Extcommunity-list. */
20827 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20828 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20829 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20830 install_element(CONFIG_NODE
,
20831 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20832 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20833 install_element(CONFIG_NODE
,
20834 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20835 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20836 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20838 /* Large Community List */
20839 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20840 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20841 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20842 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20843 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20844 install_element(CONFIG_NODE
,
20845 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20846 install_element(CONFIG_NODE
,
20847 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20848 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20849 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20850 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20851 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20852 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20853 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20855 bgp_community_list_command_completion_setup();
20858 static struct cmd_node community_alias_node
= {
20859 .name
= "community alias",
20860 .node
= COMMUNITY_ALIAS_NODE
,
20862 .config_write
= bgp_community_alias_write
,
20865 void community_alias_vty(void)
20867 install_node(&community_alias_node
);
20869 /* Community-list. */
20870 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20872 bgp_community_alias_command_completion_setup();