2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
81 #include "bgpd/bgp_orr.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
129 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
130 { .val_bool
= false, .match_version
= "< 8.3", },
131 { .val_bool
= true },
133 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
134 { .val_bool
= false, .match_version
= "< 8.3", },
135 { .val_bool
= true },
138 DEFINE_HOOK(bgp_inst_config_write
,
139 (struct bgp
*bgp
, struct vty
*vty
),
141 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
142 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 /* Show BGP peer's information. */
157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
158 struct prefix
*range
, int exact
);
160 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
165 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
168 afi_t afi
, bool use_json
);
170 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
176 return BGP_IPV4_NODE
;
178 return BGP_IPV4M_NODE
;
179 case SAFI_LABELED_UNICAST
:
180 return BGP_IPV4L_NODE
;
182 return BGP_VPNV4_NODE
;
184 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
192 return BGP_IPV6_NODE
;
194 return BGP_IPV6M_NODE
;
195 case SAFI_LABELED_UNICAST
:
196 return BGP_IPV6L_NODE
;
198 return BGP_VPNV6_NODE
;
200 return BGP_FLOWSPECV6_NODE
;
203 return BGP_IPV4_NODE
;
206 return BGP_EVPN_NODE
;
209 // We should never be here but to clarify the switch statement..
210 return BGP_IPV4_NODE
;
213 // Impossible to happen
214 return BGP_IPV4_NODE
;
217 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
220 if (safi
== SAFI_UNICAST
)
221 return "IPv4 Unicast";
222 if (safi
== SAFI_MULTICAST
)
223 return "IPv4 Multicast";
224 if (safi
== SAFI_LABELED_UNICAST
)
225 return "IPv4 Labeled Unicast";
226 if (safi
== SAFI_MPLS_VPN
)
228 if (safi
== SAFI_ENCAP
)
230 if (safi
== SAFI_FLOWSPEC
)
231 return "IPv4 Flowspec";
232 } else if (afi
== AFI_IP6
) {
233 if (safi
== SAFI_UNICAST
)
234 return "IPv6 Unicast";
235 if (safi
== SAFI_MULTICAST
)
236 return "IPv6 Multicast";
237 if (safi
== SAFI_LABELED_UNICAST
)
238 return "IPv6 Labeled Unicast";
239 if (safi
== SAFI_MPLS_VPN
)
241 if (safi
== SAFI_ENCAP
)
243 if (safi
== SAFI_FLOWSPEC
)
244 return "IPv6 Flowspec";
245 } else if (afi
== AFI_L2VPN
) {
246 if (safi
== SAFI_EVPN
)
254 * Please note that we have intentionally camelCased
255 * the return strings here. So if you want
256 * to use this function, please ensure you
257 * are doing this within json output
259 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
262 if (safi
== SAFI_UNICAST
)
263 return "ipv4Unicast";
264 if (safi
== SAFI_MULTICAST
)
265 return "ipv4Multicast";
266 if (safi
== SAFI_LABELED_UNICAST
)
267 return "ipv4LabeledUnicast";
268 if (safi
== SAFI_MPLS_VPN
)
270 if (safi
== SAFI_ENCAP
)
272 if (safi
== SAFI_FLOWSPEC
)
273 return "ipv4Flowspec";
274 } else if (afi
== AFI_IP6
) {
275 if (safi
== SAFI_UNICAST
)
276 return "ipv6Unicast";
277 if (safi
== SAFI_MULTICAST
)
278 return "ipv6Multicast";
279 if (safi
== SAFI_LABELED_UNICAST
)
280 return "ipv6LabeledUnicast";
281 if (safi
== SAFI_MPLS_VPN
)
283 if (safi
== SAFI_ENCAP
)
285 if (safi
== SAFI_FLOWSPEC
)
286 return "ipv6Flowspec";
287 } else if (afi
== AFI_L2VPN
) {
288 if (safi
== SAFI_EVPN
)
295 /* unset srv6 locator */
296 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
299 struct listnode
*node
, *nnode
;
300 struct srv6_locator_chunk
*chunk
;
301 struct bgp_srv6_function
*func
;
304 /* release chunk notification via ZAPI */
305 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
306 bgp
->srv6_locator_name
);
311 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
312 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
313 srv6_locator_chunk_free(chunk
);
316 /* refresh functions */
317 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
318 listnode_delete(bgp
->srv6_functions
, func
);
319 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
322 /* refresh tovpn_sid */
323 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
324 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
327 /* refresh vpnv4 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
331 /* refresh vpnv6 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
336 /* update vpn bgp processes */
337 vpn_leak_postchange_all();
339 /* refresh tovpn_sid_locator */
340 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
341 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
344 /* refresh vpnv4 tovpn_sid_locator */
345 XFREE(MTYPE_BGP_SRV6_SID
,
346 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
348 /* refresh vpnv6 tovpn_sid_locator */
349 XFREE(MTYPE_BGP_SRV6_SID
,
350 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
353 /* clear locator name */
354 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
359 /* Utility function to get address family from current node. */
360 afi_t
bgp_node_afi(struct vty
*vty
)
368 case BGP_FLOWSPECV6_NODE
:
381 /* Utility function to get subsequent address family from current
383 safi_t
bgp_node_safi(struct vty
*vty
)
389 safi
= SAFI_MPLS_VPN
;
393 safi
= SAFI_MULTICAST
;
400 safi
= SAFI_LABELED_UNICAST
;
402 case BGP_FLOWSPECV4_NODE
:
403 case BGP_FLOWSPECV6_NODE
:
404 safi
= SAFI_FLOWSPEC
;
414 * Converts an AFI in string form to afi_t
416 * @param afi string, one of
420 * @return the corresponding afi_t
422 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
424 afi_t afi
= AFI_MAX
; /* unknown */
425 if (strmatch(afi_str
, "ipv4"))
427 else if (strmatch(afi_str
, "ipv6"))
429 else if (strmatch(afi_str
, "l2vpn"))
434 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
438 if (argv_find(argv
, argc
, "ipv4", index
)) {
442 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
446 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
454 /* supports <unicast|multicast|vpn|labeled-unicast> */
455 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
457 safi_t safi
= SAFI_MAX
; /* unknown */
458 if (strmatch(safi_str
, "multicast"))
459 safi
= SAFI_MULTICAST
;
460 else if (strmatch(safi_str
, "unicast"))
462 else if (strmatch(safi_str
, "vpn"))
463 safi
= SAFI_MPLS_VPN
;
464 else if (strmatch(safi_str
, "evpn"))
466 else if (strmatch(safi_str
, "labeled-unicast"))
467 safi
= SAFI_LABELED_UNICAST
;
468 else if (strmatch(safi_str
, "flowspec"))
469 safi
= SAFI_FLOWSPEC
;
473 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
477 if (argv_find(argv
, argc
, "unicast", index
)) {
480 *safi
= SAFI_UNICAST
;
481 } else if (argv_find(argv
, argc
, "multicast", index
)) {
484 *safi
= SAFI_MULTICAST
;
485 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
488 *safi
= SAFI_LABELED_UNICAST
;
489 } else if (argv_find(argv
, argc
, "vpn", index
)) {
492 *safi
= SAFI_MPLS_VPN
;
493 } else if (argv_find(argv
, argc
, "evpn", index
)) {
497 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
500 *safi
= SAFI_FLOWSPEC
;
506 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
509 * address-family identifier
512 * subsequent address-family identifier
515 * default_af string corresponding to the supplied afi/safi pair.
516 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
519 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
525 return "ipv4-unicast";
527 return "ipv4-multicast";
532 case SAFI_LABELED_UNICAST
:
533 return "ipv4-labeled-unicast";
535 return "ipv4-flowspec";
537 return "unknown-afi/safi";
543 return "ipv6-unicast";
545 return "ipv6-multicast";
550 case SAFI_LABELED_UNICAST
:
551 return "ipv6-labeled-unicast";
553 return "ipv6-flowspec";
555 return "unknown-afi/safi";
563 return "unknown-afi/safi";
567 return "unknown-afi/safi";
569 /* all AFIs are accounted for above, so this shouldn't happen */
570 return "unknown-afi/safi";
573 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
574 enum bgp_instance_type inst_type
)
576 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
578 if (ret
== BGP_CREATED
) {
579 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
580 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
582 if (DFLT_BGP_IMPORT_CHECK
)
583 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
584 if (DFLT_BGP_SHOW_HOSTNAME
)
585 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
586 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
587 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
588 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
589 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
590 if (DFLT_BGP_DETERMINISTIC_MED
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
592 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
594 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
596 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
598 if (DFLT_BGP_HARD_ADMIN_RESET
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
607 * bgp_vty_find_and_parse_afi_safi_bgp
609 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
610 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
611 * to appropriate values for the calling function. This is to allow the
612 * calling function to make decisions appropriate for the show command
613 * that is being parsed.
615 * The show commands are generally of the form:
616 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
617 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
619 * Since we use argv_find if the show command in particular doesn't have:
621 * [<view|vrf> VIEWVRFNAME]
622 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
623 * The command parsing should still be ok.
625 * vty -> The vty for the command so we can output some useful data in
626 * the event of a parse error in the vrf.
627 * argv -> The command tokens
628 * argc -> How many command tokens we have
629 * idx -> The current place in the command, generally should be 0 for this
631 * afi -> The parsed afi if it was included in the show command, returned here
632 * safi -> The parsed safi if it was included in the show command, returned here
633 * bgp -> Pointer to the bgp data structure we need to fill in.
634 * use_json -> json is configured or not
636 * The function returns the correct location in the parse tree for the
639 * Returns 0 for failure to parse correctly, else the idx position of where
640 * it found the last token.
642 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
643 struct cmd_token
**argv
, int argc
,
644 int *idx
, afi_t
*afi
, safi_t
*safi
,
645 struct bgp
**bgp
, bool use_json
)
647 char *vrf_name
= NULL
;
653 if (argv_find(argv
, argc
, "ip", idx
))
656 if (argv_find(argv
, argc
, "view", idx
))
657 vrf_name
= argv
[*idx
+ 1]->arg
;
658 else if (argv_find(argv
, argc
, "vrf", idx
)) {
659 vrf_name
= argv
[*idx
+ 1]->arg
;
660 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
664 if (strmatch(vrf_name
, "all"))
667 *bgp
= bgp_lookup_by_name(vrf_name
);
670 json_object
*json
= NULL
;
671 json
= json_object_new_object();
672 json_object_string_add(
674 "View/Vrf is unknown");
678 vty_out(vty
, "View/Vrf %s is unknown\n",
685 *bgp
= bgp_get_default();
688 json_object
*json
= NULL
;
689 json
= json_object_new_object();
690 json_object_string_add(
692 "Default BGP instance not found");
697 "Default BGP instance not found\n");
703 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
704 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
710 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
712 struct interface
*ifp
= NULL
;
713 struct listnode
*node
;
714 struct bgp_listener
*listener
;
715 union sockunion all_su
;
717 if (su
->sa
.sa_family
== AF_INET
) {
718 (void)str2sockunion("0.0.0.0", &all_su
);
719 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
720 } else if (su
->sa
.sa_family
== AF_INET6
) {
721 (void)str2sockunion("::", &all_su
);
722 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
723 su
->sin6
.sin6_scope_id
,
728 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
729 if (sockunion_family(su
) !=
730 sockunion_family(&listener
->su
))
733 /* If 0.0.0.0/:: is a listener, then treat as self and
736 if (!sockunion_cmp(&listener
->su
, su
) ||
737 !sockunion_cmp(&listener
->su
, &all_su
))
745 /* Utility function for looking up peer from VTY. */
746 /* This is used only for configuration, so disallow if attempted on
747 * a dynamic neighbor.
749 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
751 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
760 ret
= str2sockunion(ip_str
, &su
);
762 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
764 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
767 "%% Malformed address or name: %s\n",
773 peer
= peer_lookup(bgp
, &su
);
776 "%% Specify remote-as or peer-group commands first\n");
779 if (peer_dynamic_neighbor(peer
)) {
781 "%% Operation not allowed on a dynamic neighbor\n");
788 /* Utility function for looking up peer or peer group. */
789 /* This is used only for configuration, so disallow if attempted on
790 * a dynamic neighbor.
792 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
794 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
797 struct peer
*peer
= NULL
;
798 struct peer_group
*group
= NULL
;
804 ret
= str2sockunion(peer_str
, &su
);
806 /* IP address, locate peer. */
807 peer
= peer_lookup(bgp
, &su
);
809 /* Not IP, could match either peer configured on interface or a
811 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
813 group
= peer_group_lookup(bgp
, peer_str
);
817 if (peer_dynamic_neighbor(peer
)) {
819 "%% Operation not allowed on a dynamic neighbor\n");
829 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
834 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
836 const char *str
= NULL
;
841 case BGP_GR_NO_OPERATION
:
843 case BGP_ERR_INVALID_VALUE
:
844 str
= "Invalid value";
846 case BGP_ERR_INVALID_FLAG
:
847 str
= "Invalid flag";
849 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
850 str
= "Peer-group has been shutdown. Activate the peer-group first";
852 case BGP_ERR_PEER_FLAG_CONFLICT
:
853 str
= "Can't set override-capability and strict-capability-match at the same time";
855 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
856 str
= "Specify remote-as or peer-group remote AS first";
858 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
859 str
= "Cannot change the peer-group. Deconfigure first";
861 case BGP_ERR_PEER_GROUP_MISMATCH
:
862 str
= "Peer is not a member of this peer-group";
864 case BGP_ERR_PEER_FILTER_CONFLICT
:
865 str
= "Prefix/distribute list can not co-exist";
867 case BGP_ERR_NOT_INTERNAL_PEER
:
868 str
= "Invalid command. Not an internal neighbor";
870 case BGP_ERR_REMOVE_PRIVATE_AS
:
871 str
= "remove-private-AS cannot be configured for IBGP peers";
873 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
874 str
= "Cannot have local-as same as BGP AS number";
876 case BGP_ERR_TCPSIG_FAILED
:
877 str
= "Error while applying TCP-Sig to session(s)";
879 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
880 str
= "ebgp-multihop and ttl-security cannot be configured together";
882 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
883 str
= "ttl-security only allowed for EBGP peers";
885 case BGP_ERR_AS_OVERRIDE
:
886 str
= "as-override cannot be configured for IBGP peers";
888 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
889 str
= "Invalid limit for number of dynamic neighbors";
891 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
892 str
= "Dynamic neighbor listen range already exists";
894 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
895 str
= "Operation not allowed on a dynamic neighbor";
897 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
898 str
= "Operation not allowed on a directly connected neighbor";
900 case BGP_ERR_PEER_SAFI_CONFLICT
:
901 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
903 case BGP_ERR_GR_INVALID_CMD
:
904 str
= "The Graceful Restart command used is not valid at this moment.";
906 case BGP_ERR_GR_OPERATION_FAILED
:
907 str
= "The Graceful Restart Operation failed due to an err.";
909 case BGP_ERR_PEER_GROUP_MEMBER
:
910 str
= "Peer-group member cannot override remote-as of peer-group.";
912 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
913 str
= "Peer-group members must be all internal or all external.";
915 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
916 str
= "Range specified cannot be deleted because it is not part of current config.";
918 case BGP_ERR_INSTANCE_MISMATCH
:
919 str
= "Instance specified does not match the current instance.";
921 case BGP_ERR_NO_INTERFACE_CONFIG
:
922 str
= "Interface specified is not being used for interface based peer.";
924 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
925 str
= "No configuration already specified for soft reconfiguration.";
927 case BGP_ERR_AS_MISMATCH
:
928 str
= "BGP is already running.";
930 case BGP_ERR_AF_UNCONFIGURED
:
931 str
= "AFI/SAFI specified is not currently configured.";
933 case BGP_ERR_INVALID_AS
:
934 str
= "Confederation AS specified is the same AS as our AS.";
936 case BGP_ERR_INVALID_ROLE_NAME
:
937 str
= "Invalid role name";
939 case BGP_ERR_INVALID_INTERNAL_ROLE
:
940 str
= "External roles can be set only on eBGP session";
942 case BGP_ERR_PEER_ORR_CONFIGURED
:
943 str
= "Deconfigure optimal-route-reflection on this peer first";
947 vty_out(vty
, "%% %s\n", str
);
948 return CMD_WARNING_CONFIG_FAILED
;
953 /* BGP clear sort. */
962 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
963 safi_t safi
, int error
)
966 case BGP_ERR_AF_UNCONFIGURED
:
969 "%% BGP: Enable %s address family for the neighbor %s\n",
970 get_afi_safi_str(afi
, safi
, false), peer
->host
);
973 "%% BGP: Enable %s address family for the neighbor %s",
974 get_afi_safi_str(afi
, safi
, false), peer
->host
);
976 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
979 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
983 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
991 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
992 struct listnode
**nnode
, enum bgp_clear_type stype
)
997 /* if afi/.safi not specified, spin thru all of them */
998 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1001 enum bgp_af_index index
;
1003 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1004 paf
= peer
->peer_af_array
[index
];
1008 if (paf
&& paf
->subgroup
)
1009 SET_FLAG(paf
->subgroup
->sflags
,
1010 SUBGRP_STATUS_FORCE_UPDATES
);
1013 tmp_safi
= paf
->safi
;
1014 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1017 if (stype
== BGP_CLEAR_SOFT_NONE
)
1018 ret
= peer_clear(peer
, nnode
);
1020 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1023 /* if afi specified and safi not, spin thru safis on this afi */
1024 } else if (safi
== SAFI_UNSPEC
) {
1027 for (tmp_safi
= SAFI_UNICAST
;
1028 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1029 if (!peer
->afc
[afi
][tmp_safi
])
1032 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1033 if (paf
&& paf
->subgroup
)
1034 SET_FLAG(paf
->subgroup
->sflags
,
1035 SUBGRP_STATUS_FORCE_UPDATES
);
1037 if (stype
== BGP_CLEAR_SOFT_NONE
)
1038 ret
= peer_clear(peer
, nnode
);
1040 ret
= peer_clear_soft(peer
, afi
,
1043 /* both afi/safi specified, let the caller know if not defined */
1045 if (!peer
->afc
[afi
][safi
])
1048 paf
= peer_af_find(peer
, afi
, safi
);
1049 if (paf
&& paf
->subgroup
)
1050 SET_FLAG(paf
->subgroup
->sflags
,
1051 SUBGRP_STATUS_FORCE_UPDATES
);
1053 if (stype
== BGP_CLEAR_SOFT_NONE
)
1054 ret
= peer_clear(peer
, nnode
);
1056 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1062 /* `clear ip bgp' functions. */
1063 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1064 enum clear_sort sort
, enum bgp_clear_type stype
,
1071 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1073 /* Clear all neighbors. */
1075 * Pass along pointer to next node to peer_clear() when walking all
1076 * nodes on the BGP instance as that may get freed if it is a
1079 if (sort
== clear_all
) {
1080 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1082 bgp_peer_gr_flags_update(peer
);
1084 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1085 gr_router_detected
= true;
1087 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1091 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1094 if (gr_router_detected
1095 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1096 bgp_zebra_send_capabilities(bgp
, false);
1097 } else if (!gr_router_detected
1098 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1099 bgp_zebra_send_capabilities(bgp
, true);
1102 /* This is to apply read-only mode on this clear. */
1103 if (stype
== BGP_CLEAR_SOFT_NONE
)
1104 bgp
->update_delay_over
= 0;
1109 /* Clear specified neighbor. */
1110 if (sort
== clear_peer
) {
1113 /* Make sockunion for lookup. */
1114 ret
= str2sockunion(arg
, &su
);
1116 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1118 peer
= peer_lookup_by_hostname(bgp
, arg
);
1121 "Malformed address or name: %s\n",
1127 peer
= peer_lookup(bgp
, &su
);
1130 "%% BGP: Unknown neighbor - \"%s\"\n",
1136 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1137 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1139 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1141 /* if afi/safi not defined for this peer, let caller know */
1143 ret
= BGP_ERR_AF_UNCONFIGURED
;
1146 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1151 /* Clear all neighbors belonging to a specific peer-group. */
1152 if (sort
== clear_group
) {
1153 struct peer_group
*group
;
1155 group
= peer_group_lookup(bgp
, arg
);
1157 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1161 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1162 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1165 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1172 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1173 get_afi_safi_str(afi
, safi
, false), arg
);
1178 /* Clear all external (eBGP) neighbors. */
1179 if (sort
== clear_external
) {
1180 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1181 if (peer
->sort
== BGP_PEER_IBGP
)
1184 bgp_peer_gr_flags_update(peer
);
1186 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1187 gr_router_detected
= true;
1189 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1192 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1197 if (gr_router_detected
1198 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1199 bgp_zebra_send_capabilities(bgp
, false);
1200 } else if (!gr_router_detected
1201 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1202 bgp_zebra_send_capabilities(bgp
, true);
1207 "%% BGP: No external %s peer is configured\n",
1208 get_afi_safi_str(afi
, safi
, false));
1213 /* Clear all neighbors belonging to a specific AS. */
1214 if (sort
== clear_as
) {
1215 as_t as
= strtoul(arg
, NULL
, 10);
1217 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1221 bgp_peer_gr_flags_update(peer
);
1223 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1224 gr_router_detected
= true;
1226 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1229 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1234 if (gr_router_detected
1235 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1236 bgp_zebra_send_capabilities(bgp
, false);
1237 } else if (!gr_router_detected
1238 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1239 bgp_zebra_send_capabilities(bgp
, true);
1244 "%% BGP: No %s peer is configured with AS %s\n",
1245 get_afi_safi_str(afi
, safi
, false), arg
);
1253 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1254 safi_t safi
, enum clear_sort sort
,
1255 enum bgp_clear_type stype
, const char *arg
)
1259 /* BGP structure lookup. */
1261 bgp
= bgp_lookup_by_name(name
);
1263 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1267 bgp
= bgp_get_default();
1269 vty_out(vty
, "No BGP process is configured\n");
1274 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1277 /* clear soft inbound */
1278 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1283 FOREACH_AFI_SAFI (afi
, safi
)
1284 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1285 BGP_CLEAR_SOFT_IN
, NULL
);
1288 /* clear soft outbound */
1289 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1294 FOREACH_AFI_SAFI (afi
, safi
)
1295 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1296 BGP_CLEAR_SOFT_OUT
, NULL
);
1300 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1302 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1305 #ifndef VTYSH_EXTRACT_PL
1306 #include "bgpd/bgp_vty_clippy.c"
1309 DEFUN_HIDDEN (bgp_local_mac
,
1311 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1313 "Local MAC config\n"
1314 "VxLAN Network Identifier\n"
1318 "mac-mobility sequence\n"
1328 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1329 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1330 vty_out(vty
, "%% Malformed MAC address\n");
1333 memset(&ip
, 0, sizeof(ip
));
1334 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1336 bgp
= bgp_get_default();
1338 vty_out(vty
, "Default BGP instance is not there\n");
1342 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1345 vty_out(vty
, "Internal error\n");
1352 DEFUN_HIDDEN (no_bgp_local_mac
,
1353 no_bgp_local_mac_cmd
,
1354 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1357 "Local MAC config\n"
1358 "VxLAN Network Identifier\n"
1369 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1370 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1371 vty_out(vty
, "%% Malformed MAC address\n");
1374 memset(&ip
, 0, sizeof(ip
));
1376 bgp
= bgp_get_default();
1378 vty_out(vty
, "Default BGP instance is not there\n");
1382 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1384 vty_out(vty
, "Internal error\n");
1391 DEFUN (no_synchronization
,
1392 no_synchronization_cmd
,
1393 "no synchronization",
1395 "Perform IGP synchronization\n")
1400 DEFUN (no_auto_summary
,
1401 no_auto_summary_cmd
,
1404 "Enable automatic network number summarization\n")
1409 /* "router bgp" commands. */
1410 DEFUN_NOSH (router_bgp
,
1412 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1416 BGP_INSTANCE_HELP_STR
)
1419 int idx_view_vrf
= 3;
1425 const char *name
= NULL
;
1426 enum bgp_instance_type inst_type
;
1428 // "router bgp" without an ASN
1430 // Pending: Make VRF option available for ASN less config
1431 bgp
= bgp_get_default();
1434 vty_out(vty
, "%% No BGP process is configured\n");
1435 return CMD_WARNING_CONFIG_FAILED
;
1438 if (listcount(bm
->bgp
) > 1) {
1439 vty_out(vty
, "%% Please specify ASN and VRF\n");
1440 return CMD_WARNING_CONFIG_FAILED
;
1446 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1448 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1449 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1450 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1452 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1454 name
= argv
[idx_vrf
]->arg
;
1456 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1457 if (strmatch(name
, VRF_DEFAULT_NAME
))
1460 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1461 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1462 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1465 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1466 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1468 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1470 case BGP_ERR_AS_MISMATCH
:
1471 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1472 return CMD_WARNING_CONFIG_FAILED
;
1473 case BGP_ERR_INSTANCE_MISMATCH
:
1475 "BGP instance name and AS number mismatch\n");
1477 "BGP instance is already running; AS is %u\n",
1479 return CMD_WARNING_CONFIG_FAILED
;
1483 * If we just instantiated the default instance, complete
1484 * any pending VRF-VPN leaking that was configured via
1485 * earlier "router bgp X vrf FOO" blocks.
1487 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1488 vpn_leak_postchange_all();
1490 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1491 bgp_vpn_leak_export(bgp
);
1492 /* Pending: handle when user tries to change a view to vrf n vv.
1496 /* unset the auto created flag as the user config is now present */
1497 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1498 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1503 /* "no router bgp" commands. */
1504 DEFUN (no_router_bgp
,
1506 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1511 BGP_INSTANCE_HELP_STR
)
1517 const char *name
= NULL
;
1519 // "no router bgp" without an ASN
1521 // Pending: Make VRF option available for ASN less config
1522 bgp
= bgp_get_default();
1525 vty_out(vty
, "%% No BGP process is configured\n");
1526 return CMD_WARNING_CONFIG_FAILED
;
1529 if (listcount(bm
->bgp
) > 1) {
1530 vty_out(vty
, "%% Please specify ASN and VRF\n");
1531 return CMD_WARNING_CONFIG_FAILED
;
1535 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1537 return CMD_WARNING_CONFIG_FAILED
;
1540 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1543 name
= argv
[idx_vrf
]->arg
;
1544 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1545 && strmatch(name
, VRF_DEFAULT_NAME
))
1549 /* Lookup bgp structure. */
1550 bgp
= bgp_lookup(as
, name
);
1552 vty_out(vty
, "%% Can't find BGP instance\n");
1553 return CMD_WARNING_CONFIG_FAILED
;
1557 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1559 return CMD_WARNING_CONFIG_FAILED
;
1562 /* Cannot delete default instance if vrf instances exist */
1563 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1564 struct listnode
*node
;
1565 struct bgp
*tmp_bgp
;
1567 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1568 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1570 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1571 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1572 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1573 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1574 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1575 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1576 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1577 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1578 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1579 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1581 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1582 (bgp
== bgp_get_evpn() &&
1583 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1584 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1585 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1586 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1587 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1588 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1589 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1590 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1591 (hashcount(tmp_bgp
->vnihash
))) {
1593 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1594 return CMD_WARNING_CONFIG_FAILED
;
1605 /* bgp session-dscp */
1607 DEFPY (bgp_session_dscp
,
1608 bgp_session_dscp_cmd
,
1609 "bgp session-dscp (0-63)$dscp",
1611 "Override default (C6) bgp TCP session DSCP value\n"
1612 "Manually configured dscp parameter\n")
1614 bm
->tcp_dscp
= dscp
<< 2;
1619 DEFPY (no_bgp_session_dscp
,
1620 no_bgp_session_dscp_cmd
,
1621 "no bgp session-dscp [(0-63)]",
1624 "Override default (C6) bgp TCP session DSCP value\n"
1625 "Manually configured dscp parameter\n")
1627 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1632 /* BGP router-id. */
1634 DEFPY (bgp_router_id
,
1636 "bgp router-id A.B.C.D",
1638 "Override configured router identifier\n"
1639 "Manually configured router identifier\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1642 bgp_router_id_static_set(bgp
, router_id
);
1646 DEFPY (no_bgp_router_id
,
1647 no_bgp_router_id_cmd
,
1648 "no bgp router-id [A.B.C.D]",
1651 "Override configured router identifier\n"
1652 "Manually configured router identifier\n")
1654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1656 if (router_id_str
) {
1657 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1658 vty_out(vty
, "%% BGP router-id doesn't match\n");
1659 return CMD_WARNING_CONFIG_FAILED
;
1663 router_id
.s_addr
= 0;
1664 bgp_router_id_static_set(bgp
, router_id
);
1669 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1670 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1672 "Add community specific parameters\n"
1673 "Create an alias for a community\n"
1674 "Community (AA:BB or AA:BB:CC)\n"
1677 struct community_alias ca
= {};
1678 struct community_alias
*lookup_community
;
1679 struct community_alias
*lookup_alias
;
1680 struct community
*comm
;
1681 struct lcommunity
*lcomm
;
1682 uint8_t invalid
= 0;
1684 comm
= community_str2com(community
);
1687 community_free(&comm
);
1689 lcomm
= lcommunity_str2com(community
);
1692 lcommunity_free(&lcomm
);
1695 vty_out(vty
, "Invalid community format\n");
1699 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1700 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1702 lookup_community
= bgp_ca_community_lookup(&ca
);
1703 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1706 bgp_ca_alias_delete(&ca
);
1707 bgp_ca_community_delete(&ca
);
1710 /* Lookup if community hash table has an item
1711 * with the same alias name.
1713 strlcpy(ca
.community
, lookup_alias
->community
,
1714 sizeof(ca
.community
));
1715 if (bgp_ca_community_lookup(&ca
)) {
1717 "community (%s) already has this alias (%s)\n",
1718 lookup_alias
->community
,
1719 lookup_alias
->alias
);
1722 bgp_ca_alias_delete(&ca
);
1725 if (lookup_community
) {
1726 /* Lookup if alias hash table has an item
1727 * with the same community.
1729 strlcpy(ca
.alias
, lookup_community
->alias
,
1731 if (bgp_ca_alias_lookup(&ca
)) {
1733 "alias (%s) already has this community (%s)\n",
1734 lookup_community
->alias
,
1735 lookup_community
->community
);
1738 bgp_ca_community_delete(&ca
);
1741 bgp_ca_alias_insert(&ca
);
1742 bgp_ca_community_insert(&ca
);
1748 DEFPY (bgp_global_suppress_fib_pending
,
1749 bgp_global_suppress_fib_pending_cmd
,
1750 "[no] bgp suppress-fib-pending",
1753 "Advertise only routes that are programmed in kernel to peers globally\n")
1755 bm_wait_for_fib_set(!no
);
1760 DEFPY (bgp_suppress_fib_pending
,
1761 bgp_suppress_fib_pending_cmd
,
1762 "[no] bgp suppress-fib-pending",
1765 "Advertise only routes that are programmed in kernel to peers\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1769 bgp_suppress_fib_pending_set(bgp
, !no
);
1774 /* BGP Cluster ID. */
1775 DEFUN (bgp_cluster_id
,
1777 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1779 "Configure Route-Reflector Cluster-id\n"
1780 "Route-Reflector Cluster-id in IP address format\n"
1781 "Route-Reflector Cluster-id as 32 bit quantity\n")
1783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1786 struct in_addr cluster
;
1788 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1790 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1791 return CMD_WARNING_CONFIG_FAILED
;
1794 bgp_cluster_id_set(bgp
, &cluster
);
1795 bgp_clear_star_soft_out(vty
, bgp
->name
);
1800 DEFUN (no_bgp_cluster_id
,
1801 no_bgp_cluster_id_cmd
,
1802 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1805 "Configure Route-Reflector Cluster-id\n"
1806 "Route-Reflector Cluster-id in IP address format\n"
1807 "Route-Reflector Cluster-id as 32 bit quantity\n")
1809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1810 bgp_cluster_id_unset(bgp
);
1811 bgp_clear_star_soft_out(vty
, bgp
->name
);
1820 "Disable BGP route installation to RIB (Zebra)\n")
1822 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1824 "%% No-RIB option is already set, nothing to do here.\n");
1828 bgp_option_norib_set_runtime();
1833 DEFPY (no_bgp_norib
,
1838 "Disable BGP route installation to RIB (Zebra)\n")
1840 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1842 "%% No-RIB option is not set, nothing to do here.\n");
1846 bgp_option_norib_unset_runtime();
1851 DEFPY (no_bgp_send_extra_data
,
1852 no_bgp_send_extra_data_cmd
,
1853 "[no] bgp send-extra-data zebra",
1856 "Extra data to Zebra for display/use\n"
1860 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1862 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1867 DEFUN (bgp_confederation_identifier
,
1868 bgp_confederation_identifier_cmd
,
1869 "bgp confederation identifier (1-4294967295)",
1871 "AS confederation parameters\n"
1873 "Set routing domain confederation AS\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1879 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1881 bgp_confederation_id_set(bgp
, as
);
1886 DEFUN (no_bgp_confederation_identifier
,
1887 no_bgp_confederation_identifier_cmd
,
1888 "no bgp confederation identifier [(1-4294967295)]",
1891 "AS confederation parameters\n"
1893 "Set routing domain confederation AS\n")
1895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1896 bgp_confederation_id_unset(bgp
);
1901 DEFUN (bgp_confederation_peers
,
1902 bgp_confederation_peers_cmd
,
1903 "bgp confederation peers (1-4294967295)...",
1905 "AS confederation parameters\n"
1906 "Peer ASs in BGP confederation\n"
1909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1914 for (i
= idx_asn
; i
< argc
; i
++) {
1915 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1917 if (bgp
->as
== as
) {
1919 "%% Local member-AS not allowed in confed peer list\n");
1923 bgp_confederation_peers_add(bgp
, as
);
1928 DEFUN (no_bgp_confederation_peers
,
1929 no_bgp_confederation_peers_cmd
,
1930 "no bgp confederation peers (1-4294967295)...",
1933 "AS confederation parameters\n"
1934 "Peer ASs in BGP confederation\n"
1937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1942 for (i
= idx_asn
; i
< argc
; i
++) {
1943 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1945 bgp_confederation_peers_remove(bgp
, as
);
1951 * Central routine for maximum-paths configuration.
1952 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1953 * @set: 1 for setting values, 0 for removing the max-paths config.
1955 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1956 const char *mpaths
, uint16_t options
,
1959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1960 uint16_t maxpaths
= 0;
1965 afi
= bgp_node_afi(vty
);
1966 safi
= bgp_node_safi(vty
);
1969 maxpaths
= strtol(mpaths
, NULL
, 10);
1970 if (maxpaths
> multipath_num
) {
1972 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1973 maxpaths
, multipath_num
);
1974 return CMD_WARNING_CONFIG_FAILED
;
1976 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1979 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1983 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1984 (set
== 1) ? "" : "un",
1985 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1986 maxpaths
, afi
, safi
);
1987 return CMD_WARNING_CONFIG_FAILED
;
1990 bgp_recalculate_all_bestpaths(bgp
);
1995 DEFUN (bgp_maxmed_admin
,
1996 bgp_maxmed_admin_cmd
,
1997 "bgp max-med administrative ",
1999 "Advertise routes with max-med\n"
2000 "Administratively applied, for an indefinite period\n")
2002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp
->v_maxmed_admin
= 1;
2005 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2007 bgp_maxmed_update(bgp
);
2012 DEFUN (bgp_maxmed_admin_medv
,
2013 bgp_maxmed_admin_medv_cmd
,
2014 "bgp max-med administrative (0-4294967295)",
2016 "Advertise routes with max-med\n"
2017 "Administratively applied, for an indefinite period\n"
2018 "Max MED value to be used\n")
2020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2023 bgp
->v_maxmed_admin
= 1;
2024 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2026 bgp_maxmed_update(bgp
);
2031 DEFUN (no_bgp_maxmed_admin
,
2032 no_bgp_maxmed_admin_cmd
,
2033 "no bgp max-med administrative [(0-4294967295)]",
2036 "Advertise routes with max-med\n"
2037 "Administratively applied, for an indefinite period\n"
2038 "Max MED value to be used\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2041 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2042 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2043 bgp_maxmed_update(bgp
);
2048 DEFUN (bgp_maxmed_onstartup
,
2049 bgp_maxmed_onstartup_cmd
,
2050 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2052 "Advertise routes with max-med\n"
2053 "Effective on a startup\n"
2054 "Time (seconds) period for max-med\n"
2055 "Max MED value to be used\n")
2057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2061 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2062 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2063 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2065 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2067 bgp_maxmed_update(bgp
);
2072 DEFUN (no_bgp_maxmed_onstartup
,
2073 no_bgp_maxmed_onstartup_cmd
,
2074 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2077 "Advertise routes with max-med\n"
2078 "Effective on a startup\n"
2079 "Time (seconds) period for max-med\n"
2080 "Max MED value to be used\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2084 /* Cancel max-med onstartup if its on */
2085 if (bgp
->t_maxmed_onstartup
) {
2086 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2087 bgp
->maxmed_onstartup_over
= 1;
2090 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2091 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2093 bgp_maxmed_update(bgp
);
2098 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2099 uint16_t update_delay
,
2100 uint16_t establish_wait
)
2102 struct listnode
*node
, *nnode
;
2104 bool vrf_cfg
= false;
2107 * See if update-delay is set per-vrf and warn user to delete it
2108 * Note that we only need to check this if this is the first time
2109 * setting the global config.
2111 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2112 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2113 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2115 "%% update-delay configuration found in vrf %s\n",
2116 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2126 "%%Failed: global update-delay config not permitted\n");
2130 if (!establish_wait
) { /* update-delay <delay> */
2131 bm
->v_update_delay
= update_delay
;
2132 bm
->v_establish_wait
= bm
->v_update_delay
;
2134 /* update-delay <delay> <establish-wait> */
2135 if (update_delay
< establish_wait
) {
2137 "%%Failed: update-delay less than the establish-wait!\n");
2138 return CMD_WARNING_CONFIG_FAILED
;
2141 bm
->v_update_delay
= update_delay
;
2142 bm
->v_establish_wait
= establish_wait
;
2145 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2146 bgp
->v_update_delay
= bm
->v_update_delay
;
2147 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2153 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2155 struct listnode
*node
, *nnode
;
2158 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2159 bm
->v_establish_wait
= bm
->v_update_delay
;
2161 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2162 bgp
->v_update_delay
= bm
->v_update_delay
;
2163 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2169 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2170 uint16_t establish_wait
)
2172 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2174 /* if configured globally, per-instance config is not allowed */
2175 if (bm
->v_update_delay
) {
2177 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2178 return CMD_WARNING_CONFIG_FAILED
;
2182 if (!establish_wait
) /* update-delay <delay> */
2184 bgp
->v_update_delay
= update_delay
;
2185 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2189 /* update-delay <delay> <establish-wait> */
2190 if (update_delay
< establish_wait
) {
2192 "%%Failed: update-delay less than the establish-wait!\n");
2193 return CMD_WARNING_CONFIG_FAILED
;
2196 bgp
->v_update_delay
= update_delay
;
2197 bgp
->v_establish_wait
= establish_wait
;
2202 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2206 /* If configured globally, cannot remove from one bgp instance */
2207 if (bm
->v_update_delay
) {
2209 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2210 return CMD_WARNING_CONFIG_FAILED
;
2212 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2213 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2218 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2220 /* If configured globally, no need to display per-instance value */
2221 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2222 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2223 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2224 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2229 /* Global update-delay configuration */
2230 DEFPY (bgp_global_update_delay
,
2231 bgp_global_update_delay_cmd
,
2232 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2234 "Force initial delay for best-path and updates for all bgp instances\n"
2235 "Max delay in seconds\n"
2236 "Establish wait in seconds\n")
2238 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2241 /* Global update-delay deconfiguration */
2242 DEFPY (no_bgp_global_update_delay
,
2243 no_bgp_global_update_delay_cmd
,
2244 "no bgp update-delay [(0-3600) [(1-3600)]]",
2247 "Force initial delay for best-path and updates\n"
2248 "Max delay in seconds\n"
2249 "Establish wait in seconds\n")
2251 return bgp_global_update_delay_deconfig_vty(vty
);
2254 /* Update-delay configuration */
2256 DEFPY (bgp_update_delay
,
2257 bgp_update_delay_cmd
,
2258 "update-delay (0-3600)$delay [(1-3600)$wait]",
2259 "Force initial delay for best-path and updates\n"
2260 "Max delay in seconds\n"
2261 "Establish wait in seconds\n")
2263 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2266 /* Update-delay deconfiguration */
2267 DEFPY (no_bgp_update_delay
,
2268 no_bgp_update_delay_cmd
,
2269 "no update-delay [(0-3600) [(1-3600)]]",
2271 "Force initial delay for best-path and updates\n"
2272 "Max delay in seconds\n"
2273 "Establish wait in seconds\n")
2275 return bgp_update_delay_deconfig_vty(vty
);
2279 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2284 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2285 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2290 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2295 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2296 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2301 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2304 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2305 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2306 vty_out(vty
, " write-quanta %d\n", quanta
);
2309 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2312 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2313 if (quanta
!= BGP_READ_PACKET_MAX
)
2314 vty_out(vty
, " read-quanta %d\n", quanta
);
2317 /* Packet quanta configuration
2319 * XXX: The value set here controls the size of a stack buffer in the IO
2320 * thread. When changing these limits be careful to prevent stack overflow.
2322 * Furthermore, the maximums used here should correspond to
2323 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2325 DEFPY (bgp_wpkt_quanta
,
2326 bgp_wpkt_quanta_cmd
,
2327 "[no] write-quanta (1-64)$quanta",
2329 "How many packets to write to peer socket per run\n"
2330 "Number of packets\n")
2332 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2335 DEFPY (bgp_rpkt_quanta
,
2336 bgp_rpkt_quanta_cmd
,
2337 "[no] read-quanta (1-10)$quanta",
2339 "How many packets to read from peer socket per I/O cycle\n"
2340 "Number of packets\n")
2342 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2345 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2347 if (!bgp
->heuristic_coalesce
)
2348 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2351 /* BGP TCP keepalive */
2352 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2354 if (bgp
->tcp_keepalive_idle
) {
2355 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2356 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2357 bgp
->tcp_keepalive_probes
);
2361 DEFUN (bgp_coalesce_time
,
2362 bgp_coalesce_time_cmd
,
2363 "coalesce-time (0-4294967295)",
2364 "Subgroup coalesce timer\n"
2365 "Subgroup coalesce timer value (in ms)\n")
2367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2371 bgp
->heuristic_coalesce
= false;
2373 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2374 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2379 DEFUN (no_bgp_coalesce_time
,
2380 no_bgp_coalesce_time_cmd
,
2381 "no coalesce-time (0-4294967295)",
2383 "Subgroup coalesce timer\n"
2384 "Subgroup coalesce timer value (in ms)\n")
2386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2388 bgp
->heuristic_coalesce
= true;
2389 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2393 /* Maximum-paths configuration */
2394 DEFUN (bgp_maxpaths
,
2396 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2397 "Forward packets over multiple paths\n"
2398 "Number of paths\n")
2401 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2402 argv
[idx_number
]->arg
, 0, 1);
2405 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2406 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2407 "Forward packets over multiple paths\n"
2408 "Number of paths\n")
2410 DEFUN (bgp_maxpaths_ibgp
,
2411 bgp_maxpaths_ibgp_cmd
,
2412 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2413 "Forward packets over multiple paths\n"
2415 "Number of paths\n")
2418 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2419 argv
[idx_number
]->arg
, 0, 1);
2422 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2423 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2424 "Forward packets over multiple paths\n"
2426 "Number of paths\n")
2428 DEFUN (bgp_maxpaths_ibgp_cluster
,
2429 bgp_maxpaths_ibgp_cluster_cmd
,
2430 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2431 "Forward packets over multiple paths\n"
2434 "Match the cluster length\n")
2437 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2438 argv
[idx_number
]->arg
, true, 1);
2441 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2442 "maximum-paths ibgp " CMD_RANGE_STR(
2443 1, MULTIPATH_NUM
) " equal-cluster-length",
2444 "Forward packets over multiple paths\n"
2447 "Match the cluster length\n")
2449 DEFUN (no_bgp_maxpaths
,
2450 no_bgp_maxpaths_cmd
,
2451 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2453 "Forward packets over multiple paths\n"
2454 "Number of paths\n")
2456 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2459 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2460 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2461 "Forward packets over multiple paths\n"
2462 "Number of paths\n")
2464 DEFUN (no_bgp_maxpaths_ibgp
,
2465 no_bgp_maxpaths_ibgp_cmd
,
2466 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2468 "Forward packets over multiple paths\n"
2471 "Match the cluster length\n")
2473 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2476 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2477 "no maximum-paths ibgp [" CMD_RANGE_STR(
2478 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2480 "Forward packets over multiple paths\n"
2483 "Match the cluster length\n")
2485 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2486 afi_t afi
, safi_t safi
)
2488 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2489 vty_out(vty
, " maximum-paths %d\n",
2490 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2493 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2494 vty_out(vty
, " maximum-paths ibgp %d",
2495 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2496 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2497 vty_out(vty
, " equal-cluster-length");
2506 "timers bgp (0-65535) (0-65535)",
2507 "Adjust routing timers\n"
2509 "Keepalive interval\n"
2512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2514 int idx_number_2
= 3;
2515 unsigned long keepalive
= 0;
2516 unsigned long holdtime
= 0;
2518 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2519 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2521 /* Holdtime value check. */
2522 if (holdtime
< 3 && holdtime
!= 0) {
2524 "%% hold time value must be either 0 or greater than 3\n");
2525 return CMD_WARNING_CONFIG_FAILED
;
2528 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2529 BGP_DEFAULT_DELAYOPEN
);
2534 DEFUN (no_bgp_timers
,
2536 "no timers bgp [(0-65535) (0-65535)]",
2538 "Adjust routing timers\n"
2540 "Keepalive interval\n"
2543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2544 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2545 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2550 /* BGP minimum holdtime. */
2552 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2553 "bgp minimum-holdtime (1-65535)",
2554 "BGP specific commands\n"
2555 "BGP minimum holdtime\n"
2558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2560 unsigned long min_holdtime
;
2562 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2564 bgp
->default_min_holdtime
= min_holdtime
;
2569 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2570 "no bgp minimum-holdtime [(1-65535)]",
2572 "BGP specific commands\n"
2573 "BGP minimum holdtime\n"
2576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2578 bgp
->default_min_holdtime
= 0;
2583 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2584 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2586 "TCP keepalive parameters\n"
2587 "TCP keepalive idle time (seconds)\n"
2588 "TCP keepalive interval (seconds)\n"
2589 "TCP keepalive maximum probes\n")
2591 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2593 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2599 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2600 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2603 "TCP keepalive parameters\n"
2604 "TCP keepalive idle time (seconds)\n"
2605 "TCP keepalive interval (seconds)\n"
2606 "TCP keepalive maximum probes\n")
2608 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2610 bgp_tcp_keepalive_unset(bgp
);
2615 DEFUN (bgp_client_to_client_reflection
,
2616 bgp_client_to_client_reflection_cmd
,
2617 "bgp client-to-client reflection",
2619 "Configure client to client route reflection\n"
2620 "reflection of routes allowed\n")
2622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2623 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2624 bgp_clear_star_soft_out(vty
, bgp
->name
);
2629 DEFUN (no_bgp_client_to_client_reflection
,
2630 no_bgp_client_to_client_reflection_cmd
,
2631 "no bgp client-to-client reflection",
2634 "Configure client to client route reflection\n"
2635 "reflection of routes allowed\n")
2637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2638 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2639 bgp_clear_star_soft_out(vty
, bgp
->name
);
2644 /* "bgp always-compare-med" configuration. */
2645 DEFUN (bgp_always_compare_med
,
2646 bgp_always_compare_med_cmd
,
2647 "bgp always-compare-med",
2649 "Allow comparing MED from different neighbors\n")
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2653 bgp_recalculate_all_bestpaths(bgp
);
2658 DEFUN (no_bgp_always_compare_med
,
2659 no_bgp_always_compare_med_cmd
,
2660 "no bgp always-compare-med",
2663 "Allow comparing MED from different neighbors\n")
2665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2666 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2667 bgp_recalculate_all_bestpaths(bgp
);
2673 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2674 "bgp ebgp-requires-policy",
2676 "Require in and out policy for eBGP peers (RFC8212)\n")
2678 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2679 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2683 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2684 "no bgp ebgp-requires-policy",
2687 "Require in and out policy for eBGP peers (RFC8212)\n")
2689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2690 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2694 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2695 "bgp suppress-duplicates",
2697 "Suppress duplicate updates if the route actually not changed\n")
2699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2700 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2704 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2705 "no bgp suppress-duplicates",
2708 "Suppress duplicate updates if the route actually not changed\n")
2710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2711 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2715 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2716 "bgp reject-as-sets",
2718 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 struct listnode
*node
, *nnode
;
2724 bgp
->reject_as_sets
= true;
2726 /* Reset existing BGP sessions to reject routes
2727 * with aspath containing AS_SET or AS_CONFED_SET.
2729 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2730 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2731 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2732 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2733 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2740 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2741 "no bgp reject-as-sets",
2744 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2747 struct listnode
*node
, *nnode
;
2750 bgp
->reject_as_sets
= false;
2752 /* Reset existing BGP sessions to reject routes
2753 * with aspath containing AS_SET or AS_CONFED_SET.
2755 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2756 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2757 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2758 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2759 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2766 /* "bgp deterministic-med" configuration. */
2767 DEFUN (bgp_deterministic_med
,
2768 bgp_deterministic_med_cmd
,
2769 "bgp deterministic-med",
2771 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2775 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2776 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2777 bgp_recalculate_all_bestpaths(bgp
);
2783 DEFUN (no_bgp_deterministic_med
,
2784 no_bgp_deterministic_med_cmd
,
2785 "no bgp deterministic-med",
2788 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2791 int bestpath_per_as_used
;
2795 struct listnode
*node
, *nnode
;
2797 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2798 bestpath_per_as_used
= 0;
2800 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2801 FOREACH_AFI_SAFI (afi
, safi
)
2802 if (bgp_addpath_dmed_required(
2803 peer
->addpath_type
[afi
][safi
])) {
2804 bestpath_per_as_used
= 1;
2808 if (bestpath_per_as_used
)
2812 if (bestpath_per_as_used
) {
2814 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2815 return CMD_WARNING_CONFIG_FAILED
;
2817 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2818 bgp_recalculate_all_bestpaths(bgp
);
2825 /* "bgp graceful-restart mode" configuration. */
2826 DEFUN (bgp_graceful_restart
,
2827 bgp_graceful_restart_cmd
,
2828 "bgp graceful-restart",
2833 int ret
= BGP_GR_FAILURE
;
2835 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2836 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2842 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2845 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2846 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2848 "Graceful restart configuration changed, reset all peers to take effect\n");
2849 return bgp_vty_return(vty
, ret
);
2852 DEFUN (no_bgp_graceful_restart
,
2853 no_bgp_graceful_restart_cmd
,
2854 "no bgp graceful-restart",
2860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2862 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2863 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2865 int ret
= BGP_GR_FAILURE
;
2867 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2869 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2872 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2873 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2875 "Graceful restart configuration changed, reset all peers to take effect\n");
2877 return bgp_vty_return(vty
, ret
);
2880 DEFUN (bgp_graceful_restart_stalepath_time
,
2881 bgp_graceful_restart_stalepath_time_cmd
,
2882 "bgp graceful-restart stalepath-time (1-4095)",
2884 "Graceful restart capability parameters\n"
2885 "Set the max time to hold onto restarting peer's stale paths\n"
2886 "Delay value (seconds)\n")
2888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2892 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2893 bgp
->stalepath_time
= stalepath
;
2897 DEFUN (bgp_graceful_restart_restart_time
,
2898 bgp_graceful_restart_restart_time_cmd
,
2899 "bgp graceful-restart restart-time (0-4095)",
2901 "Graceful restart capability parameters\n"
2902 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2903 "Delay value (seconds)\n")
2905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2909 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2910 bgp
->restart_time
= restart
;
2914 DEFUN (bgp_graceful_restart_select_defer_time
,
2915 bgp_graceful_restart_select_defer_time_cmd
,
2916 "bgp graceful-restart select-defer-time (0-3600)",
2918 "Graceful restart capability parameters\n"
2919 "Set the time to defer the BGP route selection after restart\n"
2920 "Delay value (seconds, 0 - disable)\n")
2922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2924 uint32_t defer_time
;
2926 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2927 bgp
->select_defer_time
= defer_time
;
2928 if (defer_time
== 0)
2929 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2931 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2936 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2937 no_bgp_graceful_restart_stalepath_time_cmd
,
2938 "no bgp graceful-restart stalepath-time [(1-4095)]",
2941 "Graceful restart capability parameters\n"
2942 "Set the max time to hold onto restarting peer's stale paths\n"
2943 "Delay value (seconds)\n")
2945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2947 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2951 DEFUN (no_bgp_graceful_restart_restart_time
,
2952 no_bgp_graceful_restart_restart_time_cmd
,
2953 "no bgp graceful-restart restart-time [(0-4095)]",
2956 "Graceful restart capability parameters\n"
2957 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2958 "Delay value (seconds)\n")
2960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2962 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2966 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2967 no_bgp_graceful_restart_select_defer_time_cmd
,
2968 "no bgp graceful-restart select-defer-time [(0-3600)]",
2971 "Graceful restart capability parameters\n"
2972 "Set the time to defer the BGP route selection after restart\n"
2973 "Delay value (seconds)\n")
2975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2977 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2978 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2983 DEFUN (bgp_graceful_restart_preserve_fw
,
2984 bgp_graceful_restart_preserve_fw_cmd
,
2985 "bgp graceful-restart preserve-fw-state",
2987 "Graceful restart capability parameters\n"
2988 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2990 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2991 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2995 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2996 no_bgp_graceful_restart_preserve_fw_cmd
,
2997 "no bgp graceful-restart preserve-fw-state",
3000 "Graceful restart capability parameters\n"
3001 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3003 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3004 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3008 DEFPY (bgp_graceful_restart_notification
,
3009 bgp_graceful_restart_notification_cmd
,
3010 "[no$no] bgp graceful-restart notification",
3013 "Graceful restart capability parameters\n"
3014 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3019 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3021 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3026 DEFPY (bgp_administrative_reset
,
3027 bgp_administrative_reset_cmd
,
3028 "[no$no] bgp hard-administrative-reset",
3031 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3036 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3038 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3043 DEFUN (bgp_graceful_restart_disable
,
3044 bgp_graceful_restart_disable_cmd
,
3045 "bgp graceful-restart-disable",
3049 int ret
= BGP_GR_FAILURE
;
3051 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3053 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3057 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3059 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3062 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3064 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3066 "Graceful restart configuration changed, reset all peers to take effect\n");
3068 return bgp_vty_return(vty
, ret
);
3071 DEFUN (no_bgp_graceful_restart_disable
,
3072 no_bgp_graceful_restart_disable_cmd
,
3073 "no bgp graceful-restart-disable",
3079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3081 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3083 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3085 int ret
= BGP_GR_FAILURE
;
3087 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3089 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3092 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3094 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3096 "Graceful restart configuration changed, reset all peers to take effect\n");
3098 return bgp_vty_return(vty
, ret
);
3101 DEFUN (bgp_neighbor_graceful_restart_set
,
3102 bgp_neighbor_graceful_restart_set_cmd
,
3103 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3111 int ret
= BGP_GR_FAILURE
;
3113 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3115 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3117 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3119 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3121 return CMD_WARNING_CONFIG_FAILED
;
3123 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3125 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3126 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3128 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3130 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3132 "Graceful restart configuration changed, reset this peer to take effect\n");
3134 return bgp_vty_return(vty
, ret
);
3137 DEFUN (no_bgp_neighbor_graceful_restart
,
3138 no_bgp_neighbor_graceful_restart_set_cmd
,
3139 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3147 int ret
= BGP_GR_FAILURE
;
3150 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3152 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3154 return CMD_WARNING_CONFIG_FAILED
;
3156 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3158 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3160 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3162 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3163 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3165 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3167 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3169 "Graceful restart configuration changed, reset this peer to take effect\n");
3171 return bgp_vty_return(vty
, ret
);
3174 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3175 bgp_neighbor_graceful_restart_helper_set_cmd
,
3176 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3179 GR_NEIGHBOR_HELPER_CMD
3184 int ret
= BGP_GR_FAILURE
;
3186 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3188 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3190 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3192 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3195 return CMD_WARNING_CONFIG_FAILED
;
3198 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3200 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3201 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3203 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3205 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3207 "Graceful restart configuration changed, reset this peer to take effect\n");
3209 return bgp_vty_return(vty
, ret
);
3212 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3213 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3214 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3218 NO_GR_NEIGHBOR_HELPER_CMD
3222 int ret
= BGP_GR_FAILURE
;
3225 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3227 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3229 return CMD_WARNING_CONFIG_FAILED
;
3231 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3233 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3235 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3237 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3238 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3240 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3242 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3244 "Graceful restart configuration changed, reset this peer to take effect\n");
3246 return bgp_vty_return(vty
, ret
);
3249 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3250 bgp_neighbor_graceful_restart_disable_set_cmd
,
3251 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3254 GR_NEIGHBOR_DISABLE_CMD
3259 int ret
= BGP_GR_FAILURE
;
3261 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3263 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3265 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3267 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3269 return CMD_WARNING_CONFIG_FAILED
;
3271 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3273 if (peer
->bgp
->t_startup
)
3274 bgp_peer_gr_flags_update(peer
);
3276 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3277 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3279 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3281 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3283 "Graceful restart configuration changed, reset this peer to take effect\n");
3285 return bgp_vty_return(vty
, ret
);
3288 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3289 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3290 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3294 NO_GR_NEIGHBOR_DISABLE_CMD
3298 int ret
= BGP_GR_FAILURE
;
3301 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3303 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3305 return CMD_WARNING_CONFIG_FAILED
;
3307 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3309 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3311 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3313 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3314 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3316 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3318 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3320 "Graceful restart configuration changed, reset this peer to take effect\n");
3322 return bgp_vty_return(vty
, ret
);
3325 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3326 bgp_graceful_restart_disable_eor_cmd
,
3327 "bgp graceful-restart disable-eor",
3329 "Graceful restart configuration parameters\n"
3330 "Disable EOR Check\n")
3332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3333 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3338 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3339 no_bgp_graceful_restart_disable_eor_cmd
,
3340 "no bgp graceful-restart disable-eor",
3343 "Graceful restart configuration parameters\n"
3344 "Disable EOR Check\n")
3346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3347 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3352 DEFUN (bgp_graceful_restart_rib_stale_time
,
3353 bgp_graceful_restart_rib_stale_time_cmd
,
3354 "bgp graceful-restart rib-stale-time (1-3600)",
3356 "Graceful restart configuration parameters\n"
3357 "Specify the stale route removal timer in rib\n"
3358 "Delay value (seconds)\n")
3360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3362 uint32_t stale_time
;
3364 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3365 bgp
->rib_stale_time
= stale_time
;
3366 /* Send the stale timer update message to RIB */
3367 if (bgp_zebra_stale_timer_update(bgp
))
3373 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3374 no_bgp_graceful_restart_rib_stale_time_cmd
,
3375 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3378 "Graceful restart configuration parameters\n"
3379 "Specify the stale route removal timer in rib\n"
3380 "Delay value (seconds)\n")
3382 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3384 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3385 /* Send the stale timer update message to RIB */
3386 if (bgp_zebra_stale_timer_update(bgp
))
3392 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3393 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3395 "Enable Long-lived Graceful Restart\n"
3396 "Specifies maximum time to wait before purging long-lived stale routes\n"
3397 "Stale time value (seconds)\n")
3399 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3401 uint32_t llgr_stale_time
;
3403 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3404 bgp
->llgr_stale_time
= llgr_stale_time
;
3409 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3410 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3412 "Enable Long-lived Graceful Restart\n"
3413 "Specifies maximum time to wait before purging long-lived stale routes\n"
3414 "Stale time value (seconds)\n")
3416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3418 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3423 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3426 bgp_static_redo_import_check(bgp
);
3427 bgp_redistribute_redo(bgp
);
3428 bgp_clear_star_soft_out(vty
, bgp
->name
);
3429 bgp_clear_star_soft_in(vty
, bgp
->name
);
3432 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3434 struct listnode
*node
, *nnode
;
3436 bool vrf_cfg
= false;
3438 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3441 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3442 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3443 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3445 "%% graceful-shutdown configuration found in vrf %s\n",
3446 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3447 VRF_DEFAULT_NAME
: bgp
->name
);
3454 "%%Failed: global graceful-shutdown not permitted\n");
3458 /* Set flag globally */
3459 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3461 /* Initiate processing for all BGP instances. */
3462 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3463 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3468 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3470 struct listnode
*node
, *nnode
;
3473 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3476 /* Unset flag globally */
3477 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3479 /* Initiate processing for all BGP instances. */
3480 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3481 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3486 /* "bgp graceful-shutdown" configuration */
3487 DEFUN (bgp_graceful_shutdown
,
3488 bgp_graceful_shutdown_cmd
,
3489 "bgp graceful-shutdown",
3491 "Graceful shutdown parameters\n")
3493 if (vty
->node
== CONFIG_NODE
)
3494 return bgp_global_graceful_shutdown_config_vty(vty
);
3496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3498 /* if configured globally, per-instance config is not allowed */
3499 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3501 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3502 return CMD_WARNING_CONFIG_FAILED
;
3505 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3506 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3507 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3513 DEFUN (no_bgp_graceful_shutdown
,
3514 no_bgp_graceful_shutdown_cmd
,
3515 "no bgp graceful-shutdown",
3518 "Graceful shutdown parameters\n")
3520 if (vty
->node
== CONFIG_NODE
)
3521 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3525 /* If configured globally, cannot remove from one bgp instance */
3526 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3528 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3533 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3534 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3540 /* "bgp fast-external-failover" configuration. */
3541 DEFUN (bgp_fast_external_failover
,
3542 bgp_fast_external_failover_cmd
,
3543 "bgp fast-external-failover",
3545 "Immediately reset session if a link to a directly connected external peer goes down\n")
3547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3548 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3552 DEFUN (no_bgp_fast_external_failover
,
3553 no_bgp_fast_external_failover_cmd
,
3554 "no bgp fast-external-failover",
3557 "Immediately reset session if a link to a directly connected external peer goes down\n")
3559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3560 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3564 /* "bgp bestpath compare-routerid" configuration. */
3565 DEFUN (bgp_bestpath_compare_router_id
,
3566 bgp_bestpath_compare_router_id_cmd
,
3567 "bgp bestpath compare-routerid",
3569 "Change the default bestpath selection\n"
3570 "Compare router-id for identical EBGP paths\n")
3572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3573 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3574 bgp_recalculate_all_bestpaths(bgp
);
3579 DEFUN (no_bgp_bestpath_compare_router_id
,
3580 no_bgp_bestpath_compare_router_id_cmd
,
3581 "no bgp bestpath compare-routerid",
3584 "Change the default bestpath selection\n"
3585 "Compare router-id for identical EBGP paths\n")
3587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3588 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3589 bgp_recalculate_all_bestpaths(bgp
);
3594 /* "bgp bestpath as-path ignore" configuration. */
3595 DEFUN (bgp_bestpath_aspath_ignore
,
3596 bgp_bestpath_aspath_ignore_cmd
,
3597 "bgp bestpath as-path ignore",
3599 "Change the default bestpath selection\n"
3600 "AS-path attribute\n"
3601 "Ignore as-path length in selecting a route\n")
3603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3604 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3605 bgp_recalculate_all_bestpaths(bgp
);
3610 DEFUN (no_bgp_bestpath_aspath_ignore
,
3611 no_bgp_bestpath_aspath_ignore_cmd
,
3612 "no bgp bestpath as-path ignore",
3615 "Change the default bestpath selection\n"
3616 "AS-path attribute\n"
3617 "Ignore as-path length in selecting a route\n")
3619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3620 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3621 bgp_recalculate_all_bestpaths(bgp
);
3626 /* "bgp bestpath as-path confed" configuration. */
3627 DEFUN (bgp_bestpath_aspath_confed
,
3628 bgp_bestpath_aspath_confed_cmd
,
3629 "bgp bestpath as-path confed",
3631 "Change the default bestpath selection\n"
3632 "AS-path attribute\n"
3633 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3636 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3637 bgp_recalculate_all_bestpaths(bgp
);
3642 DEFUN (no_bgp_bestpath_aspath_confed
,
3643 no_bgp_bestpath_aspath_confed_cmd
,
3644 "no bgp bestpath as-path confed",
3647 "Change the default bestpath selection\n"
3648 "AS-path attribute\n"
3649 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3652 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3653 bgp_recalculate_all_bestpaths(bgp
);
3658 /* "bgp bestpath as-path multipath-relax" configuration. */
3659 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3660 bgp_bestpath_aspath_multipath_relax_cmd
,
3661 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3663 "Change the default bestpath selection\n"
3664 "AS-path attribute\n"
3665 "Allow load sharing across routes that have different AS paths (but same length)\n"
3666 "Generate an AS_SET\n"
3667 "Do not generate an AS_SET\n")
3669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3671 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3673 /* no-as-set is now the default behavior so we can silently
3675 if (argv_find(argv
, argc
, "as-set", &idx
))
3676 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3678 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3680 bgp_recalculate_all_bestpaths(bgp
);
3685 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3686 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3687 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3690 "Change the default bestpath selection\n"
3691 "AS-path attribute\n"
3692 "Allow load sharing across routes that have different AS paths (but same length)\n"
3693 "Generate an AS_SET\n"
3694 "Do not generate an AS_SET\n")
3696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3697 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3698 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3699 bgp_recalculate_all_bestpaths(bgp
);
3704 /* "bgp bestpath peer-type multipath-relax" configuration. */
3705 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3706 bgp_bestpath_peer_type_multipath_relax_cmd
,
3707 "bgp bestpath peer-type multipath-relax",
3709 "Change the default bestpath selection\n"
3711 "Allow load sharing across routes learned from different peer types\n")
3713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3714 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3715 bgp_recalculate_all_bestpaths(bgp
);
3720 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3721 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3722 "no bgp bestpath peer-type multipath-relax",
3724 "Change the default bestpath selection\n"
3726 "Allow load sharing across routes learned from different peer types\n")
3728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3729 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3730 bgp_recalculate_all_bestpaths(bgp
);
3735 /* "bgp log-neighbor-changes" configuration. */
3736 DEFUN (bgp_log_neighbor_changes
,
3737 bgp_log_neighbor_changes_cmd
,
3738 "bgp log-neighbor-changes",
3740 "Log neighbor up/down and reset reason\n")
3742 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3743 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3747 DEFUN (no_bgp_log_neighbor_changes
,
3748 no_bgp_log_neighbor_changes_cmd
,
3749 "no bgp log-neighbor-changes",
3752 "Log neighbor up/down and reset reason\n")
3754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3755 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3759 /* "bgp bestpath med" configuration. */
3760 DEFUN (bgp_bestpath_med
,
3761 bgp_bestpath_med_cmd
,
3762 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3764 "Change the default bestpath selection\n"
3766 "Compare MED among confederation paths\n"
3767 "Treat missing MED as the least preferred one\n"
3768 "Treat missing MED as the least preferred one\n"
3769 "Compare MED among confederation paths\n")
3771 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3774 if (argv_find(argv
, argc
, "confed", &idx
))
3775 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3777 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3778 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3780 bgp_recalculate_all_bestpaths(bgp
);
3785 DEFUN (no_bgp_bestpath_med
,
3786 no_bgp_bestpath_med_cmd
,
3787 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3790 "Change the default bestpath selection\n"
3792 "Compare MED among confederation paths\n"
3793 "Treat missing MED as the least preferred one\n"
3794 "Treat missing MED as the least preferred one\n"
3795 "Compare MED among confederation paths\n")
3797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3800 if (argv_find(argv
, argc
, "confed", &idx
))
3801 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3803 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3804 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3806 bgp_recalculate_all_bestpaths(bgp
);
3811 /* "bgp bestpath bandwidth" configuration. */
3812 DEFPY (bgp_bestpath_bw
,
3813 bgp_bestpath_bw_cmd
,
3814 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3816 "Change the default bestpath selection\n"
3817 "Link Bandwidth attribute\n"
3818 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3819 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3820 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3827 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3828 return CMD_ERR_INCOMPLETE
;
3830 if (!strcmp(bw_cfg
, "ignore"))
3831 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3832 else if (!strcmp(bw_cfg
, "skip-missing"))
3833 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3834 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3835 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3837 return CMD_ERR_NO_MATCH
;
3839 /* This config is used in route install, so redo that. */
3840 FOREACH_AFI_SAFI (afi
, safi
) {
3841 if (!bgp_fibupd_safi(safi
))
3843 bgp_zebra_announce_table(bgp
, afi
, safi
);
3849 DEFPY (no_bgp_bestpath_bw
,
3850 no_bgp_bestpath_bw_cmd
,
3851 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3854 "Change the default bestpath selection\n"
3855 "Link Bandwidth attribute\n"
3856 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3857 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3858 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3864 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3866 /* This config is used in route install, so redo that. */
3867 FOREACH_AFI_SAFI (afi
, safi
) {
3868 if (!bgp_fibupd_safi(safi
))
3870 bgp_zebra_announce_table(bgp
, afi
, safi
);
3875 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3876 "[no] bgp default <ipv4-unicast|"
3879 "ipv4-labeled-unicast|"
3884 "ipv6-labeled-unicast|"
3886 "l2vpn-evpn>$afi_safi",
3889 "Configure BGP defaults\n"
3890 "Activate ipv4-unicast for a peer by default\n"
3891 "Activate ipv4-multicast for a peer by default\n"
3892 "Activate ipv4-vpn for a peer by default\n"
3893 "Activate ipv4-labeled-unicast for a peer by default\n"
3894 "Activate ipv4-flowspec for a peer by default\n"
3895 "Activate ipv6-unicast for a peer by default\n"
3896 "Activate ipv6-multicast for a peer by default\n"
3897 "Activate ipv6-vpn for a peer by default\n"
3898 "Activate ipv6-labeled-unicast for a peer by default\n"
3899 "Activate ipv6-flowspec for a peer by default\n"
3900 "Activate l2vpn-evpn for a peer by default\n")
3902 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3903 char afi_safi_str
[strlen(afi_safi
) + 1];
3904 char *afi_safi_str_tok
;
3906 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3907 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3908 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3909 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3913 * Impossible situation but making coverity happy
3915 assert(afi
!= AFI_MAX
);
3917 if (strmatch(safi_str
, "labeled"))
3918 safi
= bgp_vty_safi_from_str("labeled-unicast");
3920 safi
= bgp_vty_safi_from_str(safi_str
);
3922 assert(safi
!= SAFI_MAX
);
3924 bgp
->default_af
[afi
][safi
] = false;
3926 if ((safi
== SAFI_LABELED_UNICAST
3927 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3928 || (safi
== SAFI_UNICAST
3929 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3930 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3932 bgp
->default_af
[afi
][safi
] = true;
3938 /* Display hostname in certain command outputs */
3939 DEFUN (bgp_default_show_hostname
,
3940 bgp_default_show_hostname_cmd
,
3941 "bgp default show-hostname",
3943 "Configure BGP defaults\n"
3944 "Show hostname in certain command outputs\n")
3946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3947 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3951 DEFUN (no_bgp_default_show_hostname
,
3952 no_bgp_default_show_hostname_cmd
,
3953 "no bgp default show-hostname",
3956 "Configure BGP defaults\n"
3957 "Show hostname in certain command outputs\n")
3959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3960 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3964 /* Display hostname in certain command outputs */
3965 DEFUN (bgp_default_show_nexthop_hostname
,
3966 bgp_default_show_nexthop_hostname_cmd
,
3967 "bgp default show-nexthop-hostname",
3969 "Configure BGP defaults\n"
3970 "Show hostname for nexthop in certain command outputs\n")
3972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3973 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3977 DEFUN (no_bgp_default_show_nexthop_hostname
,
3978 no_bgp_default_show_nexthop_hostname_cmd
,
3979 "no bgp default show-nexthop-hostname",
3982 "Configure BGP defaults\n"
3983 "Show hostname for nexthop in certain command outputs\n")
3985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3986 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3990 /* "bgp network import-check" configuration. */
3991 DEFUN (bgp_network_import_check
,
3992 bgp_network_import_check_cmd
,
3993 "bgp network import-check",
3995 "BGP network command\n"
3996 "Check BGP network route exists in IGP\n")
3998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3999 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4000 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4001 bgp_static_redo_import_check(bgp
);
4007 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4008 "bgp network import-check exact",
4010 "BGP network command\n"
4011 "Check BGP network route exists in IGP\n"
4012 "Match route precisely\n")
4014 DEFUN (no_bgp_network_import_check
,
4015 no_bgp_network_import_check_cmd
,
4016 "no bgp network import-check",
4019 "BGP network command\n"
4020 "Check BGP network route exists in IGP\n")
4022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4023 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4024 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4025 bgp_static_redo_import_check(bgp
);
4031 DEFUN (bgp_default_local_preference
,
4032 bgp_default_local_preference_cmd
,
4033 "bgp default local-preference (0-4294967295)",
4035 "Configure BGP defaults\n"
4036 "local preference (higher=more preferred)\n"
4037 "Configure default local preference value\n")
4039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4041 uint32_t local_pref
;
4043 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4045 bgp_default_local_preference_set(bgp
, local_pref
);
4046 bgp_clear_star_soft_in(vty
, bgp
->name
);
4051 DEFUN (no_bgp_default_local_preference
,
4052 no_bgp_default_local_preference_cmd
,
4053 "no bgp default local-preference [(0-4294967295)]",
4056 "Configure BGP defaults\n"
4057 "local preference (higher=more preferred)\n"
4058 "Configure default local preference value\n")
4060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4061 bgp_default_local_preference_unset(bgp
);
4062 bgp_clear_star_soft_in(vty
, bgp
->name
);
4068 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4069 bgp_default_subgroup_pkt_queue_max_cmd
,
4070 "bgp default subgroup-pkt-queue-max (20-100)",
4072 "Configure BGP defaults\n"
4073 "subgroup-pkt-queue-max\n"
4074 "Configure subgroup packet queue max\n")
4076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4080 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4082 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4087 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4088 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4089 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4092 "Configure BGP defaults\n"
4093 "subgroup-pkt-queue-max\n"
4094 "Configure subgroup packet queue max\n")
4096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4097 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4102 DEFUN (bgp_rr_allow_outbound_policy
,
4103 bgp_rr_allow_outbound_policy_cmd
,
4104 "bgp route-reflector allow-outbound-policy",
4106 "Allow modifications made by out route-map\n"
4107 "on ibgp neighbors\n")
4109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4111 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4112 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4113 update_group_announce_rrclients(bgp
);
4114 bgp_clear_star_soft_out(vty
, bgp
->name
);
4120 DEFUN (no_bgp_rr_allow_outbound_policy
,
4121 no_bgp_rr_allow_outbound_policy_cmd
,
4122 "no bgp route-reflector allow-outbound-policy",
4125 "Allow modifications made by out route-map\n"
4126 "on ibgp neighbors\n")
4128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4130 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4131 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4132 update_group_announce_rrclients(bgp
);
4133 bgp_clear_star_soft_out(vty
, bgp
->name
);
4139 DEFUN (bgp_listen_limit
,
4140 bgp_listen_limit_cmd
,
4141 "bgp listen limit (1-65535)",
4143 "BGP Dynamic Neighbors listen commands\n"
4144 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4145 "Configure Dynamic Neighbors listen limit value\n")
4147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4151 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4153 bgp_listen_limit_set(bgp
, listen_limit
);
4158 DEFUN (no_bgp_listen_limit
,
4159 no_bgp_listen_limit_cmd
,
4160 "no bgp listen limit [(1-65535)]",
4163 "BGP Dynamic Neighbors listen commands\n"
4164 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4165 "Configure Dynamic Neighbors listen limit value\n")
4167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4168 bgp_listen_limit_unset(bgp
);
4174 * Check if this listen range is already configured. Check for exact
4175 * match or overlap based on input.
4177 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4178 struct prefix
*range
, int exact
)
4180 struct listnode
*node
, *nnode
;
4181 struct listnode
*node1
, *nnode1
;
4182 struct peer_group
*group
;
4187 afi
= family2afi(range
->family
);
4188 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4189 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4192 match
= prefix_same(range
, lr
);
4194 match
= (prefix_match(range
, lr
)
4195 || prefix_match(lr
, range
));
4204 DEFUN (bgp_listen_range
,
4205 bgp_listen_range_cmd
,
4206 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4208 "Configure BGP dynamic neighbors listen range\n"
4209 "Configure BGP dynamic neighbors listen range\n"
4211 "Member of the peer-group\n"
4212 "Peer-group name\n")
4214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4215 struct prefix range
;
4216 struct peer_group
*group
, *existing_group
;
4221 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4222 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4223 char *prefix
= argv
[idx
]->arg
;
4224 argv_find(argv
, argc
, "PGNAME", &idx
);
4225 char *peergroup
= argv
[idx
]->arg
;
4227 /* Convert IP prefix string to struct prefix. */
4228 ret
= str2prefix(prefix
, &range
);
4230 vty_out(vty
, "%% Malformed listen range\n");
4231 return CMD_WARNING_CONFIG_FAILED
;
4234 afi
= family2afi(range
.family
);
4236 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4238 "%% Malformed listen range (link-local address)\n");
4239 return CMD_WARNING_CONFIG_FAILED
;
4244 /* Check if same listen range is already configured. */
4245 existing_group
= listen_range_exists(bgp
, &range
, 1);
4246 if (existing_group
) {
4247 if (strcmp(existing_group
->name
, peergroup
) == 0)
4251 "%% Same listen range is attached to peer-group %s\n",
4252 existing_group
->name
);
4253 return CMD_WARNING_CONFIG_FAILED
;
4257 /* Check if an overlapping listen range exists. */
4258 if (listen_range_exists(bgp
, &range
, 0)) {
4260 "%% Listen range overlaps with existing listen range\n");
4261 return CMD_WARNING_CONFIG_FAILED
;
4264 group
= peer_group_lookup(bgp
, peergroup
);
4266 vty_out(vty
, "%% Configure the peer-group first\n");
4267 return CMD_WARNING_CONFIG_FAILED
;
4270 ret
= peer_group_listen_range_add(group
, &range
);
4271 return bgp_vty_return(vty
, ret
);
4274 DEFUN (no_bgp_listen_range
,
4275 no_bgp_listen_range_cmd
,
4276 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4279 "Unconfigure BGP dynamic neighbors listen range\n"
4280 "Unconfigure BGP dynamic neighbors listen range\n"
4282 "Member of the peer-group\n"
4283 "Peer-group name\n")
4285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4286 struct prefix range
;
4287 struct peer_group
*group
;
4292 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4293 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4294 char *prefix
= argv
[idx
]->arg
;
4295 argv_find(argv
, argc
, "PGNAME", &idx
);
4296 char *peergroup
= argv
[idx
]->arg
;
4298 /* Convert IP prefix string to struct prefix. */
4299 ret
= str2prefix(prefix
, &range
);
4301 vty_out(vty
, "%% Malformed listen range\n");
4302 return CMD_WARNING_CONFIG_FAILED
;
4305 afi
= family2afi(range
.family
);
4307 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4309 "%% Malformed listen range (link-local address)\n");
4310 return CMD_WARNING_CONFIG_FAILED
;
4315 group
= peer_group_lookup(bgp
, peergroup
);
4317 vty_out(vty
, "%% Peer-group does not exist\n");
4318 return CMD_WARNING_CONFIG_FAILED
;
4321 ret
= peer_group_listen_range_del(group
, &range
);
4322 return bgp_vty_return(vty
, ret
);
4325 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4327 struct peer_group
*group
;
4328 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4329 struct prefix
*range
;
4332 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4333 vty_out(vty
, " bgp listen limit %d\n",
4334 bgp
->dynamic_neighbors_limit
);
4336 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4337 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4338 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4341 " bgp listen range %pFX peer-group %s\n",
4342 range
, group
->name
);
4349 DEFUN (bgp_disable_connected_route_check
,
4350 bgp_disable_connected_route_check_cmd
,
4351 "bgp disable-ebgp-connected-route-check",
4353 "Disable checking if nexthop is connected on ebgp sessions\n")
4355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4356 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4357 bgp_clear_star_soft_in(vty
, bgp
->name
);
4362 DEFUN (no_bgp_disable_connected_route_check
,
4363 no_bgp_disable_connected_route_check_cmd
,
4364 "no bgp disable-ebgp-connected-route-check",
4367 "Disable checking if nexthop is connected on ebgp sessions\n")
4369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4370 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4371 bgp_clear_star_soft_in(vty
, bgp
->name
);
4377 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4383 int as_type
= AS_SPECIFIED
;
4386 if (as_str
[0] == 'i') {
4388 as_type
= AS_INTERNAL
;
4389 } else if (as_str
[0] == 'e') {
4391 as_type
= AS_EXTERNAL
;
4393 /* Get AS number. */
4394 as
= strtoul(as_str
, NULL
, 10);
4397 /* If peer is peer group or interface peer, call proper function. */
4398 ret
= str2sockunion(peer_str
, &su
);
4402 /* Check if existing interface peer */
4403 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4405 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4407 /* if not interface peer, check peer-group settings */
4408 if (ret
< 0 && !peer
) {
4409 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4412 "%% Create the peer-group or interface first\n");
4413 return CMD_WARNING_CONFIG_FAILED
;
4418 if (peer_address_self_check(bgp
, &su
)) {
4420 "%% Can not configure the local system as neighbor\n");
4421 return CMD_WARNING_CONFIG_FAILED
;
4423 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4426 return bgp_vty_return(vty
, ret
);
4429 DEFUN (bgp_default_shutdown
,
4430 bgp_default_shutdown_cmd
,
4431 "[no] bgp default shutdown",
4434 "Configure BGP defaults\n"
4435 "Apply administrative shutdown to newly configured peers\n")
4437 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4438 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4442 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4444 "Administrative shutdown of the BGP instance\n"
4445 "Add a shutdown message (RFC 8203)\n"
4446 "Shutdown message\n")
4448 char *msgstr
= NULL
;
4450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4453 msgstr
= argv_concat(argv
, argc
, 3);
4455 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4456 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4457 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4458 return CMD_WARNING_CONFIG_FAILED
;
4461 bgp_shutdown_enable(bgp
, msgstr
);
4462 XFREE(MTYPE_TMP
, msgstr
);
4467 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4468 BGP_STR
"Administrative shutdown of the BGP instance\n")
4470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4472 bgp_shutdown_enable(bgp
, NULL
);
4477 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4478 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4482 bgp_shutdown_disable(bgp
);
4487 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4488 "no bgp shutdown message MSG...", NO_STR BGP_STR
4489 "Administrative shutdown of the BGP instance\n"
4490 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4492 DEFUN (neighbor_remote_as
,
4493 neighbor_remote_as_cmd
,
4494 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4497 "Specify a BGP neighbor\n"
4499 "Internal BGP peer\n"
4500 "External BGP peer\n")
4503 int idx_remote_as
= 3;
4504 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4505 argv
[idx_remote_as
]->arg
);
4508 DEFPY (bgp_allow_martian
,
4509 bgp_allow_martian_cmd
,
4510 "[no]$no bgp allow-martian-nexthop",
4513 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4518 bgp
->allow_martian
= false;
4520 bgp
->allow_martian
= true;
4525 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4526 * sessions do not wait for hold timer expiry to bring down the sessions
4527 * when nexthop becomes unreachable
4529 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4530 BGP_STR
"Fast convergence for bgp sessions\n")
4532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4533 bgp
->fast_convergence
= true;
4538 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4539 "no bgp fast-convergence",
4540 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4543 bgp
->fast_convergence
= false;
4548 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4550 const char *peer_group_name
,
4553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4555 int as_type
= AS_UNSPECIFIED
;
4557 struct peer_group
*group
;
4560 group
= peer_group_lookup(bgp
, conf_if
);
4563 vty_out(vty
, "%% Name conflict with peer-group \n");
4564 return CMD_WARNING_CONFIG_FAILED
;
4568 if (as_str
[0] == 'i') {
4569 as_type
= AS_INTERNAL
;
4570 } else if (as_str
[0] == 'e') {
4571 as_type
= AS_EXTERNAL
;
4573 /* Get AS number. */
4574 as
= strtoul(as_str
, NULL
, 10);
4575 as_type
= AS_SPECIFIED
;
4579 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4582 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4584 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4588 vty_out(vty
, "%% BGP failed to create peer\n");
4589 return CMD_WARNING_CONFIG_FAILED
;
4593 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4595 /* Request zebra to initiate IPv6 RAs on this interface. We do
4597 * any unnumbered peer in order to not worry about run-time
4599 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4601 * gets deleted later etc.)
4604 bgp_zebra_initiate_radv(bgp
, peer
);
4607 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4608 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4610 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4612 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4614 /* v6only flag changed. Reset bgp seesion */
4615 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4616 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4617 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4618 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4620 bgp_session_reset(peer
);
4623 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4624 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4625 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4626 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4629 if (peer_group_name
) {
4630 group
= peer_group_lookup(bgp
, peer_group_name
);
4632 vty_out(vty
, "%% Configure the peer-group first\n");
4633 return CMD_WARNING_CONFIG_FAILED
;
4636 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4639 return bgp_vty_return(vty
, ret
);
4642 DEFUN (neighbor_interface_config
,
4643 neighbor_interface_config_cmd
,
4644 "neighbor WORD interface [peer-group PGNAME]",
4646 "Interface name or neighbor tag\n"
4647 "Enable BGP on interface\n"
4648 "Member of the peer-group\n"
4649 "Peer-group name\n")
4652 int idx_peer_group_word
= 4;
4654 if (argc
> idx_peer_group_word
)
4655 return peer_conf_interface_get(
4656 vty
, argv
[idx_word
]->arg
, 0,
4657 argv
[idx_peer_group_word
]->arg
, NULL
);
4659 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4663 DEFUN (neighbor_interface_config_v6only
,
4664 neighbor_interface_config_v6only_cmd
,
4665 "neighbor WORD interface v6only [peer-group PGNAME]",
4667 "Interface name or neighbor tag\n"
4668 "Enable BGP on interface\n"
4669 "Enable BGP with v6 link-local only\n"
4670 "Member of the peer-group\n"
4671 "Peer-group name\n")
4674 int idx_peer_group_word
= 5;
4676 if (argc
> idx_peer_group_word
)
4677 return peer_conf_interface_get(
4678 vty
, argv
[idx_word
]->arg
, 1,
4679 argv
[idx_peer_group_word
]->arg
, NULL
);
4681 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4685 DEFUN (neighbor_interface_config_remote_as
,
4686 neighbor_interface_config_remote_as_cmd
,
4687 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4689 "Interface name or neighbor tag\n"
4690 "Enable BGP on interface\n"
4691 "Specify a BGP neighbor\n"
4693 "Internal BGP peer\n"
4694 "External BGP peer\n")
4697 int idx_remote_as
= 4;
4698 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4699 argv
[idx_remote_as
]->arg
);
4702 DEFUN (neighbor_interface_v6only_config_remote_as
,
4703 neighbor_interface_v6only_config_remote_as_cmd
,
4704 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4706 "Interface name or neighbor tag\n"
4707 "Enable BGP with v6 link-local only\n"
4708 "Enable BGP on interface\n"
4709 "Specify a BGP neighbor\n"
4711 "Internal BGP peer\n"
4712 "External BGP peer\n")
4715 int idx_remote_as
= 5;
4716 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4717 argv
[idx_remote_as
]->arg
);
4720 DEFUN (neighbor_peer_group
,
4721 neighbor_peer_group_cmd
,
4722 "neighbor WORD peer-group",
4724 "Interface name or neighbor tag\n"
4725 "Configure peer-group\n")
4727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4730 struct peer_group
*group
;
4732 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4734 vty_out(vty
, "%% Name conflict with interface: \n");
4735 return CMD_WARNING_CONFIG_FAILED
;
4738 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4740 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4741 return CMD_WARNING_CONFIG_FAILED
;
4749 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4753 "Specify a BGP neighbor\n"
4755 "Internal BGP peer\n"
4756 "External BGP peer\n")
4758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4762 struct peer_group
*group
;
4766 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4768 /* look up for neighbor by interface name config. */
4769 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4771 /* Request zebra to terminate IPv6 RAs on this
4774 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4775 peer_notify_unconfig(peer
);
4780 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4782 peer_group_notify_unconfig(group
);
4783 peer_group_delete(group
);
4785 vty_out(vty
, "%% Create the peer-group first\n");
4786 return CMD_WARNING_CONFIG_FAILED
;
4789 peer
= peer_lookup(bgp
, &su
);
4791 if (peer_dynamic_neighbor(peer
)) {
4793 "%% Operation not allowed on a dynamic neighbor\n");
4794 return CMD_WARNING_CONFIG_FAILED
;
4797 other
= peer
->doppelganger
;
4799 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4800 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4802 peer_notify_unconfig(peer
);
4804 if (other
&& other
->status
!= Deleted
) {
4805 peer_notify_unconfig(other
);
4814 DEFUN (no_neighbor_interface_config
,
4815 no_neighbor_interface_config_cmd
,
4816 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4820 "Configure BGP on interface\n"
4821 "Enable BGP with v6 link-local only\n"
4822 "Member of the peer-group\n"
4824 "Specify a BGP neighbor\n"
4826 "Internal BGP peer\n"
4827 "External BGP peer\n")
4829 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4833 /* look up for neighbor by interface name config. */
4834 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4836 /* Request zebra to terminate IPv6 RAs on this interface. */
4838 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4839 peer_notify_unconfig(peer
);
4842 vty_out(vty
, "%% Create the bgp interface first\n");
4843 return CMD_WARNING_CONFIG_FAILED
;
4848 DEFUN (no_neighbor_peer_group
,
4849 no_neighbor_peer_group_cmd
,
4850 "no neighbor WORD peer-group",
4854 "Configure peer-group\n")
4856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4858 struct peer_group
*group
;
4860 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4862 peer_group_notify_unconfig(group
);
4863 peer_group_delete(group
);
4865 vty_out(vty
, "%% Create the peer-group first\n");
4866 return CMD_WARNING_CONFIG_FAILED
;
4871 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4872 no_neighbor_interface_peer_group_remote_as_cmd
,
4873 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4876 "Interface name or neighbor tag\n"
4877 "Specify a BGP neighbor\n"
4879 "Internal BGP peer\n"
4880 "External BGP peer\n")
4882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4884 struct peer_group
*group
;
4887 /* look up for neighbor by interface name config. */
4888 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4890 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4894 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4896 peer_group_remote_as_delete(group
);
4898 vty_out(vty
, "%% Create the peer-group or interface first\n");
4899 return CMD_WARNING_CONFIG_FAILED
;
4904 DEFUN (neighbor_local_as
,
4905 neighbor_local_as_cmd
,
4906 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4909 "Specify a local-as number\n"
4910 "AS number used as local AS\n")
4918 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4920 return CMD_WARNING_CONFIG_FAILED
;
4922 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4923 ret
= peer_local_as_set(peer
, as
, 0, 0);
4924 return bgp_vty_return(vty
, ret
);
4927 DEFUN (neighbor_local_as_no_prepend
,
4928 neighbor_local_as_no_prepend_cmd
,
4929 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4932 "Specify a local-as number\n"
4933 "AS number used as local AS\n"
4934 "Do not prepend local-as to updates from ebgp peers\n")
4942 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4944 return CMD_WARNING_CONFIG_FAILED
;
4946 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4947 ret
= peer_local_as_set(peer
, as
, 1, 0);
4948 return bgp_vty_return(vty
, ret
);
4951 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4952 neighbor_local_as_no_prepend_replace_as_cmd
,
4953 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4956 "Specify a local-as number\n"
4957 "AS number used as local AS\n"
4958 "Do not prepend local-as to updates from ebgp peers\n"
4959 "Do not prepend local-as to updates from ibgp peers\n")
4967 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4969 return CMD_WARNING_CONFIG_FAILED
;
4971 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4972 ret
= peer_local_as_set(peer
, as
, 1, 1);
4973 return bgp_vty_return(vty
, ret
);
4976 DEFUN (no_neighbor_local_as
,
4977 no_neighbor_local_as_cmd
,
4978 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4982 "Specify a local-as number\n"
4983 "AS number used as local AS\n"
4984 "Do not prepend local-as to updates from ebgp peers\n"
4985 "Do not prepend local-as to updates from ibgp peers\n")
4991 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4993 return CMD_WARNING_CONFIG_FAILED
;
4995 ret
= peer_local_as_unset(peer
);
4996 return bgp_vty_return(vty
, ret
);
5000 DEFUN (neighbor_solo
,
5002 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5005 "Solo peer - part of its own update group\n")
5011 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5013 return CMD_WARNING_CONFIG_FAILED
;
5015 ret
= update_group_adjust_soloness(peer
, 1);
5016 return bgp_vty_return(vty
, ret
);
5019 DEFUN (no_neighbor_solo
,
5020 no_neighbor_solo_cmd
,
5021 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5025 "Solo peer - part of its own update group\n")
5031 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5033 return CMD_WARNING_CONFIG_FAILED
;
5035 ret
= update_group_adjust_soloness(peer
, 0);
5036 return bgp_vty_return(vty
, ret
);
5039 DEFUN (neighbor_password
,
5040 neighbor_password_cmd
,
5041 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5052 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5054 return CMD_WARNING_CONFIG_FAILED
;
5056 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5057 return bgp_vty_return(vty
, ret
);
5060 DEFUN (no_neighbor_password
,
5061 no_neighbor_password_cmd
,
5062 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5073 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5075 return CMD_WARNING_CONFIG_FAILED
;
5077 ret
= peer_password_unset(peer
);
5078 return bgp_vty_return(vty
, ret
);
5081 DEFUN (neighbor_activate
,
5082 neighbor_activate_cmd
,
5083 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5086 "Enable the Address Family for this Neighbor\n")
5092 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5094 return CMD_WARNING_CONFIG_FAILED
;
5096 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5097 return bgp_vty_return(vty
, ret
);
5100 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5101 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5102 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5103 "Enable the Address Family for this Neighbor\n")
5105 DEFUN (no_neighbor_activate
,
5106 no_neighbor_activate_cmd
,
5107 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5111 "Enable the Address Family for this Neighbor\n")
5118 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5120 return CMD_WARNING_CONFIG_FAILED
;
5122 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5123 return bgp_vty_return(vty
, ret
);
5126 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5127 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5128 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5129 "Enable the Address Family for this Neighbor\n")
5131 DEFUN (neighbor_set_peer_group
,
5132 neighbor_set_peer_group_cmd
,
5133 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5136 "Member of the peer-group\n"
5137 "Peer-group name\n")
5139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5146 struct peer_group
*group
;
5148 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5150 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5152 vty_out(vty
, "%% Malformed address or name: %s\n",
5153 argv
[idx_peer
]->arg
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5157 if (peer_address_self_check(bgp
, &su
)) {
5159 "%% Can not configure the local system as neighbor\n");
5160 return CMD_WARNING_CONFIG_FAILED
;
5163 /* Disallow for dynamic neighbor. */
5164 peer
= peer_lookup(bgp
, &su
);
5165 if (peer
&& peer_dynamic_neighbor(peer
)) {
5167 "%% Operation not allowed on a dynamic neighbor\n");
5168 return CMD_WARNING_CONFIG_FAILED
;
5172 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5174 vty_out(vty
, "%% Configure the peer-group first\n");
5175 return CMD_WARNING_CONFIG_FAILED
;
5178 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5180 return bgp_vty_return(vty
, ret
);
5183 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5184 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5185 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5186 "Member of the peer-group\n"
5187 "Peer-group name\n")
5189 DEFUN (no_neighbor_set_peer_group
,
5190 no_neighbor_set_peer_group_cmd
,
5191 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5195 "Member of the peer-group\n"
5196 "Peer-group name\n")
5198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5203 struct peer_group
*group
;
5205 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5207 return CMD_WARNING_CONFIG_FAILED
;
5209 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5211 vty_out(vty
, "%% Configure the peer-group first\n");
5212 return CMD_WARNING_CONFIG_FAILED
;
5215 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5216 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5218 peer_notify_unconfig(peer
);
5219 ret
= peer_delete(peer
);
5221 return bgp_vty_return(vty
, ret
);
5224 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5225 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5227 "Member of the peer-group\n"
5228 "Peer-group name\n")
5230 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5231 uint64_t flag
, int set
)
5236 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5238 return CMD_WARNING_CONFIG_FAILED
;
5241 * If 'neighbor <interface>', then this is for directly connected peers,
5242 * we should not accept disable-connected-check.
5244 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5246 "%s is directly connected peer, cannot accept disable-connected-check\n",
5248 return CMD_WARNING_CONFIG_FAILED
;
5251 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5252 peer_tx_shutdown_message_unset(peer
);
5255 ret
= peer_flag_set(peer
, flag
);
5257 ret
= peer_flag_unset(peer
, flag
);
5259 return bgp_vty_return(vty
, ret
);
5262 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5264 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5267 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5270 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5273 /* neighbor passive. */
5274 DEFUN (neighbor_passive
,
5275 neighbor_passive_cmd
,
5276 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5279 "Don't send open messages to this neighbor\n")
5282 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5285 DEFUN (no_neighbor_passive
,
5286 no_neighbor_passive_cmd
,
5287 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5291 "Don't send open messages to this neighbor\n")
5294 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5297 /* neighbor shutdown. */
5298 DEFUN (neighbor_shutdown_msg
,
5299 neighbor_shutdown_msg_cmd
,
5300 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5303 "Administratively shut down this neighbor\n"
5304 "Add a shutdown message (RFC 8203)\n"
5305 "Shutdown message\n")
5311 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5315 return CMD_WARNING_CONFIG_FAILED
;
5316 message
= argv_concat(argv
, argc
, 4);
5317 peer_tx_shutdown_message_set(peer
, message
);
5318 XFREE(MTYPE_TMP
, message
);
5321 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5324 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5325 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5327 "Administratively shut down this neighbor\n")
5329 DEFUN (no_neighbor_shutdown_msg
,
5330 no_neighbor_shutdown_msg_cmd
,
5331 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5335 "Administratively shut down this neighbor\n"
5336 "Remove a shutdown message (RFC 8203)\n"
5337 "Shutdown message\n")
5341 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5342 PEER_FLAG_SHUTDOWN
);
5345 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5346 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5347 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5348 "Administratively shut down this neighbor\n")
5350 DEFUN(neighbor_shutdown_rtt
,
5351 neighbor_shutdown_rtt_cmd
,
5352 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5355 "Administratively shut down this neighbor\n"
5356 "Shutdown if round-trip-time is higher than expected\n"
5357 "Round-trip-time in milliseconds\n"
5358 "Specify the number of keepalives before shutdown\n"
5359 "The number of keepalives with higher RTT to shutdown\n")
5366 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5369 return CMD_WARNING_CONFIG_FAILED
;
5371 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5373 if (argv_find(argv
, argc
, "count", &idx_count
))
5374 peer
->rtt_keepalive_conf
=
5375 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5377 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5378 PEER_FLAG_RTT_SHUTDOWN
);
5381 DEFUN(no_neighbor_shutdown_rtt
,
5382 no_neighbor_shutdown_rtt_cmd
,
5383 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5387 "Administratively shut down this neighbor\n"
5388 "Shutdown if round-trip-time is higher than expected\n"
5389 "Round-trip-time in milliseconds\n"
5390 "Specify the number of keepalives before shutdown\n"
5391 "The number of keepalives with higher RTT to shutdown\n")
5396 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5399 return CMD_WARNING_CONFIG_FAILED
;
5401 peer
->rtt_expected
= 0;
5402 peer
->rtt_keepalive_conf
= 1;
5404 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5405 PEER_FLAG_RTT_SHUTDOWN
);
5408 /* neighbor capability dynamic. */
5409 DEFUN (neighbor_capability_dynamic
,
5410 neighbor_capability_dynamic_cmd
,
5411 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5414 "Advertise capability to the peer\n"
5415 "Advertise dynamic capability to this neighbor\n")
5418 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5419 PEER_FLAG_DYNAMIC_CAPABILITY
);
5422 DEFUN (no_neighbor_capability_dynamic
,
5423 no_neighbor_capability_dynamic_cmd
,
5424 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5428 "Advertise capability to the peer\n"
5429 "Advertise dynamic capability to this neighbor\n")
5432 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5433 PEER_FLAG_DYNAMIC_CAPABILITY
);
5436 /* neighbor dont-capability-negotiate */
5437 DEFUN (neighbor_dont_capability_negotiate
,
5438 neighbor_dont_capability_negotiate_cmd
,
5439 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5442 "Do not perform capability negotiation\n")
5445 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5446 PEER_FLAG_DONT_CAPABILITY
);
5449 DEFUN (no_neighbor_dont_capability_negotiate
,
5450 no_neighbor_dont_capability_negotiate_cmd
,
5451 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5455 "Do not perform capability negotiation\n")
5458 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5459 PEER_FLAG_DONT_CAPABILITY
);
5462 /* neighbor capability extended next hop encoding */
5463 DEFUN (neighbor_capability_enhe
,
5464 neighbor_capability_enhe_cmd
,
5465 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5468 "Advertise capability to the peer\n"
5469 "Advertise extended next-hop capability to the peer\n")
5474 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5475 if (peer
&& peer
->conf_if
)
5478 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5479 PEER_FLAG_CAPABILITY_ENHE
);
5482 DEFUN (no_neighbor_capability_enhe
,
5483 no_neighbor_capability_enhe_cmd
,
5484 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5488 "Advertise capability to the peer\n"
5489 "Advertise extended next-hop capability to the peer\n")
5494 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5495 if (peer
&& peer
->conf_if
) {
5497 "Peer %s cannot have capability extended-nexthop turned off\n",
5498 argv
[idx_peer
]->arg
);
5499 return CMD_WARNING_CONFIG_FAILED
;
5502 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5503 PEER_FLAG_CAPABILITY_ENHE
);
5506 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5507 afi_t afi
, safi_t safi
, uint32_t flag
,
5513 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5515 return CMD_WARNING_CONFIG_FAILED
;
5518 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5520 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5522 return bgp_vty_return(vty
, ret
);
5525 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5526 afi_t afi
, safi_t safi
, uint32_t flag
)
5528 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5531 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5532 afi_t afi
, safi_t safi
, uint32_t flag
)
5534 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5537 /* neighbor capability orf prefix-list. */
5538 DEFUN (neighbor_capability_orf_prefix
,
5539 neighbor_capability_orf_prefix_cmd
,
5540 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5543 "Advertise capability to the peer\n"
5544 "Advertise ORF capability to the peer\n"
5545 "Advertise prefixlist ORF capability to this neighbor\n"
5546 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5547 "Capability to RECEIVE the ORF from this neighbor\n"
5548 "Capability to SEND the ORF to this neighbor\n")
5550 int idx_send_recv
= 5;
5551 char *peer_str
= argv
[1]->arg
;
5553 afi_t afi
= bgp_node_afi(vty
);
5554 safi_t safi
= bgp_node_safi(vty
);
5556 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5561 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5562 PEER_FLAG_ORF_PREFIX_SM
);
5564 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5565 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5566 PEER_FLAG_ORF_PREFIX_RM
);
5568 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5569 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5570 PEER_FLAG_ORF_PREFIX_SM
)
5571 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5572 PEER_FLAG_ORF_PREFIX_RM
);
5574 return CMD_WARNING_CONFIG_FAILED
;
5578 neighbor_capability_orf_prefix
,
5579 neighbor_capability_orf_prefix_hidden_cmd
,
5580 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5582 "Advertise capability to the peer\n"
5583 "Advertise ORF capability to the peer\n"
5584 "Advertise prefixlist ORF capability to this neighbor\n"
5585 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5586 "Capability to RECEIVE the ORF from this neighbor\n"
5587 "Capability to SEND the ORF to this neighbor\n")
5589 DEFUN (no_neighbor_capability_orf_prefix
,
5590 no_neighbor_capability_orf_prefix_cmd
,
5591 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5595 "Advertise capability to the peer\n"
5596 "Advertise ORF capability to the peer\n"
5597 "Advertise prefixlist ORF capability to this neighbor\n"
5598 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5599 "Capability to RECEIVE the ORF from this neighbor\n"
5600 "Capability to SEND the ORF to this neighbor\n")
5602 int idx_send_recv
= 6;
5603 char *peer_str
= argv
[2]->arg
;
5605 afi_t afi
= bgp_node_afi(vty
);
5606 safi_t safi
= bgp_node_safi(vty
);
5608 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5610 return CMD_WARNING_CONFIG_FAILED
;
5612 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5613 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5614 PEER_FLAG_ORF_PREFIX_SM
);
5616 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5617 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5618 PEER_FLAG_ORF_PREFIX_RM
);
5620 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5621 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5622 PEER_FLAG_ORF_PREFIX_SM
)
5623 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5624 PEER_FLAG_ORF_PREFIX_RM
);
5626 return CMD_WARNING_CONFIG_FAILED
;
5630 no_neighbor_capability_orf_prefix
,
5631 no_neighbor_capability_orf_prefix_hidden_cmd
,
5632 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5633 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5634 "Advertise capability to the peer\n"
5635 "Advertise ORF capability to the peer\n"
5636 "Advertise prefixlist ORF capability to this neighbor\n"
5637 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5638 "Capability to RECEIVE the ORF from this neighbor\n"
5639 "Capability to SEND the ORF to this neighbor\n")
5641 /* neighbor next-hop-self. */
5642 DEFUN (neighbor_nexthop_self
,
5643 neighbor_nexthop_self_cmd
,
5644 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5647 "Disable the next hop calculation for this neighbor\n")
5650 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5651 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5654 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5655 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5656 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5657 "Disable the next hop calculation for this neighbor\n")
5659 /* neighbor next-hop-self. */
5660 DEFUN (neighbor_nexthop_self_force
,
5661 neighbor_nexthop_self_force_cmd
,
5662 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5665 "Disable the next hop calculation for this neighbor\n"
5666 "Set the next hop to self for reflected routes\n")
5669 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5671 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5674 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5675 neighbor_nexthop_self_force_hidden_cmd
,
5676 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5677 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5678 "Disable the next hop calculation for this neighbor\n"
5679 "Set the next hop to self for reflected routes\n")
5681 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5682 neighbor_nexthop_self_all_hidden_cmd
,
5683 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5684 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5685 "Disable the next hop calculation for this neighbor\n"
5686 "Set the next hop to self for reflected routes\n")
5688 DEFUN (no_neighbor_nexthop_self
,
5689 no_neighbor_nexthop_self_cmd
,
5690 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5694 "Disable the next hop calculation for this neighbor\n")
5697 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5698 bgp_node_afi(vty
), bgp_node_safi(vty
),
5699 PEER_FLAG_NEXTHOP_SELF
);
5702 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5703 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5704 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5705 "Disable the next hop calculation for this neighbor\n")
5707 DEFUN (no_neighbor_nexthop_self_force
,
5708 no_neighbor_nexthop_self_force_cmd
,
5709 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5713 "Disable the next hop calculation for this neighbor\n"
5714 "Set the next hop to self for reflected routes\n")
5717 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5718 bgp_node_afi(vty
), bgp_node_safi(vty
),
5719 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5722 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5723 no_neighbor_nexthop_self_force_hidden_cmd
,
5724 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5725 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5726 "Disable the next hop calculation for this neighbor\n"
5727 "Set the next hop to self for reflected routes\n")
5729 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5730 no_neighbor_nexthop_self_all_hidden_cmd
,
5731 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5732 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5733 "Disable the next hop calculation for this neighbor\n"
5734 "Set the next hop to self for reflected routes\n")
5736 /* neighbor as-override */
5737 DEFUN (neighbor_as_override
,
5738 neighbor_as_override_cmd
,
5739 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5742 "Override ASNs in outbound updates if aspath equals remote-as\n")
5745 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5746 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5749 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5750 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5751 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5752 "Override ASNs in outbound updates if aspath equals remote-as\n")
5754 DEFUN (no_neighbor_as_override
,
5755 no_neighbor_as_override_cmd
,
5756 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5760 "Override ASNs in outbound updates if aspath equals remote-as\n")
5763 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5764 bgp_node_afi(vty
), bgp_node_safi(vty
),
5765 PEER_FLAG_AS_OVERRIDE
);
5768 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5769 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5770 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5771 "Override ASNs in outbound updates if aspath equals remote-as\n")
5773 /* neighbor remove-private-AS. */
5774 DEFUN (neighbor_remove_private_as
,
5775 neighbor_remove_private_as_cmd
,
5776 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5779 "Remove private ASNs in outbound updates\n")
5782 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5784 PEER_FLAG_REMOVE_PRIVATE_AS
);
5787 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5788 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5789 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5790 "Remove private ASNs in outbound updates\n")
5792 DEFUN (neighbor_remove_private_as_all
,
5793 neighbor_remove_private_as_all_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5797 "Remove private ASNs in outbound updates\n"
5798 "Apply to all AS numbers\n")
5801 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5803 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5806 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5807 neighbor_remove_private_as_all_hidden_cmd
,
5808 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5809 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5810 "Remove private ASNs in outbound updates\n"
5811 "Apply to all AS numbers")
5813 DEFUN (neighbor_remove_private_as_replace_as
,
5814 neighbor_remove_private_as_replace_as_cmd
,
5815 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5818 "Remove private ASNs in outbound updates\n"
5819 "Replace private ASNs with our ASN in outbound updates\n")
5822 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5824 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5827 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5828 neighbor_remove_private_as_replace_as_hidden_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5830 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5831 "Remove private ASNs in outbound updates\n"
5832 "Replace private ASNs with our ASN in outbound updates\n")
5834 DEFUN (neighbor_remove_private_as_all_replace_as
,
5835 neighbor_remove_private_as_all_replace_as_cmd
,
5836 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5839 "Remove private ASNs in outbound updates\n"
5840 "Apply to all AS numbers\n"
5841 "Replace private ASNs with our ASN in outbound updates\n")
5844 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5846 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5850 neighbor_remove_private_as_all_replace_as
,
5851 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5852 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5853 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5854 "Remove private ASNs in outbound updates\n"
5855 "Apply to all AS numbers\n"
5856 "Replace private ASNs with our ASN in outbound updates\n")
5858 DEFUN (no_neighbor_remove_private_as
,
5859 no_neighbor_remove_private_as_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5864 "Remove private ASNs in outbound updates\n")
5867 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5868 bgp_node_afi(vty
), bgp_node_safi(vty
),
5869 PEER_FLAG_REMOVE_PRIVATE_AS
);
5872 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5873 no_neighbor_remove_private_as_hidden_cmd
,
5874 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5875 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5876 "Remove private ASNs in outbound updates\n")
5878 DEFUN (no_neighbor_remove_private_as_all
,
5879 no_neighbor_remove_private_as_all_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5884 "Remove private ASNs in outbound updates\n"
5885 "Apply to all AS numbers\n")
5888 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5889 bgp_node_afi(vty
), bgp_node_safi(vty
),
5890 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5893 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5894 no_neighbor_remove_private_as_all_hidden_cmd
,
5895 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5896 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5897 "Remove private ASNs in outbound updates\n"
5898 "Apply to all AS numbers\n")
5900 DEFUN (no_neighbor_remove_private_as_replace_as
,
5901 no_neighbor_remove_private_as_replace_as_cmd
,
5902 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5906 "Remove private ASNs in outbound updates\n"
5907 "Replace private ASNs with our ASN in outbound updates\n")
5910 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5911 bgp_node_afi(vty
), bgp_node_safi(vty
),
5912 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5915 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5916 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5917 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5918 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5919 "Remove private ASNs in outbound updates\n"
5920 "Replace private ASNs with our ASN in outbound updates\n")
5922 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5923 no_neighbor_remove_private_as_all_replace_as_cmd
,
5924 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5928 "Remove private ASNs in outbound updates\n"
5929 "Apply to all AS numbers\n"
5930 "Replace private ASNs with our ASN in outbound updates\n")
5933 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5934 bgp_node_afi(vty
), bgp_node_safi(vty
),
5935 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5939 no_neighbor_remove_private_as_all_replace_as
,
5940 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5941 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5942 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5943 "Remove private ASNs in outbound updates\n"
5944 "Apply to all AS numbers\n"
5945 "Replace private ASNs with our ASN in outbound updates\n")
5948 /* neighbor send-community. */
5949 DEFUN (neighbor_send_community
,
5950 neighbor_send_community_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5954 "Send Community attribute to this neighbor\n")
5958 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5960 PEER_FLAG_SEND_COMMUNITY
);
5963 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5964 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5966 "Send Community attribute to this neighbor\n")
5968 DEFUN (no_neighbor_send_community
,
5969 no_neighbor_send_community_cmd
,
5970 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5974 "Send Community attribute to this neighbor\n")
5978 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5979 bgp_node_afi(vty
), bgp_node_safi(vty
),
5980 PEER_FLAG_SEND_COMMUNITY
);
5983 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5984 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5985 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5986 "Send Community attribute to this neighbor\n")
5988 /* neighbor send-community extended. */
5989 DEFUN (neighbor_send_community_type
,
5990 neighbor_send_community_type_cmd
,
5991 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5994 "Send Community attribute to this neighbor\n"
5995 "Send Standard and Extended Community attributes\n"
5996 "Send Standard, Large and Extended Community attributes\n"
5997 "Send Extended Community attributes\n"
5998 "Send Standard Community attributes\n"
5999 "Send Large Community attributes\n")
6001 const char *type
= argv
[argc
- 1]->text
;
6002 char *peer_str
= argv
[1]->arg
;
6004 afi_t afi
= bgp_node_afi(vty
);
6005 safi_t safi
= bgp_node_safi(vty
);
6007 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6009 return CMD_WARNING_CONFIG_FAILED
;
6011 if (strmatch(type
, "standard"))
6012 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6013 PEER_FLAG_SEND_COMMUNITY
);
6015 if (strmatch(type
, "extended"))
6016 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6017 PEER_FLAG_SEND_EXT_COMMUNITY
);
6019 if (strmatch(type
, "large"))
6020 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6021 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6023 if (strmatch(type
, "both")) {
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
);
6029 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6030 PEER_FLAG_SEND_COMMUNITY
)
6031 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6032 PEER_FLAG_SEND_EXT_COMMUNITY
)
6033 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6034 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6038 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6039 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6040 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6041 "Send Community attribute to this neighbor\n"
6042 "Send Standard and Extended Community attributes\n"
6043 "Send Standard, Large and Extended Community attributes\n"
6044 "Send Extended Community attributes\n"
6045 "Send Standard Community attributes\n"
6046 "Send Large Community attributes\n")
6048 DEFUN (no_neighbor_send_community_type
,
6049 no_neighbor_send_community_type_cmd
,
6050 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6054 "Send Community attribute to this neighbor\n"
6055 "Send Standard and Extended Community attributes\n"
6056 "Send Standard, Large and Extended Community attributes\n"
6057 "Send Extended Community attributes\n"
6058 "Send Standard Community attributes\n"
6059 "Send Large Community attributes\n")
6061 const char *type
= argv
[argc
- 1]->text
;
6062 char *peer_str
= argv
[2]->arg
;
6064 afi_t afi
= bgp_node_afi(vty
);
6065 safi_t safi
= bgp_node_safi(vty
);
6067 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6069 return CMD_WARNING_CONFIG_FAILED
;
6071 if (strmatch(type
, "standard"))
6072 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6073 PEER_FLAG_SEND_COMMUNITY
);
6075 if (strmatch(type
, "extended"))
6076 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6077 PEER_FLAG_SEND_EXT_COMMUNITY
);
6079 if (strmatch(type
, "large"))
6080 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6081 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6083 if (strmatch(type
, "both")) {
6085 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6086 PEER_FLAG_SEND_COMMUNITY
)
6087 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6088 PEER_FLAG_SEND_EXT_COMMUNITY
);
6091 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6092 PEER_FLAG_SEND_COMMUNITY
)
6093 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6094 PEER_FLAG_SEND_EXT_COMMUNITY
)
6095 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6096 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6100 no_neighbor_send_community_type
,
6101 no_neighbor_send_community_type_hidden_cmd
,
6102 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6103 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Send Community attribute to this neighbor\n"
6105 "Send Standard and Extended Community attributes\n"
6106 "Send Standard, Large and Extended Community attributes\n"
6107 "Send Extended Community attributes\n"
6108 "Send Standard Community attributes\n"
6109 "Send Large Community attributes\n")
6111 /* neighbor soft-reconfig. */
6112 DEFUN (neighbor_soft_reconfiguration
,
6113 neighbor_soft_reconfiguration_cmd
,
6114 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6117 "Per neighbor soft reconfiguration\n"
6118 "Allow inbound soft reconfiguration for this neighbor\n")
6121 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6123 PEER_FLAG_SOFT_RECONFIG
);
6126 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6127 neighbor_soft_reconfiguration_hidden_cmd
,
6128 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6130 "Per neighbor soft reconfiguration\n"
6131 "Allow inbound soft reconfiguration for this neighbor\n")
6133 DEFUN (no_neighbor_soft_reconfiguration
,
6134 no_neighbor_soft_reconfiguration_cmd
,
6135 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6139 "Per neighbor soft reconfiguration\n"
6140 "Allow inbound soft reconfiguration for this neighbor\n")
6143 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6144 bgp_node_afi(vty
), bgp_node_safi(vty
),
6145 PEER_FLAG_SOFT_RECONFIG
);
6148 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6149 no_neighbor_soft_reconfiguration_hidden_cmd
,
6150 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6152 "Per neighbor soft reconfiguration\n"
6153 "Allow inbound soft reconfiguration for this neighbor\n")
6155 DEFUN (neighbor_route_reflector_client
,
6156 neighbor_route_reflector_client_cmd
,
6157 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6160 "Configure a neighbor as Route Reflector client\n")
6166 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6168 return CMD_WARNING_CONFIG_FAILED
;
6170 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6172 PEER_FLAG_REFLECTOR_CLIENT
);
6175 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6176 neighbor_route_reflector_client_hidden_cmd
,
6177 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6178 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6179 "Configure a neighbor as Route Reflector client\n")
6181 DEFUN (no_neighbor_route_reflector_client
,
6182 no_neighbor_route_reflector_client_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6187 "Configure a neighbor as Route Reflector client\n")
6190 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6191 bgp_node_afi(vty
), bgp_node_safi(vty
),
6192 PEER_FLAG_REFLECTOR_CLIENT
);
6195 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6196 no_neighbor_route_reflector_client_hidden_cmd
,
6197 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6198 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6199 "Configure a neighbor as Route Reflector client\n")
6201 /* optimal-route-reflection Root Routers configuration */
6202 DEFPY (optimal_route_reflection
,
6203 optimal_route_reflection_cmd
,
6204 "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]",
6206 "Create ORR group and assign root router(s)\n"
6208 "Primary Root address\n"
6209 "Primary Root IPv6 address\n"
6210 "Secondary Root address\n"
6211 "Secondary Root IPv6 address\n"
6212 "Tertiary Root address\n"
6213 "Tertiary Root IPv6 address\n")
6215 if (!no
&& !primary
) {
6216 vty_out(vty
, "%% Specify Primary Root address\n");
6217 return CMD_WARNING_CONFIG_FAILED
;
6219 return bgp_afi_safi_orr_group_set_vty(
6220 vty
, bgp_node_afi(vty
), bgp_node_safi(vty
), orr_group
,
6221 primary_str
, secondary_str
, tertiary_str
, !no
);
6224 /* neighbor optimal-route-reflection group*/
6225 DEFPY (neighbor_optimal_route_reflection
,
6226 neighbor_optimal_route_reflection_cmd
,
6227 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group",
6231 "Apply ORR group configuration to the neighbor\n"
6234 return peer_orr_group_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
6235 bgp_node_safi(vty
), orr_group
, !no
);
6238 /* neighbor route-server-client. */
6239 DEFUN (neighbor_route_server_client
,
6240 neighbor_route_server_client_cmd
,
6241 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6244 "Configure a neighbor as Route Server client\n")
6249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6251 return CMD_WARNING_CONFIG_FAILED
;
6252 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6254 PEER_FLAG_RSERVER_CLIENT
);
6257 ALIAS_HIDDEN(neighbor_route_server_client
,
6258 neighbor_route_server_client_hidden_cmd
,
6259 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6260 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6261 "Configure a neighbor as Route Server client\n")
6263 DEFUN (no_neighbor_route_server_client
,
6264 no_neighbor_route_server_client_cmd
,
6265 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6269 "Configure a neighbor as Route Server client\n")
6272 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6273 bgp_node_afi(vty
), bgp_node_safi(vty
),
6274 PEER_FLAG_RSERVER_CLIENT
);
6277 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6278 no_neighbor_route_server_client_hidden_cmd
,
6279 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6280 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6281 "Configure a neighbor as Route Server client\n")
6283 DEFUN (neighbor_nexthop_local_unchanged
,
6284 neighbor_nexthop_local_unchanged_cmd
,
6285 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6288 "Configure treatment of outgoing link-local nexthop attribute\n"
6289 "Leave link-local nexthop unchanged for this peer\n")
6292 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6294 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6297 DEFUN (no_neighbor_nexthop_local_unchanged
,
6298 no_neighbor_nexthop_local_unchanged_cmd
,
6299 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6303 "Configure treatment of outgoing link-local-nexthop attribute\n"
6304 "Leave link-local nexthop unchanged for this peer\n")
6307 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6308 bgp_node_afi(vty
), bgp_node_safi(vty
),
6309 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6312 DEFUN (neighbor_attr_unchanged
,
6313 neighbor_attr_unchanged_cmd
,
6314 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6317 "BGP attribute is propagated unchanged to this neighbor\n"
6318 "As-path attribute\n"
6319 "Nexthop attribute\n"
6323 char *peer_str
= argv
[1]->arg
;
6325 bool aspath
= false;
6326 bool nexthop
= false;
6328 afi_t afi
= bgp_node_afi(vty
);
6329 safi_t safi
= bgp_node_safi(vty
);
6332 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6334 return CMD_WARNING_CONFIG_FAILED
;
6336 if (argv_find(argv
, argc
, "as-path", &idx
))
6340 if (argv_find(argv
, argc
, "next-hop", &idx
))
6344 if (argv_find(argv
, argc
, "med", &idx
))
6347 /* no flags means all of them! */
6348 if (!aspath
&& !nexthop
&& !med
) {
6349 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6350 PEER_FLAG_AS_PATH_UNCHANGED
);
6351 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6352 PEER_FLAG_NEXTHOP_UNCHANGED
);
6353 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6354 PEER_FLAG_MED_UNCHANGED
);
6357 if (peer_af_flag_check(peer
, afi
, safi
,
6358 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6359 ret
|= peer_af_flag_unset_vty(
6360 vty
, peer_str
, afi
, safi
,
6361 PEER_FLAG_AS_PATH_UNCHANGED
);
6364 ret
|= peer_af_flag_set_vty(
6365 vty
, peer_str
, afi
, safi
,
6366 PEER_FLAG_AS_PATH_UNCHANGED
);
6369 if (peer_af_flag_check(peer
, afi
, safi
,
6370 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6371 ret
|= peer_af_flag_unset_vty(
6372 vty
, peer_str
, afi
, safi
,
6373 PEER_FLAG_NEXTHOP_UNCHANGED
);
6376 ret
|= peer_af_flag_set_vty(
6377 vty
, peer_str
, afi
, safi
,
6378 PEER_FLAG_NEXTHOP_UNCHANGED
);
6381 if (peer_af_flag_check(peer
, afi
, safi
,
6382 PEER_FLAG_MED_UNCHANGED
)) {
6383 ret
|= peer_af_flag_unset_vty(
6384 vty
, peer_str
, afi
, safi
,
6385 PEER_FLAG_MED_UNCHANGED
);
6388 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6389 PEER_FLAG_MED_UNCHANGED
);
6396 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6397 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6398 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6399 "BGP attribute is propagated unchanged to this neighbor\n"
6400 "As-path attribute\n"
6401 "Nexthop attribute\n"
6404 DEFUN (no_neighbor_attr_unchanged
,
6405 no_neighbor_attr_unchanged_cmd
,
6406 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6410 "BGP attribute is propagated unchanged to this neighbor\n"
6411 "As-path attribute\n"
6412 "Nexthop attribute\n"
6416 char *peer_str
= argv
[2]->arg
;
6418 bool aspath
= false;
6419 bool nexthop
= false;
6421 afi_t afi
= bgp_node_afi(vty
);
6422 safi_t safi
= bgp_node_safi(vty
);
6425 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6427 return CMD_WARNING_CONFIG_FAILED
;
6429 if (argv_find(argv
, argc
, "as-path", &idx
))
6433 if (argv_find(argv
, argc
, "next-hop", &idx
))
6437 if (argv_find(argv
, argc
, "med", &idx
))
6440 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6441 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6442 PEER_FLAG_AS_PATH_UNCHANGED
)
6443 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6444 PEER_FLAG_NEXTHOP_UNCHANGED
)
6445 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6446 PEER_FLAG_MED_UNCHANGED
);
6449 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6450 PEER_FLAG_AS_PATH_UNCHANGED
);
6453 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6454 PEER_FLAG_NEXTHOP_UNCHANGED
);
6457 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6458 PEER_FLAG_MED_UNCHANGED
);
6464 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6465 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6466 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6467 "BGP attribute is propagated unchanged to this neighbor\n"
6468 "As-path attribute\n"
6469 "Nexthop attribute\n"
6472 /* EBGP multihop configuration. */
6473 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6474 const char *ttl_str
)
6479 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6481 return CMD_WARNING_CONFIG_FAILED
;
6484 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6489 ttl
= strtoul(ttl_str
, NULL
, 10);
6491 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6494 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6498 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6500 return CMD_WARNING_CONFIG_FAILED
;
6502 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6505 /* neighbor ebgp-multihop. */
6506 DEFUN (neighbor_ebgp_multihop
,
6507 neighbor_ebgp_multihop_cmd
,
6508 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6511 "Allow EBGP neighbors not on directly connected networks\n")
6514 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6517 DEFUN (neighbor_ebgp_multihop_ttl
,
6518 neighbor_ebgp_multihop_ttl_cmd
,
6519 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6522 "Allow EBGP neighbors not on directly connected networks\n"
6523 "maximum hop count\n")
6527 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6528 argv
[idx_number
]->arg
);
6531 DEFUN (no_neighbor_ebgp_multihop
,
6532 no_neighbor_ebgp_multihop_cmd
,
6533 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6537 "Allow EBGP neighbors not on directly connected networks\n"
6538 "maximum hop count\n")
6541 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6544 static uint8_t get_role_by_name(const char *role_str
)
6546 if (strncmp(role_str
, "peer", 2) == 0)
6548 if (strncmp(role_str
, "provider", 2) == 0)
6549 return ROLE_PROVIDER
;
6550 if (strncmp(role_str
, "customer", 2) == 0)
6551 return ROLE_CUSTOMER
;
6552 if (strncmp(role_str
, "rs-server", 4) == 0)
6553 return ROLE_RS_SERVER
;
6554 if (strncmp(role_str
, "rs-client", 4) == 0)
6555 return ROLE_RS_CLIENT
;
6556 return ROLE_UNDEFINED
;
6559 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6560 const char *role_str
, bool strict_mode
)
6564 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6566 return CMD_WARNING_CONFIG_FAILED
;
6567 uint8_t role
= get_role_by_name(role_str
);
6569 if (role
== ROLE_UNDEFINED
)
6570 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6571 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6574 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6580 return CMD_WARNING_CONFIG_FAILED
;
6581 return bgp_vty_return(vty
, peer_role_unset(peer
));
6584 DEFPY(neighbor_role
,
6586 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6589 "Set session role\n"
6595 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6599 DEFPY(neighbor_role_strict
,
6600 neighbor_role_strict_cmd
,
6601 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6604 "Set session role\n"
6606 "Use additional restriction on peer\n")
6611 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6615 DEFPY(no_neighbor_role
,
6616 no_neighbor_role_cmd
,
6617 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6621 "Set session role\n"
6623 "Use additional restriction on peer\n")
6627 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6630 /* disable-connected-check */
6631 DEFUN (neighbor_disable_connected_check
,
6632 neighbor_disable_connected_check_cmd
,
6633 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6636 "one-hop away EBGP peer using loopback address\n"
6637 "Enforce EBGP neighbors perform multihop\n")
6640 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6641 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6644 DEFUN (no_neighbor_disable_connected_check
,
6645 no_neighbor_disable_connected_check_cmd
,
6646 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6650 "one-hop away EBGP peer using loopback address\n"
6651 "Enforce EBGP neighbors perform multihop\n")
6654 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6655 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6658 /* disable-link-bw-encoding-ieee */
6659 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6660 neighbor_disable_link_bw_encoding_ieee_cmd
,
6661 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6662 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6663 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6667 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6668 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6671 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6672 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6673 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6674 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6675 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6679 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6680 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6683 /* extended-optional-parameters */
6684 DEFUN(neighbor_extended_optional_parameters
,
6685 neighbor_extended_optional_parameters_cmd
,
6686 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6687 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6688 "Force the extended optional parameters format for OPEN messages\n")
6692 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6693 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6696 DEFUN(no_neighbor_extended_optional_parameters
,
6697 no_neighbor_extended_optional_parameters_cmd
,
6698 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6699 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6700 "Force the extended optional parameters format for OPEN messages\n")
6704 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6705 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6708 /* enforce-first-as */
6709 DEFUN (neighbor_enforce_first_as
,
6710 neighbor_enforce_first_as_cmd
,
6711 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6714 "Enforce the first AS for EBGP routes\n")
6718 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6719 PEER_FLAG_ENFORCE_FIRST_AS
);
6722 DEFUN (no_neighbor_enforce_first_as
,
6723 no_neighbor_enforce_first_as_cmd
,
6724 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6728 "Enforce the first AS for EBGP routes\n")
6732 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6733 PEER_FLAG_ENFORCE_FIRST_AS
);
6737 DEFUN (neighbor_description
,
6738 neighbor_description_cmd
,
6739 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6742 "Neighbor specific description\n"
6743 "Up to 80 characters describing this neighbor\n")
6750 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6752 return CMD_WARNING_CONFIG_FAILED
;
6754 str
= argv_concat(argv
, argc
, idx_line
);
6756 peer_description_set(peer
, str
);
6758 XFREE(MTYPE_TMP
, str
);
6763 DEFUN (no_neighbor_description
,
6764 no_neighbor_description_cmd
,
6765 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6769 "Neighbor specific description\n")
6774 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6776 return CMD_WARNING_CONFIG_FAILED
;
6778 peer_description_unset(peer
);
6783 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6784 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6785 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6786 "Neighbor specific description\n"
6787 "Up to 80 characters describing this neighbor\n")
6789 /* Neighbor update-source. */
6790 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6791 const char *source_str
)
6797 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6799 return CMD_WARNING_CONFIG_FAILED
;
6805 if (str2sockunion(source_str
, &su
) == 0)
6806 peer_update_source_addr_set(peer
, &su
);
6808 if (str2prefix(source_str
, &p
)) {
6810 "%% Invalid update-source, remove prefix length \n");
6811 return CMD_WARNING_CONFIG_FAILED
;
6813 peer_update_source_if_set(peer
, source_str
);
6816 peer_update_source_unset(peer
);
6821 #define BGP_UPDATE_SOURCE_HELP_STR \
6824 "Interface name (requires zebra to be running)\n"
6826 DEFUN (neighbor_update_source
,
6827 neighbor_update_source_cmd
,
6828 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6831 "Source of routing updates\n"
6832 BGP_UPDATE_SOURCE_HELP_STR
)
6836 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6837 argv
[idx_peer_2
]->arg
);
6840 DEFUN (no_neighbor_update_source
,
6841 no_neighbor_update_source_cmd
,
6842 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6846 "Source of routing updates\n"
6847 BGP_UPDATE_SOURCE_HELP_STR
)
6850 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6853 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6854 afi_t afi
, safi_t safi
,
6855 const char *rmap
, int set
)
6859 struct route_map
*route_map
= NULL
;
6861 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6863 return CMD_WARNING_CONFIG_FAILED
;
6867 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6868 ret
= peer_default_originate_set(peer
, afi
, safi
,
6871 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6873 return bgp_vty_return(vty
, ret
);
6876 /* neighbor default-originate. */
6877 DEFUN (neighbor_default_originate
,
6878 neighbor_default_originate_cmd
,
6879 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6882 "Originate default route to this neighbor\n")
6885 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6887 bgp_node_safi(vty
), NULL
, 1);
6890 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6891 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6892 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6893 "Originate default route to this neighbor\n")
6895 DEFUN (neighbor_default_originate_rmap
,
6896 neighbor_default_originate_rmap_cmd
,
6897 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6900 "Originate default route to this neighbor\n"
6901 "Route-map to specify criteria to originate default\n"
6906 return peer_default_originate_set_vty(
6907 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6908 argv
[idx_word
]->arg
, 1);
6912 neighbor_default_originate_rmap
,
6913 neighbor_default_originate_rmap_hidden_cmd
,
6914 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6915 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6916 "Originate default route to this neighbor\n"
6917 "Route-map to specify criteria to originate default\n"
6920 DEFUN (no_neighbor_default_originate
,
6921 no_neighbor_default_originate_cmd
,
6922 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6926 "Originate default route to this neighbor\n"
6927 "Route-map to specify criteria to originate default\n"
6931 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6933 bgp_node_safi(vty
), NULL
, 0);
6937 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6938 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6939 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6940 "Originate default route to this neighbor\n"
6941 "Route-map to specify criteria to originate default\n"
6945 /* Set neighbor's BGP port. */
6946 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6947 const char *port_str
)
6953 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6955 return CMD_WARNING_CONFIG_FAILED
;
6958 sp
= getservbyname("bgp", "tcp");
6959 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6961 port
= strtoul(port_str
, NULL
, 10);
6964 peer_port_set(peer
, port
);
6969 /* Set specified peer's BGP port. */
6970 DEFUN (neighbor_port
,
6972 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6975 "Neighbor's BGP port\n"
6976 "TCP port number\n")
6980 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6981 argv
[idx_number
]->arg
);
6984 DEFUN (no_neighbor_port
,
6985 no_neighbor_port_cmd
,
6986 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6990 "Neighbor's BGP port\n"
6991 "TCP port number\n")
6994 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6998 /* neighbor weight. */
6999 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7000 safi_t safi
, const char *weight_str
)
7004 unsigned long weight
;
7006 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7008 return CMD_WARNING_CONFIG_FAILED
;
7010 weight
= strtoul(weight_str
, NULL
, 10);
7012 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7013 return bgp_vty_return(vty
, ret
);
7016 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7022 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7024 return CMD_WARNING_CONFIG_FAILED
;
7026 ret
= peer_weight_unset(peer
, afi
, safi
);
7027 return bgp_vty_return(vty
, ret
);
7030 DEFUN (neighbor_weight
,
7031 neighbor_weight_cmd
,
7032 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7035 "Set default weight for routes from this neighbor\n"
7040 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7041 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7044 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7045 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7046 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7047 "Set default weight for routes from this neighbor\n"
7050 DEFUN (no_neighbor_weight
,
7051 no_neighbor_weight_cmd
,
7052 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7056 "Set default weight for routes from this neighbor\n"
7060 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7061 bgp_node_afi(vty
), bgp_node_safi(vty
));
7064 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7065 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7066 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7067 "Set default weight for routes from this neighbor\n"
7071 /* Override capability negotiation. */
7072 DEFUN (neighbor_override_capability
,
7073 neighbor_override_capability_cmd
,
7074 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7077 "Override capability negotiation result\n")
7080 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7081 PEER_FLAG_OVERRIDE_CAPABILITY
);
7084 DEFUN (no_neighbor_override_capability
,
7085 no_neighbor_override_capability_cmd
,
7086 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7090 "Override capability negotiation result\n")
7093 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7094 PEER_FLAG_OVERRIDE_CAPABILITY
);
7097 DEFUN (neighbor_strict_capability
,
7098 neighbor_strict_capability_cmd
,
7099 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7102 "Strict capability negotiation match\n")
7106 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7107 PEER_FLAG_STRICT_CAP_MATCH
);
7110 DEFUN (no_neighbor_strict_capability
,
7111 no_neighbor_strict_capability_cmd
,
7112 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7116 "Strict capability negotiation match\n")
7120 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7121 PEER_FLAG_STRICT_CAP_MATCH
);
7124 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7125 const char *keep_str
, const char *hold_str
)
7132 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7134 return CMD_WARNING_CONFIG_FAILED
;
7136 keepalive
= strtoul(keep_str
, NULL
, 10);
7137 holdtime
= strtoul(hold_str
, NULL
, 10);
7139 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7141 return bgp_vty_return(vty
, ret
);
7144 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7149 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7151 return CMD_WARNING_CONFIG_FAILED
;
7153 ret
= peer_timers_unset(peer
);
7155 return bgp_vty_return(vty
, ret
);
7158 DEFUN (neighbor_timers
,
7159 neighbor_timers_cmd
,
7160 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7163 "BGP per neighbor timers\n"
7164 "Keepalive interval\n"
7169 int idx_number_2
= 4;
7170 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7171 argv
[idx_number
]->arg
,
7172 argv
[idx_number_2
]->arg
);
7175 DEFUN (no_neighbor_timers
,
7176 no_neighbor_timers_cmd
,
7177 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7181 "BGP per neighbor timers\n"
7182 "Keepalive interval\n"
7186 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7190 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7191 const char *time_str
)
7197 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7199 return CMD_WARNING_CONFIG_FAILED
;
7201 connect
= strtoul(time_str
, NULL
, 10);
7203 ret
= peer_timers_connect_set(peer
, connect
);
7205 return bgp_vty_return(vty
, ret
);
7208 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7213 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7215 return CMD_WARNING_CONFIG_FAILED
;
7217 ret
= peer_timers_connect_unset(peer
);
7219 return bgp_vty_return(vty
, ret
);
7222 DEFUN (neighbor_timers_connect
,
7223 neighbor_timers_connect_cmd
,
7224 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7227 "BGP per neighbor timers\n"
7228 "BGP connect timer\n"
7233 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7234 argv
[idx_number
]->arg
);
7237 DEFUN (no_neighbor_timers_connect
,
7238 no_neighbor_timers_connect_cmd
,
7239 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7243 "BGP per neighbor timers\n"
7244 "BGP connect timer\n"
7248 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7251 DEFPY (neighbor_timers_delayopen
,
7252 neighbor_timers_delayopen_cmd
,
7253 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7256 "BGP per neighbor timers\n"
7257 "RFC 4271 DelayOpenTimer\n"
7258 "DelayOpenTime timer interval\n")
7262 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7264 return CMD_WARNING_CONFIG_FAILED
;
7267 if (peer_timers_delayopen_unset(peer
))
7268 return CMD_WARNING_CONFIG_FAILED
;
7270 if (peer_timers_delayopen_set(peer
, interval
))
7271 return CMD_WARNING_CONFIG_FAILED
;
7277 DEFPY (no_neighbor_timers_delayopen
,
7278 no_neighbor_timers_delayopen_cmd
,
7279 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7283 "BGP per neighbor timers\n"
7284 "RFC 4271 DelayOpenTimer\n"
7285 "DelayOpenTime timer interval\n")
7289 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7291 return CMD_WARNING_CONFIG_FAILED
;
7293 if (peer_timers_delayopen_unset(peer
))
7294 return CMD_WARNING_CONFIG_FAILED
;
7299 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7300 const char *time_str
, int set
)
7304 uint32_t routeadv
= 0;
7306 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7308 return CMD_WARNING_CONFIG_FAILED
;
7311 routeadv
= strtoul(time_str
, NULL
, 10);
7314 ret
= peer_advertise_interval_set(peer
, routeadv
);
7316 ret
= peer_advertise_interval_unset(peer
);
7318 return bgp_vty_return(vty
, ret
);
7321 DEFUN (neighbor_advertise_interval
,
7322 neighbor_advertise_interval_cmd
,
7323 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7326 "Minimum interval between sending BGP routing updates\n"
7327 "time in seconds\n")
7331 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7332 argv
[idx_number
]->arg
, 1);
7335 DEFUN (no_neighbor_advertise_interval
,
7336 no_neighbor_advertise_interval_cmd
,
7337 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7341 "Minimum interval between sending BGP routing updates\n"
7342 "time in seconds\n")
7345 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7349 /* Time to wait before processing route-map updates */
7350 DEFUN (bgp_set_route_map_delay_timer
,
7351 bgp_set_route_map_delay_timer_cmd
,
7352 "bgp route-map delay-timer (0-600)",
7354 "BGP route-map delay timer\n"
7355 "Time in secs to wait before processing route-map changes\n"
7356 "0 disables the timer, no route updates happen when route-maps change\n")
7359 uint32_t rmap_delay_timer
;
7361 if (argv
[idx_number
]->arg
) {
7362 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7363 bm
->rmap_update_timer
= rmap_delay_timer
;
7365 /* if the dynamic update handling is being disabled, and a timer
7367 * running, stop the timer and act as if the timer has already
7370 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7371 THREAD_OFF(bm
->t_rmap_update
);
7372 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7377 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7378 return CMD_WARNING_CONFIG_FAILED
;
7382 DEFUN (no_bgp_set_route_map_delay_timer
,
7383 no_bgp_set_route_map_delay_timer_cmd
,
7384 "no bgp route-map delay-timer [(0-600)]",
7387 "Default BGP route-map delay timer\n"
7388 "Reset to default time to wait for processing route-map changes\n"
7389 "0 disables the timer, no route updates happen when route-maps change\n")
7392 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7397 /* neighbor interface */
7398 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7403 peer
= peer_lookup_vty(vty
, ip_str
);
7404 if (!peer
|| peer
->conf_if
) {
7405 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7406 return CMD_WARNING_CONFIG_FAILED
;
7410 peer_interface_set(peer
, str
);
7412 peer_interface_unset(peer
);
7417 DEFUN (neighbor_interface
,
7418 neighbor_interface_cmd
,
7419 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7428 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7431 DEFUN (no_neighbor_interface
,
7432 no_neighbor_interface_cmd
,
7433 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7442 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7445 DEFUN (neighbor_distribute_list
,
7446 neighbor_distribute_list_cmd
,
7447 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7450 "Filter updates to/from this neighbor\n"
7451 "IP Access-list name\n"
7452 "Filter incoming updates\n"
7453 "Filter outgoing updates\n")
7460 const char *pstr
= argv
[idx_peer
]->arg
;
7461 const char *acl
= argv
[idx_acl
]->arg
;
7462 const char *inout
= argv
[argc
- 1]->text
;
7464 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7466 return CMD_WARNING_CONFIG_FAILED
;
7468 /* Check filter direction. */
7469 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7470 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7473 return bgp_vty_return(vty
, ret
);
7477 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7478 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7479 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7480 "Filter updates to/from this neighbor\n"
7481 "IP Access-list name\n"
7482 "Filter incoming updates\n"
7483 "Filter outgoing updates\n")
7485 DEFUN (no_neighbor_distribute_list
,
7486 no_neighbor_distribute_list_cmd
,
7487 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7491 "Filter updates to/from this neighbor\n"
7492 "IP Access-list name\n"
7493 "Filter incoming updates\n"
7494 "Filter outgoing updates\n")
7500 const char *pstr
= argv
[idx_peer
]->arg
;
7501 const char *inout
= argv
[argc
- 1]->text
;
7503 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7505 return CMD_WARNING_CONFIG_FAILED
;
7507 /* Check filter direction. */
7508 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7509 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7512 return bgp_vty_return(vty
, ret
);
7516 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7517 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7518 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7519 "Filter updates to/from this neighbor\n"
7520 "IP Access-list name\n"
7521 "Filter incoming updates\n"
7522 "Filter outgoing updates\n")
7524 /* Set prefix list to the peer. */
7525 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7526 afi_t afi
, safi_t safi
,
7527 const char *name_str
,
7528 const char *direct_str
)
7531 int direct
= FILTER_IN
;
7534 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7536 return CMD_WARNING_CONFIG_FAILED
;
7538 /* Check filter direction. */
7539 if (strncmp(direct_str
, "i", 1) == 0)
7541 else if (strncmp(direct_str
, "o", 1) == 0)
7542 direct
= FILTER_OUT
;
7544 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7546 return bgp_vty_return(vty
, ret
);
7549 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7550 afi_t afi
, safi_t safi
,
7551 const char *direct_str
)
7555 int direct
= FILTER_IN
;
7557 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7559 return CMD_WARNING_CONFIG_FAILED
;
7561 /* Check filter direction. */
7562 if (strncmp(direct_str
, "i", 1) == 0)
7564 else if (strncmp(direct_str
, "o", 1) == 0)
7565 direct
= FILTER_OUT
;
7567 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7569 return bgp_vty_return(vty
, ret
);
7572 DEFUN (neighbor_prefix_list
,
7573 neighbor_prefix_list_cmd
,
7574 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
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")
7585 return peer_prefix_list_set_vty(
7586 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7587 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7590 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7591 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7592 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7593 "Filter updates to/from this neighbor\n"
7594 "Name of a prefix list\n"
7595 "Filter incoming updates\n"
7596 "Filter outgoing updates\n")
7598 DEFUN (no_neighbor_prefix_list
,
7599 no_neighbor_prefix_list_cmd
,
7600 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7604 "Filter updates to/from this neighbor\n"
7605 "Name of a prefix list\n"
7606 "Filter incoming updates\n"
7607 "Filter outgoing updates\n")
7611 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7612 bgp_node_afi(vty
), bgp_node_safi(vty
),
7613 argv
[idx_in_out
]->arg
);
7616 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7617 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7618 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7619 "Filter updates to/from this neighbor\n"
7620 "Name of a prefix list\n"
7621 "Filter incoming updates\n"
7622 "Filter outgoing updates\n")
7624 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7625 safi_t safi
, const char *name_str
,
7626 const char *direct_str
)
7630 int direct
= FILTER_IN
;
7632 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7634 return CMD_WARNING_CONFIG_FAILED
;
7636 /* Check filter direction. */
7637 if (strncmp(direct_str
, "i", 1) == 0)
7639 else if (strncmp(direct_str
, "o", 1) == 0)
7640 direct
= FILTER_OUT
;
7642 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7644 return bgp_vty_return(vty
, ret
);
7647 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7648 safi_t safi
, const char *direct_str
)
7652 int direct
= FILTER_IN
;
7654 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7656 return CMD_WARNING_CONFIG_FAILED
;
7658 /* Check filter direction. */
7659 if (strncmp(direct_str
, "i", 1) == 0)
7661 else if (strncmp(direct_str
, "o", 1) == 0)
7662 direct
= FILTER_OUT
;
7664 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7666 return bgp_vty_return(vty
, ret
);
7669 DEFUN (neighbor_filter_list
,
7670 neighbor_filter_list_cmd
,
7671 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7674 "Establish BGP filters\n"
7675 "AS path access-list name\n"
7676 "Filter incoming routes\n"
7677 "Filter outgoing routes\n")
7682 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7683 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7684 argv
[idx_in_out
]->arg
);
7687 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7688 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7689 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7690 "Establish BGP filters\n"
7691 "AS path access-list name\n"
7692 "Filter incoming routes\n"
7693 "Filter outgoing routes\n")
7695 DEFUN (no_neighbor_filter_list
,
7696 no_neighbor_filter_list_cmd
,
7697 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7701 "Establish BGP filters\n"
7702 "AS path access-list name\n"
7703 "Filter incoming routes\n"
7704 "Filter outgoing routes\n")
7708 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7709 bgp_node_afi(vty
), bgp_node_safi(vty
),
7710 argv
[idx_in_out
]->arg
);
7713 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7714 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7716 "Establish BGP filters\n"
7717 "AS path access-list name\n"
7718 "Filter incoming routes\n"
7719 "Filter outgoing routes\n")
7721 /* Set advertise-map to the peer. */
7722 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7723 afi_t afi
, safi_t safi
,
7724 const char *advertise_str
,
7725 const char *condition_str
, bool condition
,
7728 int ret
= CMD_WARNING_CONFIG_FAILED
;
7730 struct route_map
*advertise_map
;
7731 struct route_map
*condition_map
;
7733 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7737 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7738 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7741 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7742 advertise_map
, condition_str
,
7743 condition_map
, condition
);
7745 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7746 advertise_map
, condition_str
,
7747 condition_map
, condition
);
7749 return bgp_vty_return(vty
, ret
);
7752 DEFPY (bgp_condadv_period
,
7753 bgp_condadv_period_cmd
,
7754 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7757 "Conditional advertisement settings\n"
7758 "Set period to rescan BGP table to check if condition is met\n"
7759 "Period between BGP table scans, in seconds; default 60\n")
7761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7763 bgp
->condition_check_period
=
7764 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7769 DEFPY (neighbor_advertise_map
,
7770 neighbor_advertise_map_cmd
,
7771 "[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",
7775 "Route-map to conditionally advertise routes\n"
7776 "Name of advertise map\n"
7777 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7778 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7779 "Name of the exist or non exist map\n")
7781 bool condition
= CONDITION_EXIST
;
7783 if (!strcmp(exist
, "non-exist-map"))
7784 condition
= CONDITION_NON_EXIST
;
7786 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7787 bgp_node_safi(vty
), advertise_str
,
7788 condition_str
, condition
, !no
);
7791 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7792 "[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",
7793 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7794 "Route-map to conditionally advertise routes\n"
7795 "Name of advertise map\n"
7796 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7797 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7798 "Name of the exist or non exist map\n")
7800 /* Set route-map to the peer. */
7801 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7802 afi_t afi
, safi_t safi
, const char *name_str
,
7803 const char *direct_str
)
7807 int direct
= RMAP_IN
;
7808 struct route_map
*route_map
;
7810 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7812 return CMD_WARNING_CONFIG_FAILED
;
7814 /* Check filter direction. */
7815 if (strncmp(direct_str
, "in", 2) == 0)
7817 else if (strncmp(direct_str
, "o", 1) == 0)
7820 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7821 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7823 return bgp_vty_return(vty
, ret
);
7826 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7827 afi_t afi
, safi_t safi
,
7828 const char *direct_str
)
7832 int direct
= RMAP_IN
;
7834 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7836 return CMD_WARNING_CONFIG_FAILED
;
7838 /* Check filter direction. */
7839 if (strncmp(direct_str
, "in", 2) == 0)
7841 else if (strncmp(direct_str
, "o", 1) == 0)
7844 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7846 return bgp_vty_return(vty
, ret
);
7849 DEFUN (neighbor_route_map
,
7850 neighbor_route_map_cmd
,
7851 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
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")
7862 return peer_route_map_set_vty(
7863 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7864 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7867 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7868 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7869 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7870 "Apply route map to neighbor\n"
7871 "Name of route map\n"
7872 "Apply map to incoming routes\n"
7873 "Apply map to outbound routes\n")
7875 DEFUN (no_neighbor_route_map
,
7876 no_neighbor_route_map_cmd
,
7877 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7881 "Apply route map to neighbor\n"
7882 "Name of route map\n"
7883 "Apply map to incoming routes\n"
7884 "Apply map to outbound routes\n")
7888 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7889 bgp_node_afi(vty
), bgp_node_safi(vty
),
7890 argv
[idx_in_out
]->arg
);
7893 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7894 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7895 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7896 "Apply route map to neighbor\n"
7897 "Name of route map\n"
7898 "Apply map to incoming routes\n"
7899 "Apply map to outbound routes\n")
7901 /* Set unsuppress-map to the peer. */
7902 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7903 afi_t afi
, safi_t safi
,
7904 const char *name_str
)
7908 struct route_map
*route_map
;
7910 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7912 return CMD_WARNING_CONFIG_FAILED
;
7914 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7915 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7917 return bgp_vty_return(vty
, ret
);
7920 /* Unset route-map from the peer. */
7921 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7922 afi_t afi
, safi_t safi
)
7927 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7929 return CMD_WARNING_CONFIG_FAILED
;
7931 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7933 return bgp_vty_return(vty
, ret
);
7936 DEFUN (neighbor_unsuppress_map
,
7937 neighbor_unsuppress_map_cmd
,
7938 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7941 "Route-map to selectively unsuppress suppressed routes\n"
7942 "Name of route map\n")
7946 return peer_unsuppress_map_set_vty(
7947 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7948 argv
[idx_word
]->arg
);
7951 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7952 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7953 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7954 "Route-map to selectively unsuppress suppressed routes\n"
7955 "Name of route map\n")
7957 DEFUN (no_neighbor_unsuppress_map
,
7958 no_neighbor_unsuppress_map_cmd
,
7959 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7963 "Route-map to selectively unsuppress suppressed routes\n"
7964 "Name of route map\n")
7967 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7969 bgp_node_safi(vty
));
7972 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7973 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7974 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7975 "Route-map to selectively unsuppress suppressed routes\n"
7976 "Name of route map\n")
7978 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7979 afi_t afi
, safi_t safi
,
7980 const char *num_str
,
7981 const char *threshold_str
, int warning
,
7982 const char *restart_str
,
7983 const char *force_str
)
7991 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7993 return CMD_WARNING_CONFIG_FAILED
;
7995 max
= strtoul(num_str
, NULL
, 10);
7997 threshold
= atoi(threshold_str
);
7999 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8002 restart
= atoi(restart_str
);
8006 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8007 restart
, force_str
? true : false);
8009 return bgp_vty_return(vty
, ret
);
8012 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8013 afi_t afi
, safi_t safi
)
8018 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8020 return CMD_WARNING_CONFIG_FAILED
;
8022 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8024 return bgp_vty_return(vty
, ret
);
8027 /* Maximum number of prefix to be sent to the neighbor. */
8028 DEFUN(neighbor_maximum_prefix_out
,
8029 neighbor_maximum_prefix_out_cmd
,
8030 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8033 "Maximum number of prefixes to be sent to this peer\n"
8034 "Maximum no. of prefix limit\n")
8041 afi_t afi
= bgp_node_afi(vty
);
8042 safi_t safi
= bgp_node_safi(vty
);
8044 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8046 return CMD_WARNING_CONFIG_FAILED
;
8048 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8050 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8052 return bgp_vty_return(vty
, ret
);
8055 DEFUN(no_neighbor_maximum_prefix_out
,
8056 no_neighbor_maximum_prefix_out_cmd
,
8057 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8061 "Maximum number of prefixes to be sent to this peer\n"
8062 "Maximum no. of prefix limit\n")
8067 afi_t afi
= bgp_node_afi(vty
);
8068 safi_t safi
= bgp_node_safi(vty
);
8070 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8072 return CMD_WARNING_CONFIG_FAILED
;
8074 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8076 return bgp_vty_return(vty
, ret
);
8079 /* Maximum number of prefix configuration. Prefix count is different
8080 for each peer configuration. So this configuration can be set for
8081 each peer configuration. */
8082 DEFUN (neighbor_maximum_prefix
,
8083 neighbor_maximum_prefix_cmd
,
8084 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8087 "Maximum number of prefix accept from this peer\n"
8088 "maximum no. of prefix limit\n"
8089 "Force checking all received routes not only accepted\n")
8096 if (argv_find(argv
, argc
, "force", &idx_force
))
8097 force
= argv
[idx_force
]->arg
;
8099 return peer_maximum_prefix_set_vty(
8100 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8101 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8104 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8105 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8107 "Maximum number of prefix accept from this peer\n"
8108 "maximum no. of prefix limit\n"
8109 "Force checking all received routes not only accepted\n")
8111 DEFUN (neighbor_maximum_prefix_threshold
,
8112 neighbor_maximum_prefix_threshold_cmd
,
8113 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8116 "Maximum number of prefix accept from this peer\n"
8117 "maximum no. of prefix limit\n"
8118 "Threshold value (%) at which to generate a warning msg\n"
8119 "Force checking all received routes not only accepted\n")
8123 int idx_number_2
= 4;
8127 if (argv_find(argv
, argc
, "force", &idx_force
))
8128 force
= argv
[idx_force
]->arg
;
8130 return peer_maximum_prefix_set_vty(
8131 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8132 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8136 neighbor_maximum_prefix_threshold
,
8137 neighbor_maximum_prefix_threshold_hidden_cmd
,
8138 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8139 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8140 "Maximum number of prefix accept from this peer\n"
8141 "maximum no. of prefix limit\n"
8142 "Threshold value (%) at which to generate a warning msg\n"
8143 "Force checking all received routes not only accepted\n")
8145 DEFUN (neighbor_maximum_prefix_warning
,
8146 neighbor_maximum_prefix_warning_cmd
,
8147 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8150 "Maximum number of prefix accept from this peer\n"
8151 "maximum no. of prefix limit\n"
8152 "Only give warning message when limit is exceeded\n"
8153 "Force checking all received routes not only accepted\n")
8160 if (argv_find(argv
, argc
, "force", &idx_force
))
8161 force
= argv
[idx_force
]->arg
;
8163 return peer_maximum_prefix_set_vty(
8164 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8165 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8169 neighbor_maximum_prefix_warning
,
8170 neighbor_maximum_prefix_warning_hidden_cmd
,
8171 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8172 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8173 "Maximum number of prefix accept from this peer\n"
8174 "maximum no. of prefix limit\n"
8175 "Only give warning message when limit is exceeded\n"
8176 "Force checking all received routes not only accepted\n")
8178 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8179 neighbor_maximum_prefix_threshold_warning_cmd
,
8180 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8183 "Maximum number of prefix accept from this peer\n"
8184 "maximum no. of prefix limit\n"
8185 "Threshold value (%) at which to generate a warning msg\n"
8186 "Only give warning message when limit is exceeded\n"
8187 "Force checking all received routes not only accepted\n")
8191 int idx_number_2
= 4;
8195 if (argv_find(argv
, argc
, "force", &idx_force
))
8196 force
= argv
[idx_force
]->arg
;
8198 return peer_maximum_prefix_set_vty(
8199 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8200 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8204 neighbor_maximum_prefix_threshold_warning
,
8205 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8206 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8207 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8208 "Maximum number of prefix accept from this peer\n"
8209 "maximum no. of prefix limit\n"
8210 "Threshold value (%) at which to generate a warning msg\n"
8211 "Only give warning message when limit is exceeded\n"
8212 "Force checking all received routes not only accepted\n")
8214 DEFUN (neighbor_maximum_prefix_restart
,
8215 neighbor_maximum_prefix_restart_cmd
,
8216 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8219 "Maximum number of prefix accept from this peer\n"
8220 "maximum no. of prefix limit\n"
8221 "Restart bgp connection after limit is exceeded\n"
8222 "Restart interval in minutes\n"
8223 "Force checking all received routes not only accepted\n")
8227 int idx_number_2
= 5;
8231 if (argv_find(argv
, argc
, "force", &idx_force
))
8232 force
= argv
[idx_force
]->arg
;
8234 return peer_maximum_prefix_set_vty(
8235 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8236 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8240 neighbor_maximum_prefix_restart
,
8241 neighbor_maximum_prefix_restart_hidden_cmd
,
8242 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8243 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8244 "Maximum number of prefix accept from this peer\n"
8245 "maximum no. of prefix limit\n"
8246 "Restart bgp connection after limit is exceeded\n"
8247 "Restart interval in minutes\n"
8248 "Force checking all received routes not only accepted\n")
8250 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8251 neighbor_maximum_prefix_threshold_restart_cmd
,
8252 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8255 "Maximum number of prefixes to accept from this peer\n"
8256 "maximum no. of prefix limit\n"
8257 "Threshold value (%) at which to generate a warning msg\n"
8258 "Restart bgp connection after limit is exceeded\n"
8259 "Restart interval in minutes\n"
8260 "Force checking all received routes not only accepted\n")
8264 int idx_number_2
= 4;
8265 int idx_number_3
= 6;
8269 if (argv_find(argv
, argc
, "force", &idx_force
))
8270 force
= argv
[idx_force
]->arg
;
8272 return peer_maximum_prefix_set_vty(
8273 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8274 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8275 argv
[idx_number_3
]->arg
, force
);
8279 neighbor_maximum_prefix_threshold_restart
,
8280 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8281 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8282 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8283 "Maximum number of prefixes to accept from this peer\n"
8284 "maximum no. of prefix limit\n"
8285 "Threshold value (%) at which to generate a warning msg\n"
8286 "Restart bgp connection after limit is exceeded\n"
8287 "Restart interval in minutes\n"
8288 "Force checking all received routes not only accepted\n")
8290 DEFUN (no_neighbor_maximum_prefix
,
8291 no_neighbor_maximum_prefix_cmd
,
8292 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8296 "Maximum number of prefixes to accept from this peer\n"
8297 "maximum no. of prefix limit\n"
8298 "Threshold value (%) at which to generate a warning msg\n"
8299 "Restart bgp connection after limit is exceeded\n"
8300 "Restart interval in minutes\n"
8301 "Only give warning message when limit is exceeded\n"
8302 "Force checking all received routes not only accepted\n")
8305 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8307 bgp_node_safi(vty
));
8311 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8312 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8313 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8314 "Maximum number of prefixes to accept from this peer\n"
8315 "maximum no. of prefix limit\n"
8316 "Threshold value (%) at which to generate a warning msg\n"
8317 "Restart bgp connection after limit is exceeded\n"
8318 "Restart interval in minutes\n"
8319 "Only give warning message when limit is exceeded\n"
8320 "Force checking all received routes not only accepted\n")
8322 /* "neighbor soo" */
8323 DEFPY (neighbor_soo
,
8325 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8328 "Set the Site-of-Origin (SoO) extended community\n"
8329 "VPN extended community\n")
8332 afi_t afi
= bgp_node_afi(vty
);
8333 safi_t safi
= bgp_node_safi(vty
);
8334 struct ecommunity
*ecomm_soo
;
8336 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8338 return CMD_WARNING_CONFIG_FAILED
;
8340 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8342 vty_out(vty
, "%% Malformed SoO extended community\n");
8345 ecommunity_str(ecomm_soo
);
8347 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8348 ecommunity_free(&peer
->soo
[afi
][safi
]);
8349 peer
->soo
[afi
][safi
] = ecomm_soo
;
8350 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8353 return bgp_vty_return(vty
,
8354 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8357 DEFPY (no_neighbor_soo
,
8358 no_neighbor_soo_cmd
,
8359 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8363 "Set the Site-of-Origin (SoO) extended community\n"
8364 "VPN extended community\n")
8367 afi_t afi
= bgp_node_afi(vty
);
8368 safi_t safi
= bgp_node_safi(vty
);
8370 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8372 return CMD_WARNING_CONFIG_FAILED
;
8374 ecommunity_free(&peer
->soo
[afi
][safi
]);
8376 return bgp_vty_return(
8377 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8380 /* "neighbor allowas-in" */
8381 DEFUN (neighbor_allowas_in
,
8382 neighbor_allowas_in_cmd
,
8383 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8386 "Accept as-path with my AS present in it\n"
8387 "Number of occurrences of AS number\n"
8388 "Only accept my AS in the as-path if the route was originated in my AS\n")
8391 int idx_number_origin
= 3;
8397 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8399 return CMD_WARNING_CONFIG_FAILED
;
8401 if (argc
<= idx_number_origin
)
8404 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8407 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8410 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8413 return bgp_vty_return(vty
, ret
);
8417 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8418 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8419 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8420 "Accept as-path with my AS present in it\n"
8421 "Number of occurrences of AS number\n"
8422 "Only accept my AS in the as-path if the route was originated in my AS\n")
8424 DEFUN (no_neighbor_allowas_in
,
8425 no_neighbor_allowas_in_cmd
,
8426 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8430 "allow local ASN appears in aspath attribute\n"
8431 "Number of occurrences of AS number\n"
8432 "Only accept my AS in the as-path if the route was originated in my AS\n")
8438 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8440 return CMD_WARNING_CONFIG_FAILED
;
8442 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8443 bgp_node_safi(vty
));
8445 return bgp_vty_return(vty
, ret
);
8449 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8450 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8451 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8452 "allow local ASN appears in aspath attribute\n"
8453 "Number of occurrences of AS number\n"
8454 "Only accept my AS in the as-path if the route was originated in my AS\n")
8456 DEFUN (neighbor_ttl_security
,
8457 neighbor_ttl_security_cmd
,
8458 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8461 "BGP ttl-security parameters\n"
8462 "Specify the maximum number of hops to the BGP peer\n"
8463 "Number of hops to BGP peer\n")
8470 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8472 return CMD_WARNING_CONFIG_FAILED
;
8474 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8477 * If 'neighbor swpX', then this is for directly connected peers,
8478 * we should not accept a ttl-security hops value greater than 1.
8480 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8482 "%s is directly connected peer, hops cannot exceed 1\n",
8483 argv
[idx_peer
]->arg
);
8484 return CMD_WARNING_CONFIG_FAILED
;
8487 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8490 DEFUN (no_neighbor_ttl_security
,
8491 no_neighbor_ttl_security_cmd
,
8492 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8496 "BGP ttl-security parameters\n"
8497 "Specify the maximum number of hops to the BGP peer\n"
8498 "Number of hops to BGP peer\n")
8503 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8505 return CMD_WARNING_CONFIG_FAILED
;
8507 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8510 /* disable-addpath-rx */
8511 DEFUN(neighbor_disable_addpath_rx
,
8512 neighbor_disable_addpath_rx_cmd
,
8513 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8516 "Do not accept additional paths\n")
8518 char *peer_str
= argv
[1]->arg
;
8520 afi_t afi
= bgp_node_afi(vty
);
8521 safi_t safi
= bgp_node_safi(vty
);
8523 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8525 return CMD_WARNING_CONFIG_FAILED
;
8527 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8528 PEER_FLAG_DISABLE_ADDPATH_RX
);
8531 DEFUN(no_neighbor_disable_addpath_rx
,
8532 no_neighbor_disable_addpath_rx_cmd
,
8533 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8537 "Do not accept additional paths\n")
8539 char *peer_str
= argv
[2]->arg
;
8541 afi_t afi
= bgp_node_afi(vty
);
8542 safi_t safi
= bgp_node_safi(vty
);
8544 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8546 return CMD_WARNING_CONFIG_FAILED
;
8548 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8549 PEER_FLAG_DISABLE_ADDPATH_RX
);
8552 DEFUN (neighbor_addpath_tx_all_paths
,
8553 neighbor_addpath_tx_all_paths_cmd
,
8554 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8557 "Use addpath to advertise all paths to a neighbor\n")
8562 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8564 return CMD_WARNING_CONFIG_FAILED
;
8566 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8571 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8572 neighbor_addpath_tx_all_paths_hidden_cmd
,
8573 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8574 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8575 "Use addpath to advertise all paths to a neighbor\n")
8577 DEFUN (no_neighbor_addpath_tx_all_paths
,
8578 no_neighbor_addpath_tx_all_paths_cmd
,
8579 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8583 "Use addpath to advertise all paths to a neighbor\n")
8588 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8590 return CMD_WARNING_CONFIG_FAILED
;
8592 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8593 != BGP_ADDPATH_ALL
) {
8595 "%% Peer not currently configured to transmit all paths.");
8596 return CMD_WARNING_CONFIG_FAILED
;
8599 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8605 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8606 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8607 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8608 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8609 "Use addpath to advertise all paths to a neighbor\n")
8611 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8612 neighbor_addpath_tx_bestpath_per_as_cmd
,
8613 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8616 "Use addpath to advertise the bestpath per each neighboring AS\n")
8621 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8623 return CMD_WARNING_CONFIG_FAILED
;
8625 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8626 BGP_ADDPATH_BEST_PER_AS
);
8631 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8632 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8633 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8634 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8635 "Use addpath to advertise the bestpath per each neighboring AS\n")
8637 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8638 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8639 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8643 "Use addpath to advertise the bestpath per each neighboring AS\n")
8648 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8650 return CMD_WARNING_CONFIG_FAILED
;
8652 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8653 != BGP_ADDPATH_BEST_PER_AS
) {
8655 "%% Peer not currently configured to transmit all best path per as.");
8656 return CMD_WARNING_CONFIG_FAILED
;
8659 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8665 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8666 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8667 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8668 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8669 "Use addpath to advertise the bestpath per each neighboring AS\n")
8672 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8673 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8676 "Detect AS loops before sending to neighbor\n")
8680 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8682 return CMD_WARNING_CONFIG_FAILED
;
8684 peer
->as_path_loop_detection
= true;
8690 no_neighbor_aspath_loop_detection
,
8691 no_neighbor_aspath_loop_detection_cmd
,
8692 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8696 "Detect AS loops before sending to neighbor\n")
8700 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8702 return CMD_WARNING_CONFIG_FAILED
;
8704 peer
->as_path_loop_detection
= false;
8709 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8710 struct ecommunity
**list
, bool is_rt6
)
8712 struct ecommunity
*ecom
= NULL
;
8713 struct ecommunity
*ecomadd
;
8715 for (; argc
; --argc
, ++argv
) {
8717 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8718 ECOMMUNITY_ROUTE_TARGET
,
8721 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8722 ECOMMUNITY_ROUTE_TARGET
,
8725 vty_out(vty
, "Malformed community-list value\n");
8727 ecommunity_free(&ecom
);
8728 return CMD_WARNING_CONFIG_FAILED
;
8732 ecommunity_merge(ecom
, ecomadd
);
8733 ecommunity_free(&ecomadd
);
8740 ecommunity_free(&*list
);
8748 * v2vimport is true if we are handling a `import vrf ...` command
8750 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8754 switch (vty
->node
) {
8763 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8768 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8769 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8770 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8771 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8773 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8777 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8778 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8779 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8780 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8782 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8789 DEFPY (af_rd_vpn_export
,
8790 af_rd_vpn_export_cmd
,
8791 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8793 "Specify route distinguisher\n"
8794 "Between current address-family and vpn\n"
8795 "For routes leaked from current address-family to vpn\n"
8796 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8799 struct prefix_rd prd
;
8805 if (argv_find(argv
, argc
, "no", &idx
))
8809 ret
= str2prefix_rd(rd_str
, &prd
);
8811 vty_out(vty
, "%% Malformed rd\n");
8812 return CMD_WARNING_CONFIG_FAILED
;
8816 afi
= vpn_policy_getafi(vty
, bgp
, false);
8818 return CMD_WARNING_CONFIG_FAILED
;
8821 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8823 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8824 bgp_get_default(), bgp
);
8827 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8828 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8829 BGP_VPN_POLICY_TOVPN_RD_SET
);
8831 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8832 BGP_VPN_POLICY_TOVPN_RD_SET
);
8835 /* post-change: re-export vpn routes */
8836 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8837 bgp_get_default(), bgp
);
8842 ALIAS (af_rd_vpn_export
,
8843 af_no_rd_vpn_export_cmd
,
8846 "Specify route distinguisher\n"
8847 "Between current address-family and vpn\n"
8848 "For routes leaked from current address-family to vpn\n")
8850 DEFPY (af_label_vpn_export
,
8851 af_label_vpn_export_cmd
,
8852 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8854 "label value for VRF\n"
8855 "Between current address-family and vpn\n"
8856 "For routes leaked from current address-family to vpn\n"
8857 "Label Value <0-1048575>\n"
8858 "Automatically assign a label\n")
8860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8861 mpls_label_t label
= MPLS_LABEL_NONE
;
8866 if (argv_find(argv
, argc
, "no", &idx
))
8869 /* If "no ...", squash trailing parameter */
8875 label
= label_val
; /* parser should force unsigned */
8878 afi
= vpn_policy_getafi(vty
, bgp
, false);
8880 return CMD_WARNING_CONFIG_FAILED
;
8883 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8884 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8889 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8891 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8892 bgp_get_default(), bgp
);
8894 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8895 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8897 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8900 * label has previously been automatically
8901 * assigned by labelpool: release it
8903 * NB if tovpn_label == MPLS_LABEL_NONE it
8904 * means the automatic assignment is in flight
8905 * and therefore the labelpool callback must
8906 * detect that the auto label is not needed.
8909 bgp_lp_release(LP_TYPE_VRF
,
8910 &bgp
->vpn_policy
[afi
],
8911 bgp
->vpn_policy
[afi
].tovpn_label
);
8913 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8914 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8917 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8919 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8920 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8921 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8922 vpn_leak_label_callback
);
8925 /* post-change: re-export vpn routes */
8926 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8927 bgp_get_default(), bgp
);
8929 hook_call(bgp_snmp_update_last_changed
, bgp
);
8933 DEFPY (af_sid_vpn_export
,
8934 af_sid_vpn_export_cmd
,
8935 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8937 "sid value for VRF\n"
8938 "Between current address-family and vpn\n"
8939 "For routes leaked from current address-family to vpn\n"
8940 "Sid allocation index\n"
8941 "Automatically assign a label\n")
8943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8949 if (argv_find(argv
, argc
, "no", &idx
))
8951 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8952 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8954 afi
= vpn_policy_getafi(vty
, bgp
, false);
8956 return CMD_WARNING_CONFIG_FAILED
;
8960 vty_out(vty
, "It's not implemented\n");
8961 return CMD_WARNING_CONFIG_FAILED
;
8964 /* skip when it's already configured */
8965 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8966 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8967 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8971 * mode change between sid_idx and sid_auto isn't supported.
8972 * user must negate sid vpn export when they want to change the mode
8974 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8975 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8976 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8977 vty_out(vty
, "it's already configured as %s.\n",
8978 sid_auto
? "auto-mode" : "idx-mode");
8979 return CMD_WARNING_CONFIG_FAILED
;
8983 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8984 bgp_get_default(), bgp
);
8987 /* SID allocation auto-mode */
8989 zlog_debug("%s: auto sid alloc.", __func__
);
8990 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8991 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8993 /* SID allocation index-mode */
8995 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8996 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9000 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9001 bgp_get_default(), bgp
);
9005 ALIAS (af_label_vpn_export
,
9006 af_no_label_vpn_export_cmd
,
9007 "no label vpn export",
9009 "label value for VRF\n"
9010 "Between current address-family and vpn\n"
9011 "For routes leaked from current address-family to vpn\n")
9013 DEFPY (af_nexthop_vpn_export
,
9014 af_nexthop_vpn_export_cmd
,
9015 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9017 "Specify next hop to use for VRF advertised prefixes\n"
9018 "Between current address-family and vpn\n"
9019 "For routes leaked from current address-family to vpn\n"
9023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9029 vty_out(vty
, "%% Nexthop required\n");
9030 return CMD_WARNING_CONFIG_FAILED
;
9032 if (!sockunion2hostprefix(nexthop_su
, &p
))
9033 return CMD_WARNING_CONFIG_FAILED
;
9036 afi
= vpn_policy_getafi(vty
, bgp
, false);
9038 return CMD_WARNING_CONFIG_FAILED
;
9041 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9043 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9044 bgp_get_default(), bgp
);
9047 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9048 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9049 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9051 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9052 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9055 /* post-change: re-export vpn routes */
9056 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9057 bgp_get_default(), bgp
);
9062 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9064 if (!strcmp(dstr
, "import")) {
9065 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9066 } else if (!strcmp(dstr
, "export")) {
9067 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9068 } else if (!strcmp(dstr
, "both")) {
9069 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9070 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9072 vty_out(vty
, "%% direction parse error\n");
9073 return CMD_WARNING_CONFIG_FAILED
;
9078 DEFPY (af_rt_vpn_imexport
,
9079 af_rt_vpn_imexport_cmd
,
9080 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9082 "Specify route target list\n"
9083 "Specify route target list\n"
9084 "Between current address-family and vpn\n"
9085 "For routes leaked from vpn to current address-family: match any\n"
9086 "For routes leaked from current address-family to vpn: set\n"
9087 "both import: match any and export: set\n"
9088 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9092 struct ecommunity
*ecom
= NULL
;
9093 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9094 enum vpn_policy_direction dir
;
9099 if (argv_find(argv
, argc
, "no", &idx
))
9102 afi
= vpn_policy_getafi(vty
, bgp
, false);
9104 return CMD_WARNING_CONFIG_FAILED
;
9106 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9107 if (ret
!= CMD_SUCCESS
)
9111 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9112 vty_out(vty
, "%% Missing RTLIST\n");
9113 return CMD_WARNING_CONFIG_FAILED
;
9115 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9116 if (ret
!= CMD_SUCCESS
) {
9121 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9125 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9128 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9130 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9131 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9132 ecommunity_dup(ecom
);
9134 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9136 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9137 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9140 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9144 ecommunity_free(&ecom
);
9149 ALIAS (af_rt_vpn_imexport
,
9150 af_no_rt_vpn_imexport_cmd
,
9151 "no <rt|route-target> vpn <import|export|both>$direction_str",
9153 "Specify route target list\n"
9154 "Specify route target list\n"
9155 "Between current address-family and vpn\n"
9156 "For routes leaked from vpn to current address-family\n"
9157 "For routes leaked from current address-family to vpn\n"
9158 "both import and export\n")
9160 DEFPY (af_route_map_vpn_imexport
,
9161 af_route_map_vpn_imexport_cmd
,
9162 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9163 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9165 "Specify route map\n"
9166 "Between current address-family and vpn\n"
9167 "For routes leaked from vpn to current address-family\n"
9168 "For routes leaked from current address-family to vpn\n"
9169 "name of route-map\n")
9171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9173 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9174 enum vpn_policy_direction dir
;
9179 if (argv_find(argv
, argc
, "no", &idx
))
9182 afi
= vpn_policy_getafi(vty
, bgp
, false);
9184 return CMD_WARNING_CONFIG_FAILED
;
9186 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9187 if (ret
!= CMD_SUCCESS
)
9190 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9194 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9197 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9198 XFREE(MTYPE_ROUTE_MAP_NAME
,
9199 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9200 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9201 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9202 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9203 route_map_lookup_warn_noexist(vty
, rmap_str
);
9204 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9207 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9208 XFREE(MTYPE_ROUTE_MAP_NAME
,
9209 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9210 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9211 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9214 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9220 ALIAS (af_route_map_vpn_imexport
,
9221 af_no_route_map_vpn_imexport_cmd
,
9222 "no route-map vpn <import|export>$direction_str",
9224 "Specify route map\n"
9225 "Between current address-family and vpn\n"
9226 "For routes leaked from vpn to current address-family\n"
9227 "For routes leaked from current address-family to vpn\n")
9229 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9230 "import vrf route-map RMAP$rmap_str",
9231 "Import routes from another VRF\n"
9232 "Vrf routes being filtered\n"
9233 "Specify route map\n"
9234 "name of route-map\n")
9236 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9237 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9239 struct bgp
*bgp_default
;
9241 afi
= vpn_policy_getafi(vty
, bgp
, true);
9243 return CMD_WARNING_CONFIG_FAILED
;
9245 bgp_default
= bgp_get_default();
9250 /* Auto-create assuming the same AS */
9251 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9252 BGP_INSTANCE_TYPE_DEFAULT
);
9256 "VRF default is not configured as a bgp instance\n");
9261 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9263 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9264 XFREE(MTYPE_ROUTE_MAP_NAME
,
9265 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9266 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9267 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9268 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9269 route_map_lookup_warn_noexist(vty
, rmap_str
);
9270 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9273 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9274 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9276 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9281 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9282 "no import vrf route-map [RMAP$rmap_str]",
9284 "Import routes from another VRF\n"
9285 "Vrf routes being filtered\n"
9286 "Specify route map\n"
9287 "name of route-map\n")
9289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9290 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9293 afi
= vpn_policy_getafi(vty
, bgp
, true);
9295 return CMD_WARNING_CONFIG_FAILED
;
9297 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9299 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9300 XFREE(MTYPE_ROUTE_MAP_NAME
,
9301 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9302 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9303 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9305 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9306 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9307 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9309 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9314 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9315 "[no] import vrf VIEWVRFNAME$import_name",
9317 "Import routes from another VRF\n"
9318 "VRF to import from\n"
9319 "The name of the VRF\n")
9321 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9322 struct listnode
*node
;
9323 struct bgp
*vrf_bgp
, *bgp_default
;
9326 bool remove
= false;
9329 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9333 if (import_name
== NULL
) {
9334 vty_out(vty
, "%% Missing import name\n");
9338 if (strcmp(import_name
, "route-map") == 0) {
9339 vty_out(vty
, "%% Must include route-map name\n");
9343 if (argv_find(argv
, argc
, "no", &idx
))
9346 afi
= vpn_policy_getafi(vty
, bgp
, true);
9348 return CMD_WARNING_CONFIG_FAILED
;
9350 safi
= bgp_node_safi(vty
);
9352 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9353 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9354 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9355 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9356 remove
? "unimport" : "import", import_name
);
9360 bgp_default
= bgp_get_default();
9362 /* Auto-create assuming the same AS */
9363 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9364 BGP_INSTANCE_TYPE_DEFAULT
);
9368 "VRF default is not configured as a bgp instance\n");
9373 vrf_bgp
= bgp_lookup_by_name(import_name
);
9375 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9376 vrf_bgp
= bgp_default
;
9378 /* Auto-create assuming the same AS */
9379 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9383 "VRF %s is not configured as a bgp instance\n",
9390 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9392 /* Already importing from "import_vrf"? */
9393 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9395 if (strcmp(vname
, import_name
) == 0)
9399 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9405 /* This command is valid only in a bgp vrf instance or the default instance */
9406 DEFPY (bgp_imexport_vpn
,
9407 bgp_imexport_vpn_cmd
,
9408 "[no] <import|export>$direction_str vpn",
9410 "Import routes to this address-family\n"
9411 "Export routes from this address-family\n"
9412 "to/from default instance VPN RIB\n")
9414 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9421 enum vpn_policy_direction dir
;
9423 if (argv_find(argv
, argc
, "no", &idx
))
9426 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9427 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9429 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9430 return CMD_WARNING_CONFIG_FAILED
;
9433 afi
= bgp_node_afi(vty
);
9434 safi
= bgp_node_safi(vty
);
9435 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9436 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9437 return CMD_WARNING_CONFIG_FAILED
;
9440 if (!strcmp(direction_str
, "import")) {
9441 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9442 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9443 } else if (!strcmp(direction_str
, "export")) {
9444 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9445 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9447 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9448 return CMD_WARNING_CONFIG_FAILED
;
9451 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9454 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9455 if (!previous_state
) {
9456 /* trigger export current vrf */
9457 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9460 if (previous_state
) {
9461 /* trigger un-export current vrf */
9462 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9464 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9467 hook_call(bgp_snmp_init_stats
, bgp
);
9472 DEFPY (af_routetarget_import
,
9473 af_routetarget_import_cmd
,
9474 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9476 "Specify route target list\n"
9477 "Specify route target list\n"
9478 "Specify route target list\n"
9479 "Specify route target list\n"
9480 "Flow-spec redirect type route target\n"
9481 "Import routes to this address-family\n"
9482 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9486 struct ecommunity
*ecom
= NULL
;
9488 int idx
= 0, idx_unused
= 0;
9492 if (argv_find(argv
, argc
, "no", &idx
))
9495 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9496 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9499 afi
= vpn_policy_getafi(vty
, bgp
, false);
9501 return CMD_WARNING_CONFIG_FAILED
;
9503 if (rt6
&& afi
!= AFI_IP6
)
9504 return CMD_WARNING_CONFIG_FAILED
;
9507 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9508 vty_out(vty
, "%% Missing RTLIST\n");
9509 return CMD_WARNING_CONFIG_FAILED
;
9511 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9512 if (ret
!= CMD_SUCCESS
)
9517 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9518 ecommunity_free(&bgp
->vpn_policy
[afi
]
9519 .import_redirect_rtlist
);
9520 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9521 ecommunity_dup(ecom
);
9523 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9524 ecommunity_free(&bgp
->vpn_policy
[afi
]
9525 .import_redirect_rtlist
);
9526 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9530 ecommunity_free(&ecom
);
9535 DEFUN_NOSH (address_family_ipv4_safi
,
9536 address_family_ipv4_safi_cmd
,
9537 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9538 "Enter Address Family command mode\n"
9540 BGP_SAFI_WITH_LABEL_HELP_STR
)
9544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9545 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9546 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9547 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9548 && safi
!= SAFI_EVPN
) {
9550 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9551 return CMD_WARNING_CONFIG_FAILED
;
9553 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9555 vty
->node
= BGP_IPV4_NODE
;
9560 DEFUN_NOSH (address_family_ipv6_safi
,
9561 address_family_ipv6_safi_cmd
,
9562 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9563 "Enter Address Family command mode\n"
9565 BGP_SAFI_WITH_LABEL_HELP_STR
)
9568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9569 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9570 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9571 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9572 && safi
!= SAFI_EVPN
) {
9574 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9575 return CMD_WARNING_CONFIG_FAILED
;
9577 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9579 vty
->node
= BGP_IPV6_NODE
;
9584 #ifdef KEEP_OLD_VPN_COMMANDS
9585 DEFUN_NOSH (address_family_vpnv4
,
9586 address_family_vpnv4_cmd
,
9587 "address-family vpnv4 [unicast]",
9588 "Enter Address Family command mode\n"
9590 BGP_AF_MODIFIER_STR
)
9592 vty
->node
= BGP_VPNV4_NODE
;
9596 DEFUN_NOSH (address_family_vpnv6
,
9597 address_family_vpnv6_cmd
,
9598 "address-family vpnv6 [unicast]",
9599 "Enter Address Family command mode\n"
9601 BGP_AF_MODIFIER_STR
)
9603 vty
->node
= BGP_VPNV6_NODE
;
9606 #endif /* KEEP_OLD_VPN_COMMANDS */
9608 DEFUN_NOSH (address_family_evpn
,
9609 address_family_evpn_cmd
,
9610 "address-family l2vpn evpn",
9611 "Enter Address Family command mode\n"
9613 BGP_AF_MODIFIER_STR
)
9615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9616 vty
->node
= BGP_EVPN_NODE
;
9620 DEFUN_NOSH (bgp_segment_routing_srv6
,
9621 bgp_segment_routing_srv6_cmd
,
9622 "segment-routing srv6",
9623 "Segment-Routing configuration\n"
9624 "Segment-Routing SRv6 configuration\n")
9626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9627 bgp
->srv6_enabled
= true;
9628 vty
->node
= BGP_SRV6_NODE
;
9632 DEFUN (no_bgp_segment_routing_srv6
,
9633 no_bgp_segment_routing_srv6_cmd
,
9634 "no segment-routing srv6",
9636 "Segment-Routing configuration\n"
9637 "Segment-Routing SRv6 configuration\n")
9639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9641 if (strlen(bgp
->srv6_locator_name
) > 0)
9642 if (bgp_srv6_locator_unset(bgp
) < 0)
9643 return CMD_WARNING_CONFIG_FAILED
;
9645 bgp
->srv6_enabled
= false;
9649 DEFPY (bgp_srv6_locator
,
9650 bgp_srv6_locator_cmd
,
9651 "locator NAME$name",
9652 "Specify SRv6 locator\n"
9653 "Specify SRv6 locator\n")
9655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9658 if (strlen(bgp
->srv6_locator_name
) > 0
9659 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9660 vty_out(vty
, "srv6 locator is already configured\n");
9661 return CMD_WARNING_CONFIG_FAILED
;
9664 snprintf(bgp
->srv6_locator_name
,
9665 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9667 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9669 return CMD_WARNING_CONFIG_FAILED
;
9674 DEFPY (no_bgp_srv6_locator
,
9675 no_bgp_srv6_locator_cmd
,
9676 "no locator NAME$name",
9678 "Specify SRv6 locator\n"
9679 "Specify SRv6 locator\n")
9681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9683 /* when locator isn't configured, do nothing */
9684 if (strlen(bgp
->srv6_locator_name
) < 1)
9687 /* name validation */
9688 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9689 vty_out(vty
, "%% No srv6 locator is configured\n");
9690 return CMD_WARNING_CONFIG_FAILED
;
9694 if (bgp_srv6_locator_unset(bgp
) < 0)
9695 return CMD_WARNING_CONFIG_FAILED
;
9700 DEFPY (show_bgp_srv6
,
9702 "show bgp segment-routing srv6",
9705 "BGP Segment Routing\n"
9706 "BGP Segment Routing SRv6\n")
9709 struct listnode
*node
;
9710 struct srv6_locator_chunk
*chunk
;
9711 struct bgp_srv6_function
*func
;
9714 bgp
= bgp_get_default();
9718 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9719 vty_out(vty
, "locator_chunks:\n");
9720 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9721 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9723 vty_out(vty
, "functions:\n");
9724 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9725 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9726 vty_out(vty
, "- sid: %s\n", buf
);
9727 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9730 vty_out(vty
, "bgps:\n");
9731 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9732 vty_out(vty
, "- name: %s\n",
9733 bgp
->name
? bgp
->name
: "default");
9735 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9736 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9737 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9738 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9744 DEFUN_NOSH (exit_address_family
,
9745 exit_address_family_cmd
,
9746 "exit-address-family",
9747 "Exit from Address Family configuration mode\n")
9749 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9750 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9751 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9752 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9753 || vty
->node
== BGP_EVPN_NODE
9754 || vty
->node
== BGP_FLOWSPECV4_NODE
9755 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9756 vty
->node
= BGP_NODE
;
9760 /* Recalculate bestpath and re-advertise a prefix */
9761 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9762 const char *ip_str
, afi_t afi
, safi_t safi
,
9763 struct prefix_rd
*prd
)
9766 struct prefix match
;
9767 struct bgp_dest
*dest
;
9768 struct bgp_dest
*rm
;
9770 struct bgp_table
*table
;
9771 struct bgp_table
*rib
;
9773 /* BGP structure lookup. */
9775 bgp
= bgp_lookup_by_name(view_name
);
9777 vty_out(vty
, "%% Can't find BGP instance %s\n",
9782 bgp
= bgp_get_default();
9784 vty_out(vty
, "%% No BGP process is configured\n");
9789 /* Check IP address argument. */
9790 ret
= str2prefix(ip_str
, &match
);
9792 vty_out(vty
, "%% address is malformed\n");
9796 match
.family
= afi2family(afi
);
9797 rib
= bgp
->rib
[afi
][safi
];
9799 if (safi
== SAFI_MPLS_VPN
) {
9800 for (dest
= bgp_table_top(rib
); dest
;
9801 dest
= bgp_route_next(dest
)) {
9802 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9804 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9807 table
= bgp_dest_get_bgp_table_info(dest
);
9811 rm
= bgp_node_match(table
, &match
);
9813 const struct prefix
*rm_p
=
9814 bgp_dest_get_prefix(rm
);
9816 if (rm_p
->prefixlen
== match
.prefixlen
) {
9818 BGP_NODE_USER_CLEAR
);
9819 bgp_process(bgp
, rm
, afi
, safi
);
9821 bgp_dest_unlock_node(rm
);
9825 dest
= bgp_node_match(rib
, &match
);
9827 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9829 if (dest_p
->prefixlen
== match
.prefixlen
) {
9830 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9831 bgp_process(bgp
, dest
, afi
, safi
);
9833 bgp_dest_unlock_node(dest
);
9840 /* one clear bgp command to rule them all */
9841 DEFUN (clear_ip_bgp_all
,
9842 clear_ip_bgp_all_cmd
,
9843 "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>]",
9847 BGP_INSTANCE_HELP_STR
9850 BGP_SAFI_WITH_LABEL_HELP_STR
9853 "BGP IPv4 neighbor to clear\n"
9854 "BGP IPv6 neighbor to clear\n"
9855 "BGP neighbor on interface to clear\n"
9856 "Clear peers with the AS number\n"
9857 "Clear all external peers\n"
9858 "Clear all members of peer-group\n"
9859 "BGP peer-group name\n"
9864 "Push out prefix-list ORF and do inbound soft reconfig\n"
9866 "Reset message statistics\n")
9870 afi_t afi
= AFI_UNSPEC
;
9871 safi_t safi
= SAFI_UNSPEC
;
9872 enum clear_sort clr_sort
= clear_peer
;
9873 enum bgp_clear_type clr_type
;
9874 char *clr_arg
= NULL
;
9878 /* clear [ip] bgp */
9879 if (argv_find(argv
, argc
, "ip", &idx
))
9882 /* [<vrf> VIEWVRFNAME] */
9883 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9884 vrf
= argv
[idx
+ 1]->arg
;
9886 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9888 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9889 /* [<view> VIEWVRFNAME] */
9890 vrf
= argv
[idx
+ 1]->arg
;
9893 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9894 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9895 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9897 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9898 if (argv_find(argv
, argc
, "*", &idx
)) {
9899 clr_sort
= clear_all
;
9900 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9901 clr_sort
= clear_peer
;
9902 clr_arg
= argv
[idx
]->arg
;
9903 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9904 clr_sort
= clear_peer
;
9905 clr_arg
= argv
[idx
]->arg
;
9906 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9907 clr_sort
= clear_group
;
9909 clr_arg
= argv
[idx
]->arg
;
9910 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9911 clr_sort
= clear_peer
;
9912 clr_arg
= argv
[idx
]->arg
;
9913 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9914 clr_sort
= clear_peer
;
9915 clr_arg
= argv
[idx
]->arg
;
9916 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9917 clr_sort
= clear_as
;
9918 clr_arg
= argv
[idx
]->arg
;
9919 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9920 clr_sort
= clear_external
;
9923 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9924 if (argv_find(argv
, argc
, "soft", &idx
)) {
9925 if (argv_find(argv
, argc
, "in", &idx
)
9926 || argv_find(argv
, argc
, "out", &idx
))
9927 clr_type
= strmatch(argv
[idx
]->text
, "in")
9929 : BGP_CLEAR_SOFT_OUT
;
9931 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9932 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9933 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9934 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9935 : BGP_CLEAR_SOFT_IN
;
9936 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9937 clr_type
= BGP_CLEAR_SOFT_OUT
;
9938 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9939 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9941 clr_type
= BGP_CLEAR_SOFT_NONE
;
9943 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9946 DEFUN (clear_ip_bgp_prefix
,
9947 clear_ip_bgp_prefix_cmd
,
9948 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9952 BGP_INSTANCE_HELP_STR
9953 "Clear bestpath and re-advertise\n"
9957 char *prefix
= NULL
;
9961 /* [<view|vrf> VIEWVRFNAME] */
9962 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9963 vrf
= argv
[idx
+ 1]->arg
;
9965 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9967 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9968 /* [<view> VIEWVRFNAME] */
9969 vrf
= argv
[idx
+ 1]->arg
;
9973 prefix
= argv
[argc
- 1]->arg
;
9975 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9978 DEFUN (clear_bgp_ipv6_safi_prefix
,
9979 clear_bgp_ipv6_safi_prefix_cmd
,
9980 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9986 "Clear bestpath and re-advertise\n"
9990 int idx_ipv6_prefix
= 0;
9991 safi_t safi
= SAFI_UNICAST
;
9992 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9993 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9995 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9996 return bgp_clear_prefix(
9997 vty
, NULL
, prefix
, AFI_IP6
,
10001 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10002 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10003 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10007 BGP_INSTANCE_HELP_STR
10010 "Clear bestpath and re-advertise\n"
10014 int idx_vrfview
= 0;
10015 int idx_ipv6_prefix
= 0;
10016 safi_t safi
= SAFI_UNICAST
;
10017 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10018 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10019 char *vrfview
= NULL
;
10021 /* [<view|vrf> VIEWVRFNAME] */
10022 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10023 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10024 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10026 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10027 /* [<view> VIEWVRFNAME] */
10028 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10030 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10032 return bgp_clear_prefix(
10033 vty
, vrfview
, prefix
,
10034 AFI_IP6
, safi
, NULL
);
10037 DEFUN (show_bgp_views
,
10038 show_bgp_views_cmd
,
10039 "show [ip] bgp views",
10043 "Show the defined BGP views\n")
10045 struct list
*inst
= bm
->bgp
;
10046 struct listnode
*node
;
10049 vty_out(vty
, "Defined BGP views:\n");
10050 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10052 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10054 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10058 return CMD_SUCCESS
;
10061 DEFUN (show_bgp_vrfs
,
10063 "show [ip] bgp vrfs [json]",
10070 char buf
[ETHER_ADDR_STRLEN
];
10071 struct list
*inst
= bm
->bgp
;
10072 struct listnode
*node
;
10074 bool uj
= use_json(argc
, argv
);
10075 json_object
*json
= NULL
;
10076 json_object
*json_vrfs
= NULL
;
10080 json
= json_object_new_object();
10081 json_vrfs
= json_object_new_object();
10084 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10085 const char *name
, *type
;
10087 struct listnode
*node2
, *nnode2
;
10088 int peers_cfg
, peers_estb
;
10089 json_object
*json_vrf
= NULL
;
10092 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10096 if (!uj
&& count
== 1) {
10098 "%4s %-5s %-16s %9s %10s %-37s\n",
10099 "Type", "Id", "routerId", "#PeersCfg",
10100 "#PeersEstb", "Name");
10101 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10102 "L3-VNI", "RouterMAC", "Interface");
10105 peers_cfg
= peers_estb
= 0;
10107 json_vrf
= json_object_new_object();
10110 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10111 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10114 if (peer_established(peer
))
10118 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10119 name
= VRF_DEFAULT_NAME
;
10128 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10130 : (int64_t)bgp
->vrf_id
;
10131 char buf
[BUFSIZ
] = {0};
10133 json_object_string_add(json_vrf
, "type", type
);
10134 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10135 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10137 json_object_int_add(json_vrf
, "numConfiguredPeers",
10139 json_object_int_add(json_vrf
, "numEstablishedPeers",
10142 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10143 json_object_string_add(
10145 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10146 json_object_string_add(json_vrf
, "interface",
10147 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10149 json_object_object_add(json_vrfs
, name
, json_vrf
);
10151 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10153 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10154 : (int)bgp
->vrf_id
,
10155 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10156 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10158 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10159 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10165 json_object_object_add(json
, "vrfs", json_vrfs
);
10167 json_object_int_add(json
, "totalVrfs", count
);
10169 vty_json(vty
, json
);
10173 "\nTotal number of VRFs (including default): %d\n",
10177 return CMD_SUCCESS
;
10180 DEFUN (show_bgp_mac_hash
,
10181 show_bgp_mac_hash_cmd
,
10182 "show bgp mac hash",
10186 "Mac Address database\n")
10188 bgp_mac_dump_table(vty
);
10190 return CMD_SUCCESS
;
10193 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10195 struct vty
*vty
= (struct vty
*)args
;
10196 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10198 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10201 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10203 vty_out(vty
, "self nexthop database:\n");
10204 bgp_nexthop_show_address_hash(vty
, bgp
);
10206 vty_out(vty
, "Tunnel-ip database:\n");
10207 hash_iterate(bgp
->tip_hash
,
10208 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10212 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10213 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10214 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10215 "martian next-hops\n"
10216 "martian next-hop database\n")
10218 struct bgp
*bgp
= NULL
;
10222 /* [<vrf> VIEWVRFNAME] */
10223 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10224 name
= argv
[idx
+ 1]->arg
;
10225 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10227 } else if (argv_find(argv
, argc
, "view", &idx
))
10228 /* [<view> VIEWVRFNAME] */
10229 name
= argv
[idx
+ 1]->arg
;
10231 bgp
= bgp_lookup_by_name(name
);
10233 bgp
= bgp_get_default();
10236 vty_out(vty
, "%% No BGP process is configured\n");
10237 return CMD_WARNING
;
10239 bgp_show_martian_nexthops(vty
, bgp
);
10241 return CMD_SUCCESS
;
10244 DEFUN (show_bgp_memory
,
10245 show_bgp_memory_cmd
,
10246 "show [ip] bgp memory",
10250 "Global BGP memory statistics\n")
10252 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10253 unsigned long count
;
10255 /* RIB related usage stats */
10256 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10257 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10258 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10259 count
* sizeof(struct bgp_dest
)));
10261 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10262 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10263 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10264 count
* sizeof(struct bgp_path_info
)));
10265 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10266 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10269 memstrbuf
, sizeof(memstrbuf
),
10270 count
* sizeof(struct bgp_path_info_extra
)));
10272 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10273 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10274 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10275 count
* sizeof(struct bgp_static
)));
10277 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10278 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10279 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10280 count
* sizeof(struct bpacket
)));
10283 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10284 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10285 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10286 count
* sizeof(struct bgp_adj_in
)));
10287 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10288 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10289 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10290 count
* sizeof(struct bgp_adj_out
)));
10292 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10293 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10295 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10296 count
* sizeof(struct bgp_nexthop_cache
)));
10298 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10299 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10301 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10302 count
* sizeof(struct bgp_damp_info
)));
10305 count
= attr_count();
10306 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10307 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10308 count
* sizeof(struct attr
)));
10310 if ((count
= attr_unknown_count()))
10311 vty_out(vty
, "%ld unknown attributes\n", count
);
10313 /* AS_PATH attributes */
10314 count
= aspath_count();
10315 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10316 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10317 count
* sizeof(struct aspath
)));
10319 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10320 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10321 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10322 count
* sizeof(struct assegment
)));
10324 /* Other attributes */
10325 if ((count
= community_count()))
10326 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10327 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10328 count
* sizeof(struct community
)));
10329 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10331 "%ld BGP ext-community entries, using %s of memory\n",
10333 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10334 count
* sizeof(struct ecommunity
)));
10335 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10337 "%ld BGP large-community entries, using %s of memory\n",
10338 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10339 count
* sizeof(struct lcommunity
)));
10341 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10342 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10343 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10344 count
* sizeof(struct cluster_list
)));
10346 /* Peer related usage */
10347 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10348 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10349 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10350 count
* sizeof(struct peer
)));
10352 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10353 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10354 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10355 count
* sizeof(struct peer_group
)));
10358 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10359 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10360 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10361 count
* sizeof(regex_t
)));
10362 return CMD_SUCCESS
;
10365 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10367 json_object
*bestpath
= json_object_new_object();
10369 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10370 json_object_string_add(bestpath
, "asPath", "ignore");
10372 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10373 json_object_string_add(bestpath
, "asPath", "confed");
10375 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10376 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10377 json_object_string_add(bestpath
, "multiPathRelax",
10380 json_object_string_add(bestpath
, "multiPathRelax",
10383 json_object_string_add(bestpath
, "multiPathRelax", "false");
10385 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10386 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10388 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10389 json_object_string_add(bestpath
, "compareRouterId", "true");
10390 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10391 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10392 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10393 json_object_string_add(bestpath
, "med", "confed");
10394 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10395 json_object_string_add(bestpath
, "med",
10396 "missing-as-worst");
10398 json_object_string_add(bestpath
, "med", "true");
10401 json_object_object_add(json
, "bestPath", bestpath
);
10404 /* Print the error code/subcode for why the peer is down */
10405 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10406 json_object
*json_peer
, bool use_json
)
10408 const char *code_str
;
10409 const char *subcode_str
;
10412 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10413 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10414 char errorcodesubcode_hexstr
[5];
10415 char errorcodesubcode_str
[256];
10417 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10418 subcode_str
= bgp_notify_subcode_str(
10420 peer
->notify
.subcode
);
10422 snprintf(errorcodesubcode_hexstr
,
10423 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10424 peer
->notify
.code
, peer
->notify
.subcode
);
10425 json_object_string_add(json_peer
,
10426 "lastErrorCodeSubcode",
10427 errorcodesubcode_hexstr
);
10428 snprintf(errorcodesubcode_str
, 255, "%s%s",
10429 code_str
, subcode_str
);
10430 json_object_string_add(json_peer
,
10431 "lastNotificationReason",
10432 errorcodesubcode_str
);
10433 json_object_boolean_add(json_peer
,
10434 "lastNotificationHardReset",
10435 peer
->notify
.hard_reset
);
10436 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10437 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10438 && (peer
->notify
.subcode
10439 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10440 || peer
->notify
.subcode
10441 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10442 && peer
->notify
.length
) {
10444 const char *msg_str
;
10446 msg_str
= bgp_notify_admin_message(
10447 msgbuf
, sizeof(msgbuf
),
10448 (uint8_t *)peer
->notify
.data
,
10449 peer
->notify
.length
);
10451 json_object_string_add(
10453 "lastShutdownDescription",
10458 json_object_string_add(json_peer
, "lastResetDueTo",
10459 peer_down_str
[(int)peer
->last_reset
]);
10460 json_object_int_add(json_peer
, "lastResetCode",
10463 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10464 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10465 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10467 bgp_notify_subcode_str(peer
->notify
.code
,
10468 peer
->notify
.subcode
);
10469 vty_out(vty
, " Notification %s (%s%s%s)\n",
10470 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10473 code_str
, subcode_str
,
10474 peer
->notify
.hard_reset
10475 ? bgp_notify_subcode_str(
10477 BGP_NOTIFY_CEASE_HARD_RESET
)
10480 vty_out(vty
, " %s\n",
10481 peer_down_str
[(int)peer
->last_reset
]);
10486 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10489 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10492 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10493 struct peer
*peer
, json_object
*json_peer
,
10494 int max_neighbor_width
, bool use_json
)
10496 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10500 if (peer_dynamic_neighbor(peer
))
10501 json_object_boolean_true_add(json_peer
,
10503 if (peer
->hostname
)
10504 json_object_string_add(json_peer
, "hostname",
10507 if (peer
->domainname
)
10508 json_object_string_add(json_peer
, "domainname",
10510 json_object_int_add(json_peer
, "connectionsEstablished",
10511 peer
->established
);
10512 json_object_int_add(json_peer
, "connectionsDropped",
10514 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10515 use_json
, json_peer
);
10516 if (peer_established(peer
))
10517 json_object_string_add(json_peer
, "lastResetDueTo",
10518 "AFI/SAFI Not Negotiated");
10520 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10523 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10525 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10526 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10527 peer
->hostname
, peer
->host
);
10529 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10531 /* pad the neighbor column with spaces */
10532 if (len
< max_neighbor_width
)
10533 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10535 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10537 peer_uptime(peer
->uptime
, timebuf
,
10538 BGP_UPTIME_LEN
, 0, NULL
));
10539 if (peer_established(peer
))
10540 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10542 bgp_show_peer_reset(vty
, peer
, NULL
,
10547 /* Strip peer's description to the given size. */
10548 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10550 static char stripped
[BUFSIZ
];
10552 uint32_t last_space
= 0;
10555 if (*(desc
+ i
) == 0) {
10556 stripped
[i
] = '\0';
10559 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10561 stripped
[i
] = *(desc
+ i
);
10565 if (last_space
> size
)
10566 stripped
[size
+ 1] = '\0';
10568 stripped
[last_space
] = '\0';
10573 /* Determine whether var peer should be filtered out of the summary. */
10574 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10575 struct peer
*fpeer
, int as_type
,
10579 /* filter neighbor XXXX */
10580 if (fpeer
&& fpeer
!= peer
)
10583 /* filter remote-as (internal|external) */
10584 if (as_type
!= AS_UNSPECIFIED
) {
10585 if (peer
->as_type
== AS_SPECIFIED
) {
10586 if (as_type
== AS_INTERNAL
) {
10587 if (peer
->as
!= peer
->local_as
)
10589 } else if (peer
->as
== peer
->local_as
)
10591 } else if (as_type
!= peer
->as_type
)
10593 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10599 /* Show BGP peer's summary information.
10601 * Peer's description is stripped according to if `wide` option is given
10604 * When adding new columns to `show bgp summary` output, please make
10605 * sure `Desc` is the lastest column to show because it can contain
10606 * whitespaces and the whole output will be tricky.
10608 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10609 struct peer
*fpeer
, int as_type
, as_t as
,
10610 uint16_t show_flags
)
10613 struct listnode
*node
, *nnode
;
10614 unsigned int count
= 0, dn_count
= 0;
10615 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10616 char neighbor_buf
[VTY_BUFSIZ
];
10617 int neighbor_col_default_width
= 16;
10618 int len
, failed_count
= 0;
10619 unsigned int filtered_count
= 0;
10620 int max_neighbor_width
= 0;
10622 json_object
*json
= NULL
;
10623 json_object
*json_peer
= NULL
;
10624 json_object
*json_peers
= NULL
;
10625 struct peer_af
*paf
;
10626 struct bgp_filter
*filter
;
10627 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10628 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10629 bool show_established
=
10630 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10631 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10632 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10634 /* labeled-unicast routes are installed in the unicast table so in order
10636 * display the correct PfxRcd value we must look at SAFI_UNICAST
10639 if (safi
== SAFI_LABELED_UNICAST
)
10640 pfx_rcd_safi
= SAFI_UNICAST
;
10642 pfx_rcd_safi
= safi
;
10645 json
= json_object_new_object();
10646 json_peers
= json_object_new_object();
10647 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10648 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10655 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10658 if (peer
->afc
[afi
][safi
]) {
10659 /* See if we have at least a single failed peer */
10660 if (bgp_has_peer_failed(peer
, afi
, safi
))
10664 if (peer_dynamic_neighbor(peer
))
10669 /* Loop over all neighbors that will be displayed to determine
10671 * characters are needed for the Neighbor column
10673 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10674 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10681 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10684 if (peer
->afc
[afi
][safi
]) {
10685 memset(dn_flag
, '\0', sizeof(dn_flag
));
10686 if (peer_dynamic_neighbor(peer
))
10690 && CHECK_FLAG(bgp
->flags
,
10691 BGP_FLAG_SHOW_HOSTNAME
))
10692 snprintf(neighbor_buf
,
10693 sizeof(neighbor_buf
),
10694 "%s%s(%s) ", dn_flag
,
10695 peer
->hostname
, peer
->host
);
10697 snprintf(neighbor_buf
,
10698 sizeof(neighbor_buf
), "%s%s ",
10699 dn_flag
, peer
->host
);
10701 len
= strlen(neighbor_buf
);
10703 if (len
> max_neighbor_width
)
10704 max_neighbor_width
= len
;
10706 /* See if we have at least a single failed peer */
10707 if (bgp_has_peer_failed(peer
, afi
, safi
))
10713 /* Originally we displayed the Neighbor column as 16
10714 * characters wide so make that the default
10716 if (max_neighbor_width
< neighbor_col_default_width
)
10717 max_neighbor_width
= neighbor_col_default_width
;
10720 if (show_failed
&& !failed_count
) {
10722 json_object_int_add(json
, "failedPeersCount", 0);
10723 json_object_int_add(json
, "dynamicPeers", dn_count
);
10724 json_object_int_add(json
, "totalPeers", count
);
10726 vty_json(vty
, json
);
10728 vty_out(vty
, "%% No failed BGP neighbors found\n");
10730 return CMD_SUCCESS
;
10733 count
= 0; /* Reset the value as its used again */
10734 filtered_count
= 0;
10736 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10737 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10740 if (!peer
->afc
[afi
][safi
])
10744 unsigned long ents
;
10745 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10748 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10750 : (int64_t)bgp
->vrf_id
;
10752 /* Usage summary and header */
10754 json_object_string_addf(json
, "routerId",
10757 json_object_int_add(json
, "as", bgp
->as
);
10758 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10759 json_object_string_add(
10762 == BGP_INSTANCE_TYPE_DEFAULT
)
10767 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10768 &bgp
->router_id
, bgp
->as
,
10769 bgp
->vrf_id
== VRF_UNKNOWN
10771 : (int)bgp
->vrf_id
);
10772 vty_out(vty
, "\n");
10775 if (bgp_update_delay_configured(bgp
)) {
10777 json_object_int_add(
10778 json
, "updateDelayLimit",
10779 bgp
->v_update_delay
);
10781 if (bgp
->v_update_delay
10782 != bgp
->v_establish_wait
)
10783 json_object_int_add(
10785 "updateDelayEstablishWait",
10786 bgp
->v_establish_wait
);
10788 if (bgp_update_delay_active(bgp
)) {
10789 json_object_string_add(
10791 "updateDelayFirstNeighbor",
10792 bgp
->update_delay_begin_time
);
10793 json_object_boolean_true_add(
10795 "updateDelayInProgress");
10797 if (bgp
->update_delay_over
) {
10798 json_object_string_add(
10800 "updateDelayFirstNeighbor",
10801 bgp
->update_delay_begin_time
);
10802 json_object_string_add(
10804 "updateDelayBestpathResumed",
10805 bgp
->update_delay_end_time
);
10806 json_object_string_add(
10808 "updateDelayZebraUpdateResume",
10809 bgp
->update_delay_zebra_resume_time
);
10810 json_object_string_add(
10812 "updateDelayPeerUpdateResume",
10813 bgp
->update_delay_peers_resume_time
);
10818 "Read-only mode update-delay limit: %d seconds\n",
10819 bgp
->v_update_delay
);
10820 if (bgp
->v_update_delay
10821 != bgp
->v_establish_wait
)
10823 " Establish wait: %d seconds\n",
10824 bgp
->v_establish_wait
);
10826 if (bgp_update_delay_active(bgp
)) {
10828 " First neighbor established: %s\n",
10829 bgp
->update_delay_begin_time
);
10831 " Delay in progress\n");
10833 if (bgp
->update_delay_over
) {
10835 " First neighbor established: %s\n",
10836 bgp
->update_delay_begin_time
);
10838 " Best-paths resumed: %s\n",
10839 bgp
->update_delay_end_time
);
10841 " zebra update resumed: %s\n",
10842 bgp
->update_delay_zebra_resume_time
);
10844 " peers update resumed: %s\n",
10845 bgp
->update_delay_peers_resume_time
);
10852 if (bgp_maxmed_onstartup_configured(bgp
)
10853 && bgp
->maxmed_active
)
10854 json_object_boolean_true_add(
10855 json
, "maxMedOnStartup");
10856 if (bgp
->v_maxmed_admin
)
10857 json_object_boolean_true_add(
10858 json
, "maxMedAdministrative");
10860 json_object_int_add(
10861 json
, "tableVersion",
10862 bgp_table_version(bgp
->rib
[afi
][safi
]));
10864 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10865 json_object_int_add(json
, "ribCount", ents
);
10866 json_object_int_add(
10868 ents
* sizeof(struct bgp_dest
));
10870 ents
= bgp
->af_peer_count
[afi
][safi
];
10871 json_object_int_add(json
, "peerCount", ents
);
10872 json_object_int_add(json
, "peerMemory",
10873 ents
* sizeof(struct peer
));
10875 if ((ents
= listcount(bgp
->group
))) {
10876 json_object_int_add(
10877 json
, "peerGroupCount", ents
);
10878 json_object_int_add(
10879 json
, "peerGroupMemory",
10880 ents
* sizeof(struct
10884 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10885 BGP_CONFIG_DAMPENING
))
10886 json_object_boolean_true_add(
10887 json
, "dampeningEnabled");
10890 if (bgp_maxmed_onstartup_configured(bgp
)
10891 && bgp
->maxmed_active
)
10893 "Max-med on-startup active\n");
10894 if (bgp
->v_maxmed_admin
)
10896 "Max-med administrative active\n");
10899 "BGP table version %" PRIu64
10902 bgp
->rib
[afi
][safi
]));
10904 ents
= bgp_table_count(
10905 bgp
->rib
[afi
][safi
]);
10907 "RIB entries %ld, using %s of memory\n",
10917 /* Peer related usage */
10918 ents
= bgp
->af_peer_count
[afi
][safi
];
10920 "Peers %ld, using %s of memory\n",
10930 if ((ents
= listcount(bgp
->group
)))
10932 "Peer groups %ld, using %s of memory\n",
10942 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10943 BGP_CONFIG_DAMPENING
))
10945 "Dampening enabled.\n");
10948 vty_out(vty
, "\n");
10950 /* Subtract 8 here because 'Neighbor' is
10952 vty_out(vty
, "Neighbor");
10953 vty_out(vty
, "%*s",
10954 max_neighbor_width
- 8, " ");
10956 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10961 paf
= peer_af_find(peer
, afi
, safi
);
10962 filter
= &peer
->filter
[afi
][safi
];
10965 /* Works for both failed & successful cases */
10966 if (peer_dynamic_neighbor(peer
))
10971 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10977 bgp_has_peer_failed(peer
, afi
, safi
)) {
10978 json_peer
= json_object_new_object();
10979 bgp_show_failed_summary(vty
, bgp
, peer
,
10980 json_peer
, 0, use_json
);
10981 } else if (!show_failed
) {
10982 if (show_established
10983 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10988 json_peer
= json_object_new_object();
10989 if (peer_dynamic_neighbor(peer
)) {
10990 json_object_boolean_true_add(json_peer
,
10994 if (peer
->hostname
)
10995 json_object_string_add(json_peer
, "hostname",
10998 if (peer
->domainname
)
10999 json_object_string_add(json_peer
, "domainname",
11002 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11003 json_object_int_add(
11004 json_peer
, "localAs",
11005 peer
->change_local_as
11006 ? peer
->change_local_as
11008 json_object_int_add(json_peer
, "version", 4);
11009 json_object_int_add(json_peer
, "msgRcvd",
11010 PEER_TOTAL_RX(peer
));
11011 json_object_int_add(json_peer
, "msgSent",
11012 PEER_TOTAL_TX(peer
));
11014 atomic_size_t outq_count
, inq_count
;
11015 outq_count
= atomic_load_explicit(
11016 &peer
->obuf
->count
,
11017 memory_order_relaxed
);
11018 inq_count
= atomic_load_explicit(
11019 &peer
->ibuf
->count
,
11020 memory_order_relaxed
);
11022 json_object_int_add(json_peer
, "tableVersion",
11023 peer
->version
[afi
][safi
]);
11024 json_object_int_add(json_peer
, "outq",
11026 json_object_int_add(json_peer
, "inq",
11028 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11029 use_json
, json_peer
);
11031 json_object_int_add(json_peer
, "pfxRcd",
11032 peer
->pcount
[afi
][pfx_rcd_safi
]);
11034 if (paf
&& PAF_SUBGRP(paf
))
11035 json_object_int_add(
11036 json_peer
, "pfxSnt",
11037 (PAF_SUBGRP(paf
))->scount
);
11039 json_object_int_add(json_peer
, "pfxSnt",
11042 /* BGP FSM state */
11043 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11044 || CHECK_FLAG(peer
->bgp
->flags
,
11045 BGP_FLAG_SHUTDOWN
))
11046 json_object_string_add(json_peer
,
11049 else if (peer
->afc_recv
[afi
][safi
])
11050 json_object_string_add(
11051 json_peer
, "state",
11052 lookup_msg(bgp_status_msg
,
11053 peer
->status
, NULL
));
11054 else if (CHECK_FLAG(
11056 PEER_STATUS_PREFIX_OVERFLOW
))
11057 json_object_string_add(json_peer
,
11061 json_object_string_add(
11062 json_peer
, "state",
11063 lookup_msg(bgp_status_msg
,
11064 peer
->status
, NULL
));
11066 /* BGP peer state */
11067 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11068 || CHECK_FLAG(peer
->bgp
->flags
,
11069 BGP_FLAG_SHUTDOWN
))
11070 json_object_string_add(json_peer
,
11073 else if (CHECK_FLAG(
11075 PEER_STATUS_PREFIX_OVERFLOW
))
11076 json_object_string_add(json_peer
,
11079 else if (CHECK_FLAG(peer
->flags
,
11080 PEER_FLAG_PASSIVE
))
11081 json_object_string_add(json_peer
,
11084 else if (CHECK_FLAG(peer
->sflags
,
11085 PEER_STATUS_NSF_WAIT
))
11086 json_object_string_add(json_peer
,
11089 else if (CHECK_FLAG(
11091 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11092 && (!bgp_inbound_policy_exists(peer
,
11094 || !bgp_outbound_policy_exists(
11096 json_object_string_add(json_peer
,
11100 json_object_string_add(
11101 json_peer
, "peerState", "OK");
11103 json_object_int_add(json_peer
, "connectionsEstablished",
11104 peer
->established
);
11105 json_object_int_add(json_peer
, "connectionsDropped",
11108 json_object_string_add(
11109 json_peer
, "desc", peer
->desc
);
11111 /* Avoid creating empty peer dicts in JSON */
11112 if (json_peer
== NULL
)
11116 json_object_string_add(json_peer
, "idType",
11118 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11119 json_object_string_add(json_peer
, "idType",
11121 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11122 json_object_string_add(json_peer
, "idType",
11124 json_object_object_add(json_peers
, peer
->host
,
11127 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11133 bgp_has_peer_failed(peer
, afi
, safi
)) {
11134 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11135 max_neighbor_width
,
11137 } else if (!show_failed
) {
11138 if (show_established
11139 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11144 if ((count
- filtered_count
) == 1) {
11145 /* display headline before the first
11147 vty_out(vty
, "\n");
11149 /* Subtract 8 here because 'Neighbor' is
11151 vty_out(vty
, "Neighbor");
11152 vty_out(vty
, "%*s",
11153 max_neighbor_width
- 8, " ");
11156 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11157 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11160 memset(dn_flag
, '\0', sizeof(dn_flag
));
11161 if (peer_dynamic_neighbor(peer
)) {
11166 && CHECK_FLAG(bgp
->flags
,
11167 BGP_FLAG_SHOW_HOSTNAME
))
11168 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11172 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11174 /* pad the neighbor column with spaces */
11175 if (len
< max_neighbor_width
)
11176 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11179 atomic_size_t outq_count
, inq_count
;
11180 outq_count
= atomic_load_explicit(
11181 &peer
->obuf
->count
,
11182 memory_order_relaxed
);
11183 inq_count
= atomic_load_explicit(
11184 &peer
->ibuf
->count
,
11185 memory_order_relaxed
);
11189 "4 %10u %10u %9u %9u %8" PRIu64
11192 peer
->change_local_as
11193 ? peer
->change_local_as
11195 PEER_TOTAL_RX(peer
),
11196 PEER_TOTAL_TX(peer
),
11197 peer
->version
[afi
][safi
],
11198 inq_count
, outq_count
,
11199 peer_uptime(peer
->uptime
,
11204 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11206 peer
->as
, PEER_TOTAL_RX(peer
),
11207 PEER_TOTAL_TX(peer
),
11208 peer
->version
[afi
][safi
],
11209 inq_count
, outq_count
,
11210 peer_uptime(peer
->uptime
,
11215 if (peer_established(peer
)) {
11216 if (peer
->afc_recv
[afi
][safi
]) {
11219 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11220 && !bgp_inbound_policy_exists(
11222 vty_out(vty
, " %12s",
11231 vty_out(vty
, " NoNeg");
11234 if (paf
&& PAF_SUBGRP(paf
)) {
11237 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11238 && !bgp_outbound_policy_exists(
11240 vty_out(vty
, " %8s",
11249 vty_out(vty
, " NoNeg");
11252 if (CHECK_FLAG(peer
->flags
,
11253 PEER_FLAG_SHUTDOWN
)
11254 || CHECK_FLAG(peer
->bgp
->flags
,
11255 BGP_FLAG_SHUTDOWN
))
11256 vty_out(vty
, " Idle (Admin)");
11257 else if (CHECK_FLAG(
11259 PEER_STATUS_PREFIX_OVERFLOW
))
11260 vty_out(vty
, " Idle (PfxCt)");
11262 vty_out(vty
, " %12s",
11263 lookup_msg(bgp_status_msg
,
11264 peer
->status
, NULL
));
11266 vty_out(vty
, " %8u", 0);
11268 /* Make sure `Desc` column is the lastest in
11272 vty_out(vty
, " %s",
11273 bgp_peer_description_stripped(
11275 show_wide
? 64 : 20));
11277 vty_out(vty
, " N/A");
11278 vty_out(vty
, "\n");
11285 json_object_object_add(json
, "peers", json_peers
);
11286 json_object_int_add(json
, "failedPeers", failed_count
);
11287 json_object_int_add(json
, "displayedPeers",
11288 count
- filtered_count
);
11289 json_object_int_add(json
, "totalPeers", count
);
11290 json_object_int_add(json
, "dynamicPeers", dn_count
);
11293 bgp_show_bestpath_json(bgp
, json
);
11295 vty_json(vty
, json
);
11298 if (filtered_count
== count
)
11299 vty_out(vty
, "\n%% No matching neighbor\n");
11302 vty_out(vty
, "\nDisplayed neighbors %d",
11304 else if (as_type
!= AS_UNSPECIFIED
|| as
11305 || fpeer
|| show_established
)
11306 vty_out(vty
, "\nDisplayed neighbors %d",
11307 count
- filtered_count
);
11309 vty_out(vty
, "\nTotal number of neighbors %d\n",
11313 vty_out(vty
, "No %s neighbor is configured\n",
11314 get_afi_safi_str(afi
, safi
, false));
11318 vty_out(vty
, "* - dynamic neighbor\n");
11319 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11320 dn_count
, bgp
->dynamic_neighbors_limit
);
11324 return CMD_SUCCESS
;
11327 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11328 int safi
, struct peer
*fpeer
, int as_type
,
11329 as_t as
, uint16_t show_flags
)
11332 int afi_wildcard
= (afi
== AFI_MAX
);
11333 int safi_wildcard
= (safi
== SAFI_MAX
);
11334 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11335 bool nbr_output
= false;
11336 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11338 if (use_json
&& is_wildcard
)
11339 vty_out(vty
, "{\n");
11341 afi
= 1; /* AFI_IP */
11342 while (afi
< AFI_MAX
) {
11344 safi
= 1; /* SAFI_UNICAST */
11345 while (safi
< SAFI_MAX
) {
11346 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11351 * So limit output to those afi/safi
11353 * actualy have something interesting in
11358 vty_out(vty
, ",\n");
11362 vty_out(vty
, "\"%s\":",
11363 get_afi_safi_str(afi
,
11368 "\n%s Summary (%s):\n",
11369 get_afi_safi_str(afi
,
11375 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11376 as_type
, as
, show_flags
);
11379 if (!safi_wildcard
)
11387 if (use_json
&& is_wildcard
)
11388 vty_out(vty
, "}\n");
11389 else if (!nbr_output
) {
11391 vty_out(vty
, "{}\n");
11393 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11398 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11400 const char *neighbor
,
11401 int as_type
, as_t as
,
11402 uint16_t show_flags
)
11404 struct listnode
*node
, *nnode
;
11406 struct peer
*fpeer
= NULL
;
11408 bool nbr_output
= false;
11409 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11412 vty_out(vty
, "{\n");
11414 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11418 vty_out(vty
, ",\n");
11422 vty_out(vty
, "\"%s\":",
11423 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11428 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11433 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11438 vty_out(vty
, "}\n");
11439 else if (!nbr_output
)
11440 vty_out(vty
, "%% BGP instance not found\n");
11443 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11444 safi_t safi
, const char *neighbor
, int as_type
,
11445 as_t as
, uint16_t show_flags
)
11448 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11449 struct peer
*fpeer
= NULL
;
11452 if (strmatch(name
, "all")) {
11453 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11456 return CMD_SUCCESS
;
11458 bgp
= bgp_lookup_by_name(name
);
11462 vty_out(vty
, "{}\n");
11465 "%% BGP instance not found\n");
11466 return CMD_WARNING
;
11470 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11473 return CMD_WARNING
;
11475 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11476 as_type
, as
, show_flags
);
11477 return CMD_SUCCESS
;
11481 bgp
= bgp_get_default();
11485 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11488 return CMD_WARNING
;
11490 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11494 vty_out(vty
, "{}\n");
11496 vty_out(vty
, "%% BGP instance not found\n");
11497 return CMD_WARNING
;
11500 return CMD_SUCCESS
;
11503 /* `show [ip] bgp summary' commands. */
11504 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11505 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11506 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11507 "]] [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]",
11508 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11509 BGP_SAFI_WITH_LABEL_HELP_STR
11510 "Display the entries for all address families\n"
11511 "Summary of BGP neighbor status\n"
11512 "Show only sessions in Established state\n"
11513 "Show only sessions not in Established state\n"
11514 "Show only the specified neighbor session\n"
11515 "Neighbor to display information about\n"
11516 "Neighbor to display information about\n"
11517 "Neighbor on BGP configured interface\n"
11518 "Show only the specified remote AS sessions\n"
11520 "Internal (iBGP) AS sessions\n"
11521 "External (eBGP) AS sessions\n"
11522 "Shorten the information on BGP instances\n"
11523 "Increase table width for longer output\n" JSON_STR
)
11526 afi_t afi
= AFI_MAX
;
11527 safi_t safi
= SAFI_MAX
;
11528 as_t as
= 0; /* 0 means AS filter not set */
11529 int as_type
= AS_UNSPECIFIED
;
11530 uint16_t show_flags
= 0;
11534 /* show [ip] bgp */
11535 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11537 /* [<vrf> VIEWVRFNAME] */
11538 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11539 vrf
= argv
[idx
+ 1]->arg
;
11540 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11542 } else if (argv_find(argv
, argc
, "view", &idx
))
11543 /* [<view> VIEWVRFNAME] */
11544 vrf
= argv
[idx
+ 1]->arg
;
11545 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11546 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11547 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11550 if (argv_find(argv
, argc
, "failed", &idx
))
11551 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11553 if (argv_find(argv
, argc
, "established", &idx
))
11554 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11556 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11557 if (argv
[idx
+ 1]->arg
[0] == 'i')
11558 as_type
= AS_INTERNAL
;
11559 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11560 as_type
= AS_EXTERNAL
;
11562 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11565 if (argv_find(argv
, argc
, "terse", &idx
))
11566 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11568 if (argv_find(argv
, argc
, "wide", &idx
))
11569 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11571 if (argv_find(argv
, argc
, "json", &idx
))
11572 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11574 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11578 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11581 return get_afi_safi_json_str(afi
, safi
);
11583 return get_afi_safi_vty_str(afi
, safi
);
11587 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11588 afi_t afi
, safi_t safi
,
11589 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11590 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11591 bool use_json
, json_object
*json_pref
)
11594 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11595 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11597 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11598 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11599 json_object_string_add(json_pref
, "sendMode",
11600 "advertisedAndReceived");
11601 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11602 json_object_string_add(json_pref
, "sendMode",
11604 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11605 json_object_string_add(json_pref
, "sendMode",
11608 vty_out(vty
, " Send-mode: ");
11609 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11610 vty_out(vty
, "advertised");
11611 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11612 vty_out(vty
, "%sreceived",
11613 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11617 vty_out(vty
, "\n");
11622 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11623 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11625 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11626 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11627 json_object_string_add(json_pref
, "recvMode",
11628 "advertisedAndReceived");
11629 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11630 json_object_string_add(json_pref
, "recvMode",
11632 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11633 json_object_string_add(json_pref
, "recvMode",
11636 vty_out(vty
, " Receive-mode: ");
11637 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11638 vty_out(vty
, "advertised");
11639 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11640 vty_out(vty
, "%sreceived",
11641 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11645 vty_out(vty
, "\n");
11650 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11658 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11659 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11660 && (peer_established(p
))) {
11661 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11662 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11666 json_object_boolean_add(json
, "rBit", rbit
);
11667 json_object_boolean_add(json
, "nBit", nbit
);
11669 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11670 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11674 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11679 const char *mode
= "NotApplicable";
11682 vty_out(vty
, "\n Remote GR Mode: ");
11684 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11685 && (peer_established(peer
))) {
11687 if ((peer
->nsf_af_count
== 0)
11688 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11692 } else if (peer
->nsf_af_count
== 0
11693 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11697 } else if (peer
->nsf_af_count
!= 0
11698 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11705 json_object_string_add(json
, "remoteGrMode", mode
);
11707 vty_out(vty
, mode
, "\n");
11710 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11715 const char *mode
= "Invalid";
11718 vty_out(vty
, " Local GR Mode: ");
11720 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11722 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11724 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11726 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11727 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11729 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11731 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11738 json_object_string_add(json
, "localGrMode", mode
);
11740 vty_out(vty
, mode
, "\n");
11744 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11745 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11749 json_object
*json_afi_safi
= NULL
;
11750 json_object
*json_timer
= NULL
;
11751 json_object
*json_endofrib_status
= NULL
;
11752 bool eor_flag
= false;
11754 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11755 if (!peer
->afc
[afi
][safi
])
11758 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11759 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11763 json_afi_safi
= json_object_new_object();
11764 json_endofrib_status
= json_object_new_object();
11765 json_timer
= json_object_new_object();
11768 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11774 vty_out(vty
, " %s:\n",
11775 get_afi_safi_str(afi
, safi
, false));
11777 vty_out(vty
, " F bit: ");
11780 if (peer
->nsf
[afi
][safi
] &&
11781 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11782 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11785 json_object_boolean_true_add(json_afi_safi
,
11788 vty_out(vty
, "True\n");
11791 json_object_boolean_false_add(json_afi_safi
,
11794 vty_out(vty
, "False\n");
11798 vty_out(vty
, " End-of-RIB sent: ");
11800 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11801 PEER_STATUS_EOR_SEND
)) {
11803 json_object_boolean_true_add(
11804 json_endofrib_status
, "endOfRibSend");
11806 PRINT_EOR_JSON(eor_flag
);
11808 vty_out(vty
, "Yes\n");
11810 " End-of-RIB sent after update: ");
11812 PRINT_EOR(eor_flag
);
11816 json_object_boolean_false_add(
11817 json_endofrib_status
, "endOfRibSend");
11818 json_object_boolean_false_add(
11819 json_endofrib_status
,
11820 "endOfRibSentAfterUpdate");
11822 vty_out(vty
, "No\n");
11824 " End-of-RIB sent after update: ");
11825 vty_out(vty
, "No\n");
11830 vty_out(vty
, " End-of-RIB received: ");
11832 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11833 PEER_STATUS_EOR_RECEIVED
)) {
11835 json_object_boolean_true_add(
11836 json_endofrib_status
, "endOfRibRecv");
11838 vty_out(vty
, "Yes\n");
11841 json_object_boolean_false_add(
11842 json_endofrib_status
, "endOfRibRecv");
11844 vty_out(vty
, "No\n");
11848 json_object_int_add(json_timer
, "stalePathTimer",
11849 peer
->bgp
->stalepath_time
);
11851 if (peer
->t_gr_stale
!= NULL
) {
11852 json_object_int_add(json_timer
,
11853 "stalePathTimerRemaining",
11854 thread_timer_remain_second(
11855 peer
->t_gr_stale
));
11858 /* Display Configured Selection
11859 * Deferral only when when
11860 * Gr mode is enabled.
11862 if (CHECK_FLAG(peer
->flags
,
11863 PEER_FLAG_GRACEFUL_RESTART
)) {
11864 json_object_int_add(json_timer
,
11865 "selectionDeferralTimer",
11866 peer
->bgp
->stalepath_time
);
11869 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11872 json_object_int_add(
11874 "selectionDeferralTimerRemaining",
11875 thread_timer_remain_second(
11876 peer
->bgp
->gr_info
[afi
][safi
]
11877 .t_select_deferral
));
11880 vty_out(vty
, " Timers:\n");
11882 " Configured Stale Path Time(sec): %u\n",
11883 peer
->bgp
->stalepath_time
);
11885 if (peer
->t_gr_stale
!= NULL
)
11887 " Stale Path Remaining(sec): %ld\n",
11888 thread_timer_remain_second(
11889 peer
->t_gr_stale
));
11890 /* Display Configured Selection
11891 * Deferral only when when
11892 * Gr mode is enabled.
11894 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11896 " Configured Selection Deferral Time(sec): %u\n",
11897 peer
->bgp
->select_defer_time
);
11899 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11902 " Selection Deferral Time Remaining(sec): %ld\n",
11903 thread_timer_remain_second(
11904 peer
->bgp
->gr_info
[afi
][safi
]
11905 .t_select_deferral
));
11908 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11909 json_endofrib_status
);
11910 json_object_object_add(json_afi_safi
, "timers",
11912 json_object_object_add(
11913 json
, get_afi_safi_str(afi
, safi
, true),
11919 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11925 json_object
*json_timer
= NULL
;
11927 json_timer
= json_object_new_object();
11929 json_object_int_add(json_timer
, "configuredRestartTimer",
11930 p
->bgp
->restart_time
);
11932 json_object_int_add(json_timer
, "receivedRestartTimer",
11935 if (p
->t_gr_restart
!= NULL
)
11936 json_object_int_add(
11937 json_timer
, "restartTimerRemaining",
11938 thread_timer_remain_second(p
->t_gr_restart
));
11940 json_object_object_add(json
, "timers", json_timer
);
11943 vty_out(vty
, " Timers:\n");
11944 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11945 p
->bgp
->restart_time
);
11947 vty_out(vty
, " Received Restart Time(sec): %u\n",
11949 if (p
->t_gr_restart
!= NULL
)
11950 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11951 thread_timer_remain_second(p
->t_gr_restart
));
11952 if (p
->t_gr_restart
!= NULL
) {
11953 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11954 thread_timer_remain_second(p
->t_gr_restart
));
11959 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11960 bool use_json
, json_object
*json
)
11962 char dn_flag
[2] = {0};
11963 /* '*' + v6 address of neighbor */
11964 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11966 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11971 json_object_string_addf(json
, "neighborAddr", "%pSU",
11974 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
11977 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11981 json_object_string_add(json
, "neighborAddr",
11984 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11987 /* more gr info in new format */
11988 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11991 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11992 safi_t safi
, bool use_json
,
11993 json_object
*json_neigh
)
11995 struct bgp_filter
*filter
;
11996 struct peer_af
*paf
;
11997 char orf_pfx_name
[BUFSIZ
];
11999 json_object
*json_af
= NULL
;
12000 json_object
*json_prefA
= NULL
;
12001 json_object
*json_prefB
= NULL
;
12002 json_object
*json_addr
= NULL
;
12003 json_object
*json_advmap
= NULL
;
12006 json_addr
= json_object_new_object();
12007 json_af
= json_object_new_object();
12008 filter
= &p
->filter
[afi
][safi
];
12010 if (peer_group_active(p
))
12011 json_object_string_add(json_addr
, "peerGroupMember",
12014 paf
= peer_af_find(p
, afi
, safi
);
12015 if (paf
&& PAF_SUBGRP(paf
)) {
12016 json_object_int_add(json_addr
, "updateGroupId",
12017 PAF_UPDGRP(paf
)->id
);
12018 json_object_int_add(json_addr
, "subGroupId",
12019 PAF_SUBGRP(paf
)->id
);
12020 json_object_int_add(json_addr
, "packetQueueLength",
12021 bpacket_queue_virtual_length(paf
));
12024 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12025 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12026 PEER_CAP_ORF_PREFIX_SM_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 json_object_int_add(json_af
, "orfType",
12033 json_prefA
= json_object_new_object();
12034 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12035 PEER_CAP_ORF_PREFIX_SM_ADV
,
12036 PEER_CAP_ORF_PREFIX_RM_ADV
,
12037 PEER_CAP_ORF_PREFIX_SM_RCV
,
12038 PEER_CAP_ORF_PREFIX_RM_RCV
,
12039 use_json
, json_prefA
);
12040 json_object_object_add(json_af
, "orfPrefixList",
12044 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12045 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12046 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12047 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12048 PEER_CAP_ORF_PREFIX_RM_ADV
)
12049 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12050 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12051 json_object_int_add(json_af
, "orfOldType",
12052 ORF_TYPE_PREFIX_OLD
);
12053 json_prefB
= json_object_new_object();
12054 bgp_show_peer_afi_orf_cap(
12055 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12056 PEER_CAP_ORF_PREFIX_RM_ADV
,
12057 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12058 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12060 json_object_object_add(json_af
, "orfOldPrefixList",
12064 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12065 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12066 PEER_CAP_ORF_PREFIX_SM_RCV
)
12067 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12068 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12069 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12070 PEER_CAP_ORF_PREFIX_RM_ADV
)
12071 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12072 PEER_CAP_ORF_PREFIX_RM_RCV
)
12073 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12074 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12075 json_object_object_add(json_addr
, "afDependentCap",
12078 json_object_free(json_af
);
12080 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12081 p
->host
, afi
, safi
);
12082 orf_pfx_count
= prefix_bgp_show_prefix_list(
12083 NULL
, afi
, orf_pfx_name
, use_json
);
12085 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12086 PEER_STATUS_ORF_PREFIX_SEND
)
12087 || orf_pfx_count
) {
12088 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12089 PEER_STATUS_ORF_PREFIX_SEND
))
12090 json_object_boolean_true_add(json_neigh
,
12093 json_object_int_add(json_addr
, "orfRecvCounter",
12096 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12097 PEER_STATUS_ORF_WAIT_REFRESH
))
12098 json_object_string_add(
12099 json_addr
, "orfFirstUpdate",
12100 "deferredUntilORFOrRouteRefreshRecvd");
12102 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12103 PEER_FLAG_REFLECTOR_CLIENT
))
12104 json_object_boolean_true_add(json_addr
,
12105 "routeReflectorClient");
12106 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12107 PEER_FLAG_RSERVER_CLIENT
))
12108 json_object_boolean_true_add(json_addr
,
12109 "routeServerClient");
12110 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12111 json_object_boolean_true_add(json_addr
,
12112 "inboundSoftConfigPermit");
12114 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12115 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12116 json_object_boolean_true_add(
12118 "privateAsNumsAllReplacedInUpdatesToNbr");
12119 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12120 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12121 json_object_boolean_true_add(
12123 "privateAsNumsReplacedInUpdatesToNbr");
12124 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12125 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12126 json_object_boolean_true_add(
12128 "privateAsNumsAllRemovedInUpdatesToNbr");
12129 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12130 PEER_FLAG_REMOVE_PRIVATE_AS
))
12131 json_object_boolean_true_add(
12133 "privateAsNumsRemovedInUpdatesToNbr");
12135 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12136 json_object_boolean_true_add(
12138 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12141 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12142 json_object_string_add(json_addr
,
12143 "overrideASNsInOutboundUpdates",
12144 "ifAspathEqualRemoteAs");
12146 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12147 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12148 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12149 json_object_boolean_true_add(json_addr
,
12150 "routerAlwaysNextHop");
12151 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12152 PEER_FLAG_AS_PATH_UNCHANGED
))
12153 json_object_boolean_true_add(
12154 json_addr
, "unchangedAsPathPropogatedToNbr");
12155 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12156 PEER_FLAG_NEXTHOP_UNCHANGED
))
12157 json_object_boolean_true_add(
12158 json_addr
, "unchangedNextHopPropogatedToNbr");
12159 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12160 json_object_boolean_true_add(
12161 json_addr
, "unchangedMedPropogatedToNbr");
12162 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12163 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12164 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12165 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12166 PEER_FLAG_SEND_COMMUNITY
)
12167 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12168 PEER_FLAG_SEND_EXT_COMMUNITY
))
12169 json_object_string_add(json_addr
,
12170 "commAttriSentToNbr",
12171 "extendedAndStandard");
12172 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12173 PEER_FLAG_SEND_EXT_COMMUNITY
))
12174 json_object_string_add(json_addr
,
12175 "commAttriSentToNbr",
12178 json_object_string_add(json_addr
,
12179 "commAttriSentToNbr",
12182 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12183 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12184 if (p
->default_rmap
[afi
][safi
].name
)
12185 json_object_string_add(
12186 json_addr
, "defaultRouteMap",
12187 p
->default_rmap
[afi
][safi
].name
);
12189 if (paf
&& PAF_SUBGRP(paf
)
12190 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12191 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12192 json_object_boolean_true_add(json_addr
,
12195 json_object_boolean_true_add(json_addr
,
12199 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12200 if (is_evpn_enabled())
12201 json_object_boolean_true_add(
12202 json_addr
, "advertiseAllVnis");
12205 if (filter
->plist
[FILTER_IN
].name
12206 || filter
->dlist
[FILTER_IN
].name
12207 || filter
->aslist
[FILTER_IN
].name
12208 || filter
->map
[RMAP_IN
].name
)
12209 json_object_boolean_true_add(json_addr
,
12210 "inboundPathPolicyConfig");
12211 if (filter
->plist
[FILTER_OUT
].name
12212 || filter
->dlist
[FILTER_OUT
].name
12213 || filter
->aslist
[FILTER_OUT
].name
12214 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12215 json_object_boolean_true_add(
12216 json_addr
, "outboundPathPolicyConfig");
12219 if (filter
->plist
[FILTER_IN
].name
)
12220 json_object_string_add(json_addr
,
12221 "incomingUpdatePrefixFilterList",
12222 filter
->plist
[FILTER_IN
].name
);
12223 if (filter
->plist
[FILTER_OUT
].name
)
12224 json_object_string_add(json_addr
,
12225 "outgoingUpdatePrefixFilterList",
12226 filter
->plist
[FILTER_OUT
].name
);
12228 /* distribute-list */
12229 if (filter
->dlist
[FILTER_IN
].name
)
12230 json_object_string_add(
12231 json_addr
, "incomingUpdateNetworkFilterList",
12232 filter
->dlist
[FILTER_IN
].name
);
12233 if (filter
->dlist
[FILTER_OUT
].name
)
12234 json_object_string_add(
12235 json_addr
, "outgoingUpdateNetworkFilterList",
12236 filter
->dlist
[FILTER_OUT
].name
);
12239 if (filter
->aslist
[FILTER_IN
].name
)
12240 json_object_string_add(json_addr
,
12241 "incomingUpdateAsPathFilterList",
12242 filter
->aslist
[FILTER_IN
].name
);
12243 if (filter
->aslist
[FILTER_OUT
].name
)
12244 json_object_string_add(json_addr
,
12245 "outgoingUpdateAsPathFilterList",
12246 filter
->aslist
[FILTER_OUT
].name
);
12249 if (filter
->map
[RMAP_IN
].name
)
12250 json_object_string_add(
12251 json_addr
, "routeMapForIncomingAdvertisements",
12252 filter
->map
[RMAP_IN
].name
);
12253 if (filter
->map
[RMAP_OUT
].name
)
12254 json_object_string_add(
12255 json_addr
, "routeMapForOutgoingAdvertisements",
12256 filter
->map
[RMAP_OUT
].name
);
12258 /* ebgp-requires-policy (inbound) */
12259 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12260 && !bgp_inbound_policy_exists(p
, filter
))
12261 json_object_string_add(
12262 json_addr
, "inboundEbgpRequiresPolicy",
12263 "Inbound updates discarded due to missing policy");
12265 /* ebgp-requires-policy (outbound) */
12266 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12267 && (!bgp_outbound_policy_exists(p
, filter
)))
12268 json_object_string_add(
12269 json_addr
, "outboundEbgpRequiresPolicy",
12270 "Outbound updates discarded due to missing policy");
12272 /* unsuppress-map */
12273 if (filter
->usmap
.name
)
12274 json_object_string_add(json_addr
,
12275 "selectiveUnsuppressRouteMap",
12276 filter
->usmap
.name
);
12278 /* advertise-map */
12279 if (filter
->advmap
.aname
) {
12280 json_advmap
= json_object_new_object();
12281 json_object_string_add(json_advmap
, "condition",
12282 filter
->advmap
.condition
12285 json_object_string_add(json_advmap
, "conditionMap",
12286 filter
->advmap
.cname
);
12287 json_object_string_add(json_advmap
, "advertiseMap",
12288 filter
->advmap
.aname
);
12289 json_object_string_add(
12290 json_advmap
, "advertiseStatus",
12291 filter
->advmap
.update_type
==
12292 UPDATE_TYPE_ADVERTISE
12295 json_object_object_add(json_addr
, "advertiseMap",
12299 /* Receive prefix count */
12300 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12301 p
->pcount
[afi
][safi
]);
12302 if (paf
&& PAF_SUBGRP(paf
))
12303 json_object_int_add(json_addr
, "sentPrefixCounter",
12304 (PAF_SUBGRP(paf
))->scount
);
12306 /* Maximum prefix */
12307 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12308 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12309 p
->pmax_out
[afi
][safi
]);
12311 /* Maximum prefix */
12312 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12313 json_object_int_add(json_addr
, "prefixAllowedMax",
12314 p
->pmax
[afi
][safi
]);
12315 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12316 PEER_FLAG_MAX_PREFIX_WARNING
))
12317 json_object_boolean_true_add(
12318 json_addr
, "prefixAllowedMaxWarning");
12319 json_object_int_add(json_addr
,
12320 "prefixAllowedWarningThresh",
12321 p
->pmax_threshold
[afi
][safi
]);
12322 if (p
->pmax_restart
[afi
][safi
])
12323 json_object_int_add(
12325 "prefixAllowedRestartIntervalMsecs",
12326 p
->pmax_restart
[afi
][safi
] * 60000);
12328 json_object_object_add(json_neigh
,
12329 get_afi_safi_str(afi
, safi
, true),
12333 filter
= &p
->filter
[afi
][safi
];
12335 vty_out(vty
, " For address family: %s\n",
12336 get_afi_safi_str(afi
, safi
, false));
12338 if (peer_group_active(p
))
12339 vty_out(vty
, " %s peer-group member\n",
12342 paf
= peer_af_find(p
, afi
, safi
);
12343 if (paf
&& PAF_SUBGRP(paf
)) {
12344 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12345 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12346 vty_out(vty
, " Packet Queue length %d\n",
12347 bpacket_queue_virtual_length(paf
));
12349 vty_out(vty
, " Not part of any update group\n");
12351 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12352 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12353 PEER_CAP_ORF_PREFIX_SM_RCV
)
12354 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12355 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12356 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12357 PEER_CAP_ORF_PREFIX_RM_ADV
)
12358 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12359 PEER_CAP_ORF_PREFIX_RM_RCV
)
12360 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12361 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12362 vty_out(vty
, " AF-dependant capabilities:\n");
12364 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12365 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12366 PEER_CAP_ORF_PREFIX_SM_RCV
)
12367 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12368 PEER_CAP_ORF_PREFIX_RM_ADV
)
12369 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12370 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12372 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12374 bgp_show_peer_afi_orf_cap(
12375 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12376 PEER_CAP_ORF_PREFIX_RM_ADV
,
12377 PEER_CAP_ORF_PREFIX_SM_RCV
,
12378 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12380 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12381 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12382 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12383 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12384 PEER_CAP_ORF_PREFIX_RM_ADV
)
12385 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12386 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12388 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12389 ORF_TYPE_PREFIX_OLD
);
12390 bgp_show_peer_afi_orf_cap(
12391 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12392 PEER_CAP_ORF_PREFIX_RM_ADV
,
12393 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12394 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12397 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12398 p
->host
, afi
, safi
);
12399 orf_pfx_count
= prefix_bgp_show_prefix_list(
12400 NULL
, afi
, orf_pfx_name
, use_json
);
12402 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12403 PEER_STATUS_ORF_PREFIX_SEND
)
12404 || orf_pfx_count
) {
12405 vty_out(vty
, " Outbound Route Filter (ORF):");
12406 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12407 PEER_STATUS_ORF_PREFIX_SEND
))
12408 vty_out(vty
, " sent;");
12410 vty_out(vty
, " received (%d entries)",
12412 vty_out(vty
, "\n");
12414 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12415 PEER_STATUS_ORF_WAIT_REFRESH
))
12417 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12419 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12420 PEER_FLAG_REFLECTOR_CLIENT
))
12421 vty_out(vty
, " Route-Reflector Client\n");
12422 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_RSERVER_CLIENT
))
12424 vty_out(vty
, " Route-Server Client\n");
12426 if (peer_af_flag_check(p
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
12427 vty_out(vty
, " ORR group (configured) : %s\n",
12428 p
->orr_group_name
[afi
][safi
]);
12430 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12432 " Inbound soft reconfiguration allowed\n");
12434 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12435 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12437 " Private AS numbers (all) replaced in updates to this neighbor\n");
12438 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12439 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12441 " Private AS numbers replaced in updates to this neighbor\n");
12442 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12443 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12445 " Private AS numbers (all) removed in updates to this neighbor\n");
12446 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12447 PEER_FLAG_REMOVE_PRIVATE_AS
))
12449 " Private AS numbers removed in updates to this neighbor\n");
12451 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12452 vty_out(vty
, " %s\n",
12453 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12454 ->human_description
);
12456 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12458 " Override ASNs in outbound updates if aspath equals remote-as\n");
12460 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12461 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12462 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12463 vty_out(vty
, " NEXT_HOP is always this router\n");
12464 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12465 PEER_FLAG_AS_PATH_UNCHANGED
))
12467 " AS_PATH is propagated unchanged to this neighbor\n");
12468 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12469 PEER_FLAG_NEXTHOP_UNCHANGED
))
12471 " NEXT_HOP is propagated unchanged to this neighbor\n");
12472 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12474 " MED is propagated unchanged to this neighbor\n");
12475 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12476 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12477 PEER_FLAG_SEND_EXT_COMMUNITY
)
12478 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12479 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12481 " Community attribute sent to this neighbor");
12482 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12483 PEER_FLAG_SEND_COMMUNITY
)
12484 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12485 PEER_FLAG_SEND_EXT_COMMUNITY
)
12486 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12487 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12488 vty_out(vty
, "(all)\n");
12489 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12490 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12491 vty_out(vty
, "(large)\n");
12492 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12493 PEER_FLAG_SEND_EXT_COMMUNITY
))
12494 vty_out(vty
, "(extended)\n");
12496 vty_out(vty
, "(standard)\n");
12498 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12499 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12500 vty_out(vty
, " Default information originate,");
12502 if (p
->default_rmap
[afi
][safi
].name
)
12503 vty_out(vty
, " default route-map %s%s,",
12504 p
->default_rmap
[afi
][safi
].map
? "*"
12506 p
->default_rmap
[afi
][safi
].name
);
12507 if (paf
&& PAF_SUBGRP(paf
)
12508 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12509 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12510 vty_out(vty
, " default sent\n");
12512 vty_out(vty
, " default not sent\n");
12515 /* advertise-vni-all */
12516 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12517 if (is_evpn_enabled())
12518 vty_out(vty
, " advertise-all-vni\n");
12521 if (filter
->plist
[FILTER_IN
].name
12522 || filter
->dlist
[FILTER_IN
].name
12523 || filter
->aslist
[FILTER_IN
].name
12524 || filter
->map
[RMAP_IN
].name
)
12525 vty_out(vty
, " Inbound path policy configured\n");
12526 if (filter
->plist
[FILTER_OUT
].name
12527 || filter
->dlist
[FILTER_OUT
].name
12528 || filter
->aslist
[FILTER_OUT
].name
12529 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12530 vty_out(vty
, " Outbound path policy configured\n");
12533 if (filter
->plist
[FILTER_IN
].name
)
12535 " Incoming update prefix filter list is %s%s\n",
12536 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12537 filter
->plist
[FILTER_IN
].name
);
12538 if (filter
->plist
[FILTER_OUT
].name
)
12540 " Outgoing update prefix filter list is %s%s\n",
12541 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12542 filter
->plist
[FILTER_OUT
].name
);
12544 /* distribute-list */
12545 if (filter
->dlist
[FILTER_IN
].name
)
12547 " Incoming update network filter list is %s%s\n",
12548 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12549 filter
->dlist
[FILTER_IN
].name
);
12550 if (filter
->dlist
[FILTER_OUT
].name
)
12552 " Outgoing update network filter list is %s%s\n",
12553 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12554 filter
->dlist
[FILTER_OUT
].name
);
12557 if (filter
->aslist
[FILTER_IN
].name
)
12559 " Incoming update AS path filter list is %s%s\n",
12560 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12561 filter
->aslist
[FILTER_IN
].name
);
12562 if (filter
->aslist
[FILTER_OUT
].name
)
12564 " Outgoing update AS path filter list is %s%s\n",
12565 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12566 filter
->aslist
[FILTER_OUT
].name
);
12569 if (filter
->map
[RMAP_IN
].name
)
12571 " Route map for incoming advertisements is %s%s\n",
12572 filter
->map
[RMAP_IN
].map
? "*" : "",
12573 filter
->map
[RMAP_IN
].name
);
12574 if (filter
->map
[RMAP_OUT
].name
)
12576 " Route map for outgoing advertisements is %s%s\n",
12577 filter
->map
[RMAP_OUT
].map
? "*" : "",
12578 filter
->map
[RMAP_OUT
].name
);
12580 /* ebgp-requires-policy (inbound) */
12581 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12582 && !bgp_inbound_policy_exists(p
, filter
))
12584 " Inbound updates discarded due to missing policy\n");
12586 /* ebgp-requires-policy (outbound) */
12587 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12588 && !bgp_outbound_policy_exists(p
, filter
))
12590 " Outbound updates discarded due to missing policy\n");
12592 /* unsuppress-map */
12593 if (filter
->usmap
.name
)
12595 " Route map for selective unsuppress is %s%s\n",
12596 filter
->usmap
.map
? "*" : "",
12597 filter
->usmap
.name
);
12599 /* advertise-map */
12600 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12602 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12603 filter
->advmap
.condition
? "EXIST"
12605 filter
->advmap
.cmap
? "*" : "",
12606 filter
->advmap
.cname
,
12607 filter
->advmap
.amap
? "*" : "",
12608 filter
->advmap
.aname
,
12609 filter
->advmap
.update_type
==
12610 UPDATE_TYPE_ADVERTISE
12614 /* Receive prefix count */
12615 vty_out(vty
, " %u accepted prefixes\n",
12616 p
->pcount
[afi
][safi
]);
12618 /* maximum-prefix-out */
12619 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12620 PEER_FLAG_MAX_PREFIX_OUT
))
12622 " Maximum allowed prefixes sent %u\n",
12623 p
->pmax_out
[afi
][safi
]);
12625 /* Maximum prefix */
12626 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12628 " Maximum prefixes allowed %u%s\n",
12629 p
->pmax
[afi
][safi
],
12630 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12631 PEER_FLAG_MAX_PREFIX_WARNING
)
12632 ? " (warning-only)"
12634 vty_out(vty
, " Threshold for warning message %d%%",
12635 p
->pmax_threshold
[afi
][safi
]);
12636 if (p
->pmax_restart
[afi
][safi
])
12637 vty_out(vty
, ", restart interval %d min",
12638 p
->pmax_restart
[afi
][safi
]);
12639 vty_out(vty
, "\n");
12642 vty_out(vty
, "\n");
12646 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12650 char buf1
[PREFIX2STR_BUFFER
];
12651 char timebuf
[BGP_UPTIME_LEN
];
12657 json_object
*json_neigh
= NULL
;
12659 uint32_t sync_tcp_mss
;
12664 json_neigh
= json_object_new_object();
12666 memset(dn_flag
, '\0', sizeof(dn_flag
));
12667 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12671 if (p
->conf_if
) /* Configured interface name. */
12672 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12674 else /* Configured IP address. */
12675 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12680 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12681 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12683 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12684 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12687 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12689 if (p
->change_local_as
)
12690 json_object_int_add(json_neigh
, "localAs",
12691 p
->change_local_as
);
12693 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12695 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12696 json_object_boolean_true_add(json_neigh
,
12697 "localAsNoPrepend");
12699 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12700 json_object_boolean_true_add(json_neigh
,
12701 "localAsReplaceAs");
12703 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12704 || (p
->as_type
== AS_INTERNAL
))
12705 vty_out(vty
, "remote AS %u, ", p
->as
);
12707 vty_out(vty
, "remote AS Unspecified, ");
12708 vty_out(vty
, "local AS %u%s%s, ",
12709 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12710 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12713 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12717 /* peer type internal or confed-internal */
12718 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12720 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12721 json_object_boolean_true_add(
12722 json_neigh
, "nbrConfedInternalLink");
12724 json_object_boolean_true_add(json_neigh
,
12725 "nbrInternalLink");
12727 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12728 vty_out(vty
, "confed-internal link\n");
12730 vty_out(vty
, "internal link\n");
12732 /* peer type external or confed-external */
12733 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12735 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12736 json_object_boolean_true_add(
12737 json_neigh
, "nbrConfedExternalLink");
12739 json_object_boolean_true_add(json_neigh
,
12740 "nbrExternalLink");
12742 if (bgp_confederation_peers_check(bgp
, p
->as
))
12743 vty_out(vty
, "confed-external link\n");
12745 vty_out(vty
, "external link\n");
12749 json_object_boolean_true_add(json_neigh
,
12750 "nbrUnspecifiedLink");
12752 vty_out(vty
, "unspecified link\n");
12757 json_object_string_add(json_neigh
, "localRole",
12758 bgp_get_name_by_role(p
->local_role
));
12759 json_object_string_add(json_neigh
, "remoteRole",
12760 bgp_get_name_by_role(p
->remote_role
));
12762 vty_out(vty
, " Local Role: %s\n",
12763 bgp_get_name_by_role(p
->local_role
));
12764 vty_out(vty
, " Remote Role: %s\n",
12765 bgp_get_name_by_role(p
->remote_role
));
12772 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12774 vty_out(vty
, " Description: %s\n", p
->desc
);
12780 json_object_string_add(json_neigh
, "hostname",
12784 json_object_string_add(json_neigh
, "domainname",
12787 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12788 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12791 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12798 json_object_string_add(json_neigh
, "peerGroup",
12802 struct prefix prefix
, *range
= NULL
;
12804 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12805 range
= peer_group_lookup_dynamic_neighbor_range(
12806 p
->group
, &prefix
);
12809 json_object_string_addf(
12811 "peerSubnetRangeGroup", "%pFX",
12817 " Member of peer-group %s for session parameters\n",
12821 struct prefix prefix
, *range
= NULL
;
12823 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12824 range
= peer_group_lookup_dynamic_neighbor_range(
12825 p
->group
, &prefix
);
12829 " Belongs to the subnet range group: %pFX\n",
12837 /* Administrative shutdown. */
12838 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12839 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12840 json_object_boolean_true_add(json_neigh
,
12844 json_object_int_add(json_neigh
, "bgpVersion", 4);
12845 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12847 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12850 /* Confederation */
12851 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12852 && bgp_confederation_peers_check(bgp
, p
->as
))
12853 json_object_boolean_true_add(json_neigh
,
12857 json_object_string_add(
12858 json_neigh
, "bgpState",
12859 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12861 if (peer_established(p
)) {
12864 uptime
= monotime(NULL
);
12865 uptime
-= p
->uptime
;
12866 epoch_tbuf
= time(NULL
) - uptime
;
12868 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12870 json_object_string_add(json_neigh
, "bgpTimerUpString",
12871 peer_uptime(p
->uptime
, timebuf
,
12874 json_object_int_add(json_neigh
,
12875 "bgpTimerUpEstablishedEpoch",
12879 else if (p
->status
== Active
) {
12880 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12881 json_object_string_add(json_neigh
, "bgpStateIs",
12883 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12884 json_object_string_add(json_neigh
, "bgpStateIs",
12892 uptime
= monotime(NULL
);
12893 uptime
-= p
->readtime
;
12894 gmtime_r(&uptime
, &tm
);
12896 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12897 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12898 + (tm
.tm_hour
* 3600000));
12900 uptime
= monotime(NULL
);
12901 uptime
-= p
->last_write
;
12902 gmtime_r(&uptime
, &tm
);
12904 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12905 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12906 + (tm
.tm_hour
* 3600000));
12908 uptime
= monotime(NULL
);
12909 uptime
-= p
->update_time
;
12910 gmtime_r(&uptime
, &tm
);
12912 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12913 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12914 + (tm
.tm_hour
* 3600000));
12916 /* Configured timer values. */
12917 json_object_int_add(json_neigh
,
12918 "bgpTimerConfiguredHoldTimeMsecs",
12919 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12920 ? p
->holdtime
* 1000
12921 : bgp
->default_holdtime
* 1000);
12922 json_object_int_add(json_neigh
,
12923 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12924 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12925 ? p
->keepalive
* 1000
12926 : bgp
->default_keepalive
* 1000);
12927 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12928 p
->v_holdtime
* 1000);
12929 json_object_int_add(json_neigh
,
12930 "bgpTimerKeepAliveIntervalMsecs",
12931 p
->v_keepalive
* 1000);
12932 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12933 json_object_int_add(json_neigh
,
12934 "bgpTimerDelayOpenTimeMsecs",
12935 p
->v_delayopen
* 1000);
12938 /* Configured and Synced tcp-mss value for peer */
12939 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12940 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12941 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12943 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12947 /* Extended Optional Parameters Length for BGP OPEN Message */
12948 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12949 json_object_boolean_true_add(
12950 json_neigh
, "extendedOptionalParametersLength");
12952 json_object_boolean_false_add(
12953 json_neigh
, "extendedOptionalParametersLength");
12955 /* Conditional advertisements */
12956 json_object_int_add(
12958 "bgpTimerConfiguredConditionalAdvertisementsSec",
12959 bgp
->condition_check_period
);
12960 if (thread_is_scheduled(bgp
->t_condition_check
))
12961 json_object_int_add(
12963 "bgpTimerUntilConditionalAdvertisementsSec",
12964 thread_timer_remain_second(
12965 bgp
->t_condition_check
));
12967 /* Administrative shutdown. */
12968 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12969 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12970 vty_out(vty
, " Administratively shut down\n");
12973 vty_out(vty
, " BGP version 4");
12974 vty_out(vty
, ", remote router ID %s",
12975 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12976 vty_out(vty
, ", local router ID %s\n",
12977 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12980 /* Confederation */
12981 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12982 && bgp_confederation_peers_check(bgp
, p
->as
))
12984 " Neighbor under common administration\n");
12987 vty_out(vty
, " BGP state = %s",
12988 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12990 if (peer_established(p
))
12991 vty_out(vty
, ", up for %8s",
12992 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12995 else if (p
->status
== Active
) {
12996 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12997 vty_out(vty
, " (passive)");
12998 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12999 vty_out(vty
, " (NSF passive)");
13001 vty_out(vty
, "\n");
13004 vty_out(vty
, " Last read %s",
13005 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13007 vty_out(vty
, ", Last write %s\n",
13008 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13011 /* Configured timer values. */
13013 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13014 p
->v_holdtime
, p
->v_keepalive
);
13015 vty_out(vty
, " Configured hold time is %d seconds",
13016 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13018 : bgp
->default_holdtime
);
13019 vty_out(vty
, ", keepalive interval is %d seconds\n",
13020 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13022 : bgp
->default_keepalive
);
13023 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13025 " Configured DelayOpenTime is %d seconds\n",
13028 /* Configured and synced tcp-mss value for peer */
13029 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13030 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13031 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13032 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13035 /* Extended Optional Parameters Length for BGP OPEN Message */
13036 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13038 " Extended Optional Parameters Length is enabled\n");
13040 /* Conditional advertisements */
13042 " Configured conditional advertisements interval is %d seconds\n",
13043 bgp
->condition_check_period
);
13044 if (thread_is_scheduled(bgp
->t_condition_check
))
13046 " Time until conditional advertisements begin is %lu seconds\n",
13047 thread_timer_remain_second(
13048 bgp
->t_condition_check
));
13051 if (peer_established(p
) &&
13052 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13054 json_object
*json_cap
= NULL
;
13056 json_cap
= json_object_new_object();
13059 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13060 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13061 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13062 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13063 json_object_string_add(
13064 json_cap
, "4byteAs",
13065 "advertisedAndReceived");
13066 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13067 json_object_string_add(json_cap
,
13070 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13071 json_object_string_add(json_cap
,
13076 /* Extended Message Support */
13077 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13078 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13079 json_object_string_add(json_cap
,
13081 "advertisedAndReceived");
13082 else if (CHECK_FLAG(p
->cap
,
13083 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13084 json_object_string_add(json_cap
,
13087 else if (CHECK_FLAG(p
->cap
,
13088 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13089 json_object_string_add(json_cap
,
13094 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13095 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13096 json_object
*json_add
= NULL
;
13097 const char *print_store
;
13099 json_add
= json_object_new_object();
13101 FOREACH_AFI_SAFI (afi
, safi
) {
13102 json_object
*json_sub
= NULL
;
13103 json_sub
= json_object_new_object();
13104 print_store
= get_afi_safi_str(
13108 p
->af_cap
[afi
][safi
],
13109 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13111 p
->af_cap
[afi
][safi
],
13112 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13116 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13120 PEER_CAP_ADDPATH_AF_TX_RCV
))
13121 json_object_boolean_true_add(
13123 "txAdvertisedAndReceived");
13128 PEER_CAP_ADDPATH_AF_TX_ADV
))
13129 json_object_boolean_true_add(
13136 PEER_CAP_ADDPATH_AF_TX_RCV
))
13137 json_object_boolean_true_add(
13143 p
->af_cap
[afi
][safi
],
13144 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13146 p
->af_cap
[afi
][safi
],
13147 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13151 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13155 PEER_CAP_ADDPATH_AF_RX_RCV
))
13156 json_object_boolean_true_add(
13158 "rxAdvertisedAndReceived");
13163 PEER_CAP_ADDPATH_AF_RX_ADV
))
13164 json_object_boolean_true_add(
13171 PEER_CAP_ADDPATH_AF_RX_RCV
))
13172 json_object_boolean_true_add(
13178 p
->af_cap
[afi
][safi
],
13179 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13181 p
->af_cap
[afi
][safi
],
13182 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13184 p
->af_cap
[afi
][safi
],
13185 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13187 p
->af_cap
[afi
][safi
],
13188 PEER_CAP_ADDPATH_AF_RX_RCV
))
13189 json_object_object_add(
13190 json_add
, print_store
,
13193 json_object_free(json_sub
);
13196 json_object_object_add(json_cap
, "addPath",
13201 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13202 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13203 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13204 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13205 json_object_string_add(
13206 json_cap
, "dynamic",
13207 "advertisedAndReceived");
13208 else if (CHECK_FLAG(p
->cap
,
13209 PEER_CAP_DYNAMIC_ADV
))
13210 json_object_string_add(json_cap
,
13213 else if (CHECK_FLAG(p
->cap
,
13214 PEER_CAP_DYNAMIC_RCV
))
13215 json_object_string_add(json_cap
,
13221 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13222 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13223 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13224 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13225 json_object_string_add(
13227 "advertisedAndReceived");
13228 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13229 json_object_string_add(json_cap
, "role",
13231 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13232 json_object_string_add(json_cap
, "role",
13236 /* Extended nexthop */
13237 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13238 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13239 json_object
*json_nxt
= NULL
;
13240 const char *print_store
;
13243 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13244 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13245 json_object_string_add(
13246 json_cap
, "extendedNexthop",
13247 "advertisedAndReceived");
13248 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13249 json_object_string_add(
13250 json_cap
, "extendedNexthop",
13252 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13253 json_object_string_add(
13254 json_cap
, "extendedNexthop",
13257 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13258 json_nxt
= json_object_new_object();
13260 for (safi
= SAFI_UNICAST
;
13261 safi
< SAFI_MAX
; safi
++) {
13265 PEER_CAP_ENHE_AF_RCV
)) {
13271 json_object_string_add(
13274 "recieved"); /* misspelled for compatibility */
13277 json_object_object_add(
13279 "extendedNexthopFamililesByPeer",
13284 /* Long-lived Graceful Restart */
13285 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13286 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13287 json_object
*json_llgr
= NULL
;
13288 const char *afi_safi_str
;
13290 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13291 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13292 json_object_string_add(
13294 "longLivedGracefulRestart",
13295 "advertisedAndReceived");
13296 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13297 json_object_string_add(
13299 "longLivedGracefulRestart",
13301 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13302 json_object_string_add(
13304 "longLivedGracefulRestart",
13307 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13308 json_llgr
= json_object_new_object();
13310 FOREACH_AFI_SAFI (afi
, safi
) {
13314 PEER_CAP_ENHE_AF_RCV
)) {
13320 json_object_string_add(
13326 json_object_object_add(
13328 "longLivedGracefulRestartByPeer",
13333 /* Route Refresh */
13334 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13335 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13336 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13337 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13338 (CHECK_FLAG(p
->cap
,
13339 PEER_CAP_REFRESH_NEW_RCV
) ||
13341 PEER_CAP_REFRESH_OLD_RCV
))) {
13344 PEER_CAP_REFRESH_OLD_RCV
) &&
13347 PEER_CAP_REFRESH_NEW_RCV
))
13348 json_object_string_add(
13351 "advertisedAndReceivedOldNew");
13355 PEER_CAP_REFRESH_OLD_RCV
))
13356 json_object_string_add(
13359 "advertisedAndReceivedOld");
13361 json_object_string_add(
13364 "advertisedAndReceivedNew");
13366 } else if (CHECK_FLAG(p
->cap
,
13367 PEER_CAP_REFRESH_ADV
))
13368 json_object_string_add(json_cap
,
13371 else if (CHECK_FLAG(p
->cap
,
13372 PEER_CAP_REFRESH_NEW_RCV
) ||
13374 PEER_CAP_REFRESH_OLD_RCV
))
13375 json_object_string_add(json_cap
,
13380 /* Enhanced Route Refresh */
13381 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13382 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13383 if (CHECK_FLAG(p
->cap
,
13384 PEER_CAP_ENHANCED_RR_ADV
) &&
13386 PEER_CAP_ENHANCED_RR_RCV
))
13387 json_object_string_add(
13389 "enhancedRouteRefresh",
13390 "advertisedAndReceived");
13391 else if (CHECK_FLAG(p
->cap
,
13392 PEER_CAP_ENHANCED_RR_ADV
))
13393 json_object_string_add(
13395 "enhancedRouteRefresh",
13397 else if (CHECK_FLAG(p
->cap
,
13398 PEER_CAP_ENHANCED_RR_RCV
))
13399 json_object_string_add(
13401 "enhancedRouteRefresh",
13405 /* Multiprotocol Extensions */
13406 json_object
*json_multi
= NULL
;
13408 json_multi
= json_object_new_object();
13410 FOREACH_AFI_SAFI (afi
, safi
) {
13411 if (p
->afc_adv
[afi
][safi
] ||
13412 p
->afc_recv
[afi
][safi
]) {
13413 json_object
*json_exten
= NULL
;
13414 json_exten
= json_object_new_object();
13416 if (p
->afc_adv
[afi
][safi
] &&
13417 p
->afc_recv
[afi
][safi
])
13418 json_object_boolean_true_add(
13420 "advertisedAndReceived");
13421 else if (p
->afc_adv
[afi
][safi
])
13422 json_object_boolean_true_add(
13425 else if (p
->afc_recv
[afi
][safi
])
13426 json_object_boolean_true_add(
13427 json_exten
, "received");
13429 json_object_object_add(
13431 get_afi_safi_str(afi
, safi
,
13436 json_object_object_add(json_cap
,
13437 "multiprotocolExtensions",
13440 /* Hostname capabilities */
13441 json_object
*json_hname
= NULL
;
13443 json_hname
= json_object_new_object();
13445 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13446 json_object_string_add(
13447 json_hname
, "advHostName",
13448 bgp
->peer_self
->hostname
13449 ? bgp
->peer_self
->hostname
13451 json_object_string_add(
13452 json_hname
, "advDomainName",
13453 bgp
->peer_self
->domainname
13454 ? bgp
->peer_self
->domainname
13459 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13460 json_object_string_add(
13461 json_hname
, "rcvHostName",
13462 p
->hostname
? p
->hostname
: "n/a");
13463 json_object_string_add(
13464 json_hname
, "rcvDomainName",
13465 p
->domainname
? p
->domainname
: "n/a");
13468 json_object_object_add(json_cap
, "hostName",
13471 /* Graceful Restart */
13472 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13473 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13474 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13475 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13476 json_object_string_add(
13477 json_cap
, "gracefulRestart",
13478 "advertisedAndReceived");
13479 else if (CHECK_FLAG(p
->cap
,
13480 PEER_CAP_RESTART_ADV
))
13481 json_object_string_add(
13483 "gracefulRestartCapability",
13485 else if (CHECK_FLAG(p
->cap
,
13486 PEER_CAP_RESTART_RCV
))
13487 json_object_string_add(
13489 "gracefulRestartCapability",
13492 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13493 int restart_af_count
= 0;
13494 json_object
*json_restart
= NULL
;
13495 json_restart
= json_object_new_object();
13497 json_object_int_add(
13499 "gracefulRestartRemoteTimerMsecs",
13500 p
->v_gr_restart
* 1000);
13502 FOREACH_AFI_SAFI (afi
, safi
) {
13506 PEER_CAP_RESTART_AF_RCV
)) {
13507 json_object
*json_sub
=
13510 json_object_new_object();
13516 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13517 json_object_boolean_true_add(
13520 restart_af_count
++;
13521 json_object_object_add(
13530 if (!restart_af_count
) {
13531 json_object_string_add(
13533 "addressFamiliesByPeer",
13535 json_object_free(json_restart
);
13537 json_object_object_add(
13539 "addressFamiliesByPeer",
13543 json_object_object_add(
13544 json_neigh
, "neighborCapabilities", json_cap
);
13546 vty_out(vty
, " Neighbor capabilities:\n");
13549 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13550 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13551 vty_out(vty
, " 4 Byte AS:");
13552 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13553 vty_out(vty
, " advertised");
13554 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13555 vty_out(vty
, " %sreceived",
13560 vty_out(vty
, "\n");
13563 /* Extended Message Support */
13564 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13565 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13566 vty_out(vty
, " Extended Message:");
13567 if (CHECK_FLAG(p
->cap
,
13568 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13569 vty_out(vty
, " advertised");
13570 if (CHECK_FLAG(p
->cap
,
13571 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13572 vty_out(vty
, " %sreceived",
13575 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13578 vty_out(vty
, "\n");
13582 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13583 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13584 vty_out(vty
, " AddPath:\n");
13586 FOREACH_AFI_SAFI (afi
, safi
) {
13588 p
->af_cap
[afi
][safi
],
13589 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13591 p
->af_cap
[afi
][safi
],
13592 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13593 vty_out(vty
, " %s: TX ",
13601 PEER_CAP_ADDPATH_AF_TX_ADV
))
13608 PEER_CAP_ADDPATH_AF_TX_RCV
))
13615 PEER_CAP_ADDPATH_AF_TX_ADV
)
13619 vty_out(vty
, "\n");
13623 p
->af_cap
[afi
][safi
],
13624 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13626 p
->af_cap
[afi
][safi
],
13627 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13628 vty_out(vty
, " %s: RX ",
13636 PEER_CAP_ADDPATH_AF_RX_ADV
))
13643 PEER_CAP_ADDPATH_AF_RX_RCV
))
13650 PEER_CAP_ADDPATH_AF_RX_ADV
)
13654 vty_out(vty
, "\n");
13660 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13661 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13662 vty_out(vty
, " Dynamic:");
13663 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13664 vty_out(vty
, " advertised");
13665 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13666 vty_out(vty
, " %sreceived",
13668 PEER_CAP_DYNAMIC_ADV
)
13671 vty_out(vty
, "\n");
13675 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13676 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13677 vty_out(vty
, " Role:");
13678 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13679 vty_out(vty
, " advertised");
13680 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13681 vty_out(vty
, " %sreceived",
13686 vty_out(vty
, "\n");
13689 /* Extended nexthop */
13690 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13691 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13692 vty_out(vty
, " Extended nexthop:");
13693 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13694 vty_out(vty
, " advertised");
13695 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13696 vty_out(vty
, " %sreceived",
13701 vty_out(vty
, "\n");
13703 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13705 " Address families by peer:\n ");
13706 for (safi
= SAFI_UNICAST
;
13707 safi
< SAFI_MAX
; safi
++)
13711 PEER_CAP_ENHE_AF_RCV
))
13721 /* Long-lived Graceful Restart */
13722 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13723 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13725 " Long-lived Graceful Restart:");
13726 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13727 vty_out(vty
, " advertised");
13728 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13729 vty_out(vty
, " %sreceived",
13734 vty_out(vty
, "\n");
13736 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13738 " Address families by peer:\n");
13739 FOREACH_AFI_SAFI (afi
, safi
)
13743 PEER_CAP_LLGR_AF_RCV
))
13753 /* Route Refresh */
13754 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13755 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13756 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13757 vty_out(vty
, " Route refresh:");
13758 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13759 vty_out(vty
, " advertised");
13760 if (CHECK_FLAG(p
->cap
,
13761 PEER_CAP_REFRESH_NEW_RCV
) ||
13763 PEER_CAP_REFRESH_OLD_RCV
))
13764 vty_out(vty
, " %sreceived(%s)",
13766 PEER_CAP_REFRESH_ADV
)
13771 PEER_CAP_REFRESH_OLD_RCV
) &&
13774 PEER_CAP_REFRESH_NEW_RCV
))
13778 PEER_CAP_REFRESH_OLD_RCV
)
13782 vty_out(vty
, "\n");
13785 /* Enhanced Route Refresh */
13786 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13787 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13788 vty_out(vty
, " Enhanced Route Refresh:");
13789 if (CHECK_FLAG(p
->cap
,
13790 PEER_CAP_ENHANCED_RR_ADV
))
13791 vty_out(vty
, " advertised");
13792 if (CHECK_FLAG(p
->cap
,
13793 PEER_CAP_ENHANCED_RR_RCV
))
13794 vty_out(vty
, " %sreceived",
13796 PEER_CAP_REFRESH_ADV
)
13799 vty_out(vty
, "\n");
13802 /* Multiprotocol Extensions */
13803 FOREACH_AFI_SAFI (afi
, safi
)
13804 if (p
->afc_adv
[afi
][safi
] ||
13805 p
->afc_recv
[afi
][safi
]) {
13806 vty_out(vty
, " Address Family %s:",
13807 get_afi_safi_str(afi
, safi
,
13809 if (p
->afc_adv
[afi
][safi
])
13810 vty_out(vty
, " advertised");
13811 if (p
->afc_recv
[afi
][safi
])
13812 vty_out(vty
, " %sreceived",
13813 p
->afc_adv
[afi
][safi
]
13816 vty_out(vty
, "\n");
13819 /* Hostname capability */
13820 vty_out(vty
, " Hostname Capability:");
13822 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13824 " advertised (name: %s,domain name: %s)",
13825 bgp
->peer_self
->hostname
13826 ? bgp
->peer_self
->hostname
13828 bgp
->peer_self
->domainname
13829 ? bgp
->peer_self
->domainname
13832 vty_out(vty
, " not advertised");
13835 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13837 " received (name: %s,domain name: %s)",
13838 p
->hostname
? p
->hostname
: "n/a",
13839 p
->domainname
? p
->domainname
: "n/a");
13841 vty_out(vty
, " not received");
13844 vty_out(vty
, "\n");
13846 /* Graceful Restart */
13847 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13848 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13850 " Graceful Restart Capability:");
13851 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13852 vty_out(vty
, " advertised");
13853 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13854 vty_out(vty
, " %sreceived",
13856 PEER_CAP_RESTART_ADV
)
13859 vty_out(vty
, "\n");
13861 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13862 int restart_af_count
= 0;
13865 " Remote Restart timer is %d seconds\n",
13868 " Address families by peer:\n ");
13870 FOREACH_AFI_SAFI (afi
, safi
)
13874 PEER_CAP_RESTART_AF_RCV
)) {
13875 vty_out(vty
, "%s%s(%s)",
13887 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13889 : "not preserved");
13890 restart_af_count
++;
13892 if (!restart_af_count
)
13893 vty_out(vty
, "none");
13894 vty_out(vty
, "\n");
13896 } /* Graceful Restart */
13900 /* graceful restart information */
13901 json_object
*json_grace
= NULL
;
13902 json_object
*json_grace_send
= NULL
;
13903 json_object
*json_grace_recv
= NULL
;
13904 int eor_send_af_count
= 0;
13905 int eor_receive_af_count
= 0;
13908 json_grace
= json_object_new_object();
13909 json_grace_send
= json_object_new_object();
13910 json_grace_recv
= json_object_new_object();
13912 if ((peer_established(p
)) &&
13913 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13914 FOREACH_AFI_SAFI (afi
, safi
) {
13915 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13916 PEER_STATUS_EOR_SEND
)) {
13917 json_object_boolean_true_add(
13919 get_afi_safi_str(afi
, safi
,
13921 eor_send_af_count
++;
13924 FOREACH_AFI_SAFI (afi
, safi
) {
13925 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13926 PEER_STATUS_EOR_RECEIVED
)) {
13927 json_object_boolean_true_add(
13929 get_afi_safi_str(afi
, safi
,
13931 eor_receive_af_count
++;
13935 json_object_object_add(json_grace
, "endOfRibSend",
13937 json_object_object_add(json_grace
, "endOfRibRecv",
13941 if (p
->t_gr_restart
)
13942 json_object_int_add(
13943 json_grace
, "gracefulRestartTimerMsecs",
13944 thread_timer_remain_second(p
->t_gr_restart
) *
13948 json_object_int_add(
13949 json_grace
, "gracefulStalepathTimerMsecs",
13950 thread_timer_remain_second(p
->t_gr_stale
) *
13952 /* more gr info in new format */
13953 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13954 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13957 vty_out(vty
, " Graceful restart information:\n");
13958 if ((peer_established(p
)) &&
13959 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13961 vty_out(vty
, " End-of-RIB send: ");
13962 FOREACH_AFI_SAFI (afi
, safi
) {
13963 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13964 PEER_STATUS_EOR_SEND
)) {
13965 vty_out(vty
, "%s%s",
13966 eor_send_af_count
? ", " : "",
13967 get_afi_safi_str(afi
, safi
,
13969 eor_send_af_count
++;
13972 vty_out(vty
, "\n");
13973 vty_out(vty
, " End-of-RIB received: ");
13974 FOREACH_AFI_SAFI (afi
, safi
) {
13975 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13976 PEER_STATUS_EOR_RECEIVED
)) {
13977 vty_out(vty
, "%s%s",
13978 eor_receive_af_count
? ", "
13980 get_afi_safi_str(afi
, safi
,
13982 eor_receive_af_count
++;
13985 vty_out(vty
, "\n");
13988 if (p
->t_gr_restart
)
13990 " The remaining time of restart timer is %ld\n",
13991 thread_timer_remain_second(p
->t_gr_restart
));
13995 " The remaining time of stalepath timer is %ld\n",
13996 thread_timer_remain_second(p
->t_gr_stale
));
13998 /* more gr info in new format */
13999 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14003 json_object
*json_stat
= NULL
;
14004 json_stat
= json_object_new_object();
14005 /* Packet counts. */
14007 atomic_size_t outq_count
, inq_count
;
14008 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14009 memory_order_relaxed
);
14010 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14011 memory_order_relaxed
);
14013 json_object_int_add(json_stat
, "depthInq",
14014 (unsigned long)inq_count
);
14015 json_object_int_add(json_stat
, "depthOutq",
14016 (unsigned long)outq_count
);
14017 json_object_int_add(json_stat
, "opensSent",
14018 atomic_load_explicit(&p
->open_out
,
14019 memory_order_relaxed
));
14020 json_object_int_add(json_stat
, "opensRecv",
14021 atomic_load_explicit(&p
->open_in
,
14022 memory_order_relaxed
));
14023 json_object_int_add(json_stat
, "notificationsSent",
14024 atomic_load_explicit(&p
->notify_out
,
14025 memory_order_relaxed
));
14026 json_object_int_add(json_stat
, "notificationsRecv",
14027 atomic_load_explicit(&p
->notify_in
,
14028 memory_order_relaxed
));
14029 json_object_int_add(json_stat
, "updatesSent",
14030 atomic_load_explicit(&p
->update_out
,
14031 memory_order_relaxed
));
14032 json_object_int_add(json_stat
, "updatesRecv",
14033 atomic_load_explicit(&p
->update_in
,
14034 memory_order_relaxed
));
14035 json_object_int_add(json_stat
, "keepalivesSent",
14036 atomic_load_explicit(&p
->keepalive_out
,
14037 memory_order_relaxed
));
14038 json_object_int_add(json_stat
, "keepalivesRecv",
14039 atomic_load_explicit(&p
->keepalive_in
,
14040 memory_order_relaxed
));
14041 json_object_int_add(json_stat
, "routeRefreshSent",
14042 atomic_load_explicit(&p
->refresh_out
,
14043 memory_order_relaxed
));
14044 json_object_int_add(json_stat
, "routeRefreshRecv",
14045 atomic_load_explicit(&p
->refresh_in
,
14046 memory_order_relaxed
));
14047 json_object_int_add(json_stat
, "capabilitySent",
14048 atomic_load_explicit(&p
->dynamic_cap_out
,
14049 memory_order_relaxed
));
14050 json_object_int_add(json_stat
, "capabilityRecv",
14051 atomic_load_explicit(&p
->dynamic_cap_in
,
14052 memory_order_relaxed
));
14053 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14054 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14055 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14057 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14058 notify_out
, notify_in
, update_out
, update_in
,
14059 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14060 dynamic_cap_out
, dynamic_cap_in
;
14061 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14062 memory_order_relaxed
);
14063 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14064 memory_order_relaxed
);
14065 open_out
= atomic_load_explicit(&p
->open_out
,
14066 memory_order_relaxed
);
14068 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14069 notify_out
= atomic_load_explicit(&p
->notify_out
,
14070 memory_order_relaxed
);
14071 notify_in
= atomic_load_explicit(&p
->notify_in
,
14072 memory_order_relaxed
);
14073 update_out
= atomic_load_explicit(&p
->update_out
,
14074 memory_order_relaxed
);
14075 update_in
= atomic_load_explicit(&p
->update_in
,
14076 memory_order_relaxed
);
14077 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14078 memory_order_relaxed
);
14079 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14080 memory_order_relaxed
);
14081 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14082 memory_order_relaxed
);
14083 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14084 memory_order_relaxed
);
14085 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14086 memory_order_relaxed
);
14087 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14088 memory_order_relaxed
);
14090 /* Packet counts. */
14091 vty_out(vty
, " Message statistics:\n");
14092 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14093 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14094 vty_out(vty
, " Sent Rcvd\n");
14095 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14097 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14099 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14101 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14103 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14105 vty_out(vty
, " Capability: %10zu %10zu\n",
14106 dynamic_cap_out
, dynamic_cap_in
);
14107 vty_out(vty
, " Total: %10u %10u\n",
14108 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14112 /* advertisement-interval */
14113 json_object_int_add(json_neigh
,
14114 "minBtwnAdvertisementRunsTimerMsecs",
14115 p
->v_routeadv
* 1000);
14117 /* Update-source. */
14118 if (p
->update_if
|| p
->update_source
) {
14120 json_object_string_add(json_neigh
,
14123 else if (p
->update_source
)
14124 json_object_string_addf(json_neigh
,
14125 "updateSource", "%pSU",
14129 /* advertisement-interval */
14131 " Minimum time between advertisement runs is %d seconds\n",
14134 /* Update-source. */
14135 if (p
->update_if
|| p
->update_source
) {
14136 vty_out(vty
, " Update source is ");
14138 vty_out(vty
, "%s", p
->update_if
);
14139 else if (p
->update_source
)
14140 vty_out(vty
, "%pSU", p
->update_source
);
14141 vty_out(vty
, "\n");
14144 vty_out(vty
, "\n");
14147 /* Address Family Information */
14148 json_object
*json_hold
= NULL
;
14151 json_hold
= json_object_new_object();
14153 FOREACH_AFI_SAFI (afi
, safi
)
14154 if (p
->afc
[afi
][safi
])
14155 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14159 json_object_object_add(json_neigh
, "addressFamilyInfo",
14161 json_object_int_add(json_neigh
, "connectionsEstablished",
14163 json_object_int_add(json_neigh
, "connectionsDropped",
14166 vty_out(vty
, " Connections established %d; dropped %d\n",
14167 p
->established
, p
->dropped
);
14169 if (!p
->last_reset
) {
14171 json_object_string_add(json_neigh
, "lastReset",
14174 vty_out(vty
, " Last reset never\n");
14180 uptime
= monotime(NULL
);
14181 uptime
-= p
->resettime
;
14182 gmtime_r(&uptime
, &tm
);
14184 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14186 + (tm
.tm_min
* 60000)
14187 + (tm
.tm_hour
* 3600000));
14188 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14190 vty_out(vty
, " Last reset %s, ",
14191 peer_uptime(p
->resettime
, timebuf
,
14192 BGP_UPTIME_LEN
, 0, NULL
));
14194 bgp_show_peer_reset(vty
, p
, NULL
, false);
14195 if (p
->last_reset_cause_size
) {
14196 msg
= p
->last_reset_cause
;
14198 " Message received that caused BGP to send a NOTIFICATION:\n ");
14199 for (i
= 1; i
<= p
->last_reset_cause_size
;
14201 vty_out(vty
, "%02X", *msg
++);
14203 if (i
!= p
->last_reset_cause_size
) {
14205 vty_out(vty
, "\n ");
14206 } else if (i
% 4 == 0) {
14211 vty_out(vty
, "\n");
14216 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14218 json_object_boolean_true_add(json_neigh
,
14219 "prefixesConfigExceedMax");
14222 " Peer had exceeded the max. no. of prefixes configured.\n");
14224 if (p
->t_pmax_restart
) {
14226 json_object_boolean_true_add(
14227 json_neigh
, "reducePrefixNumFrom");
14228 json_object_int_add(json_neigh
,
14229 "restartInTimerMsec",
14230 thread_timer_remain_second(
14235 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14236 p
->host
, thread_timer_remain_second(
14237 p
->t_pmax_restart
));
14240 json_object_boolean_true_add(
14242 "reducePrefixNumAndClearIpBgp");
14245 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14250 /* EBGP Multihop and GTSM */
14251 if (p
->sort
!= BGP_PEER_IBGP
) {
14253 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14254 json_object_int_add(json_neigh
,
14255 "externalBgpNbrMaxHopsAway",
14258 json_object_int_add(json_neigh
,
14259 "externalBgpNbrMaxHopsAway",
14262 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14264 " External BGP neighbor may be up to %d hops away.\n",
14268 " External BGP neighbor may be up to %d hops away.\n",
14273 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14274 json_object_int_add(json_neigh
,
14275 "internalBgpNbrMaxHopsAway",
14278 json_object_int_add(json_neigh
,
14279 "internalBgpNbrMaxHopsAway",
14282 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14284 " Internal BGP neighbor may be up to %d hops away.\n",
14288 " Internal BGP neighbor may be up to %d hops away.\n",
14293 /* Local address. */
14296 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14298 json_object_int_add(json_neigh
, "portLocal",
14299 ntohs(p
->su_local
->sin
.sin_port
));
14301 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14302 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14305 json_object_string_add(json_neigh
, "hostLocal",
14307 json_object_int_add(json_neigh
, "portLocal", -1);
14311 /* Remote address. */
14312 if (p
->su_remote
) {
14314 json_object_string_addf(json_neigh
, "hostForeign",
14315 "%pSU", p
->su_remote
);
14316 json_object_int_add(json_neigh
, "portForeign",
14317 ntohs(p
->su_remote
->sin
.sin_port
));
14319 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14321 ntohs(p
->su_remote
->sin
.sin_port
));
14324 json_object_string_add(json_neigh
, "hostForeign",
14326 json_object_int_add(json_neigh
, "portForeign", -1);
14330 /* Nexthop display. */
14333 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14335 json_object_string_addf(json_neigh
, "nexthopGlobal",
14336 "%pI6", &p
->nexthop
.v6_global
);
14337 json_object_string_addf(json_neigh
, "nexthopLocal",
14338 "%pI6", &p
->nexthop
.v6_local
);
14339 if (p
->shared_network
)
14340 json_object_string_add(json_neigh
,
14344 json_object_string_add(json_neigh
,
14346 "nonSharedNetwork");
14348 vty_out(vty
, "Nexthop: %s\n",
14349 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14351 vty_out(vty
, "Nexthop global: %s\n",
14352 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14354 vty_out(vty
, "Nexthop local: %s\n",
14355 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14357 vty_out(vty
, "BGP connection: %s\n",
14358 p
->shared_network
? "shared network"
14359 : "non shared network");
14363 /* Timer information. */
14365 json_object_int_add(json_neigh
, "connectRetryTimer",
14367 if (peer_established(p
) && p
->rtt
)
14368 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14371 json_object_int_add(
14372 json_neigh
, "nextStartTimerDueInMsecs",
14373 thread_timer_remain_second(p
->t_start
) * 1000);
14375 json_object_int_add(
14376 json_neigh
, "nextConnectTimerDueInMsecs",
14377 thread_timer_remain_second(p
->t_connect
)
14379 if (p
->t_routeadv
) {
14380 json_object_int_add(json_neigh
, "mraiInterval",
14382 json_object_int_add(
14383 json_neigh
, "mraiTimerExpireInMsecs",
14384 thread_timer_remain_second(p
->t_routeadv
)
14388 json_object_int_add(json_neigh
, "authenticationEnabled",
14392 json_object_string_add(json_neigh
, "readThread", "on");
14394 json_object_string_add(json_neigh
, "readThread", "off");
14396 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14397 json_object_string_add(json_neigh
, "writeThread", "on");
14399 json_object_string_add(json_neigh
, "writeThread",
14402 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14404 if (peer_established(p
) && p
->rtt
)
14405 vty_out(vty
, "Estimated round trip time: %d ms\n",
14408 vty_out(vty
, "Next start timer due in %ld seconds\n",
14409 thread_timer_remain_second(p
->t_start
));
14411 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14412 thread_timer_remain_second(p
->t_connect
));
14415 "MRAI (interval %u) timer expires in %ld seconds\n",
14417 thread_timer_remain_second(p
->t_routeadv
));
14419 vty_out(vty
, "Peer Authentication Enabled\n");
14421 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14422 p
->t_read
? "on" : "off",
14423 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14428 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14429 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14430 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14433 vty_out(vty
, "\n");
14435 /* BFD information. */
14437 bgp_bfd_show_info(vty
, p
, json_neigh
);
14440 if (p
->conf_if
) /* Configured interface name. */
14441 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14442 else /* Configured IP address. */
14443 json_object_object_add(json
, p
->host
, json_neigh
);
14447 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14448 enum show_type type
,
14449 union sockunion
*su
,
14450 const char *conf_if
, afi_t afi
,
14453 struct listnode
*node
, *nnode
;
14456 safi_t safi
= SAFI_UNICAST
;
14457 json_object
*json
= NULL
;
14458 json_object
*json_neighbor
= NULL
;
14461 json
= json_object_new_object();
14462 json_neighbor
= json_object_new_object();
14465 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14467 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14470 if ((peer
->afc
[afi
][safi
]) == 0)
14473 if (type
== show_all
) {
14474 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14478 json_object_object_add(json
, peer
->host
,
14480 json_neighbor
= NULL
;
14483 } else if (type
== show_peer
) {
14486 && !strcmp(peer
->conf_if
, conf_if
))
14488 && !strcmp(peer
->hostname
, conf_if
))) {
14490 bgp_show_peer_gr_status(vty
, peer
,
14495 if (sockunion_same(&peer
->su
, su
)) {
14497 bgp_show_peer_gr_status(vty
, peer
,
14502 if (use_json
&& find
)
14503 json_object_object_add(json
, peer
->host
,
14508 json_neighbor
= NULL
;
14513 if (type
== show_peer
&& !find
) {
14515 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14517 vty_out(vty
, "%% No such neighbor\n");
14521 json_object_free(json_neighbor
);
14522 vty_json(vty
, json
);
14524 vty_out(vty
, "\n");
14527 return CMD_SUCCESS
;
14530 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14531 enum show_type type
, union sockunion
*su
,
14532 const char *conf_if
, bool use_json
,
14535 struct listnode
*node
, *nnode
;
14538 bool nbr_output
= false;
14539 afi_t afi
= AFI_MAX
;
14540 safi_t safi
= SAFI_MAX
;
14542 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14544 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14548 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14549 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14554 bgp_show_peer(vty
, peer
, use_json
, json
);
14560 && !strcmp(peer
->conf_if
, conf_if
))
14562 && !strcmp(peer
->hostname
, conf_if
))) {
14564 bgp_show_peer(vty
, peer
, use_json
,
14568 if (sockunion_same(&peer
->su
, su
)) {
14570 bgp_show_peer(vty
, peer
, use_json
,
14575 case show_ipv4_peer
:
14576 case show_ipv6_peer
:
14577 FOREACH_SAFI (safi
) {
14578 if (peer
->afc
[afi
][safi
]) {
14581 && !strcmp(peer
->conf_if
, conf_if
))
14583 && !strcmp(peer
->hostname
, conf_if
))) {
14585 bgp_show_peer(vty
, peer
, use_json
,
14590 if (sockunion_same(&peer
->su
, su
)) {
14592 bgp_show_peer(vty
, peer
, use_json
,
14600 case show_ipv4_all
:
14601 case show_ipv6_all
:
14602 FOREACH_SAFI (safi
) {
14603 if (peer
->afc
[afi
][safi
]) {
14604 bgp_show_peer(vty
, peer
, use_json
, json
);
14613 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14614 type
== show_ipv6_peer
) && !find
) {
14616 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14618 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14621 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14622 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14623 vty_out(vty
, "%% No BGP neighbors found\n");
14626 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14627 json
, JSON_C_TO_STRING_PRETTY
));
14629 vty_out(vty
, "\n");
14632 return CMD_SUCCESS
;
14635 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14636 enum show_type type
,
14637 const char *ip_str
,
14638 afi_t afi
, bool use_json
)
14643 union sockunion su
;
14645 bgp
= bgp_get_default();
14651 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14655 ret
= str2sockunion(ip_str
, &su
);
14657 bgp_show_neighbor_graceful_restart(
14658 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14660 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14661 NULL
, afi
, use_json
);
14663 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14667 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14668 enum show_type type
,
14669 const char *ip_str
,
14672 struct listnode
*node
, *nnode
;
14674 union sockunion su
;
14675 json_object
*json
= NULL
;
14676 int ret
, is_first
= 1;
14677 bool nbr_output
= false;
14680 vty_out(vty
, "{\n");
14682 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14685 if (!(json
= json_object_new_object())) {
14687 EC_BGP_JSON_MEM_ERROR
,
14688 "Unable to allocate memory for JSON object");
14690 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14694 json_object_int_add(json
, "vrfId",
14695 (bgp
->vrf_id
== VRF_UNKNOWN
)
14697 : (int64_t)bgp
->vrf_id
);
14698 json_object_string_add(
14700 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14705 vty_out(vty
, ",\n");
14709 vty_out(vty
, "\"%s\":",
14710 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14714 vty_out(vty
, "\nInstance %s:\n",
14715 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14720 if (type
== show_peer
|| type
== show_ipv4_peer
||
14721 type
== show_ipv6_peer
) {
14722 ret
= str2sockunion(ip_str
, &su
);
14724 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14727 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14730 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14733 json_object_free(json
);
14738 vty_out(vty
, "}\n");
14739 else if (!nbr_output
)
14740 vty_out(vty
, "%% BGP instance not found\n");
14743 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14744 enum show_type type
, const char *ip_str
,
14749 union sockunion su
;
14750 json_object
*json
= NULL
;
14753 if (strmatch(name
, "all")) {
14754 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14756 return CMD_SUCCESS
;
14758 bgp
= bgp_lookup_by_name(name
);
14761 json
= json_object_new_object();
14762 vty_json(vty
, json
);
14765 "%% BGP instance not found\n");
14767 return CMD_WARNING
;
14771 bgp
= bgp_get_default();
14775 json
= json_object_new_object();
14777 ret
= str2sockunion(ip_str
, &su
);
14779 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14782 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14785 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14788 json_object_free(json
);
14791 vty_out(vty
, "{}\n");
14793 vty_out(vty
, "%% BGP instance not found\n");
14796 return CMD_SUCCESS
;
14801 /* "show [ip] bgp neighbors graceful-restart" commands. */
14802 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14803 show_ip_bgp_neighbors_graceful_restart_cmd
,
14804 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14810 "Neighbor to display information about\n"
14811 "Neighbor to display information about\n"
14812 "Neighbor on BGP configured interface\n"
14816 char *sh_arg
= NULL
;
14817 enum show_type sh_type
;
14819 afi_t afi
= AFI_MAX
;
14820 bool uj
= use_json(argc
, argv
);
14822 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14827 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14828 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14829 || argv_find(argv
, argc
, "WORD", &idx
)) {
14830 sh_type
= show_peer
;
14831 sh_arg
= argv
[idx
]->arg
;
14833 sh_type
= show_all
;
14835 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14836 return CMD_SUCCESS
;
14839 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14843 /* "show [ip] bgp neighbors" commands. */
14844 DEFUN (show_ip_bgp_neighbors
,
14845 show_ip_bgp_neighbors_cmd
,
14846 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14850 BGP_INSTANCE_HELP_STR
14853 "Detailed information on TCP and BGP neighbor connections\n"
14854 "Neighbor to display information about\n"
14855 "Neighbor to display information about\n"
14856 "Neighbor on BGP configured interface\n"
14860 char *sh_arg
= NULL
;
14861 enum show_type sh_type
;
14862 afi_t afi
= AFI_MAX
;
14864 bool uj
= use_json(argc
, argv
);
14868 /* [<vrf> VIEWVRFNAME] */
14869 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14870 vrf
= argv
[idx
+ 1]->arg
;
14871 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14873 } else if (argv_find(argv
, argc
, "view", &idx
))
14874 /* [<view> VIEWVRFNAME] */
14875 vrf
= argv
[idx
+ 1]->arg
;
14879 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14880 sh_type
= show_ipv4_all
;
14882 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14883 sh_type
= show_ipv6_all
;
14886 sh_type
= show_all
;
14889 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14890 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14891 || argv_find(argv
, argc
, "WORD", &idx
)) {
14892 sh_type
= show_peer
;
14893 sh_arg
= argv
[idx
]->arg
;
14896 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14897 sh_type
= show_ipv4_peer
;
14898 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14899 sh_type
= show_ipv6_peer
;
14902 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14905 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14906 paths' and `show ip mbgp paths'. Those functions results are the
14908 DEFUN (show_ip_bgp_paths
,
14909 show_ip_bgp_paths_cmd
,
14910 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14915 "Path information\n")
14917 vty_out(vty
, "Address Refcnt Path\n");
14918 aspath_print_all_vty(vty
);
14919 return CMD_SUCCESS
;
14924 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14927 struct community
*com
;
14929 com
= (struct community
*)bucket
->data
;
14930 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14931 community_str(com
, false, false));
14934 /* Show BGP's community internal data. */
14935 DEFUN (show_ip_bgp_community_info
,
14936 show_ip_bgp_community_info_cmd
,
14937 "show [ip] bgp community-info",
14941 "List all bgp community information\n")
14943 vty_out(vty
, "Address Refcnt Community\n");
14945 hash_iterate(community_hash(),
14946 (void (*)(struct hash_bucket
*,
14947 void *))community_show_all_iterator
,
14950 return CMD_SUCCESS
;
14953 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14956 struct lcommunity
*lcom
;
14958 lcom
= (struct lcommunity
*)bucket
->data
;
14959 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14960 lcommunity_str(lcom
, false, false));
14963 /* Show BGP's community internal data. */
14964 DEFUN (show_ip_bgp_lcommunity_info
,
14965 show_ip_bgp_lcommunity_info_cmd
,
14966 "show ip bgp large-community-info",
14970 "List all bgp large-community information\n")
14972 vty_out(vty
, "Address Refcnt Large-community\n");
14974 hash_iterate(lcommunity_hash(),
14975 (void (*)(struct hash_bucket
*,
14976 void *))lcommunity_show_all_iterator
,
14979 return CMD_SUCCESS
;
14981 /* Graceful Restart */
14983 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14990 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14992 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14994 switch (bgp_global_gr_mode
) {
14996 case GLOBAL_HELPER
:
14997 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15001 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15004 case GLOBAL_DISABLE
:
15005 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15008 case GLOBAL_INVALID
:
15010 "Global BGP GR Mode Invalid\n");
15013 vty_out(vty
, "\n");
15016 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15017 enum show_type type
,
15018 const char *ip_str
,
15019 afi_t afi
, bool use_json
)
15021 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15024 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15026 bgp_show_neighbor_graceful_restart_vty(
15027 vty
, type
, ip_str
, afi
, use_json
);
15030 } else if (afi
!= AFI_MAX
) {
15031 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15034 return CMD_ERR_INCOMPLETE
;
15037 return CMD_SUCCESS
;
15039 /* Graceful Restart */
15041 DEFUN (show_ip_bgp_attr_info
,
15042 show_ip_bgp_attr_info_cmd
,
15043 "show [ip] bgp attribute-info",
15047 "List all bgp attribute information\n")
15049 attr_show_all(vty
);
15050 return CMD_SUCCESS
;
15053 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15054 afi_t afi
, safi_t safi
,
15055 bool use_json
, json_object
*json
)
15058 struct listnode
*node
;
15061 enum vpn_policy_direction dir
;
15064 json_object
*json_import_vrfs
= NULL
;
15065 json_object
*json_export_vrfs
= NULL
;
15067 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15070 vty_json(vty
, json
);
15072 return CMD_WARNING
;
15075 /* Provide context for the block */
15076 json_object_string_add(json
, "vrf", name
? name
: "default");
15077 json_object_string_add(json
, "afiSafi",
15078 get_afi_safi_str(afi
, safi
, true));
15080 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15081 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15082 json_object_string_add(json
, "importFromVrfs", "none");
15083 json_object_string_add(json
, "importRts", "none");
15085 json_import_vrfs
= json_object_new_array();
15087 for (ALL_LIST_ELEMENTS_RO(
15088 bgp
->vpn_policy
[afi
].import_vrf
,
15090 json_object_array_add(json_import_vrfs
,
15091 json_object_new_string(vname
));
15093 json_object_object_add(json
, "importFromVrfs",
15095 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15096 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15097 ecom_str
= ecommunity_ecom2str(
15098 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15099 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15100 json_object_string_add(json
, "importRts",
15102 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15104 json_object_string_add(json
, "importRts",
15108 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15109 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15110 json_object_string_add(json
, "exportToVrfs", "none");
15111 json_object_string_add(json
, "routeDistinguisher",
15113 json_object_string_add(json
, "exportRts", "none");
15115 json_export_vrfs
= json_object_new_array();
15117 for (ALL_LIST_ELEMENTS_RO(
15118 bgp
->vpn_policy
[afi
].export_vrf
,
15120 json_object_array_add(json_export_vrfs
,
15121 json_object_new_string(vname
));
15122 json_object_object_add(json
, "exportToVrfs",
15124 json_object_string_addf(json
, "routeDistinguisher",
15126 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15128 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15129 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15130 ecom_str
= ecommunity_ecom2str(
15131 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15132 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15133 json_object_string_add(json
, "exportRts",
15135 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15137 json_object_string_add(json
, "exportRts",
15142 vty_json(vty
, json
);
15145 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15148 vty_out(vty
, "%% No such BGP instance exist\n");
15149 return CMD_WARNING
;
15152 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15153 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15155 "This VRF is not importing %s routes from any other VRF\n",
15156 get_afi_safi_str(afi
, safi
, false));
15159 "This VRF is importing %s routes from the following VRFs:\n",
15160 get_afi_safi_str(afi
, safi
, false));
15162 for (ALL_LIST_ELEMENTS_RO(
15163 bgp
->vpn_policy
[afi
].import_vrf
,
15165 vty_out(vty
, " %s\n", vname
);
15167 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15169 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15170 ecom_str
= ecommunity_ecom2str(
15171 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15172 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15173 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15175 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15177 vty_out(vty
, "Import RT(s):\n");
15180 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15181 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15183 "This VRF is not exporting %s routes to any other VRF\n",
15184 get_afi_safi_str(afi
, safi
, false));
15187 "This VRF is exporting %s routes to the following VRFs:\n",
15188 get_afi_safi_str(afi
, safi
, false));
15190 for (ALL_LIST_ELEMENTS_RO(
15191 bgp
->vpn_policy
[afi
].export_vrf
,
15193 vty_out(vty
, " %s\n", vname
);
15195 vty_out(vty
, "RD: %pRD\n",
15196 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15198 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15199 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15200 ecom_str
= ecommunity_ecom2str(
15201 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15202 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15203 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15204 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15206 vty_out(vty
, "Import RT(s):\n");
15210 return CMD_SUCCESS
;
15213 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15214 safi_t safi
, bool use_json
)
15216 struct listnode
*node
, *nnode
;
15218 char *vrf_name
= NULL
;
15219 json_object
*json
= NULL
;
15220 json_object
*json_vrf
= NULL
;
15221 json_object
*json_vrfs
= NULL
;
15224 json
= json_object_new_object();
15225 json_vrfs
= json_object_new_object();
15228 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15230 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15231 vrf_name
= bgp
->name
;
15234 json_vrf
= json_object_new_object();
15236 vty_out(vty
, "\nInstance %s:\n",
15237 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15238 ? VRF_DEFAULT_NAME
: bgp
->name
);
15240 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15242 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15243 json_object_object_add(json_vrfs
,
15244 VRF_DEFAULT_NAME
, json_vrf
);
15246 json_object_object_add(json_vrfs
, vrf_name
,
15252 json_object_object_add(json
, "vrfs", json_vrfs
);
15253 vty_json(vty
, json
);
15256 return CMD_SUCCESS
;
15259 /* "show [ip] bgp route-leak" command. */
15260 DEFUN (show_ip_bgp_route_leak
,
15261 show_ip_bgp_route_leak_cmd
,
15262 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15266 BGP_INSTANCE_HELP_STR
15269 "Route leaking information\n"
15273 afi_t afi
= AFI_MAX
;
15274 safi_t safi
= SAFI_MAX
;
15276 bool uj
= use_json(argc
, argv
);
15278 json_object
*json
= NULL
;
15280 /* show [ip] bgp */
15281 if (argv_find(argv
, argc
, "ip", &idx
)) {
15283 safi
= SAFI_UNICAST
;
15285 /* [vrf VIEWVRFNAME] */
15286 if (argv_find(argv
, argc
, "view", &idx
)) {
15288 "%% This command is not applicable to BGP views\n");
15289 return CMD_WARNING
;
15292 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15293 vrf
= argv
[idx
+ 1]->arg
;
15294 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15297 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15298 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15299 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15301 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15303 "%% This command is applicable only for unicast ipv4|ipv6\n");
15304 return CMD_WARNING
;
15307 if (vrf
&& strmatch(vrf
, "all"))
15308 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15311 json
= json_object_new_object();
15313 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15316 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15319 struct listnode
*node
, *nnode
;
15322 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15323 vty_out(vty
, "\nInstance %s:\n",
15324 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15327 update_group_show(bgp
, afi
, safi
, vty
, 0);
15331 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15332 int safi
, uint64_t subgrp_id
)
15337 if (strmatch(name
, "all")) {
15338 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15339 return CMD_SUCCESS
;
15341 bgp
= bgp_lookup_by_name(name
);
15344 bgp
= bgp_get_default();
15348 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15349 return CMD_SUCCESS
;
15352 DEFUN (show_ip_bgp_updgrps
,
15353 show_ip_bgp_updgrps_cmd
,
15354 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15358 BGP_INSTANCE_HELP_STR
15360 BGP_SAFI_WITH_LABEL_HELP_STR
15361 "Detailed info about dynamic update groups\n"
15362 "Specific subgroup to display detailed info for\n")
15365 afi_t afi
= AFI_IP6
;
15366 safi_t safi
= SAFI_UNICAST
;
15367 uint64_t subgrp_id
= 0;
15371 /* show [ip] bgp */
15372 if (argv_find(argv
, argc
, "ip", &idx
))
15374 /* [<vrf> VIEWVRFNAME] */
15375 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15376 vrf
= argv
[idx
+ 1]->arg
;
15377 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15379 } else if (argv_find(argv
, argc
, "view", &idx
))
15380 /* [<view> VIEWVRFNAME] */
15381 vrf
= argv
[idx
+ 1]->arg
;
15382 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15383 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15384 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15387 /* get subgroup id, if provided */
15389 if (argv
[idx
]->type
== VARIABLE_TKN
)
15390 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15392 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15395 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15396 show_bgp_instance_all_ipv6_updgrps_cmd
,
15397 "show [ip] bgp <view|vrf> all update-groups",
15401 BGP_INSTANCE_ALL_HELP_STR
15402 "Detailed info about dynamic update groups\n")
15404 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15405 return CMD_SUCCESS
;
15408 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15409 show_bgp_l2vpn_evpn_updgrps_cmd
,
15410 "show [ip] bgp l2vpn evpn update-groups",
15414 "l2vpn address family\n"
15415 "evpn sub-address family\n"
15416 "Detailed info about dynamic update groups\n")
15419 uint64_t subgrp_id
= 0;
15421 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15422 return CMD_SUCCESS
;
15425 DEFUN (show_bgp_updgrps_stats
,
15426 show_bgp_updgrps_stats_cmd
,
15427 "show [ip] bgp update-groups statistics",
15431 "Detailed info about dynamic update groups\n"
15436 bgp
= bgp_get_default();
15438 update_group_show_stats(bgp
, vty
);
15440 return CMD_SUCCESS
;
15443 DEFUN (show_bgp_instance_updgrps_stats
,
15444 show_bgp_instance_updgrps_stats_cmd
,
15445 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15449 BGP_INSTANCE_HELP_STR
15450 "Detailed info about dynamic update groups\n"
15456 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15458 update_group_show_stats(bgp
, vty
);
15460 return CMD_SUCCESS
;
15463 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15464 afi_t afi
, safi_t safi
,
15465 const char *what
, uint64_t subgrp_id
)
15470 bgp
= bgp_lookup_by_name(name
);
15472 bgp
= bgp_get_default();
15475 if (!strcmp(what
, "advertise-queue"))
15476 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15478 else if (!strcmp(what
, "advertised-routes"))
15479 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15481 else if (!strcmp(what
, "packet-queue"))
15482 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15487 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15488 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15489 "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",
15490 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15492 "Detailed info about dynamic update groups\n"
15493 "Specific subgroup to display info for\n"
15494 "Advertisement queue\n"
15495 "Announced routes\n"
15498 uint64_t subgrp_id
= 0;
15502 subgrp_id
= strtoull(sgid
, NULL
, 10);
15507 afiz
= bgp_vty_afi_from_str(afi
);
15511 afiz
= bgp_vty_afi_from_str(afi
);
15512 if (afiz
!= AFI_IP
)
15514 "%% Cannot specify both 'ip' and 'ipv6'\n");
15515 return CMD_WARNING
;
15518 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15520 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15521 return CMD_SUCCESS
;
15524 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15527 struct listnode
*node
, *nnode
;
15528 struct prefix
*range
;
15533 const char *peer_status
;
15537 json_object
*json_peer_group
= NULL
;
15538 json_object
*json_peer_group_afc
= NULL
;
15539 json_object
*json_peer_group_members
= NULL
;
15540 json_object
*json_peer_group_dynamic
= NULL
;
15541 json_object
*json_peer_group_dynamic_af
= NULL
;
15542 json_object
*json_peer_group_ranges
= NULL
;
15544 conf
= group
->conf
;
15547 json_peer_group
= json_object_new_object();
15548 json_peer_group_afc
= json_object_new_array();
15551 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15553 json_object_int_add(json_peer_group
, "remoteAs",
15556 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15557 group
->name
, conf
->as
);
15558 } else if (conf
->as_type
== AS_INTERNAL
) {
15560 json_object_int_add(json_peer_group
, "remoteAs",
15563 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15564 group
->name
, group
->bgp
->as
);
15567 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15570 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15572 json_object_string_add(json_peer_group
, "type",
15575 vty_out(vty
, " Peer-group type is internal\n");
15578 json_object_string_add(json_peer_group
, "type",
15581 vty_out(vty
, " Peer-group type is external\n");
15584 /* Display AFs configured. */
15586 vty_out(vty
, " Configured address-families:");
15588 FOREACH_AFI_SAFI (afi
, safi
) {
15589 if (conf
->afc
[afi
][safi
]) {
15592 json_object_array_add(
15593 json_peer_group_afc
,
15594 json_object_new_string(get_afi_safi_str(
15595 afi
, safi
, false)));
15597 vty_out(vty
, " %s;",
15598 get_afi_safi_str(afi
, safi
, false));
15603 json_object_object_add(json_peer_group
,
15604 "addressFamiliesConfigured",
15605 json_peer_group_afc
);
15608 vty_out(vty
, " none\n");
15610 vty_out(vty
, "\n");
15613 /* Display listen ranges (for dynamic neighbors), if any */
15614 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15615 lr_count
= listcount(group
->listen_range
[afi
]);
15618 if (!json_peer_group_dynamic
)
15619 json_peer_group_dynamic
=
15620 json_object_new_object();
15622 json_peer_group_dynamic_af
=
15623 json_object_new_object();
15624 json_peer_group_ranges
=
15625 json_object_new_array();
15626 json_object_int_add(json_peer_group_dynamic_af
,
15627 "count", lr_count
);
15629 vty_out(vty
, " %d %s listen range(s)\n",
15630 lr_count
, afi2str(afi
));
15633 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15638 snprintfrr(buf
, sizeof(buf
), "%pFX",
15641 json_object_array_add(
15642 json_peer_group_ranges
,
15643 json_object_new_string(buf
));
15645 vty_out(vty
, " %pFX\n", range
);
15650 json_object_object_add(
15651 json_peer_group_dynamic_af
, "ranges",
15652 json_peer_group_ranges
);
15654 json_object_object_add(
15655 json_peer_group_dynamic
, afi2str(afi
),
15656 json_peer_group_dynamic_af
);
15661 if (json_peer_group_dynamic
)
15662 json_object_object_add(json_peer_group
, "dynamicRanges",
15663 json_peer_group_dynamic
);
15665 /* Display group members and their status */
15666 if (listcount(group
->peer
)) {
15668 json_peer_group_members
= json_object_new_object();
15670 vty_out(vty
, " Peer-group members:\n");
15671 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15672 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15673 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15674 peer_status
= "Idle (Admin)";
15675 else if (CHECK_FLAG(peer
->sflags
,
15676 PEER_STATUS_PREFIX_OVERFLOW
))
15677 peer_status
= "Idle (PfxCt)";
15679 peer_status
= lookup_msg(bgp_status_msg
,
15680 peer
->status
, NULL
);
15682 dynamic
= peer_dynamic_neighbor(peer
);
15685 json_object
*json_peer_group_member
=
15686 json_object_new_object();
15688 json_object_string_add(json_peer_group_member
,
15689 "status", peer_status
);
15692 json_object_boolean_true_add(
15693 json_peer_group_member
,
15696 json_object_object_add(json_peer_group_members
,
15698 json_peer_group_member
);
15700 vty_out(vty
, " %s %s %s \n", peer
->host
,
15701 dynamic
? "(dynamic)" : "",
15706 json_object_object_add(json_peer_group
, "members",
15707 json_peer_group_members
);
15711 json_object_object_add(json
, group
->name
, json_peer_group
);
15713 return CMD_SUCCESS
;
15716 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15717 const char *group_name
, bool uj
)
15720 struct listnode
*node
, *nnode
;
15721 struct peer_group
*group
;
15722 bool found
= false;
15723 json_object
*json
= NULL
;
15726 json
= json_object_new_object();
15728 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15732 vty_json(vty
, json
);
15734 vty_out(vty
, "%% BGP instance not found\n");
15736 return CMD_WARNING
;
15739 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15741 if (strmatch(group
->name
, group_name
)) {
15742 bgp_show_one_peer_group(vty
, group
, json
);
15747 bgp_show_one_peer_group(vty
, group
, json
);
15751 if (group_name
&& !found
&& !uj
)
15752 vty_out(vty
, "%% No such peer-group\n");
15755 vty_json(vty
, json
);
15757 return CMD_SUCCESS
;
15760 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15761 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15762 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15763 "Detailed information on BGP peer groups\n"
15764 "Peer group name\n" JSON_STR
)
15768 bool uj
= use_json(argc
, argv
);
15770 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15772 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15774 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15778 /* Redistribute VTY commands. */
15780 DEFUN (bgp_redistribute_ipv4
,
15781 bgp_redistribute_ipv4_cmd
,
15782 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15783 "Redistribute information from another routing protocol\n"
15784 FRR_IP_REDIST_HELP_STR_BGPD
)
15786 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15787 int idx_protocol
= 1;
15790 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15792 vty_out(vty
, "%% Invalid route type\n");
15793 return CMD_WARNING_CONFIG_FAILED
;
15796 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15797 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15801 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15802 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15803 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15805 DEFUN (bgp_redistribute_ipv4_rmap
,
15806 bgp_redistribute_ipv4_rmap_cmd
,
15807 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15808 "Redistribute information from another routing protocol\n"
15809 FRR_IP_REDIST_HELP_STR_BGPD
15810 "Route map reference\n"
15811 "Pointer to route-map entries\n")
15813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15814 int idx_protocol
= 1;
15817 struct bgp_redist
*red
;
15819 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15820 vty
, argv
[idx_word
]->arg
);
15822 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15824 vty_out(vty
, "%% Invalid route type\n");
15825 return CMD_WARNING_CONFIG_FAILED
;
15828 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15830 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15831 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15835 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15836 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15837 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15838 "Route map reference\n"
15839 "Pointer to route-map entries\n")
15841 DEFUN (bgp_redistribute_ipv4_metric
,
15842 bgp_redistribute_ipv4_metric_cmd
,
15843 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15844 "Redistribute information from another routing protocol\n"
15845 FRR_IP_REDIST_HELP_STR_BGPD
15846 "Metric for redistributed routes\n"
15847 "Default metric\n")
15849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15850 int idx_protocol
= 1;
15851 int idx_number
= 3;
15854 struct bgp_redist
*red
;
15857 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15859 vty_out(vty
, "%% Invalid route type\n");
15860 return CMD_WARNING_CONFIG_FAILED
;
15862 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15864 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15865 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15866 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15870 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15871 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15872 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15873 "Metric for redistributed routes\n"
15874 "Default metric\n")
15876 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15877 bgp_redistribute_ipv4_rmap_metric_cmd
,
15878 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15879 "Redistribute information from another routing protocol\n"
15880 FRR_IP_REDIST_HELP_STR_BGPD
15881 "Route map reference\n"
15882 "Pointer to route-map entries\n"
15883 "Metric for redistributed routes\n"
15884 "Default metric\n")
15886 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15887 int idx_protocol
= 1;
15889 int idx_number
= 5;
15892 struct bgp_redist
*red
;
15894 struct route_map
*route_map
=
15895 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15897 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15899 vty_out(vty
, "%% Invalid route type\n");
15900 return CMD_WARNING_CONFIG_FAILED
;
15902 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15904 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15906 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15907 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15908 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15912 bgp_redistribute_ipv4_rmap_metric
,
15913 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15914 "redistribute " FRR_IP_REDIST_STR_BGPD
15915 " route-map RMAP_NAME metric (0-4294967295)",
15916 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15917 "Route map reference\n"
15918 "Pointer to route-map entries\n"
15919 "Metric for redistributed routes\n"
15920 "Default metric\n")
15922 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15923 bgp_redistribute_ipv4_metric_rmap_cmd
,
15924 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15925 "Redistribute information from another routing protocol\n"
15926 FRR_IP_REDIST_HELP_STR_BGPD
15927 "Metric for redistributed routes\n"
15929 "Route map reference\n"
15930 "Pointer to route-map entries\n")
15932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15933 int idx_protocol
= 1;
15934 int idx_number
= 3;
15938 struct bgp_redist
*red
;
15940 struct route_map
*route_map
=
15941 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15943 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15945 vty_out(vty
, "%% Invalid route type\n");
15946 return CMD_WARNING_CONFIG_FAILED
;
15948 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15950 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15951 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15953 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15954 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15958 bgp_redistribute_ipv4_metric_rmap
,
15959 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15960 "redistribute " FRR_IP_REDIST_STR_BGPD
15961 " metric (0-4294967295) route-map RMAP_NAME",
15962 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15963 "Metric for redistributed routes\n"
15965 "Route map reference\n"
15966 "Pointer to route-map entries\n")
15968 DEFUN (bgp_redistribute_ipv4_ospf
,
15969 bgp_redistribute_ipv4_ospf_cmd
,
15970 "redistribute <ospf|table> (1-65535)",
15971 "Redistribute information from another routing protocol\n"
15972 "Open Shortest Path First (OSPFv2)\n"
15973 "Non-main Kernel Routing Table\n"
15974 "Instance ID/Table ID\n")
15976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15977 int idx_ospf_table
= 1;
15978 int idx_number
= 2;
15979 unsigned short instance
;
15980 unsigned short protocol
;
15982 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15984 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15985 protocol
= ZEBRA_ROUTE_OSPF
;
15987 protocol
= ZEBRA_ROUTE_TABLE
;
15989 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15990 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15993 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15994 "redistribute <ospf|table> (1-65535)",
15995 "Redistribute information from another routing protocol\n"
15996 "Open Shortest Path First (OSPFv2)\n"
15997 "Non-main Kernel Routing Table\n"
15998 "Instance ID/Table ID\n")
16000 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16001 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16002 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16003 "Redistribute information from another routing protocol\n"
16004 "Open Shortest Path First (OSPFv2)\n"
16005 "Non-main Kernel Routing Table\n"
16006 "Instance ID/Table ID\n"
16007 "Route map reference\n"
16008 "Pointer to route-map entries\n")
16010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16011 int idx_ospf_table
= 1;
16012 int idx_number
= 2;
16014 struct bgp_redist
*red
;
16015 unsigned short instance
;
16018 struct route_map
*route_map
=
16019 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16021 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16022 protocol
= ZEBRA_ROUTE_OSPF
;
16024 protocol
= ZEBRA_ROUTE_TABLE
;
16026 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16027 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16029 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16030 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16033 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16034 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16035 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16036 "Redistribute information from another routing protocol\n"
16037 "Open Shortest Path First (OSPFv2)\n"
16038 "Non-main Kernel Routing Table\n"
16039 "Instance ID/Table ID\n"
16040 "Route map reference\n"
16041 "Pointer to route-map entries\n")
16043 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16044 bgp_redistribute_ipv4_ospf_metric_cmd
,
16045 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16046 "Redistribute information from another routing protocol\n"
16047 "Open Shortest Path First (OSPFv2)\n"
16048 "Non-main Kernel Routing Table\n"
16049 "Instance ID/Table ID\n"
16050 "Metric for redistributed routes\n"
16051 "Default metric\n")
16053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16054 int idx_ospf_table
= 1;
16055 int idx_number
= 2;
16056 int idx_number_2
= 4;
16058 struct bgp_redist
*red
;
16059 unsigned short instance
;
16063 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16064 protocol
= ZEBRA_ROUTE_OSPF
;
16066 protocol
= ZEBRA_ROUTE_TABLE
;
16068 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16069 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16071 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16072 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16074 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16077 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16078 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16079 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16080 "Redistribute information from another routing protocol\n"
16081 "Open Shortest Path First (OSPFv2)\n"
16082 "Non-main Kernel Routing Table\n"
16083 "Instance ID/Table ID\n"
16084 "Metric for redistributed routes\n"
16085 "Default metric\n")
16087 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16088 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16089 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16090 "Redistribute information from another routing protocol\n"
16091 "Open Shortest Path First (OSPFv2)\n"
16092 "Non-main Kernel Routing Table\n"
16093 "Instance ID/Table ID\n"
16094 "Route map reference\n"
16095 "Pointer to route-map entries\n"
16096 "Metric for redistributed routes\n"
16097 "Default metric\n")
16099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16100 int idx_ospf_table
= 1;
16101 int idx_number
= 2;
16103 int idx_number_2
= 6;
16105 struct bgp_redist
*red
;
16106 unsigned short instance
;
16109 struct route_map
*route_map
=
16110 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16112 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16113 protocol
= ZEBRA_ROUTE_OSPF
;
16115 protocol
= ZEBRA_ROUTE_TABLE
;
16117 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16118 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16120 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16122 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16123 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16125 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16129 bgp_redistribute_ipv4_ospf_rmap_metric
,
16130 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16131 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16132 "Redistribute information from another routing protocol\n"
16133 "Open Shortest Path First (OSPFv2)\n"
16134 "Non-main Kernel Routing Table\n"
16135 "Instance ID/Table ID\n"
16136 "Route map reference\n"
16137 "Pointer to route-map entries\n"
16138 "Metric for redistributed routes\n"
16139 "Default metric\n")
16141 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16142 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16143 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16144 "Redistribute information from another routing protocol\n"
16145 "Open Shortest Path First (OSPFv2)\n"
16146 "Non-main Kernel Routing Table\n"
16147 "Instance ID/Table ID\n"
16148 "Metric for redistributed routes\n"
16150 "Route map reference\n"
16151 "Pointer to route-map entries\n")
16153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16154 int idx_ospf_table
= 1;
16155 int idx_number
= 2;
16156 int idx_number_2
= 4;
16159 struct bgp_redist
*red
;
16160 unsigned short instance
;
16163 struct route_map
*route_map
=
16164 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16166 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16167 protocol
= ZEBRA_ROUTE_OSPF
;
16169 protocol
= ZEBRA_ROUTE_TABLE
;
16171 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16172 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16174 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16175 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16178 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16179 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16183 bgp_redistribute_ipv4_ospf_metric_rmap
,
16184 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16185 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16186 "Redistribute information from another routing protocol\n"
16187 "Open Shortest Path First (OSPFv2)\n"
16188 "Non-main Kernel Routing Table\n"
16189 "Instance ID/Table ID\n"
16190 "Metric for redistributed routes\n"
16192 "Route map reference\n"
16193 "Pointer to route-map entries\n")
16195 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16196 no_bgp_redistribute_ipv4_ospf_cmd
,
16197 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16199 "Redistribute information from another routing protocol\n"
16200 "Open Shortest Path First (OSPFv2)\n"
16201 "Non-main Kernel Routing Table\n"
16202 "Instance ID/Table ID\n"
16203 "Metric for redistributed routes\n"
16205 "Route map reference\n"
16206 "Pointer to route-map entries\n")
16208 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16209 int idx_ospf_table
= 2;
16210 int idx_number
= 3;
16211 unsigned short instance
;
16214 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16215 protocol
= ZEBRA_ROUTE_OSPF
;
16217 protocol
= ZEBRA_ROUTE_TABLE
;
16219 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16220 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16224 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16225 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16227 "Redistribute information from another routing protocol\n"
16228 "Open Shortest Path First (OSPFv2)\n"
16229 "Non-main Kernel Routing Table\n"
16230 "Instance ID/Table ID\n"
16231 "Metric for redistributed routes\n"
16233 "Route map reference\n"
16234 "Pointer to route-map entries\n")
16236 DEFUN (no_bgp_redistribute_ipv4
,
16237 no_bgp_redistribute_ipv4_cmd
,
16238 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16240 "Redistribute information from another routing protocol\n"
16241 FRR_IP_REDIST_HELP_STR_BGPD
16242 "Metric for redistributed routes\n"
16244 "Route map reference\n"
16245 "Pointer to route-map entries\n")
16247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16248 int idx_protocol
= 2;
16251 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16253 vty_out(vty
, "%% Invalid route type\n");
16254 return CMD_WARNING_CONFIG_FAILED
;
16256 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16260 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16261 "no redistribute " FRR_IP_REDIST_STR_BGPD
16262 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16264 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16265 "Metric for redistributed routes\n"
16267 "Route map reference\n"
16268 "Pointer to route-map entries\n")
16270 DEFUN (bgp_redistribute_ipv6
,
16271 bgp_redistribute_ipv6_cmd
,
16272 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16273 "Redistribute information from another routing protocol\n"
16274 FRR_IP6_REDIST_HELP_STR_BGPD
)
16276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16277 int idx_protocol
= 1;
16280 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16282 vty_out(vty
, "%% Invalid route type\n");
16283 return CMD_WARNING_CONFIG_FAILED
;
16286 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16287 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16290 DEFUN (bgp_redistribute_ipv6_rmap
,
16291 bgp_redistribute_ipv6_rmap_cmd
,
16292 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16293 "Redistribute information from another routing protocol\n"
16294 FRR_IP6_REDIST_HELP_STR_BGPD
16295 "Route map reference\n"
16296 "Pointer to route-map entries\n")
16298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16299 int idx_protocol
= 1;
16302 struct bgp_redist
*red
;
16304 struct route_map
*route_map
=
16305 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16307 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16309 vty_out(vty
, "%% Invalid route type\n");
16310 return CMD_WARNING_CONFIG_FAILED
;
16313 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16315 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16316 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16319 DEFUN (bgp_redistribute_ipv6_metric
,
16320 bgp_redistribute_ipv6_metric_cmd
,
16321 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16322 "Redistribute information from another routing protocol\n"
16323 FRR_IP6_REDIST_HELP_STR_BGPD
16324 "Metric for redistributed routes\n"
16325 "Default metric\n")
16327 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16328 int idx_protocol
= 1;
16329 int idx_number
= 3;
16332 struct bgp_redist
*red
;
16335 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16337 vty_out(vty
, "%% Invalid route type\n");
16338 return CMD_WARNING_CONFIG_FAILED
;
16340 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16342 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16343 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16344 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16347 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16348 bgp_redistribute_ipv6_rmap_metric_cmd
,
16349 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16350 "Redistribute information from another routing protocol\n"
16351 FRR_IP6_REDIST_HELP_STR_BGPD
16352 "Route map reference\n"
16353 "Pointer to route-map entries\n"
16354 "Metric for redistributed routes\n"
16355 "Default metric\n")
16357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16358 int idx_protocol
= 1;
16360 int idx_number
= 5;
16363 struct bgp_redist
*red
;
16365 struct route_map
*route_map
=
16366 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16368 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16370 vty_out(vty
, "%% Invalid route type\n");
16371 return CMD_WARNING_CONFIG_FAILED
;
16373 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16375 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16377 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16378 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16380 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16383 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16384 bgp_redistribute_ipv6_metric_rmap_cmd
,
16385 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16386 "Redistribute information from another routing protocol\n"
16387 FRR_IP6_REDIST_HELP_STR_BGPD
16388 "Metric for redistributed routes\n"
16390 "Route map reference\n"
16391 "Pointer to route-map entries\n")
16393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16394 int idx_protocol
= 1;
16395 int idx_number
= 3;
16399 struct bgp_redist
*red
;
16401 struct route_map
*route_map
=
16402 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16404 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16406 vty_out(vty
, "%% Invalid route type\n");
16407 return CMD_WARNING_CONFIG_FAILED
;
16409 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16411 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16412 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16415 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16416 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16419 DEFUN (no_bgp_redistribute_ipv6
,
16420 no_bgp_redistribute_ipv6_cmd
,
16421 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16423 "Redistribute information from another routing protocol\n"
16424 FRR_IP6_REDIST_HELP_STR_BGPD
16425 "Metric for redistributed routes\n"
16427 "Route map reference\n"
16428 "Pointer to route-map entries\n")
16430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16431 int idx_protocol
= 2;
16434 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16436 vty_out(vty
, "%% Invalid route type\n");
16437 return CMD_WARNING_CONFIG_FAILED
;
16440 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16443 /* Neighbor update tcp-mss. */
16444 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16445 const char *tcp_mss_str
)
16448 uint32_t tcp_mss_val
= 0;
16450 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16452 return CMD_WARNING_CONFIG_FAILED
;
16455 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16456 peer_tcp_mss_set(peer
, tcp_mss_val
);
16458 peer_tcp_mss_unset(peer
);
16461 return CMD_SUCCESS
;
16464 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16465 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16467 "TCP max segment size\n"
16470 int peer_index
= 1;
16474 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16475 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16476 argv
[mss_index
]->arg
);
16479 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16480 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16482 "TCP max segment size\n"
16485 int peer_index
= 2;
16488 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16489 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16492 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16493 "[no$no] bgp retain route-target all",
16495 "Retain BGP updates\n"
16496 "Retain BGP updates based on route-target values\n"
16497 "Retain all BGP updates\n")
16500 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16502 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16503 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16504 if (check
!= !no
) {
16506 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16507 [bgp_node_safi(vty
)],
16508 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16510 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16511 [bgp_node_safi(vty
)],
16512 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16513 /* trigger a flush to re-sync with ADJ-RIB-in */
16514 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16515 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16517 return CMD_SUCCESS
;
16520 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16521 afi_t afi
, safi_t safi
)
16525 /* Unicast redistribution only. */
16526 if (safi
!= SAFI_UNICAST
)
16529 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16530 /* Redistribute BGP does not make sense. */
16531 if (i
!= ZEBRA_ROUTE_BGP
) {
16532 struct list
*red_list
;
16533 struct listnode
*node
;
16534 struct bgp_redist
*red
;
16536 red_list
= bgp
->redist
[afi
][i
];
16540 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16541 /* "redistribute" configuration. */
16542 vty_out(vty
, " redistribute %s",
16543 zebra_route_string(i
));
16545 vty_out(vty
, " %d", red
->instance
);
16546 if (red
->redist_metric_flag
)
16547 vty_out(vty
, " metric %u",
16548 red
->redist_metric
);
16549 if (red
->rmap
.name
)
16550 vty_out(vty
, " route-map %s",
16552 vty_out(vty
, "\n");
16558 /* peer-group helpers for config-write */
16560 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16562 if (!peer_group_active(peer
)) {
16563 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16564 return !CHECK_FLAG(peer
->flags
, flag
);
16566 return !!CHECK_FLAG(peer
->flags
, flag
);
16569 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16572 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16575 if (!peer_group_active(peer
)) {
16576 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16577 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16579 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16582 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16585 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16586 uint8_t type
, int direct
)
16588 struct bgp_filter
*filter
;
16590 if (peer_group_active(peer
))
16591 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16594 filter
= &peer
->filter
[afi
][safi
];
16596 case PEER_FT_DISTRIBUTE_LIST
:
16597 return !!(filter
->dlist
[direct
].name
);
16598 case PEER_FT_FILTER_LIST
:
16599 return !!(filter
->aslist
[direct
].name
);
16600 case PEER_FT_PREFIX_LIST
:
16601 return !!(filter
->plist
[direct
].name
);
16602 case PEER_FT_ROUTE_MAP
:
16603 return !!(filter
->map
[direct
].name
);
16604 case PEER_FT_UNSUPPRESS_MAP
:
16605 return !!(filter
->usmap
.name
);
16606 case PEER_FT_ADVERTISE_MAP
:
16607 return !!(filter
->advmap
.aname
16608 && ((filter
->advmap
.condition
== direct
)
16609 && filter
->advmap
.cname
));
16615 /* Return true if the addpath type is set for peer and different from
16618 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16621 enum bgp_addpath_strat type
, g_type
;
16623 type
= peer
->addpath_type
[afi
][safi
];
16625 if (type
!= BGP_ADDPATH_NONE
) {
16626 if (peer_group_active(peer
)) {
16627 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16629 if (type
!= g_type
)
16641 /* This is part of the address-family block (unicast only) */
16642 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16646 uint32_t tovpn_sid_index
= 0;
16648 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16649 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16650 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16651 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16652 bgp
->vpn_policy
[afi
]
16653 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16655 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16656 bgp
->vpn_policy
[afi
]
16657 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16659 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16660 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16661 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16662 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16665 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16666 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16668 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16671 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16672 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16673 bgp
->vpn_policy
[afi
].tovpn_label
);
16677 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16678 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16679 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16680 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16681 } else if (tovpn_sid_index
!= 0) {
16682 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16686 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16687 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16688 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16690 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16691 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16693 char buf
[PREFIX_STRLEN
];
16694 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16695 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16698 vty_out(vty
, "%*snexthop vpn export %s\n",
16702 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16703 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16705 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16706 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16708 char *b
= ecommunity_ecom2str(
16709 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16710 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16711 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16712 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16714 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16715 char *b
= ecommunity_ecom2str(
16716 bgp
->vpn_policy
[afi
]
16717 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16718 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16719 ECOMMUNITY_ROUTE_TARGET
);
16720 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16721 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16723 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16724 char *b
= ecommunity_ecom2str(
16725 bgp
->vpn_policy
[afi
]
16726 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16727 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16728 ECOMMUNITY_ROUTE_TARGET
);
16729 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16730 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16734 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16735 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16736 bgp
->vpn_policy
[afi
]
16737 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16739 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16740 char *b
= ecommunity_ecom2str(
16741 bgp
->vpn_policy
[afi
]
16742 .import_redirect_rtlist
,
16743 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16744 ECOMMUNITY_ROUTE_TARGET
);
16746 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16747 != ECOMMUNITY_SIZE
)
16748 vty_out(vty
, "%*srt6 redirect import %s\n",
16751 vty_out(vty
, "%*srt redirect import %s\n",
16753 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16757 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16758 afi_t afi
, safi_t safi
)
16760 struct bgp_filter
*filter
;
16764 filter
= &peer
->filter
[afi
][safi
];
16766 /* distribute-list. */
16767 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16769 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16770 filter
->dlist
[FILTER_IN
].name
);
16772 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16774 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16775 filter
->dlist
[FILTER_OUT
].name
);
16778 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16780 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16781 filter
->plist
[FILTER_IN
].name
);
16783 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16785 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16786 filter
->plist
[FILTER_OUT
].name
);
16789 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16790 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16791 filter
->map
[RMAP_IN
].name
);
16793 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16795 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16796 filter
->map
[RMAP_OUT
].name
);
16798 /* unsuppress-map */
16799 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16800 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16801 filter
->usmap
.name
);
16803 /* advertise-map : always applied in OUT direction*/
16804 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16805 CONDITION_NON_EXIST
))
16807 " neighbor %s advertise-map %s non-exist-map %s\n",
16808 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16810 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16812 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16813 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16816 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16818 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16819 filter
->aslist
[FILTER_IN
].name
);
16821 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16823 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16824 filter
->aslist
[FILTER_OUT
].name
);
16827 /* BGP peer configuration display function. */
16828 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16831 struct peer
*g_peer
= NULL
;
16833 int if_pg_printed
= false;
16834 int if_ras_printed
= false;
16836 /* Skip dynamic neighbors. */
16837 if (peer_dynamic_neighbor(peer
))
16841 addr
= peer
->conf_if
;
16845 /************************************
16846 ****** Global to the neighbor ******
16847 ************************************/
16848 if (peer
->conf_if
) {
16849 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16850 vty_out(vty
, " neighbor %s interface v6only", addr
);
16852 vty_out(vty
, " neighbor %s interface", addr
);
16854 if (peer_group_active(peer
)) {
16855 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16856 if_pg_printed
= true;
16857 } else if (peer
->as_type
== AS_SPECIFIED
) {
16858 vty_out(vty
, " remote-as %u", peer
->as
);
16859 if_ras_printed
= true;
16860 } else if (peer
->as_type
== AS_INTERNAL
) {
16861 vty_out(vty
, " remote-as internal");
16862 if_ras_printed
= true;
16863 } else if (peer
->as_type
== AS_EXTERNAL
) {
16864 vty_out(vty
, " remote-as external");
16865 if_ras_printed
= true;
16868 vty_out(vty
, "\n");
16871 /* remote-as and peer-group */
16872 /* peer is a member of a peer-group */
16873 if (peer_group_active(peer
)) {
16874 g_peer
= peer
->group
->conf
;
16876 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16877 if (peer
->as_type
== AS_SPECIFIED
) {
16878 vty_out(vty
, " neighbor %s remote-as %u\n",
16880 } else if (peer
->as_type
== AS_INTERNAL
) {
16882 " neighbor %s remote-as internal\n",
16884 } else if (peer
->as_type
== AS_EXTERNAL
) {
16886 " neighbor %s remote-as external\n",
16891 /* For swpX peers we displayed the peer-group
16892 * via 'neighbor swpX interface peer-group PGNAME' */
16893 if (!if_pg_printed
)
16894 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16895 peer
->group
->name
);
16898 /* peer is NOT a member of a peer-group */
16900 /* peer is a peer-group, declare the peer-group */
16901 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16902 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16905 if (!if_ras_printed
) {
16906 if (peer
->as_type
== AS_SPECIFIED
) {
16907 vty_out(vty
, " neighbor %s remote-as %u\n",
16909 } else if (peer
->as_type
== AS_INTERNAL
) {
16911 " neighbor %s remote-as internal\n",
16913 } else if (peer
->as_type
== AS_EXTERNAL
) {
16915 " neighbor %s remote-as external\n",
16922 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16923 vty_out(vty
, " neighbor %s local-as %u", addr
,
16924 peer
->change_local_as
);
16925 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16926 vty_out(vty
, " no-prepend");
16927 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16928 vty_out(vty
, " replace-as");
16929 vty_out(vty
, "\n");
16934 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16938 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16939 if (peer
->tx_shutdown_message
)
16940 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16941 peer
->tx_shutdown_message
);
16943 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16946 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16947 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16948 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16951 if (peer
->bfd_config
)
16952 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16955 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16956 vty_out(vty
, " neighbor %s password %s\n", addr
,
16959 /* neighbor solo */
16960 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16961 if (!peer_group_active(peer
)) {
16962 vty_out(vty
, " neighbor %s solo\n", addr
);
16967 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16968 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16971 /* Local interface name */
16972 if (peer
->ifname
) {
16973 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16976 /* TCP max segment size */
16977 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16978 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16981 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16982 vty_out(vty
, " neighbor %s passive\n", addr
);
16984 /* ebgp-multihop */
16985 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16986 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16987 && peer
->ttl
== MAXTTL
)) {
16988 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16989 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16995 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
16996 peer
->local_role
!= ROLE_UNDEFINED
)
16997 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
16998 bgp_get_name_by_role(peer
->local_role
),
16999 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17003 /* ttl-security hops */
17004 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17005 if (!peer_group_active(peer
)
17006 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17007 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17008 addr
, peer
->gtsm_hops
);
17012 /* disable-connected-check */
17013 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17014 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17016 /* link-bw-encoding-ieee */
17017 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17018 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17021 /* extended-optional-parameters */
17022 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17023 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17026 /* enforce-first-as */
17027 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17028 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17030 /* update-source */
17031 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17032 if (peer
->update_source
)
17033 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17034 peer
->update_source
);
17035 else if (peer
->update_if
)
17036 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17040 /* advertisement-interval */
17041 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17042 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17046 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17047 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17048 peer
->keepalive
, peer
->holdtime
);
17050 /* timers connect */
17051 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17052 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17054 /* need special-case handling for changed default values due to
17055 * config profile / version (because there is no "timers bgp connect"
17056 * command, we need to save this per-peer :/)
17058 else if (!peer_group_active(peer
) && !peer
->connect
&&
17059 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17060 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17061 peer
->bgp
->default_connect_retry
);
17063 /* timers delayopen */
17064 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17065 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17067 /* Save config even though flag is not set if default values have been
17070 else if (!peer_group_active(peer
) && !peer
->delayopen
17071 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17072 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17073 peer
->bgp
->default_delayopen
);
17075 /* capability dynamic */
17076 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17077 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17079 /* capability extended-nexthop */
17080 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17081 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17084 " no neighbor %s capability extended-nexthop\n",
17086 else if (!peer
->conf_if
)
17088 " neighbor %s capability extended-nexthop\n",
17092 /* dont-capability-negotiation */
17093 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17094 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17096 /* override-capability */
17097 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17098 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17100 /* strict-capability-match */
17101 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17102 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17104 /* Sender side AS path loop detection. */
17105 if (peer
->as_path_loop_detection
)
17106 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17109 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17110 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17112 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17113 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17115 " neighbor %s graceful-restart-helper\n", addr
);
17116 } else if (CHECK_FLAG(
17117 peer
->peer_gr_new_status_flag
,
17118 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17120 " neighbor %s graceful-restart\n", addr
);
17122 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17123 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17125 peer
->peer_gr_new_status_flag
,
17126 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17127 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17133 /* BGP peer configuration display function. */
17134 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17135 struct peer
*peer
, afi_t afi
, safi_t safi
)
17137 struct peer
*g_peer
= NULL
;
17139 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17141 /* Skip dynamic neighbors. */
17142 if (peer_dynamic_neighbor(peer
))
17146 addr
= peer
->conf_if
;
17150 /************************************
17151 ****** Per AF to the neighbor ******
17152 ************************************/
17153 if (peer_group_active(peer
)) {
17154 g_peer
= peer
->group
->conf
;
17156 /* If the peer-group is active but peer is not, print a 'no
17158 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17159 vty_out(vty
, " no neighbor %s activate\n", addr
);
17162 /* If the peer-group is not active but peer is, print an
17164 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17165 vty_out(vty
, " neighbor %s activate\n", addr
);
17168 if (peer
->afc
[afi
][safi
]) {
17169 if (safi
== SAFI_ENCAP
)
17170 vty_out(vty
, " neighbor %s activate\n", addr
);
17171 else if (!bgp
->default_af
[afi
][safi
])
17172 vty_out(vty
, " neighbor %s activate\n", addr
);
17174 if (bgp
->default_af
[afi
][safi
])
17175 vty_out(vty
, " no neighbor %s activate\n",
17180 /* addpath TX knobs */
17181 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17182 switch (peer
->addpath_type
[afi
][safi
]) {
17183 case BGP_ADDPATH_ALL
:
17184 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17187 case BGP_ADDPATH_BEST_PER_AS
:
17189 " neighbor %s addpath-tx-bestpath-per-AS\n",
17192 case BGP_ADDPATH_MAX
:
17193 case BGP_ADDPATH_NONE
:
17198 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17199 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17201 /* ORF capability. */
17202 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17203 || peergroup_af_flag_check(peer
, afi
, safi
,
17204 PEER_FLAG_ORF_PREFIX_RM
)) {
17205 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17207 if (peergroup_af_flag_check(peer
, afi
, safi
,
17208 PEER_FLAG_ORF_PREFIX_SM
)
17209 && peergroup_af_flag_check(peer
, afi
, safi
,
17210 PEER_FLAG_ORF_PREFIX_RM
))
17211 vty_out(vty
, " both");
17212 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17213 PEER_FLAG_ORF_PREFIX_SM
))
17214 vty_out(vty
, " send");
17216 vty_out(vty
, " receive");
17217 vty_out(vty
, "\n");
17220 /* Route reflector client. */
17221 if (peergroup_af_flag_check(peer
, afi
, safi
,
17222 PEER_FLAG_REFLECTOR_CLIENT
)) {
17223 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17226 /* next-hop-self force */
17227 if (peergroup_af_flag_check(peer
, afi
, safi
,
17228 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17229 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17232 /* next-hop-self */
17233 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17234 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17237 /* remove-private-AS */
17238 if (peergroup_af_flag_check(peer
, afi
, safi
,
17239 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17240 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17244 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17245 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17246 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17250 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17252 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17255 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17256 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17257 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17261 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17262 vty_out(vty
, " neighbor %s as-override\n", addr
);
17265 /* send-community print. */
17266 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17267 PEER_FLAG_SEND_COMMUNITY
);
17268 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17269 PEER_FLAG_SEND_EXT_COMMUNITY
);
17270 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17271 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17273 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17274 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17277 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17280 " no neighbor %s send-community extended\n",
17284 vty_out(vty
, " no neighbor %s send-community large\n",
17288 /* Default information */
17289 if (peergroup_af_flag_check(peer
, afi
, safi
,
17290 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17291 vty_out(vty
, " neighbor %s default-originate", addr
);
17293 if (peer
->default_rmap
[afi
][safi
].name
)
17294 vty_out(vty
, " route-map %s",
17295 peer
->default_rmap
[afi
][safi
].name
);
17297 vty_out(vty
, "\n");
17300 /* Soft reconfiguration inbound. */
17301 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17302 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17306 /* maximum-prefix. */
17307 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17308 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17309 peer
->pmax
[afi
][safi
]);
17311 if (peer
->pmax_threshold
[afi
][safi
]
17312 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17313 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17314 if (peer_af_flag_check(peer
, afi
, safi
,
17315 PEER_FLAG_MAX_PREFIX_WARNING
))
17316 vty_out(vty
, " warning-only");
17317 if (peer
->pmax_restart
[afi
][safi
])
17318 vty_out(vty
, " restart %u",
17319 peer
->pmax_restart
[afi
][safi
]);
17320 if (peer_af_flag_check(peer
, afi
, safi
,
17321 PEER_FLAG_MAX_PREFIX_FORCE
))
17322 vty_out(vty
, " force");
17324 vty_out(vty
, "\n");
17327 /* maximum-prefix-out */
17328 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17329 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17330 addr
, peer
->pmax_out
[afi
][safi
]);
17332 /* Route server client. */
17333 if (peergroup_af_flag_check(peer
, afi
, safi
,
17334 PEER_FLAG_RSERVER_CLIENT
)) {
17335 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17338 /* Nexthop-local unchanged. */
17339 if (peergroup_af_flag_check(peer
, afi
, safi
,
17340 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17341 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17344 /* allowas-in <1-10> */
17345 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17346 if (peer_af_flag_check(peer
, afi
, safi
,
17347 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17348 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17349 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17350 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17352 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17353 peer
->allowas_in
[afi
][safi
]);
17358 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17359 char *soo_str
= ecommunity_ecom2str(
17360 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17362 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17363 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17367 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17368 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17369 peer
->weight
[afi
][safi
]);
17372 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17374 /* atribute-unchanged. */
17375 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17376 || (safi
!= SAFI_EVPN
17377 && peer_af_flag_check(peer
, afi
, safi
,
17378 PEER_FLAG_NEXTHOP_UNCHANGED
))
17379 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17381 if (!peer_group_active(peer
)
17382 || peergroup_af_flag_check(peer
, afi
, safi
,
17383 PEER_FLAG_AS_PATH_UNCHANGED
)
17384 || peergroup_af_flag_check(peer
, afi
, safi
,
17385 PEER_FLAG_NEXTHOP_UNCHANGED
)
17386 || peergroup_af_flag_check(peer
, afi
, safi
,
17387 PEER_FLAG_MED_UNCHANGED
)) {
17390 " neighbor %s attribute-unchanged%s%s%s\n",
17392 peer_af_flag_check(peer
, afi
, safi
,
17393 PEER_FLAG_AS_PATH_UNCHANGED
)
17396 peer_af_flag_check(peer
, afi
, safi
,
17397 PEER_FLAG_NEXTHOP_UNCHANGED
)
17400 peer_af_flag_check(peer
, afi
, safi
,
17401 PEER_FLAG_MED_UNCHANGED
)
17407 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
17408 vty_out(vty
, " neighbor %s optimal-route-reflection %s\n",
17409 addr
, peer
->orr_group_name
[afi
][safi
]);
17412 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17415 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17416 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17417 vty_out(vty
, " no bgp retain route-target all\n");
17420 /* Address family based peer configuration display. */
17421 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17425 struct peer_group
*group
;
17426 struct listnode
*node
, *nnode
;
17429 vty_frame(vty
, " !\n address-family ");
17430 if (afi
== AFI_IP
) {
17431 if (safi
== SAFI_UNICAST
)
17432 vty_frame(vty
, "ipv4 unicast");
17433 else if (safi
== SAFI_LABELED_UNICAST
)
17434 vty_frame(vty
, "ipv4 labeled-unicast");
17435 else if (safi
== SAFI_MULTICAST
)
17436 vty_frame(vty
, "ipv4 multicast");
17437 else if (safi
== SAFI_MPLS_VPN
)
17438 vty_frame(vty
, "ipv4 vpn");
17439 else if (safi
== SAFI_ENCAP
)
17440 vty_frame(vty
, "ipv4 encap");
17441 else if (safi
== SAFI_FLOWSPEC
)
17442 vty_frame(vty
, "ipv4 flowspec");
17443 } else if (afi
== AFI_IP6
) {
17444 if (safi
== SAFI_UNICAST
)
17445 vty_frame(vty
, "ipv6 unicast");
17446 else if (safi
== SAFI_LABELED_UNICAST
)
17447 vty_frame(vty
, "ipv6 labeled-unicast");
17448 else if (safi
== SAFI_MULTICAST
)
17449 vty_frame(vty
, "ipv6 multicast");
17450 else if (safi
== SAFI_MPLS_VPN
)
17451 vty_frame(vty
, "ipv6 vpn");
17452 else if (safi
== SAFI_ENCAP
)
17453 vty_frame(vty
, "ipv6 encap");
17454 else if (safi
== SAFI_FLOWSPEC
)
17455 vty_frame(vty
, "ipv6 flowspec");
17456 } else if (afi
== AFI_L2VPN
) {
17457 if (safi
== SAFI_EVPN
)
17458 vty_frame(vty
, "l2vpn evpn");
17460 vty_frame(vty
, "\n");
17462 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17464 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17466 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17468 /* BGP flag dampening. */
17469 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17470 bgp_config_write_damp(vty
, afi
, safi
);
17472 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17473 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17475 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17476 /* Do not display doppelganger peers */
17477 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17478 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17481 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17482 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17484 if (safi
== SAFI_EVPN
)
17485 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17487 if (safi
== SAFI_FLOWSPEC
)
17488 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17490 if (safi
== SAFI_MPLS_VPN
)
17491 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17493 if (safi
== SAFI_UNICAST
) {
17494 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17495 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17496 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17498 vty_out(vty
, " export vpn\n");
17500 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17501 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17503 vty_out(vty
, " import vpn\n");
17505 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17506 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17509 for (ALL_LIST_ELEMENTS_RO(
17510 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17512 vty_out(vty
, " import vrf %s\n", name
);
17516 /* Optimal Route Reflection */
17517 bgp_config_write_orr(vty
, bgp
, afi
, safi
);
17519 vty_endframe(vty
, " exit-address-family\n");
17522 int bgp_config_write(struct vty
*vty
)
17525 struct peer_group
*group
;
17527 struct listnode
*node
, *nnode
;
17528 struct listnode
*mnode
, *mnnode
;
17532 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17533 vty_out(vty
, "bgp route-map delay-timer %u\n",
17534 bm
->rmap_update_timer
);
17536 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17537 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17538 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17539 vty_out(vty
, " %d", bm
->v_establish_wait
);
17540 vty_out(vty
, "\n");
17543 if (bm
->wait_for_fib
)
17544 vty_out(vty
, "bgp suppress-fib-pending\n");
17546 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17547 vty_out(vty
, "bgp graceful-shutdown\n");
17549 /* No-RIB (Zebra) option flag configuration */
17550 if (bgp_option_check(BGP_OPT_NO_FIB
))
17551 vty_out(vty
, "bgp no-rib\n");
17553 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17554 vty_out(vty
, "bgp send-extra-data zebra\n");
17556 /* BGP session DSCP value */
17557 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17558 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17560 /* BGP configuration. */
17561 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17563 /* skip all auto created vrf as they dont have user config */
17564 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17567 /* Router bgp ASN */
17568 vty_out(vty
, "router bgp %u", bgp
->as
);
17571 vty_out(vty
, " %s %s",
17572 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17573 ? "view" : "vrf", bgp
->name
);
17574 vty_out(vty
, "\n");
17576 /* BGP fast-external-failover. */
17577 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17578 vty_out(vty
, " no bgp fast-external-failover\n");
17580 /* BGP router ID. */
17581 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17582 vty_out(vty
, " bgp router-id %pI4\n",
17583 &bgp
->router_id_static
);
17585 /* Suppress fib pending */
17586 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17587 vty_out(vty
, " bgp suppress-fib-pending\n");
17589 /* BGP log-neighbor-changes. */
17590 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17591 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17592 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17593 CHECK_FLAG(bgp
->flags
,
17594 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17598 /* BGP configuration. */
17599 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17600 vty_out(vty
, " bgp always-compare-med\n");
17602 /* RFC8212 default eBGP policy. */
17603 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17604 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17605 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17606 CHECK_FLAG(bgp
->flags
,
17607 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17611 /* draft-ietf-idr-deprecate-as-set-confed-set */
17612 if (bgp
->reject_as_sets
)
17613 vty_out(vty
, " bgp reject-as-sets\n");
17615 /* Suppress duplicate updates if the route actually not changed
17617 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17618 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17619 vty_out(vty
, " %sbgp suppress-duplicates\n",
17620 CHECK_FLAG(bgp
->flags
,
17621 BGP_FLAG_SUPPRESS_DUPLICATES
)
17625 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17627 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17628 SAVE_BGP_HARD_ADMIN_RESET
)
17629 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17630 CHECK_FLAG(bgp
->flags
,
17631 BGP_FLAG_HARD_ADMIN_RESET
)
17635 /* BGP default <afi>-<safi> */
17636 FOREACH_AFI_SAFI (afi
, safi
) {
17637 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17638 if (!bgp
->default_af
[afi
][safi
])
17639 vty_out(vty
, " no bgp default %s\n",
17640 get_bgp_default_af_flag(afi
,
17642 } else if (bgp
->default_af
[afi
][safi
])
17643 vty_out(vty
, " bgp default %s\n",
17644 get_bgp_default_af_flag(afi
, safi
));
17647 /* BGP default local-preference. */
17648 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17649 vty_out(vty
, " bgp default local-preference %u\n",
17650 bgp
->default_local_pref
);
17652 /* BGP default show-hostname */
17653 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17654 != SAVE_BGP_SHOW_HOSTNAME
)
17655 vty_out(vty
, " %sbgp default show-hostname\n",
17656 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17660 /* BGP default show-nexthop-hostname */
17661 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17662 != SAVE_BGP_SHOW_HOSTNAME
)
17663 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17664 CHECK_FLAG(bgp
->flags
,
17665 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17669 /* BGP default subgroup-pkt-queue-max. */
17670 if (bgp
->default_subgroup_pkt_queue_max
17671 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17672 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17673 bgp
->default_subgroup_pkt_queue_max
);
17675 /* BGP client-to-client reflection. */
17676 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17677 vty_out(vty
, " no bgp client-to-client reflection\n");
17679 /* BGP cluster ID. */
17680 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17681 vty_out(vty
, " bgp cluster-id %pI4\n",
17684 /* Disable ebgp connected nexthop check */
17685 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17687 " bgp disable-ebgp-connected-route-check\n");
17689 /* Confederation identifier*/
17690 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17691 vty_out(vty
, " bgp confederation identifier %u\n",
17694 /* Confederation peer */
17695 if (bgp
->confed_peers_cnt
> 0) {
17698 vty_out(vty
, " bgp confederation peers");
17700 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17701 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17703 vty_out(vty
, "\n");
17706 /* BGP deterministic-med. */
17707 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17708 != SAVE_BGP_DETERMINISTIC_MED
)
17709 vty_out(vty
, " %sbgp deterministic-med\n",
17710 CHECK_FLAG(bgp
->flags
,
17711 BGP_FLAG_DETERMINISTIC_MED
)
17715 /* BGP update-delay. */
17716 bgp_config_write_update_delay(vty
, bgp
);
17718 if (bgp
->v_maxmed_onstartup
17719 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17720 vty_out(vty
, " bgp max-med on-startup %u",
17721 bgp
->v_maxmed_onstartup
);
17722 if (bgp
->maxmed_onstartup_value
17723 != BGP_MAXMED_VALUE_DEFAULT
)
17724 vty_out(vty
, " %u",
17725 bgp
->maxmed_onstartup_value
);
17726 vty_out(vty
, "\n");
17728 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17729 vty_out(vty
, " bgp max-med administrative");
17730 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17731 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17732 vty_out(vty
, "\n");
17736 bgp_config_write_wpkt_quanta(vty
, bgp
);
17738 bgp_config_write_rpkt_quanta(vty
, bgp
);
17740 /* coalesce time */
17741 bgp_config_write_coalesce_time(vty
, bgp
);
17743 /* BGP per-instance graceful-shutdown */
17744 /* BGP-wide settings and per-instance settings are mutually
17747 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17748 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17749 vty_out(vty
, " bgp graceful-shutdown\n");
17751 /* Long-lived Graceful Restart */
17752 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17754 " bgp long-lived-graceful-restart stale-time %u\n",
17755 bgp
->llgr_stale_time
);
17757 /* BGP graceful-restart. */
17758 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17760 " bgp graceful-restart stalepath-time %u\n",
17761 bgp
->stalepath_time
);
17763 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17764 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17765 bgp
->restart_time
);
17767 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17768 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17769 vty_out(vty
, " %sbgp graceful-restart notification\n",
17770 CHECK_FLAG(bgp
->flags
,
17771 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17775 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17777 " bgp graceful-restart select-defer-time %u\n",
17778 bgp
->select_defer_time
);
17780 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17781 vty_out(vty
, " bgp graceful-restart\n");
17783 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17784 vty_out(vty
, " bgp graceful-restart-disable\n");
17786 /* BGP graceful-restart Preserve State F bit. */
17787 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17789 " bgp graceful-restart preserve-fw-state\n");
17791 /* BGP TCP keepalive */
17792 bgp_config_tcp_keepalive(vty
, bgp
);
17794 /* Stale timer for RIB */
17795 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17797 " bgp graceful-restart rib-stale-time %u\n",
17798 bgp
->rib_stale_time
);
17800 /* BGP bestpath method. */
17801 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17802 vty_out(vty
, " bgp bestpath as-path ignore\n");
17803 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17804 vty_out(vty
, " bgp bestpath as-path confed\n");
17806 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17807 if (CHECK_FLAG(bgp
->flags
,
17808 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17810 " bgp bestpath as-path multipath-relax as-set\n");
17813 " bgp bestpath as-path multipath-relax\n");
17817 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17819 " bgp route-reflector allow-outbound-policy\n");
17821 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17822 vty_out(vty
, " bgp bestpath compare-routerid\n");
17823 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17824 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17825 vty_out(vty
, " bgp bestpath med");
17826 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17827 vty_out(vty
, " confed");
17828 if (CHECK_FLAG(bgp
->flags
,
17829 BGP_FLAG_MED_MISSING_AS_WORST
))
17830 vty_out(vty
, " missing-as-worst");
17831 vty_out(vty
, "\n");
17834 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17836 " bgp bestpath peer-type multipath-relax\n");
17838 /* Link bandwidth handling. */
17839 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17840 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17841 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17842 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17843 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17844 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17846 /* BGP network import check. */
17847 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17848 != SAVE_BGP_IMPORT_CHECK
)
17849 vty_out(vty
, " %sbgp network import-check\n",
17850 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17854 /* BGP timers configuration. */
17855 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17856 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17857 vty_out(vty
, " timers bgp %u %u\n",
17858 bgp
->default_keepalive
, bgp
->default_holdtime
);
17860 /* BGP minimum holdtime configuration. */
17861 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17862 && bgp
->default_min_holdtime
!= 0)
17863 vty_out(vty
, " bgp minimum-holdtime %u\n",
17864 bgp
->default_min_holdtime
);
17866 /* Conditional advertisement timer configuration */
17867 if (bgp
->condition_check_period
17868 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17870 " bgp conditional-advertisement timer %u\n",
17871 bgp
->condition_check_period
);
17874 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17875 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17878 /* Normal neighbor configuration. */
17879 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17880 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17881 bgp_config_write_peer_global(vty
, bgp
, peer
);
17884 /* listen range and limit for dynamic BGP neighbors */
17885 bgp_config_write_listen(vty
, bgp
);
17888 * BGP default autoshutdown neighbors
17890 * This must be placed after any peer and peer-group
17891 * configuration, to avoid setting all peers to shutdown after
17892 * a daemon restart, which is undesired behavior. (see #2286)
17894 if (bgp
->autoshutdown
)
17895 vty_out(vty
, " bgp default shutdown\n");
17897 /* BGP instance administrative shutdown */
17898 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17899 vty_out(vty
, " bgp shutdown\n");
17901 if (bgp
->allow_martian
)
17902 vty_out(vty
, " bgp allow-martian-nexthop\n");
17904 if (bgp
->fast_convergence
)
17905 vty_out(vty
, " bgp fast-convergence\n");
17907 if (bgp
->srv6_enabled
) {
17908 vty_frame(vty
, " !\n segment-routing srv6\n");
17909 if (strlen(bgp
->srv6_locator_name
))
17910 vty_out(vty
, " locator %s\n",
17911 bgp
->srv6_locator_name
);
17912 vty_endframe(vty
, " exit\n");
17916 /* IPv4 unicast configuration. */
17917 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17919 /* IPv4 multicast configuration. */
17920 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17922 /* IPv4 labeled-unicast configuration. */
17923 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17925 /* IPv4 VPN configuration. */
17926 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17928 /* ENCAPv4 configuration. */
17929 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17931 /* FLOWSPEC v4 configuration. */
17932 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17934 /* IPv6 unicast configuration. */
17935 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17937 /* IPv6 multicast configuration. */
17938 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17940 /* IPv6 labeled-unicast configuration. */
17941 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17942 SAFI_LABELED_UNICAST
);
17944 /* IPv6 VPN configuration. */
17945 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17947 /* ENCAPv6 configuration. */
17948 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17950 /* FLOWSPEC v6 configuration. */
17951 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17953 /* EVPN configuration. */
17954 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17956 hook_call(bgp_inst_config_write
, bgp
, vty
);
17958 #ifdef ENABLE_BGP_VNC
17959 bgp_rfapi_cfg_write(vty
, bgp
);
17962 vty_out(vty
, "exit\n");
17963 vty_out(vty
, "!\n");
17969 /* BGP node structure. */
17970 static struct cmd_node bgp_node
= {
17973 .parent_node
= CONFIG_NODE
,
17974 .prompt
= "%s(config-router)# ",
17975 .config_write
= bgp_config_write
,
17978 static struct cmd_node bgp_ipv4_unicast_node
= {
17979 .name
= "bgp ipv4 unicast",
17980 .node
= BGP_IPV4_NODE
,
17981 .parent_node
= BGP_NODE
,
17982 .prompt
= "%s(config-router-af)# ",
17986 static struct cmd_node bgp_ipv4_multicast_node
= {
17987 .name
= "bgp ipv4 multicast",
17988 .node
= BGP_IPV4M_NODE
,
17989 .parent_node
= BGP_NODE
,
17990 .prompt
= "%s(config-router-af)# ",
17994 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17995 .name
= "bgp ipv4 labeled unicast",
17996 .node
= BGP_IPV4L_NODE
,
17997 .parent_node
= BGP_NODE
,
17998 .prompt
= "%s(config-router-af)# ",
18002 static struct cmd_node bgp_ipv6_unicast_node
= {
18003 .name
= "bgp ipv6 unicast",
18004 .node
= BGP_IPV6_NODE
,
18005 .parent_node
= BGP_NODE
,
18006 .prompt
= "%s(config-router-af)# ",
18010 static struct cmd_node bgp_ipv6_multicast_node
= {
18011 .name
= "bgp ipv6 multicast",
18012 .node
= BGP_IPV6M_NODE
,
18013 .parent_node
= BGP_NODE
,
18014 .prompt
= "%s(config-router-af)# ",
18018 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18019 .name
= "bgp ipv6 labeled unicast",
18020 .node
= BGP_IPV6L_NODE
,
18021 .parent_node
= BGP_NODE
,
18022 .prompt
= "%s(config-router-af)# ",
18026 static struct cmd_node bgp_vpnv4_node
= {
18027 .name
= "bgp vpnv4",
18028 .node
= BGP_VPNV4_NODE
,
18029 .parent_node
= BGP_NODE
,
18030 .prompt
= "%s(config-router-af)# ",
18034 static struct cmd_node bgp_vpnv6_node
= {
18035 .name
= "bgp vpnv6",
18036 .node
= BGP_VPNV6_NODE
,
18037 .parent_node
= BGP_NODE
,
18038 .prompt
= "%s(config-router-af-vpnv6)# ",
18042 static struct cmd_node bgp_evpn_node
= {
18043 .name
= "bgp evpn",
18044 .node
= BGP_EVPN_NODE
,
18045 .parent_node
= BGP_NODE
,
18046 .prompt
= "%s(config-router-evpn)# ",
18050 static struct cmd_node bgp_evpn_vni_node
= {
18051 .name
= "bgp evpn vni",
18052 .node
= BGP_EVPN_VNI_NODE
,
18053 .parent_node
= BGP_EVPN_NODE
,
18054 .prompt
= "%s(config-router-af-vni)# ",
18057 static struct cmd_node bgp_flowspecv4_node
= {
18058 .name
= "bgp ipv4 flowspec",
18059 .node
= BGP_FLOWSPECV4_NODE
,
18060 .parent_node
= BGP_NODE
,
18061 .prompt
= "%s(config-router-af)# ",
18065 static struct cmd_node bgp_flowspecv6_node
= {
18066 .name
= "bgp ipv6 flowspec",
18067 .node
= BGP_FLOWSPECV6_NODE
,
18068 .parent_node
= BGP_NODE
,
18069 .prompt
= "%s(config-router-af-vpnv6)# ",
18073 static struct cmd_node bgp_srv6_node
= {
18074 .name
= "bgp srv6",
18075 .node
= BGP_SRV6_NODE
,
18076 .parent_node
= BGP_NODE
,
18077 .prompt
= "%s(config-router-srv6)# ",
18080 static void community_list_vty(void);
18082 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18085 struct peer_group
*group
;
18086 struct listnode
*lnbgp
, *lnpeer
;
18088 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18089 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18091 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18095 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18099 struct listnode
*lnbgp
, *lnpeer
;
18101 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18102 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18103 /* only provide suggestions on the appropriate input
18105 * they'll otherwise show up multiple times */
18106 enum cmd_token_type match_type
;
18107 char *name
= peer
->host
;
18109 if (peer
->conf_if
) {
18110 match_type
= VARIABLE_TKN
;
18111 name
= peer
->conf_if
;
18112 } else if (strchr(peer
->host
, ':'))
18113 match_type
= IPV6_TKN
;
18115 match_type
= IPV4_TKN
;
18117 if (token
->type
!= match_type
)
18120 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18125 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18127 bgp_ac_peer(comps
, token
);
18129 if (token
->type
== VARIABLE_TKN
)
18130 bgp_ac_peergroup(comps
, token
);
18133 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18134 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18135 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18136 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18137 {.completions
= NULL
}};
18139 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18140 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18141 {.completions
= NULL
} };
18143 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18145 static struct thread
*t_bgp_cfg
;
18147 bool bgp_config_inprocess(void)
18149 return thread_is_scheduled(t_bgp_cfg
);
18152 static void bgp_config_finish(struct thread
*t
)
18154 struct listnode
*node
;
18157 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18158 hook_call(bgp_config_end
, bgp
);
18161 static void bgp_config_start(void)
18163 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18164 THREAD_OFF(t_bgp_cfg
);
18165 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18166 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18169 /* When we receive a hook the configuration is read,
18170 * we start a timer to make sure we postpone sending
18171 * EoR before route-maps are processed.
18172 * This is especially valid if using `bgp route-map delay-timer`.
18174 static void bgp_config_end(void)
18176 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18177 uint32_t bgp_post_config_delay
=
18178 thread_is_scheduled(bm
->t_rmap_update
)
18179 ? thread_timer_remain_second(bm
->t_rmap_update
)
18180 : BGP_POST_CONFIG_DELAY_SECONDS
;
18182 /* If BGP config processing thread isn't running, then
18183 * we can return and rely it's properly handled.
18185 if (!bgp_config_inprocess())
18188 THREAD_OFF(t_bgp_cfg
);
18190 /* Start a new timer to make sure we don't send EoR
18191 * before route-maps are processed.
18193 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18194 bgp_post_config_delay
, &t_bgp_cfg
);
18197 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18200 struct interface
*ifp
;
18201 struct bgp_interface
*iifp
;
18203 FOR_ALL_INTERFACES (vrf
, ifp
) {
18208 if_vty_config_start(vty
, ifp
);
18210 if (CHECK_FLAG(iifp
->flags
,
18211 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18212 vty_out(vty
, " mpls bgp forwarding\n");
18216 if_vty_config_end(vty
);
18222 /* Configuration write function for bgpd. */
18223 static int config_write_interface(struct vty
*vty
)
18226 struct vrf
*vrf
= NULL
;
18228 /* Display all VRF aware OSPF interface configuration */
18229 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18230 write
+= config_write_interface_one(vty
, vrf
);
18236 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18237 "[no$no] mpls bgp forwarding",
18238 NO_STR MPLS_STR BGP_STR
18239 "Enable MPLS forwarding for eBGP directly connected peers\n")
18242 struct bgp_interface
*iifp
;
18244 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18247 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18248 return CMD_WARNING_CONFIG_FAILED
;
18250 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18251 if (check
!= !no
) {
18253 UNSET_FLAG(iifp
->flags
,
18254 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18256 SET_FLAG(iifp
->flags
,
18257 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18258 /* trigger a nht update on eBGP sessions */
18259 if (if_is_operative(ifp
))
18260 bgp_nht_ifp_up(ifp
);
18262 return CMD_SUCCESS
;
18265 /* Initialization of BGP interface. */
18266 static void bgp_vty_if_init(void)
18268 /* Install interface node. */
18269 if_cmd_init(config_write_interface
);
18271 /* "mpls bgp forwarding" commands. */
18272 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18275 void bgp_vty_init(void)
18277 cmd_variable_handler_register(bgp_var_neighbor
);
18278 cmd_variable_handler_register(bgp_var_peergroup
);
18280 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18282 /* Install bgp top node. */
18283 install_node(&bgp_node
);
18284 install_node(&bgp_ipv4_unicast_node
);
18285 install_node(&bgp_ipv4_multicast_node
);
18286 install_node(&bgp_ipv4_labeled_unicast_node
);
18287 install_node(&bgp_ipv6_unicast_node
);
18288 install_node(&bgp_ipv6_multicast_node
);
18289 install_node(&bgp_ipv6_labeled_unicast_node
);
18290 install_node(&bgp_vpnv4_node
);
18291 install_node(&bgp_vpnv6_node
);
18292 install_node(&bgp_evpn_node
);
18293 install_node(&bgp_evpn_vni_node
);
18294 install_node(&bgp_flowspecv4_node
);
18295 install_node(&bgp_flowspecv6_node
);
18296 install_node(&bgp_srv6_node
);
18298 /* Install default VTY commands to new nodes. */
18299 install_default(BGP_NODE
);
18300 install_default(BGP_IPV4_NODE
);
18301 install_default(BGP_IPV4M_NODE
);
18302 install_default(BGP_IPV4L_NODE
);
18303 install_default(BGP_IPV6_NODE
);
18304 install_default(BGP_IPV6M_NODE
);
18305 install_default(BGP_IPV6L_NODE
);
18306 install_default(BGP_VPNV4_NODE
);
18307 install_default(BGP_VPNV6_NODE
);
18308 install_default(BGP_FLOWSPECV4_NODE
);
18309 install_default(BGP_FLOWSPECV6_NODE
);
18310 install_default(BGP_EVPN_NODE
);
18311 install_default(BGP_EVPN_VNI_NODE
);
18312 install_default(BGP_SRV6_NODE
);
18314 /* "bgp local-mac" hidden commands. */
18315 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18316 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18318 /* "bgp suppress-fib-pending" global */
18319 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18321 /* bgp route-map delay-timer commands. */
18322 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18323 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18325 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18327 /* bgp fast-convergence command */
18328 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18329 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18331 /* global bgp update-delay command */
18332 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18333 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18335 /* global bgp graceful-shutdown command */
18336 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18337 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18339 /* Dummy commands (Currently not supported) */
18340 install_element(BGP_NODE
, &no_synchronization_cmd
);
18341 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18343 /* "router bgp" commands. */
18344 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18346 /* "no router bgp" commands. */
18347 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18349 /* "bgp session-dscp command */
18350 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18351 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18353 /* "bgp router-id" commands. */
18354 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18355 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18357 /* "bgp suppress-fib-pending" command */
18358 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18360 /* "bgp cluster-id" commands. */
18361 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18362 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18364 /* "bgp no-rib" commands. */
18365 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18366 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18368 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18370 /* "bgp confederation" commands. */
18371 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18372 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18374 /* "bgp confederation peers" commands. */
18375 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18376 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18378 /* bgp max-med command */
18379 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18380 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18381 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18382 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18383 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18385 /* "neighbor role" commands. */
18386 install_element(BGP_NODE
, &neighbor_role_cmd
);
18387 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18388 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18390 /* bgp disable-ebgp-connected-nh-check */
18391 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18392 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18394 /* bgp update-delay command */
18395 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18396 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18398 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18399 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18401 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18402 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18404 /* "maximum-paths" commands. */
18405 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18406 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18407 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18408 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18409 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18410 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18411 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18412 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18413 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18414 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18415 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18416 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18417 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18418 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18419 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18421 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18422 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18423 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18424 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18425 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18426 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18427 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18428 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18429 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18430 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18432 /* "timers bgp" commands. */
18433 install_element(BGP_NODE
, &bgp_timers_cmd
);
18434 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18436 /* "minimum-holdtime" commands. */
18437 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18438 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18440 /* route-map delay-timer commands - per instance for backwards compat.
18442 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18443 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18445 /* "bgp client-to-client reflection" commands */
18446 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18447 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18449 /* "bgp always-compare-med" commands */
18450 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18451 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18453 /* bgp ebgp-requires-policy */
18454 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18455 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18457 /* bgp suppress-duplicates */
18458 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18459 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18461 /* bgp reject-as-sets */
18462 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18463 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18465 /* "bgp deterministic-med" commands */
18466 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18467 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18469 /* "bgp graceful-restart" command */
18470 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18471 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18473 /* "bgp graceful-restart-disable" command */
18474 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18475 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18477 /* "neighbor a:b:c:d graceful-restart" command */
18478 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18479 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18481 /* "neighbor a:b:c:d graceful-restart-disable" command */
18482 install_element(BGP_NODE
,
18483 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18484 install_element(BGP_NODE
,
18485 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18487 /* "neighbor a:b:c:d graceful-restart-helper" command */
18488 install_element(BGP_NODE
,
18489 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18490 install_element(BGP_NODE
,
18491 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18493 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18494 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18495 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18496 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18497 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18498 install_element(BGP_NODE
,
18499 &no_bgp_graceful_restart_select_defer_time_cmd
);
18500 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18501 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18502 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18504 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18505 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18506 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18507 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18509 /* "bgp graceful-shutdown" commands */
18510 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18511 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18513 /* "bgp hard-administrative-reset" commands */
18514 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18516 /* "bgp long-lived-graceful-restart" commands */
18517 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18518 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18520 /* "bgp fast-external-failover" commands */
18521 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18522 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18524 /* "bgp bestpath compare-routerid" commands */
18525 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18526 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18528 /* "bgp bestpath as-path ignore" commands */
18529 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18530 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18532 /* "bgp bestpath as-path confed" commands */
18533 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18534 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18536 /* "bgp bestpath as-path multipath-relax" commands */
18537 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18538 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18540 /* "bgp bestpath peer-type multipath-relax" commands */
18541 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18542 install_element(BGP_NODE
,
18543 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18545 /* "bgp log-neighbor-changes" commands */
18546 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18547 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18549 /* "bgp bestpath med" commands */
18550 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18551 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18553 /* "bgp bestpath bandwidth" commands */
18554 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18555 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18557 /* "no bgp default <afi>-<safi>" commands. */
18558 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18560 /* "bgp network import-check" commands. */
18561 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18562 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18563 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18565 /* "bgp default local-preference" commands. */
18566 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18567 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18569 /* bgp default show-hostname */
18570 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18571 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18573 /* bgp default show-nexthop-hostname */
18574 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18575 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18577 /* "bgp default subgroup-pkt-queue-max" commands. */
18578 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18579 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18581 /* bgp ibgp-allow-policy-mods command */
18582 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18583 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18585 /* "bgp listen limit" commands. */
18586 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18587 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18589 /* "bgp listen range" commands. */
18590 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18591 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18593 /* "bgp default shutdown" command */
18594 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18596 /* "bgp shutdown" commands */
18597 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18598 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18599 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18600 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18602 /* "neighbor remote-as" commands. */
18603 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18604 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18605 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18606 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18607 install_element(BGP_NODE
,
18608 &neighbor_interface_v6only_config_remote_as_cmd
);
18609 install_element(BGP_NODE
, &no_neighbor_cmd
);
18610 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18612 /* "neighbor peer-group" commands. */
18613 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18614 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18615 install_element(BGP_NODE
,
18616 &no_neighbor_interface_peer_group_remote_as_cmd
);
18618 /* "neighbor local-as" commands. */
18619 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18620 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18621 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18622 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18624 /* "neighbor solo" commands. */
18625 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18626 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18628 /* "neighbor password" commands. */
18629 install_element(BGP_NODE
, &neighbor_password_cmd
);
18630 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18632 /* "neighbor activate" commands. */
18633 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18634 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18635 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18636 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18637 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18638 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18639 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18640 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18641 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18642 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18643 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18644 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18646 /* "no neighbor activate" commands. */
18647 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18648 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18649 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18650 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18651 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18652 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18653 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18654 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18655 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18656 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18657 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18658 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18660 /* "neighbor peer-group" set commands. */
18661 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18662 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18663 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18664 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18665 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18666 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18667 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18668 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18669 install_element(BGP_FLOWSPECV4_NODE
,
18670 &neighbor_set_peer_group_hidden_cmd
);
18671 install_element(BGP_FLOWSPECV6_NODE
,
18672 &neighbor_set_peer_group_hidden_cmd
);
18674 /* "no neighbor peer-group unset" commands. */
18675 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18676 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18677 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18678 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18679 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18680 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18681 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18682 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18683 install_element(BGP_FLOWSPECV4_NODE
,
18684 &no_neighbor_set_peer_group_hidden_cmd
);
18685 install_element(BGP_FLOWSPECV6_NODE
,
18686 &no_neighbor_set_peer_group_hidden_cmd
);
18688 /* "neighbor softreconfiguration inbound" commands.*/
18689 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18690 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18691 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18692 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18693 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18694 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18695 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18696 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18697 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18698 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18699 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18700 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18701 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18702 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18703 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18704 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18705 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18706 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18707 install_element(BGP_FLOWSPECV4_NODE
,
18708 &neighbor_soft_reconfiguration_cmd
);
18709 install_element(BGP_FLOWSPECV4_NODE
,
18710 &no_neighbor_soft_reconfiguration_cmd
);
18711 install_element(BGP_FLOWSPECV6_NODE
,
18712 &neighbor_soft_reconfiguration_cmd
);
18713 install_element(BGP_FLOWSPECV6_NODE
,
18714 &no_neighbor_soft_reconfiguration_cmd
);
18715 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18716 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18718 /* "neighbor attribute-unchanged" commands. */
18719 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18720 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18721 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18722 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18723 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18724 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18725 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18726 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18727 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18728 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18729 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18730 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18731 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18732 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18733 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18734 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18735 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18736 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18738 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18739 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18741 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18742 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18743 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18744 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18746 /* "nexthop-local unchanged" commands */
18747 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18748 install_element(BGP_IPV6_NODE
,
18749 &no_neighbor_nexthop_local_unchanged_cmd
);
18751 /* "neighbor next-hop-self" commands. */
18752 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18753 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18754 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18755 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18756 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18757 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18758 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18759 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18760 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18761 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18762 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18763 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18764 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18765 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18766 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18767 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18768 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18769 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18770 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18771 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18773 /* "neighbor next-hop-self force" commands. */
18774 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18775 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18776 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18777 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18778 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18779 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18780 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18781 install_element(BGP_IPV4_NODE
,
18782 &no_neighbor_nexthop_self_all_hidden_cmd
);
18783 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18784 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18785 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18786 install_element(BGP_IPV4M_NODE
,
18787 &no_neighbor_nexthop_self_all_hidden_cmd
);
18788 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18789 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18790 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18791 install_element(BGP_IPV4L_NODE
,
18792 &no_neighbor_nexthop_self_all_hidden_cmd
);
18793 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18794 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18795 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18796 install_element(BGP_IPV6_NODE
,
18797 &no_neighbor_nexthop_self_all_hidden_cmd
);
18798 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18799 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18800 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18801 install_element(BGP_IPV6M_NODE
,
18802 &no_neighbor_nexthop_self_all_hidden_cmd
);
18803 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18804 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18805 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18806 install_element(BGP_IPV6L_NODE
,
18807 &no_neighbor_nexthop_self_all_hidden_cmd
);
18808 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18809 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18810 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18811 install_element(BGP_VPNV4_NODE
,
18812 &no_neighbor_nexthop_self_all_hidden_cmd
);
18813 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18814 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18815 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18816 install_element(BGP_VPNV6_NODE
,
18817 &no_neighbor_nexthop_self_all_hidden_cmd
);
18818 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18819 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18821 /* "neighbor as-override" commands. */
18822 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18823 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18824 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18825 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18826 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18827 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18828 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18829 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18830 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18831 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18832 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18833 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18834 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18835 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18836 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18837 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18838 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18839 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18841 /* "neighbor remove-private-AS" commands. */
18842 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18843 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18844 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18845 install_element(BGP_NODE
,
18846 &no_neighbor_remove_private_as_all_hidden_cmd
);
18847 install_element(BGP_NODE
,
18848 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18849 install_element(BGP_NODE
,
18850 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18851 install_element(BGP_NODE
,
18852 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18855 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18856 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18857 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18858 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18859 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18860 install_element(BGP_IPV4_NODE
,
18861 &neighbor_remove_private_as_replace_as_cmd
);
18862 install_element(BGP_IPV4_NODE
,
18863 &no_neighbor_remove_private_as_replace_as_cmd
);
18864 install_element(BGP_IPV4_NODE
,
18865 &neighbor_remove_private_as_all_replace_as_cmd
);
18866 install_element(BGP_IPV4_NODE
,
18867 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18868 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18869 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18870 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18871 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18872 install_element(BGP_IPV4M_NODE
,
18873 &neighbor_remove_private_as_replace_as_cmd
);
18874 install_element(BGP_IPV4M_NODE
,
18875 &no_neighbor_remove_private_as_replace_as_cmd
);
18876 install_element(BGP_IPV4M_NODE
,
18877 &neighbor_remove_private_as_all_replace_as_cmd
);
18878 install_element(BGP_IPV4M_NODE
,
18879 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18880 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18881 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18882 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18883 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18884 install_element(BGP_IPV4L_NODE
,
18885 &neighbor_remove_private_as_replace_as_cmd
);
18886 install_element(BGP_IPV4L_NODE
,
18887 &no_neighbor_remove_private_as_replace_as_cmd
);
18888 install_element(BGP_IPV4L_NODE
,
18889 &neighbor_remove_private_as_all_replace_as_cmd
);
18890 install_element(BGP_IPV4L_NODE
,
18891 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18892 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18893 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18894 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18895 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18896 install_element(BGP_IPV6_NODE
,
18897 &neighbor_remove_private_as_replace_as_cmd
);
18898 install_element(BGP_IPV6_NODE
,
18899 &no_neighbor_remove_private_as_replace_as_cmd
);
18900 install_element(BGP_IPV6_NODE
,
18901 &neighbor_remove_private_as_all_replace_as_cmd
);
18902 install_element(BGP_IPV6_NODE
,
18903 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18904 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18905 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18906 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18907 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18908 install_element(BGP_IPV6M_NODE
,
18909 &neighbor_remove_private_as_replace_as_cmd
);
18910 install_element(BGP_IPV6M_NODE
,
18911 &no_neighbor_remove_private_as_replace_as_cmd
);
18912 install_element(BGP_IPV6M_NODE
,
18913 &neighbor_remove_private_as_all_replace_as_cmd
);
18914 install_element(BGP_IPV6M_NODE
,
18915 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18916 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18917 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18918 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18919 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18920 install_element(BGP_IPV6L_NODE
,
18921 &neighbor_remove_private_as_replace_as_cmd
);
18922 install_element(BGP_IPV6L_NODE
,
18923 &no_neighbor_remove_private_as_replace_as_cmd
);
18924 install_element(BGP_IPV6L_NODE
,
18925 &neighbor_remove_private_as_all_replace_as_cmd
);
18926 install_element(BGP_IPV6L_NODE
,
18927 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18928 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18929 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18930 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18931 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18932 install_element(BGP_VPNV4_NODE
,
18933 &neighbor_remove_private_as_replace_as_cmd
);
18934 install_element(BGP_VPNV4_NODE
,
18935 &no_neighbor_remove_private_as_replace_as_cmd
);
18936 install_element(BGP_VPNV4_NODE
,
18937 &neighbor_remove_private_as_all_replace_as_cmd
);
18938 install_element(BGP_VPNV4_NODE
,
18939 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18940 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18941 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18942 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18943 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18944 install_element(BGP_VPNV6_NODE
,
18945 &neighbor_remove_private_as_replace_as_cmd
);
18946 install_element(BGP_VPNV6_NODE
,
18947 &no_neighbor_remove_private_as_replace_as_cmd
);
18948 install_element(BGP_VPNV6_NODE
,
18949 &neighbor_remove_private_as_all_replace_as_cmd
);
18950 install_element(BGP_VPNV6_NODE
,
18951 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18953 /* "neighbor send-community" commands.*/
18954 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18955 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18956 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18957 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18958 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18959 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18960 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18961 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18962 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18963 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18964 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18965 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18966 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18967 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18968 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18969 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18970 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18971 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18972 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18973 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18974 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18975 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18976 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18977 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18978 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18979 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18980 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18981 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18982 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18983 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18984 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18985 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18986 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18987 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18988 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18989 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18991 /* "neighbor route-reflector" commands.*/
18992 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18993 install_element(BGP_NODE
,
18994 &no_neighbor_route_reflector_client_hidden_cmd
);
18995 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18996 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18997 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18998 install_element(BGP_IPV4M_NODE
,
18999 &no_neighbor_route_reflector_client_cmd
);
19000 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19001 install_element(BGP_IPV4L_NODE
,
19002 &no_neighbor_route_reflector_client_cmd
);
19003 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19004 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19005 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19006 install_element(BGP_IPV6M_NODE
,
19007 &no_neighbor_route_reflector_client_cmd
);
19008 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19009 install_element(BGP_IPV6L_NODE
,
19010 &no_neighbor_route_reflector_client_cmd
);
19011 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19012 install_element(BGP_VPNV4_NODE
,
19013 &no_neighbor_route_reflector_client_cmd
);
19014 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19015 install_element(BGP_VPNV6_NODE
,
19016 &no_neighbor_route_reflector_client_cmd
);
19017 install_element(BGP_FLOWSPECV4_NODE
,
19018 &neighbor_route_reflector_client_cmd
);
19019 install_element(BGP_FLOWSPECV4_NODE
,
19020 &no_neighbor_route_reflector_client_cmd
);
19021 install_element(BGP_FLOWSPECV6_NODE
,
19022 &neighbor_route_reflector_client_cmd
);
19023 install_element(BGP_FLOWSPECV6_NODE
,
19024 &no_neighbor_route_reflector_client_cmd
);
19025 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19026 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19028 /* "optimal-route-reflection" commands */
19029 install_element(BGP_IPV4_NODE
, &optimal_route_reflection_cmd
);
19030 install_element(BGP_IPV4M_NODE
, &optimal_route_reflection_cmd
);
19031 install_element(BGP_IPV4L_NODE
, &optimal_route_reflection_cmd
);
19032 install_element(BGP_IPV6_NODE
, &optimal_route_reflection_cmd
);
19033 install_element(BGP_IPV6M_NODE
, &optimal_route_reflection_cmd
);
19034 install_element(BGP_IPV6L_NODE
, &optimal_route_reflection_cmd
);
19035 install_element(BGP_VPNV4_NODE
, &optimal_route_reflection_cmd
);
19036 install_element(BGP_VPNV6_NODE
, &optimal_route_reflection_cmd
);
19037 install_element(BGP_FLOWSPECV4_NODE
, &optimal_route_reflection_cmd
);
19038 install_element(BGP_FLOWSPECV6_NODE
, &optimal_route_reflection_cmd
);
19039 install_element(BGP_EVPN_NODE
, &optimal_route_reflection_cmd
);
19041 /* "neighbor optimal-route-reflection" commands */
19042 install_element(BGP_IPV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19043 install_element(BGP_IPV4M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19044 install_element(BGP_IPV4L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19045 install_element(BGP_IPV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19046 install_element(BGP_IPV6M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19047 install_element(BGP_IPV6L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19048 install_element(BGP_VPNV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19049 install_element(BGP_VPNV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19050 install_element(BGP_FLOWSPECV4_NODE
,
19051 &neighbor_optimal_route_reflection_cmd
);
19052 install_element(BGP_FLOWSPECV6_NODE
,
19053 &neighbor_optimal_route_reflection_cmd
);
19054 install_element(BGP_EVPN_NODE
, &neighbor_optimal_route_reflection_cmd
);
19056 /* "neighbor route-server" commands.*/
19057 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19058 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19059 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19060 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19061 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19062 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19063 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19064 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19065 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19066 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19067 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19068 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19069 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19070 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19071 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19072 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19073 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19075 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19076 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19077 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19078 install_element(BGP_FLOWSPECV4_NODE
,
19079 &no_neighbor_route_server_client_cmd
);
19080 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19081 install_element(BGP_FLOWSPECV6_NODE
,
19082 &no_neighbor_route_server_client_cmd
);
19084 /* "neighbor disable-addpath-rx" commands. */
19085 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19086 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19087 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19088 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19089 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19090 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19091 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19092 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19093 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19094 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19095 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19096 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19097 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19098 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19099 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19100 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19102 /* "neighbor addpath-tx-all-paths" commands.*/
19103 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19104 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19105 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19106 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19107 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19108 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19109 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19110 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19111 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19112 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19113 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19114 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19115 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19116 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19117 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19118 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19119 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19120 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19122 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19123 install_element(BGP_NODE
,
19124 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19125 install_element(BGP_NODE
,
19126 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19127 install_element(BGP_IPV4_NODE
,
19128 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19129 install_element(BGP_IPV4_NODE
,
19130 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19131 install_element(BGP_IPV4M_NODE
,
19132 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19133 install_element(BGP_IPV4M_NODE
,
19134 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19135 install_element(BGP_IPV4L_NODE
,
19136 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19137 install_element(BGP_IPV4L_NODE
,
19138 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19139 install_element(BGP_IPV6_NODE
,
19140 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19141 install_element(BGP_IPV6_NODE
,
19142 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19143 install_element(BGP_IPV6M_NODE
,
19144 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19145 install_element(BGP_IPV6M_NODE
,
19146 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19147 install_element(BGP_IPV6L_NODE
,
19148 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19149 install_element(BGP_IPV6L_NODE
,
19150 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19151 install_element(BGP_VPNV4_NODE
,
19152 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19153 install_element(BGP_VPNV4_NODE
,
19154 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19155 install_element(BGP_VPNV6_NODE
,
19156 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19157 install_element(BGP_VPNV6_NODE
,
19158 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19160 /* "neighbor sender-as-path-loop-detection" commands. */
19161 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19162 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19164 /* "neighbor passive" commands. */
19165 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19166 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19169 /* "neighbor shutdown" commands. */
19170 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19171 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19172 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19173 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19174 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19175 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19177 /* "neighbor capability extended-nexthop" commands.*/
19178 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19179 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19181 /* "neighbor capability orf prefix-list" commands.*/
19182 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19183 install_element(BGP_NODE
,
19184 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19185 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19186 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19187 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19188 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19189 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19190 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19191 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19192 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19193 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19194 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19195 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19196 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19198 /* "neighbor capability dynamic" commands.*/
19199 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19200 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19202 /* "neighbor dont-capability-negotiate" commands. */
19203 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19204 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19206 /* "neighbor ebgp-multihop" commands. */
19207 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19208 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19209 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19211 /* "neighbor disable-connected-check" commands. */
19212 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19213 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19215 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19216 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19217 install_element(BGP_NODE
,
19218 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19220 /* "neighbor extended-optional-parameters" commands. */
19221 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19222 install_element(BGP_NODE
,
19223 &no_neighbor_extended_optional_parameters_cmd
);
19225 /* "neighbor enforce-first-as" commands. */
19226 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19227 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19229 /* "neighbor description" commands. */
19230 install_element(BGP_NODE
, &neighbor_description_cmd
);
19231 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19232 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19234 /* "neighbor update-source" commands. "*/
19235 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19236 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19238 /* "neighbor default-originate" commands. */
19239 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19240 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19241 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19242 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19243 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19244 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19245 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19246 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19247 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19248 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19249 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19250 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19251 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19252 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19253 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19254 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19255 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19256 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19257 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19258 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19259 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19261 /* "neighbor port" commands. */
19262 install_element(BGP_NODE
, &neighbor_port_cmd
);
19263 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19265 /* "neighbor weight" commands. */
19266 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19267 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19269 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19270 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19271 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19272 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19273 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19274 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19275 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19276 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19277 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19278 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19279 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19280 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19281 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19282 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19283 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19284 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19286 /* "neighbor override-capability" commands. */
19287 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19288 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19290 /* "neighbor strict-capability-match" commands. */
19291 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19292 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19294 /* "neighbor timers" commands. */
19295 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19296 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19298 /* "neighbor timers connect" commands. */
19299 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19300 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19302 /* "neighbor timers delayopen" commands. */
19303 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19304 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19306 /* "neighbor advertisement-interval" commands. */
19307 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19308 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19310 /* "neighbor interface" commands. */
19311 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19312 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19314 /* "neighbor distribute" commands. */
19315 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19316 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19317 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19318 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19319 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19320 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19321 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19322 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19323 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19324 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19325 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19326 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19327 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19328 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19329 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19330 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19331 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19332 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19334 /* "neighbor prefix-list" commands. */
19335 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19336 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19337 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19338 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19339 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19340 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19341 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19342 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19343 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19344 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19345 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19346 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19347 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19348 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19349 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19350 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19351 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19352 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19353 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19354 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19355 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19356 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19358 /* "neighbor filter-list" commands. */
19359 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19360 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19361 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19362 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19363 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19364 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19365 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19366 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19367 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19368 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19369 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19370 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19371 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19372 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19373 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19374 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19375 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19376 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19377 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19378 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19379 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19380 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19382 /* "neighbor route-map" commands. */
19383 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19384 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19385 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19386 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19387 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19388 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19389 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19390 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19391 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19392 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19393 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19394 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19395 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19396 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19397 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19398 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19399 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19400 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19401 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19402 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19403 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19404 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19405 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19406 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19408 /* "neighbor unsuppress-map" commands. */
19409 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19410 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19411 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19412 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19413 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19414 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19415 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19416 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19417 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19418 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19419 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19420 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19421 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19422 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19423 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19424 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19425 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19426 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19428 /* "neighbor advertise-map" commands. */
19429 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19430 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19431 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19432 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19433 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19434 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19435 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19436 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19437 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19438 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19440 /* neighbor maximum-prefix-out commands. */
19441 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19442 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19443 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19444 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19445 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19446 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19447 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19448 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19449 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19450 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19451 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19452 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19453 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19454 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19455 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19456 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19457 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19458 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19460 /* "neighbor maximum-prefix" commands. */
19461 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19462 install_element(BGP_NODE
,
19463 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19464 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19465 install_element(BGP_NODE
,
19466 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19467 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19468 install_element(BGP_NODE
,
19469 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19470 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19471 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19472 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19473 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19474 install_element(BGP_IPV4_NODE
,
19475 &neighbor_maximum_prefix_threshold_warning_cmd
);
19476 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19477 install_element(BGP_IPV4_NODE
,
19478 &neighbor_maximum_prefix_threshold_restart_cmd
);
19479 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19480 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19481 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19482 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19483 install_element(BGP_IPV4M_NODE
,
19484 &neighbor_maximum_prefix_threshold_warning_cmd
);
19485 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19486 install_element(BGP_IPV4M_NODE
,
19487 &neighbor_maximum_prefix_threshold_restart_cmd
);
19488 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19489 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19490 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19491 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19492 install_element(BGP_IPV4L_NODE
,
19493 &neighbor_maximum_prefix_threshold_warning_cmd
);
19494 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19495 install_element(BGP_IPV4L_NODE
,
19496 &neighbor_maximum_prefix_threshold_restart_cmd
);
19497 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19498 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19499 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19500 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19501 install_element(BGP_IPV6_NODE
,
19502 &neighbor_maximum_prefix_threshold_warning_cmd
);
19503 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19504 install_element(BGP_IPV6_NODE
,
19505 &neighbor_maximum_prefix_threshold_restart_cmd
);
19506 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19507 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19508 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19509 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19510 install_element(BGP_IPV6M_NODE
,
19511 &neighbor_maximum_prefix_threshold_warning_cmd
);
19512 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19513 install_element(BGP_IPV6M_NODE
,
19514 &neighbor_maximum_prefix_threshold_restart_cmd
);
19515 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19516 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19517 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19518 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19519 install_element(BGP_IPV6L_NODE
,
19520 &neighbor_maximum_prefix_threshold_warning_cmd
);
19521 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19522 install_element(BGP_IPV6L_NODE
,
19523 &neighbor_maximum_prefix_threshold_restart_cmd
);
19524 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19525 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19526 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19527 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19528 install_element(BGP_VPNV4_NODE
,
19529 &neighbor_maximum_prefix_threshold_warning_cmd
);
19530 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19531 install_element(BGP_VPNV4_NODE
,
19532 &neighbor_maximum_prefix_threshold_restart_cmd
);
19533 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19534 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19535 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19536 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19537 install_element(BGP_VPNV6_NODE
,
19538 &neighbor_maximum_prefix_threshold_warning_cmd
);
19539 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19540 install_element(BGP_VPNV6_NODE
,
19541 &neighbor_maximum_prefix_threshold_restart_cmd
);
19542 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19544 /* "neighbor allowas-in" */
19545 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19546 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19547 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19548 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19549 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19550 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19551 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19552 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19553 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19554 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19555 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19556 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19557 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19558 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19559 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19560 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19561 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19562 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19563 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19564 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19566 /* "neighbor soo" */
19567 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19568 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19569 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19570 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19571 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19572 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19573 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19574 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19575 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19576 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19577 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19578 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19579 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19580 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19581 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19582 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19583 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19584 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19586 /* address-family commands. */
19587 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19588 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19589 #ifdef KEEP_OLD_VPN_COMMANDS
19590 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19591 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19592 #endif /* KEEP_OLD_VPN_COMMANDS */
19594 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19596 /* "exit-address-family" command. */
19597 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19598 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19599 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19600 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19601 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19602 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19603 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19604 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19605 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19606 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19607 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19609 /* BGP retain all route-target */
19610 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19611 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19613 /* "clear ip bgp commands" */
19614 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19616 /* clear ip bgp prefix */
19617 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19618 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19619 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19621 /* "show [ip] bgp summary" commands. */
19622 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19623 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19624 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19625 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19626 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19627 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19628 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19630 /* "show [ip] bgp neighbors" commands. */
19631 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19633 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19635 /* "show [ip] bgp peer-group" commands. */
19636 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19638 /* "show [ip] bgp paths" commands. */
19639 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19641 /* "show [ip] bgp community" commands. */
19642 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19644 /* "show ip bgp large-community" commands. */
19645 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19646 /* "show [ip] bgp attribute-info" commands. */
19647 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19648 /* "show [ip] bgp route-leak" command */
19649 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19651 /* "redistribute" commands. */
19652 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19653 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19654 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19655 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19656 install_element(BGP_NODE
,
19657 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19658 install_element(BGP_NODE
,
19659 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19660 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19661 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19662 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19663 install_element(BGP_NODE
,
19664 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19665 install_element(BGP_NODE
,
19666 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19667 install_element(BGP_NODE
,
19668 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19669 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19670 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19671 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19672 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19673 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19674 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19675 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19676 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19677 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19678 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19679 install_element(BGP_IPV4_NODE
,
19680 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19681 install_element(BGP_IPV4_NODE
,
19682 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19683 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19684 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19685 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19686 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19687 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19688 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19690 /* import|export vpn [route-map RMAP_NAME] */
19691 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19692 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19694 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19695 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19697 /* ttl_security commands */
19698 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19699 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19701 /* "bgp tcp-keepalive" commands */
19702 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19703 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19705 /* "show [ip] bgp memory" commands. */
19706 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19708 /* "show bgp martian next-hop" */
19709 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19711 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19713 /* "show [ip] bgp views" commands. */
19714 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19716 /* "show [ip] bgp vrfs" commands. */
19717 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19719 /* Community-list. */
19720 community_list_vty();
19722 community_alias_vty();
19724 /* vpn-policy commands */
19725 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19726 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19727 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19728 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19729 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19730 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19731 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19732 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19733 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19734 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19735 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19736 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19738 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19739 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19741 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19742 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19743 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19744 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19745 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19746 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19747 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19748 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19749 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19750 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19752 /* tcp-mss command */
19753 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19754 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19756 /* srv6 commands */
19757 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19758 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19759 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19760 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19761 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19762 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19763 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19768 #include "memory.h"
19769 #include "bgp_regex.h"
19770 #include "bgp_clist.h"
19771 #include "bgp_ecommunity.h"
19773 /* VTY functions. */
19775 /* Direction value to string conversion. */
19776 static const char *community_direct_str(int direct
)
19779 case COMMUNITY_DENY
:
19781 case COMMUNITY_PERMIT
:
19788 /* Display error string. */
19789 static void community_list_perror(struct vty
*vty
, int ret
)
19792 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19793 vty_out(vty
, "%% Can't find community-list\n");
19795 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19796 vty_out(vty
, "%% Malformed community-list value\n");
19798 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19800 "%% Community name conflict, previously defined as standard community\n");
19802 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19804 "%% Community name conflict, previously defined as expanded community\n");
19809 /* "community-list" keyword help string. */
19810 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19812 /*community-list standard */
19813 DEFUN (community_list_standard
,
19814 bgp_community_list_standard_cmd
,
19815 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19818 "Community list number (standard)\n"
19819 "Add an standard community-list entry\n"
19820 "Community list name\n"
19821 "Sequence number of an entry\n"
19822 "Sequence number\n"
19823 "Specify community to reject\n"
19824 "Specify community to accept\n"
19827 char *cl_name_or_number
= NULL
;
19830 int style
= COMMUNITY_LIST_STANDARD
;
19833 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19834 seq
= argv
[idx
]->arg
;
19837 argv_find(argv
, argc
, "(1-99)", &idx
);
19838 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19839 cl_name_or_number
= argv
[idx
]->arg
;
19840 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19842 argv_find(argv
, argc
, "AA:NN", &idx
);
19843 char *str
= argv_concat(argv
, argc
, idx
);
19845 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19848 XFREE(MTYPE_TMP
, str
);
19851 /* Display error string. */
19852 community_list_perror(vty
, ret
);
19853 return CMD_WARNING_CONFIG_FAILED
;
19856 return CMD_SUCCESS
;
19859 DEFUN (no_community_list_standard_all
,
19860 no_bgp_community_list_standard_all_cmd
,
19861 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19865 "Community list number (standard)\n"
19866 "Add an standard community-list entry\n"
19867 "Community list name\n"
19868 "Sequence number of an entry\n"
19869 "Sequence number\n"
19870 "Specify community to reject\n"
19871 "Specify community to accept\n"
19874 char *cl_name_or_number
= NULL
;
19877 int style
= COMMUNITY_LIST_STANDARD
;
19881 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19882 seq
= argv
[idx
]->arg
;
19885 argv_find(argv
, argc
, "permit", &idx
);
19886 argv_find(argv
, argc
, "deny", &idx
);
19889 direct
= argv_find(argv
, argc
, "permit", &idx
)
19894 argv_find(argv
, argc
, "AA:NN", &idx
);
19895 str
= argv_concat(argv
, argc
, idx
);
19899 argv_find(argv
, argc
, "(1-99)", &idx
);
19900 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19901 cl_name_or_number
= argv
[idx
]->arg
;
19903 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19906 XFREE(MTYPE_TMP
, str
);
19909 community_list_perror(vty
, ret
);
19910 return CMD_WARNING_CONFIG_FAILED
;
19913 return CMD_SUCCESS
;
19916 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19917 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19918 NO_STR BGP_STR COMMUNITY_LIST_STR
19919 "Community list number (standard)\n"
19920 "Add an standard community-list entry\n"
19921 "Community list name\n")
19923 /*community-list expanded */
19924 DEFUN (community_list_expanded_all
,
19925 bgp_community_list_expanded_all_cmd
,
19926 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19929 "Community list number (expanded)\n"
19930 "Add an expanded community-list entry\n"
19931 "Community list name\n"
19932 "Sequence number of an entry\n"
19933 "Sequence number\n"
19934 "Specify community to reject\n"
19935 "Specify community to accept\n"
19938 char *cl_name_or_number
= NULL
;
19941 int style
= COMMUNITY_LIST_EXPANDED
;
19944 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19945 seq
= argv
[idx
]->arg
;
19949 argv_find(argv
, argc
, "(100-500)", &idx
);
19950 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19951 cl_name_or_number
= argv
[idx
]->arg
;
19952 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19954 argv_find(argv
, argc
, "AA:NN", &idx
);
19955 char *str
= argv_concat(argv
, argc
, idx
);
19957 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19960 XFREE(MTYPE_TMP
, str
);
19963 /* Display error string. */
19964 community_list_perror(vty
, ret
);
19965 return CMD_WARNING_CONFIG_FAILED
;
19968 return CMD_SUCCESS
;
19971 DEFUN (no_community_list_expanded_all
,
19972 no_bgp_community_list_expanded_all_cmd
,
19973 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19977 "Community list number (expanded)\n"
19978 "Add an expanded community-list entry\n"
19979 "Community list name\n"
19980 "Sequence number of an entry\n"
19981 "Sequence number\n"
19982 "Specify community to reject\n"
19983 "Specify community to accept\n"
19986 char *cl_name_or_number
= NULL
;
19990 int style
= COMMUNITY_LIST_EXPANDED
;
19993 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19994 seq
= argv
[idx
]->arg
;
19997 argv_find(argv
, argc
, "permit", &idx
);
19998 argv_find(argv
, argc
, "deny", &idx
);
20001 direct
= argv_find(argv
, argc
, "permit", &idx
)
20006 argv_find(argv
, argc
, "AA:NN", &idx
);
20007 str
= argv_concat(argv
, argc
, idx
);
20011 argv_find(argv
, argc
, "(100-500)", &idx
);
20012 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20013 cl_name_or_number
= argv
[idx
]->arg
;
20015 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20018 XFREE(MTYPE_TMP
, str
);
20021 community_list_perror(vty
, ret
);
20022 return CMD_WARNING_CONFIG_FAILED
;
20025 return CMD_SUCCESS
;
20028 ALIAS(no_community_list_expanded_all
,
20029 no_bgp_community_list_expanded_all_list_cmd
,
20030 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20031 NO_STR BGP_STR COMMUNITY_LIST_STR
20032 "Community list number (expanded)\n"
20033 "Add an expanded community-list entry\n"
20034 "Community list name\n")
20036 /* Return configuration string of community-list entry. */
20037 static const char *community_list_config_str(struct community_entry
*entry
)
20044 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20045 str
= community_str(entry
->u
.com
, false, false);
20046 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20047 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20049 str
= entry
->config
;
20054 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20056 struct community_entry
*entry
;
20058 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20059 if (entry
== list
->head
) {
20060 if (all_digit(list
->name
))
20061 vty_out(vty
, "Community %s list %s\n",
20062 entry
->style
== COMMUNITY_LIST_STANDARD
20064 : "(expanded) access",
20067 vty_out(vty
, "Named Community %s list %s\n",
20068 entry
->style
== COMMUNITY_LIST_STANDARD
20074 vty_out(vty
, " %s\n",
20075 community_direct_str(entry
->direct
));
20077 vty_out(vty
, " %s %s\n",
20078 community_direct_str(entry
->direct
),
20079 community_list_config_str(entry
));
20083 DEFUN (show_community_list
,
20084 show_bgp_community_list_cmd
,
20085 "show bgp community-list",
20088 "List community-list\n")
20090 struct community_list
*list
;
20091 struct community_list_master
*cm
;
20093 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20095 return CMD_SUCCESS
;
20097 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20098 community_list_show(vty
, list
);
20100 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20101 community_list_show(vty
, list
);
20103 return CMD_SUCCESS
;
20106 DEFUN (show_community_list_arg
,
20107 show_bgp_community_list_arg_cmd
,
20108 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20111 "List community-list\n"
20112 "Community-list number\n"
20113 "Community-list name\n"
20114 "Detailed information on community-list\n")
20116 int idx_comm_list
= 3;
20117 struct community_list
*list
;
20119 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20120 COMMUNITY_LIST_MASTER
);
20122 vty_out(vty
, "%% Can't find community-list\n");
20123 return CMD_WARNING
;
20126 community_list_show(vty
, list
);
20128 return CMD_SUCCESS
;
20132 * Large Community code.
20134 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20135 struct cmd_token
**argv
, int style
,
20136 int reject_all_digit_name
)
20145 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20146 seq
= argv
[idx
]->arg
;
20149 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20152 /* All digit name check. */
20154 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20155 argv_find(argv
, argc
, "(1-99)", &idx
);
20156 argv_find(argv
, argc
, "(100-500)", &idx
);
20157 cl_name
= argv
[idx
]->arg
;
20158 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20159 vty_out(vty
, "%% Community name cannot have all digits\n");
20160 return CMD_WARNING_CONFIG_FAILED
;
20164 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20165 argv_find(argv
, argc
, "LINE", &idx
);
20166 /* Concat community string argument. */
20168 str
= argv_concat(argv
, argc
, idx
);
20172 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20174 /* Free temporary community list string allocated by
20176 XFREE(MTYPE_TMP
, str
);
20179 community_list_perror(vty
, ret
);
20180 return CMD_WARNING_CONFIG_FAILED
;
20182 return CMD_SUCCESS
;
20185 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20186 struct cmd_token
**argv
, int style
)
20194 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20195 seq
= argv
[idx
]->arg
;
20198 argv_find(argv
, argc
, "permit", &idx
);
20199 argv_find(argv
, argc
, "deny", &idx
);
20202 /* Check the list direct. */
20203 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20204 direct
= COMMUNITY_PERMIT
;
20206 direct
= COMMUNITY_DENY
;
20209 argv_find(argv
, argc
, "LINE", &idx
);
20210 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20211 /* Concat community string argument. */
20212 str
= argv_concat(argv
, argc
, idx
);
20216 argv_find(argv
, argc
, "(1-99)", &idx
);
20217 argv_find(argv
, argc
, "(100-500)", &idx
);
20218 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20220 /* Unset community list. */
20221 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20224 /* Free temporary community list string allocated by
20226 XFREE(MTYPE_TMP
, str
);
20229 community_list_perror(vty
, ret
);
20230 return CMD_WARNING_CONFIG_FAILED
;
20233 return CMD_SUCCESS
;
20236 /* "large-community-list" keyword help string. */
20237 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20238 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20240 DEFUN (lcommunity_list_standard
,
20241 bgp_lcommunity_list_standard_cmd
,
20242 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20244 LCOMMUNITY_LIST_STR
20245 "Large Community list number (standard)\n"
20246 "Sequence number of an entry\n"
20247 "Sequence number\n"
20248 "Specify large community to reject\n"
20249 "Specify large community to accept\n"
20250 LCOMMUNITY_VAL_STR
)
20252 return lcommunity_list_set_vty(vty
, argc
, argv
,
20253 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20256 DEFUN (lcommunity_list_expanded
,
20257 bgp_lcommunity_list_expanded_cmd
,
20258 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20260 LCOMMUNITY_LIST_STR
20261 "Large Community list number (expanded)\n"
20262 "Sequence number of an entry\n"
20263 "Sequence number\n"
20264 "Specify large community to reject\n"
20265 "Specify large community to accept\n"
20266 "An ordered list as a regular-expression\n")
20268 return lcommunity_list_set_vty(vty
, argc
, argv
,
20269 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20272 DEFUN (lcommunity_list_name_standard
,
20273 bgp_lcommunity_list_name_standard_cmd
,
20274 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20276 LCOMMUNITY_LIST_STR
20277 "Specify standard large-community-list\n"
20278 "Large Community list name\n"
20279 "Sequence number of an entry\n"
20280 "Sequence number\n"
20281 "Specify large community to reject\n"
20282 "Specify large community to accept\n"
20283 LCOMMUNITY_VAL_STR
)
20285 return lcommunity_list_set_vty(vty
, argc
, argv
,
20286 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20289 DEFUN (lcommunity_list_name_expanded
,
20290 bgp_lcommunity_list_name_expanded_cmd
,
20291 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20293 LCOMMUNITY_LIST_STR
20294 "Specify expanded large-community-list\n"
20295 "Large Community list name\n"
20296 "Sequence number of an entry\n"
20297 "Sequence number\n"
20298 "Specify large community to reject\n"
20299 "Specify large community to accept\n"
20300 "An ordered list as a regular-expression\n")
20302 return lcommunity_list_set_vty(vty
, argc
, argv
,
20303 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20306 DEFUN (no_lcommunity_list_all
,
20307 no_bgp_lcommunity_list_all_cmd
,
20308 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20311 LCOMMUNITY_LIST_STR
20312 "Large Community list number (standard)\n"
20313 "Large Community list number (expanded)\n"
20314 "Large Community list name\n")
20316 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20317 LARGE_COMMUNITY_LIST_STANDARD
);
20320 DEFUN (no_lcommunity_list_name_standard_all
,
20321 no_bgp_lcommunity_list_name_standard_all_cmd
,
20322 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20325 LCOMMUNITY_LIST_STR
20326 "Specify standard large-community-list\n"
20327 "Large Community list name\n")
20329 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20330 LARGE_COMMUNITY_LIST_STANDARD
);
20333 DEFUN (no_lcommunity_list_name_expanded_all
,
20334 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20335 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20338 LCOMMUNITY_LIST_STR
20339 "Specify expanded large-community-list\n"
20340 "Large Community list name\n")
20342 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20343 LARGE_COMMUNITY_LIST_EXPANDED
);
20346 DEFUN (no_lcommunity_list_standard
,
20347 no_bgp_lcommunity_list_standard_cmd
,
20348 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20351 LCOMMUNITY_LIST_STR
20352 "Large Community list number (standard)\n"
20353 "Sequence number of an entry\n"
20354 "Sequence number\n"
20355 "Specify large community to reject\n"
20356 "Specify large community to accept\n"
20357 LCOMMUNITY_VAL_STR
)
20359 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20360 LARGE_COMMUNITY_LIST_STANDARD
);
20363 DEFUN (no_lcommunity_list_expanded
,
20364 no_bgp_lcommunity_list_expanded_cmd
,
20365 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20368 LCOMMUNITY_LIST_STR
20369 "Large Community list number (expanded)\n"
20370 "Sequence number of an entry\n"
20371 "Sequence number\n"
20372 "Specify large community to reject\n"
20373 "Specify large community to accept\n"
20374 "An ordered list as a regular-expression\n")
20376 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20377 LARGE_COMMUNITY_LIST_EXPANDED
);
20380 DEFUN (no_lcommunity_list_name_standard
,
20381 no_bgp_lcommunity_list_name_standard_cmd
,
20382 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20385 LCOMMUNITY_LIST_STR
20386 "Specify standard large-community-list\n"
20387 "Large Community list name\n"
20388 "Sequence number of an entry\n"
20389 "Sequence number\n"
20390 "Specify large community to reject\n"
20391 "Specify large community to accept\n"
20392 LCOMMUNITY_VAL_STR
)
20394 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20395 LARGE_COMMUNITY_LIST_STANDARD
);
20398 DEFUN (no_lcommunity_list_name_expanded
,
20399 no_bgp_lcommunity_list_name_expanded_cmd
,
20400 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20403 LCOMMUNITY_LIST_STR
20404 "Specify expanded large-community-list\n"
20405 "Large community list name\n"
20406 "Sequence number of an entry\n"
20407 "Sequence number\n"
20408 "Specify large community to reject\n"
20409 "Specify large community to accept\n"
20410 "An ordered list as a regular-expression\n")
20412 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20413 LARGE_COMMUNITY_LIST_EXPANDED
);
20416 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20418 struct community_entry
*entry
;
20420 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20421 if (entry
== list
->head
) {
20422 if (all_digit(list
->name
))
20423 vty_out(vty
, "Large community %s list %s\n",
20425 LARGE_COMMUNITY_LIST_STANDARD
20427 : "(expanded) access",
20431 "Named large community %s list %s\n",
20433 LARGE_COMMUNITY_LIST_STANDARD
20439 vty_out(vty
, " %s\n",
20440 community_direct_str(entry
->direct
));
20442 vty_out(vty
, " %s %s\n",
20443 community_direct_str(entry
->direct
),
20444 community_list_config_str(entry
));
20448 DEFUN (show_lcommunity_list
,
20449 show_bgp_lcommunity_list_cmd
,
20450 "show bgp large-community-list",
20453 "List large-community list\n")
20455 struct community_list
*list
;
20456 struct community_list_master
*cm
;
20458 cm
= community_list_master_lookup(bgp_clist
,
20459 LARGE_COMMUNITY_LIST_MASTER
);
20461 return CMD_SUCCESS
;
20463 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20464 lcommunity_list_show(vty
, list
);
20466 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20467 lcommunity_list_show(vty
, list
);
20469 return CMD_SUCCESS
;
20472 DEFUN (show_lcommunity_list_arg
,
20473 show_bgp_lcommunity_list_arg_cmd
,
20474 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20477 "List large-community list\n"
20478 "Large-community-list number\n"
20479 "Large-community-list name\n"
20480 "Detailed information on large-community-list\n")
20482 struct community_list
*list
;
20484 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20485 LARGE_COMMUNITY_LIST_MASTER
);
20487 vty_out(vty
, "%% Can't find large-community-list\n");
20488 return CMD_WARNING
;
20491 lcommunity_list_show(vty
, list
);
20493 return CMD_SUCCESS
;
20496 /* "extcommunity-list" keyword help string. */
20497 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20498 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20500 DEFUN (extcommunity_list_standard
,
20501 bgp_extcommunity_list_standard_cmd
,
20502 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20504 EXTCOMMUNITY_LIST_STR
20505 "Extended Community list number (standard)\n"
20506 "Specify standard extcommunity-list\n"
20507 "Community list name\n"
20508 "Sequence number of an entry\n"
20509 "Sequence number\n"
20510 "Specify community to reject\n"
20511 "Specify community to accept\n"
20512 EXTCOMMUNITY_VAL_STR
)
20514 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20516 char *cl_number_or_name
= NULL
;
20521 argv_find(argv
, argc
, "(1-99)", &idx
);
20522 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20523 cl_number_or_name
= argv
[idx
]->arg
;
20525 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20526 seq
= argv
[idx
]->arg
;
20528 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20530 argv_find(argv
, argc
, "AA:NN", &idx
);
20531 char *str
= argv_concat(argv
, argc
, idx
);
20533 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20536 XFREE(MTYPE_TMP
, str
);
20539 community_list_perror(vty
, ret
);
20540 return CMD_WARNING_CONFIG_FAILED
;
20543 return CMD_SUCCESS
;
20546 DEFUN (extcommunity_list_name_expanded
,
20547 bgp_extcommunity_list_name_expanded_cmd
,
20548 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20550 EXTCOMMUNITY_LIST_STR
20551 "Extended Community list number (expanded)\n"
20552 "Specify expanded extcommunity-list\n"
20553 "Extended Community list name\n"
20554 "Sequence number of an entry\n"
20555 "Sequence number\n"
20556 "Specify community to reject\n"
20557 "Specify community to accept\n"
20558 "An ordered list as a regular-expression\n")
20560 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20562 char *cl_number_or_name
= NULL
;
20566 argv_find(argv
, argc
, "(100-500)", &idx
);
20567 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20568 cl_number_or_name
= argv
[idx
]->arg
;
20570 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20571 seq
= argv
[idx
]->arg
;
20573 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20575 argv_find(argv
, argc
, "LINE", &idx
);
20576 char *str
= argv_concat(argv
, argc
, idx
);
20578 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20581 XFREE(MTYPE_TMP
, str
);
20584 community_list_perror(vty
, ret
);
20585 return CMD_WARNING_CONFIG_FAILED
;
20588 return CMD_SUCCESS
;
20591 DEFUN (no_extcommunity_list_standard_all
,
20592 no_bgp_extcommunity_list_standard_all_cmd
,
20593 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20596 EXTCOMMUNITY_LIST_STR
20597 "Extended Community list number (standard)\n"
20598 "Specify standard extcommunity-list\n"
20599 "Community list name\n"
20600 "Sequence number of an entry\n"
20601 "Sequence number\n"
20602 "Specify community to reject\n"
20603 "Specify community to accept\n"
20604 EXTCOMMUNITY_VAL_STR
)
20606 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20608 char *cl_number_or_name
= NULL
;
20613 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20614 seq
= argv
[idx
]->arg
;
20617 argv_find(argv
, argc
, "permit", &idx
);
20618 argv_find(argv
, argc
, "deny", &idx
);
20620 direct
= argv_find(argv
, argc
, "permit", &idx
)
20625 argv_find(argv
, argc
, "AA:NN", &idx
);
20626 str
= argv_concat(argv
, argc
, idx
);
20630 argv_find(argv
, argc
, "(1-99)", &idx
);
20631 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20632 cl_number_or_name
= argv
[idx
]->arg
;
20634 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20635 seq
, direct
, style
);
20637 XFREE(MTYPE_TMP
, str
);
20640 community_list_perror(vty
, ret
);
20641 return CMD_WARNING_CONFIG_FAILED
;
20644 return CMD_SUCCESS
;
20647 ALIAS(no_extcommunity_list_standard_all
,
20648 no_bgp_extcommunity_list_standard_all_list_cmd
,
20649 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20650 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20651 "Extended Community list number (standard)\n"
20652 "Specify standard extcommunity-list\n"
20653 "Community list name\n")
20655 DEFUN (no_extcommunity_list_expanded_all
,
20656 no_bgp_extcommunity_list_expanded_all_cmd
,
20657 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20660 EXTCOMMUNITY_LIST_STR
20661 "Extended Community list number (expanded)\n"
20662 "Specify expanded extcommunity-list\n"
20663 "Extended Community list name\n"
20664 "Sequence number of an entry\n"
20665 "Sequence number\n"
20666 "Specify community to reject\n"
20667 "Specify community to accept\n"
20668 "An ordered list as a regular-expression\n")
20670 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20672 char *cl_number_or_name
= NULL
;
20677 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20678 seq
= argv
[idx
]->arg
;
20681 argv_find(argv
, argc
, "permit", &idx
);
20682 argv_find(argv
, argc
, "deny", &idx
);
20685 direct
= argv_find(argv
, argc
, "permit", &idx
)
20690 argv_find(argv
, argc
, "LINE", &idx
);
20691 str
= argv_concat(argv
, argc
, idx
);
20695 argv_find(argv
, argc
, "(100-500)", &idx
);
20696 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20697 cl_number_or_name
= argv
[idx
]->arg
;
20699 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20700 seq
, direct
, style
);
20702 XFREE(MTYPE_TMP
, str
);
20705 community_list_perror(vty
, ret
);
20706 return CMD_WARNING_CONFIG_FAILED
;
20709 return CMD_SUCCESS
;
20712 ALIAS(no_extcommunity_list_expanded_all
,
20713 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20714 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20715 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20716 "Extended Community list number (expanded)\n"
20717 "Specify expanded extcommunity-list\n"
20718 "Extended Community list name\n")
20720 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20722 struct community_entry
*entry
;
20724 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20725 if (entry
== list
->head
) {
20726 if (all_digit(list
->name
))
20727 vty_out(vty
, "Extended community %s list %s\n",
20728 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20730 : "(expanded) access",
20734 "Named extended community %s list %s\n",
20735 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20741 vty_out(vty
, " %s\n",
20742 community_direct_str(entry
->direct
));
20744 vty_out(vty
, " %s %s\n",
20745 community_direct_str(entry
->direct
),
20746 community_list_config_str(entry
));
20750 DEFUN (show_extcommunity_list
,
20751 show_bgp_extcommunity_list_cmd
,
20752 "show bgp extcommunity-list",
20755 "List extended-community list\n")
20757 struct community_list
*list
;
20758 struct community_list_master
*cm
;
20760 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20762 return CMD_SUCCESS
;
20764 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20765 extcommunity_list_show(vty
, list
);
20767 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20768 extcommunity_list_show(vty
, list
);
20770 return CMD_SUCCESS
;
20773 DEFUN (show_extcommunity_list_arg
,
20774 show_bgp_extcommunity_list_arg_cmd
,
20775 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20778 "List extended-community list\n"
20779 "Extcommunity-list number\n"
20780 "Extcommunity-list name\n"
20781 "Detailed information on extcommunity-list\n")
20783 int idx_comm_list
= 3;
20784 struct community_list
*list
;
20786 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20787 EXTCOMMUNITY_LIST_MASTER
);
20789 vty_out(vty
, "%% Can't find extcommunity-list\n");
20790 return CMD_WARNING
;
20793 extcommunity_list_show(vty
, list
);
20795 return CMD_SUCCESS
;
20798 /* Display community-list and extcommunity-list configuration. */
20799 static int community_list_config_write(struct vty
*vty
)
20801 struct community_list
*list
;
20802 struct community_entry
*entry
;
20803 struct community_list_master
*cm
;
20806 /* Community-list. */
20807 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20809 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20810 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20812 "bgp community-list %s seq %" PRId64
" %s %s\n",
20813 list
->name
, entry
->seq
,
20814 community_direct_str(entry
->direct
),
20815 community_list_config_str(entry
));
20818 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20819 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20821 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20822 entry
->style
== COMMUNITY_LIST_STANDARD
20825 list
->name
, entry
->seq
,
20826 community_direct_str(entry
->direct
),
20827 community_list_config_str(entry
));
20831 /* Extcommunity-list. */
20832 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20834 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20835 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20837 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20838 list
->name
, entry
->seq
,
20839 community_direct_str(entry
->direct
),
20840 community_list_config_str(entry
));
20843 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20844 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20846 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20847 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20850 list
->name
, entry
->seq
,
20851 community_direct_str(entry
->direct
),
20852 community_list_config_str(entry
));
20857 /* lcommunity-list. */
20858 cm
= community_list_master_lookup(bgp_clist
,
20859 LARGE_COMMUNITY_LIST_MASTER
);
20861 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20862 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20864 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20865 list
->name
, entry
->seq
,
20866 community_direct_str(entry
->direct
),
20867 community_list_config_str(entry
));
20870 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20871 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20873 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20875 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20878 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20879 community_list_config_str(entry
));
20886 static int community_list_config_write(struct vty
*vty
);
20887 static struct cmd_node community_list_node
= {
20888 .name
= "community list",
20889 .node
= COMMUNITY_LIST_NODE
,
20891 .config_write
= community_list_config_write
,
20894 static void community_list_vty(void)
20896 install_node(&community_list_node
);
20898 /* Community-list. */
20899 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20900 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20901 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20902 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20903 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20904 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20905 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20906 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20908 /* Extcommunity-list. */
20909 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20910 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20911 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20912 install_element(CONFIG_NODE
,
20913 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20914 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20915 install_element(CONFIG_NODE
,
20916 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20917 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20918 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20920 /* Large Community List */
20921 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20922 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20923 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20924 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20925 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20926 install_element(CONFIG_NODE
,
20927 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20928 install_element(CONFIG_NODE
,
20929 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20930 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20931 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20932 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20933 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20934 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20935 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20937 bgp_community_list_command_completion_setup();
20940 static struct cmd_node community_alias_node
= {
20941 .name
= "community alias",
20942 .node
= COMMUNITY_ALIAS_NODE
,
20944 .config_write
= bgp_community_alias_write
,
20947 void community_alias_vty(void)
20949 install_node(&community_alias_node
);
20951 /* Community-list. */
20952 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20954 bgp_community_alias_command_completion_setup();