2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
81 #include "bgpd/bgp_orr.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
129 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
130 { .val_bool
= false, .match_version
= "< 8.3", },
131 { .val_bool
= true },
133 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
134 { .val_bool
= false, .match_version
= "< 8.3", },
135 { .val_bool
= true },
138 DEFINE_HOOK(bgp_inst_config_write
,
139 (struct bgp
*bgp
, struct vty
*vty
),
141 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
142 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 /* Show BGP peer's information. */
157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
158 struct prefix
*range
, int exact
);
160 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
165 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
168 afi_t afi
, bool use_json
);
170 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
176 return BGP_IPV4_NODE
;
178 return BGP_IPV4M_NODE
;
179 case SAFI_LABELED_UNICAST
:
180 return BGP_IPV4L_NODE
;
182 return BGP_VPNV4_NODE
;
184 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
192 return BGP_IPV6_NODE
;
194 return BGP_IPV6M_NODE
;
195 case SAFI_LABELED_UNICAST
:
196 return BGP_IPV6L_NODE
;
198 return BGP_VPNV6_NODE
;
200 return BGP_FLOWSPECV6_NODE
;
203 return BGP_IPV4_NODE
;
206 return BGP_EVPN_NODE
;
209 // We should never be here but to clarify the switch statement..
210 return BGP_IPV4_NODE
;
213 // Impossible to happen
214 return BGP_IPV4_NODE
;
217 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
220 if (safi
== SAFI_UNICAST
)
221 return "IPv4 Unicast";
222 if (safi
== SAFI_MULTICAST
)
223 return "IPv4 Multicast";
224 if (safi
== SAFI_LABELED_UNICAST
)
225 return "IPv4 Labeled Unicast";
226 if (safi
== SAFI_MPLS_VPN
)
228 if (safi
== SAFI_ENCAP
)
230 if (safi
== SAFI_FLOWSPEC
)
231 return "IPv4 Flowspec";
232 } else if (afi
== AFI_IP6
) {
233 if (safi
== SAFI_UNICAST
)
234 return "IPv6 Unicast";
235 if (safi
== SAFI_MULTICAST
)
236 return "IPv6 Multicast";
237 if (safi
== SAFI_LABELED_UNICAST
)
238 return "IPv6 Labeled Unicast";
239 if (safi
== SAFI_MPLS_VPN
)
241 if (safi
== SAFI_ENCAP
)
243 if (safi
== SAFI_FLOWSPEC
)
244 return "IPv6 Flowspec";
245 } else if (afi
== AFI_L2VPN
) {
246 if (safi
== SAFI_EVPN
)
254 * Please note that we have intentionally camelCased
255 * the return strings here. So if you want
256 * to use this function, please ensure you
257 * are doing this within json output
259 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
262 if (safi
== SAFI_UNICAST
)
263 return "ipv4Unicast";
264 if (safi
== SAFI_MULTICAST
)
265 return "ipv4Multicast";
266 if (safi
== SAFI_LABELED_UNICAST
)
267 return "ipv4LabeledUnicast";
268 if (safi
== SAFI_MPLS_VPN
)
270 if (safi
== SAFI_ENCAP
)
272 if (safi
== SAFI_FLOWSPEC
)
273 return "ipv4Flowspec";
274 } else if (afi
== AFI_IP6
) {
275 if (safi
== SAFI_UNICAST
)
276 return "ipv6Unicast";
277 if (safi
== SAFI_MULTICAST
)
278 return "ipv6Multicast";
279 if (safi
== SAFI_LABELED_UNICAST
)
280 return "ipv6LabeledUnicast";
281 if (safi
== SAFI_MPLS_VPN
)
283 if (safi
== SAFI_ENCAP
)
285 if (safi
== SAFI_FLOWSPEC
)
286 return "ipv6Flowspec";
287 } else if (afi
== AFI_L2VPN
) {
288 if (safi
== SAFI_EVPN
)
295 /* unset srv6 locator */
296 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
299 struct listnode
*node
, *nnode
;
300 struct srv6_locator_chunk
*chunk
;
301 struct bgp_srv6_function
*func
;
304 /* release chunk notification via ZAPI */
305 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
306 bgp
->srv6_locator_name
);
311 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
312 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
313 srv6_locator_chunk_free(&chunk
);
316 /* refresh functions */
317 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
318 listnode_delete(bgp
->srv6_functions
, func
);
319 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
322 /* refresh tovpn_sid */
323 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
324 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
327 /* refresh vpnv4 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
331 /* refresh vpnv6 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
335 /* refresh per-vrf tovpn_sid */
336 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
339 /* update vpn bgp processes */
340 vpn_leak_postchange_all();
342 /* refresh tovpn_sid_locator */
343 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
344 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
347 /* refresh vpnv4 tovpn_sid_locator */
348 srv6_locator_chunk_free(
349 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
351 /* refresh vpnv6 tovpn_sid_locator */
352 srv6_locator_chunk_free(
353 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
355 /* refresh per-vrf tovpn_sid_locator */
356 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
359 /* clear locator name */
360 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
365 /* Utility function to get address family from current node. */
366 afi_t
bgp_node_afi(struct vty
*vty
)
374 case BGP_FLOWSPECV6_NODE
:
387 /* Utility function to get subsequent address family from current
389 safi_t
bgp_node_safi(struct vty
*vty
)
395 safi
= SAFI_MPLS_VPN
;
399 safi
= SAFI_MULTICAST
;
406 safi
= SAFI_LABELED_UNICAST
;
408 case BGP_FLOWSPECV4_NODE
:
409 case BGP_FLOWSPECV6_NODE
:
410 safi
= SAFI_FLOWSPEC
;
420 * Converts an AFI in string form to afi_t
422 * @param afi string, one of
426 * @return the corresponding afi_t
428 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
430 afi_t afi
= AFI_MAX
; /* unknown */
431 if (strmatch(afi_str
, "ipv4"))
433 else if (strmatch(afi_str
, "ipv6"))
435 else if (strmatch(afi_str
, "l2vpn"))
440 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
444 if (argv_find(argv
, argc
, "ipv4", index
)) {
448 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
452 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
460 /* supports <unicast|multicast|vpn|labeled-unicast> */
461 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
463 safi_t safi
= SAFI_MAX
; /* unknown */
464 if (strmatch(safi_str
, "multicast"))
465 safi
= SAFI_MULTICAST
;
466 else if (strmatch(safi_str
, "unicast"))
468 else if (strmatch(safi_str
, "vpn"))
469 safi
= SAFI_MPLS_VPN
;
470 else if (strmatch(safi_str
, "evpn"))
472 else if (strmatch(safi_str
, "labeled-unicast"))
473 safi
= SAFI_LABELED_UNICAST
;
474 else if (strmatch(safi_str
, "flowspec"))
475 safi
= SAFI_FLOWSPEC
;
479 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
483 if (argv_find(argv
, argc
, "unicast", index
)) {
486 *safi
= SAFI_UNICAST
;
487 } else if (argv_find(argv
, argc
, "multicast", index
)) {
490 *safi
= SAFI_MULTICAST
;
491 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
494 *safi
= SAFI_LABELED_UNICAST
;
495 } else if (argv_find(argv
, argc
, "vpn", index
)) {
498 *safi
= SAFI_MPLS_VPN
;
499 } else if (argv_find(argv
, argc
, "evpn", index
)) {
503 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
506 *safi
= SAFI_FLOWSPEC
;
512 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
515 * address-family identifier
518 * subsequent address-family identifier
521 * default_af string corresponding to the supplied afi/safi pair.
522 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
525 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
531 return "ipv4-unicast";
533 return "ipv4-multicast";
538 case SAFI_LABELED_UNICAST
:
539 return "ipv4-labeled-unicast";
541 return "ipv4-flowspec";
543 return "unknown-afi/safi";
549 return "ipv6-unicast";
551 return "ipv6-multicast";
556 case SAFI_LABELED_UNICAST
:
557 return "ipv6-labeled-unicast";
559 return "ipv6-flowspec";
561 return "unknown-afi/safi";
569 return "unknown-afi/safi";
573 return "unknown-afi/safi";
575 /* all AFIs are accounted for above, so this shouldn't happen */
576 return "unknown-afi/safi";
579 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
580 enum bgp_instance_type inst_type
)
582 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
584 if (ret
== BGP_CREATED
) {
585 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
586 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
588 if (DFLT_BGP_IMPORT_CHECK
)
589 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
590 if (DFLT_BGP_SHOW_HOSTNAME
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
592 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
594 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
596 if (DFLT_BGP_DETERMINISTIC_MED
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
598 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
600 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
602 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
604 if (DFLT_BGP_HARD_ADMIN_RESET
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
613 * bgp_vty_find_and_parse_afi_safi_bgp
615 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
616 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
617 * to appropriate values for the calling function. This is to allow the
618 * calling function to make decisions appropriate for the show command
619 * that is being parsed.
621 * The show commands are generally of the form:
622 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
623 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
625 * Since we use argv_find if the show command in particular doesn't have:
627 * [<view|vrf> VIEWVRFNAME]
628 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
629 * The command parsing should still be ok.
631 * vty -> The vty for the command so we can output some useful data in
632 * the event of a parse error in the vrf.
633 * argv -> The command tokens
634 * argc -> How many command tokens we have
635 * idx -> The current place in the command, generally should be 0 for this
637 * afi -> The parsed afi if it was included in the show command, returned here
638 * safi -> The parsed safi if it was included in the show command, returned here
639 * bgp -> Pointer to the bgp data structure we need to fill in.
640 * use_json -> json is configured or not
642 * The function returns the correct location in the parse tree for the
645 * Returns 0 for failure to parse correctly, else the idx position of where
646 * it found the last token.
648 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
649 struct cmd_token
**argv
, int argc
,
650 int *idx
, afi_t
*afi
, safi_t
*safi
,
651 struct bgp
**bgp
, bool use_json
)
653 char *vrf_name
= NULL
;
659 if (argv_find(argv
, argc
, "ip", idx
))
662 if (argv_find(argv
, argc
, "view", idx
))
663 vrf_name
= argv
[*idx
+ 1]->arg
;
664 else if (argv_find(argv
, argc
, "vrf", idx
)) {
665 vrf_name
= argv
[*idx
+ 1]->arg
;
666 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
670 if (strmatch(vrf_name
, "all"))
673 *bgp
= bgp_lookup_by_name(vrf_name
);
676 json_object
*json
= NULL
;
677 json
= json_object_new_object();
678 json_object_string_add(
680 "View/Vrf is unknown");
684 vty_out(vty
, "View/Vrf %s is unknown\n",
691 *bgp
= bgp_get_default();
694 json_object
*json
= NULL
;
695 json
= json_object_new_object();
696 json_object_string_add(
698 "Default BGP instance not found");
703 "Default BGP instance not found\n");
709 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
710 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
716 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
718 struct interface
*ifp
= NULL
;
719 struct listnode
*node
;
720 struct bgp_listener
*listener
;
721 union sockunion all_su
;
723 if (su
->sa
.sa_family
== AF_INET
) {
724 (void)str2sockunion("0.0.0.0", &all_su
);
725 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
726 } else if (su
->sa
.sa_family
== AF_INET6
) {
727 (void)str2sockunion("::", &all_su
);
728 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
729 su
->sin6
.sin6_scope_id
,
734 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
735 if (sockunion_family(su
) !=
736 sockunion_family(&listener
->su
))
739 /* If 0.0.0.0/:: is a listener, then treat as self and
742 if (!sockunion_cmp(&listener
->su
, su
) ||
743 !sockunion_cmp(&listener
->su
, &all_su
))
751 /* Utility function for looking up peer from VTY. */
752 /* This is used only for configuration, so disallow if attempted on
753 * a dynamic neighbor.
755 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
757 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
766 ret
= str2sockunion(ip_str
, &su
);
768 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
770 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
773 "%% Malformed address or name: %s\n",
779 peer
= peer_lookup(bgp
, &su
);
782 "%% Specify remote-as or peer-group commands first\n");
785 if (peer_dynamic_neighbor(peer
)) {
787 "%% Operation not allowed on a dynamic neighbor\n");
794 /* Utility function for looking up peer or peer group. */
795 /* This is used only for configuration, so disallow if attempted on
796 * a dynamic neighbor.
798 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
800 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
803 struct peer
*peer
= NULL
;
804 struct peer_group
*group
= NULL
;
810 ret
= str2sockunion(peer_str
, &su
);
812 /* IP address, locate peer. */
813 peer
= peer_lookup(bgp
, &su
);
815 /* Not IP, could match either peer configured on interface or a
817 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
819 group
= peer_group_lookup(bgp
, peer_str
);
823 if (peer_dynamic_neighbor(peer
)) {
825 "%% Operation not allowed on a dynamic neighbor\n");
835 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
840 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
842 const char *str
= NULL
;
847 case BGP_GR_NO_OPERATION
:
849 case BGP_ERR_INVALID_VALUE
:
850 str
= "Invalid value";
852 case BGP_ERR_INVALID_FLAG
:
853 str
= "Invalid flag";
855 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
856 str
= "Peer-group has been shutdown. Activate the peer-group first";
858 case BGP_ERR_PEER_FLAG_CONFLICT
:
859 str
= "Can't set override-capability and strict-capability-match at the same time";
861 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
862 str
= "Specify remote-as or peer-group remote AS first";
864 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
865 str
= "Cannot change the peer-group. Deconfigure first";
867 case BGP_ERR_PEER_GROUP_MISMATCH
:
868 str
= "Peer is not a member of this peer-group";
870 case BGP_ERR_PEER_FILTER_CONFLICT
:
871 str
= "Prefix/distribute list can not co-exist";
873 case BGP_ERR_NOT_INTERNAL_PEER
:
874 str
= "Invalid command. Not an internal neighbor";
876 case BGP_ERR_REMOVE_PRIVATE_AS
:
877 str
= "remove-private-AS cannot be configured for IBGP peers";
879 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
880 str
= "Cannot have local-as same as BGP AS number";
882 case BGP_ERR_TCPSIG_FAILED
:
883 str
= "Error while applying TCP-Sig to session(s)";
885 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
886 str
= "ebgp-multihop and ttl-security cannot be configured together";
888 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
889 str
= "ttl-security only allowed for EBGP peers";
891 case BGP_ERR_AS_OVERRIDE
:
892 str
= "as-override cannot be configured for IBGP peers";
894 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
895 str
= "Invalid limit for number of dynamic neighbors";
897 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
898 str
= "Dynamic neighbor listen range already exists";
900 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
901 str
= "Operation not allowed on a dynamic neighbor";
903 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
904 str
= "Operation not allowed on a directly connected neighbor";
906 case BGP_ERR_PEER_SAFI_CONFLICT
:
907 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
909 case BGP_ERR_GR_INVALID_CMD
:
910 str
= "The Graceful Restart command used is not valid at this moment.";
912 case BGP_ERR_GR_OPERATION_FAILED
:
913 str
= "The Graceful Restart Operation failed due to an err.";
915 case BGP_ERR_PEER_GROUP_MEMBER
:
916 str
= "Peer-group member cannot override remote-as of peer-group.";
918 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
919 str
= "Peer-group members must be all internal or all external.";
921 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
922 str
= "Range specified cannot be deleted because it is not part of current config.";
924 case BGP_ERR_INSTANCE_MISMATCH
:
925 str
= "Instance specified does not match the current instance.";
927 case BGP_ERR_NO_INTERFACE_CONFIG
:
928 str
= "Interface specified is not being used for interface based peer.";
930 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
931 str
= "No configuration already specified for soft reconfiguration.";
933 case BGP_ERR_AS_MISMATCH
:
934 str
= "BGP is already running.";
936 case BGP_ERR_AF_UNCONFIGURED
:
937 str
= "AFI/SAFI specified is not currently configured.";
939 case BGP_ERR_INVALID_AS
:
940 str
= "Confederation AS specified is the same AS as our AS.";
942 case BGP_ERR_INVALID_ROLE_NAME
:
943 str
= "Invalid role name";
945 case BGP_ERR_INVALID_INTERNAL_ROLE
:
946 str
= "External roles can be set only on eBGP session";
948 case BGP_ERR_PEER_ORR_CONFIGURED
:
949 str
= "Deconfigure optimal-route-reflection on this peer first";
953 vty_out(vty
, "%% %s\n", str
);
954 return CMD_WARNING_CONFIG_FAILED
;
959 /* BGP clear sort. */
968 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
969 safi_t safi
, int error
)
972 case BGP_ERR_AF_UNCONFIGURED
:
975 "%% BGP: Enable %s address family for the neighbor %s\n",
976 get_afi_safi_str(afi
, safi
, false), peer
->host
);
979 "%% BGP: Enable %s address family for the neighbor %s",
980 get_afi_safi_str(afi
, safi
, false), peer
->host
);
982 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
985 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
989 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
997 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
998 struct listnode
**nnode
, enum bgp_clear_type stype
)
1001 struct peer_af
*paf
;
1003 /* if afi/.safi not specified, spin thru all of them */
1004 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1007 enum bgp_af_index index
;
1009 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1010 paf
= peer
->peer_af_array
[index
];
1014 if (paf
&& paf
->subgroup
)
1015 SET_FLAG(paf
->subgroup
->sflags
,
1016 SUBGRP_STATUS_FORCE_UPDATES
);
1019 tmp_safi
= paf
->safi
;
1020 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1023 if (stype
== BGP_CLEAR_SOFT_NONE
)
1024 ret
= peer_clear(peer
, nnode
);
1026 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1029 /* if afi specified and safi not, spin thru safis on this afi */
1030 } else if (safi
== SAFI_UNSPEC
) {
1033 for (tmp_safi
= SAFI_UNICAST
;
1034 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1035 if (!peer
->afc
[afi
][tmp_safi
])
1038 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1039 if (paf
&& paf
->subgroup
)
1040 SET_FLAG(paf
->subgroup
->sflags
,
1041 SUBGRP_STATUS_FORCE_UPDATES
);
1043 if (stype
== BGP_CLEAR_SOFT_NONE
)
1044 ret
= peer_clear(peer
, nnode
);
1046 ret
= peer_clear_soft(peer
, afi
,
1049 /* both afi/safi specified, let the caller know if not defined */
1051 if (!peer
->afc
[afi
][safi
])
1054 paf
= peer_af_find(peer
, afi
, safi
);
1055 if (paf
&& paf
->subgroup
)
1056 SET_FLAG(paf
->subgroup
->sflags
,
1057 SUBGRP_STATUS_FORCE_UPDATES
);
1059 if (stype
== BGP_CLEAR_SOFT_NONE
)
1060 ret
= peer_clear(peer
, nnode
);
1062 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1068 /* `clear ip bgp' functions. */
1069 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1070 enum clear_sort sort
, enum bgp_clear_type stype
,
1077 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1079 /* Clear all neighbors. */
1081 * Pass along pointer to next node to peer_clear() when walking all
1082 * nodes on the BGP instance as that may get freed if it is a
1085 if (sort
== clear_all
) {
1086 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1088 bgp_peer_gr_flags_update(peer
);
1090 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1091 gr_router_detected
= true;
1093 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1097 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1100 if (gr_router_detected
1101 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1102 bgp_zebra_send_capabilities(bgp
, false);
1103 } else if (!gr_router_detected
1104 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1105 bgp_zebra_send_capabilities(bgp
, true);
1108 /* This is to apply read-only mode on this clear. */
1109 if (stype
== BGP_CLEAR_SOFT_NONE
)
1110 bgp
->update_delay_over
= 0;
1115 /* Clear specified neighbor. */
1116 if (sort
== clear_peer
) {
1119 /* Make sockunion for lookup. */
1120 ret
= str2sockunion(arg
, &su
);
1122 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1124 peer
= peer_lookup_by_hostname(bgp
, arg
);
1127 "Malformed address or name: %s\n",
1133 peer
= peer_lookup(bgp
, &su
);
1136 "%% BGP: Unknown neighbor - \"%s\"\n",
1142 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1143 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1145 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1147 /* if afi/safi not defined for this peer, let caller know */
1149 ret
= BGP_ERR_AF_UNCONFIGURED
;
1152 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1157 /* Clear all neighbors belonging to a specific peer-group. */
1158 if (sort
== clear_group
) {
1159 struct peer_group
*group
;
1161 group
= peer_group_lookup(bgp
, arg
);
1163 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1167 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1168 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1171 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1178 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1179 get_afi_safi_str(afi
, safi
, false), arg
);
1184 /* Clear all external (eBGP) neighbors. */
1185 if (sort
== clear_external
) {
1186 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1187 if (peer
->sort
== BGP_PEER_IBGP
)
1190 bgp_peer_gr_flags_update(peer
);
1192 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1193 gr_router_detected
= true;
1195 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1198 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1203 if (gr_router_detected
1204 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1205 bgp_zebra_send_capabilities(bgp
, false);
1206 } else if (!gr_router_detected
1207 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1208 bgp_zebra_send_capabilities(bgp
, true);
1213 "%% BGP: No external %s peer is configured\n",
1214 get_afi_safi_str(afi
, safi
, false));
1219 /* Clear all neighbors belonging to a specific AS. */
1220 if (sort
== clear_as
) {
1221 as_t as
= strtoul(arg
, NULL
, 10);
1223 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1227 bgp_peer_gr_flags_update(peer
);
1229 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1230 gr_router_detected
= true;
1232 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1235 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1240 if (gr_router_detected
1241 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1242 bgp_zebra_send_capabilities(bgp
, false);
1243 } else if (!gr_router_detected
1244 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1245 bgp_zebra_send_capabilities(bgp
, true);
1250 "%% BGP: No %s peer is configured with AS %s\n",
1251 get_afi_safi_str(afi
, safi
, false), arg
);
1259 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1260 safi_t safi
, enum clear_sort sort
,
1261 enum bgp_clear_type stype
, const char *arg
)
1265 /* BGP structure lookup. */
1267 bgp
= bgp_lookup_by_name(name
);
1269 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1273 bgp
= bgp_get_default();
1275 vty_out(vty
, "No BGP process is configured\n");
1280 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1283 /* clear soft inbound */
1284 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1289 FOREACH_AFI_SAFI (afi
, safi
)
1290 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1291 BGP_CLEAR_SOFT_IN
, NULL
);
1294 /* clear soft outbound */
1295 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1300 FOREACH_AFI_SAFI (afi
, safi
)
1301 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1302 BGP_CLEAR_SOFT_OUT
, NULL
);
1306 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1308 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1311 #ifndef VTYSH_EXTRACT_PL
1312 #include "bgpd/bgp_vty_clippy.c"
1315 DEFUN_HIDDEN (bgp_local_mac
,
1317 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1319 "Local MAC config\n"
1320 "VxLAN Network Identifier\n"
1324 "mac-mobility sequence\n"
1334 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1335 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1336 vty_out(vty
, "%% Malformed MAC address\n");
1339 memset(&ip
, 0, sizeof(ip
));
1340 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1342 bgp
= bgp_get_default();
1344 vty_out(vty
, "Default BGP instance is not there\n");
1348 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1351 vty_out(vty
, "Internal error\n");
1358 DEFUN_HIDDEN (no_bgp_local_mac
,
1359 no_bgp_local_mac_cmd
,
1360 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1363 "Local MAC config\n"
1364 "VxLAN Network Identifier\n"
1375 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1376 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1377 vty_out(vty
, "%% Malformed MAC address\n");
1380 memset(&ip
, 0, sizeof(ip
));
1382 bgp
= bgp_get_default();
1384 vty_out(vty
, "Default BGP instance is not there\n");
1388 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1390 vty_out(vty
, "Internal error\n");
1397 DEFUN (no_synchronization
,
1398 no_synchronization_cmd
,
1399 "no synchronization",
1401 "Perform IGP synchronization\n")
1406 DEFUN (no_auto_summary
,
1407 no_auto_summary_cmd
,
1410 "Enable automatic network number summarization\n")
1415 /* "router bgp" commands. */
1416 DEFUN_NOSH (router_bgp
,
1418 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1422 BGP_INSTANCE_HELP_STR
)
1425 int idx_view_vrf
= 3;
1431 const char *name
= NULL
;
1432 enum bgp_instance_type inst_type
;
1434 // "router bgp" without an ASN
1436 // Pending: Make VRF option available for ASN less config
1437 bgp
= bgp_get_default();
1440 vty_out(vty
, "%% No BGP process is configured\n");
1441 return CMD_WARNING_CONFIG_FAILED
;
1444 if (listcount(bm
->bgp
) > 1) {
1445 vty_out(vty
, "%% Please specify ASN and VRF\n");
1446 return CMD_WARNING_CONFIG_FAILED
;
1452 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1454 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1455 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1456 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1458 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1460 name
= argv
[idx_vrf
]->arg
;
1462 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1463 if (strmatch(name
, VRF_DEFAULT_NAME
))
1466 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1467 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1468 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1471 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1472 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1474 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1476 case BGP_ERR_AS_MISMATCH
:
1477 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1478 return CMD_WARNING_CONFIG_FAILED
;
1479 case BGP_ERR_INSTANCE_MISMATCH
:
1481 "BGP instance name and AS number mismatch\n");
1483 "BGP instance is already running; AS is %u\n",
1485 return CMD_WARNING_CONFIG_FAILED
;
1489 * If we just instantiated the default instance, complete
1490 * any pending VRF-VPN leaking that was configured via
1491 * earlier "router bgp X vrf FOO" blocks.
1493 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1494 vpn_leak_postchange_all();
1496 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1497 bgp_vpn_leak_export(bgp
);
1498 /* Pending: handle when user tries to change a view to vrf n vv.
1502 /* unset the auto created flag as the user config is now present */
1503 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1504 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1509 /* "no router bgp" commands. */
1510 DEFUN (no_router_bgp
,
1512 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1517 BGP_INSTANCE_HELP_STR
)
1523 const char *name
= NULL
;
1525 // "no router bgp" without an ASN
1527 // Pending: Make VRF option available for ASN less config
1528 bgp
= bgp_get_default();
1531 vty_out(vty
, "%% No BGP process is configured\n");
1532 return CMD_WARNING_CONFIG_FAILED
;
1535 if (listcount(bm
->bgp
) > 1) {
1536 vty_out(vty
, "%% Please specify ASN and VRF\n");
1537 return CMD_WARNING_CONFIG_FAILED
;
1541 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1543 return CMD_WARNING_CONFIG_FAILED
;
1546 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1549 name
= argv
[idx_vrf
]->arg
;
1550 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1551 && strmatch(name
, VRF_DEFAULT_NAME
))
1555 /* Lookup bgp structure. */
1556 bgp
= bgp_lookup(as
, name
);
1558 vty_out(vty
, "%% Can't find BGP instance\n");
1559 return CMD_WARNING_CONFIG_FAILED
;
1563 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1565 return CMD_WARNING_CONFIG_FAILED
;
1568 /* Cannot delete default instance if vrf instances exist */
1569 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1570 struct listnode
*node
;
1571 struct bgp
*tmp_bgp
;
1573 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1574 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1576 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1577 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1578 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1579 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1581 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1582 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1583 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1584 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1585 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1586 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1587 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1588 (bgp
== bgp_get_evpn() &&
1589 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1590 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1591 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1592 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1593 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1594 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1595 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1596 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1597 (hashcount(tmp_bgp
->vnihash
))) {
1599 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1600 return CMD_WARNING_CONFIG_FAILED
;
1611 /* bgp session-dscp */
1613 DEFPY (bgp_session_dscp
,
1614 bgp_session_dscp_cmd
,
1615 "bgp session-dscp (0-63)$dscp",
1617 "Override default (C6) bgp TCP session DSCP value\n"
1618 "Manually configured dscp parameter\n")
1620 bm
->tcp_dscp
= dscp
<< 2;
1625 DEFPY (no_bgp_session_dscp
,
1626 no_bgp_session_dscp_cmd
,
1627 "no bgp session-dscp [(0-63)]",
1630 "Override default (C6) bgp TCP session DSCP value\n"
1631 "Manually configured dscp parameter\n")
1633 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1638 /* BGP router-id. */
1640 DEFPY (bgp_router_id
,
1642 "bgp router-id A.B.C.D",
1644 "Override configured router identifier\n"
1645 "Manually configured router identifier\n")
1647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1648 bgp_router_id_static_set(bgp
, router_id
);
1652 DEFPY (no_bgp_router_id
,
1653 no_bgp_router_id_cmd
,
1654 "no bgp router-id [A.B.C.D]",
1657 "Override configured router identifier\n"
1658 "Manually configured router identifier\n")
1660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1662 if (router_id_str
) {
1663 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1664 vty_out(vty
, "%% BGP router-id doesn't match\n");
1665 return CMD_WARNING_CONFIG_FAILED
;
1669 router_id
.s_addr
= 0;
1670 bgp_router_id_static_set(bgp
, router_id
);
1675 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1676 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1678 "Add community specific parameters\n"
1679 "Create an alias for a community\n"
1680 "Community (AA:BB or AA:BB:CC)\n"
1683 struct community_alias ca
= {};
1684 struct community_alias
*lookup_community
;
1685 struct community_alias
*lookup_alias
;
1686 struct community
*comm
;
1687 struct lcommunity
*lcomm
;
1688 uint8_t invalid
= 0;
1690 comm
= community_str2com(community
);
1693 community_free(&comm
);
1695 lcomm
= lcommunity_str2com(community
);
1698 lcommunity_free(&lcomm
);
1701 vty_out(vty
, "Invalid community format\n");
1705 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1706 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1708 lookup_community
= bgp_ca_community_lookup(&ca
);
1709 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1712 bgp_ca_alias_delete(&ca
);
1713 bgp_ca_community_delete(&ca
);
1716 /* Lookup if community hash table has an item
1717 * with the same alias name.
1719 strlcpy(ca
.community
, lookup_alias
->community
,
1720 sizeof(ca
.community
));
1721 if (bgp_ca_community_lookup(&ca
)) {
1723 "community (%s) already has this alias (%s)\n",
1724 lookup_alias
->community
,
1725 lookup_alias
->alias
);
1728 bgp_ca_alias_delete(&ca
);
1731 if (lookup_community
) {
1732 /* Lookup if alias hash table has an item
1733 * with the same community.
1735 strlcpy(ca
.alias
, lookup_community
->alias
,
1737 if (bgp_ca_alias_lookup(&ca
)) {
1739 "alias (%s) already has this community (%s)\n",
1740 lookup_community
->alias
,
1741 lookup_community
->community
);
1744 bgp_ca_community_delete(&ca
);
1747 bgp_ca_alias_insert(&ca
);
1748 bgp_ca_community_insert(&ca
);
1754 DEFPY (bgp_global_suppress_fib_pending
,
1755 bgp_global_suppress_fib_pending_cmd
,
1756 "[no] bgp suppress-fib-pending",
1759 "Advertise only routes that are programmed in kernel to peers globally\n")
1761 bm_wait_for_fib_set(!no
);
1766 DEFPY (bgp_suppress_fib_pending
,
1767 bgp_suppress_fib_pending_cmd
,
1768 "[no] bgp suppress-fib-pending",
1771 "Advertise only routes that are programmed in kernel to peers\n")
1773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1775 bgp_suppress_fib_pending_set(bgp
, !no
);
1780 /* BGP Cluster ID. */
1781 DEFUN (bgp_cluster_id
,
1783 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1785 "Configure Route-Reflector Cluster-id\n"
1786 "Route-Reflector Cluster-id in IP address format\n"
1787 "Route-Reflector Cluster-id as 32 bit quantity\n")
1789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1792 struct in_addr cluster
;
1794 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1796 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1797 return CMD_WARNING_CONFIG_FAILED
;
1800 bgp_cluster_id_set(bgp
, &cluster
);
1801 bgp_clear_star_soft_out(vty
, bgp
->name
);
1806 DEFUN (no_bgp_cluster_id
,
1807 no_bgp_cluster_id_cmd
,
1808 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1811 "Configure Route-Reflector Cluster-id\n"
1812 "Route-Reflector Cluster-id in IP address format\n"
1813 "Route-Reflector Cluster-id as 32 bit quantity\n")
1815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1816 bgp_cluster_id_unset(bgp
);
1817 bgp_clear_star_soft_out(vty
, bgp
->name
);
1826 "Disable BGP route installation to RIB (Zebra)\n")
1828 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1830 "%% No-RIB option is already set, nothing to do here.\n");
1834 bgp_option_norib_set_runtime();
1839 DEFPY (no_bgp_norib
,
1844 "Disable BGP route installation to RIB (Zebra)\n")
1846 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1848 "%% No-RIB option is not set, nothing to do here.\n");
1852 bgp_option_norib_unset_runtime();
1857 DEFPY (no_bgp_send_extra_data
,
1858 no_bgp_send_extra_data_cmd
,
1859 "[no] bgp send-extra-data zebra",
1862 "Extra data to Zebra for display/use\n"
1866 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1868 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1873 DEFUN (bgp_confederation_identifier
,
1874 bgp_confederation_identifier_cmd
,
1875 "bgp confederation identifier (1-4294967295)",
1877 "AS confederation parameters\n"
1879 "Set routing domain confederation AS\n")
1881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1885 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1887 bgp_confederation_id_set(bgp
, as
);
1892 DEFUN (no_bgp_confederation_identifier
,
1893 no_bgp_confederation_identifier_cmd
,
1894 "no bgp confederation identifier [(1-4294967295)]",
1897 "AS confederation parameters\n"
1899 "Set routing domain confederation AS\n")
1901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1902 bgp_confederation_id_unset(bgp
);
1907 DEFUN (bgp_confederation_peers
,
1908 bgp_confederation_peers_cmd
,
1909 "bgp confederation peers (1-4294967295)...",
1911 "AS confederation parameters\n"
1912 "Peer ASs in BGP confederation\n"
1915 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1920 for (i
= idx_asn
; i
< argc
; i
++) {
1921 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1923 if (bgp
->as
== as
) {
1925 "%% Local member-AS not allowed in confed peer list\n");
1929 bgp_confederation_peers_add(bgp
, as
);
1934 DEFUN (no_bgp_confederation_peers
,
1935 no_bgp_confederation_peers_cmd
,
1936 "no bgp confederation peers (1-4294967295)...",
1939 "AS confederation parameters\n"
1940 "Peer ASs in BGP confederation\n"
1943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1948 for (i
= idx_asn
; i
< argc
; i
++) {
1949 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1951 bgp_confederation_peers_remove(bgp
, as
);
1957 * Central routine for maximum-paths configuration.
1958 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1959 * @set: 1 for setting values, 0 for removing the max-paths config.
1961 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1962 const char *mpaths
, uint16_t options
,
1965 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1966 uint16_t maxpaths
= 0;
1971 afi
= bgp_node_afi(vty
);
1972 safi
= bgp_node_safi(vty
);
1975 maxpaths
= strtol(mpaths
, NULL
, 10);
1976 if (maxpaths
> multipath_num
) {
1978 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1979 maxpaths
, multipath_num
);
1980 return CMD_WARNING_CONFIG_FAILED
;
1982 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1985 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1989 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1990 (set
== 1) ? "" : "un",
1991 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1992 maxpaths
, afi
, safi
);
1993 return CMD_WARNING_CONFIG_FAILED
;
1996 bgp_recalculate_all_bestpaths(bgp
);
2001 DEFUN (bgp_maxmed_admin
,
2002 bgp_maxmed_admin_cmd
,
2003 "bgp max-med administrative ",
2005 "Advertise routes with max-med\n"
2006 "Administratively applied, for an indefinite period\n")
2008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2010 bgp
->v_maxmed_admin
= 1;
2011 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2013 bgp_maxmed_update(bgp
);
2018 DEFUN (bgp_maxmed_admin_medv
,
2019 bgp_maxmed_admin_medv_cmd
,
2020 "bgp max-med administrative (0-4294967295)",
2022 "Advertise routes with max-med\n"
2023 "Administratively applied, for an indefinite period\n"
2024 "Max MED value to be used\n")
2026 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 bgp
->v_maxmed_admin
= 1;
2030 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2032 bgp_maxmed_update(bgp
);
2037 DEFUN (no_bgp_maxmed_admin
,
2038 no_bgp_maxmed_admin_cmd
,
2039 "no bgp max-med administrative [(0-4294967295)]",
2042 "Advertise routes with max-med\n"
2043 "Administratively applied, for an indefinite period\n"
2044 "Max MED value to be used\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2047 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2048 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2049 bgp_maxmed_update(bgp
);
2054 DEFUN (bgp_maxmed_onstartup
,
2055 bgp_maxmed_onstartup_cmd
,
2056 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2058 "Advertise routes with max-med\n"
2059 "Effective on a startup\n"
2060 "Time (seconds) period for max-med\n"
2061 "Max MED value to be used\n")
2063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2066 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2067 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2068 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2069 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2071 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2073 bgp_maxmed_update(bgp
);
2078 DEFUN (no_bgp_maxmed_onstartup
,
2079 no_bgp_maxmed_onstartup_cmd
,
2080 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2083 "Advertise routes with max-med\n"
2084 "Effective on a startup\n"
2085 "Time (seconds) period for max-med\n"
2086 "Max MED value to be used\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 /* Cancel max-med onstartup if its on */
2091 if (bgp
->t_maxmed_onstartup
) {
2092 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2093 bgp
->maxmed_onstartup_over
= 1;
2096 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2097 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2099 bgp_maxmed_update(bgp
);
2104 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2105 uint16_t update_delay
,
2106 uint16_t establish_wait
)
2108 struct listnode
*node
, *nnode
;
2110 bool vrf_cfg
= false;
2113 * See if update-delay is set per-vrf and warn user to delete it
2114 * Note that we only need to check this if this is the first time
2115 * setting the global config.
2117 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2118 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2119 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2121 "%% update-delay configuration found in vrf %s\n",
2122 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2132 "%%Failed: global update-delay config not permitted\n");
2136 if (!establish_wait
) { /* update-delay <delay> */
2137 bm
->v_update_delay
= update_delay
;
2138 bm
->v_establish_wait
= bm
->v_update_delay
;
2140 /* update-delay <delay> <establish-wait> */
2141 if (update_delay
< establish_wait
) {
2143 "%%Failed: update-delay less than the establish-wait!\n");
2144 return CMD_WARNING_CONFIG_FAILED
;
2147 bm
->v_update_delay
= update_delay
;
2148 bm
->v_establish_wait
= establish_wait
;
2151 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2152 bgp
->v_update_delay
= bm
->v_update_delay
;
2153 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2159 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2161 struct listnode
*node
, *nnode
;
2164 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2165 bm
->v_establish_wait
= bm
->v_update_delay
;
2167 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2168 bgp
->v_update_delay
= bm
->v_update_delay
;
2169 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2175 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2176 uint16_t establish_wait
)
2178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2180 /* if configured globally, per-instance config is not allowed */
2181 if (bm
->v_update_delay
) {
2183 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2184 return CMD_WARNING_CONFIG_FAILED
;
2188 if (!establish_wait
) /* update-delay <delay> */
2190 bgp
->v_update_delay
= update_delay
;
2191 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2195 /* update-delay <delay> <establish-wait> */
2196 if (update_delay
< establish_wait
) {
2198 "%%Failed: update-delay less than the establish-wait!\n");
2199 return CMD_WARNING_CONFIG_FAILED
;
2202 bgp
->v_update_delay
= update_delay
;
2203 bgp
->v_establish_wait
= establish_wait
;
2208 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2212 /* If configured globally, cannot remove from one bgp instance */
2213 if (bm
->v_update_delay
) {
2215 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2216 return CMD_WARNING_CONFIG_FAILED
;
2218 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2219 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2224 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2226 /* If configured globally, no need to display per-instance value */
2227 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2228 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2229 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2230 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2235 /* Global update-delay configuration */
2236 DEFPY (bgp_global_update_delay
,
2237 bgp_global_update_delay_cmd
,
2238 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2240 "Force initial delay for best-path and updates for all bgp instances\n"
2241 "Max delay in seconds\n"
2242 "Establish wait in seconds\n")
2244 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2247 /* Global update-delay deconfiguration */
2248 DEFPY (no_bgp_global_update_delay
,
2249 no_bgp_global_update_delay_cmd
,
2250 "no bgp update-delay [(0-3600) [(1-3600)]]",
2253 "Force initial delay for best-path and updates\n"
2254 "Max delay in seconds\n"
2255 "Establish wait in seconds\n")
2257 return bgp_global_update_delay_deconfig_vty(vty
);
2260 /* Update-delay configuration */
2262 DEFPY (bgp_update_delay
,
2263 bgp_update_delay_cmd
,
2264 "update-delay (0-3600)$delay [(1-3600)$wait]",
2265 "Force initial delay for best-path and updates\n"
2266 "Max delay in seconds\n"
2267 "Establish wait in seconds\n")
2269 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2272 /* Update-delay deconfiguration */
2273 DEFPY (no_bgp_update_delay
,
2274 no_bgp_update_delay_cmd
,
2275 "no update-delay [(0-3600) [(1-3600)]]",
2277 "Force initial delay for best-path and updates\n"
2278 "Max delay in seconds\n"
2279 "Establish wait in seconds\n")
2281 return bgp_update_delay_deconfig_vty(vty
);
2285 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2290 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2291 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2296 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2302 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2307 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2310 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2311 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2312 vty_out(vty
, " write-quanta %d\n", quanta
);
2315 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2318 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2319 if (quanta
!= BGP_READ_PACKET_MAX
)
2320 vty_out(vty
, " read-quanta %d\n", quanta
);
2323 /* Packet quanta configuration
2325 * XXX: The value set here controls the size of a stack buffer in the IO
2326 * thread. When changing these limits be careful to prevent stack overflow.
2328 * Furthermore, the maximums used here should correspond to
2329 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2331 DEFPY (bgp_wpkt_quanta
,
2332 bgp_wpkt_quanta_cmd
,
2333 "[no] write-quanta (1-64)$quanta",
2335 "How many packets to write to peer socket per run\n"
2336 "Number of packets\n")
2338 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2341 DEFPY (bgp_rpkt_quanta
,
2342 bgp_rpkt_quanta_cmd
,
2343 "[no] read-quanta (1-10)$quanta",
2345 "How many packets to read from peer socket per I/O cycle\n"
2346 "Number of packets\n")
2348 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2351 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2353 if (!bgp
->heuristic_coalesce
)
2354 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2357 /* BGP TCP keepalive */
2358 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2360 if (bgp
->tcp_keepalive_idle
) {
2361 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2362 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2363 bgp
->tcp_keepalive_probes
);
2367 DEFUN (bgp_coalesce_time
,
2368 bgp_coalesce_time_cmd
,
2369 "coalesce-time (0-4294967295)",
2370 "Subgroup coalesce timer\n"
2371 "Subgroup coalesce timer value (in ms)\n")
2373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2377 bgp
->heuristic_coalesce
= false;
2379 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2380 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2385 DEFUN (no_bgp_coalesce_time
,
2386 no_bgp_coalesce_time_cmd
,
2387 "no coalesce-time (0-4294967295)",
2389 "Subgroup coalesce timer\n"
2390 "Subgroup coalesce timer value (in ms)\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2394 bgp
->heuristic_coalesce
= true;
2395 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2399 /* Maximum-paths configuration */
2400 DEFUN (bgp_maxpaths
,
2402 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2403 "Forward packets over multiple paths\n"
2404 "Number of paths\n")
2407 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2408 argv
[idx_number
]->arg
, 0, 1);
2411 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2412 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2413 "Forward packets over multiple paths\n"
2414 "Number of paths\n")
2416 DEFUN (bgp_maxpaths_ibgp
,
2417 bgp_maxpaths_ibgp_cmd
,
2418 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2419 "Forward packets over multiple paths\n"
2421 "Number of paths\n")
2424 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2425 argv
[idx_number
]->arg
, 0, 1);
2428 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2429 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2430 "Forward packets over multiple paths\n"
2432 "Number of paths\n")
2434 DEFUN (bgp_maxpaths_ibgp_cluster
,
2435 bgp_maxpaths_ibgp_cluster_cmd
,
2436 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2437 "Forward packets over multiple paths\n"
2440 "Match the cluster length\n")
2443 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2444 argv
[idx_number
]->arg
, true, 1);
2447 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2448 "maximum-paths ibgp " CMD_RANGE_STR(
2449 1, MULTIPATH_NUM
) " equal-cluster-length",
2450 "Forward packets over multiple paths\n"
2453 "Match the cluster length\n")
2455 DEFUN (no_bgp_maxpaths
,
2456 no_bgp_maxpaths_cmd
,
2457 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2459 "Forward packets over multiple paths\n"
2460 "Number of paths\n")
2462 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2465 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2466 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2467 "Forward packets over multiple paths\n"
2468 "Number of paths\n")
2470 DEFUN (no_bgp_maxpaths_ibgp
,
2471 no_bgp_maxpaths_ibgp_cmd
,
2472 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2474 "Forward packets over multiple paths\n"
2477 "Match the cluster length\n")
2479 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2482 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2483 "no maximum-paths ibgp [" CMD_RANGE_STR(
2484 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2486 "Forward packets over multiple paths\n"
2489 "Match the cluster length\n")
2491 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2492 afi_t afi
, safi_t safi
)
2494 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2495 vty_out(vty
, " maximum-paths %d\n",
2496 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2499 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2500 vty_out(vty
, " maximum-paths ibgp %d",
2501 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2502 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2503 vty_out(vty
, " equal-cluster-length");
2512 "timers bgp (0-65535) (0-65535)",
2513 "Adjust routing timers\n"
2515 "Keepalive interval\n"
2518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2520 int idx_number_2
= 3;
2521 unsigned long keepalive
= 0;
2522 unsigned long holdtime
= 0;
2524 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2525 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2527 /* Holdtime value check. */
2528 if (holdtime
< 3 && holdtime
!= 0) {
2530 "%% hold time value must be either 0 or greater than 3\n");
2531 return CMD_WARNING_CONFIG_FAILED
;
2534 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2535 BGP_DEFAULT_DELAYOPEN
);
2540 DEFUN (no_bgp_timers
,
2542 "no timers bgp [(0-65535) (0-65535)]",
2544 "Adjust routing timers\n"
2546 "Keepalive interval\n"
2549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2550 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2551 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2556 /* BGP minimum holdtime. */
2558 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2559 "bgp minimum-holdtime (1-65535)",
2560 "BGP specific commands\n"
2561 "BGP minimum holdtime\n"
2564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2566 unsigned long min_holdtime
;
2568 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2570 bgp
->default_min_holdtime
= min_holdtime
;
2575 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2576 "no bgp minimum-holdtime [(1-65535)]",
2578 "BGP specific commands\n"
2579 "BGP minimum holdtime\n"
2582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2584 bgp
->default_min_holdtime
= 0;
2589 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2590 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2592 "TCP keepalive parameters\n"
2593 "TCP keepalive idle time (seconds)\n"
2594 "TCP keepalive interval (seconds)\n"
2595 "TCP keepalive maximum probes\n")
2597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2599 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2605 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2606 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2609 "TCP keepalive parameters\n"
2610 "TCP keepalive idle time (seconds)\n"
2611 "TCP keepalive interval (seconds)\n"
2612 "TCP keepalive maximum probes\n")
2614 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2616 bgp_tcp_keepalive_unset(bgp
);
2621 DEFUN (bgp_client_to_client_reflection
,
2622 bgp_client_to_client_reflection_cmd
,
2623 "bgp client-to-client reflection",
2625 "Configure client to client route reflection\n"
2626 "reflection of routes allowed\n")
2628 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2629 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2630 bgp_clear_star_soft_out(vty
, bgp
->name
);
2635 DEFUN (no_bgp_client_to_client_reflection
,
2636 no_bgp_client_to_client_reflection_cmd
,
2637 "no bgp client-to-client reflection",
2640 "Configure client to client route reflection\n"
2641 "reflection of routes allowed\n")
2643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2644 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2645 bgp_clear_star_soft_out(vty
, bgp
->name
);
2650 /* "bgp always-compare-med" configuration. */
2651 DEFUN (bgp_always_compare_med
,
2652 bgp_always_compare_med_cmd
,
2653 "bgp always-compare-med",
2655 "Allow comparing MED from different neighbors\n")
2657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2658 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2659 bgp_recalculate_all_bestpaths(bgp
);
2664 DEFUN (no_bgp_always_compare_med
,
2665 no_bgp_always_compare_med_cmd
,
2666 "no bgp always-compare-med",
2669 "Allow comparing MED from different neighbors\n")
2671 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2672 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2673 bgp_recalculate_all_bestpaths(bgp
);
2679 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2680 "bgp ebgp-requires-policy",
2682 "Require in and out policy for eBGP peers (RFC8212)\n")
2684 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2685 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2689 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2690 "no bgp ebgp-requires-policy",
2693 "Require in and out policy for eBGP peers (RFC8212)\n")
2695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2696 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2700 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2701 "bgp suppress-duplicates",
2703 "Suppress duplicate updates if the route actually not changed\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2710 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2711 "no bgp suppress-duplicates",
2714 "Suppress duplicate updates if the route actually not changed\n")
2716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2717 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2721 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2722 "bgp reject-as-sets",
2724 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2727 struct listnode
*node
, *nnode
;
2730 bgp
->reject_as_sets
= true;
2732 /* Reset existing BGP sessions to reject routes
2733 * with aspath containing AS_SET or AS_CONFED_SET.
2735 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2736 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2737 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2738 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2739 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2746 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2747 "no bgp reject-as-sets",
2750 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2752 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2753 struct listnode
*node
, *nnode
;
2756 bgp
->reject_as_sets
= false;
2758 /* Reset existing BGP sessions to reject routes
2759 * with aspath containing AS_SET or AS_CONFED_SET.
2761 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2762 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2763 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2764 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2765 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2772 /* "bgp deterministic-med" configuration. */
2773 DEFUN (bgp_deterministic_med
,
2774 bgp_deterministic_med_cmd
,
2775 "bgp deterministic-med",
2777 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2781 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2782 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2783 bgp_recalculate_all_bestpaths(bgp
);
2789 DEFUN (no_bgp_deterministic_med
,
2790 no_bgp_deterministic_med_cmd
,
2791 "no bgp deterministic-med",
2794 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2797 int bestpath_per_as_used
;
2801 struct listnode
*node
, *nnode
;
2803 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2804 bestpath_per_as_used
= 0;
2806 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2807 FOREACH_AFI_SAFI (afi
, safi
)
2808 if (bgp_addpath_dmed_required(
2809 peer
->addpath_type
[afi
][safi
])) {
2810 bestpath_per_as_used
= 1;
2814 if (bestpath_per_as_used
)
2818 if (bestpath_per_as_used
) {
2820 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2821 return CMD_WARNING_CONFIG_FAILED
;
2823 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2824 bgp_recalculate_all_bestpaths(bgp
);
2831 /* "bgp graceful-restart mode" configuration. */
2832 DEFUN (bgp_graceful_restart
,
2833 bgp_graceful_restart_cmd
,
2834 "bgp graceful-restart",
2839 int ret
= BGP_GR_FAILURE
;
2841 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2842 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2846 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2848 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2851 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2852 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2854 "Graceful restart configuration changed, reset all peers to take effect\n");
2855 return bgp_vty_return(vty
, ret
);
2858 DEFUN (no_bgp_graceful_restart
,
2859 no_bgp_graceful_restart_cmd
,
2860 "no bgp graceful-restart",
2866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2868 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2869 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2871 int ret
= BGP_GR_FAILURE
;
2873 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2875 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2878 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2879 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2881 "Graceful restart configuration changed, reset all peers to take effect\n");
2883 return bgp_vty_return(vty
, ret
);
2886 DEFUN (bgp_graceful_restart_stalepath_time
,
2887 bgp_graceful_restart_stalepath_time_cmd
,
2888 "bgp graceful-restart stalepath-time (1-4095)",
2890 "Graceful restart capability parameters\n"
2891 "Set the max time to hold onto restarting peer's stale paths\n"
2892 "Delay value (seconds)\n")
2894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2898 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2899 bgp
->stalepath_time
= stalepath
;
2903 DEFUN (bgp_graceful_restart_restart_time
,
2904 bgp_graceful_restart_restart_time_cmd
,
2905 "bgp graceful-restart restart-time (0-4095)",
2907 "Graceful restart capability parameters\n"
2908 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2909 "Delay value (seconds)\n")
2911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2915 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2916 bgp
->restart_time
= restart
;
2920 DEFUN (bgp_graceful_restart_select_defer_time
,
2921 bgp_graceful_restart_select_defer_time_cmd
,
2922 "bgp graceful-restart select-defer-time (0-3600)",
2924 "Graceful restart capability parameters\n"
2925 "Set the time to defer the BGP route selection after restart\n"
2926 "Delay value (seconds, 0 - disable)\n")
2928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2930 uint32_t defer_time
;
2932 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2933 bgp
->select_defer_time
= defer_time
;
2934 if (defer_time
== 0)
2935 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2937 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2942 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2943 no_bgp_graceful_restart_stalepath_time_cmd
,
2944 "no bgp graceful-restart stalepath-time [(1-4095)]",
2947 "Graceful restart capability parameters\n"
2948 "Set the max time to hold onto restarting peer's stale paths\n"
2949 "Delay value (seconds)\n")
2951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2953 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2957 DEFUN (no_bgp_graceful_restart_restart_time
,
2958 no_bgp_graceful_restart_restart_time_cmd
,
2959 "no bgp graceful-restart restart-time [(0-4095)]",
2962 "Graceful restart capability parameters\n"
2963 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2964 "Delay value (seconds)\n")
2966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2968 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2972 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2973 no_bgp_graceful_restart_select_defer_time_cmd
,
2974 "no bgp graceful-restart select-defer-time [(0-3600)]",
2977 "Graceful restart capability parameters\n"
2978 "Set the time to defer the BGP route selection after restart\n"
2979 "Delay value (seconds)\n")
2981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2983 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2984 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2989 DEFUN (bgp_graceful_restart_preserve_fw
,
2990 bgp_graceful_restart_preserve_fw_cmd
,
2991 "bgp graceful-restart preserve-fw-state",
2993 "Graceful restart capability parameters\n"
2994 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2997 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3001 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3002 no_bgp_graceful_restart_preserve_fw_cmd
,
3003 "no bgp graceful-restart preserve-fw-state",
3006 "Graceful restart capability parameters\n"
3007 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3009 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3010 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3014 DEFPY (bgp_graceful_restart_notification
,
3015 bgp_graceful_restart_notification_cmd
,
3016 "[no$no] bgp graceful-restart notification",
3019 "Graceful restart capability parameters\n"
3020 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3025 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3027 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3032 DEFPY (bgp_administrative_reset
,
3033 bgp_administrative_reset_cmd
,
3034 "[no$no] bgp hard-administrative-reset",
3037 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3042 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3044 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3049 DEFUN (bgp_graceful_restart_disable
,
3050 bgp_graceful_restart_disable_cmd
,
3051 "bgp graceful-restart-disable",
3055 int ret
= BGP_GR_FAILURE
;
3057 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3059 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3063 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3065 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3068 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3070 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3072 "Graceful restart configuration changed, reset all peers to take effect\n");
3074 return bgp_vty_return(vty
, ret
);
3077 DEFUN (no_bgp_graceful_restart_disable
,
3078 no_bgp_graceful_restart_disable_cmd
,
3079 "no bgp graceful-restart-disable",
3085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3091 int ret
= BGP_GR_FAILURE
;
3093 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3095 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3098 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3100 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3102 "Graceful restart configuration changed, reset all peers to take effect\n");
3104 return bgp_vty_return(vty
, ret
);
3107 DEFUN (bgp_neighbor_graceful_restart_set
,
3108 bgp_neighbor_graceful_restart_set_cmd
,
3109 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3117 int ret
= BGP_GR_FAILURE
;
3119 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3121 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3123 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3127 return CMD_WARNING_CONFIG_FAILED
;
3129 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3131 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3132 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3134 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3136 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3138 "Graceful restart configuration changed, reset this peer to take effect\n");
3140 return bgp_vty_return(vty
, ret
);
3143 DEFUN (no_bgp_neighbor_graceful_restart
,
3144 no_bgp_neighbor_graceful_restart_set_cmd
,
3145 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3153 int ret
= BGP_GR_FAILURE
;
3156 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3160 return CMD_WARNING_CONFIG_FAILED
;
3162 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3164 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3166 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3168 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3169 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3171 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3173 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3175 "Graceful restart configuration changed, reset this peer to take effect\n");
3177 return bgp_vty_return(vty
, ret
);
3180 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3181 bgp_neighbor_graceful_restart_helper_set_cmd
,
3182 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3185 GR_NEIGHBOR_HELPER_CMD
3190 int ret
= BGP_GR_FAILURE
;
3192 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3194 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3196 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3198 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3201 return CMD_WARNING_CONFIG_FAILED
;
3204 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3206 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3207 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3209 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3211 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3213 "Graceful restart configuration changed, reset this peer to take effect\n");
3215 return bgp_vty_return(vty
, ret
);
3218 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3219 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3220 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3224 NO_GR_NEIGHBOR_HELPER_CMD
3228 int ret
= BGP_GR_FAILURE
;
3231 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3233 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3235 return CMD_WARNING_CONFIG_FAILED
;
3237 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3239 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3241 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3243 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3244 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3246 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3248 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3250 "Graceful restart configuration changed, reset this peer to take effect\n");
3252 return bgp_vty_return(vty
, ret
);
3255 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3256 bgp_neighbor_graceful_restart_disable_set_cmd
,
3257 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3260 GR_NEIGHBOR_DISABLE_CMD
3265 int ret
= BGP_GR_FAILURE
;
3267 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3269 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3271 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3273 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3275 return CMD_WARNING_CONFIG_FAILED
;
3277 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3279 if (peer
->bgp
->t_startup
)
3280 bgp_peer_gr_flags_update(peer
);
3282 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3283 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3285 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3287 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3289 "Graceful restart configuration changed, reset this peer to take effect\n");
3291 return bgp_vty_return(vty
, ret
);
3294 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3295 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3296 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3300 NO_GR_NEIGHBOR_DISABLE_CMD
3304 int ret
= BGP_GR_FAILURE
;
3307 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3309 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3311 return CMD_WARNING_CONFIG_FAILED
;
3313 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3315 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3317 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3319 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3320 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3322 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3324 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3326 "Graceful restart configuration changed, reset this peer to take effect\n");
3328 return bgp_vty_return(vty
, ret
);
3331 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3332 bgp_graceful_restart_disable_eor_cmd
,
3333 "bgp graceful-restart disable-eor",
3335 "Graceful restart configuration parameters\n"
3336 "Disable EOR Check\n")
3338 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3339 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3344 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3345 no_bgp_graceful_restart_disable_eor_cmd
,
3346 "no bgp graceful-restart disable-eor",
3349 "Graceful restart configuration parameters\n"
3350 "Disable EOR Check\n")
3352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3353 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3358 DEFUN (bgp_graceful_restart_rib_stale_time
,
3359 bgp_graceful_restart_rib_stale_time_cmd
,
3360 "bgp graceful-restart rib-stale-time (1-3600)",
3362 "Graceful restart configuration parameters\n"
3363 "Specify the stale route removal timer in rib\n"
3364 "Delay value (seconds)\n")
3366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3368 uint32_t stale_time
;
3370 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3371 bgp
->rib_stale_time
= stale_time
;
3372 /* Send the stale timer update message to RIB */
3373 if (bgp_zebra_stale_timer_update(bgp
))
3379 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3380 no_bgp_graceful_restart_rib_stale_time_cmd
,
3381 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3384 "Graceful restart configuration parameters\n"
3385 "Specify the stale route removal timer in rib\n"
3386 "Delay value (seconds)\n")
3388 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3390 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3391 /* Send the stale timer update message to RIB */
3392 if (bgp_zebra_stale_timer_update(bgp
))
3398 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3399 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3401 "Enable Long-lived Graceful Restart\n"
3402 "Specifies maximum time to wait before purging long-lived stale routes\n"
3403 "Stale time value (seconds)\n")
3405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3407 uint32_t llgr_stale_time
;
3409 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3410 bgp
->llgr_stale_time
= llgr_stale_time
;
3415 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3416 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3418 "Enable Long-lived Graceful Restart\n"
3419 "Specifies maximum time to wait before purging long-lived stale routes\n"
3420 "Stale time value (seconds)\n")
3422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3424 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3429 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3432 bgp_static_redo_import_check(bgp
);
3433 bgp_redistribute_redo(bgp
);
3434 bgp_clear_star_soft_out(vty
, bgp
->name
);
3435 bgp_clear_star_soft_in(vty
, bgp
->name
);
3438 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3440 struct listnode
*node
, *nnode
;
3442 bool vrf_cfg
= false;
3444 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3447 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3448 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3449 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3451 "%% graceful-shutdown configuration found in vrf %s\n",
3452 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3453 VRF_DEFAULT_NAME
: bgp
->name
);
3460 "%%Failed: global graceful-shutdown not permitted\n");
3464 /* Set flag globally */
3465 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3467 /* Initiate processing for all BGP instances. */
3468 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3469 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3474 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3476 struct listnode
*node
, *nnode
;
3479 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3482 /* Unset flag globally */
3483 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3485 /* Initiate processing for all BGP instances. */
3486 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3487 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3492 /* "bgp graceful-shutdown" configuration */
3493 DEFUN (bgp_graceful_shutdown
,
3494 bgp_graceful_shutdown_cmd
,
3495 "bgp graceful-shutdown",
3497 "Graceful shutdown parameters\n")
3499 if (vty
->node
== CONFIG_NODE
)
3500 return bgp_global_graceful_shutdown_config_vty(vty
);
3502 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3504 /* if configured globally, per-instance config is not allowed */
3505 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3507 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3508 return CMD_WARNING_CONFIG_FAILED
;
3511 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3512 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3513 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3519 DEFUN (no_bgp_graceful_shutdown
,
3520 no_bgp_graceful_shutdown_cmd
,
3521 "no bgp graceful-shutdown",
3524 "Graceful shutdown parameters\n")
3526 if (vty
->node
== CONFIG_NODE
)
3527 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3531 /* If configured globally, cannot remove from one bgp instance */
3532 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3534 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3535 return CMD_WARNING_CONFIG_FAILED
;
3538 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3539 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3540 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3546 /* "bgp fast-external-failover" configuration. */
3547 DEFUN (bgp_fast_external_failover
,
3548 bgp_fast_external_failover_cmd
,
3549 "bgp fast-external-failover",
3551 "Immediately reset session if a link to a directly connected external peer goes down\n")
3553 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3554 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3558 DEFUN (no_bgp_fast_external_failover
,
3559 no_bgp_fast_external_failover_cmd
,
3560 "no bgp fast-external-failover",
3563 "Immediately reset session if a link to a directly connected external peer goes down\n")
3565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3566 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3570 /* "bgp bestpath compare-routerid" configuration. */
3571 DEFUN (bgp_bestpath_compare_router_id
,
3572 bgp_bestpath_compare_router_id_cmd
,
3573 "bgp bestpath compare-routerid",
3575 "Change the default bestpath selection\n"
3576 "Compare router-id for identical EBGP paths\n")
3578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3580 bgp_recalculate_all_bestpaths(bgp
);
3585 DEFUN (no_bgp_bestpath_compare_router_id
,
3586 no_bgp_bestpath_compare_router_id_cmd
,
3587 "no bgp bestpath compare-routerid",
3590 "Change the default bestpath selection\n"
3591 "Compare router-id for identical EBGP paths\n")
3593 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3594 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3595 bgp_recalculate_all_bestpaths(bgp
);
3600 /* "bgp bestpath as-path ignore" configuration. */
3601 DEFUN (bgp_bestpath_aspath_ignore
,
3602 bgp_bestpath_aspath_ignore_cmd
,
3603 "bgp bestpath as-path ignore",
3605 "Change the default bestpath selection\n"
3606 "AS-path attribute\n"
3607 "Ignore as-path length in selecting a route\n")
3609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3610 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3611 bgp_recalculate_all_bestpaths(bgp
);
3616 DEFUN (no_bgp_bestpath_aspath_ignore
,
3617 no_bgp_bestpath_aspath_ignore_cmd
,
3618 "no bgp bestpath as-path ignore",
3621 "Change the default bestpath selection\n"
3622 "AS-path attribute\n"
3623 "Ignore as-path length in selecting a route\n")
3625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3626 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3627 bgp_recalculate_all_bestpaths(bgp
);
3632 /* "bgp bestpath as-path confed" configuration. */
3633 DEFUN (bgp_bestpath_aspath_confed
,
3634 bgp_bestpath_aspath_confed_cmd
,
3635 "bgp bestpath as-path confed",
3637 "Change the default bestpath selection\n"
3638 "AS-path attribute\n"
3639 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3642 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3643 bgp_recalculate_all_bestpaths(bgp
);
3648 DEFUN (no_bgp_bestpath_aspath_confed
,
3649 no_bgp_bestpath_aspath_confed_cmd
,
3650 "no bgp bestpath as-path confed",
3653 "Change the default bestpath selection\n"
3654 "AS-path attribute\n"
3655 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3658 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3659 bgp_recalculate_all_bestpaths(bgp
);
3664 /* "bgp bestpath as-path multipath-relax" configuration. */
3665 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3666 bgp_bestpath_aspath_multipath_relax_cmd
,
3667 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3669 "Change the default bestpath selection\n"
3670 "AS-path attribute\n"
3671 "Allow load sharing across routes that have different AS paths (but same length)\n"
3672 "Generate an AS_SET\n"
3673 "Do not generate an AS_SET\n")
3675 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3677 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3679 /* no-as-set is now the default behavior so we can silently
3681 if (argv_find(argv
, argc
, "as-set", &idx
))
3682 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3684 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3686 bgp_recalculate_all_bestpaths(bgp
);
3691 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3692 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3693 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3696 "Change the default bestpath selection\n"
3697 "AS-path attribute\n"
3698 "Allow load sharing across routes that have different AS paths (but same length)\n"
3699 "Generate an AS_SET\n"
3700 "Do not generate an AS_SET\n")
3702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3703 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3704 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3705 bgp_recalculate_all_bestpaths(bgp
);
3710 /* "bgp bestpath peer-type multipath-relax" configuration. */
3711 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3712 bgp_bestpath_peer_type_multipath_relax_cmd
,
3713 "bgp bestpath peer-type multipath-relax",
3715 "Change the default bestpath selection\n"
3717 "Allow load sharing across routes learned from different peer types\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3721 bgp_recalculate_all_bestpaths(bgp
);
3726 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3727 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3728 "no bgp bestpath peer-type multipath-relax",
3730 "Change the default bestpath selection\n"
3732 "Allow load sharing across routes learned from different peer types\n")
3734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3735 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3736 bgp_recalculate_all_bestpaths(bgp
);
3741 /* "bgp log-neighbor-changes" configuration. */
3742 DEFUN (bgp_log_neighbor_changes
,
3743 bgp_log_neighbor_changes_cmd
,
3744 "bgp log-neighbor-changes",
3746 "Log neighbor up/down and reset reason\n")
3748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3749 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3753 DEFUN (no_bgp_log_neighbor_changes
,
3754 no_bgp_log_neighbor_changes_cmd
,
3755 "no bgp log-neighbor-changes",
3758 "Log neighbor up/down and reset reason\n")
3760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3761 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3765 /* "bgp bestpath med" configuration. */
3766 DEFUN (bgp_bestpath_med
,
3767 bgp_bestpath_med_cmd
,
3768 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3770 "Change the default bestpath selection\n"
3772 "Compare MED among confederation paths\n"
3773 "Treat missing MED as the least preferred one\n"
3774 "Treat missing MED as the least preferred one\n"
3775 "Compare MED among confederation paths\n")
3777 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3780 if (argv_find(argv
, argc
, "confed", &idx
))
3781 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3783 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3784 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3786 bgp_recalculate_all_bestpaths(bgp
);
3791 DEFUN (no_bgp_bestpath_med
,
3792 no_bgp_bestpath_med_cmd
,
3793 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3796 "Change the default bestpath selection\n"
3798 "Compare MED among confederation paths\n"
3799 "Treat missing MED as the least preferred one\n"
3800 "Treat missing MED as the least preferred one\n"
3801 "Compare MED among confederation paths\n")
3803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3806 if (argv_find(argv
, argc
, "confed", &idx
))
3807 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3809 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3810 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3812 bgp_recalculate_all_bestpaths(bgp
);
3817 /* "bgp bestpath bandwidth" configuration. */
3818 DEFPY (bgp_bestpath_bw
,
3819 bgp_bestpath_bw_cmd
,
3820 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3822 "Change the default bestpath selection\n"
3823 "Link Bandwidth attribute\n"
3824 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3825 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3826 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3833 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3834 return CMD_ERR_INCOMPLETE
;
3836 if (!strcmp(bw_cfg
, "ignore"))
3837 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3838 else if (!strcmp(bw_cfg
, "skip-missing"))
3839 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3840 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3841 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3843 return CMD_ERR_NO_MATCH
;
3845 /* This config is used in route install, so redo that. */
3846 FOREACH_AFI_SAFI (afi
, safi
) {
3847 if (!bgp_fibupd_safi(safi
))
3849 bgp_zebra_announce_table(bgp
, afi
, safi
);
3855 DEFPY (no_bgp_bestpath_bw
,
3856 no_bgp_bestpath_bw_cmd
,
3857 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3860 "Change the default bestpath selection\n"
3861 "Link Bandwidth attribute\n"
3862 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3863 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3864 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3870 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3872 /* This config is used in route install, so redo that. */
3873 FOREACH_AFI_SAFI (afi
, safi
) {
3874 if (!bgp_fibupd_safi(safi
))
3876 bgp_zebra_announce_table(bgp
, afi
, safi
);
3881 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3882 "[no] bgp default <ipv4-unicast|"
3885 "ipv4-labeled-unicast|"
3890 "ipv6-labeled-unicast|"
3892 "l2vpn-evpn>$afi_safi",
3895 "Configure BGP defaults\n"
3896 "Activate ipv4-unicast for a peer by default\n"
3897 "Activate ipv4-multicast for a peer by default\n"
3898 "Activate ipv4-vpn for a peer by default\n"
3899 "Activate ipv4-labeled-unicast for a peer by default\n"
3900 "Activate ipv4-flowspec for a peer by default\n"
3901 "Activate ipv6-unicast for a peer by default\n"
3902 "Activate ipv6-multicast for a peer by default\n"
3903 "Activate ipv6-vpn for a peer by default\n"
3904 "Activate ipv6-labeled-unicast for a peer by default\n"
3905 "Activate ipv6-flowspec for a peer by default\n"
3906 "Activate l2vpn-evpn for a peer by default\n")
3908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3909 char afi_safi_str
[strlen(afi_safi
) + 1];
3910 char *afi_safi_str_tok
;
3912 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3913 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3914 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3915 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3919 * Impossible situation but making coverity happy
3921 assert(afi
!= AFI_MAX
);
3923 if (strmatch(safi_str
, "labeled"))
3924 safi
= bgp_vty_safi_from_str("labeled-unicast");
3926 safi
= bgp_vty_safi_from_str(safi_str
);
3928 assert(safi
!= SAFI_MAX
);
3930 bgp
->default_af
[afi
][safi
] = false;
3932 if ((safi
== SAFI_LABELED_UNICAST
3933 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3934 || (safi
== SAFI_UNICAST
3935 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3936 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3938 bgp
->default_af
[afi
][safi
] = true;
3944 /* Display hostname in certain command outputs */
3945 DEFUN (bgp_default_show_hostname
,
3946 bgp_default_show_hostname_cmd
,
3947 "bgp default show-hostname",
3949 "Configure BGP defaults\n"
3950 "Show hostname in certain command outputs\n")
3952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3953 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3957 DEFUN (no_bgp_default_show_hostname
,
3958 no_bgp_default_show_hostname_cmd
,
3959 "no bgp default show-hostname",
3962 "Configure BGP defaults\n"
3963 "Show hostname in certain command outputs\n")
3965 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3966 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3970 /* Display hostname in certain command outputs */
3971 DEFUN (bgp_default_show_nexthop_hostname
,
3972 bgp_default_show_nexthop_hostname_cmd
,
3973 "bgp default show-nexthop-hostname",
3975 "Configure BGP defaults\n"
3976 "Show hostname for nexthop in certain command outputs\n")
3978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3979 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3983 DEFUN (no_bgp_default_show_nexthop_hostname
,
3984 no_bgp_default_show_nexthop_hostname_cmd
,
3985 "no bgp default show-nexthop-hostname",
3988 "Configure BGP defaults\n"
3989 "Show hostname for nexthop in certain command outputs\n")
3991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3992 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3996 /* "bgp network import-check" configuration. */
3997 DEFUN (bgp_network_import_check
,
3998 bgp_network_import_check_cmd
,
3999 "bgp network import-check",
4001 "BGP network command\n"
4002 "Check BGP network route exists in IGP\n")
4004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4005 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4006 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4007 bgp_static_redo_import_check(bgp
);
4013 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4014 "bgp network import-check exact",
4016 "BGP network command\n"
4017 "Check BGP network route exists in IGP\n"
4018 "Match route precisely\n")
4020 DEFUN (no_bgp_network_import_check
,
4021 no_bgp_network_import_check_cmd
,
4022 "no bgp network import-check",
4025 "BGP network command\n"
4026 "Check BGP network route exists in IGP\n")
4028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4029 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4030 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4031 bgp_static_redo_import_check(bgp
);
4037 DEFUN (bgp_default_local_preference
,
4038 bgp_default_local_preference_cmd
,
4039 "bgp default local-preference (0-4294967295)",
4041 "Configure BGP defaults\n"
4042 "local preference (higher=more preferred)\n"
4043 "Configure default local preference value\n")
4045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4047 uint32_t local_pref
;
4049 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4051 bgp_default_local_preference_set(bgp
, local_pref
);
4052 bgp_clear_star_soft_in(vty
, bgp
->name
);
4057 DEFUN (no_bgp_default_local_preference
,
4058 no_bgp_default_local_preference_cmd
,
4059 "no bgp default local-preference [(0-4294967295)]",
4062 "Configure BGP defaults\n"
4063 "local preference (higher=more preferred)\n"
4064 "Configure default local preference value\n")
4066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4067 bgp_default_local_preference_unset(bgp
);
4068 bgp_clear_star_soft_in(vty
, bgp
->name
);
4074 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4075 bgp_default_subgroup_pkt_queue_max_cmd
,
4076 "bgp default subgroup-pkt-queue-max (20-100)",
4078 "Configure BGP defaults\n"
4079 "subgroup-pkt-queue-max\n"
4080 "Configure subgroup packet queue max\n")
4082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4086 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4088 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4093 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4094 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4095 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4098 "Configure BGP defaults\n"
4099 "subgroup-pkt-queue-max\n"
4100 "Configure subgroup packet queue max\n")
4102 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4103 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4108 DEFUN (bgp_rr_allow_outbound_policy
,
4109 bgp_rr_allow_outbound_policy_cmd
,
4110 "bgp route-reflector allow-outbound-policy",
4112 "Allow modifications made by out route-map\n"
4113 "on ibgp neighbors\n")
4115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4117 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4118 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4119 update_group_announce_rrclients(bgp
);
4120 bgp_clear_star_soft_out(vty
, bgp
->name
);
4126 DEFUN (no_bgp_rr_allow_outbound_policy
,
4127 no_bgp_rr_allow_outbound_policy_cmd
,
4128 "no bgp route-reflector allow-outbound-policy",
4131 "Allow modifications made by out route-map\n"
4132 "on ibgp neighbors\n")
4134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4136 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4137 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4138 update_group_announce_rrclients(bgp
);
4139 bgp_clear_star_soft_out(vty
, bgp
->name
);
4145 DEFUN (bgp_listen_limit
,
4146 bgp_listen_limit_cmd
,
4147 "bgp listen limit (1-65535)",
4149 "BGP Dynamic Neighbors listen commands\n"
4150 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4151 "Configure Dynamic Neighbors listen limit value\n")
4153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4157 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4159 bgp_listen_limit_set(bgp
, listen_limit
);
4164 DEFUN (no_bgp_listen_limit
,
4165 no_bgp_listen_limit_cmd
,
4166 "no bgp listen limit [(1-65535)]",
4169 "BGP Dynamic Neighbors listen commands\n"
4170 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4171 "Configure Dynamic Neighbors listen limit value\n")
4173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4174 bgp_listen_limit_unset(bgp
);
4180 * Check if this listen range is already configured. Check for exact
4181 * match or overlap based on input.
4183 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4184 struct prefix
*range
, int exact
)
4186 struct listnode
*node
, *nnode
;
4187 struct listnode
*node1
, *nnode1
;
4188 struct peer_group
*group
;
4193 afi
= family2afi(range
->family
);
4194 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4195 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4198 match
= prefix_same(range
, lr
);
4200 match
= (prefix_match(range
, lr
)
4201 || prefix_match(lr
, range
));
4210 DEFUN (bgp_listen_range
,
4211 bgp_listen_range_cmd
,
4212 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4214 "Configure BGP dynamic neighbors listen range\n"
4215 "Configure BGP dynamic neighbors listen range\n"
4217 "Member of the peer-group\n"
4218 "Peer-group name\n")
4220 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4221 struct prefix range
;
4222 struct peer_group
*group
, *existing_group
;
4227 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4228 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4229 char *prefix
= argv
[idx
]->arg
;
4230 argv_find(argv
, argc
, "PGNAME", &idx
);
4231 char *peergroup
= argv
[idx
]->arg
;
4233 /* Convert IP prefix string to struct prefix. */
4234 ret
= str2prefix(prefix
, &range
);
4236 vty_out(vty
, "%% Malformed listen range\n");
4237 return CMD_WARNING_CONFIG_FAILED
;
4240 afi
= family2afi(range
.family
);
4242 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4244 "%% Malformed listen range (link-local address)\n");
4245 return CMD_WARNING_CONFIG_FAILED
;
4250 /* Check if same listen range is already configured. */
4251 existing_group
= listen_range_exists(bgp
, &range
, 1);
4252 if (existing_group
) {
4253 if (strcmp(existing_group
->name
, peergroup
) == 0)
4257 "%% Same listen range is attached to peer-group %s\n",
4258 existing_group
->name
);
4259 return CMD_WARNING_CONFIG_FAILED
;
4263 /* Check if an overlapping listen range exists. */
4264 if (listen_range_exists(bgp
, &range
, 0)) {
4266 "%% Listen range overlaps with existing listen range\n");
4267 return CMD_WARNING_CONFIG_FAILED
;
4270 group
= peer_group_lookup(bgp
, peergroup
);
4272 vty_out(vty
, "%% Configure the peer-group first\n");
4273 return CMD_WARNING_CONFIG_FAILED
;
4276 ret
= peer_group_listen_range_add(group
, &range
);
4277 return bgp_vty_return(vty
, ret
);
4280 DEFUN (no_bgp_listen_range
,
4281 no_bgp_listen_range_cmd
,
4282 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4285 "Unconfigure BGP dynamic neighbors listen range\n"
4286 "Unconfigure BGP dynamic neighbors listen range\n"
4288 "Member of the peer-group\n"
4289 "Peer-group name\n")
4291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4292 struct prefix range
;
4293 struct peer_group
*group
;
4298 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4299 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4300 char *prefix
= argv
[idx
]->arg
;
4301 argv_find(argv
, argc
, "PGNAME", &idx
);
4302 char *peergroup
= argv
[idx
]->arg
;
4304 /* Convert IP prefix string to struct prefix. */
4305 ret
= str2prefix(prefix
, &range
);
4307 vty_out(vty
, "%% Malformed listen range\n");
4308 return CMD_WARNING_CONFIG_FAILED
;
4311 afi
= family2afi(range
.family
);
4313 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4315 "%% Malformed listen range (link-local address)\n");
4316 return CMD_WARNING_CONFIG_FAILED
;
4321 group
= peer_group_lookup(bgp
, peergroup
);
4323 vty_out(vty
, "%% Peer-group does not exist\n");
4324 return CMD_WARNING_CONFIG_FAILED
;
4327 ret
= peer_group_listen_range_del(group
, &range
);
4328 return bgp_vty_return(vty
, ret
);
4331 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4333 struct peer_group
*group
;
4334 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4335 struct prefix
*range
;
4338 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4339 vty_out(vty
, " bgp listen limit %d\n",
4340 bgp
->dynamic_neighbors_limit
);
4342 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4343 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4344 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4347 " bgp listen range %pFX peer-group %s\n",
4348 range
, group
->name
);
4355 DEFUN (bgp_disable_connected_route_check
,
4356 bgp_disable_connected_route_check_cmd
,
4357 "bgp disable-ebgp-connected-route-check",
4359 "Disable checking if nexthop is connected on ebgp sessions\n")
4361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4362 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4363 bgp_clear_star_soft_in(vty
, bgp
->name
);
4368 DEFUN (no_bgp_disable_connected_route_check
,
4369 no_bgp_disable_connected_route_check_cmd
,
4370 "no bgp disable-ebgp-connected-route-check",
4373 "Disable checking if nexthop is connected on ebgp sessions\n")
4375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4376 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4377 bgp_clear_star_soft_in(vty
, bgp
->name
);
4383 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4389 int as_type
= AS_SPECIFIED
;
4392 if (as_str
[0] == 'i') {
4394 as_type
= AS_INTERNAL
;
4395 } else if (as_str
[0] == 'e') {
4397 as_type
= AS_EXTERNAL
;
4399 /* Get AS number. */
4400 as
= strtoul(as_str
, NULL
, 10);
4403 /* If peer is peer group or interface peer, call proper function. */
4404 ret
= str2sockunion(peer_str
, &su
);
4408 /* Check if existing interface peer */
4409 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4411 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4413 /* if not interface peer, check peer-group settings */
4414 if (ret
< 0 && !peer
) {
4415 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4418 "%% Create the peer-group or interface first\n");
4419 return CMD_WARNING_CONFIG_FAILED
;
4424 if (peer_address_self_check(bgp
, &su
)) {
4426 "%% Can not configure the local system as neighbor\n");
4427 return CMD_WARNING_CONFIG_FAILED
;
4429 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4432 return bgp_vty_return(vty
, ret
);
4435 DEFUN (bgp_default_shutdown
,
4436 bgp_default_shutdown_cmd
,
4437 "[no] bgp default shutdown",
4440 "Configure BGP defaults\n"
4441 "Apply administrative shutdown to newly configured peers\n")
4443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4444 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4448 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4450 "Administrative shutdown of the BGP instance\n"
4451 "Add a shutdown message (RFC 8203)\n"
4452 "Shutdown message\n")
4454 char *msgstr
= NULL
;
4456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4459 msgstr
= argv_concat(argv
, argc
, 3);
4461 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4462 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4463 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4464 return CMD_WARNING_CONFIG_FAILED
;
4467 bgp_shutdown_enable(bgp
, msgstr
);
4468 XFREE(MTYPE_TMP
, msgstr
);
4473 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4474 BGP_STR
"Administrative shutdown of the BGP instance\n")
4476 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4478 bgp_shutdown_enable(bgp
, NULL
);
4483 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4484 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4488 bgp_shutdown_disable(bgp
);
4493 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4494 "no bgp shutdown message MSG...", NO_STR BGP_STR
4495 "Administrative shutdown of the BGP instance\n"
4496 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4498 DEFUN (neighbor_remote_as
,
4499 neighbor_remote_as_cmd
,
4500 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4503 "Specify a BGP neighbor\n"
4505 "Internal BGP peer\n"
4506 "External BGP peer\n")
4509 int idx_remote_as
= 3;
4510 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4511 argv
[idx_remote_as
]->arg
);
4514 DEFPY (bgp_allow_martian
,
4515 bgp_allow_martian_cmd
,
4516 "[no]$no bgp allow-martian-nexthop",
4519 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4524 bgp
->allow_martian
= false;
4526 bgp
->allow_martian
= true;
4531 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4532 * sessions do not wait for hold timer expiry to bring down the sessions
4533 * when nexthop becomes unreachable
4535 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4536 BGP_STR
"Fast convergence for bgp sessions\n")
4538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4539 bgp
->fast_convergence
= true;
4544 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4545 "no bgp fast-convergence",
4546 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4549 bgp
->fast_convergence
= false;
4554 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4556 const char *peer_group_name
,
4559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4561 int as_type
= AS_UNSPECIFIED
;
4563 struct peer_group
*group
;
4566 group
= peer_group_lookup(bgp
, conf_if
);
4569 vty_out(vty
, "%% Name conflict with peer-group \n");
4570 return CMD_WARNING_CONFIG_FAILED
;
4574 if (as_str
[0] == 'i') {
4575 as_type
= AS_INTERNAL
;
4576 } else if (as_str
[0] == 'e') {
4577 as_type
= AS_EXTERNAL
;
4579 /* Get AS number. */
4580 as
= strtoul(as_str
, NULL
, 10);
4581 as_type
= AS_SPECIFIED
;
4585 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4588 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4590 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4594 vty_out(vty
, "%% BGP failed to create peer\n");
4595 return CMD_WARNING_CONFIG_FAILED
;
4599 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4601 /* Request zebra to initiate IPv6 RAs on this interface. We do
4603 * any unnumbered peer in order to not worry about run-time
4605 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4607 * gets deleted later etc.)
4610 bgp_zebra_initiate_radv(bgp
, peer
);
4613 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4614 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4616 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4618 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4620 /* v6only flag changed. Reset bgp seesion */
4621 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4622 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4623 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4624 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4626 bgp_session_reset(peer
);
4629 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4630 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4631 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4632 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4635 if (peer_group_name
) {
4636 group
= peer_group_lookup(bgp
, peer_group_name
);
4638 vty_out(vty
, "%% Configure the peer-group first\n");
4639 return CMD_WARNING_CONFIG_FAILED
;
4642 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4645 return bgp_vty_return(vty
, ret
);
4648 DEFUN (neighbor_interface_config
,
4649 neighbor_interface_config_cmd
,
4650 "neighbor WORD interface [peer-group PGNAME]",
4652 "Interface name or neighbor tag\n"
4653 "Enable BGP on interface\n"
4654 "Member of the peer-group\n"
4655 "Peer-group name\n")
4658 int idx_peer_group_word
= 4;
4660 if (argc
> idx_peer_group_word
)
4661 return peer_conf_interface_get(
4662 vty
, argv
[idx_word
]->arg
, 0,
4663 argv
[idx_peer_group_word
]->arg
, NULL
);
4665 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4669 DEFUN (neighbor_interface_config_v6only
,
4670 neighbor_interface_config_v6only_cmd
,
4671 "neighbor WORD interface v6only [peer-group PGNAME]",
4673 "Interface name or neighbor tag\n"
4674 "Enable BGP on interface\n"
4675 "Enable BGP with v6 link-local only\n"
4676 "Member of the peer-group\n"
4677 "Peer-group name\n")
4680 int idx_peer_group_word
= 5;
4682 if (argc
> idx_peer_group_word
)
4683 return peer_conf_interface_get(
4684 vty
, argv
[idx_word
]->arg
, 1,
4685 argv
[idx_peer_group_word
]->arg
, NULL
);
4687 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4691 DEFUN (neighbor_interface_config_remote_as
,
4692 neighbor_interface_config_remote_as_cmd
,
4693 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4695 "Interface name or neighbor tag\n"
4696 "Enable BGP on interface\n"
4697 "Specify a BGP neighbor\n"
4699 "Internal BGP peer\n"
4700 "External BGP peer\n")
4703 int idx_remote_as
= 4;
4704 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4705 argv
[idx_remote_as
]->arg
);
4708 DEFUN (neighbor_interface_v6only_config_remote_as
,
4709 neighbor_interface_v6only_config_remote_as_cmd
,
4710 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4712 "Interface name or neighbor tag\n"
4713 "Enable BGP with v6 link-local only\n"
4714 "Enable BGP on interface\n"
4715 "Specify a BGP neighbor\n"
4717 "Internal BGP peer\n"
4718 "External BGP peer\n")
4721 int idx_remote_as
= 5;
4722 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4723 argv
[idx_remote_as
]->arg
);
4726 DEFUN (neighbor_peer_group
,
4727 neighbor_peer_group_cmd
,
4728 "neighbor WORD peer-group",
4730 "Interface name or neighbor tag\n"
4731 "Configure peer-group\n")
4733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4736 struct peer_group
*group
;
4738 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4740 vty_out(vty
, "%% Name conflict with interface: \n");
4741 return CMD_WARNING_CONFIG_FAILED
;
4744 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4746 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4747 return CMD_WARNING_CONFIG_FAILED
;
4755 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4759 "Specify a BGP neighbor\n"
4761 "Internal BGP peer\n"
4762 "External BGP peer\n")
4764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4768 struct peer_group
*group
;
4772 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4774 /* look up for neighbor by interface name config. */
4775 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4777 /* Request zebra to terminate IPv6 RAs on this
4780 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4781 peer_notify_unconfig(peer
);
4786 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4788 peer_group_notify_unconfig(group
);
4789 peer_group_delete(group
);
4791 vty_out(vty
, "%% Create the peer-group first\n");
4792 return CMD_WARNING_CONFIG_FAILED
;
4795 peer
= peer_lookup(bgp
, &su
);
4797 if (peer_dynamic_neighbor(peer
)) {
4799 "%% Operation not allowed on a dynamic neighbor\n");
4800 return CMD_WARNING_CONFIG_FAILED
;
4803 other
= peer
->doppelganger
;
4805 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4806 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4808 peer_notify_unconfig(peer
);
4810 if (other
&& other
->status
!= Deleted
) {
4811 peer_notify_unconfig(other
);
4820 DEFUN (no_neighbor_interface_config
,
4821 no_neighbor_interface_config_cmd
,
4822 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4826 "Configure BGP on interface\n"
4827 "Enable BGP with v6 link-local only\n"
4828 "Member of the peer-group\n"
4830 "Specify a BGP neighbor\n"
4832 "Internal BGP peer\n"
4833 "External BGP peer\n")
4835 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4839 /* look up for neighbor by interface name config. */
4840 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4842 /* Request zebra to terminate IPv6 RAs on this interface. */
4844 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4845 peer_notify_unconfig(peer
);
4848 vty_out(vty
, "%% Create the bgp interface first\n");
4849 return CMD_WARNING_CONFIG_FAILED
;
4854 DEFUN (no_neighbor_peer_group
,
4855 no_neighbor_peer_group_cmd
,
4856 "no neighbor WORD peer-group",
4860 "Configure peer-group\n")
4862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4864 struct peer_group
*group
;
4866 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4868 peer_group_notify_unconfig(group
);
4869 peer_group_delete(group
);
4871 vty_out(vty
, "%% Create the peer-group first\n");
4872 return CMD_WARNING_CONFIG_FAILED
;
4877 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4878 no_neighbor_interface_peer_group_remote_as_cmd
,
4879 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4882 "Interface name or neighbor tag\n"
4883 "Specify a BGP neighbor\n"
4885 "Internal BGP peer\n"
4886 "External BGP peer\n")
4888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4890 struct peer_group
*group
;
4893 /* look up for neighbor by interface name config. */
4894 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4896 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4900 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4902 peer_group_remote_as_delete(group
);
4904 vty_out(vty
, "%% Create the peer-group or interface first\n");
4905 return CMD_WARNING_CONFIG_FAILED
;
4910 DEFUN (neighbor_local_as
,
4911 neighbor_local_as_cmd
,
4912 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4915 "Specify a local-as number\n"
4916 "AS number used as local AS\n")
4924 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4926 return CMD_WARNING_CONFIG_FAILED
;
4928 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4929 ret
= peer_local_as_set(peer
, as
, 0, 0);
4930 return bgp_vty_return(vty
, ret
);
4933 DEFUN (neighbor_local_as_no_prepend
,
4934 neighbor_local_as_no_prepend_cmd
,
4935 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4938 "Specify a local-as number\n"
4939 "AS number used as local AS\n"
4940 "Do not prepend local-as to updates from ebgp peers\n")
4948 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4950 return CMD_WARNING_CONFIG_FAILED
;
4952 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4953 ret
= peer_local_as_set(peer
, as
, 1, 0);
4954 return bgp_vty_return(vty
, ret
);
4957 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4958 neighbor_local_as_no_prepend_replace_as_cmd
,
4959 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4962 "Specify a local-as number\n"
4963 "AS number used as local AS\n"
4964 "Do not prepend local-as to updates from ebgp peers\n"
4965 "Do not prepend local-as to updates from ibgp peers\n")
4973 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4975 return CMD_WARNING_CONFIG_FAILED
;
4977 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4978 ret
= peer_local_as_set(peer
, as
, 1, 1);
4979 return bgp_vty_return(vty
, ret
);
4982 DEFUN (no_neighbor_local_as
,
4983 no_neighbor_local_as_cmd
,
4984 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4988 "Specify a local-as number\n"
4989 "AS number used as local AS\n"
4990 "Do not prepend local-as to updates from ebgp peers\n"
4991 "Do not prepend local-as to updates from ibgp peers\n")
4997 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4999 return CMD_WARNING_CONFIG_FAILED
;
5001 ret
= peer_local_as_unset(peer
);
5002 return bgp_vty_return(vty
, ret
);
5006 DEFUN (neighbor_solo
,
5008 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5011 "Solo peer - part of its own update group\n")
5017 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5019 return CMD_WARNING_CONFIG_FAILED
;
5021 ret
= update_group_adjust_soloness(peer
, 1);
5022 return bgp_vty_return(vty
, ret
);
5025 DEFUN (no_neighbor_solo
,
5026 no_neighbor_solo_cmd
,
5027 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5031 "Solo peer - part of its own update group\n")
5037 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5039 return CMD_WARNING_CONFIG_FAILED
;
5041 ret
= update_group_adjust_soloness(peer
, 0);
5042 return bgp_vty_return(vty
, ret
);
5045 DEFUN (neighbor_password
,
5046 neighbor_password_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5058 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5060 return CMD_WARNING_CONFIG_FAILED
;
5062 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5063 return bgp_vty_return(vty
, ret
);
5066 DEFUN (no_neighbor_password
,
5067 no_neighbor_password_cmd
,
5068 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5079 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5081 return CMD_WARNING_CONFIG_FAILED
;
5083 ret
= peer_password_unset(peer
);
5084 return bgp_vty_return(vty
, ret
);
5087 DEFUN (neighbor_activate
,
5088 neighbor_activate_cmd
,
5089 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5092 "Enable the Address Family for this Neighbor\n")
5098 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5100 return CMD_WARNING_CONFIG_FAILED
;
5102 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5103 return bgp_vty_return(vty
, ret
);
5106 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5107 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5108 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5109 "Enable the Address Family for this Neighbor\n")
5111 DEFUN (no_neighbor_activate
,
5112 no_neighbor_activate_cmd
,
5113 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5117 "Enable the Address Family for this Neighbor\n")
5124 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5126 return CMD_WARNING_CONFIG_FAILED
;
5128 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5129 return bgp_vty_return(vty
, ret
);
5132 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5133 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5134 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5135 "Enable the Address Family for this Neighbor\n")
5137 DEFUN (neighbor_set_peer_group
,
5138 neighbor_set_peer_group_cmd
,
5139 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5142 "Member of the peer-group\n"
5143 "Peer-group name\n")
5145 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5152 struct peer_group
*group
;
5154 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5156 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5158 vty_out(vty
, "%% Malformed address or name: %s\n",
5159 argv
[idx_peer
]->arg
);
5160 return CMD_WARNING_CONFIG_FAILED
;
5163 if (peer_address_self_check(bgp
, &su
)) {
5165 "%% Can not configure the local system as neighbor\n");
5166 return CMD_WARNING_CONFIG_FAILED
;
5169 /* Disallow for dynamic neighbor. */
5170 peer
= peer_lookup(bgp
, &su
);
5171 if (peer
&& peer_dynamic_neighbor(peer
)) {
5173 "%% Operation not allowed on a dynamic neighbor\n");
5174 return CMD_WARNING_CONFIG_FAILED
;
5178 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5180 vty_out(vty
, "%% Configure the peer-group first\n");
5181 return CMD_WARNING_CONFIG_FAILED
;
5184 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5186 return bgp_vty_return(vty
, ret
);
5189 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5190 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5191 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5192 "Member of the peer-group\n"
5193 "Peer-group name\n")
5195 DEFUN (no_neighbor_set_peer_group
,
5196 no_neighbor_set_peer_group_cmd
,
5197 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5201 "Member of the peer-group\n"
5202 "Peer-group name\n")
5204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5209 struct peer_group
*group
;
5211 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5213 return CMD_WARNING_CONFIG_FAILED
;
5215 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5217 vty_out(vty
, "%% Configure the peer-group first\n");
5218 return CMD_WARNING_CONFIG_FAILED
;
5221 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5222 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5224 peer_notify_unconfig(peer
);
5225 ret
= peer_delete(peer
);
5227 return bgp_vty_return(vty
, ret
);
5230 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5231 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5233 "Member of the peer-group\n"
5234 "Peer-group name\n")
5236 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5237 uint64_t flag
, int set
)
5242 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5244 return CMD_WARNING_CONFIG_FAILED
;
5247 * If 'neighbor <interface>', then this is for directly connected peers,
5248 * we should not accept disable-connected-check.
5250 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5252 "%s is directly connected peer, cannot accept disable-connected-check\n",
5254 return CMD_WARNING_CONFIG_FAILED
;
5257 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5258 peer_tx_shutdown_message_unset(peer
);
5261 ret
= peer_flag_set(peer
, flag
);
5263 ret
= peer_flag_unset(peer
, flag
);
5265 return bgp_vty_return(vty
, ret
);
5268 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5270 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5273 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5276 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5279 /* neighbor passive. */
5280 DEFUN (neighbor_passive
,
5281 neighbor_passive_cmd
,
5282 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5285 "Don't send open messages to this neighbor\n")
5288 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5291 DEFUN (no_neighbor_passive
,
5292 no_neighbor_passive_cmd
,
5293 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5297 "Don't send open messages to this neighbor\n")
5300 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5303 /* neighbor shutdown. */
5304 DEFUN (neighbor_shutdown_msg
,
5305 neighbor_shutdown_msg_cmd
,
5306 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5309 "Administratively shut down this neighbor\n"
5310 "Add a shutdown message (RFC 8203)\n"
5311 "Shutdown message\n")
5317 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5321 return CMD_WARNING_CONFIG_FAILED
;
5322 message
= argv_concat(argv
, argc
, 4);
5323 peer_tx_shutdown_message_set(peer
, message
);
5324 XFREE(MTYPE_TMP
, message
);
5327 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5330 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5331 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5332 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5333 "Administratively shut down this neighbor\n")
5335 DEFUN (no_neighbor_shutdown_msg
,
5336 no_neighbor_shutdown_msg_cmd
,
5337 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5341 "Administratively shut down this neighbor\n"
5342 "Remove a shutdown message (RFC 8203)\n"
5343 "Shutdown message\n")
5347 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5348 PEER_FLAG_SHUTDOWN
);
5351 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5352 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5353 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5354 "Administratively shut down this neighbor\n")
5356 DEFUN(neighbor_shutdown_rtt
,
5357 neighbor_shutdown_rtt_cmd
,
5358 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5361 "Administratively shut down this neighbor\n"
5362 "Shutdown if round-trip-time is higher than expected\n"
5363 "Round-trip-time in milliseconds\n"
5364 "Specify the number of keepalives before shutdown\n"
5365 "The number of keepalives with higher RTT to shutdown\n")
5372 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5375 return CMD_WARNING_CONFIG_FAILED
;
5377 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5379 if (argv_find(argv
, argc
, "count", &idx_count
))
5380 peer
->rtt_keepalive_conf
=
5381 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5383 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5384 PEER_FLAG_RTT_SHUTDOWN
);
5387 DEFUN(no_neighbor_shutdown_rtt
,
5388 no_neighbor_shutdown_rtt_cmd
,
5389 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5393 "Administratively shut down this neighbor\n"
5394 "Shutdown if round-trip-time is higher than expected\n"
5395 "Round-trip-time in milliseconds\n"
5396 "Specify the number of keepalives before shutdown\n"
5397 "The number of keepalives with higher RTT to shutdown\n")
5402 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5405 return CMD_WARNING_CONFIG_FAILED
;
5407 peer
->rtt_expected
= 0;
5408 peer
->rtt_keepalive_conf
= 1;
5410 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5411 PEER_FLAG_RTT_SHUTDOWN
);
5414 /* neighbor capability dynamic. */
5415 DEFUN (neighbor_capability_dynamic
,
5416 neighbor_capability_dynamic_cmd
,
5417 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5420 "Advertise capability to the peer\n"
5421 "Advertise dynamic capability to this neighbor\n")
5424 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5425 PEER_FLAG_DYNAMIC_CAPABILITY
);
5428 DEFUN (no_neighbor_capability_dynamic
,
5429 no_neighbor_capability_dynamic_cmd
,
5430 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5434 "Advertise capability to the peer\n"
5435 "Advertise dynamic capability to this neighbor\n")
5438 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5439 PEER_FLAG_DYNAMIC_CAPABILITY
);
5442 /* neighbor dont-capability-negotiate */
5443 DEFUN (neighbor_dont_capability_negotiate
,
5444 neighbor_dont_capability_negotiate_cmd
,
5445 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5448 "Do not perform capability negotiation\n")
5451 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5452 PEER_FLAG_DONT_CAPABILITY
);
5455 DEFUN (no_neighbor_dont_capability_negotiate
,
5456 no_neighbor_dont_capability_negotiate_cmd
,
5457 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5461 "Do not perform capability negotiation\n")
5464 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5465 PEER_FLAG_DONT_CAPABILITY
);
5468 /* neighbor capability extended next hop encoding */
5469 DEFUN (neighbor_capability_enhe
,
5470 neighbor_capability_enhe_cmd
,
5471 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5474 "Advertise capability to the peer\n"
5475 "Advertise extended next-hop capability to the peer\n")
5480 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5481 if (peer
&& peer
->conf_if
)
5484 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5485 PEER_FLAG_CAPABILITY_ENHE
);
5488 DEFUN (no_neighbor_capability_enhe
,
5489 no_neighbor_capability_enhe_cmd
,
5490 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5494 "Advertise capability to the peer\n"
5495 "Advertise extended next-hop capability to the peer\n")
5500 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5501 if (peer
&& peer
->conf_if
) {
5503 "Peer %s cannot have capability extended-nexthop turned off\n",
5504 argv
[idx_peer
]->arg
);
5505 return CMD_WARNING_CONFIG_FAILED
;
5508 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5509 PEER_FLAG_CAPABILITY_ENHE
);
5512 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5513 afi_t afi
, safi_t safi
, uint32_t flag
,
5519 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5521 return CMD_WARNING_CONFIG_FAILED
;
5524 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5526 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5528 return bgp_vty_return(vty
, ret
);
5531 static int peer_af_flag_set_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
, 1);
5537 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5538 afi_t afi
, safi_t safi
, uint32_t flag
)
5540 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5543 /* neighbor capability orf prefix-list. */
5544 DEFUN (neighbor_capability_orf_prefix
,
5545 neighbor_capability_orf_prefix_cmd
,
5546 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5549 "Advertise capability to the peer\n"
5550 "Advertise ORF capability to the peer\n"
5551 "Advertise prefixlist ORF capability to this neighbor\n"
5552 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5553 "Capability to RECEIVE the ORF from this neighbor\n"
5554 "Capability to SEND the ORF to this neighbor\n")
5556 int idx_send_recv
= 5;
5557 char *peer_str
= argv
[1]->arg
;
5559 afi_t afi
= bgp_node_afi(vty
);
5560 safi_t safi
= bgp_node_safi(vty
);
5562 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5564 return CMD_WARNING_CONFIG_FAILED
;
5566 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5567 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5568 PEER_FLAG_ORF_PREFIX_SM
);
5570 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5571 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5572 PEER_FLAG_ORF_PREFIX_RM
);
5574 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5575 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5576 PEER_FLAG_ORF_PREFIX_SM
)
5577 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5578 PEER_FLAG_ORF_PREFIX_RM
);
5580 return CMD_WARNING_CONFIG_FAILED
;
5584 neighbor_capability_orf_prefix
,
5585 neighbor_capability_orf_prefix_hidden_cmd
,
5586 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5587 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5588 "Advertise capability to the peer\n"
5589 "Advertise ORF capability to the peer\n"
5590 "Advertise prefixlist ORF capability to this neighbor\n"
5591 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5592 "Capability to RECEIVE the ORF from this neighbor\n"
5593 "Capability to SEND the ORF to this neighbor\n")
5595 DEFUN (no_neighbor_capability_orf_prefix
,
5596 no_neighbor_capability_orf_prefix_cmd
,
5597 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5601 "Advertise capability to the peer\n"
5602 "Advertise ORF capability to the peer\n"
5603 "Advertise prefixlist ORF capability to this neighbor\n"
5604 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5605 "Capability to RECEIVE the ORF from this neighbor\n"
5606 "Capability to SEND the ORF to this neighbor\n")
5608 int idx_send_recv
= 6;
5609 char *peer_str
= argv
[2]->arg
;
5611 afi_t afi
= bgp_node_afi(vty
);
5612 safi_t safi
= bgp_node_safi(vty
);
5614 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5616 return CMD_WARNING_CONFIG_FAILED
;
5618 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5619 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5620 PEER_FLAG_ORF_PREFIX_SM
);
5622 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5623 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5624 PEER_FLAG_ORF_PREFIX_RM
);
5626 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5627 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5628 PEER_FLAG_ORF_PREFIX_SM
)
5629 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5630 PEER_FLAG_ORF_PREFIX_RM
);
5632 return CMD_WARNING_CONFIG_FAILED
;
5636 no_neighbor_capability_orf_prefix
,
5637 no_neighbor_capability_orf_prefix_hidden_cmd
,
5638 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5639 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5640 "Advertise capability to the peer\n"
5641 "Advertise ORF capability to the peer\n"
5642 "Advertise prefixlist ORF capability to this neighbor\n"
5643 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5644 "Capability to RECEIVE the ORF from this neighbor\n"
5645 "Capability to SEND the ORF to this neighbor\n")
5647 /* neighbor next-hop-self. */
5648 DEFUN (neighbor_nexthop_self
,
5649 neighbor_nexthop_self_cmd
,
5650 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5653 "Disable the next hop calculation for this neighbor\n")
5656 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5657 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5660 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5661 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5662 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5663 "Disable the next hop calculation for this neighbor\n")
5665 /* neighbor next-hop-self. */
5666 DEFUN (neighbor_nexthop_self_force
,
5667 neighbor_nexthop_self_force_cmd
,
5668 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5671 "Disable the next hop calculation for this neighbor\n"
5672 "Set the next hop to self for reflected routes\n")
5675 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5677 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5680 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5681 neighbor_nexthop_self_force_hidden_cmd
,
5682 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5683 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5684 "Disable the next hop calculation for this neighbor\n"
5685 "Set the next hop to self for reflected routes\n")
5687 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5688 neighbor_nexthop_self_all_hidden_cmd
,
5689 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5690 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5691 "Disable the next hop calculation for this neighbor\n"
5692 "Set the next hop to self for reflected routes\n")
5694 DEFUN (no_neighbor_nexthop_self
,
5695 no_neighbor_nexthop_self_cmd
,
5696 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5700 "Disable the next hop calculation for this neighbor\n")
5703 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5704 bgp_node_afi(vty
), bgp_node_safi(vty
),
5705 PEER_FLAG_NEXTHOP_SELF
);
5708 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5709 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5710 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5711 "Disable the next hop calculation for this neighbor\n")
5713 DEFUN (no_neighbor_nexthop_self_force
,
5714 no_neighbor_nexthop_self_force_cmd
,
5715 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5719 "Disable the next hop calculation for this neighbor\n"
5720 "Set the next hop to self for reflected routes\n")
5723 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5724 bgp_node_afi(vty
), bgp_node_safi(vty
),
5725 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5728 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5729 no_neighbor_nexthop_self_force_hidden_cmd
,
5730 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5731 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5732 "Disable the next hop calculation for this neighbor\n"
5733 "Set the next hop to self for reflected routes\n")
5735 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5736 no_neighbor_nexthop_self_all_hidden_cmd
,
5737 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5738 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5739 "Disable the next hop calculation for this neighbor\n"
5740 "Set the next hop to self for reflected routes\n")
5742 /* neighbor as-override */
5743 DEFUN (neighbor_as_override
,
5744 neighbor_as_override_cmd
,
5745 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5748 "Override ASNs in outbound updates if aspath equals remote-as\n")
5751 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5752 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5755 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5756 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5757 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5758 "Override ASNs in outbound updates if aspath equals remote-as\n")
5760 DEFUN (no_neighbor_as_override
,
5761 no_neighbor_as_override_cmd
,
5762 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5766 "Override ASNs in outbound updates if aspath equals remote-as\n")
5769 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5770 bgp_node_afi(vty
), bgp_node_safi(vty
),
5771 PEER_FLAG_AS_OVERRIDE
);
5774 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5775 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5776 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5777 "Override ASNs in outbound updates if aspath equals remote-as\n")
5779 /* neighbor remove-private-AS. */
5780 DEFUN (neighbor_remove_private_as
,
5781 neighbor_remove_private_as_cmd
,
5782 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5785 "Remove private ASNs in outbound updates\n")
5788 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5790 PEER_FLAG_REMOVE_PRIVATE_AS
);
5793 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5795 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5796 "Remove private ASNs in outbound updates\n")
5798 DEFUN (neighbor_remove_private_as_all
,
5799 neighbor_remove_private_as_all_cmd
,
5800 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5803 "Remove private ASNs in outbound updates\n"
5804 "Apply to all AS numbers\n")
5807 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5809 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5812 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5813 neighbor_remove_private_as_all_hidden_cmd
,
5814 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5815 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5816 "Remove private ASNs in outbound updates\n"
5817 "Apply to all AS numbers\n")
5819 DEFUN (neighbor_remove_private_as_replace_as
,
5820 neighbor_remove_private_as_replace_as_cmd
,
5821 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5824 "Remove private ASNs in outbound updates\n"
5825 "Replace private ASNs with our ASN in outbound updates\n")
5828 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5830 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5833 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5834 neighbor_remove_private_as_replace_as_hidden_cmd
,
5835 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5836 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5837 "Remove private ASNs in outbound updates\n"
5838 "Replace private ASNs with our ASN in outbound updates\n")
5840 DEFUN (neighbor_remove_private_as_all_replace_as
,
5841 neighbor_remove_private_as_all_replace_as_cmd
,
5842 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5845 "Remove private ASNs in outbound updates\n"
5846 "Apply to all AS numbers\n"
5847 "Replace private ASNs with our ASN in outbound updates\n")
5850 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5852 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5856 neighbor_remove_private_as_all_replace_as
,
5857 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5858 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5859 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5860 "Remove private ASNs in outbound updates\n"
5861 "Apply to all AS numbers\n"
5862 "Replace private ASNs with our ASN in outbound updates\n")
5864 DEFUN (no_neighbor_remove_private_as
,
5865 no_neighbor_remove_private_as_cmd
,
5866 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5870 "Remove private ASNs in outbound updates\n")
5873 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5874 bgp_node_afi(vty
), bgp_node_safi(vty
),
5875 PEER_FLAG_REMOVE_PRIVATE_AS
);
5878 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5879 no_neighbor_remove_private_as_hidden_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5881 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5882 "Remove private ASNs in outbound updates\n")
5884 DEFUN (no_neighbor_remove_private_as_all
,
5885 no_neighbor_remove_private_as_all_cmd
,
5886 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5890 "Remove private ASNs in outbound updates\n"
5891 "Apply to all AS numbers\n")
5894 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5895 bgp_node_afi(vty
), bgp_node_safi(vty
),
5896 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5899 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5900 no_neighbor_remove_private_as_all_hidden_cmd
,
5901 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5902 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5903 "Remove private ASNs in outbound updates\n"
5904 "Apply to all AS numbers\n")
5906 DEFUN (no_neighbor_remove_private_as_replace_as
,
5907 no_neighbor_remove_private_as_replace_as_cmd
,
5908 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5912 "Remove private ASNs in outbound updates\n"
5913 "Replace private ASNs with our ASN in outbound updates\n")
5916 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5917 bgp_node_afi(vty
), bgp_node_safi(vty
),
5918 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5921 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5922 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5923 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5924 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5925 "Remove private ASNs in outbound updates\n"
5926 "Replace private ASNs with our ASN in outbound updates\n")
5928 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5929 no_neighbor_remove_private_as_all_replace_as_cmd
,
5930 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5934 "Remove private ASNs in outbound updates\n"
5935 "Apply to all AS numbers\n"
5936 "Replace private ASNs with our ASN in outbound updates\n")
5939 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5940 bgp_node_afi(vty
), bgp_node_safi(vty
),
5941 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5945 no_neighbor_remove_private_as_all_replace_as
,
5946 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5947 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5948 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5949 "Remove private ASNs in outbound updates\n"
5950 "Apply to all AS numbers\n"
5951 "Replace private ASNs with our ASN in outbound updates\n")
5954 /* neighbor send-community. */
5955 DEFUN (neighbor_send_community
,
5956 neighbor_send_community_cmd
,
5957 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5960 "Send Community attribute to this neighbor\n")
5964 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5966 PEER_FLAG_SEND_COMMUNITY
);
5969 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5970 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5971 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5972 "Send Community attribute to this neighbor\n")
5974 DEFUN (no_neighbor_send_community
,
5975 no_neighbor_send_community_cmd
,
5976 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5980 "Send Community attribute to this neighbor\n")
5984 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5985 bgp_node_afi(vty
), bgp_node_safi(vty
),
5986 PEER_FLAG_SEND_COMMUNITY
);
5989 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5990 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5991 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5992 "Send Community attribute to this neighbor\n")
5994 /* neighbor send-community extended. */
5995 DEFUN (neighbor_send_community_type
,
5996 neighbor_send_community_type_cmd
,
5997 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6000 "Send Community attribute to this neighbor\n"
6001 "Send Standard and Extended Community attributes\n"
6002 "Send Standard, Large and Extended Community attributes\n"
6003 "Send Extended Community attributes\n"
6004 "Send Standard Community attributes\n"
6005 "Send Large Community attributes\n")
6007 const char *type
= argv
[argc
- 1]->text
;
6008 char *peer_str
= argv
[1]->arg
;
6010 afi_t afi
= bgp_node_afi(vty
);
6011 safi_t safi
= bgp_node_safi(vty
);
6013 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6015 return CMD_WARNING_CONFIG_FAILED
;
6017 if (strmatch(type
, "standard"))
6018 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6019 PEER_FLAG_SEND_COMMUNITY
);
6021 if (strmatch(type
, "extended"))
6022 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6023 PEER_FLAG_SEND_EXT_COMMUNITY
);
6025 if (strmatch(type
, "large"))
6026 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6027 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6029 if (strmatch(type
, "both")) {
6030 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6031 PEER_FLAG_SEND_COMMUNITY
)
6032 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6033 PEER_FLAG_SEND_EXT_COMMUNITY
);
6035 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6036 PEER_FLAG_SEND_COMMUNITY
)
6037 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6038 PEER_FLAG_SEND_EXT_COMMUNITY
)
6039 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6040 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6044 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6045 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6046 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6047 "Send Community attribute to this neighbor\n"
6048 "Send Standard and Extended Community attributes\n"
6049 "Send Standard, Large and Extended Community attributes\n"
6050 "Send Extended Community attributes\n"
6051 "Send Standard Community attributes\n"
6052 "Send Large Community attributes\n")
6054 DEFUN (no_neighbor_send_community_type
,
6055 no_neighbor_send_community_type_cmd
,
6056 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6060 "Send Community attribute to this neighbor\n"
6061 "Send Standard and Extended Community attributes\n"
6062 "Send Standard, Large and Extended Community attributes\n"
6063 "Send Extended Community attributes\n"
6064 "Send Standard Community attributes\n"
6065 "Send Large Community attributes\n")
6067 const char *type
= argv
[argc
- 1]->text
;
6068 char *peer_str
= argv
[2]->arg
;
6070 afi_t afi
= bgp_node_afi(vty
);
6071 safi_t safi
= bgp_node_safi(vty
);
6073 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6075 return CMD_WARNING_CONFIG_FAILED
;
6077 if (strmatch(type
, "standard"))
6078 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6079 PEER_FLAG_SEND_COMMUNITY
);
6081 if (strmatch(type
, "extended"))
6082 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6083 PEER_FLAG_SEND_EXT_COMMUNITY
);
6085 if (strmatch(type
, "large"))
6086 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6087 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6089 if (strmatch(type
, "both")) {
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
);
6097 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6098 PEER_FLAG_SEND_COMMUNITY
)
6099 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6100 PEER_FLAG_SEND_EXT_COMMUNITY
)
6101 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6102 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6106 no_neighbor_send_community_type
,
6107 no_neighbor_send_community_type_hidden_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6109 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6110 "Send Community attribute to this neighbor\n"
6111 "Send Standard and Extended Community attributes\n"
6112 "Send Standard, Large and Extended Community attributes\n"
6113 "Send Extended Community attributes\n"
6114 "Send Standard Community attributes\n"
6115 "Send Large Community attributes\n")
6117 /* neighbor soft-reconfig. */
6118 DEFUN (neighbor_soft_reconfiguration
,
6119 neighbor_soft_reconfiguration_cmd
,
6120 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6123 "Per neighbor soft reconfiguration\n"
6124 "Allow inbound soft reconfiguration for this neighbor\n")
6127 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6129 PEER_FLAG_SOFT_RECONFIG
);
6132 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6133 neighbor_soft_reconfiguration_hidden_cmd
,
6134 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6135 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6136 "Per neighbor soft reconfiguration\n"
6137 "Allow inbound soft reconfiguration for this neighbor\n")
6139 DEFUN (no_neighbor_soft_reconfiguration
,
6140 no_neighbor_soft_reconfiguration_cmd
,
6141 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6145 "Per neighbor soft reconfiguration\n"
6146 "Allow inbound soft reconfiguration for this neighbor\n")
6149 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6150 bgp_node_afi(vty
), bgp_node_safi(vty
),
6151 PEER_FLAG_SOFT_RECONFIG
);
6154 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6155 no_neighbor_soft_reconfiguration_hidden_cmd
,
6156 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6157 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6158 "Per neighbor soft reconfiguration\n"
6159 "Allow inbound soft reconfiguration for this neighbor\n")
6161 DEFUN (neighbor_route_reflector_client
,
6162 neighbor_route_reflector_client_cmd
,
6163 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6166 "Configure a neighbor as Route Reflector client\n")
6172 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6174 return CMD_WARNING_CONFIG_FAILED
;
6176 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6178 PEER_FLAG_REFLECTOR_CLIENT
);
6181 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6182 neighbor_route_reflector_client_hidden_cmd
,
6183 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6184 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6185 "Configure a neighbor as Route Reflector client\n")
6187 DEFUN (no_neighbor_route_reflector_client
,
6188 no_neighbor_route_reflector_client_cmd
,
6189 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6193 "Configure a neighbor as Route Reflector client\n")
6196 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6197 bgp_node_afi(vty
), bgp_node_safi(vty
),
6198 PEER_FLAG_REFLECTOR_CLIENT
);
6201 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6202 no_neighbor_route_reflector_client_hidden_cmd
,
6203 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6204 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6205 "Configure a neighbor as Route Reflector client\n")
6207 /* optimal-route-reflection Root Routers configuration */
6208 DEFPY (optimal_route_reflection
,
6209 optimal_route_reflection_cmd
,
6210 "[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]]]",
6212 "Create ORR group and assign root router(s)\n"
6214 "Primary Root address\n"
6215 "Primary Root IPv6 address\n"
6216 "Secondary Root address\n"
6217 "Secondary Root IPv6 address\n"
6218 "Tertiary Root address\n"
6219 "Tertiary Root IPv6 address\n")
6221 if (!no
&& !primary
) {
6222 vty_out(vty
, "%% Specify Primary Root address\n");
6223 return CMD_WARNING_CONFIG_FAILED
;
6225 return bgp_afi_safi_orr_group_set_vty(
6226 vty
, bgp_node_afi(vty
), bgp_node_safi(vty
), orr_group
,
6227 primary_str
, secondary_str
, tertiary_str
, !!no
);
6230 /* neighbor optimal-route-reflection group*/
6231 DEFPY (neighbor_optimal_route_reflection
,
6232 neighbor_optimal_route_reflection_cmd
,
6233 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group",
6237 "Apply ORR group configuration to the neighbor\n"
6240 return peer_orr_group_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
6241 bgp_node_safi(vty
), orr_group
, !!no
);
6244 /* neighbor route-server-client. */
6245 DEFUN (neighbor_route_server_client
,
6246 neighbor_route_server_client_cmd
,
6247 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6250 "Configure a neighbor as Route Server client\n")
6255 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6257 return CMD_WARNING_CONFIG_FAILED
;
6258 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6260 PEER_FLAG_RSERVER_CLIENT
);
6263 ALIAS_HIDDEN(neighbor_route_server_client
,
6264 neighbor_route_server_client_hidden_cmd
,
6265 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6266 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6267 "Configure a neighbor as Route Server client\n")
6269 DEFUN (no_neighbor_route_server_client
,
6270 no_neighbor_route_server_client_cmd
,
6271 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6275 "Configure a neighbor as Route Server client\n")
6278 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6279 bgp_node_afi(vty
), bgp_node_safi(vty
),
6280 PEER_FLAG_RSERVER_CLIENT
);
6283 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6284 no_neighbor_route_server_client_hidden_cmd
,
6285 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6286 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6287 "Configure a neighbor as Route Server client\n")
6289 DEFUN (neighbor_nexthop_local_unchanged
,
6290 neighbor_nexthop_local_unchanged_cmd
,
6291 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6294 "Configure treatment of outgoing link-local nexthop attribute\n"
6295 "Leave link-local nexthop unchanged for this peer\n")
6298 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6300 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6303 DEFUN (no_neighbor_nexthop_local_unchanged
,
6304 no_neighbor_nexthop_local_unchanged_cmd
,
6305 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6309 "Configure treatment of outgoing link-local-nexthop attribute\n"
6310 "Leave link-local nexthop unchanged for this peer\n")
6313 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6314 bgp_node_afi(vty
), bgp_node_safi(vty
),
6315 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6318 DEFUN (neighbor_attr_unchanged
,
6319 neighbor_attr_unchanged_cmd
,
6320 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6323 "BGP attribute is propagated unchanged to this neighbor\n"
6324 "As-path attribute\n"
6325 "Nexthop attribute\n"
6329 char *peer_str
= argv
[1]->arg
;
6331 bool aspath
= false;
6332 bool nexthop
= false;
6334 afi_t afi
= bgp_node_afi(vty
);
6335 safi_t safi
= bgp_node_safi(vty
);
6338 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6340 return CMD_WARNING_CONFIG_FAILED
;
6342 if (argv_find(argv
, argc
, "as-path", &idx
))
6346 if (argv_find(argv
, argc
, "next-hop", &idx
))
6350 if (argv_find(argv
, argc
, "med", &idx
))
6353 /* no flags means all of them! */
6354 if (!aspath
&& !nexthop
&& !med
) {
6355 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6356 PEER_FLAG_AS_PATH_UNCHANGED
);
6357 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6358 PEER_FLAG_NEXTHOP_UNCHANGED
);
6359 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6360 PEER_FLAG_MED_UNCHANGED
);
6363 if (peer_af_flag_check(peer
, afi
, safi
,
6364 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6365 ret
|= peer_af_flag_unset_vty(
6366 vty
, peer_str
, afi
, safi
,
6367 PEER_FLAG_AS_PATH_UNCHANGED
);
6370 ret
|= peer_af_flag_set_vty(
6371 vty
, peer_str
, afi
, safi
,
6372 PEER_FLAG_AS_PATH_UNCHANGED
);
6375 if (peer_af_flag_check(peer
, afi
, safi
,
6376 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6377 ret
|= peer_af_flag_unset_vty(
6378 vty
, peer_str
, afi
, safi
,
6379 PEER_FLAG_NEXTHOP_UNCHANGED
);
6382 ret
|= peer_af_flag_set_vty(
6383 vty
, peer_str
, afi
, safi
,
6384 PEER_FLAG_NEXTHOP_UNCHANGED
);
6387 if (peer_af_flag_check(peer
, afi
, safi
,
6388 PEER_FLAG_MED_UNCHANGED
)) {
6389 ret
|= peer_af_flag_unset_vty(
6390 vty
, peer_str
, afi
, safi
,
6391 PEER_FLAG_MED_UNCHANGED
);
6394 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6395 PEER_FLAG_MED_UNCHANGED
);
6402 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6403 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6404 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6405 "BGP attribute is propagated unchanged to this neighbor\n"
6406 "As-path attribute\n"
6407 "Nexthop attribute\n"
6410 DEFUN (no_neighbor_attr_unchanged
,
6411 no_neighbor_attr_unchanged_cmd
,
6412 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6416 "BGP attribute is propagated unchanged to this neighbor\n"
6417 "As-path attribute\n"
6418 "Nexthop attribute\n"
6422 char *peer_str
= argv
[2]->arg
;
6424 bool aspath
= false;
6425 bool nexthop
= false;
6427 afi_t afi
= bgp_node_afi(vty
);
6428 safi_t safi
= bgp_node_safi(vty
);
6431 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6433 return CMD_WARNING_CONFIG_FAILED
;
6435 if (argv_find(argv
, argc
, "as-path", &idx
))
6439 if (argv_find(argv
, argc
, "next-hop", &idx
))
6443 if (argv_find(argv
, argc
, "med", &idx
))
6446 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6447 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6448 PEER_FLAG_AS_PATH_UNCHANGED
)
6449 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6450 PEER_FLAG_NEXTHOP_UNCHANGED
)
6451 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6452 PEER_FLAG_MED_UNCHANGED
);
6455 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6456 PEER_FLAG_AS_PATH_UNCHANGED
);
6459 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6460 PEER_FLAG_NEXTHOP_UNCHANGED
);
6463 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6464 PEER_FLAG_MED_UNCHANGED
);
6470 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6471 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6472 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6473 "BGP attribute is propagated unchanged to this neighbor\n"
6474 "As-path attribute\n"
6475 "Nexthop attribute\n"
6478 /* EBGP multihop configuration. */
6479 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6480 const char *ttl_str
)
6485 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6487 return CMD_WARNING_CONFIG_FAILED
;
6490 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6495 ttl
= strtoul(ttl_str
, NULL
, 10);
6497 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6500 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6504 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6506 return CMD_WARNING_CONFIG_FAILED
;
6508 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6511 /* neighbor ebgp-multihop. */
6512 DEFUN (neighbor_ebgp_multihop
,
6513 neighbor_ebgp_multihop_cmd
,
6514 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6517 "Allow EBGP neighbors not on directly connected networks\n")
6520 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6523 DEFUN (neighbor_ebgp_multihop_ttl
,
6524 neighbor_ebgp_multihop_ttl_cmd
,
6525 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6528 "Allow EBGP neighbors not on directly connected networks\n"
6529 "maximum hop count\n")
6533 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6534 argv
[idx_number
]->arg
);
6537 DEFUN (no_neighbor_ebgp_multihop
,
6538 no_neighbor_ebgp_multihop_cmd
,
6539 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6543 "Allow EBGP neighbors not on directly connected networks\n"
6544 "maximum hop count\n")
6547 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6550 static uint8_t get_role_by_name(const char *role_str
)
6552 if (strncmp(role_str
, "peer", 2) == 0)
6554 if (strncmp(role_str
, "provider", 2) == 0)
6555 return ROLE_PROVIDER
;
6556 if (strncmp(role_str
, "customer", 2) == 0)
6557 return ROLE_CUSTOMER
;
6558 if (strncmp(role_str
, "rs-server", 4) == 0)
6559 return ROLE_RS_SERVER
;
6560 if (strncmp(role_str
, "rs-client", 4) == 0)
6561 return ROLE_RS_CLIENT
;
6562 return ROLE_UNDEFINED
;
6565 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6566 const char *role_str
, bool strict_mode
)
6570 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6572 return CMD_WARNING_CONFIG_FAILED
;
6573 uint8_t role
= get_role_by_name(role_str
);
6575 if (role
== ROLE_UNDEFINED
)
6576 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6577 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6580 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6584 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6586 return CMD_WARNING_CONFIG_FAILED
;
6587 return bgp_vty_return(vty
, peer_role_unset(peer
));
6590 DEFPY(neighbor_role
,
6592 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6595 "Set session role\n"
6601 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6605 DEFPY(neighbor_role_strict
,
6606 neighbor_role_strict_cmd
,
6607 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6610 "Set session role\n"
6612 "Use additional restriction on peer\n")
6617 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6621 DEFPY(no_neighbor_role
,
6622 no_neighbor_role_cmd
,
6623 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6627 "Set session role\n"
6629 "Use additional restriction on peer\n")
6633 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6636 /* disable-connected-check */
6637 DEFUN (neighbor_disable_connected_check
,
6638 neighbor_disable_connected_check_cmd
,
6639 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6642 "one-hop away EBGP peer using loopback address\n"
6643 "Enforce EBGP neighbors perform multihop\n")
6646 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6647 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6650 DEFUN (no_neighbor_disable_connected_check
,
6651 no_neighbor_disable_connected_check_cmd
,
6652 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6656 "one-hop away EBGP peer using loopback address\n"
6657 "Enforce EBGP neighbors perform multihop\n")
6660 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6661 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6664 /* disable-link-bw-encoding-ieee */
6665 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6666 neighbor_disable_link_bw_encoding_ieee_cmd
,
6667 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6668 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6669 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6673 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6674 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6677 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6678 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6679 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6680 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6681 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6685 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6686 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6689 /* extended-optional-parameters */
6690 DEFUN(neighbor_extended_optional_parameters
,
6691 neighbor_extended_optional_parameters_cmd
,
6692 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6693 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6694 "Force the extended optional parameters format for OPEN messages\n")
6698 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6699 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6702 DEFUN(no_neighbor_extended_optional_parameters
,
6703 no_neighbor_extended_optional_parameters_cmd
,
6704 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6705 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6706 "Force the extended optional parameters format for OPEN messages\n")
6710 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6711 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6714 /* enforce-first-as */
6715 DEFUN (neighbor_enforce_first_as
,
6716 neighbor_enforce_first_as_cmd
,
6717 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6720 "Enforce the first AS for EBGP routes\n")
6724 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6725 PEER_FLAG_ENFORCE_FIRST_AS
);
6728 DEFUN (no_neighbor_enforce_first_as
,
6729 no_neighbor_enforce_first_as_cmd
,
6730 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6734 "Enforce the first AS for EBGP routes\n")
6738 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6739 PEER_FLAG_ENFORCE_FIRST_AS
);
6743 DEFUN (neighbor_description
,
6744 neighbor_description_cmd
,
6745 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6748 "Neighbor specific description\n"
6749 "Up to 80 characters describing this neighbor\n")
6756 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6758 return CMD_WARNING_CONFIG_FAILED
;
6760 str
= argv_concat(argv
, argc
, idx_line
);
6762 peer_description_set(peer
, str
);
6764 XFREE(MTYPE_TMP
, str
);
6769 DEFUN (no_neighbor_description
,
6770 no_neighbor_description_cmd
,
6771 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6775 "Neighbor specific description\n")
6780 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6782 return CMD_WARNING_CONFIG_FAILED
;
6784 peer_description_unset(peer
);
6789 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6790 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6791 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6792 "Neighbor specific description\n"
6793 "Up to 80 characters describing this neighbor\n")
6795 /* Neighbor update-source. */
6796 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6797 const char *source_str
)
6803 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6805 return CMD_WARNING_CONFIG_FAILED
;
6811 if (str2sockunion(source_str
, &su
) == 0)
6812 peer_update_source_addr_set(peer
, &su
);
6814 if (str2prefix(source_str
, &p
)) {
6816 "%% Invalid update-source, remove prefix length \n");
6817 return CMD_WARNING_CONFIG_FAILED
;
6819 peer_update_source_if_set(peer
, source_str
);
6822 peer_update_source_unset(peer
);
6827 #define BGP_UPDATE_SOURCE_HELP_STR \
6830 "Interface name (requires zebra to be running)\n"
6832 DEFUN (neighbor_update_source
,
6833 neighbor_update_source_cmd
,
6834 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6837 "Source of routing updates\n"
6838 BGP_UPDATE_SOURCE_HELP_STR
)
6842 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6843 argv
[idx_peer_2
]->arg
);
6846 DEFUN (no_neighbor_update_source
,
6847 no_neighbor_update_source_cmd
,
6848 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6852 "Source of routing updates\n"
6853 BGP_UPDATE_SOURCE_HELP_STR
)
6856 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6859 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6860 afi_t afi
, safi_t safi
,
6861 const char *rmap
, int set
)
6865 struct route_map
*route_map
= NULL
;
6867 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6869 return CMD_WARNING_CONFIG_FAILED
;
6873 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6874 ret
= peer_default_originate_set(peer
, afi
, safi
,
6877 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6879 return bgp_vty_return(vty
, ret
);
6882 /* neighbor default-originate. */
6883 DEFUN (neighbor_default_originate
,
6884 neighbor_default_originate_cmd
,
6885 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6888 "Originate default route to this neighbor\n")
6891 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6893 bgp_node_safi(vty
), NULL
, 1);
6896 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6897 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6899 "Originate default route to this neighbor\n")
6901 DEFUN (neighbor_default_originate_rmap
,
6902 neighbor_default_originate_rmap_cmd
,
6903 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6906 "Originate default route to this neighbor\n"
6907 "Route-map to specify criteria to originate default\n"
6912 return peer_default_originate_set_vty(
6913 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6914 argv
[idx_word
]->arg
, 1);
6918 neighbor_default_originate_rmap
,
6919 neighbor_default_originate_rmap_hidden_cmd
,
6920 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6922 "Originate default route to this neighbor\n"
6923 "Route-map to specify criteria to originate default\n"
6926 DEFUN (no_neighbor_default_originate
,
6927 no_neighbor_default_originate_cmd
,
6928 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6932 "Originate default route to this neighbor\n"
6933 "Route-map to specify criteria to originate default\n"
6937 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6939 bgp_node_safi(vty
), NULL
, 0);
6943 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6944 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6946 "Originate default route to this neighbor\n"
6947 "Route-map to specify criteria to originate default\n"
6951 /* Set neighbor's BGP port. */
6952 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6953 const char *port_str
)
6959 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6961 return CMD_WARNING_CONFIG_FAILED
;
6964 sp
= getservbyname("bgp", "tcp");
6965 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6967 port
= strtoul(port_str
, NULL
, 10);
6970 peer_port_set(peer
, port
);
6975 /* Set specified peer's BGP port. */
6976 DEFUN (neighbor_port
,
6978 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6981 "Neighbor's BGP port\n"
6982 "TCP port number\n")
6986 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6987 argv
[idx_number
]->arg
);
6990 DEFUN (no_neighbor_port
,
6991 no_neighbor_port_cmd
,
6992 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6996 "Neighbor's BGP port\n"
6997 "TCP port number\n")
7000 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7004 /* neighbor weight. */
7005 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7006 safi_t safi
, const char *weight_str
)
7010 unsigned long weight
;
7012 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7014 return CMD_WARNING_CONFIG_FAILED
;
7016 weight
= strtoul(weight_str
, NULL
, 10);
7018 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7019 return bgp_vty_return(vty
, ret
);
7022 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7028 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7030 return CMD_WARNING_CONFIG_FAILED
;
7032 ret
= peer_weight_unset(peer
, afi
, safi
);
7033 return bgp_vty_return(vty
, ret
);
7036 DEFUN (neighbor_weight
,
7037 neighbor_weight_cmd
,
7038 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7041 "Set default weight for routes from this neighbor\n"
7046 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7047 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7050 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7051 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7052 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7053 "Set default weight for routes from this neighbor\n"
7056 DEFUN (no_neighbor_weight
,
7057 no_neighbor_weight_cmd
,
7058 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7062 "Set default weight for routes from this neighbor\n"
7066 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7067 bgp_node_afi(vty
), bgp_node_safi(vty
));
7070 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7071 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7072 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7073 "Set default weight for routes from this neighbor\n"
7077 /* Override capability negotiation. */
7078 DEFUN (neighbor_override_capability
,
7079 neighbor_override_capability_cmd
,
7080 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7083 "Override capability negotiation result\n")
7086 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7087 PEER_FLAG_OVERRIDE_CAPABILITY
);
7090 DEFUN (no_neighbor_override_capability
,
7091 no_neighbor_override_capability_cmd
,
7092 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7096 "Override capability negotiation result\n")
7099 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7100 PEER_FLAG_OVERRIDE_CAPABILITY
);
7103 DEFUN (neighbor_strict_capability
,
7104 neighbor_strict_capability_cmd
,
7105 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7108 "Strict capability negotiation match\n")
7112 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7113 PEER_FLAG_STRICT_CAP_MATCH
);
7116 DEFUN (no_neighbor_strict_capability
,
7117 no_neighbor_strict_capability_cmd
,
7118 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7122 "Strict capability negotiation match\n")
7126 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7127 PEER_FLAG_STRICT_CAP_MATCH
);
7130 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7131 const char *keep_str
, const char *hold_str
)
7138 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7140 return CMD_WARNING_CONFIG_FAILED
;
7142 keepalive
= strtoul(keep_str
, NULL
, 10);
7143 holdtime
= strtoul(hold_str
, NULL
, 10);
7145 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7147 return bgp_vty_return(vty
, ret
);
7150 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7155 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7157 return CMD_WARNING_CONFIG_FAILED
;
7159 ret
= peer_timers_unset(peer
);
7161 return bgp_vty_return(vty
, ret
);
7164 DEFUN (neighbor_timers
,
7165 neighbor_timers_cmd
,
7166 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7169 "BGP per neighbor timers\n"
7170 "Keepalive interval\n"
7175 int idx_number_2
= 4;
7176 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7177 argv
[idx_number
]->arg
,
7178 argv
[idx_number_2
]->arg
);
7181 DEFUN (no_neighbor_timers
,
7182 no_neighbor_timers_cmd
,
7183 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7187 "BGP per neighbor timers\n"
7188 "Keepalive interval\n"
7192 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7196 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7197 const char *time_str
)
7203 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7205 return CMD_WARNING_CONFIG_FAILED
;
7207 connect
= strtoul(time_str
, NULL
, 10);
7209 ret
= peer_timers_connect_set(peer
, connect
);
7211 return bgp_vty_return(vty
, ret
);
7214 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7219 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7221 return CMD_WARNING_CONFIG_FAILED
;
7223 ret
= peer_timers_connect_unset(peer
);
7225 return bgp_vty_return(vty
, ret
);
7228 DEFUN (neighbor_timers_connect
,
7229 neighbor_timers_connect_cmd
,
7230 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7233 "BGP per neighbor timers\n"
7234 "BGP connect timer\n"
7239 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7240 argv
[idx_number
]->arg
);
7243 DEFUN (no_neighbor_timers_connect
,
7244 no_neighbor_timers_connect_cmd
,
7245 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7249 "BGP per neighbor timers\n"
7250 "BGP connect timer\n"
7254 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7257 DEFPY (neighbor_timers_delayopen
,
7258 neighbor_timers_delayopen_cmd
,
7259 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7262 "BGP per neighbor timers\n"
7263 "RFC 4271 DelayOpenTimer\n"
7264 "DelayOpenTime timer interval\n")
7268 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7270 return CMD_WARNING_CONFIG_FAILED
;
7273 if (peer_timers_delayopen_unset(peer
))
7274 return CMD_WARNING_CONFIG_FAILED
;
7276 if (peer_timers_delayopen_set(peer
, interval
))
7277 return CMD_WARNING_CONFIG_FAILED
;
7283 DEFPY (no_neighbor_timers_delayopen
,
7284 no_neighbor_timers_delayopen_cmd
,
7285 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7289 "BGP per neighbor timers\n"
7290 "RFC 4271 DelayOpenTimer\n"
7291 "DelayOpenTime timer interval\n")
7295 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7297 return CMD_WARNING_CONFIG_FAILED
;
7299 if (peer_timers_delayopen_unset(peer
))
7300 return CMD_WARNING_CONFIG_FAILED
;
7305 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7306 const char *time_str
, int set
)
7310 uint32_t routeadv
= 0;
7312 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7314 return CMD_WARNING_CONFIG_FAILED
;
7317 routeadv
= strtoul(time_str
, NULL
, 10);
7320 ret
= peer_advertise_interval_set(peer
, routeadv
);
7322 ret
= peer_advertise_interval_unset(peer
);
7324 return bgp_vty_return(vty
, ret
);
7327 DEFUN (neighbor_advertise_interval
,
7328 neighbor_advertise_interval_cmd
,
7329 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7332 "Minimum interval between sending BGP routing updates\n"
7333 "time in seconds\n")
7337 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7338 argv
[idx_number
]->arg
, 1);
7341 DEFUN (no_neighbor_advertise_interval
,
7342 no_neighbor_advertise_interval_cmd
,
7343 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7347 "Minimum interval between sending BGP routing updates\n"
7348 "time in seconds\n")
7351 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7355 /* Time to wait before processing route-map updates */
7356 DEFUN (bgp_set_route_map_delay_timer
,
7357 bgp_set_route_map_delay_timer_cmd
,
7358 "bgp route-map delay-timer (0-600)",
7360 "BGP route-map delay timer\n"
7361 "Time in secs to wait before processing route-map changes\n"
7362 "0 disables the timer, no route updates happen when route-maps change\n")
7365 uint32_t rmap_delay_timer
;
7367 if (argv
[idx_number
]->arg
) {
7368 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7369 bm
->rmap_update_timer
= rmap_delay_timer
;
7371 /* if the dynamic update handling is being disabled, and a timer
7373 * running, stop the timer and act as if the timer has already
7376 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7377 THREAD_OFF(bm
->t_rmap_update
);
7378 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7383 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7384 return CMD_WARNING_CONFIG_FAILED
;
7388 DEFUN (no_bgp_set_route_map_delay_timer
,
7389 no_bgp_set_route_map_delay_timer_cmd
,
7390 "no bgp route-map delay-timer [(0-600)]",
7393 "Default BGP route-map delay timer\n"
7394 "Reset to default time to wait for processing route-map changes\n"
7395 "0 disables the timer, no route updates happen when route-maps change\n")
7398 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7403 /* neighbor interface */
7404 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7409 peer
= peer_lookup_vty(vty
, ip_str
);
7410 if (!peer
|| peer
->conf_if
) {
7411 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7412 return CMD_WARNING_CONFIG_FAILED
;
7416 peer_interface_set(peer
, str
);
7418 peer_interface_unset(peer
);
7423 DEFUN (neighbor_interface
,
7424 neighbor_interface_cmd
,
7425 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7434 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7437 DEFUN (no_neighbor_interface
,
7438 no_neighbor_interface_cmd
,
7439 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7448 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7451 DEFUN (neighbor_distribute_list
,
7452 neighbor_distribute_list_cmd
,
7453 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7456 "Filter updates to/from this neighbor\n"
7457 "IP Access-list name\n"
7458 "Filter incoming updates\n"
7459 "Filter outgoing updates\n")
7466 const char *pstr
= argv
[idx_peer
]->arg
;
7467 const char *acl
= argv
[idx_acl
]->arg
;
7468 const char *inout
= argv
[argc
- 1]->text
;
7470 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7472 return CMD_WARNING_CONFIG_FAILED
;
7474 /* Check filter direction. */
7475 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7476 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7479 return bgp_vty_return(vty
, ret
);
7483 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7484 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7485 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7486 "Filter updates to/from this neighbor\n"
7487 "IP Access-list name\n"
7488 "Filter incoming updates\n"
7489 "Filter outgoing updates\n")
7491 DEFUN (no_neighbor_distribute_list
,
7492 no_neighbor_distribute_list_cmd
,
7493 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7497 "Filter updates to/from this neighbor\n"
7498 "IP Access-list name\n"
7499 "Filter incoming updates\n"
7500 "Filter outgoing updates\n")
7506 const char *pstr
= argv
[idx_peer
]->arg
;
7507 const char *inout
= argv
[argc
- 1]->text
;
7509 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7511 return CMD_WARNING_CONFIG_FAILED
;
7513 /* Check filter direction. */
7514 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7515 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7518 return bgp_vty_return(vty
, ret
);
7522 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7523 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7524 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7525 "Filter updates to/from this neighbor\n"
7526 "IP Access-list name\n"
7527 "Filter incoming updates\n"
7528 "Filter outgoing updates\n")
7530 /* Set prefix list to the peer. */
7531 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7532 afi_t afi
, safi_t safi
,
7533 const char *name_str
,
7534 const char *direct_str
)
7537 int direct
= FILTER_IN
;
7540 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7542 return CMD_WARNING_CONFIG_FAILED
;
7544 /* Check filter direction. */
7545 if (strncmp(direct_str
, "i", 1) == 0)
7547 else if (strncmp(direct_str
, "o", 1) == 0)
7548 direct
= FILTER_OUT
;
7550 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7552 return bgp_vty_return(vty
, ret
);
7555 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7556 afi_t afi
, safi_t safi
,
7557 const char *direct_str
)
7561 int direct
= FILTER_IN
;
7563 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7565 return CMD_WARNING_CONFIG_FAILED
;
7567 /* Check filter direction. */
7568 if (strncmp(direct_str
, "i", 1) == 0)
7570 else if (strncmp(direct_str
, "o", 1) == 0)
7571 direct
= FILTER_OUT
;
7573 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7575 return bgp_vty_return(vty
, ret
);
7578 DEFUN (neighbor_prefix_list
,
7579 neighbor_prefix_list_cmd
,
7580 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7583 "Filter updates to/from this neighbor\n"
7584 "Name of a prefix list\n"
7585 "Filter incoming updates\n"
7586 "Filter outgoing updates\n")
7591 return peer_prefix_list_set_vty(
7592 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7593 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7596 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7597 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7598 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7599 "Filter updates to/from this neighbor\n"
7600 "Name of a prefix list\n"
7601 "Filter incoming updates\n"
7602 "Filter outgoing updates\n")
7604 DEFUN (no_neighbor_prefix_list
,
7605 no_neighbor_prefix_list_cmd
,
7606 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7610 "Filter updates to/from this neighbor\n"
7611 "Name of a prefix list\n"
7612 "Filter incoming updates\n"
7613 "Filter outgoing updates\n")
7617 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7618 bgp_node_afi(vty
), bgp_node_safi(vty
),
7619 argv
[idx_in_out
]->arg
);
7622 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7623 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7624 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7625 "Filter updates to/from this neighbor\n"
7626 "Name of a prefix list\n"
7627 "Filter incoming updates\n"
7628 "Filter outgoing updates\n")
7630 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7631 safi_t safi
, const char *name_str
,
7632 const char *direct_str
)
7636 int direct
= FILTER_IN
;
7638 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7640 return CMD_WARNING_CONFIG_FAILED
;
7642 /* Check filter direction. */
7643 if (strncmp(direct_str
, "i", 1) == 0)
7645 else if (strncmp(direct_str
, "o", 1) == 0)
7646 direct
= FILTER_OUT
;
7648 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7650 return bgp_vty_return(vty
, ret
);
7653 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7654 safi_t safi
, const char *direct_str
)
7658 int direct
= FILTER_IN
;
7660 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7662 return CMD_WARNING_CONFIG_FAILED
;
7664 /* Check filter direction. */
7665 if (strncmp(direct_str
, "i", 1) == 0)
7667 else if (strncmp(direct_str
, "o", 1) == 0)
7668 direct
= FILTER_OUT
;
7670 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7672 return bgp_vty_return(vty
, ret
);
7675 DEFUN (neighbor_filter_list
,
7676 neighbor_filter_list_cmd
,
7677 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7680 "Establish BGP filters\n"
7681 "AS path access-list name\n"
7682 "Filter incoming routes\n"
7683 "Filter outgoing routes\n")
7688 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7689 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7690 argv
[idx_in_out
]->arg
);
7693 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7694 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7695 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7696 "Establish BGP filters\n"
7697 "AS path access-list name\n"
7698 "Filter incoming routes\n"
7699 "Filter outgoing routes\n")
7701 DEFUN (no_neighbor_filter_list
,
7702 no_neighbor_filter_list_cmd
,
7703 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7707 "Establish BGP filters\n"
7708 "AS path access-list name\n"
7709 "Filter incoming routes\n"
7710 "Filter outgoing routes\n")
7714 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7715 bgp_node_afi(vty
), bgp_node_safi(vty
),
7716 argv
[idx_in_out
]->arg
);
7719 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7720 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7721 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7722 "Establish BGP filters\n"
7723 "AS path access-list name\n"
7724 "Filter incoming routes\n"
7725 "Filter outgoing routes\n")
7727 /* Set advertise-map to the peer. */
7728 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7729 afi_t afi
, safi_t safi
,
7730 const char *advertise_str
,
7731 const char *condition_str
, bool condition
,
7734 int ret
= CMD_WARNING_CONFIG_FAILED
;
7736 struct route_map
*advertise_map
;
7737 struct route_map
*condition_map
;
7739 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7743 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7744 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7747 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7748 advertise_map
, condition_str
,
7749 condition_map
, condition
);
7751 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7752 advertise_map
, condition_str
,
7753 condition_map
, condition
);
7755 return bgp_vty_return(vty
, ret
);
7758 DEFPY (bgp_condadv_period
,
7759 bgp_condadv_period_cmd
,
7760 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7763 "Conditional advertisement settings\n"
7764 "Set period to rescan BGP table to check if condition is met\n"
7765 "Period between BGP table scans, in seconds; default 60\n")
7767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7769 bgp
->condition_check_period
=
7770 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7775 DEFPY (neighbor_advertise_map
,
7776 neighbor_advertise_map_cmd
,
7777 "[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",
7781 "Route-map to conditionally advertise routes\n"
7782 "Name of advertise map\n"
7783 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7784 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7785 "Name of the exist or non exist map\n")
7787 bool condition
= CONDITION_EXIST
;
7789 if (!strcmp(exist
, "non-exist-map"))
7790 condition
= CONDITION_NON_EXIST
;
7792 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7793 bgp_node_safi(vty
), advertise_str
,
7794 condition_str
, condition
, !no
);
7797 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7798 "[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",
7799 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7800 "Route-map to conditionally advertise routes\n"
7801 "Name of advertise map\n"
7802 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7803 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7804 "Name of the exist or non exist map\n")
7806 /* Set route-map to the peer. */
7807 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7808 afi_t afi
, safi_t safi
, const char *name_str
,
7809 const char *direct_str
)
7813 int direct
= RMAP_IN
;
7814 struct route_map
*route_map
;
7816 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7818 return CMD_WARNING_CONFIG_FAILED
;
7820 /* Check filter direction. */
7821 if (strncmp(direct_str
, "in", 2) == 0)
7823 else if (strncmp(direct_str
, "o", 1) == 0)
7826 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7827 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7829 return bgp_vty_return(vty
, ret
);
7832 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7833 afi_t afi
, safi_t safi
,
7834 const char *direct_str
)
7838 int direct
= RMAP_IN
;
7840 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7842 return CMD_WARNING_CONFIG_FAILED
;
7844 /* Check filter direction. */
7845 if (strncmp(direct_str
, "in", 2) == 0)
7847 else if (strncmp(direct_str
, "o", 1) == 0)
7850 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7852 return bgp_vty_return(vty
, ret
);
7855 DEFUN (neighbor_route_map
,
7856 neighbor_route_map_cmd
,
7857 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7860 "Apply route map to neighbor\n"
7861 "Name of route map\n"
7862 "Apply map to incoming routes\n"
7863 "Apply map to outbound routes\n")
7868 return peer_route_map_set_vty(
7869 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7870 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7873 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7874 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7875 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7876 "Apply route map to neighbor\n"
7877 "Name of route map\n"
7878 "Apply map to incoming routes\n"
7879 "Apply map to outbound routes\n")
7881 DEFUN (no_neighbor_route_map
,
7882 no_neighbor_route_map_cmd
,
7883 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7887 "Apply route map to neighbor\n"
7888 "Name of route map\n"
7889 "Apply map to incoming routes\n"
7890 "Apply map to outbound routes\n")
7894 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7895 bgp_node_afi(vty
), bgp_node_safi(vty
),
7896 argv
[idx_in_out
]->arg
);
7899 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7900 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7901 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7902 "Apply route map to neighbor\n"
7903 "Name of route map\n"
7904 "Apply map to incoming routes\n"
7905 "Apply map to outbound routes\n")
7907 /* Set unsuppress-map to the peer. */
7908 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7909 afi_t afi
, safi_t safi
,
7910 const char *name_str
)
7914 struct route_map
*route_map
;
7916 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7918 return CMD_WARNING_CONFIG_FAILED
;
7920 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7921 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7923 return bgp_vty_return(vty
, ret
);
7926 /* Unset route-map from the peer. */
7927 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7928 afi_t afi
, safi_t safi
)
7933 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7935 return CMD_WARNING_CONFIG_FAILED
;
7937 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7939 return bgp_vty_return(vty
, ret
);
7942 DEFUN (neighbor_unsuppress_map
,
7943 neighbor_unsuppress_map_cmd
,
7944 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7947 "Route-map to selectively unsuppress suppressed routes\n"
7948 "Name of route map\n")
7952 return peer_unsuppress_map_set_vty(
7953 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7954 argv
[idx_word
]->arg
);
7957 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7958 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7959 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7960 "Route-map to selectively unsuppress suppressed routes\n"
7961 "Name of route map\n")
7963 DEFUN (no_neighbor_unsuppress_map
,
7964 no_neighbor_unsuppress_map_cmd
,
7965 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7969 "Route-map to selectively unsuppress suppressed routes\n"
7970 "Name of route map\n")
7973 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7975 bgp_node_safi(vty
));
7978 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7979 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7980 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7981 "Route-map to selectively unsuppress suppressed routes\n"
7982 "Name of route map\n")
7984 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7985 afi_t afi
, safi_t safi
,
7986 const char *num_str
,
7987 const char *threshold_str
, int warning
,
7988 const char *restart_str
,
7989 const char *force_str
)
7997 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7999 return CMD_WARNING_CONFIG_FAILED
;
8001 max
= strtoul(num_str
, NULL
, 10);
8003 threshold
= atoi(threshold_str
);
8005 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8008 restart
= atoi(restart_str
);
8012 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8013 restart
, force_str
? true : false);
8015 return bgp_vty_return(vty
, ret
);
8018 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8019 afi_t afi
, safi_t safi
)
8024 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8026 return CMD_WARNING_CONFIG_FAILED
;
8028 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8030 return bgp_vty_return(vty
, ret
);
8033 /* Maximum number of prefix to be sent to the neighbor. */
8034 DEFUN(neighbor_maximum_prefix_out
,
8035 neighbor_maximum_prefix_out_cmd
,
8036 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8039 "Maximum number of prefixes to be sent to this peer\n"
8040 "Maximum no. of prefix limit\n")
8047 afi_t afi
= bgp_node_afi(vty
);
8048 safi_t safi
= bgp_node_safi(vty
);
8050 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8052 return CMD_WARNING_CONFIG_FAILED
;
8054 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8056 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8058 return bgp_vty_return(vty
, ret
);
8061 DEFUN(no_neighbor_maximum_prefix_out
,
8062 no_neighbor_maximum_prefix_out_cmd
,
8063 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8067 "Maximum number of prefixes to be sent to this peer\n"
8068 "Maximum no. of prefix limit\n")
8073 afi_t afi
= bgp_node_afi(vty
);
8074 safi_t safi
= bgp_node_safi(vty
);
8076 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8078 return CMD_WARNING_CONFIG_FAILED
;
8080 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8082 return bgp_vty_return(vty
, ret
);
8085 /* Maximum number of prefix configuration. Prefix count is different
8086 for each peer configuration. So this configuration can be set for
8087 each peer configuration. */
8088 DEFUN (neighbor_maximum_prefix
,
8089 neighbor_maximum_prefix_cmd
,
8090 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8093 "Maximum number of prefix accept from this peer\n"
8094 "maximum no. of prefix limit\n"
8095 "Force checking all received routes not only accepted\n")
8102 if (argv_find(argv
, argc
, "force", &idx_force
))
8103 force
= argv
[idx_force
]->arg
;
8105 return peer_maximum_prefix_set_vty(
8106 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8107 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8110 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8111 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8112 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8113 "Maximum number of prefix accept from this peer\n"
8114 "maximum no. of prefix limit\n"
8115 "Force checking all received routes not only accepted\n")
8117 DEFUN (neighbor_maximum_prefix_threshold
,
8118 neighbor_maximum_prefix_threshold_cmd
,
8119 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8122 "Maximum number of prefix accept from this peer\n"
8123 "maximum no. of prefix limit\n"
8124 "Threshold value (%) at which to generate a warning msg\n"
8125 "Force checking all received routes not only accepted\n")
8129 int idx_number_2
= 4;
8133 if (argv_find(argv
, argc
, "force", &idx_force
))
8134 force
= argv
[idx_force
]->arg
;
8136 return peer_maximum_prefix_set_vty(
8137 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8138 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8142 neighbor_maximum_prefix_threshold
,
8143 neighbor_maximum_prefix_threshold_hidden_cmd
,
8144 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8145 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8146 "Maximum number of prefix accept from this peer\n"
8147 "maximum no. of prefix limit\n"
8148 "Threshold value (%) at which to generate a warning msg\n"
8149 "Force checking all received routes not only accepted\n")
8151 DEFUN (neighbor_maximum_prefix_warning
,
8152 neighbor_maximum_prefix_warning_cmd
,
8153 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8156 "Maximum number of prefix accept from this peer\n"
8157 "maximum no. of prefix limit\n"
8158 "Only give warning message when limit is exceeded\n"
8159 "Force checking all received routes not only accepted\n")
8166 if (argv_find(argv
, argc
, "force", &idx_force
))
8167 force
= argv
[idx_force
]->arg
;
8169 return peer_maximum_prefix_set_vty(
8170 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8171 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8175 neighbor_maximum_prefix_warning
,
8176 neighbor_maximum_prefix_warning_hidden_cmd
,
8177 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8178 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8179 "Maximum number of prefix accept from this peer\n"
8180 "maximum no. of prefix limit\n"
8181 "Only give warning message when limit is exceeded\n"
8182 "Force checking all received routes not only accepted\n")
8184 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8185 neighbor_maximum_prefix_threshold_warning_cmd
,
8186 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8189 "Maximum number of prefix accept from this peer\n"
8190 "maximum no. of prefix limit\n"
8191 "Threshold value (%) at which to generate a warning msg\n"
8192 "Only give warning message when limit is exceeded\n"
8193 "Force checking all received routes not only accepted\n")
8197 int idx_number_2
= 4;
8201 if (argv_find(argv
, argc
, "force", &idx_force
))
8202 force
= argv
[idx_force
]->arg
;
8204 return peer_maximum_prefix_set_vty(
8205 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8206 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8210 neighbor_maximum_prefix_threshold_warning
,
8211 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8212 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8213 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8214 "Maximum number of prefix accept from this peer\n"
8215 "maximum no. of prefix limit\n"
8216 "Threshold value (%) at which to generate a warning msg\n"
8217 "Only give warning message when limit is exceeded\n"
8218 "Force checking all received routes not only accepted\n")
8220 DEFUN (neighbor_maximum_prefix_restart
,
8221 neighbor_maximum_prefix_restart_cmd
,
8222 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8225 "Maximum number of prefix accept from this peer\n"
8226 "maximum no. of prefix limit\n"
8227 "Restart bgp connection after limit is exceeded\n"
8228 "Restart interval in minutes\n"
8229 "Force checking all received routes not only accepted\n")
8233 int idx_number_2
= 5;
8237 if (argv_find(argv
, argc
, "force", &idx_force
))
8238 force
= argv
[idx_force
]->arg
;
8240 return peer_maximum_prefix_set_vty(
8241 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8242 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8246 neighbor_maximum_prefix_restart
,
8247 neighbor_maximum_prefix_restart_hidden_cmd
,
8248 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8249 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8250 "Maximum number of prefix accept from this peer\n"
8251 "maximum no. of prefix limit\n"
8252 "Restart bgp connection after limit is exceeded\n"
8253 "Restart interval in minutes\n"
8254 "Force checking all received routes not only accepted\n")
8256 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8257 neighbor_maximum_prefix_threshold_restart_cmd
,
8258 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8261 "Maximum number of prefixes to accept from this peer\n"
8262 "maximum no. of prefix limit\n"
8263 "Threshold value (%) at which to generate a warning msg\n"
8264 "Restart bgp connection after limit is exceeded\n"
8265 "Restart interval in minutes\n"
8266 "Force checking all received routes not only accepted\n")
8270 int idx_number_2
= 4;
8271 int idx_number_3
= 6;
8275 if (argv_find(argv
, argc
, "force", &idx_force
))
8276 force
= argv
[idx_force
]->arg
;
8278 return peer_maximum_prefix_set_vty(
8279 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8280 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8281 argv
[idx_number_3
]->arg
, force
);
8285 neighbor_maximum_prefix_threshold_restart
,
8286 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8287 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8288 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8289 "Maximum number of prefixes to accept from this peer\n"
8290 "maximum no. of prefix limit\n"
8291 "Threshold value (%) at which to generate a warning msg\n"
8292 "Restart bgp connection after limit is exceeded\n"
8293 "Restart interval in minutes\n"
8294 "Force checking all received routes not only accepted\n")
8296 DEFUN (no_neighbor_maximum_prefix
,
8297 no_neighbor_maximum_prefix_cmd
,
8298 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8302 "Maximum number of prefixes to accept from this peer\n"
8303 "maximum no. of prefix limit\n"
8304 "Threshold value (%) at which to generate a warning msg\n"
8305 "Restart bgp connection after limit is exceeded\n"
8306 "Restart interval in minutes\n"
8307 "Only give warning message when limit is exceeded\n"
8308 "Force checking all received routes not only accepted\n")
8311 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8313 bgp_node_safi(vty
));
8317 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8318 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8319 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8320 "Maximum number of prefixes to accept from this peer\n"
8321 "maximum no. of prefix limit\n"
8322 "Threshold value (%) at which to generate a warning msg\n"
8323 "Restart bgp connection after limit is exceeded\n"
8324 "Restart interval in minutes\n"
8325 "Only give warning message when limit is exceeded\n"
8326 "Force checking all received routes not only accepted\n")
8328 /* "neighbor accept-own" */
8329 DEFPY (neighbor_accept_own
,
8330 neighbor_accept_own_cmd
,
8331 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8335 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8338 afi_t afi
= bgp_node_afi(vty
);
8339 safi_t safi
= bgp_node_safi(vty
);
8342 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8344 return CMD_WARNING_CONFIG_FAILED
;
8347 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8349 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8351 return bgp_vty_return(vty
, ret
);
8354 /* "neighbor soo" */
8355 DEFPY (neighbor_soo
,
8357 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8360 "Set the Site-of-Origin (SoO) extended community\n"
8361 "VPN extended community\n")
8364 afi_t afi
= bgp_node_afi(vty
);
8365 safi_t safi
= bgp_node_safi(vty
);
8366 struct ecommunity
*ecomm_soo
;
8368 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8370 return CMD_WARNING_CONFIG_FAILED
;
8372 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8374 vty_out(vty
, "%% Malformed SoO extended community\n");
8377 ecommunity_str(ecomm_soo
);
8379 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8380 ecommunity_free(&peer
->soo
[afi
][safi
]);
8381 peer
->soo
[afi
][safi
] = ecomm_soo
;
8382 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8385 return bgp_vty_return(vty
,
8386 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8389 DEFPY (no_neighbor_soo
,
8390 no_neighbor_soo_cmd
,
8391 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8395 "Set the Site-of-Origin (SoO) extended community\n"
8396 "VPN extended community\n")
8399 afi_t afi
= bgp_node_afi(vty
);
8400 safi_t safi
= bgp_node_safi(vty
);
8402 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8404 return CMD_WARNING_CONFIG_FAILED
;
8406 ecommunity_free(&peer
->soo
[afi
][safi
]);
8408 return bgp_vty_return(
8409 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8412 /* "neighbor allowas-in" */
8413 DEFUN (neighbor_allowas_in
,
8414 neighbor_allowas_in_cmd
,
8415 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8418 "Accept as-path with my AS present in it\n"
8419 "Number of occurrences of AS number\n"
8420 "Only accept my AS in the as-path if the route was originated in my AS\n")
8423 int idx_number_origin
= 3;
8429 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8431 return CMD_WARNING_CONFIG_FAILED
;
8433 if (argc
<= idx_number_origin
)
8436 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8439 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8442 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8445 return bgp_vty_return(vty
, ret
);
8449 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8450 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8451 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8452 "Accept as-path with my AS present in it\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 (no_neighbor_allowas_in
,
8457 no_neighbor_allowas_in_cmd
,
8458 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8462 "allow local ASN appears in aspath attribute\n"
8463 "Number of occurrences of AS number\n"
8464 "Only accept my AS in the as-path if the route was originated in my AS\n")
8470 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8472 return CMD_WARNING_CONFIG_FAILED
;
8474 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8475 bgp_node_safi(vty
));
8477 return bgp_vty_return(vty
, ret
);
8481 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8482 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8483 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8484 "allow local ASN appears in aspath attribute\n"
8485 "Number of occurrences of AS number\n"
8486 "Only accept my AS in the as-path if the route was originated in my AS\n")
8488 DEFUN (neighbor_ttl_security
,
8489 neighbor_ttl_security_cmd
,
8490 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8493 "BGP ttl-security parameters\n"
8494 "Specify the maximum number of hops to the BGP peer\n"
8495 "Number of hops to BGP peer\n")
8502 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8504 return CMD_WARNING_CONFIG_FAILED
;
8506 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8509 * If 'neighbor swpX', then this is for directly connected peers,
8510 * we should not accept a ttl-security hops value greater than 1.
8512 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8514 "%s is directly connected peer, hops cannot exceed 1\n",
8515 argv
[idx_peer
]->arg
);
8516 return CMD_WARNING_CONFIG_FAILED
;
8519 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8522 DEFUN (no_neighbor_ttl_security
,
8523 no_neighbor_ttl_security_cmd
,
8524 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8528 "BGP ttl-security parameters\n"
8529 "Specify the maximum number of hops to the BGP peer\n"
8530 "Number of hops to BGP peer\n")
8535 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8537 return CMD_WARNING_CONFIG_FAILED
;
8539 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8542 /* disable-addpath-rx */
8543 DEFUN(neighbor_disable_addpath_rx
,
8544 neighbor_disable_addpath_rx_cmd
,
8545 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8548 "Do not accept additional paths\n")
8550 char *peer_str
= argv
[1]->arg
;
8552 afi_t afi
= bgp_node_afi(vty
);
8553 safi_t safi
= bgp_node_safi(vty
);
8555 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8557 return CMD_WARNING_CONFIG_FAILED
;
8559 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8560 PEER_FLAG_DISABLE_ADDPATH_RX
);
8563 DEFUN(no_neighbor_disable_addpath_rx
,
8564 no_neighbor_disable_addpath_rx_cmd
,
8565 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8569 "Do not accept additional paths\n")
8571 char *peer_str
= argv
[2]->arg
;
8573 afi_t afi
= bgp_node_afi(vty
);
8574 safi_t safi
= bgp_node_safi(vty
);
8576 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8578 return CMD_WARNING_CONFIG_FAILED
;
8580 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8581 PEER_FLAG_DISABLE_ADDPATH_RX
);
8584 DEFUN (neighbor_addpath_tx_all_paths
,
8585 neighbor_addpath_tx_all_paths_cmd
,
8586 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8589 "Use addpath to advertise all paths to a neighbor\n")
8594 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8596 return CMD_WARNING_CONFIG_FAILED
;
8598 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8603 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8604 neighbor_addpath_tx_all_paths_hidden_cmd
,
8605 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8606 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8607 "Use addpath to advertise all paths to a neighbor\n")
8609 DEFUN (no_neighbor_addpath_tx_all_paths
,
8610 no_neighbor_addpath_tx_all_paths_cmd
,
8611 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8615 "Use addpath to advertise all paths to a neighbor\n")
8620 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8622 return CMD_WARNING_CONFIG_FAILED
;
8624 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8625 != BGP_ADDPATH_ALL
) {
8627 "%% Peer not currently configured to transmit all paths.");
8628 return CMD_WARNING_CONFIG_FAILED
;
8631 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8637 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8638 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8639 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8640 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8641 "Use addpath to advertise all paths to a neighbor\n")
8643 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8644 neighbor_addpath_tx_bestpath_per_as_cmd
,
8645 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8648 "Use addpath to advertise the bestpath per each neighboring AS\n")
8653 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8655 return CMD_WARNING_CONFIG_FAILED
;
8657 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8658 BGP_ADDPATH_BEST_PER_AS
);
8663 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8664 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8665 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8666 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8667 "Use addpath to advertise the bestpath per each neighboring AS\n")
8669 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8670 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8671 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8675 "Use addpath to advertise the bestpath per each neighboring AS\n")
8680 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8682 return CMD_WARNING_CONFIG_FAILED
;
8684 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8685 != BGP_ADDPATH_BEST_PER_AS
) {
8687 "%% Peer not currently configured to transmit all best path per as.");
8688 return CMD_WARNING_CONFIG_FAILED
;
8691 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8697 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8698 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8699 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8700 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8701 "Use addpath to advertise the bestpath per each neighboring AS\n")
8704 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8705 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8708 "Detect AS loops before sending to neighbor\n")
8712 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8714 return CMD_WARNING_CONFIG_FAILED
;
8716 peer
->as_path_loop_detection
= true;
8722 no_neighbor_aspath_loop_detection
,
8723 no_neighbor_aspath_loop_detection_cmd
,
8724 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8728 "Detect AS loops before sending to neighbor\n")
8732 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8734 return CMD_WARNING_CONFIG_FAILED
;
8736 peer
->as_path_loop_detection
= false;
8741 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8742 struct ecommunity
**list
, bool is_rt6
)
8744 struct ecommunity
*ecom
= NULL
;
8745 struct ecommunity
*ecomadd
;
8747 for (; argc
; --argc
, ++argv
) {
8749 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8750 ECOMMUNITY_ROUTE_TARGET
,
8753 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8754 ECOMMUNITY_ROUTE_TARGET
,
8757 vty_out(vty
, "Malformed community-list value\n");
8759 ecommunity_free(&ecom
);
8760 return CMD_WARNING_CONFIG_FAILED
;
8764 ecommunity_merge(ecom
, ecomadd
);
8765 ecommunity_free(&ecomadd
);
8772 ecommunity_free(&*list
);
8780 * v2vimport is true if we are handling a `import vrf ...` command
8782 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8786 switch (vty
->node
) {
8795 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8800 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8801 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8802 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8803 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8805 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8809 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8810 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8811 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8812 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8814 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8821 DEFPY (af_rd_vpn_export
,
8822 af_rd_vpn_export_cmd
,
8823 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8825 "Specify route distinguisher\n"
8826 "Between current address-family and vpn\n"
8827 "For routes leaked from current address-family to vpn\n"
8828 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8831 struct prefix_rd prd
;
8837 if (argv_find(argv
, argc
, "no", &idx
))
8841 ret
= str2prefix_rd(rd_str
, &prd
);
8843 vty_out(vty
, "%% Malformed rd\n");
8844 return CMD_WARNING_CONFIG_FAILED
;
8848 afi
= vpn_policy_getafi(vty
, bgp
, false);
8850 return CMD_WARNING_CONFIG_FAILED
;
8853 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8855 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8856 bgp_get_default(), bgp
);
8859 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8860 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8861 BGP_VPN_POLICY_TOVPN_RD_SET
);
8863 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8864 BGP_VPN_POLICY_TOVPN_RD_SET
);
8867 /* post-change: re-export vpn routes */
8868 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8869 bgp_get_default(), bgp
);
8874 ALIAS (af_rd_vpn_export
,
8875 af_no_rd_vpn_export_cmd
,
8878 "Specify route distinguisher\n"
8879 "Between current address-family and vpn\n"
8880 "For routes leaked from current address-family to vpn\n")
8882 DEFPY (af_label_vpn_export
,
8883 af_label_vpn_export_cmd
,
8884 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8886 "label value for VRF\n"
8887 "Between current address-family and vpn\n"
8888 "For routes leaked from current address-family to vpn\n"
8889 "Label Value <0-1048575>\n"
8890 "Automatically assign a label\n")
8892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8893 mpls_label_t label
= MPLS_LABEL_NONE
;
8898 if (argv_find(argv
, argc
, "no", &idx
))
8901 /* If "no ...", squash trailing parameter */
8907 label
= label_val
; /* parser should force unsigned */
8910 afi
= vpn_policy_getafi(vty
, bgp
, false);
8912 return CMD_WARNING_CONFIG_FAILED
;
8915 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8916 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8921 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8923 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8924 bgp_get_default(), bgp
);
8926 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8927 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8929 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8932 * label has previously been automatically
8933 * assigned by labelpool: release it
8935 * NB if tovpn_label == MPLS_LABEL_NONE it
8936 * means the automatic assignment is in flight
8937 * and therefore the labelpool callback must
8938 * detect that the auto label is not needed.
8941 bgp_lp_release(LP_TYPE_VRF
,
8942 &bgp
->vpn_policy
[afi
],
8943 bgp
->vpn_policy
[afi
].tovpn_label
);
8945 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8946 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8949 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8951 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8952 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8953 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8954 vpn_leak_label_callback
);
8957 /* post-change: re-export vpn routes */
8958 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8959 bgp_get_default(), bgp
);
8961 hook_call(bgp_snmp_update_last_changed
, bgp
);
8965 DEFPY (af_sid_vpn_export
,
8966 af_sid_vpn_export_cmd
,
8967 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
8969 "sid value for VRF\n"
8970 "Between current address-family and vpn\n"
8971 "For routes leaked from current address-family to vpn\n"
8972 "Sid allocation index\n"
8973 "Automatically assign a label\n")
8975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8981 if (argv_find(argv
, argc
, "no", &idx
))
8983 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8984 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8986 afi
= vpn_policy_getafi(vty
, bgp
, false);
8988 return CMD_WARNING_CONFIG_FAILED
;
8992 vty_out(vty
, "It's not implemented\n");
8993 return CMD_WARNING_CONFIG_FAILED
;
8996 if (bgp
->tovpn_sid_index
!= 0 ||
8997 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
8999 "per-vrf sid and per-af sid are mutually exclusive\n"
9000 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9001 return CMD_WARNING_CONFIG_FAILED
;
9004 /* skip when it's already configured */
9005 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9006 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9007 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9011 * mode change between sid_idx and sid_auto isn't supported.
9012 * user must negate sid vpn export when they want to change the mode
9014 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9015 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9016 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9017 vty_out(vty
, "it's already configured as %s.\n",
9018 sid_auto
? "auto-mode" : "idx-mode");
9019 return CMD_WARNING_CONFIG_FAILED
;
9023 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9024 bgp_get_default(), bgp
);
9027 /* SID allocation auto-mode */
9029 zlog_debug("%s: auto sid alloc.", __func__
);
9030 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9031 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9033 /* SID allocation index-mode */
9035 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9036 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9040 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9041 bgp_get_default(), bgp
);
9045 DEFPY (bgp_sid_vpn_export
,
9046 bgp_sid_vpn_export_cmd
,
9047 "[no] sid vpn per-vrf export <(1-255)$sid_idx|auto$sid_auto>",
9049 "sid value for VRF\n"
9050 "Between current vrf and vpn\n"
9051 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9052 "For routes leaked from current vrf to vpn\n"
9053 "Sid allocation index\n"
9054 "Automatically assign a label\n")
9056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9059 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9060 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9063 /* when per-VRF SID is not set, do nothing */
9064 if (bgp
->tovpn_sid_index
== 0 &&
9065 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9070 bgp
->tovpn_sid_index
= 0;
9071 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9074 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9075 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9076 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9077 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9078 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9079 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9081 "per-vrf sid and per-af sid are mutually exclusive\n"
9082 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9083 return CMD_WARNING_CONFIG_FAILED
;
9086 /* skip when it's already configured */
9087 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9088 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9092 * mode change between sid_idx and sid_auto isn't supported.
9093 * user must negate sid vpn export when they want to change the mode
9095 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9097 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9098 vty_out(vty
, "it's already configured as %s.\n",
9099 sid_auto
? "auto-mode" : "idx-mode");
9100 return CMD_WARNING_CONFIG_FAILED
;
9104 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9106 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9110 /* SID allocation auto-mode */
9112 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9113 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9114 } else if (sid_idx
!= 0) {
9115 /* SID allocation index-mode */
9117 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9119 bgp
->tovpn_sid_index
= sid_idx
;
9123 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9125 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9126 bgp_get_default(), bgp
);
9131 ALIAS (af_label_vpn_export
,
9132 af_no_label_vpn_export_cmd
,
9133 "no label vpn export",
9135 "label value for VRF\n"
9136 "Between current address-family and vpn\n"
9137 "For routes leaked from current address-family to vpn\n")
9139 ALIAS (bgp_sid_vpn_export
,
9140 no_bgp_sid_vpn_export_cmd
,
9141 "no$no sid vpn per-vrf export",
9143 "sid value for VRF\n"
9144 "Between current vrf and vpn\n"
9145 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9146 "For routes leaked from current vrf to vpn\n")
9148 DEFPY (af_nexthop_vpn_export
,
9149 af_nexthop_vpn_export_cmd
,
9150 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9152 "Specify next hop to use for VRF advertised prefixes\n"
9153 "Between current address-family and vpn\n"
9154 "For routes leaked from current address-family to vpn\n"
9158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9164 vty_out(vty
, "%% Nexthop required\n");
9165 return CMD_WARNING_CONFIG_FAILED
;
9167 if (!sockunion2hostprefix(nexthop_su
, &p
))
9168 return CMD_WARNING_CONFIG_FAILED
;
9171 afi
= vpn_policy_getafi(vty
, bgp
, false);
9173 return CMD_WARNING_CONFIG_FAILED
;
9176 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9178 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9179 bgp_get_default(), bgp
);
9182 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9183 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9184 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9186 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9187 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9190 /* post-change: re-export vpn routes */
9191 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9192 bgp_get_default(), bgp
);
9197 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9199 if (!strcmp(dstr
, "import")) {
9200 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9201 } else if (!strcmp(dstr
, "export")) {
9202 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9203 } else if (!strcmp(dstr
, "both")) {
9204 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9205 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9207 vty_out(vty
, "%% direction parse error\n");
9208 return CMD_WARNING_CONFIG_FAILED
;
9213 DEFPY (af_rt_vpn_imexport
,
9214 af_rt_vpn_imexport_cmd
,
9215 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9217 "Specify route target list\n"
9218 "Specify route target list\n"
9219 "Between current address-family and vpn\n"
9220 "For routes leaked from vpn to current address-family: match any\n"
9221 "For routes leaked from current address-family to vpn: set\n"
9222 "both import: match any and export: set\n"
9223 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9227 struct ecommunity
*ecom
= NULL
;
9228 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9229 enum vpn_policy_direction dir
;
9234 if (argv_find(argv
, argc
, "no", &idx
))
9237 afi
= vpn_policy_getafi(vty
, bgp
, false);
9239 return CMD_WARNING_CONFIG_FAILED
;
9241 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9242 if (ret
!= CMD_SUCCESS
)
9246 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9247 vty_out(vty
, "%% Missing RTLIST\n");
9248 return CMD_WARNING_CONFIG_FAILED
;
9250 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9251 if (ret
!= CMD_SUCCESS
) {
9256 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9260 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9263 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9265 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9266 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9267 ecommunity_dup(ecom
);
9269 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9271 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9272 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9275 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9279 ecommunity_free(&ecom
);
9284 ALIAS (af_rt_vpn_imexport
,
9285 af_no_rt_vpn_imexport_cmd
,
9286 "no <rt|route-target> vpn <import|export|both>$direction_str",
9288 "Specify route target list\n"
9289 "Specify route target list\n"
9290 "Between current address-family and vpn\n"
9291 "For routes leaked from vpn to current address-family\n"
9292 "For routes leaked from current address-family to vpn\n"
9293 "both import and export\n")
9295 DEFPY (af_route_map_vpn_imexport
,
9296 af_route_map_vpn_imexport_cmd
,
9297 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9298 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9300 "Specify route map\n"
9301 "Between current address-family and vpn\n"
9302 "For routes leaked from vpn to current address-family\n"
9303 "For routes leaked from current address-family to vpn\n"
9304 "name of route-map\n")
9306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9308 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9309 enum vpn_policy_direction dir
;
9314 if (argv_find(argv
, argc
, "no", &idx
))
9317 afi
= vpn_policy_getafi(vty
, bgp
, false);
9319 return CMD_WARNING_CONFIG_FAILED
;
9321 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9322 if (ret
!= CMD_SUCCESS
)
9325 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9329 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9332 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9333 XFREE(MTYPE_ROUTE_MAP_NAME
,
9334 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9335 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9336 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9337 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9338 route_map_lookup_warn_noexist(vty
, rmap_str
);
9339 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9342 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9343 XFREE(MTYPE_ROUTE_MAP_NAME
,
9344 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9345 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9346 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9349 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9355 ALIAS (af_route_map_vpn_imexport
,
9356 af_no_route_map_vpn_imexport_cmd
,
9357 "no route-map vpn <import|export>$direction_str",
9359 "Specify route map\n"
9360 "Between current address-family and vpn\n"
9361 "For routes leaked from vpn to current address-family\n"
9362 "For routes leaked from current address-family to vpn\n")
9364 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9365 "import vrf route-map RMAP$rmap_str",
9366 "Import routes from another VRF\n"
9367 "Vrf routes being filtered\n"
9368 "Specify route map\n"
9369 "name of route-map\n")
9371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9372 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9374 struct bgp
*bgp_default
;
9376 afi
= vpn_policy_getafi(vty
, bgp
, true);
9378 return CMD_WARNING_CONFIG_FAILED
;
9380 bgp_default
= bgp_get_default();
9385 /* Auto-create assuming the same AS */
9386 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9387 BGP_INSTANCE_TYPE_DEFAULT
);
9391 "VRF default is not configured as a bgp instance\n");
9396 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9398 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9399 XFREE(MTYPE_ROUTE_MAP_NAME
,
9400 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9401 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9402 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9403 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9404 route_map_lookup_warn_noexist(vty
, rmap_str
);
9405 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9408 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9409 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9411 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9416 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9417 "no import vrf route-map [RMAP$rmap_str]",
9419 "Import routes from another VRF\n"
9420 "Vrf routes being filtered\n"
9421 "Specify route map\n"
9422 "name of route-map\n")
9424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9425 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9428 afi
= vpn_policy_getafi(vty
, bgp
, true);
9430 return CMD_WARNING_CONFIG_FAILED
;
9432 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9434 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9435 XFREE(MTYPE_ROUTE_MAP_NAME
,
9436 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9437 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9438 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9440 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9441 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9442 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9444 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9449 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9450 "[no] import vrf VIEWVRFNAME$import_name",
9452 "Import routes from another VRF\n"
9453 "VRF to import from\n"
9454 "The name of the VRF\n")
9456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9457 struct listnode
*node
;
9458 struct bgp
*vrf_bgp
, *bgp_default
;
9461 bool remove
= false;
9464 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9468 if (import_name
== NULL
) {
9469 vty_out(vty
, "%% Missing import name\n");
9473 if (strcmp(import_name
, "route-map") == 0) {
9474 vty_out(vty
, "%% Must include route-map name\n");
9478 if (argv_find(argv
, argc
, "no", &idx
))
9481 afi
= vpn_policy_getafi(vty
, bgp
, true);
9483 return CMD_WARNING_CONFIG_FAILED
;
9485 safi
= bgp_node_safi(vty
);
9487 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9488 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9489 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9490 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9491 remove
? "unimport" : "import", import_name
);
9495 bgp_default
= bgp_get_default();
9497 /* Auto-create assuming the same AS */
9498 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9499 BGP_INSTANCE_TYPE_DEFAULT
);
9503 "VRF default is not configured as a bgp instance\n");
9508 vrf_bgp
= bgp_lookup_by_name(import_name
);
9510 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9511 vrf_bgp
= bgp_default
;
9513 /* Auto-create assuming the same AS */
9514 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9518 "VRF %s is not configured as a bgp instance\n",
9525 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9527 /* Already importing from "import_vrf"? */
9528 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9530 if (strcmp(vname
, import_name
) == 0)
9534 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9540 /* This command is valid only in a bgp vrf instance or the default instance */
9541 DEFPY (bgp_imexport_vpn
,
9542 bgp_imexport_vpn_cmd
,
9543 "[no] <import|export>$direction_str vpn",
9545 "Import routes to this address-family\n"
9546 "Export routes from this address-family\n"
9547 "to/from default instance VPN RIB\n")
9549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9556 enum vpn_policy_direction dir
;
9558 if (argv_find(argv
, argc
, "no", &idx
))
9561 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9562 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9564 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9565 return CMD_WARNING_CONFIG_FAILED
;
9568 afi
= bgp_node_afi(vty
);
9569 safi
= bgp_node_safi(vty
);
9570 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9571 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9572 return CMD_WARNING_CONFIG_FAILED
;
9575 if (!strcmp(direction_str
, "import")) {
9576 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9577 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9578 } else if (!strcmp(direction_str
, "export")) {
9579 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9580 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9582 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9583 return CMD_WARNING_CONFIG_FAILED
;
9586 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9589 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9590 if (!previous_state
) {
9591 /* trigger export current vrf */
9592 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9595 if (previous_state
) {
9596 /* trigger un-export current vrf */
9597 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9599 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9602 hook_call(bgp_snmp_init_stats
, bgp
);
9607 DEFPY (af_routetarget_import
,
9608 af_routetarget_import_cmd
,
9609 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9611 "Specify route target list\n"
9612 "Specify route target list\n"
9613 "Specify route target list\n"
9614 "Specify route target list\n"
9615 "Flow-spec redirect type route target\n"
9616 "Import routes to this address-family\n"
9617 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9621 struct ecommunity
*ecom
= NULL
;
9623 int idx
= 0, idx_unused
= 0;
9627 if (argv_find(argv
, argc
, "no", &idx
))
9630 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9631 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9634 afi
= vpn_policy_getafi(vty
, bgp
, false);
9636 return CMD_WARNING_CONFIG_FAILED
;
9638 if (rt6
&& afi
!= AFI_IP6
)
9639 return CMD_WARNING_CONFIG_FAILED
;
9642 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9643 vty_out(vty
, "%% Missing RTLIST\n");
9644 return CMD_WARNING_CONFIG_FAILED
;
9646 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9647 if (ret
!= CMD_SUCCESS
)
9652 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9653 ecommunity_free(&bgp
->vpn_policy
[afi
]
9654 .import_redirect_rtlist
);
9655 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9656 ecommunity_dup(ecom
);
9658 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9659 ecommunity_free(&bgp
->vpn_policy
[afi
]
9660 .import_redirect_rtlist
);
9661 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9665 ecommunity_free(&ecom
);
9670 DEFUN_NOSH (address_family_ipv4_safi
,
9671 address_family_ipv4_safi_cmd
,
9672 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9673 "Enter Address Family command mode\n"
9675 BGP_SAFI_WITH_LABEL_HELP_STR
)
9679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9680 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9681 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9682 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9683 && safi
!= SAFI_EVPN
) {
9685 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9686 return CMD_WARNING_CONFIG_FAILED
;
9688 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9690 vty
->node
= BGP_IPV4_NODE
;
9695 DEFUN_NOSH (address_family_ipv6_safi
,
9696 address_family_ipv6_safi_cmd
,
9697 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9698 "Enter Address Family command mode\n"
9700 BGP_SAFI_WITH_LABEL_HELP_STR
)
9703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9704 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9705 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9706 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9707 && safi
!= SAFI_EVPN
) {
9709 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9710 return CMD_WARNING_CONFIG_FAILED
;
9712 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9714 vty
->node
= BGP_IPV6_NODE
;
9719 #ifdef KEEP_OLD_VPN_COMMANDS
9720 DEFUN_NOSH (address_family_vpnv4
,
9721 address_family_vpnv4_cmd
,
9722 "address-family vpnv4 [unicast]",
9723 "Enter Address Family command mode\n"
9725 BGP_AF_MODIFIER_STR
)
9727 vty
->node
= BGP_VPNV4_NODE
;
9731 DEFUN_NOSH (address_family_vpnv6
,
9732 address_family_vpnv6_cmd
,
9733 "address-family vpnv6 [unicast]",
9734 "Enter Address Family command mode\n"
9736 BGP_AF_MODIFIER_STR
)
9738 vty
->node
= BGP_VPNV6_NODE
;
9741 #endif /* KEEP_OLD_VPN_COMMANDS */
9743 DEFUN_NOSH (address_family_evpn
,
9744 address_family_evpn_cmd
,
9745 "address-family l2vpn evpn",
9746 "Enter Address Family command mode\n"
9748 BGP_AF_MODIFIER_STR
)
9750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9751 vty
->node
= BGP_EVPN_NODE
;
9755 DEFUN_NOSH (bgp_segment_routing_srv6
,
9756 bgp_segment_routing_srv6_cmd
,
9757 "segment-routing srv6",
9758 "Segment-Routing configuration\n"
9759 "Segment-Routing SRv6 configuration\n")
9761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9762 bgp
->srv6_enabled
= true;
9763 vty
->node
= BGP_SRV6_NODE
;
9767 DEFUN (no_bgp_segment_routing_srv6
,
9768 no_bgp_segment_routing_srv6_cmd
,
9769 "no segment-routing srv6",
9771 "Segment-Routing configuration\n"
9772 "Segment-Routing SRv6 configuration\n")
9774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9776 if (strlen(bgp
->srv6_locator_name
) > 0)
9777 if (bgp_srv6_locator_unset(bgp
) < 0)
9778 return CMD_WARNING_CONFIG_FAILED
;
9780 bgp
->srv6_enabled
= false;
9784 DEFPY (bgp_srv6_locator
,
9785 bgp_srv6_locator_cmd
,
9786 "locator NAME$name",
9787 "Specify SRv6 locator\n"
9788 "Specify SRv6 locator\n")
9790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9793 if (strlen(bgp
->srv6_locator_name
) > 0
9794 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9795 vty_out(vty
, "srv6 locator is already configured\n");
9796 return CMD_WARNING_CONFIG_FAILED
;
9799 snprintf(bgp
->srv6_locator_name
,
9800 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9802 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9804 return CMD_WARNING_CONFIG_FAILED
;
9809 DEFPY (no_bgp_srv6_locator
,
9810 no_bgp_srv6_locator_cmd
,
9811 "no locator NAME$name",
9813 "Specify SRv6 locator\n"
9814 "Specify SRv6 locator\n")
9816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9818 /* when locator isn't configured, do nothing */
9819 if (strlen(bgp
->srv6_locator_name
) < 1)
9822 /* name validation */
9823 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9824 vty_out(vty
, "%% No srv6 locator is configured\n");
9825 return CMD_WARNING_CONFIG_FAILED
;
9829 if (bgp_srv6_locator_unset(bgp
) < 0)
9830 return CMD_WARNING_CONFIG_FAILED
;
9835 DEFPY (show_bgp_srv6
,
9837 "show bgp segment-routing srv6",
9840 "BGP Segment Routing\n"
9841 "BGP Segment Routing SRv6\n")
9844 struct listnode
*node
;
9845 struct srv6_locator_chunk
*chunk
;
9846 struct bgp_srv6_function
*func
;
9849 bgp
= bgp_get_default();
9853 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9854 vty_out(vty
, "locator_chunks:\n");
9855 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9856 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9857 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9858 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9859 vty_out(vty
, " func-length: %d\n",
9860 chunk
->function_bits_length
);
9861 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9864 vty_out(vty
, "functions:\n");
9865 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9866 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9867 vty_out(vty
, "- sid: %s\n", buf
);
9868 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9871 vty_out(vty
, "bgps:\n");
9872 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9873 vty_out(vty
, "- name: %s\n",
9874 bgp
->name
? bgp
->name
: "default");
9876 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9877 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9878 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9879 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9880 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9886 DEFUN_NOSH (exit_address_family
,
9887 exit_address_family_cmd
,
9888 "exit-address-family",
9889 "Exit from Address Family configuration mode\n")
9891 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9892 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9893 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9894 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9895 || vty
->node
== BGP_EVPN_NODE
9896 || vty
->node
== BGP_FLOWSPECV4_NODE
9897 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9898 vty
->node
= BGP_NODE
;
9902 /* Recalculate bestpath and re-advertise a prefix */
9903 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9904 const char *ip_str
, afi_t afi
, safi_t safi
,
9905 struct prefix_rd
*prd
)
9908 struct prefix match
;
9909 struct bgp_dest
*dest
;
9910 struct bgp_dest
*rm
;
9912 struct bgp_table
*table
;
9913 struct bgp_table
*rib
;
9915 /* BGP structure lookup. */
9917 bgp
= bgp_lookup_by_name(view_name
);
9919 vty_out(vty
, "%% Can't find BGP instance %s\n",
9924 bgp
= bgp_get_default();
9926 vty_out(vty
, "%% No BGP process is configured\n");
9931 /* Check IP address argument. */
9932 ret
= str2prefix(ip_str
, &match
);
9934 vty_out(vty
, "%% address is malformed\n");
9938 match
.family
= afi2family(afi
);
9939 rib
= bgp
->rib
[afi
][safi
];
9941 if (safi
== SAFI_MPLS_VPN
) {
9942 for (dest
= bgp_table_top(rib
); dest
;
9943 dest
= bgp_route_next(dest
)) {
9944 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9946 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9949 table
= bgp_dest_get_bgp_table_info(dest
);
9953 rm
= bgp_node_match(table
, &match
);
9955 const struct prefix
*rm_p
=
9956 bgp_dest_get_prefix(rm
);
9958 if (rm_p
->prefixlen
== match
.prefixlen
) {
9960 BGP_NODE_USER_CLEAR
);
9961 bgp_process(bgp
, rm
, afi
, safi
);
9963 bgp_dest_unlock_node(rm
);
9967 dest
= bgp_node_match(rib
, &match
);
9969 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9971 if (dest_p
->prefixlen
== match
.prefixlen
) {
9972 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9973 bgp_process(bgp
, dest
, afi
, safi
);
9975 bgp_dest_unlock_node(dest
);
9982 /* one clear bgp command to rule them all */
9983 DEFUN (clear_ip_bgp_all
,
9984 clear_ip_bgp_all_cmd
,
9985 "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>]",
9989 BGP_INSTANCE_HELP_STR
9992 BGP_SAFI_WITH_LABEL_HELP_STR
9995 "BGP IPv4 neighbor to clear\n"
9996 "BGP IPv6 neighbor to clear\n"
9997 "BGP neighbor on interface to clear\n"
9998 "Clear peers with the AS number\n"
9999 "Clear all external peers\n"
10000 "Clear all members of peer-group\n"
10001 "BGP peer-group name\n"
10006 "Push out prefix-list ORF and do inbound soft reconfig\n"
10008 "Reset message statistics\n")
10012 afi_t afi
= AFI_UNSPEC
;
10013 safi_t safi
= SAFI_UNSPEC
;
10014 enum clear_sort clr_sort
= clear_peer
;
10015 enum bgp_clear_type clr_type
;
10016 char *clr_arg
= NULL
;
10020 /* clear [ip] bgp */
10021 if (argv_find(argv
, argc
, "ip", &idx
))
10024 /* [<vrf> VIEWVRFNAME] */
10025 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10026 vrf
= argv
[idx
+ 1]->arg
;
10028 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10030 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10031 /* [<view> VIEWVRFNAME] */
10032 vrf
= argv
[idx
+ 1]->arg
;
10035 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10036 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10037 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10039 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10040 if (argv_find(argv
, argc
, "*", &idx
)) {
10041 clr_sort
= clear_all
;
10042 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10043 clr_sort
= clear_peer
;
10044 clr_arg
= argv
[idx
]->arg
;
10045 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10046 clr_sort
= clear_peer
;
10047 clr_arg
= argv
[idx
]->arg
;
10048 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10049 clr_sort
= clear_group
;
10051 clr_arg
= argv
[idx
]->arg
;
10052 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10053 clr_sort
= clear_peer
;
10054 clr_arg
= argv
[idx
]->arg
;
10055 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10056 clr_sort
= clear_peer
;
10057 clr_arg
= argv
[idx
]->arg
;
10058 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10059 clr_sort
= clear_as
;
10060 clr_arg
= argv
[idx
]->arg
;
10061 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10062 clr_sort
= clear_external
;
10065 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10066 if (argv_find(argv
, argc
, "soft", &idx
)) {
10067 if (argv_find(argv
, argc
, "in", &idx
)
10068 || argv_find(argv
, argc
, "out", &idx
))
10069 clr_type
= strmatch(argv
[idx
]->text
, "in")
10070 ? BGP_CLEAR_SOFT_IN
10071 : BGP_CLEAR_SOFT_OUT
;
10073 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10074 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10075 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10076 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10077 : BGP_CLEAR_SOFT_IN
;
10078 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10079 clr_type
= BGP_CLEAR_SOFT_OUT
;
10080 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10081 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10083 clr_type
= BGP_CLEAR_SOFT_NONE
;
10085 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10088 DEFUN (clear_ip_bgp_prefix
,
10089 clear_ip_bgp_prefix_cmd
,
10090 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10094 BGP_INSTANCE_HELP_STR
10095 "Clear bestpath and re-advertise\n"
10099 char *prefix
= NULL
;
10103 /* [<view|vrf> VIEWVRFNAME] */
10104 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10105 vrf
= argv
[idx
+ 1]->arg
;
10107 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10109 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10110 /* [<view> VIEWVRFNAME] */
10111 vrf
= argv
[idx
+ 1]->arg
;
10115 prefix
= argv
[argc
- 1]->arg
;
10117 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10120 DEFUN (clear_bgp_ipv6_safi_prefix
,
10121 clear_bgp_ipv6_safi_prefix_cmd
,
10122 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10128 "Clear bestpath and re-advertise\n"
10132 int idx_ipv6_prefix
= 0;
10133 safi_t safi
= SAFI_UNICAST
;
10134 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10135 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10137 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10138 return bgp_clear_prefix(
10139 vty
, NULL
, prefix
, AFI_IP6
,
10143 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10144 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10145 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10149 BGP_INSTANCE_HELP_STR
10152 "Clear bestpath and re-advertise\n"
10156 int idx_vrfview
= 0;
10157 int idx_ipv6_prefix
= 0;
10158 safi_t safi
= SAFI_UNICAST
;
10159 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10160 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10161 char *vrfview
= NULL
;
10163 /* [<view|vrf> VIEWVRFNAME] */
10164 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10165 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10166 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10168 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10169 /* [<view> VIEWVRFNAME] */
10170 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10172 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10174 return bgp_clear_prefix(
10175 vty
, vrfview
, prefix
,
10176 AFI_IP6
, safi
, NULL
);
10179 DEFUN (show_bgp_views
,
10180 show_bgp_views_cmd
,
10181 "show [ip] bgp views",
10185 "Show the defined BGP views\n")
10187 struct list
*inst
= bm
->bgp
;
10188 struct listnode
*node
;
10191 vty_out(vty
, "Defined BGP views:\n");
10192 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10194 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10196 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10200 return CMD_SUCCESS
;
10203 DEFUN (show_bgp_vrfs
,
10205 "show [ip] bgp vrfs [json]",
10212 char buf
[ETHER_ADDR_STRLEN
];
10213 struct list
*inst
= bm
->bgp
;
10214 struct listnode
*node
;
10216 bool uj
= use_json(argc
, argv
);
10217 json_object
*json
= NULL
;
10218 json_object
*json_vrfs
= NULL
;
10222 json
= json_object_new_object();
10223 json_vrfs
= json_object_new_object();
10226 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10227 const char *name
, *type
;
10229 struct listnode
*node2
, *nnode2
;
10230 int peers_cfg
, peers_estb
;
10231 json_object
*json_vrf
= NULL
;
10234 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10238 if (!uj
&& count
== 1) {
10240 "%4s %-5s %-16s %9s %10s %-37s\n",
10241 "Type", "Id", "routerId", "#PeersCfg",
10242 "#PeersEstb", "Name");
10243 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10244 "L3-VNI", "RouterMAC", "Interface");
10247 peers_cfg
= peers_estb
= 0;
10249 json_vrf
= json_object_new_object();
10252 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10253 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10256 if (peer_established(peer
))
10260 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10261 name
= VRF_DEFAULT_NAME
;
10270 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10272 : (int64_t)bgp
->vrf_id
;
10273 char buf
[BUFSIZ
] = {0};
10275 json_object_string_add(json_vrf
, "type", type
);
10276 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10277 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10279 json_object_int_add(json_vrf
, "numConfiguredPeers",
10281 json_object_int_add(json_vrf
, "numEstablishedPeers",
10284 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10285 json_object_string_add(
10287 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10288 json_object_string_add(json_vrf
, "interface",
10289 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10291 json_object_object_add(json_vrfs
, name
, json_vrf
);
10293 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10295 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10296 : (int)bgp
->vrf_id
,
10297 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10298 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10300 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10301 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10307 json_object_object_add(json
, "vrfs", json_vrfs
);
10309 json_object_int_add(json
, "totalVrfs", count
);
10311 vty_json(vty
, json
);
10315 "\nTotal number of VRFs (including default): %d\n",
10319 return CMD_SUCCESS
;
10322 DEFUN (show_bgp_mac_hash
,
10323 show_bgp_mac_hash_cmd
,
10324 "show bgp mac hash",
10328 "Mac Address database\n")
10330 bgp_mac_dump_table(vty
);
10332 return CMD_SUCCESS
;
10335 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10337 struct vty
*vty
= (struct vty
*)args
;
10338 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10340 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10343 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10345 vty_out(vty
, "self nexthop database:\n");
10346 bgp_nexthop_show_address_hash(vty
, bgp
);
10348 vty_out(vty
, "Tunnel-ip database:\n");
10349 hash_iterate(bgp
->tip_hash
,
10350 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10354 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10355 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10356 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10357 "martian next-hops\n"
10358 "martian next-hop database\n")
10360 struct bgp
*bgp
= NULL
;
10364 /* [<vrf> VIEWVRFNAME] */
10365 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10366 name
= argv
[idx
+ 1]->arg
;
10367 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10369 } else if (argv_find(argv
, argc
, "view", &idx
))
10370 /* [<view> VIEWVRFNAME] */
10371 name
= argv
[idx
+ 1]->arg
;
10373 bgp
= bgp_lookup_by_name(name
);
10375 bgp
= bgp_get_default();
10378 vty_out(vty
, "%% No BGP process is configured\n");
10379 return CMD_WARNING
;
10381 bgp_show_martian_nexthops(vty
, bgp
);
10383 return CMD_SUCCESS
;
10386 DEFUN (show_bgp_memory
,
10387 show_bgp_memory_cmd
,
10388 "show [ip] bgp memory",
10392 "Global BGP memory statistics\n")
10394 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10395 unsigned long count
;
10397 /* RIB related usage stats */
10398 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10399 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10400 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10401 count
* sizeof(struct bgp_dest
)));
10403 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10404 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10405 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10406 count
* sizeof(struct bgp_path_info
)));
10407 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10408 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10411 memstrbuf
, sizeof(memstrbuf
),
10412 count
* sizeof(struct bgp_path_info_extra
)));
10414 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10415 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10416 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10417 count
* sizeof(struct bgp_static
)));
10419 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10420 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10421 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10422 count
* sizeof(struct bpacket
)));
10425 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10426 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10427 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10428 count
* sizeof(struct bgp_adj_in
)));
10429 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10430 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10431 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10432 count
* sizeof(struct bgp_adj_out
)));
10434 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10435 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10437 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10438 count
* sizeof(struct bgp_nexthop_cache
)));
10440 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10441 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10443 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10444 count
* sizeof(struct bgp_damp_info
)));
10447 count
= attr_count();
10448 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10449 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10450 count
* sizeof(struct attr
)));
10452 if ((count
= attr_unknown_count()))
10453 vty_out(vty
, "%ld unknown attributes\n", count
);
10455 /* AS_PATH attributes */
10456 count
= aspath_count();
10457 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10458 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10459 count
* sizeof(struct aspath
)));
10461 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10462 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10463 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10464 count
* sizeof(struct assegment
)));
10466 /* Other attributes */
10467 if ((count
= community_count()))
10468 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10469 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10470 count
* sizeof(struct community
)));
10471 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10473 "%ld BGP ext-community entries, using %s of memory\n",
10475 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10476 count
* sizeof(struct ecommunity
)));
10477 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10479 "%ld BGP large-community entries, using %s of memory\n",
10480 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10481 count
* sizeof(struct lcommunity
)));
10483 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10484 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10485 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10486 count
* sizeof(struct cluster_list
)));
10488 /* Peer related usage */
10489 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10490 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10491 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10492 count
* sizeof(struct peer
)));
10494 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10495 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10497 count
* sizeof(struct peer_group
)));
10500 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10501 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10502 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10503 count
* sizeof(regex_t
)));
10504 return CMD_SUCCESS
;
10507 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10509 json_object
*bestpath
= json_object_new_object();
10511 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10512 json_object_string_add(bestpath
, "asPath", "ignore");
10514 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10515 json_object_string_add(bestpath
, "asPath", "confed");
10517 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10518 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10519 json_object_string_add(bestpath
, "multiPathRelax",
10522 json_object_string_add(bestpath
, "multiPathRelax",
10525 json_object_string_add(bestpath
, "multiPathRelax", "false");
10527 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10528 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10530 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10531 json_object_string_add(bestpath
, "compareRouterId", "true");
10532 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10533 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10534 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10535 json_object_string_add(bestpath
, "med", "confed");
10536 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10537 json_object_string_add(bestpath
, "med",
10538 "missing-as-worst");
10540 json_object_string_add(bestpath
, "med", "true");
10543 json_object_object_add(json
, "bestPath", bestpath
);
10546 /* Print the error code/subcode for why the peer is down */
10547 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10548 json_object
*json_peer
, bool use_json
)
10550 const char *code_str
;
10551 const char *subcode_str
;
10554 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10555 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10556 char errorcodesubcode_hexstr
[5];
10557 char errorcodesubcode_str
[256];
10559 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10560 subcode_str
= bgp_notify_subcode_str(
10562 peer
->notify
.subcode
);
10564 snprintf(errorcodesubcode_hexstr
,
10565 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10566 peer
->notify
.code
, peer
->notify
.subcode
);
10567 json_object_string_add(json_peer
,
10568 "lastErrorCodeSubcode",
10569 errorcodesubcode_hexstr
);
10570 snprintf(errorcodesubcode_str
, 255, "%s%s",
10571 code_str
, subcode_str
);
10572 json_object_string_add(json_peer
,
10573 "lastNotificationReason",
10574 errorcodesubcode_str
);
10575 json_object_boolean_add(json_peer
,
10576 "lastNotificationHardReset",
10577 peer
->notify
.hard_reset
);
10578 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10579 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10580 && (peer
->notify
.subcode
10581 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10582 || peer
->notify
.subcode
10583 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10584 && peer
->notify
.length
) {
10586 const char *msg_str
;
10588 msg_str
= bgp_notify_admin_message(
10589 msgbuf
, sizeof(msgbuf
),
10590 (uint8_t *)peer
->notify
.data
,
10591 peer
->notify
.length
);
10593 json_object_string_add(
10595 "lastShutdownDescription",
10600 json_object_string_add(json_peer
, "lastResetDueTo",
10601 peer_down_str
[(int)peer
->last_reset
]);
10602 json_object_int_add(json_peer
, "lastResetCode",
10605 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10606 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10607 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10609 bgp_notify_subcode_str(peer
->notify
.code
,
10610 peer
->notify
.subcode
);
10611 vty_out(vty
, " Notification %s (%s%s%s)\n",
10612 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10615 code_str
, subcode_str
,
10616 peer
->notify
.hard_reset
10617 ? bgp_notify_subcode_str(
10619 BGP_NOTIFY_CEASE_HARD_RESET
)
10622 vty_out(vty
, " %s\n",
10623 peer_down_str
[(int)peer
->last_reset
]);
10628 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10631 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10634 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10635 struct peer
*peer
, json_object
*json_peer
,
10636 int max_neighbor_width
, bool use_json
)
10638 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10642 if (peer_dynamic_neighbor(peer
))
10643 json_object_boolean_true_add(json_peer
,
10645 if (peer
->hostname
)
10646 json_object_string_add(json_peer
, "hostname",
10649 if (peer
->domainname
)
10650 json_object_string_add(json_peer
, "domainname",
10652 json_object_int_add(json_peer
, "connectionsEstablished",
10653 peer
->established
);
10654 json_object_int_add(json_peer
, "connectionsDropped",
10656 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10657 use_json
, json_peer
);
10658 if (peer_established(peer
))
10659 json_object_string_add(json_peer
, "lastResetDueTo",
10660 "AFI/SAFI Not Negotiated");
10662 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10665 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10667 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10668 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10669 peer
->hostname
, peer
->host
);
10671 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10673 /* pad the neighbor column with spaces */
10674 if (len
< max_neighbor_width
)
10675 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10677 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10679 peer_uptime(peer
->uptime
, timebuf
,
10680 BGP_UPTIME_LEN
, 0, NULL
));
10681 if (peer_established(peer
))
10682 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10684 bgp_show_peer_reset(vty
, peer
, NULL
,
10689 /* Strip peer's description to the given size. */
10690 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10692 static char stripped
[BUFSIZ
];
10694 uint32_t last_space
= 0;
10697 if (*(desc
+ i
) == 0) {
10698 stripped
[i
] = '\0';
10701 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10703 stripped
[i
] = *(desc
+ i
);
10707 if (last_space
> size
)
10708 stripped
[size
+ 1] = '\0';
10710 stripped
[last_space
] = '\0';
10715 /* Determine whether var peer should be filtered out of the summary. */
10716 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10717 struct peer
*fpeer
, int as_type
,
10721 /* filter neighbor XXXX */
10722 if (fpeer
&& fpeer
!= peer
)
10725 /* filter remote-as (internal|external) */
10726 if (as_type
!= AS_UNSPECIFIED
) {
10727 if (peer
->as_type
== AS_SPECIFIED
) {
10728 if (as_type
== AS_INTERNAL
) {
10729 if (peer
->as
!= peer
->local_as
)
10731 } else if (peer
->as
== peer
->local_as
)
10733 } else if (as_type
!= peer
->as_type
)
10735 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10741 /* Show BGP peer's summary information.
10743 * Peer's description is stripped according to if `wide` option is given
10746 * When adding new columns to `show bgp summary` output, please make
10747 * sure `Desc` is the lastest column to show because it can contain
10748 * whitespaces and the whole output will be tricky.
10750 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10751 struct peer
*fpeer
, int as_type
, as_t as
,
10752 uint16_t show_flags
)
10755 struct listnode
*node
, *nnode
;
10756 unsigned int count
= 0, dn_count
= 0;
10757 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10758 char neighbor_buf
[VTY_BUFSIZ
];
10759 int neighbor_col_default_width
= 16;
10760 int len
, failed_count
= 0;
10761 unsigned int filtered_count
= 0;
10762 int max_neighbor_width
= 0;
10764 json_object
*json
= NULL
;
10765 json_object
*json_peer
= NULL
;
10766 json_object
*json_peers
= NULL
;
10767 struct peer_af
*paf
;
10768 struct bgp_filter
*filter
;
10769 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10770 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10771 bool show_established
=
10772 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10773 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10774 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10776 /* labeled-unicast routes are installed in the unicast table so in order
10778 * display the correct PfxRcd value we must look at SAFI_UNICAST
10781 if (safi
== SAFI_LABELED_UNICAST
)
10782 pfx_rcd_safi
= SAFI_UNICAST
;
10784 pfx_rcd_safi
= safi
;
10787 json
= json_object_new_object();
10788 json_peers
= json_object_new_object();
10789 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10790 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10797 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10800 if (peer
->afc
[afi
][safi
]) {
10801 /* See if we have at least a single failed peer */
10802 if (bgp_has_peer_failed(peer
, afi
, safi
))
10806 if (peer_dynamic_neighbor(peer
))
10811 /* Loop over all neighbors that will be displayed to determine
10813 * characters are needed for the Neighbor column
10815 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10816 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10823 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10826 if (peer
->afc
[afi
][safi
]) {
10827 memset(dn_flag
, '\0', sizeof(dn_flag
));
10828 if (peer_dynamic_neighbor(peer
))
10832 && CHECK_FLAG(bgp
->flags
,
10833 BGP_FLAG_SHOW_HOSTNAME
))
10834 snprintf(neighbor_buf
,
10835 sizeof(neighbor_buf
),
10836 "%s%s(%s) ", dn_flag
,
10837 peer
->hostname
, peer
->host
);
10839 snprintf(neighbor_buf
,
10840 sizeof(neighbor_buf
), "%s%s ",
10841 dn_flag
, peer
->host
);
10843 len
= strlen(neighbor_buf
);
10845 if (len
> max_neighbor_width
)
10846 max_neighbor_width
= len
;
10848 /* See if we have at least a single failed peer */
10849 if (bgp_has_peer_failed(peer
, afi
, safi
))
10855 /* Originally we displayed the Neighbor column as 16
10856 * characters wide so make that the default
10858 if (max_neighbor_width
< neighbor_col_default_width
)
10859 max_neighbor_width
= neighbor_col_default_width
;
10862 if (show_failed
&& !failed_count
) {
10864 json_object_int_add(json
, "failedPeersCount", 0);
10865 json_object_int_add(json
, "dynamicPeers", dn_count
);
10866 json_object_int_add(json
, "totalPeers", count
);
10868 vty_json(vty
, json
);
10870 vty_out(vty
, "%% No failed BGP neighbors found\n");
10872 return CMD_SUCCESS
;
10875 count
= 0; /* Reset the value as its used again */
10876 filtered_count
= 0;
10878 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10879 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10882 if (!peer
->afc
[afi
][safi
])
10886 unsigned long ents
;
10887 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10890 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10892 : (int64_t)bgp
->vrf_id
;
10894 /* Usage summary and header */
10896 json_object_string_addf(json
, "routerId",
10899 json_object_int_add(json
, "as", bgp
->as
);
10900 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10901 json_object_string_add(
10904 == BGP_INSTANCE_TYPE_DEFAULT
)
10909 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10910 &bgp
->router_id
, bgp
->as
,
10911 bgp
->vrf_id
== VRF_UNKNOWN
10913 : (int)bgp
->vrf_id
);
10914 vty_out(vty
, "\n");
10917 if (bgp_update_delay_configured(bgp
)) {
10919 json_object_int_add(
10920 json
, "updateDelayLimit",
10921 bgp
->v_update_delay
);
10923 if (bgp
->v_update_delay
10924 != bgp
->v_establish_wait
)
10925 json_object_int_add(
10927 "updateDelayEstablishWait",
10928 bgp
->v_establish_wait
);
10930 if (bgp_update_delay_active(bgp
)) {
10931 json_object_string_add(
10933 "updateDelayFirstNeighbor",
10934 bgp
->update_delay_begin_time
);
10935 json_object_boolean_true_add(
10937 "updateDelayInProgress");
10939 if (bgp
->update_delay_over
) {
10940 json_object_string_add(
10942 "updateDelayFirstNeighbor",
10943 bgp
->update_delay_begin_time
);
10944 json_object_string_add(
10946 "updateDelayBestpathResumed",
10947 bgp
->update_delay_end_time
);
10948 json_object_string_add(
10950 "updateDelayZebraUpdateResume",
10951 bgp
->update_delay_zebra_resume_time
);
10952 json_object_string_add(
10954 "updateDelayPeerUpdateResume",
10955 bgp
->update_delay_peers_resume_time
);
10960 "Read-only mode update-delay limit: %d seconds\n",
10961 bgp
->v_update_delay
);
10962 if (bgp
->v_update_delay
10963 != bgp
->v_establish_wait
)
10965 " Establish wait: %d seconds\n",
10966 bgp
->v_establish_wait
);
10968 if (bgp_update_delay_active(bgp
)) {
10970 " First neighbor established: %s\n",
10971 bgp
->update_delay_begin_time
);
10973 " Delay in progress\n");
10975 if (bgp
->update_delay_over
) {
10977 " First neighbor established: %s\n",
10978 bgp
->update_delay_begin_time
);
10980 " Best-paths resumed: %s\n",
10981 bgp
->update_delay_end_time
);
10983 " zebra update resumed: %s\n",
10984 bgp
->update_delay_zebra_resume_time
);
10986 " peers update resumed: %s\n",
10987 bgp
->update_delay_peers_resume_time
);
10994 if (bgp_maxmed_onstartup_configured(bgp
)
10995 && bgp
->maxmed_active
)
10996 json_object_boolean_true_add(
10997 json
, "maxMedOnStartup");
10998 if (bgp
->v_maxmed_admin
)
10999 json_object_boolean_true_add(
11000 json
, "maxMedAdministrative");
11002 json_object_int_add(
11003 json
, "tableVersion",
11004 bgp_table_version(bgp
->rib
[afi
][safi
]));
11006 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11007 json_object_int_add(json
, "ribCount", ents
);
11008 json_object_int_add(
11010 ents
* sizeof(struct bgp_dest
));
11012 ents
= bgp
->af_peer_count
[afi
][safi
];
11013 json_object_int_add(json
, "peerCount", ents
);
11014 json_object_int_add(json
, "peerMemory",
11015 ents
* sizeof(struct peer
));
11017 if ((ents
= listcount(bgp
->group
))) {
11018 json_object_int_add(
11019 json
, "peerGroupCount", ents
);
11020 json_object_int_add(
11021 json
, "peerGroupMemory",
11022 ents
* sizeof(struct
11026 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11027 BGP_CONFIG_DAMPENING
))
11028 json_object_boolean_true_add(
11029 json
, "dampeningEnabled");
11032 if (bgp_maxmed_onstartup_configured(bgp
)
11033 && bgp
->maxmed_active
)
11035 "Max-med on-startup active\n");
11036 if (bgp
->v_maxmed_admin
)
11038 "Max-med administrative active\n");
11041 "BGP table version %" PRIu64
11044 bgp
->rib
[afi
][safi
]));
11046 ents
= bgp_table_count(
11047 bgp
->rib
[afi
][safi
]);
11049 "RIB entries %ld, using %s of memory\n",
11059 /* Peer related usage */
11060 ents
= bgp
->af_peer_count
[afi
][safi
];
11062 "Peers %ld, using %s of memory\n",
11072 if ((ents
= listcount(bgp
->group
)))
11074 "Peer groups %ld, using %s of memory\n",
11084 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11085 BGP_CONFIG_DAMPENING
))
11087 "Dampening enabled.\n");
11090 vty_out(vty
, "\n");
11092 /* Subtract 8 here because 'Neighbor' is
11094 vty_out(vty
, "Neighbor");
11095 vty_out(vty
, "%*s",
11096 max_neighbor_width
- 8, " ");
11098 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11103 paf
= peer_af_find(peer
, afi
, safi
);
11104 filter
= &peer
->filter
[afi
][safi
];
11107 /* Works for both failed & successful cases */
11108 if (peer_dynamic_neighbor(peer
))
11113 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11119 bgp_has_peer_failed(peer
, afi
, safi
)) {
11120 json_peer
= json_object_new_object();
11121 bgp_show_failed_summary(vty
, bgp
, peer
,
11122 json_peer
, 0, use_json
);
11123 } else if (!show_failed
) {
11124 if (show_established
11125 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11130 json_peer
= json_object_new_object();
11131 if (peer_dynamic_neighbor(peer
)) {
11132 json_object_boolean_true_add(json_peer
,
11136 if (peer
->hostname
)
11137 json_object_string_add(json_peer
, "hostname",
11140 if (peer
->domainname
)
11141 json_object_string_add(json_peer
, "domainname",
11144 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11145 json_object_int_add(
11146 json_peer
, "localAs",
11147 peer
->change_local_as
11148 ? peer
->change_local_as
11150 json_object_int_add(json_peer
, "version", 4);
11151 json_object_int_add(json_peer
, "msgRcvd",
11152 PEER_TOTAL_RX(peer
));
11153 json_object_int_add(json_peer
, "msgSent",
11154 PEER_TOTAL_TX(peer
));
11156 atomic_size_t outq_count
, inq_count
;
11157 outq_count
= atomic_load_explicit(
11158 &peer
->obuf
->count
,
11159 memory_order_relaxed
);
11160 inq_count
= atomic_load_explicit(
11161 &peer
->ibuf
->count
,
11162 memory_order_relaxed
);
11164 json_object_int_add(json_peer
, "tableVersion",
11165 peer
->version
[afi
][safi
]);
11166 json_object_int_add(json_peer
, "outq",
11168 json_object_int_add(json_peer
, "inq",
11170 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11171 use_json
, json_peer
);
11173 json_object_int_add(json_peer
, "pfxRcd",
11174 peer
->pcount
[afi
][pfx_rcd_safi
]);
11176 if (paf
&& PAF_SUBGRP(paf
))
11177 json_object_int_add(
11178 json_peer
, "pfxSnt",
11179 (PAF_SUBGRP(paf
))->scount
);
11181 json_object_int_add(json_peer
, "pfxSnt",
11184 /* BGP FSM state */
11185 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11186 || CHECK_FLAG(peer
->bgp
->flags
,
11187 BGP_FLAG_SHUTDOWN
))
11188 json_object_string_add(json_peer
,
11191 else if (peer
->afc_recv
[afi
][safi
])
11192 json_object_string_add(
11193 json_peer
, "state",
11194 lookup_msg(bgp_status_msg
,
11195 peer
->status
, NULL
));
11196 else if (CHECK_FLAG(
11198 PEER_STATUS_PREFIX_OVERFLOW
))
11199 json_object_string_add(json_peer
,
11203 json_object_string_add(
11204 json_peer
, "state",
11205 lookup_msg(bgp_status_msg
,
11206 peer
->status
, NULL
));
11208 /* BGP peer state */
11209 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11210 || CHECK_FLAG(peer
->bgp
->flags
,
11211 BGP_FLAG_SHUTDOWN
))
11212 json_object_string_add(json_peer
,
11215 else if (CHECK_FLAG(
11217 PEER_STATUS_PREFIX_OVERFLOW
))
11218 json_object_string_add(json_peer
,
11221 else if (CHECK_FLAG(peer
->flags
,
11222 PEER_FLAG_PASSIVE
))
11223 json_object_string_add(json_peer
,
11226 else if (CHECK_FLAG(peer
->sflags
,
11227 PEER_STATUS_NSF_WAIT
))
11228 json_object_string_add(json_peer
,
11231 else if (CHECK_FLAG(
11233 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11234 && (!bgp_inbound_policy_exists(peer
,
11236 || !bgp_outbound_policy_exists(
11238 json_object_string_add(json_peer
,
11242 json_object_string_add(
11243 json_peer
, "peerState", "OK");
11245 json_object_int_add(json_peer
, "connectionsEstablished",
11246 peer
->established
);
11247 json_object_int_add(json_peer
, "connectionsDropped",
11250 json_object_string_add(
11251 json_peer
, "desc", peer
->desc
);
11253 /* Avoid creating empty peer dicts in JSON */
11254 if (json_peer
== NULL
)
11258 json_object_string_add(json_peer
, "idType",
11260 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11261 json_object_string_add(json_peer
, "idType",
11263 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11264 json_object_string_add(json_peer
, "idType",
11266 json_object_object_add(json_peers
, peer
->host
,
11269 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11275 bgp_has_peer_failed(peer
, afi
, safi
)) {
11276 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11277 max_neighbor_width
,
11279 } else if (!show_failed
) {
11280 if (show_established
11281 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11286 if ((count
- filtered_count
) == 1) {
11287 /* display headline before the first
11289 vty_out(vty
, "\n");
11291 /* Subtract 8 here because 'Neighbor' is
11293 vty_out(vty
, "Neighbor");
11294 vty_out(vty
, "%*s",
11295 max_neighbor_width
- 8, " ");
11298 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11299 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11302 memset(dn_flag
, '\0', sizeof(dn_flag
));
11303 if (peer_dynamic_neighbor(peer
)) {
11308 && CHECK_FLAG(bgp
->flags
,
11309 BGP_FLAG_SHOW_HOSTNAME
))
11310 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11314 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11316 /* pad the neighbor column with spaces */
11317 if (len
< max_neighbor_width
)
11318 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11321 atomic_size_t outq_count
, inq_count
;
11322 outq_count
= atomic_load_explicit(
11323 &peer
->obuf
->count
,
11324 memory_order_relaxed
);
11325 inq_count
= atomic_load_explicit(
11326 &peer
->ibuf
->count
,
11327 memory_order_relaxed
);
11331 "4 %10u %10u %9u %9u %8" PRIu64
11334 peer
->change_local_as
11335 ? peer
->change_local_as
11337 PEER_TOTAL_RX(peer
),
11338 PEER_TOTAL_TX(peer
),
11339 peer
->version
[afi
][safi
],
11340 inq_count
, outq_count
,
11341 peer_uptime(peer
->uptime
,
11346 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11348 peer
->as
, PEER_TOTAL_RX(peer
),
11349 PEER_TOTAL_TX(peer
),
11350 peer
->version
[afi
][safi
],
11351 inq_count
, outq_count
,
11352 peer_uptime(peer
->uptime
,
11357 if (peer_established(peer
)) {
11358 if (peer
->afc_recv
[afi
][safi
]) {
11361 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11362 && !bgp_inbound_policy_exists(
11364 vty_out(vty
, " %12s",
11373 vty_out(vty
, " NoNeg");
11376 if (paf
&& PAF_SUBGRP(paf
)) {
11379 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11380 && !bgp_outbound_policy_exists(
11382 vty_out(vty
, " %8s",
11391 vty_out(vty
, " NoNeg");
11394 if (CHECK_FLAG(peer
->flags
,
11395 PEER_FLAG_SHUTDOWN
)
11396 || CHECK_FLAG(peer
->bgp
->flags
,
11397 BGP_FLAG_SHUTDOWN
))
11398 vty_out(vty
, " Idle (Admin)");
11399 else if (CHECK_FLAG(
11401 PEER_STATUS_PREFIX_OVERFLOW
))
11402 vty_out(vty
, " Idle (PfxCt)");
11404 vty_out(vty
, " %12s",
11405 lookup_msg(bgp_status_msg
,
11406 peer
->status
, NULL
));
11408 vty_out(vty
, " %8u", 0);
11410 /* Make sure `Desc` column is the lastest in
11414 vty_out(vty
, " %s",
11415 bgp_peer_description_stripped(
11417 show_wide
? 64 : 20));
11419 vty_out(vty
, " N/A");
11420 vty_out(vty
, "\n");
11427 json_object_object_add(json
, "peers", json_peers
);
11428 json_object_int_add(json
, "failedPeers", failed_count
);
11429 json_object_int_add(json
, "displayedPeers",
11430 count
- filtered_count
);
11431 json_object_int_add(json
, "totalPeers", count
);
11432 json_object_int_add(json
, "dynamicPeers", dn_count
);
11435 bgp_show_bestpath_json(bgp
, json
);
11437 vty_json(vty
, json
);
11440 if (filtered_count
== count
)
11441 vty_out(vty
, "\n%% No matching neighbor\n");
11444 vty_out(vty
, "\nDisplayed neighbors %d",
11446 else if (as_type
!= AS_UNSPECIFIED
|| as
11447 || fpeer
|| show_established
)
11448 vty_out(vty
, "\nDisplayed neighbors %d",
11449 count
- filtered_count
);
11451 vty_out(vty
, "\nTotal number of neighbors %d\n",
11455 vty_out(vty
, "No %s neighbor is configured\n",
11456 get_afi_safi_str(afi
, safi
, false));
11460 vty_out(vty
, "* - dynamic neighbor\n");
11461 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11462 dn_count
, bgp
->dynamic_neighbors_limit
);
11466 return CMD_SUCCESS
;
11469 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11470 int safi
, struct peer
*fpeer
, int as_type
,
11471 as_t as
, uint16_t show_flags
)
11474 int afi_wildcard
= (afi
== AFI_MAX
);
11475 int safi_wildcard
= (safi
== SAFI_MAX
);
11476 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11477 bool nbr_output
= false;
11478 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11480 if (use_json
&& is_wildcard
)
11481 vty_out(vty
, "{\n");
11483 afi
= 1; /* AFI_IP */
11484 while (afi
< AFI_MAX
) {
11486 safi
= 1; /* SAFI_UNICAST */
11487 while (safi
< SAFI_MAX
) {
11488 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11493 * So limit output to those afi/safi
11495 * actualy have something interesting in
11500 vty_out(vty
, ",\n");
11504 vty_out(vty
, "\"%s\":",
11505 get_afi_safi_str(afi
,
11510 "\n%s Summary (%s):\n",
11511 get_afi_safi_str(afi
,
11517 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11518 as_type
, as
, show_flags
);
11521 if (!safi_wildcard
)
11529 if (use_json
&& is_wildcard
)
11530 vty_out(vty
, "}\n");
11531 else if (!nbr_output
) {
11533 vty_out(vty
, "{}\n");
11535 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11540 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11542 const char *neighbor
,
11543 int as_type
, as_t as
,
11544 uint16_t show_flags
)
11546 struct listnode
*node
, *nnode
;
11548 struct peer
*fpeer
= NULL
;
11550 bool nbr_output
= false;
11551 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11554 vty_out(vty
, "{\n");
11556 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11560 vty_out(vty
, ",\n");
11564 vty_out(vty
, "\"%s\":",
11565 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11570 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11575 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11580 vty_out(vty
, "}\n");
11581 else if (!nbr_output
)
11582 vty_out(vty
, "%% BGP instance not found\n");
11585 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11586 safi_t safi
, const char *neighbor
, int as_type
,
11587 as_t as
, uint16_t show_flags
)
11590 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11591 struct peer
*fpeer
= NULL
;
11594 if (strmatch(name
, "all")) {
11595 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11598 return CMD_SUCCESS
;
11600 bgp
= bgp_lookup_by_name(name
);
11604 vty_out(vty
, "{}\n");
11607 "%% BGP instance not found\n");
11608 return CMD_WARNING
;
11612 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11615 return CMD_WARNING
;
11617 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11618 as_type
, as
, show_flags
);
11619 return CMD_SUCCESS
;
11623 bgp
= bgp_get_default();
11627 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11630 return CMD_WARNING
;
11632 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11636 vty_out(vty
, "{}\n");
11638 vty_out(vty
, "%% BGP instance not found\n");
11639 return CMD_WARNING
;
11642 return CMD_SUCCESS
;
11645 /* `show [ip] bgp summary' commands. */
11646 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11647 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11648 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11649 "]] [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]",
11650 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11651 BGP_SAFI_WITH_LABEL_HELP_STR
11652 "Display the entries for all address families\n"
11653 "Summary of BGP neighbor status\n"
11654 "Show only sessions in Established state\n"
11655 "Show only sessions not in Established state\n"
11656 "Show only the specified neighbor session\n"
11657 "Neighbor to display information about\n"
11658 "Neighbor to display information about\n"
11659 "Neighbor on BGP configured interface\n"
11660 "Show only the specified remote AS sessions\n"
11662 "Internal (iBGP) AS sessions\n"
11663 "External (eBGP) AS sessions\n"
11664 "Shorten the information on BGP instances\n"
11665 "Increase table width for longer output\n" JSON_STR
)
11668 afi_t afi
= AFI_MAX
;
11669 safi_t safi
= SAFI_MAX
;
11670 as_t as
= 0; /* 0 means AS filter not set */
11671 int as_type
= AS_UNSPECIFIED
;
11672 uint16_t show_flags
= 0;
11676 /* show [ip] bgp */
11677 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11679 /* [<vrf> VIEWVRFNAME] */
11680 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11681 vrf
= argv
[idx
+ 1]->arg
;
11682 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11684 } else if (argv_find(argv
, argc
, "view", &idx
))
11685 /* [<view> VIEWVRFNAME] */
11686 vrf
= argv
[idx
+ 1]->arg
;
11687 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11688 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11689 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11692 if (argv_find(argv
, argc
, "failed", &idx
))
11693 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11695 if (argv_find(argv
, argc
, "established", &idx
))
11696 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11698 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11699 if (argv
[idx
+ 1]->arg
[0] == 'i')
11700 as_type
= AS_INTERNAL
;
11701 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11702 as_type
= AS_EXTERNAL
;
11704 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11707 if (argv_find(argv
, argc
, "terse", &idx
))
11708 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11710 if (argv_find(argv
, argc
, "wide", &idx
))
11711 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11713 if (argv_find(argv
, argc
, "json", &idx
))
11714 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11716 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11720 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11723 return get_afi_safi_json_str(afi
, safi
);
11725 return get_afi_safi_vty_str(afi
, safi
);
11729 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11730 afi_t afi
, safi_t safi
,
11731 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11732 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11733 bool use_json
, json_object
*json_pref
)
11736 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11737 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11739 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11740 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11741 json_object_string_add(json_pref
, "sendMode",
11742 "advertisedAndReceived");
11743 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11744 json_object_string_add(json_pref
, "sendMode",
11746 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11747 json_object_string_add(json_pref
, "sendMode",
11750 vty_out(vty
, " Send-mode: ");
11751 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11752 vty_out(vty
, "advertised");
11753 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11754 vty_out(vty
, "%sreceived",
11755 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11759 vty_out(vty
, "\n");
11764 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11765 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11767 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11768 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11769 json_object_string_add(json_pref
, "recvMode",
11770 "advertisedAndReceived");
11771 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11772 json_object_string_add(json_pref
, "recvMode",
11774 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11775 json_object_string_add(json_pref
, "recvMode",
11778 vty_out(vty
, " Receive-mode: ");
11779 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11780 vty_out(vty
, "advertised");
11781 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11782 vty_out(vty
, "%sreceived",
11783 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11787 vty_out(vty
, "\n");
11792 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11800 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11801 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11802 && (peer_established(p
))) {
11803 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11804 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11808 json_object_boolean_add(json
, "rBit", rbit
);
11809 json_object_boolean_add(json
, "nBit", nbit
);
11811 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11812 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11816 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11821 const char *mode
= "NotApplicable";
11824 vty_out(vty
, "\n Remote GR Mode: ");
11826 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11827 && (peer_established(peer
))) {
11829 if ((peer
->nsf_af_count
== 0)
11830 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11834 } else if (peer
->nsf_af_count
== 0
11835 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11839 } else if (peer
->nsf_af_count
!= 0
11840 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11847 json_object_string_add(json
, "remoteGrMode", mode
);
11849 vty_out(vty
, mode
, "\n");
11852 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11857 const char *mode
= "Invalid";
11860 vty_out(vty
, " Local GR Mode: ");
11862 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11864 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11866 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11868 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11869 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11871 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11873 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11880 json_object_string_add(json
, "localGrMode", mode
);
11882 vty_out(vty
, mode
, "\n");
11886 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11887 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11891 json_object
*json_afi_safi
= NULL
;
11892 json_object
*json_timer
= NULL
;
11893 json_object
*json_endofrib_status
= NULL
;
11894 bool eor_flag
= false;
11896 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11897 if (!peer
->afc
[afi
][safi
])
11900 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11901 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11905 json_afi_safi
= json_object_new_object();
11906 json_endofrib_status
= json_object_new_object();
11907 json_timer
= json_object_new_object();
11910 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11916 vty_out(vty
, " %s:\n",
11917 get_afi_safi_str(afi
, safi
, false));
11919 vty_out(vty
, " F bit: ");
11922 if (peer
->nsf
[afi
][safi
] &&
11923 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11924 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11927 json_object_boolean_true_add(json_afi_safi
,
11930 vty_out(vty
, "True\n");
11933 json_object_boolean_false_add(json_afi_safi
,
11936 vty_out(vty
, "False\n");
11940 vty_out(vty
, " End-of-RIB sent: ");
11942 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11943 PEER_STATUS_EOR_SEND
)) {
11945 json_object_boolean_true_add(
11946 json_endofrib_status
, "endOfRibSend");
11948 PRINT_EOR_JSON(eor_flag
);
11950 vty_out(vty
, "Yes\n");
11952 " End-of-RIB sent after update: ");
11954 PRINT_EOR(eor_flag
);
11958 json_object_boolean_false_add(
11959 json_endofrib_status
, "endOfRibSend");
11960 json_object_boolean_false_add(
11961 json_endofrib_status
,
11962 "endOfRibSentAfterUpdate");
11964 vty_out(vty
, "No\n");
11966 " End-of-RIB sent after update: ");
11967 vty_out(vty
, "No\n");
11972 vty_out(vty
, " End-of-RIB received: ");
11974 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11975 PEER_STATUS_EOR_RECEIVED
)) {
11977 json_object_boolean_true_add(
11978 json_endofrib_status
, "endOfRibRecv");
11980 vty_out(vty
, "Yes\n");
11983 json_object_boolean_false_add(
11984 json_endofrib_status
, "endOfRibRecv");
11986 vty_out(vty
, "No\n");
11990 json_object_int_add(json_timer
, "stalePathTimer",
11991 peer
->bgp
->stalepath_time
);
11993 if (peer
->t_gr_stale
!= NULL
) {
11994 json_object_int_add(json_timer
,
11995 "stalePathTimerRemaining",
11996 thread_timer_remain_second(
11997 peer
->t_gr_stale
));
12000 /* Display Configured Selection
12001 * Deferral only when when
12002 * Gr mode is enabled.
12004 if (CHECK_FLAG(peer
->flags
,
12005 PEER_FLAG_GRACEFUL_RESTART
)) {
12006 json_object_int_add(json_timer
,
12007 "selectionDeferralTimer",
12008 peer
->bgp
->stalepath_time
);
12011 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12014 json_object_int_add(
12016 "selectionDeferralTimerRemaining",
12017 thread_timer_remain_second(
12018 peer
->bgp
->gr_info
[afi
][safi
]
12019 .t_select_deferral
));
12022 vty_out(vty
, " Timers:\n");
12024 " Configured Stale Path Time(sec): %u\n",
12025 peer
->bgp
->stalepath_time
);
12027 if (peer
->t_gr_stale
!= NULL
)
12029 " Stale Path Remaining(sec): %ld\n",
12030 thread_timer_remain_second(
12031 peer
->t_gr_stale
));
12032 /* Display Configured Selection
12033 * Deferral only when when
12034 * Gr mode is enabled.
12036 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12038 " Configured Selection Deferral Time(sec): %u\n",
12039 peer
->bgp
->select_defer_time
);
12041 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12044 " Selection Deferral Time Remaining(sec): %ld\n",
12045 thread_timer_remain_second(
12046 peer
->bgp
->gr_info
[afi
][safi
]
12047 .t_select_deferral
));
12050 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12051 json_endofrib_status
);
12052 json_object_object_add(json_afi_safi
, "timers",
12054 json_object_object_add(
12055 json
, get_afi_safi_str(afi
, safi
, true),
12061 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12067 json_object
*json_timer
= NULL
;
12069 json_timer
= json_object_new_object();
12071 json_object_int_add(json_timer
, "configuredRestartTimer",
12072 p
->bgp
->restart_time
);
12074 json_object_int_add(json_timer
, "receivedRestartTimer",
12077 if (p
->t_gr_restart
!= NULL
)
12078 json_object_int_add(
12079 json_timer
, "restartTimerRemaining",
12080 thread_timer_remain_second(p
->t_gr_restart
));
12082 json_object_object_add(json
, "timers", json_timer
);
12085 vty_out(vty
, " Timers:\n");
12086 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12087 p
->bgp
->restart_time
);
12089 vty_out(vty
, " Received Restart Time(sec): %u\n",
12091 if (p
->t_gr_restart
!= NULL
)
12092 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12093 thread_timer_remain_second(p
->t_gr_restart
));
12094 if (p
->t_gr_restart
!= NULL
) {
12095 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12096 thread_timer_remain_second(p
->t_gr_restart
));
12101 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12102 bool use_json
, json_object
*json
)
12104 char dn_flag
[2] = {0};
12105 /* '*' + v6 address of neighbor */
12106 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12108 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12113 json_object_string_addf(json
, "neighborAddr", "%pSU",
12116 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12119 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12123 json_object_string_add(json
, "neighborAddr",
12126 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12129 /* more gr info in new format */
12130 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12133 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12134 safi_t safi
, bool use_json
,
12135 json_object
*json_neigh
)
12137 struct bgp_filter
*filter
;
12138 struct peer_af
*paf
;
12139 char orf_pfx_name
[BUFSIZ
];
12141 json_object
*json_af
= NULL
;
12142 json_object
*json_prefA
= NULL
;
12143 json_object
*json_prefB
= NULL
;
12144 json_object
*json_addr
= NULL
;
12145 json_object
*json_advmap
= NULL
;
12148 json_addr
= json_object_new_object();
12149 json_af
= json_object_new_object();
12150 filter
= &p
->filter
[afi
][safi
];
12152 if (peer_group_active(p
))
12153 json_object_string_add(json_addr
, "peerGroupMember",
12156 paf
= peer_af_find(p
, afi
, safi
);
12157 if (paf
&& PAF_SUBGRP(paf
)) {
12158 json_object_int_add(json_addr
, "updateGroupId",
12159 PAF_UPDGRP(paf
)->id
);
12160 json_object_int_add(json_addr
, "subGroupId",
12161 PAF_SUBGRP(paf
)->id
);
12162 json_object_int_add(json_addr
, "packetQueueLength",
12163 bpacket_queue_virtual_length(paf
));
12166 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12167 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12168 PEER_CAP_ORF_PREFIX_SM_RCV
)
12169 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12170 PEER_CAP_ORF_PREFIX_RM_ADV
)
12171 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12172 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12173 json_object_int_add(json_af
, "orfType",
12175 json_prefA
= json_object_new_object();
12176 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12177 PEER_CAP_ORF_PREFIX_SM_ADV
,
12178 PEER_CAP_ORF_PREFIX_RM_ADV
,
12179 PEER_CAP_ORF_PREFIX_SM_RCV
,
12180 PEER_CAP_ORF_PREFIX_RM_RCV
,
12181 use_json
, json_prefA
);
12182 json_object_object_add(json_af
, "orfPrefixList",
12186 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12187 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12188 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12189 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12190 PEER_CAP_ORF_PREFIX_RM_ADV
)
12191 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12192 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12193 json_object_int_add(json_af
, "orfOldType",
12194 ORF_TYPE_PREFIX_OLD
);
12195 json_prefB
= json_object_new_object();
12196 bgp_show_peer_afi_orf_cap(
12197 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12198 PEER_CAP_ORF_PREFIX_RM_ADV
,
12199 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12200 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12202 json_object_object_add(json_af
, "orfOldPrefixList",
12206 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12207 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12208 PEER_CAP_ORF_PREFIX_SM_RCV
)
12209 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12210 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12211 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12212 PEER_CAP_ORF_PREFIX_RM_ADV
)
12213 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12214 PEER_CAP_ORF_PREFIX_RM_RCV
)
12215 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12216 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12217 json_object_object_add(json_addr
, "afDependentCap",
12220 json_object_free(json_af
);
12222 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12223 p
->host
, afi
, safi
);
12224 orf_pfx_count
= prefix_bgp_show_prefix_list(
12225 NULL
, afi
, orf_pfx_name
, use_json
);
12227 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12228 PEER_STATUS_ORF_PREFIX_SEND
)
12229 || orf_pfx_count
) {
12230 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12231 PEER_STATUS_ORF_PREFIX_SEND
))
12232 json_object_boolean_true_add(json_neigh
,
12235 json_object_int_add(json_addr
, "orfRecvCounter",
12238 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12239 PEER_STATUS_ORF_WAIT_REFRESH
))
12240 json_object_string_add(
12241 json_addr
, "orfFirstUpdate",
12242 "deferredUntilORFOrRouteRefreshRecvd");
12244 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12245 PEER_FLAG_REFLECTOR_CLIENT
))
12246 json_object_boolean_true_add(json_addr
,
12247 "routeReflectorClient");
12248 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12249 PEER_FLAG_RSERVER_CLIENT
))
12250 json_object_boolean_true_add(json_addr
,
12251 "routeServerClient");
12252 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12253 json_object_boolean_true_add(json_addr
,
12254 "inboundSoftConfigPermit");
12256 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12257 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12258 json_object_boolean_true_add(
12260 "privateAsNumsAllReplacedInUpdatesToNbr");
12261 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12262 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12263 json_object_boolean_true_add(
12265 "privateAsNumsReplacedInUpdatesToNbr");
12266 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12267 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12268 json_object_boolean_true_add(
12270 "privateAsNumsAllRemovedInUpdatesToNbr");
12271 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12272 PEER_FLAG_REMOVE_PRIVATE_AS
))
12273 json_object_boolean_true_add(
12275 "privateAsNumsRemovedInUpdatesToNbr");
12277 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12279 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12280 json_object_boolean_true_add(json_addr
,
12281 "allowAsInOrigin");
12283 json_object_int_add(json_addr
, "allowAsInCount",
12284 p
->allowas_in
[afi
][safi
]);
12287 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12288 json_object_boolean_true_add(
12290 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12293 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12294 json_object_string_add(json_addr
,
12295 "overrideASNsInOutboundUpdates",
12296 "ifAspathEqualRemoteAs");
12298 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12299 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12300 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12301 json_object_boolean_true_add(json_addr
,
12302 "routerAlwaysNextHop");
12303 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12304 PEER_FLAG_AS_PATH_UNCHANGED
))
12305 json_object_boolean_true_add(
12306 json_addr
, "unchangedAsPathPropogatedToNbr");
12307 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12308 PEER_FLAG_NEXTHOP_UNCHANGED
))
12309 json_object_boolean_true_add(
12310 json_addr
, "unchangedNextHopPropogatedToNbr");
12311 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12312 json_object_boolean_true_add(
12313 json_addr
, "unchangedMedPropogatedToNbr");
12314 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12315 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12316 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12317 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12318 PEER_FLAG_SEND_COMMUNITY
)
12319 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12320 PEER_FLAG_SEND_EXT_COMMUNITY
))
12321 json_object_string_add(json_addr
,
12322 "commAttriSentToNbr",
12323 "extendedAndStandard");
12324 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12325 PEER_FLAG_SEND_EXT_COMMUNITY
))
12326 json_object_string_add(json_addr
,
12327 "commAttriSentToNbr",
12330 json_object_string_add(json_addr
,
12331 "commAttriSentToNbr",
12334 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12335 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12336 if (p
->default_rmap
[afi
][safi
].name
)
12337 json_object_string_add(
12338 json_addr
, "defaultRouteMap",
12339 p
->default_rmap
[afi
][safi
].name
);
12341 if (paf
&& PAF_SUBGRP(paf
)
12342 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12343 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12344 json_object_boolean_true_add(json_addr
,
12347 json_object_boolean_true_add(json_addr
,
12351 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12352 if (is_evpn_enabled())
12353 json_object_boolean_true_add(
12354 json_addr
, "advertiseAllVnis");
12357 if (filter
->plist
[FILTER_IN
].name
12358 || filter
->dlist
[FILTER_IN
].name
12359 || filter
->aslist
[FILTER_IN
].name
12360 || filter
->map
[RMAP_IN
].name
)
12361 json_object_boolean_true_add(json_addr
,
12362 "inboundPathPolicyConfig");
12363 if (filter
->plist
[FILTER_OUT
].name
12364 || filter
->dlist
[FILTER_OUT
].name
12365 || filter
->aslist
[FILTER_OUT
].name
12366 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12367 json_object_boolean_true_add(
12368 json_addr
, "outboundPathPolicyConfig");
12371 if (filter
->plist
[FILTER_IN
].name
)
12372 json_object_string_add(json_addr
,
12373 "incomingUpdatePrefixFilterList",
12374 filter
->plist
[FILTER_IN
].name
);
12375 if (filter
->plist
[FILTER_OUT
].name
)
12376 json_object_string_add(json_addr
,
12377 "outgoingUpdatePrefixFilterList",
12378 filter
->plist
[FILTER_OUT
].name
);
12380 /* distribute-list */
12381 if (filter
->dlist
[FILTER_IN
].name
)
12382 json_object_string_add(
12383 json_addr
, "incomingUpdateNetworkFilterList",
12384 filter
->dlist
[FILTER_IN
].name
);
12385 if (filter
->dlist
[FILTER_OUT
].name
)
12386 json_object_string_add(
12387 json_addr
, "outgoingUpdateNetworkFilterList",
12388 filter
->dlist
[FILTER_OUT
].name
);
12391 if (filter
->aslist
[FILTER_IN
].name
)
12392 json_object_string_add(json_addr
,
12393 "incomingUpdateAsPathFilterList",
12394 filter
->aslist
[FILTER_IN
].name
);
12395 if (filter
->aslist
[FILTER_OUT
].name
)
12396 json_object_string_add(json_addr
,
12397 "outgoingUpdateAsPathFilterList",
12398 filter
->aslist
[FILTER_OUT
].name
);
12401 if (filter
->map
[RMAP_IN
].name
)
12402 json_object_string_add(
12403 json_addr
, "routeMapForIncomingAdvertisements",
12404 filter
->map
[RMAP_IN
].name
);
12405 if (filter
->map
[RMAP_OUT
].name
)
12406 json_object_string_add(
12407 json_addr
, "routeMapForOutgoingAdvertisements",
12408 filter
->map
[RMAP_OUT
].name
);
12410 /* ebgp-requires-policy (inbound) */
12411 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12412 && !bgp_inbound_policy_exists(p
, filter
))
12413 json_object_string_add(
12414 json_addr
, "inboundEbgpRequiresPolicy",
12415 "Inbound updates discarded due to missing policy");
12417 /* ebgp-requires-policy (outbound) */
12418 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12419 && (!bgp_outbound_policy_exists(p
, filter
)))
12420 json_object_string_add(
12421 json_addr
, "outboundEbgpRequiresPolicy",
12422 "Outbound updates discarded due to missing policy");
12424 /* unsuppress-map */
12425 if (filter
->usmap
.name
)
12426 json_object_string_add(json_addr
,
12427 "selectiveUnsuppressRouteMap",
12428 filter
->usmap
.name
);
12430 /* advertise-map */
12431 if (filter
->advmap
.aname
) {
12432 json_advmap
= json_object_new_object();
12433 json_object_string_add(json_advmap
, "condition",
12434 filter
->advmap
.condition
12437 json_object_string_add(json_advmap
, "conditionMap",
12438 filter
->advmap
.cname
);
12439 json_object_string_add(json_advmap
, "advertiseMap",
12440 filter
->advmap
.aname
);
12441 json_object_string_add(
12442 json_advmap
, "advertiseStatus",
12443 filter
->advmap
.update_type
==
12444 UPDATE_TYPE_ADVERTISE
12447 json_object_object_add(json_addr
, "advertiseMap",
12451 /* Receive prefix count */
12452 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12453 p
->pcount
[afi
][safi
]);
12454 if (paf
&& PAF_SUBGRP(paf
))
12455 json_object_int_add(json_addr
, "sentPrefixCounter",
12456 (PAF_SUBGRP(paf
))->scount
);
12458 /* Maximum prefix */
12459 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12460 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12461 p
->pmax_out
[afi
][safi
]);
12463 /* Maximum prefix */
12464 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12465 json_object_int_add(json_addr
, "prefixAllowedMax",
12466 p
->pmax
[afi
][safi
]);
12467 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12468 PEER_FLAG_MAX_PREFIX_WARNING
))
12469 json_object_boolean_true_add(
12470 json_addr
, "prefixAllowedMaxWarning");
12471 json_object_int_add(json_addr
,
12472 "prefixAllowedWarningThresh",
12473 p
->pmax_threshold
[afi
][safi
]);
12474 if (p
->pmax_restart
[afi
][safi
])
12475 json_object_int_add(
12477 "prefixAllowedRestartIntervalMsecs",
12478 p
->pmax_restart
[afi
][safi
] * 60000);
12480 json_object_object_add(json_neigh
,
12481 get_afi_safi_str(afi
, safi
, true),
12485 filter
= &p
->filter
[afi
][safi
];
12487 vty_out(vty
, " For address family: %s\n",
12488 get_afi_safi_str(afi
, safi
, false));
12490 if (peer_group_active(p
))
12491 vty_out(vty
, " %s peer-group member\n",
12494 paf
= peer_af_find(p
, afi
, safi
);
12495 if (paf
&& PAF_SUBGRP(paf
)) {
12496 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12497 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12498 vty_out(vty
, " Packet Queue length %d\n",
12499 bpacket_queue_virtual_length(paf
));
12501 vty_out(vty
, " Not part of any update group\n");
12503 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12504 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12505 PEER_CAP_ORF_PREFIX_SM_RCV
)
12506 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12507 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12508 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12509 PEER_CAP_ORF_PREFIX_RM_ADV
)
12510 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12511 PEER_CAP_ORF_PREFIX_RM_RCV
)
12512 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12513 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12514 vty_out(vty
, " AF-dependant capabilities:\n");
12516 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12517 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12518 PEER_CAP_ORF_PREFIX_SM_RCV
)
12519 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12520 PEER_CAP_ORF_PREFIX_RM_ADV
)
12521 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12522 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12524 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12526 bgp_show_peer_afi_orf_cap(
12527 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12528 PEER_CAP_ORF_PREFIX_RM_ADV
,
12529 PEER_CAP_ORF_PREFIX_SM_RCV
,
12530 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12532 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12533 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12534 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12535 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12536 PEER_CAP_ORF_PREFIX_RM_ADV
)
12537 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12538 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12540 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12541 ORF_TYPE_PREFIX_OLD
);
12542 bgp_show_peer_afi_orf_cap(
12543 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12544 PEER_CAP_ORF_PREFIX_RM_ADV
,
12545 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12546 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12549 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12550 p
->host
, afi
, safi
);
12551 orf_pfx_count
= prefix_bgp_show_prefix_list(
12552 NULL
, afi
, orf_pfx_name
, use_json
);
12554 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12555 PEER_STATUS_ORF_PREFIX_SEND
)
12556 || orf_pfx_count
) {
12557 vty_out(vty
, " Outbound Route Filter (ORF):");
12558 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12559 PEER_STATUS_ORF_PREFIX_SEND
))
12560 vty_out(vty
, " sent;");
12562 vty_out(vty
, " received (%d entries)",
12564 vty_out(vty
, "\n");
12566 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12567 PEER_STATUS_ORF_WAIT_REFRESH
))
12569 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12571 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12572 PEER_FLAG_REFLECTOR_CLIENT
))
12573 vty_out(vty
, " Route-Reflector Client\n");
12574 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12575 PEER_FLAG_RSERVER_CLIENT
))
12576 vty_out(vty
, " Route-Server Client\n");
12578 if (peer_af_flag_check(p
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
12579 vty_out(vty
, " ORR group (configured) : %s\n",
12580 p
->orr_group_name
[afi
][safi
]);
12582 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12584 " Inbound soft reconfiguration allowed\n");
12586 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12587 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12589 " Private AS numbers (all) replaced in updates to this neighbor\n");
12590 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12591 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12593 " Private AS numbers replaced in updates to this neighbor\n");
12594 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12595 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12597 " Private AS numbers (all) removed in updates to this neighbor\n");
12598 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12599 PEER_FLAG_REMOVE_PRIVATE_AS
))
12601 " Private AS numbers removed in updates to this neighbor\n");
12603 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12604 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12605 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12607 " Local AS allowed as path origin\n");
12610 " Local AS allowed in path, %d occurrences\n",
12611 p
->allowas_in
[afi
][safi
]);
12614 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12615 vty_out(vty
, " %s\n",
12616 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12617 ->human_description
);
12619 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12621 " Override ASNs in outbound updates if aspath equals remote-as\n");
12623 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12624 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12625 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12626 vty_out(vty
, " NEXT_HOP is always this router\n");
12627 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12628 PEER_FLAG_AS_PATH_UNCHANGED
))
12630 " AS_PATH is propagated unchanged to this neighbor\n");
12631 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12632 PEER_FLAG_NEXTHOP_UNCHANGED
))
12634 " NEXT_HOP is propagated unchanged to this neighbor\n");
12635 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12637 " MED is propagated unchanged to this neighbor\n");
12638 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12639 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12640 PEER_FLAG_SEND_EXT_COMMUNITY
)
12641 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12642 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12644 " Community attribute sent to this neighbor");
12645 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12646 PEER_FLAG_SEND_COMMUNITY
)
12647 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12648 PEER_FLAG_SEND_EXT_COMMUNITY
)
12649 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12650 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12651 vty_out(vty
, "(all)\n");
12652 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12653 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12654 vty_out(vty
, "(large)\n");
12655 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12656 PEER_FLAG_SEND_EXT_COMMUNITY
))
12657 vty_out(vty
, "(extended)\n");
12659 vty_out(vty
, "(standard)\n");
12661 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12662 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12663 vty_out(vty
, " Default information originate,");
12665 if (p
->default_rmap
[afi
][safi
].name
)
12666 vty_out(vty
, " default route-map %s%s,",
12667 p
->default_rmap
[afi
][safi
].map
? "*"
12669 p
->default_rmap
[afi
][safi
].name
);
12670 if (paf
&& PAF_SUBGRP(paf
)
12671 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12672 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12673 vty_out(vty
, " default sent\n");
12675 vty_out(vty
, " default not sent\n");
12678 /* advertise-vni-all */
12679 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12680 if (is_evpn_enabled())
12681 vty_out(vty
, " advertise-all-vni\n");
12684 if (filter
->plist
[FILTER_IN
].name
12685 || filter
->dlist
[FILTER_IN
].name
12686 || filter
->aslist
[FILTER_IN
].name
12687 || filter
->map
[RMAP_IN
].name
)
12688 vty_out(vty
, " Inbound path policy configured\n");
12689 if (filter
->plist
[FILTER_OUT
].name
12690 || filter
->dlist
[FILTER_OUT
].name
12691 || filter
->aslist
[FILTER_OUT
].name
12692 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12693 vty_out(vty
, " Outbound path policy configured\n");
12696 if (filter
->plist
[FILTER_IN
].name
)
12698 " Incoming update prefix filter list is %s%s\n",
12699 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12700 filter
->plist
[FILTER_IN
].name
);
12701 if (filter
->plist
[FILTER_OUT
].name
)
12703 " Outgoing update prefix filter list is %s%s\n",
12704 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12705 filter
->plist
[FILTER_OUT
].name
);
12707 /* distribute-list */
12708 if (filter
->dlist
[FILTER_IN
].name
)
12710 " Incoming update network filter list is %s%s\n",
12711 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12712 filter
->dlist
[FILTER_IN
].name
);
12713 if (filter
->dlist
[FILTER_OUT
].name
)
12715 " Outgoing update network filter list is %s%s\n",
12716 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12717 filter
->dlist
[FILTER_OUT
].name
);
12720 if (filter
->aslist
[FILTER_IN
].name
)
12722 " Incoming update AS path filter list is %s%s\n",
12723 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12724 filter
->aslist
[FILTER_IN
].name
);
12725 if (filter
->aslist
[FILTER_OUT
].name
)
12727 " Outgoing update AS path filter list is %s%s\n",
12728 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12729 filter
->aslist
[FILTER_OUT
].name
);
12732 if (filter
->map
[RMAP_IN
].name
)
12734 " Route map for incoming advertisements is %s%s\n",
12735 filter
->map
[RMAP_IN
].map
? "*" : "",
12736 filter
->map
[RMAP_IN
].name
);
12737 if (filter
->map
[RMAP_OUT
].name
)
12739 " Route map for outgoing advertisements is %s%s\n",
12740 filter
->map
[RMAP_OUT
].map
? "*" : "",
12741 filter
->map
[RMAP_OUT
].name
);
12743 /* ebgp-requires-policy (inbound) */
12744 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12745 && !bgp_inbound_policy_exists(p
, filter
))
12747 " Inbound updates discarded due to missing policy\n");
12749 /* ebgp-requires-policy (outbound) */
12750 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12751 && !bgp_outbound_policy_exists(p
, filter
))
12753 " Outbound updates discarded due to missing policy\n");
12755 /* unsuppress-map */
12756 if (filter
->usmap
.name
)
12758 " Route map for selective unsuppress is %s%s\n",
12759 filter
->usmap
.map
? "*" : "",
12760 filter
->usmap
.name
);
12762 /* advertise-map */
12763 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12765 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12766 filter
->advmap
.condition
? "EXIST"
12768 filter
->advmap
.cmap
? "*" : "",
12769 filter
->advmap
.cname
,
12770 filter
->advmap
.amap
? "*" : "",
12771 filter
->advmap
.aname
,
12772 filter
->advmap
.update_type
==
12773 UPDATE_TYPE_ADVERTISE
12777 /* Receive prefix count */
12778 vty_out(vty
, " %u accepted prefixes\n",
12779 p
->pcount
[afi
][safi
]);
12781 /* maximum-prefix-out */
12782 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12783 PEER_FLAG_MAX_PREFIX_OUT
))
12785 " Maximum allowed prefixes sent %u\n",
12786 p
->pmax_out
[afi
][safi
]);
12788 /* Maximum prefix */
12789 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12791 " Maximum prefixes allowed %u%s\n",
12792 p
->pmax
[afi
][safi
],
12793 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12794 PEER_FLAG_MAX_PREFIX_WARNING
)
12795 ? " (warning-only)"
12797 vty_out(vty
, " Threshold for warning message %d%%",
12798 p
->pmax_threshold
[afi
][safi
]);
12799 if (p
->pmax_restart
[afi
][safi
])
12800 vty_out(vty
, ", restart interval %d min",
12801 p
->pmax_restart
[afi
][safi
]);
12802 vty_out(vty
, "\n");
12805 vty_out(vty
, "\n");
12809 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12813 char buf1
[PREFIX2STR_BUFFER
];
12814 char timebuf
[BGP_UPTIME_LEN
];
12820 json_object
*json_neigh
= NULL
;
12822 uint32_t sync_tcp_mss
;
12827 json_neigh
= json_object_new_object();
12829 memset(dn_flag
, '\0', sizeof(dn_flag
));
12830 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12834 if (p
->conf_if
) /* Configured interface name. */
12835 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12837 else /* Configured IP address. */
12838 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12843 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12844 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12846 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12847 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12850 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12852 if (p
->change_local_as
)
12853 json_object_int_add(json_neigh
, "localAs",
12854 p
->change_local_as
);
12856 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12858 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12859 json_object_boolean_true_add(json_neigh
,
12860 "localAsNoPrepend");
12862 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12863 json_object_boolean_true_add(json_neigh
,
12864 "localAsReplaceAs");
12866 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12867 || (p
->as_type
== AS_INTERNAL
))
12868 vty_out(vty
, "remote AS %u, ", p
->as
);
12870 vty_out(vty
, "remote AS Unspecified, ");
12871 vty_out(vty
, "local AS %u%s%s, ",
12872 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12873 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12876 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12880 /* peer type internal or confed-internal */
12881 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12883 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12884 json_object_boolean_true_add(
12885 json_neigh
, "nbrConfedInternalLink");
12887 json_object_boolean_true_add(json_neigh
,
12888 "nbrInternalLink");
12890 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12891 vty_out(vty
, "confed-internal link\n");
12893 vty_out(vty
, "internal link\n");
12895 /* peer type external or confed-external */
12896 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12898 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12899 json_object_boolean_true_add(
12900 json_neigh
, "nbrConfedExternalLink");
12902 json_object_boolean_true_add(json_neigh
,
12903 "nbrExternalLink");
12905 if (bgp_confederation_peers_check(bgp
, p
->as
))
12906 vty_out(vty
, "confed-external link\n");
12908 vty_out(vty
, "external link\n");
12912 json_object_boolean_true_add(json_neigh
,
12913 "nbrUnspecifiedLink");
12915 vty_out(vty
, "unspecified link\n");
12920 json_object_string_add(json_neigh
, "localRole",
12921 bgp_get_name_by_role(p
->local_role
));
12922 json_object_string_add(json_neigh
, "remoteRole",
12923 bgp_get_name_by_role(p
->remote_role
));
12925 vty_out(vty
, " Local Role: %s\n",
12926 bgp_get_name_by_role(p
->local_role
));
12927 vty_out(vty
, " Remote Role: %s\n",
12928 bgp_get_name_by_role(p
->remote_role
));
12935 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12937 vty_out(vty
, " Description: %s\n", p
->desc
);
12943 json_object_string_add(json_neigh
, "hostname",
12947 json_object_string_add(json_neigh
, "domainname",
12950 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12951 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12954 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12961 json_object_string_add(json_neigh
, "peerGroup",
12965 struct prefix prefix
, *range
= NULL
;
12967 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12968 range
= peer_group_lookup_dynamic_neighbor_range(
12969 p
->group
, &prefix
);
12972 json_object_string_addf(
12974 "peerSubnetRangeGroup", "%pFX",
12980 " Member of peer-group %s for session parameters\n",
12984 struct prefix prefix
, *range
= NULL
;
12986 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12987 range
= peer_group_lookup_dynamic_neighbor_range(
12988 p
->group
, &prefix
);
12992 " Belongs to the subnet range group: %pFX\n",
13000 /* Administrative shutdown. */
13001 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13002 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13003 json_object_boolean_true_add(json_neigh
,
13007 json_object_int_add(json_neigh
, "bgpVersion", 4);
13008 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13010 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13013 /* Confederation */
13014 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13015 && bgp_confederation_peers_check(bgp
, p
->as
))
13016 json_object_boolean_true_add(json_neigh
,
13020 json_object_string_add(
13021 json_neigh
, "bgpState",
13022 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13024 if (peer_established(p
)) {
13027 uptime
= monotime(NULL
);
13028 uptime
-= p
->uptime
;
13029 epoch_tbuf
= time(NULL
) - uptime
;
13031 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13033 json_object_string_add(json_neigh
, "bgpTimerUpString",
13034 peer_uptime(p
->uptime
, timebuf
,
13037 json_object_int_add(json_neigh
,
13038 "bgpTimerUpEstablishedEpoch",
13042 else if (p
->status
== Active
) {
13043 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13044 json_object_string_add(json_neigh
, "bgpStateIs",
13046 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13047 json_object_string_add(json_neigh
, "bgpStateIs",
13055 uptime
= monotime(NULL
);
13056 uptime
-= p
->readtime
;
13057 gmtime_r(&uptime
, &tm
);
13059 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13060 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13061 + (tm
.tm_hour
* 3600000));
13063 uptime
= monotime(NULL
);
13064 uptime
-= p
->last_write
;
13065 gmtime_r(&uptime
, &tm
);
13067 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13068 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13069 + (tm
.tm_hour
* 3600000));
13071 uptime
= monotime(NULL
);
13072 uptime
-= p
->update_time
;
13073 gmtime_r(&uptime
, &tm
);
13075 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13076 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13077 + (tm
.tm_hour
* 3600000));
13079 /* Configured timer values. */
13080 json_object_int_add(json_neigh
,
13081 "bgpTimerConfiguredHoldTimeMsecs",
13082 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13083 ? p
->holdtime
* 1000
13084 : bgp
->default_holdtime
* 1000);
13085 json_object_int_add(json_neigh
,
13086 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13087 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13088 ? p
->keepalive
* 1000
13089 : bgp
->default_keepalive
* 1000);
13090 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13091 p
->v_holdtime
* 1000);
13092 json_object_int_add(json_neigh
,
13093 "bgpTimerKeepAliveIntervalMsecs",
13094 p
->v_keepalive
* 1000);
13095 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13096 json_object_int_add(json_neigh
,
13097 "bgpTimerDelayOpenTimeMsecs",
13098 p
->v_delayopen
* 1000);
13101 /* Configured and Synced tcp-mss value for peer */
13102 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13103 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13104 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13106 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13110 /* Extended Optional Parameters Length for BGP OPEN Message */
13111 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13112 json_object_boolean_true_add(
13113 json_neigh
, "extendedOptionalParametersLength");
13115 json_object_boolean_false_add(
13116 json_neigh
, "extendedOptionalParametersLength");
13118 /* Conditional advertisements */
13119 json_object_int_add(
13121 "bgpTimerConfiguredConditionalAdvertisementsSec",
13122 bgp
->condition_check_period
);
13123 if (thread_is_scheduled(bgp
->t_condition_check
))
13124 json_object_int_add(
13126 "bgpTimerUntilConditionalAdvertisementsSec",
13127 thread_timer_remain_second(
13128 bgp
->t_condition_check
));
13130 /* Administrative shutdown. */
13131 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13132 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13133 vty_out(vty
, " Administratively shut down\n");
13136 vty_out(vty
, " BGP version 4");
13137 vty_out(vty
, ", remote router ID %s",
13138 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13139 vty_out(vty
, ", local router ID %s\n",
13140 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13143 /* Confederation */
13144 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13145 && bgp_confederation_peers_check(bgp
, p
->as
))
13147 " Neighbor under common administration\n");
13150 vty_out(vty
, " BGP state = %s",
13151 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13153 if (peer_established(p
))
13154 vty_out(vty
, ", up for %8s",
13155 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13158 else if (p
->status
== Active
) {
13159 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13160 vty_out(vty
, " (passive)");
13161 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13162 vty_out(vty
, " (NSF passive)");
13164 vty_out(vty
, "\n");
13167 vty_out(vty
, " Last read %s",
13168 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13170 vty_out(vty
, ", Last write %s\n",
13171 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13174 /* Configured timer values. */
13176 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13177 p
->v_holdtime
, p
->v_keepalive
);
13178 vty_out(vty
, " Configured hold time is %d seconds",
13179 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13181 : bgp
->default_holdtime
);
13182 vty_out(vty
, ", keepalive interval is %d seconds\n",
13183 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13185 : bgp
->default_keepalive
);
13186 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13188 " Configured DelayOpenTime is %d seconds\n",
13191 /* Configured and synced tcp-mss value for peer */
13192 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13193 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13194 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13195 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13198 /* Extended Optional Parameters Length for BGP OPEN Message */
13199 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13201 " Extended Optional Parameters Length is enabled\n");
13203 /* Conditional advertisements */
13205 " Configured conditional advertisements interval is %d seconds\n",
13206 bgp
->condition_check_period
);
13207 if (thread_is_scheduled(bgp
->t_condition_check
))
13209 " Time until conditional advertisements begin is %lu seconds\n",
13210 thread_timer_remain_second(
13211 bgp
->t_condition_check
));
13214 if (peer_established(p
) &&
13215 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13217 json_object
*json_cap
= NULL
;
13219 json_cap
= json_object_new_object();
13222 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13223 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13224 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13225 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13226 json_object_string_add(
13227 json_cap
, "4byteAs",
13228 "advertisedAndReceived");
13229 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13230 json_object_string_add(json_cap
,
13233 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13234 json_object_string_add(json_cap
,
13239 /* Extended Message Support */
13240 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13241 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13242 json_object_string_add(json_cap
,
13244 "advertisedAndReceived");
13245 else if (CHECK_FLAG(p
->cap
,
13246 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13247 json_object_string_add(json_cap
,
13250 else if (CHECK_FLAG(p
->cap
,
13251 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13252 json_object_string_add(json_cap
,
13257 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13258 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13259 json_object
*json_add
= NULL
;
13260 const char *print_store
;
13262 json_add
= json_object_new_object();
13264 FOREACH_AFI_SAFI (afi
, safi
) {
13265 json_object
*json_sub
= NULL
;
13266 json_sub
= json_object_new_object();
13267 print_store
= get_afi_safi_str(
13271 p
->af_cap
[afi
][safi
],
13272 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13274 p
->af_cap
[afi
][safi
],
13275 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13279 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13283 PEER_CAP_ADDPATH_AF_TX_RCV
))
13284 json_object_boolean_true_add(
13286 "txAdvertisedAndReceived");
13291 PEER_CAP_ADDPATH_AF_TX_ADV
))
13292 json_object_boolean_true_add(
13299 PEER_CAP_ADDPATH_AF_TX_RCV
))
13300 json_object_boolean_true_add(
13306 p
->af_cap
[afi
][safi
],
13307 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13309 p
->af_cap
[afi
][safi
],
13310 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13314 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13318 PEER_CAP_ADDPATH_AF_RX_RCV
))
13319 json_object_boolean_true_add(
13321 "rxAdvertisedAndReceived");
13326 PEER_CAP_ADDPATH_AF_RX_ADV
))
13327 json_object_boolean_true_add(
13334 PEER_CAP_ADDPATH_AF_RX_RCV
))
13335 json_object_boolean_true_add(
13341 p
->af_cap
[afi
][safi
],
13342 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13344 p
->af_cap
[afi
][safi
],
13345 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13347 p
->af_cap
[afi
][safi
],
13348 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13350 p
->af_cap
[afi
][safi
],
13351 PEER_CAP_ADDPATH_AF_RX_RCV
))
13352 json_object_object_add(
13353 json_add
, print_store
,
13356 json_object_free(json_sub
);
13359 json_object_object_add(json_cap
, "addPath",
13364 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13365 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13366 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13367 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13368 json_object_string_add(
13369 json_cap
, "dynamic",
13370 "advertisedAndReceived");
13371 else if (CHECK_FLAG(p
->cap
,
13372 PEER_CAP_DYNAMIC_ADV
))
13373 json_object_string_add(json_cap
,
13376 else if (CHECK_FLAG(p
->cap
,
13377 PEER_CAP_DYNAMIC_RCV
))
13378 json_object_string_add(json_cap
,
13384 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13385 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13386 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13387 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13388 json_object_string_add(
13390 "advertisedAndReceived");
13391 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13392 json_object_string_add(json_cap
, "role",
13394 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13395 json_object_string_add(json_cap
, "role",
13399 /* Extended nexthop */
13400 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13401 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13402 json_object
*json_nxt
= NULL
;
13403 const char *print_store
;
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13407 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13408 json_object_string_add(
13409 json_cap
, "extendedNexthop",
13410 "advertisedAndReceived");
13411 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13412 json_object_string_add(
13413 json_cap
, "extendedNexthop",
13415 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13416 json_object_string_add(
13417 json_cap
, "extendedNexthop",
13420 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13421 json_nxt
= json_object_new_object();
13423 for (safi
= SAFI_UNICAST
;
13424 safi
< SAFI_MAX
; safi
++) {
13428 PEER_CAP_ENHE_AF_RCV
)) {
13434 json_object_string_add(
13437 "recieved"); /* misspelled for compatibility */
13440 json_object_object_add(
13442 "extendedNexthopFamililesByPeer",
13447 /* Long-lived Graceful Restart */
13448 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13449 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13450 json_object
*json_llgr
= NULL
;
13451 const char *afi_safi_str
;
13453 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13454 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13455 json_object_string_add(
13457 "longLivedGracefulRestart",
13458 "advertisedAndReceived");
13459 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13460 json_object_string_add(
13462 "longLivedGracefulRestart",
13464 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13465 json_object_string_add(
13467 "longLivedGracefulRestart",
13470 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13471 json_llgr
= json_object_new_object();
13473 FOREACH_AFI_SAFI (afi
, safi
) {
13477 PEER_CAP_ENHE_AF_RCV
)) {
13483 json_object_string_add(
13489 json_object_object_add(
13491 "longLivedGracefulRestartByPeer",
13496 /* Route Refresh */
13497 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13498 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13499 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13500 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13501 (CHECK_FLAG(p
->cap
,
13502 PEER_CAP_REFRESH_NEW_RCV
) ||
13504 PEER_CAP_REFRESH_OLD_RCV
))) {
13507 PEER_CAP_REFRESH_OLD_RCV
) &&
13510 PEER_CAP_REFRESH_NEW_RCV
))
13511 json_object_string_add(
13514 "advertisedAndReceivedOldNew");
13518 PEER_CAP_REFRESH_OLD_RCV
))
13519 json_object_string_add(
13522 "advertisedAndReceivedOld");
13524 json_object_string_add(
13527 "advertisedAndReceivedNew");
13529 } else if (CHECK_FLAG(p
->cap
,
13530 PEER_CAP_REFRESH_ADV
))
13531 json_object_string_add(json_cap
,
13534 else if (CHECK_FLAG(p
->cap
,
13535 PEER_CAP_REFRESH_NEW_RCV
) ||
13537 PEER_CAP_REFRESH_OLD_RCV
))
13538 json_object_string_add(json_cap
,
13543 /* Enhanced Route Refresh */
13544 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13545 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13546 if (CHECK_FLAG(p
->cap
,
13547 PEER_CAP_ENHANCED_RR_ADV
) &&
13549 PEER_CAP_ENHANCED_RR_RCV
))
13550 json_object_string_add(
13552 "enhancedRouteRefresh",
13553 "advertisedAndReceived");
13554 else if (CHECK_FLAG(p
->cap
,
13555 PEER_CAP_ENHANCED_RR_ADV
))
13556 json_object_string_add(
13558 "enhancedRouteRefresh",
13560 else if (CHECK_FLAG(p
->cap
,
13561 PEER_CAP_ENHANCED_RR_RCV
))
13562 json_object_string_add(
13564 "enhancedRouteRefresh",
13568 /* Multiprotocol Extensions */
13569 json_object
*json_multi
= NULL
;
13571 json_multi
= json_object_new_object();
13573 FOREACH_AFI_SAFI (afi
, safi
) {
13574 if (p
->afc_adv
[afi
][safi
] ||
13575 p
->afc_recv
[afi
][safi
]) {
13576 json_object
*json_exten
= NULL
;
13577 json_exten
= json_object_new_object();
13579 if (p
->afc_adv
[afi
][safi
] &&
13580 p
->afc_recv
[afi
][safi
])
13581 json_object_boolean_true_add(
13583 "advertisedAndReceived");
13584 else if (p
->afc_adv
[afi
][safi
])
13585 json_object_boolean_true_add(
13588 else if (p
->afc_recv
[afi
][safi
])
13589 json_object_boolean_true_add(
13590 json_exten
, "received");
13592 json_object_object_add(
13594 get_afi_safi_str(afi
, safi
,
13599 json_object_object_add(json_cap
,
13600 "multiprotocolExtensions",
13603 /* Hostname capabilities */
13604 json_object
*json_hname
= NULL
;
13606 json_hname
= json_object_new_object();
13608 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13609 json_object_string_add(
13610 json_hname
, "advHostName",
13611 bgp
->peer_self
->hostname
13612 ? bgp
->peer_self
->hostname
13614 json_object_string_add(
13615 json_hname
, "advDomainName",
13616 bgp
->peer_self
->domainname
13617 ? bgp
->peer_self
->domainname
13622 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13623 json_object_string_add(
13624 json_hname
, "rcvHostName",
13625 p
->hostname
? p
->hostname
: "n/a");
13626 json_object_string_add(
13627 json_hname
, "rcvDomainName",
13628 p
->domainname
? p
->domainname
: "n/a");
13631 json_object_object_add(json_cap
, "hostName",
13634 /* Graceful Restart */
13635 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13636 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13637 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13638 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13639 json_object_string_add(
13640 json_cap
, "gracefulRestart",
13641 "advertisedAndReceived");
13642 else if (CHECK_FLAG(p
->cap
,
13643 PEER_CAP_RESTART_ADV
))
13644 json_object_string_add(
13646 "gracefulRestartCapability",
13648 else if (CHECK_FLAG(p
->cap
,
13649 PEER_CAP_RESTART_RCV
))
13650 json_object_string_add(
13652 "gracefulRestartCapability",
13655 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13656 int restart_af_count
= 0;
13657 json_object
*json_restart
= NULL
;
13658 json_restart
= json_object_new_object();
13660 json_object_int_add(
13662 "gracefulRestartRemoteTimerMsecs",
13663 p
->v_gr_restart
* 1000);
13665 FOREACH_AFI_SAFI (afi
, safi
) {
13669 PEER_CAP_RESTART_AF_RCV
)) {
13670 json_object
*json_sub
=
13673 json_object_new_object();
13679 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13680 json_object_boolean_true_add(
13683 restart_af_count
++;
13684 json_object_object_add(
13693 if (!restart_af_count
) {
13694 json_object_string_add(
13696 "addressFamiliesByPeer",
13698 json_object_free(json_restart
);
13700 json_object_object_add(
13702 "addressFamiliesByPeer",
13706 json_object_object_add(
13707 json_neigh
, "neighborCapabilities", json_cap
);
13709 vty_out(vty
, " Neighbor capabilities:\n");
13712 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13713 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13714 vty_out(vty
, " 4 Byte AS:");
13715 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13716 vty_out(vty
, " advertised");
13717 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13718 vty_out(vty
, " %sreceived",
13723 vty_out(vty
, "\n");
13726 /* Extended Message Support */
13727 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13728 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13729 vty_out(vty
, " Extended Message:");
13730 if (CHECK_FLAG(p
->cap
,
13731 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13732 vty_out(vty
, " advertised");
13733 if (CHECK_FLAG(p
->cap
,
13734 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13735 vty_out(vty
, " %sreceived",
13738 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13741 vty_out(vty
, "\n");
13745 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13746 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13747 vty_out(vty
, " AddPath:\n");
13749 FOREACH_AFI_SAFI (afi
, safi
) {
13751 p
->af_cap
[afi
][safi
],
13752 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13754 p
->af_cap
[afi
][safi
],
13755 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13756 vty_out(vty
, " %s: TX ",
13764 PEER_CAP_ADDPATH_AF_TX_ADV
))
13771 PEER_CAP_ADDPATH_AF_TX_RCV
))
13778 PEER_CAP_ADDPATH_AF_TX_ADV
)
13782 vty_out(vty
, "\n");
13786 p
->af_cap
[afi
][safi
],
13787 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13789 p
->af_cap
[afi
][safi
],
13790 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13791 vty_out(vty
, " %s: RX ",
13799 PEER_CAP_ADDPATH_AF_RX_ADV
))
13806 PEER_CAP_ADDPATH_AF_RX_RCV
))
13813 PEER_CAP_ADDPATH_AF_RX_ADV
)
13817 vty_out(vty
, "\n");
13823 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13824 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13825 vty_out(vty
, " Dynamic:");
13826 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13827 vty_out(vty
, " advertised");
13828 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13829 vty_out(vty
, " %sreceived",
13831 PEER_CAP_DYNAMIC_ADV
)
13834 vty_out(vty
, "\n");
13838 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13839 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13840 vty_out(vty
, " Role:");
13841 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13842 vty_out(vty
, " advertised");
13843 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13844 vty_out(vty
, " %sreceived",
13849 vty_out(vty
, "\n");
13852 /* Extended nexthop */
13853 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13854 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13855 vty_out(vty
, " Extended nexthop:");
13856 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13857 vty_out(vty
, " advertised");
13858 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13859 vty_out(vty
, " %sreceived",
13864 vty_out(vty
, "\n");
13866 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13868 " Address families by peer:\n ");
13869 for (safi
= SAFI_UNICAST
;
13870 safi
< SAFI_MAX
; safi
++)
13874 PEER_CAP_ENHE_AF_RCV
))
13884 /* Long-lived Graceful Restart */
13885 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13886 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13888 " Long-lived Graceful Restart:");
13889 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13890 vty_out(vty
, " advertised");
13891 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13892 vty_out(vty
, " %sreceived",
13897 vty_out(vty
, "\n");
13899 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13901 " Address families by peer:\n");
13902 FOREACH_AFI_SAFI (afi
, safi
)
13906 PEER_CAP_LLGR_AF_RCV
))
13916 /* Route Refresh */
13917 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13918 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13919 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13920 vty_out(vty
, " Route refresh:");
13921 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13922 vty_out(vty
, " advertised");
13923 if (CHECK_FLAG(p
->cap
,
13924 PEER_CAP_REFRESH_NEW_RCV
) ||
13926 PEER_CAP_REFRESH_OLD_RCV
))
13927 vty_out(vty
, " %sreceived(%s)",
13929 PEER_CAP_REFRESH_ADV
)
13934 PEER_CAP_REFRESH_OLD_RCV
) &&
13937 PEER_CAP_REFRESH_NEW_RCV
))
13941 PEER_CAP_REFRESH_OLD_RCV
)
13945 vty_out(vty
, "\n");
13948 /* Enhanced Route Refresh */
13949 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13950 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13951 vty_out(vty
, " Enhanced Route Refresh:");
13952 if (CHECK_FLAG(p
->cap
,
13953 PEER_CAP_ENHANCED_RR_ADV
))
13954 vty_out(vty
, " advertised");
13955 if (CHECK_FLAG(p
->cap
,
13956 PEER_CAP_ENHANCED_RR_RCV
))
13957 vty_out(vty
, " %sreceived",
13959 PEER_CAP_REFRESH_ADV
)
13962 vty_out(vty
, "\n");
13965 /* Multiprotocol Extensions */
13966 FOREACH_AFI_SAFI (afi
, safi
)
13967 if (p
->afc_adv
[afi
][safi
] ||
13968 p
->afc_recv
[afi
][safi
]) {
13969 vty_out(vty
, " Address Family %s:",
13970 get_afi_safi_str(afi
, safi
,
13972 if (p
->afc_adv
[afi
][safi
])
13973 vty_out(vty
, " advertised");
13974 if (p
->afc_recv
[afi
][safi
])
13975 vty_out(vty
, " %sreceived",
13976 p
->afc_adv
[afi
][safi
]
13979 vty_out(vty
, "\n");
13982 /* Hostname capability */
13983 vty_out(vty
, " Hostname Capability:");
13985 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13987 " advertised (name: %s,domain name: %s)",
13988 bgp
->peer_self
->hostname
13989 ? bgp
->peer_self
->hostname
13991 bgp
->peer_self
->domainname
13992 ? bgp
->peer_self
->domainname
13995 vty_out(vty
, " not advertised");
13998 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14000 " received (name: %s,domain name: %s)",
14001 p
->hostname
? p
->hostname
: "n/a",
14002 p
->domainname
? p
->domainname
: "n/a");
14004 vty_out(vty
, " not received");
14007 vty_out(vty
, "\n");
14009 /* Graceful Restart */
14010 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14011 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14013 " Graceful Restart Capability:");
14014 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14015 vty_out(vty
, " advertised");
14016 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14017 vty_out(vty
, " %sreceived",
14019 PEER_CAP_RESTART_ADV
)
14022 vty_out(vty
, "\n");
14024 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14025 int restart_af_count
= 0;
14028 " Remote Restart timer is %d seconds\n",
14031 " Address families by peer:\n ");
14033 FOREACH_AFI_SAFI (afi
, safi
)
14037 PEER_CAP_RESTART_AF_RCV
)) {
14038 vty_out(vty
, "%s%s(%s)",
14050 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14052 : "not preserved");
14053 restart_af_count
++;
14055 if (!restart_af_count
)
14056 vty_out(vty
, "none");
14057 vty_out(vty
, "\n");
14059 } /* Graceful Restart */
14063 /* graceful restart information */
14064 json_object
*json_grace
= NULL
;
14065 json_object
*json_grace_send
= NULL
;
14066 json_object
*json_grace_recv
= NULL
;
14067 int eor_send_af_count
= 0;
14068 int eor_receive_af_count
= 0;
14071 json_grace
= json_object_new_object();
14072 json_grace_send
= json_object_new_object();
14073 json_grace_recv
= json_object_new_object();
14075 if ((peer_established(p
)) &&
14076 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14077 FOREACH_AFI_SAFI (afi
, safi
) {
14078 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14079 PEER_STATUS_EOR_SEND
)) {
14080 json_object_boolean_true_add(
14082 get_afi_safi_str(afi
, safi
,
14084 eor_send_af_count
++;
14087 FOREACH_AFI_SAFI (afi
, safi
) {
14088 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14089 PEER_STATUS_EOR_RECEIVED
)) {
14090 json_object_boolean_true_add(
14092 get_afi_safi_str(afi
, safi
,
14094 eor_receive_af_count
++;
14098 json_object_object_add(json_grace
, "endOfRibSend",
14100 json_object_object_add(json_grace
, "endOfRibRecv",
14104 if (p
->t_gr_restart
)
14105 json_object_int_add(
14106 json_grace
, "gracefulRestartTimerMsecs",
14107 thread_timer_remain_second(p
->t_gr_restart
) *
14111 json_object_int_add(
14112 json_grace
, "gracefulStalepathTimerMsecs",
14113 thread_timer_remain_second(p
->t_gr_stale
) *
14115 /* more gr info in new format */
14116 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
14117 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14120 vty_out(vty
, " Graceful restart information:\n");
14121 if ((peer_established(p
)) &&
14122 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14124 vty_out(vty
, " End-of-RIB send: ");
14125 FOREACH_AFI_SAFI (afi
, safi
) {
14126 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14127 PEER_STATUS_EOR_SEND
)) {
14128 vty_out(vty
, "%s%s",
14129 eor_send_af_count
? ", " : "",
14130 get_afi_safi_str(afi
, safi
,
14132 eor_send_af_count
++;
14135 vty_out(vty
, "\n");
14136 vty_out(vty
, " End-of-RIB received: ");
14137 FOREACH_AFI_SAFI (afi
, safi
) {
14138 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14139 PEER_STATUS_EOR_RECEIVED
)) {
14140 vty_out(vty
, "%s%s",
14141 eor_receive_af_count
? ", "
14143 get_afi_safi_str(afi
, safi
,
14145 eor_receive_af_count
++;
14148 vty_out(vty
, "\n");
14151 if (p
->t_gr_restart
)
14153 " The remaining time of restart timer is %ld\n",
14154 thread_timer_remain_second(p
->t_gr_restart
));
14158 " The remaining time of stalepath timer is %ld\n",
14159 thread_timer_remain_second(p
->t_gr_stale
));
14161 /* more gr info in new format */
14162 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14166 json_object
*json_stat
= NULL
;
14167 json_stat
= json_object_new_object();
14168 /* Packet counts. */
14170 atomic_size_t outq_count
, inq_count
;
14171 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14172 memory_order_relaxed
);
14173 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14174 memory_order_relaxed
);
14176 json_object_int_add(json_stat
, "depthInq",
14177 (unsigned long)inq_count
);
14178 json_object_int_add(json_stat
, "depthOutq",
14179 (unsigned long)outq_count
);
14180 json_object_int_add(json_stat
, "opensSent",
14181 atomic_load_explicit(&p
->open_out
,
14182 memory_order_relaxed
));
14183 json_object_int_add(json_stat
, "opensRecv",
14184 atomic_load_explicit(&p
->open_in
,
14185 memory_order_relaxed
));
14186 json_object_int_add(json_stat
, "notificationsSent",
14187 atomic_load_explicit(&p
->notify_out
,
14188 memory_order_relaxed
));
14189 json_object_int_add(json_stat
, "notificationsRecv",
14190 atomic_load_explicit(&p
->notify_in
,
14191 memory_order_relaxed
));
14192 json_object_int_add(json_stat
, "updatesSent",
14193 atomic_load_explicit(&p
->update_out
,
14194 memory_order_relaxed
));
14195 json_object_int_add(json_stat
, "updatesRecv",
14196 atomic_load_explicit(&p
->update_in
,
14197 memory_order_relaxed
));
14198 json_object_int_add(json_stat
, "keepalivesSent",
14199 atomic_load_explicit(&p
->keepalive_out
,
14200 memory_order_relaxed
));
14201 json_object_int_add(json_stat
, "keepalivesRecv",
14202 atomic_load_explicit(&p
->keepalive_in
,
14203 memory_order_relaxed
));
14204 json_object_int_add(json_stat
, "routeRefreshSent",
14205 atomic_load_explicit(&p
->refresh_out
,
14206 memory_order_relaxed
));
14207 json_object_int_add(json_stat
, "routeRefreshRecv",
14208 atomic_load_explicit(&p
->refresh_in
,
14209 memory_order_relaxed
));
14210 json_object_int_add(json_stat
, "capabilitySent",
14211 atomic_load_explicit(&p
->dynamic_cap_out
,
14212 memory_order_relaxed
));
14213 json_object_int_add(json_stat
, "capabilityRecv",
14214 atomic_load_explicit(&p
->dynamic_cap_in
,
14215 memory_order_relaxed
));
14216 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14217 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14218 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14220 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14221 notify_out
, notify_in
, update_out
, update_in
,
14222 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14223 dynamic_cap_out
, dynamic_cap_in
;
14224 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14225 memory_order_relaxed
);
14226 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14227 memory_order_relaxed
);
14228 open_out
= atomic_load_explicit(&p
->open_out
,
14229 memory_order_relaxed
);
14231 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14232 notify_out
= atomic_load_explicit(&p
->notify_out
,
14233 memory_order_relaxed
);
14234 notify_in
= atomic_load_explicit(&p
->notify_in
,
14235 memory_order_relaxed
);
14236 update_out
= atomic_load_explicit(&p
->update_out
,
14237 memory_order_relaxed
);
14238 update_in
= atomic_load_explicit(&p
->update_in
,
14239 memory_order_relaxed
);
14240 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14241 memory_order_relaxed
);
14242 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14243 memory_order_relaxed
);
14244 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14245 memory_order_relaxed
);
14246 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14247 memory_order_relaxed
);
14248 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14249 memory_order_relaxed
);
14250 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14251 memory_order_relaxed
);
14253 /* Packet counts. */
14254 vty_out(vty
, " Message statistics:\n");
14255 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14256 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14257 vty_out(vty
, " Sent Rcvd\n");
14258 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14260 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14262 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14264 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14266 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14268 vty_out(vty
, " Capability: %10zu %10zu\n",
14269 dynamic_cap_out
, dynamic_cap_in
);
14270 vty_out(vty
, " Total: %10u %10u\n",
14271 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14275 /* advertisement-interval */
14276 json_object_int_add(json_neigh
,
14277 "minBtwnAdvertisementRunsTimerMsecs",
14278 p
->v_routeadv
* 1000);
14280 /* Update-source. */
14281 if (p
->update_if
|| p
->update_source
) {
14283 json_object_string_add(json_neigh
,
14286 else if (p
->update_source
)
14287 json_object_string_addf(json_neigh
,
14288 "updateSource", "%pSU",
14292 /* advertisement-interval */
14294 " Minimum time between advertisement runs is %d seconds\n",
14297 /* Update-source. */
14298 if (p
->update_if
|| p
->update_source
) {
14299 vty_out(vty
, " Update source is ");
14301 vty_out(vty
, "%s", p
->update_if
);
14302 else if (p
->update_source
)
14303 vty_out(vty
, "%pSU", p
->update_source
);
14304 vty_out(vty
, "\n");
14307 vty_out(vty
, "\n");
14310 /* Address Family Information */
14311 json_object
*json_hold
= NULL
;
14314 json_hold
= json_object_new_object();
14316 FOREACH_AFI_SAFI (afi
, safi
)
14317 if (p
->afc
[afi
][safi
])
14318 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14322 json_object_object_add(json_neigh
, "addressFamilyInfo",
14324 json_object_int_add(json_neigh
, "connectionsEstablished",
14326 json_object_int_add(json_neigh
, "connectionsDropped",
14329 vty_out(vty
, " Connections established %d; dropped %d\n",
14330 p
->established
, p
->dropped
);
14332 if (!p
->last_reset
) {
14334 json_object_string_add(json_neigh
, "lastReset",
14337 vty_out(vty
, " Last reset never\n");
14343 uptime
= monotime(NULL
);
14344 uptime
-= p
->resettime
;
14345 gmtime_r(&uptime
, &tm
);
14347 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14349 + (tm
.tm_min
* 60000)
14350 + (tm
.tm_hour
* 3600000));
14351 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14353 vty_out(vty
, " Last reset %s, ",
14354 peer_uptime(p
->resettime
, timebuf
,
14355 BGP_UPTIME_LEN
, 0, NULL
));
14357 bgp_show_peer_reset(vty
, p
, NULL
, false);
14358 if (p
->last_reset_cause_size
) {
14359 msg
= p
->last_reset_cause
;
14361 " Message received that caused BGP to send a NOTIFICATION:\n ");
14362 for (i
= 1; i
<= p
->last_reset_cause_size
;
14364 vty_out(vty
, "%02X", *msg
++);
14366 if (i
!= p
->last_reset_cause_size
) {
14368 vty_out(vty
, "\n ");
14369 } else if (i
% 4 == 0) {
14374 vty_out(vty
, "\n");
14379 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14381 json_object_boolean_true_add(json_neigh
,
14382 "prefixesConfigExceedMax");
14385 " Peer had exceeded the max. no. of prefixes configured.\n");
14387 if (p
->t_pmax_restart
) {
14389 json_object_boolean_true_add(
14390 json_neigh
, "reducePrefixNumFrom");
14391 json_object_int_add(json_neigh
,
14392 "restartInTimerMsec",
14393 thread_timer_remain_second(
14398 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14399 p
->host
, thread_timer_remain_second(
14400 p
->t_pmax_restart
));
14403 json_object_boolean_true_add(
14405 "reducePrefixNumAndClearIpBgp");
14408 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14413 /* EBGP Multihop and GTSM */
14414 if (p
->sort
!= BGP_PEER_IBGP
) {
14416 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14417 json_object_int_add(json_neigh
,
14418 "externalBgpNbrMaxHopsAway",
14421 json_object_int_add(json_neigh
,
14422 "externalBgpNbrMaxHopsAway",
14425 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14427 " External BGP neighbor may be up to %d hops away.\n",
14431 " External BGP neighbor may be up to %d hops away.\n",
14436 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14437 json_object_int_add(json_neigh
,
14438 "internalBgpNbrMaxHopsAway",
14441 json_object_int_add(json_neigh
,
14442 "internalBgpNbrMaxHopsAway",
14445 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14447 " Internal BGP neighbor may be up to %d hops away.\n",
14451 " Internal BGP neighbor may be up to %d hops away.\n",
14456 /* Local address. */
14459 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14461 json_object_int_add(json_neigh
, "portLocal",
14462 ntohs(p
->su_local
->sin
.sin_port
));
14464 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14465 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14468 json_object_string_add(json_neigh
, "hostLocal",
14470 json_object_int_add(json_neigh
, "portLocal", -1);
14474 /* Remote address. */
14475 if (p
->su_remote
) {
14477 json_object_string_addf(json_neigh
, "hostForeign",
14478 "%pSU", p
->su_remote
);
14479 json_object_int_add(json_neigh
, "portForeign",
14480 ntohs(p
->su_remote
->sin
.sin_port
));
14482 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14484 ntohs(p
->su_remote
->sin
.sin_port
));
14487 json_object_string_add(json_neigh
, "hostForeign",
14489 json_object_int_add(json_neigh
, "portForeign", -1);
14493 /* Nexthop display. */
14496 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14498 json_object_string_addf(json_neigh
, "nexthopGlobal",
14499 "%pI6", &p
->nexthop
.v6_global
);
14500 json_object_string_addf(json_neigh
, "nexthopLocal",
14501 "%pI6", &p
->nexthop
.v6_local
);
14502 if (p
->shared_network
)
14503 json_object_string_add(json_neigh
,
14507 json_object_string_add(json_neigh
,
14509 "nonSharedNetwork");
14511 vty_out(vty
, "Nexthop: %s\n",
14512 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14514 vty_out(vty
, "Nexthop global: %s\n",
14515 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14517 vty_out(vty
, "Nexthop local: %s\n",
14518 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14520 vty_out(vty
, "BGP connection: %s\n",
14521 p
->shared_network
? "shared network"
14522 : "non shared network");
14526 /* Timer information. */
14528 json_object_int_add(json_neigh
, "connectRetryTimer",
14530 if (peer_established(p
) && p
->rtt
)
14531 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14534 json_object_int_add(
14535 json_neigh
, "nextStartTimerDueInMsecs",
14536 thread_timer_remain_second(p
->t_start
) * 1000);
14538 json_object_int_add(
14539 json_neigh
, "nextConnectTimerDueInMsecs",
14540 thread_timer_remain_second(p
->t_connect
)
14542 if (p
->t_routeadv
) {
14543 json_object_int_add(json_neigh
, "mraiInterval",
14545 json_object_int_add(
14546 json_neigh
, "mraiTimerExpireInMsecs",
14547 thread_timer_remain_second(p
->t_routeadv
)
14551 json_object_int_add(json_neigh
, "authenticationEnabled",
14555 json_object_string_add(json_neigh
, "readThread", "on");
14557 json_object_string_add(json_neigh
, "readThread", "off");
14559 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14560 json_object_string_add(json_neigh
, "writeThread", "on");
14562 json_object_string_add(json_neigh
, "writeThread",
14565 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14567 if (peer_established(p
) && p
->rtt
)
14568 vty_out(vty
, "Estimated round trip time: %d ms\n",
14571 vty_out(vty
, "Next start timer due in %ld seconds\n",
14572 thread_timer_remain_second(p
->t_start
));
14574 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14575 thread_timer_remain_second(p
->t_connect
));
14578 "MRAI (interval %u) timer expires in %ld seconds\n",
14580 thread_timer_remain_second(p
->t_routeadv
));
14582 vty_out(vty
, "Peer Authentication Enabled\n");
14584 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14585 p
->t_read
? "on" : "off",
14586 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14591 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14592 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14593 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14596 vty_out(vty
, "\n");
14598 /* BFD information. */
14600 bgp_bfd_show_info(vty
, p
, json_neigh
);
14603 if (p
->conf_if
) /* Configured interface name. */
14604 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14605 else /* Configured IP address. */
14606 json_object_object_add(json
, p
->host
, json_neigh
);
14610 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14611 enum show_type type
,
14612 union sockunion
*su
,
14613 const char *conf_if
, afi_t afi
,
14616 struct listnode
*node
, *nnode
;
14619 safi_t safi
= SAFI_UNICAST
;
14620 json_object
*json
= NULL
;
14621 json_object
*json_neighbor
= NULL
;
14624 json
= json_object_new_object();
14625 json_neighbor
= json_object_new_object();
14628 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14630 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14633 if ((peer
->afc
[afi
][safi
]) == 0)
14636 if (type
== show_all
) {
14637 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14641 json_object_object_add(json
, peer
->host
,
14643 json_neighbor
= NULL
;
14646 } else if (type
== show_peer
) {
14649 && !strcmp(peer
->conf_if
, conf_if
))
14651 && !strcmp(peer
->hostname
, conf_if
))) {
14653 bgp_show_peer_gr_status(vty
, peer
,
14658 if (sockunion_same(&peer
->su
, su
)) {
14660 bgp_show_peer_gr_status(vty
, peer
,
14665 if (use_json
&& find
)
14666 json_object_object_add(json
, peer
->host
,
14671 json_neighbor
= NULL
;
14676 if (type
== show_peer
&& !find
) {
14678 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14680 vty_out(vty
, "%% No such neighbor\n");
14684 json_object_free(json_neighbor
);
14685 vty_json(vty
, json
);
14687 vty_out(vty
, "\n");
14690 return CMD_SUCCESS
;
14693 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14694 enum show_type type
, union sockunion
*su
,
14695 const char *conf_if
, bool use_json
,
14698 struct listnode
*node
, *nnode
;
14701 bool nbr_output
= false;
14702 afi_t afi
= AFI_MAX
;
14703 safi_t safi
= SAFI_MAX
;
14705 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14707 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14711 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14712 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14717 bgp_show_peer(vty
, peer
, use_json
, json
);
14723 && !strcmp(peer
->conf_if
, conf_if
))
14725 && !strcmp(peer
->hostname
, conf_if
))) {
14727 bgp_show_peer(vty
, peer
, use_json
,
14731 if (sockunion_same(&peer
->su
, su
)) {
14733 bgp_show_peer(vty
, peer
, use_json
,
14738 case show_ipv4_peer
:
14739 case show_ipv6_peer
:
14740 FOREACH_SAFI (safi
) {
14741 if (peer
->afc
[afi
][safi
]) {
14744 && !strcmp(peer
->conf_if
, conf_if
))
14746 && !strcmp(peer
->hostname
, conf_if
))) {
14748 bgp_show_peer(vty
, peer
, use_json
,
14753 if (sockunion_same(&peer
->su
, su
)) {
14755 bgp_show_peer(vty
, peer
, use_json
,
14763 case show_ipv4_all
:
14764 case show_ipv6_all
:
14765 FOREACH_SAFI (safi
) {
14766 if (peer
->afc
[afi
][safi
]) {
14767 bgp_show_peer(vty
, peer
, use_json
, json
);
14776 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14777 type
== show_ipv6_peer
) && !find
) {
14779 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14781 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14784 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14785 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14786 vty_out(vty
, "%% No BGP neighbors found\n");
14789 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14790 json
, JSON_C_TO_STRING_PRETTY
));
14792 vty_out(vty
, "\n");
14795 return CMD_SUCCESS
;
14798 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14799 enum show_type type
,
14800 const char *ip_str
,
14801 afi_t afi
, bool use_json
)
14806 union sockunion su
;
14808 bgp
= bgp_get_default();
14814 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14818 ret
= str2sockunion(ip_str
, &su
);
14820 bgp_show_neighbor_graceful_restart(
14821 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14823 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14824 NULL
, afi
, use_json
);
14826 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14830 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14831 enum show_type type
,
14832 const char *ip_str
,
14835 struct listnode
*node
, *nnode
;
14837 union sockunion su
;
14838 json_object
*json
= NULL
;
14839 int ret
, is_first
= 1;
14840 bool nbr_output
= false;
14843 vty_out(vty
, "{\n");
14845 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14848 if (!(json
= json_object_new_object())) {
14850 EC_BGP_JSON_MEM_ERROR
,
14851 "Unable to allocate memory for JSON object");
14853 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14857 json_object_int_add(json
, "vrfId",
14858 (bgp
->vrf_id
== VRF_UNKNOWN
)
14860 : (int64_t)bgp
->vrf_id
);
14861 json_object_string_add(
14863 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14868 vty_out(vty
, ",\n");
14872 vty_out(vty
, "\"%s\":",
14873 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14877 vty_out(vty
, "\nInstance %s:\n",
14878 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14883 if (type
== show_peer
|| type
== show_ipv4_peer
||
14884 type
== show_ipv6_peer
) {
14885 ret
= str2sockunion(ip_str
, &su
);
14887 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14890 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14893 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14896 json_object_free(json
);
14901 vty_out(vty
, "}\n");
14902 else if (!nbr_output
)
14903 vty_out(vty
, "%% BGP instance not found\n");
14906 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14907 enum show_type type
, const char *ip_str
,
14912 union sockunion su
;
14913 json_object
*json
= NULL
;
14916 if (strmatch(name
, "all")) {
14917 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14919 return CMD_SUCCESS
;
14921 bgp
= bgp_lookup_by_name(name
);
14924 json
= json_object_new_object();
14925 vty_json(vty
, json
);
14928 "%% BGP instance not found\n");
14930 return CMD_WARNING
;
14934 bgp
= bgp_get_default();
14938 json
= json_object_new_object();
14940 ret
= str2sockunion(ip_str
, &su
);
14942 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14945 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14948 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14951 json_object_free(json
);
14954 vty_out(vty
, "{}\n");
14956 vty_out(vty
, "%% BGP instance not found\n");
14959 return CMD_SUCCESS
;
14964 /* "show [ip] bgp neighbors graceful-restart" commands. */
14965 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14966 show_ip_bgp_neighbors_graceful_restart_cmd
,
14967 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14973 "Neighbor to display information about\n"
14974 "Neighbor to display information about\n"
14975 "Neighbor on BGP configured interface\n"
14979 char *sh_arg
= NULL
;
14980 enum show_type sh_type
;
14982 afi_t afi
= AFI_MAX
;
14983 bool uj
= use_json(argc
, argv
);
14985 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14990 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14991 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14992 || argv_find(argv
, argc
, "WORD", &idx
)) {
14993 sh_type
= show_peer
;
14994 sh_arg
= argv
[idx
]->arg
;
14996 sh_type
= show_all
;
14998 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14999 return CMD_SUCCESS
;
15002 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15006 /* "show [ip] bgp neighbors" commands. */
15007 DEFUN (show_ip_bgp_neighbors
,
15008 show_ip_bgp_neighbors_cmd
,
15009 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15013 BGP_INSTANCE_HELP_STR
15016 "Detailed information on TCP and BGP neighbor connections\n"
15017 "Neighbor to display information about\n"
15018 "Neighbor to display information about\n"
15019 "Neighbor on BGP configured interface\n"
15023 char *sh_arg
= NULL
;
15024 enum show_type sh_type
;
15025 afi_t afi
= AFI_MAX
;
15027 bool uj
= use_json(argc
, argv
);
15031 /* [<vrf> VIEWVRFNAME] */
15032 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15033 vrf
= argv
[idx
+ 1]->arg
;
15034 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15036 } else if (argv_find(argv
, argc
, "view", &idx
))
15037 /* [<view> VIEWVRFNAME] */
15038 vrf
= argv
[idx
+ 1]->arg
;
15042 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15043 sh_type
= show_ipv4_all
;
15045 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15046 sh_type
= show_ipv6_all
;
15049 sh_type
= show_all
;
15052 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15053 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15054 || argv_find(argv
, argc
, "WORD", &idx
)) {
15055 sh_type
= show_peer
;
15056 sh_arg
= argv
[idx
]->arg
;
15059 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15060 sh_type
= show_ipv4_peer
;
15061 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15062 sh_type
= show_ipv6_peer
;
15065 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15068 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15069 paths' and `show ip mbgp paths'. Those functions results are the
15071 DEFUN (show_ip_bgp_paths
,
15072 show_ip_bgp_paths_cmd
,
15073 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15078 "Path information\n")
15080 vty_out(vty
, "Address Refcnt Path\n");
15081 aspath_print_all_vty(vty
);
15082 return CMD_SUCCESS
;
15087 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15090 struct community
*com
;
15092 com
= (struct community
*)bucket
->data
;
15093 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15094 community_str(com
, false, false));
15097 /* Show BGP's community internal data. */
15098 DEFUN (show_ip_bgp_community_info
,
15099 show_ip_bgp_community_info_cmd
,
15100 "show [ip] bgp community-info",
15104 "List all bgp community information\n")
15106 vty_out(vty
, "Address Refcnt Community\n");
15108 hash_iterate(community_hash(),
15109 (void (*)(struct hash_bucket
*,
15110 void *))community_show_all_iterator
,
15113 return CMD_SUCCESS
;
15116 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15119 struct lcommunity
*lcom
;
15121 lcom
= (struct lcommunity
*)bucket
->data
;
15122 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15123 lcommunity_str(lcom
, false, false));
15126 /* Show BGP's community internal data. */
15127 DEFUN (show_ip_bgp_lcommunity_info
,
15128 show_ip_bgp_lcommunity_info_cmd
,
15129 "show ip bgp large-community-info",
15133 "List all bgp large-community information\n")
15135 vty_out(vty
, "Address Refcnt Large-community\n");
15137 hash_iterate(lcommunity_hash(),
15138 (void (*)(struct hash_bucket
*,
15139 void *))lcommunity_show_all_iterator
,
15142 return CMD_SUCCESS
;
15144 /* Graceful Restart */
15146 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15153 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15155 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15157 switch (bgp_global_gr_mode
) {
15159 case GLOBAL_HELPER
:
15160 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15164 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15167 case GLOBAL_DISABLE
:
15168 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15171 case GLOBAL_INVALID
:
15173 "Global BGP GR Mode Invalid\n");
15176 vty_out(vty
, "\n");
15179 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15180 enum show_type type
,
15181 const char *ip_str
,
15182 afi_t afi
, bool use_json
)
15184 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15187 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15189 bgp_show_neighbor_graceful_restart_vty(
15190 vty
, type
, ip_str
, afi
, use_json
);
15193 } else if (afi
!= AFI_MAX
) {
15194 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15197 return CMD_ERR_INCOMPLETE
;
15200 return CMD_SUCCESS
;
15202 /* Graceful Restart */
15204 DEFUN (show_ip_bgp_attr_info
,
15205 show_ip_bgp_attr_info_cmd
,
15206 "show [ip] bgp attribute-info",
15210 "List all bgp attribute information\n")
15212 attr_show_all(vty
);
15213 return CMD_SUCCESS
;
15216 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15217 afi_t afi
, safi_t safi
,
15218 bool use_json
, json_object
*json
)
15221 struct listnode
*node
;
15224 enum vpn_policy_direction dir
;
15227 json_object
*json_import_vrfs
= NULL
;
15228 json_object
*json_export_vrfs
= NULL
;
15230 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15233 vty_json(vty
, json
);
15235 return CMD_WARNING
;
15238 /* Provide context for the block */
15239 json_object_string_add(json
, "vrf", name
? name
: "default");
15240 json_object_string_add(json
, "afiSafi",
15241 get_afi_safi_str(afi
, safi
, true));
15243 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15244 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15245 json_object_string_add(json
, "importFromVrfs", "none");
15246 json_object_string_add(json
, "importRts", "none");
15248 json_import_vrfs
= json_object_new_array();
15250 for (ALL_LIST_ELEMENTS_RO(
15251 bgp
->vpn_policy
[afi
].import_vrf
,
15253 json_object_array_add(json_import_vrfs
,
15254 json_object_new_string(vname
));
15256 json_object_object_add(json
, "importFromVrfs",
15258 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15259 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15260 ecom_str
= ecommunity_ecom2str(
15261 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15262 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15263 json_object_string_add(json
, "importRts",
15265 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15267 json_object_string_add(json
, "importRts",
15271 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15272 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15273 json_object_string_add(json
, "exportToVrfs", "none");
15274 json_object_string_add(json
, "routeDistinguisher",
15276 json_object_string_add(json
, "exportRts", "none");
15278 json_export_vrfs
= json_object_new_array();
15280 for (ALL_LIST_ELEMENTS_RO(
15281 bgp
->vpn_policy
[afi
].export_vrf
,
15283 json_object_array_add(json_export_vrfs
,
15284 json_object_new_string(vname
));
15285 json_object_object_add(json
, "exportToVrfs",
15287 json_object_string_addf(json
, "routeDistinguisher",
15289 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15291 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15292 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15293 ecom_str
= ecommunity_ecom2str(
15294 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15295 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15296 json_object_string_add(json
, "exportRts",
15298 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15300 json_object_string_add(json
, "exportRts",
15305 vty_json(vty
, json
);
15308 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15311 vty_out(vty
, "%% No such BGP instance exist\n");
15312 return CMD_WARNING
;
15315 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15316 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15318 "This VRF is not importing %s routes from any other VRF\n",
15319 get_afi_safi_str(afi
, safi
, false));
15322 "This VRF is importing %s routes from the following VRFs:\n",
15323 get_afi_safi_str(afi
, safi
, false));
15325 for (ALL_LIST_ELEMENTS_RO(
15326 bgp
->vpn_policy
[afi
].import_vrf
,
15328 vty_out(vty
, " %s\n", vname
);
15330 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15332 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15333 ecom_str
= ecommunity_ecom2str(
15334 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15335 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15336 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15338 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15340 vty_out(vty
, "Import RT(s):\n");
15343 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15344 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15346 "This VRF is not exporting %s routes to any other VRF\n",
15347 get_afi_safi_str(afi
, safi
, false));
15350 "This VRF is exporting %s routes to the following VRFs:\n",
15351 get_afi_safi_str(afi
, safi
, false));
15353 for (ALL_LIST_ELEMENTS_RO(
15354 bgp
->vpn_policy
[afi
].export_vrf
,
15356 vty_out(vty
, " %s\n", vname
);
15358 vty_out(vty
, "RD: %pRD\n",
15359 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15361 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15362 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15363 ecom_str
= ecommunity_ecom2str(
15364 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15365 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15366 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15367 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15369 vty_out(vty
, "Import RT(s):\n");
15373 return CMD_SUCCESS
;
15376 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15377 safi_t safi
, bool use_json
)
15379 struct listnode
*node
, *nnode
;
15381 char *vrf_name
= NULL
;
15382 json_object
*json
= NULL
;
15383 json_object
*json_vrf
= NULL
;
15384 json_object
*json_vrfs
= NULL
;
15387 json
= json_object_new_object();
15388 json_vrfs
= json_object_new_object();
15391 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15393 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15394 vrf_name
= bgp
->name
;
15397 json_vrf
= json_object_new_object();
15399 vty_out(vty
, "\nInstance %s:\n",
15400 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15401 ? VRF_DEFAULT_NAME
: bgp
->name
);
15403 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15405 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15406 json_object_object_add(json_vrfs
,
15407 VRF_DEFAULT_NAME
, json_vrf
);
15409 json_object_object_add(json_vrfs
, vrf_name
,
15415 json_object_object_add(json
, "vrfs", json_vrfs
);
15416 vty_json(vty
, json
);
15419 return CMD_SUCCESS
;
15422 /* "show [ip] bgp route-leak" command. */
15423 DEFUN (show_ip_bgp_route_leak
,
15424 show_ip_bgp_route_leak_cmd
,
15425 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15429 BGP_INSTANCE_HELP_STR
15432 "Route leaking information\n"
15436 afi_t afi
= AFI_MAX
;
15437 safi_t safi
= SAFI_MAX
;
15439 bool uj
= use_json(argc
, argv
);
15441 json_object
*json
= NULL
;
15443 /* show [ip] bgp */
15444 if (argv_find(argv
, argc
, "ip", &idx
)) {
15446 safi
= SAFI_UNICAST
;
15448 /* [vrf VIEWVRFNAME] */
15449 if (argv_find(argv
, argc
, "view", &idx
)) {
15451 "%% This command is not applicable to BGP views\n");
15452 return CMD_WARNING
;
15455 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15456 vrf
= argv
[idx
+ 1]->arg
;
15457 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15460 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15461 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15462 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15464 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15466 "%% This command is applicable only for unicast ipv4|ipv6\n");
15467 return CMD_WARNING
;
15470 if (vrf
&& strmatch(vrf
, "all"))
15471 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15474 json
= json_object_new_object();
15476 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15479 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15482 struct listnode
*node
, *nnode
;
15485 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15486 vty_out(vty
, "\nInstance %s:\n",
15487 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15490 update_group_show(bgp
, afi
, safi
, vty
, 0);
15494 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15495 int safi
, uint64_t subgrp_id
)
15500 if (strmatch(name
, "all")) {
15501 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15502 return CMD_SUCCESS
;
15504 bgp
= bgp_lookup_by_name(name
);
15507 bgp
= bgp_get_default();
15511 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15512 return CMD_SUCCESS
;
15515 DEFUN (show_ip_bgp_updgrps
,
15516 show_ip_bgp_updgrps_cmd
,
15517 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15521 BGP_INSTANCE_HELP_STR
15523 BGP_SAFI_WITH_LABEL_HELP_STR
15524 "Detailed info about dynamic update groups\n"
15525 "Specific subgroup to display detailed info for\n")
15528 afi_t afi
= AFI_IP6
;
15529 safi_t safi
= SAFI_UNICAST
;
15530 uint64_t subgrp_id
= 0;
15534 /* show [ip] bgp */
15535 if (argv_find(argv
, argc
, "ip", &idx
))
15537 /* [<vrf> VIEWVRFNAME] */
15538 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15539 vrf
= argv
[idx
+ 1]->arg
;
15540 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15542 } else if (argv_find(argv
, argc
, "view", &idx
))
15543 /* [<view> VIEWVRFNAME] */
15544 vrf
= argv
[idx
+ 1]->arg
;
15545 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15546 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15547 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15550 /* get subgroup id, if provided */
15552 if (argv
[idx
]->type
== VARIABLE_TKN
)
15553 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15555 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15558 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15559 show_bgp_instance_all_ipv6_updgrps_cmd
,
15560 "show [ip] bgp <view|vrf> all update-groups",
15564 BGP_INSTANCE_ALL_HELP_STR
15565 "Detailed info about dynamic update groups\n")
15567 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15568 return CMD_SUCCESS
;
15571 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15572 show_bgp_l2vpn_evpn_updgrps_cmd
,
15573 "show [ip] bgp l2vpn evpn update-groups",
15577 "l2vpn address family\n"
15578 "evpn sub-address family\n"
15579 "Detailed info about dynamic update groups\n")
15582 uint64_t subgrp_id
= 0;
15584 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15585 return CMD_SUCCESS
;
15588 DEFUN (show_bgp_updgrps_stats
,
15589 show_bgp_updgrps_stats_cmd
,
15590 "show [ip] bgp update-groups statistics",
15594 "Detailed info about dynamic update groups\n"
15599 bgp
= bgp_get_default();
15601 update_group_show_stats(bgp
, vty
);
15603 return CMD_SUCCESS
;
15606 DEFUN (show_bgp_instance_updgrps_stats
,
15607 show_bgp_instance_updgrps_stats_cmd
,
15608 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15612 BGP_INSTANCE_HELP_STR
15613 "Detailed info about dynamic update groups\n"
15619 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15621 update_group_show_stats(bgp
, vty
);
15623 return CMD_SUCCESS
;
15626 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15627 afi_t afi
, safi_t safi
,
15628 const char *what
, uint64_t subgrp_id
)
15633 bgp
= bgp_lookup_by_name(name
);
15635 bgp
= bgp_get_default();
15638 if (!strcmp(what
, "advertise-queue"))
15639 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15641 else if (!strcmp(what
, "advertised-routes"))
15642 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15644 else if (!strcmp(what
, "packet-queue"))
15645 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15650 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15651 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15652 "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",
15653 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15655 "Detailed info about dynamic update groups\n"
15656 "Specific subgroup to display info for\n"
15657 "Advertisement queue\n"
15658 "Announced routes\n"
15661 uint64_t subgrp_id
= 0;
15665 subgrp_id
= strtoull(sgid
, NULL
, 10);
15670 afiz
= bgp_vty_afi_from_str(afi
);
15674 afiz
= bgp_vty_afi_from_str(afi
);
15675 if (afiz
!= AFI_IP
)
15677 "%% Cannot specify both 'ip' and 'ipv6'\n");
15678 return CMD_WARNING
;
15681 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15683 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15684 return CMD_SUCCESS
;
15687 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15690 struct listnode
*node
, *nnode
;
15691 struct prefix
*range
;
15696 const char *peer_status
;
15700 json_object
*json_peer_group
= NULL
;
15701 json_object
*json_peer_group_afc
= NULL
;
15702 json_object
*json_peer_group_members
= NULL
;
15703 json_object
*json_peer_group_dynamic
= NULL
;
15704 json_object
*json_peer_group_dynamic_af
= NULL
;
15705 json_object
*json_peer_group_ranges
= NULL
;
15707 conf
= group
->conf
;
15710 json_peer_group
= json_object_new_object();
15711 json_peer_group_afc
= json_object_new_array();
15714 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15716 json_object_int_add(json_peer_group
, "remoteAs",
15719 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15720 group
->name
, conf
->as
);
15721 } else if (conf
->as_type
== AS_INTERNAL
) {
15723 json_object_int_add(json_peer_group
, "remoteAs",
15726 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15727 group
->name
, group
->bgp
->as
);
15730 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15733 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15735 json_object_string_add(json_peer_group
, "type",
15738 vty_out(vty
, " Peer-group type is internal\n");
15741 json_object_string_add(json_peer_group
, "type",
15744 vty_out(vty
, " Peer-group type is external\n");
15747 /* Display AFs configured. */
15749 vty_out(vty
, " Configured address-families:");
15751 FOREACH_AFI_SAFI (afi
, safi
) {
15752 if (conf
->afc
[afi
][safi
]) {
15755 json_object_array_add(
15756 json_peer_group_afc
,
15757 json_object_new_string(get_afi_safi_str(
15758 afi
, safi
, false)));
15760 vty_out(vty
, " %s;",
15761 get_afi_safi_str(afi
, safi
, false));
15766 json_object_object_add(json_peer_group
,
15767 "addressFamiliesConfigured",
15768 json_peer_group_afc
);
15771 vty_out(vty
, " none\n");
15773 vty_out(vty
, "\n");
15776 /* Display listen ranges (for dynamic neighbors), if any */
15777 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15778 lr_count
= listcount(group
->listen_range
[afi
]);
15781 if (!json_peer_group_dynamic
)
15782 json_peer_group_dynamic
=
15783 json_object_new_object();
15785 json_peer_group_dynamic_af
=
15786 json_object_new_object();
15787 json_peer_group_ranges
=
15788 json_object_new_array();
15789 json_object_int_add(json_peer_group_dynamic_af
,
15790 "count", lr_count
);
15792 vty_out(vty
, " %d %s listen range(s)\n",
15793 lr_count
, afi2str(afi
));
15796 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15801 snprintfrr(buf
, sizeof(buf
), "%pFX",
15804 json_object_array_add(
15805 json_peer_group_ranges
,
15806 json_object_new_string(buf
));
15808 vty_out(vty
, " %pFX\n", range
);
15813 json_object_object_add(
15814 json_peer_group_dynamic_af
, "ranges",
15815 json_peer_group_ranges
);
15817 json_object_object_add(
15818 json_peer_group_dynamic
, afi2str(afi
),
15819 json_peer_group_dynamic_af
);
15824 if (json_peer_group_dynamic
)
15825 json_object_object_add(json_peer_group
, "dynamicRanges",
15826 json_peer_group_dynamic
);
15828 /* Display group members and their status */
15829 if (listcount(group
->peer
)) {
15831 json_peer_group_members
= json_object_new_object();
15833 vty_out(vty
, " Peer-group members:\n");
15834 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15835 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15836 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15837 peer_status
= "Idle (Admin)";
15838 else if (CHECK_FLAG(peer
->sflags
,
15839 PEER_STATUS_PREFIX_OVERFLOW
))
15840 peer_status
= "Idle (PfxCt)";
15842 peer_status
= lookup_msg(bgp_status_msg
,
15843 peer
->status
, NULL
);
15845 dynamic
= peer_dynamic_neighbor(peer
);
15848 json_object
*json_peer_group_member
=
15849 json_object_new_object();
15851 json_object_string_add(json_peer_group_member
,
15852 "status", peer_status
);
15855 json_object_boolean_true_add(
15856 json_peer_group_member
,
15859 json_object_object_add(json_peer_group_members
,
15861 json_peer_group_member
);
15863 vty_out(vty
, " %s %s %s \n", peer
->host
,
15864 dynamic
? "(dynamic)" : "",
15869 json_object_object_add(json_peer_group
, "members",
15870 json_peer_group_members
);
15874 json_object_object_add(json
, group
->name
, json_peer_group
);
15876 return CMD_SUCCESS
;
15879 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15880 const char *group_name
, bool uj
)
15883 struct listnode
*node
, *nnode
;
15884 struct peer_group
*group
;
15885 bool found
= false;
15886 json_object
*json
= NULL
;
15889 json
= json_object_new_object();
15891 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15895 vty_json(vty
, json
);
15897 vty_out(vty
, "%% BGP instance not found\n");
15899 return CMD_WARNING
;
15902 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15904 if (strmatch(group
->name
, group_name
)) {
15905 bgp_show_one_peer_group(vty
, group
, json
);
15910 bgp_show_one_peer_group(vty
, group
, json
);
15914 if (group_name
&& !found
&& !uj
)
15915 vty_out(vty
, "%% No such peer-group\n");
15918 vty_json(vty
, json
);
15920 return CMD_SUCCESS
;
15923 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15924 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15925 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15926 "Detailed information on BGP peer groups\n"
15927 "Peer group name\n" JSON_STR
)
15931 bool uj
= use_json(argc
, argv
);
15933 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15935 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15937 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15941 /* Redistribute VTY commands. */
15943 DEFUN (bgp_redistribute_ipv4
,
15944 bgp_redistribute_ipv4_cmd
,
15945 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15946 "Redistribute information from another routing protocol\n"
15947 FRR_IP_REDIST_HELP_STR_BGPD
)
15949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15950 int idx_protocol
= 1;
15953 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15955 vty_out(vty
, "%% Invalid route type\n");
15956 return CMD_WARNING_CONFIG_FAILED
;
15959 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15960 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15964 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15965 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15966 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15968 DEFUN (bgp_redistribute_ipv4_rmap
,
15969 bgp_redistribute_ipv4_rmap_cmd
,
15970 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15971 "Redistribute information from another routing protocol\n"
15972 FRR_IP_REDIST_HELP_STR_BGPD
15973 "Route map reference\n"
15974 "Pointer to route-map entries\n")
15976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15977 int idx_protocol
= 1;
15980 struct bgp_redist
*red
;
15982 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15983 vty
, argv
[idx_word
]->arg
);
15985 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15987 vty_out(vty
, "%% Invalid route type\n");
15988 return CMD_WARNING_CONFIG_FAILED
;
15991 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15993 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15994 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15998 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15999 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16000 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16001 "Route map reference\n"
16002 "Pointer to route-map entries\n")
16004 DEFUN (bgp_redistribute_ipv4_metric
,
16005 bgp_redistribute_ipv4_metric_cmd
,
16006 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16007 "Redistribute information from another routing protocol\n"
16008 FRR_IP_REDIST_HELP_STR_BGPD
16009 "Metric for redistributed routes\n"
16010 "Default metric\n")
16012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16013 int idx_protocol
= 1;
16014 int idx_number
= 3;
16017 struct bgp_redist
*red
;
16020 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16022 vty_out(vty
, "%% Invalid route type\n");
16023 return CMD_WARNING_CONFIG_FAILED
;
16025 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16027 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16028 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16029 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16033 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16034 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16035 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16036 "Metric for redistributed routes\n"
16037 "Default metric\n")
16039 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16040 bgp_redistribute_ipv4_rmap_metric_cmd
,
16041 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16042 "Redistribute information from another routing protocol\n"
16043 FRR_IP_REDIST_HELP_STR_BGPD
16044 "Route map reference\n"
16045 "Pointer to route-map entries\n"
16046 "Metric for redistributed routes\n"
16047 "Default metric\n")
16049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16050 int idx_protocol
= 1;
16052 int idx_number
= 5;
16055 struct bgp_redist
*red
;
16057 struct route_map
*route_map
=
16058 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16060 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16062 vty_out(vty
, "%% Invalid route type\n");
16063 return CMD_WARNING_CONFIG_FAILED
;
16065 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16067 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16069 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16070 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16071 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16075 bgp_redistribute_ipv4_rmap_metric
,
16076 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16077 "redistribute " FRR_IP_REDIST_STR_BGPD
16078 " route-map RMAP_NAME metric (0-4294967295)",
16079 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16080 "Route map reference\n"
16081 "Pointer to route-map entries\n"
16082 "Metric for redistributed routes\n"
16083 "Default metric\n")
16085 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16086 bgp_redistribute_ipv4_metric_rmap_cmd
,
16087 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16088 "Redistribute information from another routing protocol\n"
16089 FRR_IP_REDIST_HELP_STR_BGPD
16090 "Metric for redistributed routes\n"
16092 "Route map reference\n"
16093 "Pointer to route-map entries\n")
16095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16096 int idx_protocol
= 1;
16097 int idx_number
= 3;
16101 struct bgp_redist
*red
;
16103 struct route_map
*route_map
=
16104 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16106 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16108 vty_out(vty
, "%% Invalid route type\n");
16109 return CMD_WARNING_CONFIG_FAILED
;
16111 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16113 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16114 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16116 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16117 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16121 bgp_redistribute_ipv4_metric_rmap
,
16122 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16123 "redistribute " FRR_IP_REDIST_STR_BGPD
16124 " metric (0-4294967295) route-map RMAP_NAME",
16125 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16126 "Metric for redistributed routes\n"
16128 "Route map reference\n"
16129 "Pointer to route-map entries\n")
16131 DEFUN (bgp_redistribute_ipv4_ospf
,
16132 bgp_redistribute_ipv4_ospf_cmd
,
16133 "redistribute <ospf|table> (1-65535)",
16134 "Redistribute information from another routing protocol\n"
16135 "Open Shortest Path First (OSPFv2)\n"
16136 "Non-main Kernel Routing Table\n"
16137 "Instance ID/Table ID\n")
16139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16140 int idx_ospf_table
= 1;
16141 int idx_number
= 2;
16142 unsigned short instance
;
16143 unsigned short protocol
;
16145 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16147 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16148 protocol
= ZEBRA_ROUTE_OSPF
;
16150 protocol
= ZEBRA_ROUTE_TABLE
;
16152 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16153 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16156 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16157 "redistribute <ospf|table> (1-65535)",
16158 "Redistribute information from another routing protocol\n"
16159 "Open Shortest Path First (OSPFv2)\n"
16160 "Non-main Kernel Routing Table\n"
16161 "Instance ID/Table ID\n")
16163 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16164 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16165 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16166 "Redistribute information from another routing protocol\n"
16167 "Open Shortest Path First (OSPFv2)\n"
16168 "Non-main Kernel Routing Table\n"
16169 "Instance ID/Table ID\n"
16170 "Route map reference\n"
16171 "Pointer to route-map entries\n")
16173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16174 int idx_ospf_table
= 1;
16175 int idx_number
= 2;
16177 struct bgp_redist
*red
;
16178 unsigned short instance
;
16181 struct route_map
*route_map
=
16182 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16184 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16185 protocol
= ZEBRA_ROUTE_OSPF
;
16187 protocol
= ZEBRA_ROUTE_TABLE
;
16189 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16190 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16192 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16193 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16196 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16197 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16198 "redistribute <ospf|table> (1-65535) 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 "Route map reference\n"
16204 "Pointer to route-map entries\n")
16206 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16207 bgp_redistribute_ipv4_ospf_metric_cmd
,
16208 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16209 "Redistribute information from another routing protocol\n"
16210 "Open Shortest Path First (OSPFv2)\n"
16211 "Non-main Kernel Routing Table\n"
16212 "Instance ID/Table ID\n"
16213 "Metric for redistributed routes\n"
16214 "Default metric\n")
16216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16217 int idx_ospf_table
= 1;
16218 int idx_number
= 2;
16219 int idx_number_2
= 4;
16221 struct bgp_redist
*red
;
16222 unsigned short instance
;
16226 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16227 protocol
= ZEBRA_ROUTE_OSPF
;
16229 protocol
= ZEBRA_ROUTE_TABLE
;
16231 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16232 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16234 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16235 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16237 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16240 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16241 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16242 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16243 "Redistribute information from another routing protocol\n"
16244 "Open Shortest Path First (OSPFv2)\n"
16245 "Non-main Kernel Routing Table\n"
16246 "Instance ID/Table ID\n"
16247 "Metric for redistributed routes\n"
16248 "Default metric\n")
16250 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16251 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16252 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16253 "Redistribute information from another routing protocol\n"
16254 "Open Shortest Path First (OSPFv2)\n"
16255 "Non-main Kernel Routing Table\n"
16256 "Instance ID/Table ID\n"
16257 "Route map reference\n"
16258 "Pointer to route-map entries\n"
16259 "Metric for redistributed routes\n"
16260 "Default metric\n")
16262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16263 int idx_ospf_table
= 1;
16264 int idx_number
= 2;
16266 int idx_number_2
= 6;
16268 struct bgp_redist
*red
;
16269 unsigned short instance
;
16272 struct route_map
*route_map
=
16273 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16275 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16276 protocol
= ZEBRA_ROUTE_OSPF
;
16278 protocol
= ZEBRA_ROUTE_TABLE
;
16280 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16281 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16283 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16285 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16286 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16288 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16292 bgp_redistribute_ipv4_ospf_rmap_metric
,
16293 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16294 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16295 "Redistribute information from another routing protocol\n"
16296 "Open Shortest Path First (OSPFv2)\n"
16297 "Non-main Kernel Routing Table\n"
16298 "Instance ID/Table ID\n"
16299 "Route map reference\n"
16300 "Pointer to route-map entries\n"
16301 "Metric for redistributed routes\n"
16302 "Default metric\n")
16304 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16305 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16306 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16307 "Redistribute information from another routing protocol\n"
16308 "Open Shortest Path First (OSPFv2)\n"
16309 "Non-main Kernel Routing Table\n"
16310 "Instance ID/Table ID\n"
16311 "Metric for redistributed routes\n"
16313 "Route map reference\n"
16314 "Pointer to route-map entries\n")
16316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16317 int idx_ospf_table
= 1;
16318 int idx_number
= 2;
16319 int idx_number_2
= 4;
16322 struct bgp_redist
*red
;
16323 unsigned short instance
;
16326 struct route_map
*route_map
=
16327 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16329 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16330 protocol
= ZEBRA_ROUTE_OSPF
;
16332 protocol
= ZEBRA_ROUTE_TABLE
;
16334 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16335 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16337 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16338 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16341 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16342 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16346 bgp_redistribute_ipv4_ospf_metric_rmap
,
16347 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16348 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16349 "Redistribute information from another routing protocol\n"
16350 "Open Shortest Path First (OSPFv2)\n"
16351 "Non-main Kernel Routing Table\n"
16352 "Instance ID/Table ID\n"
16353 "Metric for redistributed routes\n"
16355 "Route map reference\n"
16356 "Pointer to route-map entries\n")
16358 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16359 no_bgp_redistribute_ipv4_ospf_cmd
,
16360 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16362 "Redistribute information from another routing protocol\n"
16363 "Open Shortest Path First (OSPFv2)\n"
16364 "Non-main Kernel Routing Table\n"
16365 "Instance ID/Table ID\n"
16366 "Metric for redistributed routes\n"
16368 "Route map reference\n"
16369 "Pointer to route-map entries\n")
16371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16372 int idx_ospf_table
= 2;
16373 int idx_number
= 3;
16374 unsigned short instance
;
16377 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16378 protocol
= ZEBRA_ROUTE_OSPF
;
16380 protocol
= ZEBRA_ROUTE_TABLE
;
16382 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16383 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16387 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16388 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16390 "Redistribute information from another routing protocol\n"
16391 "Open Shortest Path First (OSPFv2)\n"
16392 "Non-main Kernel Routing Table\n"
16393 "Instance ID/Table ID\n"
16394 "Metric for redistributed routes\n"
16396 "Route map reference\n"
16397 "Pointer to route-map entries\n")
16399 DEFUN (no_bgp_redistribute_ipv4
,
16400 no_bgp_redistribute_ipv4_cmd
,
16401 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16403 "Redistribute information from another routing protocol\n"
16404 FRR_IP_REDIST_HELP_STR_BGPD
16405 "Metric for redistributed routes\n"
16407 "Route map reference\n"
16408 "Pointer to route-map entries\n")
16410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16411 int idx_protocol
= 2;
16414 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16416 vty_out(vty
, "%% Invalid route type\n");
16417 return CMD_WARNING_CONFIG_FAILED
;
16419 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16423 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16424 "no redistribute " FRR_IP_REDIST_STR_BGPD
16425 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16427 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16428 "Metric for redistributed routes\n"
16430 "Route map reference\n"
16431 "Pointer to route-map entries\n")
16433 DEFUN (bgp_redistribute_ipv6
,
16434 bgp_redistribute_ipv6_cmd
,
16435 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16436 "Redistribute information from another routing protocol\n"
16437 FRR_IP6_REDIST_HELP_STR_BGPD
)
16439 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16440 int idx_protocol
= 1;
16443 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16445 vty_out(vty
, "%% Invalid route type\n");
16446 return CMD_WARNING_CONFIG_FAILED
;
16449 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16450 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16453 DEFUN (bgp_redistribute_ipv6_rmap
,
16454 bgp_redistribute_ipv6_rmap_cmd
,
16455 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16456 "Redistribute information from another routing protocol\n"
16457 FRR_IP6_REDIST_HELP_STR_BGPD
16458 "Route map reference\n"
16459 "Pointer to route-map entries\n")
16461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16462 int idx_protocol
= 1;
16465 struct bgp_redist
*red
;
16467 struct route_map
*route_map
=
16468 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16470 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16472 vty_out(vty
, "%% Invalid route type\n");
16473 return CMD_WARNING_CONFIG_FAILED
;
16476 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16478 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16479 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16482 DEFUN (bgp_redistribute_ipv6_metric
,
16483 bgp_redistribute_ipv6_metric_cmd
,
16484 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16485 "Redistribute information from another routing protocol\n"
16486 FRR_IP6_REDIST_HELP_STR_BGPD
16487 "Metric for redistributed routes\n"
16488 "Default metric\n")
16490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16491 int idx_protocol
= 1;
16492 int idx_number
= 3;
16495 struct bgp_redist
*red
;
16498 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16500 vty_out(vty
, "%% Invalid route type\n");
16501 return CMD_WARNING_CONFIG_FAILED
;
16503 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16505 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16506 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16507 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16510 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16511 bgp_redistribute_ipv6_rmap_metric_cmd
,
16512 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16513 "Redistribute information from another routing protocol\n"
16514 FRR_IP6_REDIST_HELP_STR_BGPD
16515 "Route map reference\n"
16516 "Pointer to route-map entries\n"
16517 "Metric for redistributed routes\n"
16518 "Default metric\n")
16520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16521 int idx_protocol
= 1;
16523 int idx_number
= 5;
16526 struct bgp_redist
*red
;
16528 struct route_map
*route_map
=
16529 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16531 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16533 vty_out(vty
, "%% Invalid route type\n");
16534 return CMD_WARNING_CONFIG_FAILED
;
16536 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16538 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16540 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16541 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16543 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16546 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16547 bgp_redistribute_ipv6_metric_rmap_cmd
,
16548 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16549 "Redistribute information from another routing protocol\n"
16550 FRR_IP6_REDIST_HELP_STR_BGPD
16551 "Metric for redistributed routes\n"
16553 "Route map reference\n"
16554 "Pointer to route-map entries\n")
16556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16557 int idx_protocol
= 1;
16558 int idx_number
= 3;
16562 struct bgp_redist
*red
;
16564 struct route_map
*route_map
=
16565 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16567 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16569 vty_out(vty
, "%% Invalid route type\n");
16570 return CMD_WARNING_CONFIG_FAILED
;
16572 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16574 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16575 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16578 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16579 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16582 DEFUN (no_bgp_redistribute_ipv6
,
16583 no_bgp_redistribute_ipv6_cmd
,
16584 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16586 "Redistribute information from another routing protocol\n"
16587 FRR_IP6_REDIST_HELP_STR_BGPD
16588 "Metric for redistributed routes\n"
16590 "Route map reference\n"
16591 "Pointer to route-map entries\n")
16593 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16594 int idx_protocol
= 2;
16597 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16599 vty_out(vty
, "%% Invalid route type\n");
16600 return CMD_WARNING_CONFIG_FAILED
;
16603 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16606 /* Neighbor update tcp-mss. */
16607 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16608 const char *tcp_mss_str
)
16611 uint32_t tcp_mss_val
= 0;
16613 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16615 return CMD_WARNING_CONFIG_FAILED
;
16618 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16619 peer_tcp_mss_set(peer
, tcp_mss_val
);
16621 peer_tcp_mss_unset(peer
);
16624 return CMD_SUCCESS
;
16627 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16628 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16629 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16630 "TCP max segment size\n"
16633 int peer_index
= 1;
16637 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16638 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16639 argv
[mss_index
]->arg
);
16642 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16643 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16644 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16645 "TCP max segment size\n"
16648 int peer_index
= 2;
16651 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16652 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16655 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16656 "[no$no] bgp retain route-target all",
16658 "Retain BGP updates\n"
16659 "Retain BGP updates based on route-target values\n"
16660 "Retain all BGP updates\n")
16663 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16665 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16666 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16667 if (check
!= !no
) {
16669 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16670 [bgp_node_safi(vty
)],
16671 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16673 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16674 [bgp_node_safi(vty
)],
16675 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16676 /* trigger a flush to re-sync with ADJ-RIB-in */
16677 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16678 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16680 return CMD_SUCCESS
;
16683 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16684 afi_t afi
, safi_t safi
)
16688 /* Unicast redistribution only. */
16689 if (safi
!= SAFI_UNICAST
)
16692 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16693 /* Redistribute BGP does not make sense. */
16694 if (i
!= ZEBRA_ROUTE_BGP
) {
16695 struct list
*red_list
;
16696 struct listnode
*node
;
16697 struct bgp_redist
*red
;
16699 red_list
= bgp
->redist
[afi
][i
];
16703 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16704 /* "redistribute" configuration. */
16705 vty_out(vty
, " redistribute %s",
16706 zebra_route_string(i
));
16708 vty_out(vty
, " %d", red
->instance
);
16709 if (red
->redist_metric_flag
)
16710 vty_out(vty
, " metric %u",
16711 red
->redist_metric
);
16712 if (red
->rmap
.name
)
16713 vty_out(vty
, " route-map %s",
16715 vty_out(vty
, "\n");
16721 /* peer-group helpers for config-write */
16723 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16725 if (!peer_group_active(peer
)) {
16726 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16727 return !CHECK_FLAG(peer
->flags
, flag
);
16729 return !!CHECK_FLAG(peer
->flags
, flag
);
16732 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16735 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16738 if (!peer_group_active(peer
)) {
16739 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16740 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16742 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16745 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16748 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16749 uint8_t type
, int direct
)
16751 struct bgp_filter
*filter
;
16753 if (peer_group_active(peer
))
16754 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16757 filter
= &peer
->filter
[afi
][safi
];
16759 case PEER_FT_DISTRIBUTE_LIST
:
16760 return !!(filter
->dlist
[direct
].name
);
16761 case PEER_FT_FILTER_LIST
:
16762 return !!(filter
->aslist
[direct
].name
);
16763 case PEER_FT_PREFIX_LIST
:
16764 return !!(filter
->plist
[direct
].name
);
16765 case PEER_FT_ROUTE_MAP
:
16766 return !!(filter
->map
[direct
].name
);
16767 case PEER_FT_UNSUPPRESS_MAP
:
16768 return !!(filter
->usmap
.name
);
16769 case PEER_FT_ADVERTISE_MAP
:
16770 return !!(filter
->advmap
.aname
16771 && ((filter
->advmap
.condition
== direct
)
16772 && filter
->advmap
.cname
));
16778 /* Return true if the addpath type is set for peer and different from
16781 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16784 enum bgp_addpath_strat type
, g_type
;
16786 type
= peer
->addpath_type
[afi
][safi
];
16788 if (type
!= BGP_ADDPATH_NONE
) {
16789 if (peer_group_active(peer
)) {
16790 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16792 if (type
!= g_type
)
16804 /* This is part of the address-family block (unicast only) */
16805 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16809 uint32_t tovpn_sid_index
= 0;
16811 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16812 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16813 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16814 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16815 bgp
->vpn_policy
[afi
]
16816 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16818 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16819 bgp
->vpn_policy
[afi
]
16820 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16822 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16823 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16824 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16825 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16828 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16829 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16831 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16834 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16835 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16836 bgp
->vpn_policy
[afi
].tovpn_label
);
16840 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16841 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16842 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16843 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16844 } else if (tovpn_sid_index
!= 0) {
16845 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16849 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16850 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16851 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16853 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16854 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16856 char buf
[PREFIX_STRLEN
];
16857 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16858 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16861 vty_out(vty
, "%*snexthop vpn export %s\n",
16865 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16866 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16868 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16869 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16871 char *b
= ecommunity_ecom2str(
16872 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16873 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16874 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16875 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16877 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16878 char *b
= ecommunity_ecom2str(
16879 bgp
->vpn_policy
[afi
]
16880 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16881 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16882 ECOMMUNITY_ROUTE_TARGET
);
16883 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16884 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16886 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16887 char *b
= ecommunity_ecom2str(
16888 bgp
->vpn_policy
[afi
]
16889 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16890 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16891 ECOMMUNITY_ROUTE_TARGET
);
16892 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16893 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16897 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16898 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16899 bgp
->vpn_policy
[afi
]
16900 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16902 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16903 char *b
= ecommunity_ecom2str(
16904 bgp
->vpn_policy
[afi
]
16905 .import_redirect_rtlist
,
16906 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16907 ECOMMUNITY_ROUTE_TARGET
);
16909 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16910 != ECOMMUNITY_SIZE
)
16911 vty_out(vty
, "%*srt6 redirect import %s\n",
16914 vty_out(vty
, "%*srt redirect import %s\n",
16916 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16920 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16921 afi_t afi
, safi_t safi
)
16923 struct bgp_filter
*filter
;
16927 filter
= &peer
->filter
[afi
][safi
];
16929 /* distribute-list. */
16930 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16932 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16933 filter
->dlist
[FILTER_IN
].name
);
16935 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16937 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16938 filter
->dlist
[FILTER_OUT
].name
);
16941 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16943 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16944 filter
->plist
[FILTER_IN
].name
);
16946 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16948 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16949 filter
->plist
[FILTER_OUT
].name
);
16952 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16953 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16954 filter
->map
[RMAP_IN
].name
);
16956 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16958 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16959 filter
->map
[RMAP_OUT
].name
);
16961 /* unsuppress-map */
16962 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16963 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16964 filter
->usmap
.name
);
16966 /* advertise-map : always applied in OUT direction*/
16967 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16968 CONDITION_NON_EXIST
))
16970 " neighbor %s advertise-map %s non-exist-map %s\n",
16971 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16973 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16975 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16976 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16979 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16981 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16982 filter
->aslist
[FILTER_IN
].name
);
16984 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16986 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16987 filter
->aslist
[FILTER_OUT
].name
);
16990 /* BGP peer configuration display function. */
16991 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16994 struct peer
*g_peer
= NULL
;
16996 int if_pg_printed
= false;
16997 int if_ras_printed
= false;
16999 /* Skip dynamic neighbors. */
17000 if (peer_dynamic_neighbor(peer
))
17004 addr
= peer
->conf_if
;
17008 /************************************
17009 ****** Global to the neighbor ******
17010 ************************************/
17011 if (peer
->conf_if
) {
17012 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17013 vty_out(vty
, " neighbor %s interface v6only", addr
);
17015 vty_out(vty
, " neighbor %s interface", addr
);
17017 if (peer_group_active(peer
)) {
17018 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17019 if_pg_printed
= true;
17020 } else if (peer
->as_type
== AS_SPECIFIED
) {
17021 vty_out(vty
, " remote-as %u", peer
->as
);
17022 if_ras_printed
= true;
17023 } else if (peer
->as_type
== AS_INTERNAL
) {
17024 vty_out(vty
, " remote-as internal");
17025 if_ras_printed
= true;
17026 } else if (peer
->as_type
== AS_EXTERNAL
) {
17027 vty_out(vty
, " remote-as external");
17028 if_ras_printed
= true;
17031 vty_out(vty
, "\n");
17034 /* remote-as and peer-group */
17035 /* peer is a member of a peer-group */
17036 if (peer_group_active(peer
)) {
17037 g_peer
= peer
->group
->conf
;
17039 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17040 if (peer
->as_type
== AS_SPECIFIED
) {
17041 vty_out(vty
, " neighbor %s remote-as %u\n",
17043 } else if (peer
->as_type
== AS_INTERNAL
) {
17045 " neighbor %s remote-as internal\n",
17047 } else if (peer
->as_type
== AS_EXTERNAL
) {
17049 " neighbor %s remote-as external\n",
17054 /* For swpX peers we displayed the peer-group
17055 * via 'neighbor swpX interface peer-group PGNAME' */
17056 if (!if_pg_printed
)
17057 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17058 peer
->group
->name
);
17061 /* peer is NOT a member of a peer-group */
17063 /* peer is a peer-group, declare the peer-group */
17064 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17065 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17068 if (!if_ras_printed
) {
17069 if (peer
->as_type
== AS_SPECIFIED
) {
17070 vty_out(vty
, " neighbor %s remote-as %u\n",
17072 } else if (peer
->as_type
== AS_INTERNAL
) {
17074 " neighbor %s remote-as internal\n",
17076 } else if (peer
->as_type
== AS_EXTERNAL
) {
17078 " neighbor %s remote-as external\n",
17085 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17086 vty_out(vty
, " neighbor %s local-as %u", addr
,
17087 peer
->change_local_as
);
17088 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17089 vty_out(vty
, " no-prepend");
17090 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17091 vty_out(vty
, " replace-as");
17092 vty_out(vty
, "\n");
17097 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17101 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17102 if (peer
->tx_shutdown_message
)
17103 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17104 peer
->tx_shutdown_message
);
17106 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17109 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17110 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17111 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17114 if (peer
->bfd_config
)
17115 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17118 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17119 vty_out(vty
, " neighbor %s password %s\n", addr
,
17122 /* neighbor solo */
17123 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17124 if (!peer_group_active(peer
)) {
17125 vty_out(vty
, " neighbor %s solo\n", addr
);
17130 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17131 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17134 /* Local interface name */
17135 if (peer
->ifname
) {
17136 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17139 /* TCP max segment size */
17140 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17141 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17144 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17145 vty_out(vty
, " neighbor %s passive\n", addr
);
17147 /* ebgp-multihop */
17148 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17149 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17150 && peer
->ttl
== MAXTTL
)) {
17151 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17152 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17158 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17159 peer
->local_role
!= ROLE_UNDEFINED
)
17160 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17161 bgp_get_name_by_role(peer
->local_role
),
17162 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17166 /* ttl-security hops */
17167 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17168 if (!peer_group_active(peer
)
17169 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17170 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17171 addr
, peer
->gtsm_hops
);
17175 /* disable-connected-check */
17176 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17177 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17179 /* link-bw-encoding-ieee */
17180 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17181 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17184 /* extended-optional-parameters */
17185 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17186 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17189 /* enforce-first-as */
17190 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17191 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17193 /* update-source */
17194 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17195 if (peer
->update_source
)
17196 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17197 peer
->update_source
);
17198 else if (peer
->update_if
)
17199 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17203 /* advertisement-interval */
17204 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17205 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17209 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17210 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17211 peer
->keepalive
, peer
->holdtime
);
17213 /* timers connect */
17214 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17215 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17217 /* need special-case handling for changed default values due to
17218 * config profile / version (because there is no "timers bgp connect"
17219 * command, we need to save this per-peer :/)
17221 else if (!peer_group_active(peer
) && !peer
->connect
&&
17222 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17223 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17224 peer
->bgp
->default_connect_retry
);
17226 /* timers delayopen */
17227 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17228 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17230 /* Save config even though flag is not set if default values have been
17233 else if (!peer_group_active(peer
) && !peer
->delayopen
17234 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17235 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17236 peer
->bgp
->default_delayopen
);
17238 /* capability dynamic */
17239 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17240 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17242 /* capability extended-nexthop */
17243 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17244 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17247 " no neighbor %s capability extended-nexthop\n",
17249 else if (!peer
->conf_if
)
17251 " neighbor %s capability extended-nexthop\n",
17255 /* dont-capability-negotiation */
17256 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17257 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17259 /* override-capability */
17260 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17261 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17263 /* strict-capability-match */
17264 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17265 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17267 /* Sender side AS path loop detection. */
17268 if (peer
->as_path_loop_detection
)
17269 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17272 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17273 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17275 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17276 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17278 " neighbor %s graceful-restart-helper\n", addr
);
17279 } else if (CHECK_FLAG(
17280 peer
->peer_gr_new_status_flag
,
17281 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17283 " neighbor %s graceful-restart\n", addr
);
17285 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17286 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17288 peer
->peer_gr_new_status_flag
,
17289 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17290 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17296 /* BGP peer configuration display function. */
17297 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17298 struct peer
*peer
, afi_t afi
, safi_t safi
)
17300 struct peer
*g_peer
= NULL
;
17302 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17304 /* Skip dynamic neighbors. */
17305 if (peer_dynamic_neighbor(peer
))
17309 addr
= peer
->conf_if
;
17313 /************************************
17314 ****** Per AF to the neighbor ******
17315 ************************************/
17316 if (peer_group_active(peer
)) {
17317 g_peer
= peer
->group
->conf
;
17319 /* If the peer-group is active but peer is not, print a 'no
17321 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17322 vty_out(vty
, " no neighbor %s activate\n", addr
);
17325 /* If the peer-group is not active but peer is, print an
17327 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17328 vty_out(vty
, " neighbor %s activate\n", addr
);
17331 if (peer
->afc
[afi
][safi
]) {
17332 if (safi
== SAFI_ENCAP
)
17333 vty_out(vty
, " neighbor %s activate\n", addr
);
17334 else if (!bgp
->default_af
[afi
][safi
])
17335 vty_out(vty
, " neighbor %s activate\n", addr
);
17337 if (bgp
->default_af
[afi
][safi
])
17338 vty_out(vty
, " no neighbor %s activate\n",
17343 /* addpath TX knobs */
17344 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17345 switch (peer
->addpath_type
[afi
][safi
]) {
17346 case BGP_ADDPATH_ALL
:
17347 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17350 case BGP_ADDPATH_BEST_PER_AS
:
17352 " neighbor %s addpath-tx-bestpath-per-AS\n",
17355 case BGP_ADDPATH_MAX
:
17356 case BGP_ADDPATH_NONE
:
17361 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17362 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17364 /* ORF capability. */
17365 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17366 || peergroup_af_flag_check(peer
, afi
, safi
,
17367 PEER_FLAG_ORF_PREFIX_RM
)) {
17368 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17370 if (peergroup_af_flag_check(peer
, afi
, safi
,
17371 PEER_FLAG_ORF_PREFIX_SM
)
17372 && peergroup_af_flag_check(peer
, afi
, safi
,
17373 PEER_FLAG_ORF_PREFIX_RM
))
17374 vty_out(vty
, " both");
17375 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17376 PEER_FLAG_ORF_PREFIX_SM
))
17377 vty_out(vty
, " send");
17379 vty_out(vty
, " receive");
17380 vty_out(vty
, "\n");
17383 /* Route reflector client. */
17384 if (peergroup_af_flag_check(peer
, afi
, safi
,
17385 PEER_FLAG_REFLECTOR_CLIENT
)) {
17386 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17389 /* next-hop-self force */
17390 if (peergroup_af_flag_check(peer
, afi
, safi
,
17391 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17392 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17395 /* next-hop-self */
17396 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17397 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17400 /* remove-private-AS */
17401 if (peergroup_af_flag_check(peer
, afi
, safi
,
17402 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17403 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17407 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17408 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17409 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17413 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17414 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17415 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17418 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17419 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17420 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17424 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17425 vty_out(vty
, " neighbor %s as-override\n", addr
);
17428 /* send-community print. */
17429 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17430 PEER_FLAG_SEND_COMMUNITY
);
17431 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17432 PEER_FLAG_SEND_EXT_COMMUNITY
);
17433 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17434 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17436 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17437 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17440 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17443 " no neighbor %s send-community extended\n",
17447 vty_out(vty
, " no neighbor %s send-community large\n",
17451 /* Default information */
17452 if (peergroup_af_flag_check(peer
, afi
, safi
,
17453 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17454 vty_out(vty
, " neighbor %s default-originate", addr
);
17456 if (peer
->default_rmap
[afi
][safi
].name
)
17457 vty_out(vty
, " route-map %s",
17458 peer
->default_rmap
[afi
][safi
].name
);
17460 vty_out(vty
, "\n");
17463 /* Soft reconfiguration inbound. */
17464 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17465 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17469 /* maximum-prefix. */
17470 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17471 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17472 peer
->pmax
[afi
][safi
]);
17474 if (peer
->pmax_threshold
[afi
][safi
]
17475 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17476 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17477 if (peer_af_flag_check(peer
, afi
, safi
,
17478 PEER_FLAG_MAX_PREFIX_WARNING
))
17479 vty_out(vty
, " warning-only");
17480 if (peer
->pmax_restart
[afi
][safi
])
17481 vty_out(vty
, " restart %u",
17482 peer
->pmax_restart
[afi
][safi
]);
17483 if (peer_af_flag_check(peer
, afi
, safi
,
17484 PEER_FLAG_MAX_PREFIX_FORCE
))
17485 vty_out(vty
, " force");
17487 vty_out(vty
, "\n");
17490 /* maximum-prefix-out */
17491 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17492 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17493 addr
, peer
->pmax_out
[afi
][safi
]);
17495 /* Route server client. */
17496 if (peergroup_af_flag_check(peer
, afi
, safi
,
17497 PEER_FLAG_RSERVER_CLIENT
)) {
17498 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17501 /* Nexthop-local unchanged. */
17502 if (peergroup_af_flag_check(peer
, afi
, safi
,
17503 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17504 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17507 /* allowas-in <1-10> */
17508 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17509 if (peer_af_flag_check(peer
, afi
, safi
,
17510 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17511 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17512 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17513 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17515 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17516 peer
->allowas_in
[afi
][safi
]);
17521 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17522 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17525 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17526 char *soo_str
= ecommunity_ecom2str(
17527 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17529 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17530 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17534 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17535 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17536 peer
->weight
[afi
][safi
]);
17539 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17541 /* atribute-unchanged. */
17542 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17543 || (safi
!= SAFI_EVPN
17544 && peer_af_flag_check(peer
, afi
, safi
,
17545 PEER_FLAG_NEXTHOP_UNCHANGED
))
17546 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17548 if (!peer_group_active(peer
)
17549 || peergroup_af_flag_check(peer
, afi
, safi
,
17550 PEER_FLAG_AS_PATH_UNCHANGED
)
17551 || peergroup_af_flag_check(peer
, afi
, safi
,
17552 PEER_FLAG_NEXTHOP_UNCHANGED
)
17553 || peergroup_af_flag_check(peer
, afi
, safi
,
17554 PEER_FLAG_MED_UNCHANGED
)) {
17557 " neighbor %s attribute-unchanged%s%s%s\n",
17559 peer_af_flag_check(peer
, afi
, safi
,
17560 PEER_FLAG_AS_PATH_UNCHANGED
)
17563 peer_af_flag_check(peer
, afi
, safi
,
17564 PEER_FLAG_NEXTHOP_UNCHANGED
)
17567 peer_af_flag_check(peer
, afi
, safi
,
17568 PEER_FLAG_MED_UNCHANGED
)
17574 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
17575 vty_out(vty
, " neighbor %s optimal-route-reflection %s\n",
17576 addr
, peer
->orr_group_name
[afi
][safi
]);
17579 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17582 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17583 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17584 vty_out(vty
, " no bgp retain route-target all\n");
17587 /* Address family based peer configuration display. */
17588 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17592 struct peer_group
*group
;
17593 struct listnode
*node
, *nnode
;
17596 vty_frame(vty
, " !\n address-family ");
17597 if (afi
== AFI_IP
) {
17598 if (safi
== SAFI_UNICAST
)
17599 vty_frame(vty
, "ipv4 unicast");
17600 else if (safi
== SAFI_LABELED_UNICAST
)
17601 vty_frame(vty
, "ipv4 labeled-unicast");
17602 else if (safi
== SAFI_MULTICAST
)
17603 vty_frame(vty
, "ipv4 multicast");
17604 else if (safi
== SAFI_MPLS_VPN
)
17605 vty_frame(vty
, "ipv4 vpn");
17606 else if (safi
== SAFI_ENCAP
)
17607 vty_frame(vty
, "ipv4 encap");
17608 else if (safi
== SAFI_FLOWSPEC
)
17609 vty_frame(vty
, "ipv4 flowspec");
17610 } else if (afi
== AFI_IP6
) {
17611 if (safi
== SAFI_UNICAST
)
17612 vty_frame(vty
, "ipv6 unicast");
17613 else if (safi
== SAFI_LABELED_UNICAST
)
17614 vty_frame(vty
, "ipv6 labeled-unicast");
17615 else if (safi
== SAFI_MULTICAST
)
17616 vty_frame(vty
, "ipv6 multicast");
17617 else if (safi
== SAFI_MPLS_VPN
)
17618 vty_frame(vty
, "ipv6 vpn");
17619 else if (safi
== SAFI_ENCAP
)
17620 vty_frame(vty
, "ipv6 encap");
17621 else if (safi
== SAFI_FLOWSPEC
)
17622 vty_frame(vty
, "ipv6 flowspec");
17623 } else if (afi
== AFI_L2VPN
) {
17624 if (safi
== SAFI_EVPN
)
17625 vty_frame(vty
, "l2vpn evpn");
17627 vty_frame(vty
, "\n");
17629 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17631 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17633 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17635 /* BGP flag dampening. */
17636 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17637 bgp_config_write_damp(vty
, afi
, safi
);
17639 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17640 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17642 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17643 /* Do not display doppelganger peers */
17644 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17645 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17648 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17649 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17651 if (safi
== SAFI_EVPN
)
17652 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17654 if (safi
== SAFI_FLOWSPEC
)
17655 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17657 if (safi
== SAFI_MPLS_VPN
)
17658 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17660 if (safi
== SAFI_UNICAST
) {
17661 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17662 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17663 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17665 vty_out(vty
, " export vpn\n");
17667 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17668 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17670 vty_out(vty
, " import vpn\n");
17672 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17673 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17676 for (ALL_LIST_ELEMENTS_RO(
17677 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17679 vty_out(vty
, " import vrf %s\n", name
);
17683 /* Optimal Route Reflection */
17684 bgp_config_write_orr(vty
, bgp
, afi
, safi
);
17686 vty_endframe(vty
, " exit-address-family\n");
17689 int bgp_config_write(struct vty
*vty
)
17692 struct peer_group
*group
;
17694 struct listnode
*node
, *nnode
;
17695 struct listnode
*mnode
, *mnnode
;
17698 uint32_t tovpn_sid_index
= 0;
17700 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17701 vty_out(vty
, "bgp route-map delay-timer %u\n",
17702 bm
->rmap_update_timer
);
17704 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17705 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17706 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17707 vty_out(vty
, " %d", bm
->v_establish_wait
);
17708 vty_out(vty
, "\n");
17711 if (bm
->wait_for_fib
)
17712 vty_out(vty
, "bgp suppress-fib-pending\n");
17714 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17715 vty_out(vty
, "bgp graceful-shutdown\n");
17717 /* No-RIB (Zebra) option flag configuration */
17718 if (bgp_option_check(BGP_OPT_NO_FIB
))
17719 vty_out(vty
, "bgp no-rib\n");
17721 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17722 vty_out(vty
, "bgp send-extra-data zebra\n");
17724 /* BGP session DSCP value */
17725 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17726 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17728 /* BGP InQ limit */
17729 if (bm
->inq_limit
!= BM_DEFAULT_INQ_LIMIT
)
17730 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17732 /* BGP configuration. */
17733 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17735 /* skip all auto created vrf as they dont have user config */
17736 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17739 /* Router bgp ASN */
17740 vty_out(vty
, "router bgp %u", bgp
->as
);
17743 vty_out(vty
, " %s %s",
17744 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17745 ? "view" : "vrf", bgp
->name
);
17746 vty_out(vty
, "\n");
17748 /* BGP fast-external-failover. */
17749 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17750 vty_out(vty
, " no bgp fast-external-failover\n");
17752 /* BGP router ID. */
17753 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17754 vty_out(vty
, " bgp router-id %pI4\n",
17755 &bgp
->router_id_static
);
17757 /* Suppress fib pending */
17758 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17759 vty_out(vty
, " bgp suppress-fib-pending\n");
17761 /* BGP log-neighbor-changes. */
17762 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17763 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17764 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17765 CHECK_FLAG(bgp
->flags
,
17766 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17770 /* BGP configuration. */
17771 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17772 vty_out(vty
, " bgp always-compare-med\n");
17774 /* RFC8212 default eBGP policy. */
17775 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17776 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17777 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17778 CHECK_FLAG(bgp
->flags
,
17779 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17783 /* draft-ietf-idr-deprecate-as-set-confed-set */
17784 if (bgp
->reject_as_sets
)
17785 vty_out(vty
, " bgp reject-as-sets\n");
17787 /* Suppress duplicate updates if the route actually not changed
17789 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17790 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17791 vty_out(vty
, " %sbgp suppress-duplicates\n",
17792 CHECK_FLAG(bgp
->flags
,
17793 BGP_FLAG_SUPPRESS_DUPLICATES
)
17797 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17799 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17800 SAVE_BGP_HARD_ADMIN_RESET
)
17801 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17802 CHECK_FLAG(bgp
->flags
,
17803 BGP_FLAG_HARD_ADMIN_RESET
)
17807 /* BGP default <afi>-<safi> */
17808 FOREACH_AFI_SAFI (afi
, safi
) {
17809 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17810 if (!bgp
->default_af
[afi
][safi
])
17811 vty_out(vty
, " no bgp default %s\n",
17812 get_bgp_default_af_flag(afi
,
17814 } else if (bgp
->default_af
[afi
][safi
])
17815 vty_out(vty
, " bgp default %s\n",
17816 get_bgp_default_af_flag(afi
, safi
));
17819 /* BGP default local-preference. */
17820 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17821 vty_out(vty
, " bgp default local-preference %u\n",
17822 bgp
->default_local_pref
);
17824 /* BGP default show-hostname */
17825 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17826 != SAVE_BGP_SHOW_HOSTNAME
)
17827 vty_out(vty
, " %sbgp default show-hostname\n",
17828 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17832 /* BGP default show-nexthop-hostname */
17833 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17834 != SAVE_BGP_SHOW_HOSTNAME
)
17835 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17836 CHECK_FLAG(bgp
->flags
,
17837 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17841 /* BGP default subgroup-pkt-queue-max. */
17842 if (bgp
->default_subgroup_pkt_queue_max
17843 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17844 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17845 bgp
->default_subgroup_pkt_queue_max
);
17847 /* BGP client-to-client reflection. */
17848 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17849 vty_out(vty
, " no bgp client-to-client reflection\n");
17851 /* BGP cluster ID. */
17852 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17853 vty_out(vty
, " bgp cluster-id %pI4\n",
17856 /* Disable ebgp connected nexthop check */
17857 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17859 " bgp disable-ebgp-connected-route-check\n");
17861 /* Confederation identifier*/
17862 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17863 vty_out(vty
, " bgp confederation identifier %u\n",
17866 /* Confederation peer */
17867 if (bgp
->confed_peers_cnt
> 0) {
17870 vty_out(vty
, " bgp confederation peers");
17872 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17873 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17875 vty_out(vty
, "\n");
17878 /* BGP deterministic-med. */
17879 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17880 != SAVE_BGP_DETERMINISTIC_MED
)
17881 vty_out(vty
, " %sbgp deterministic-med\n",
17882 CHECK_FLAG(bgp
->flags
,
17883 BGP_FLAG_DETERMINISTIC_MED
)
17887 /* BGP update-delay. */
17888 bgp_config_write_update_delay(vty
, bgp
);
17890 if (bgp
->v_maxmed_onstartup
17891 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17892 vty_out(vty
, " bgp max-med on-startup %u",
17893 bgp
->v_maxmed_onstartup
);
17894 if (bgp
->maxmed_onstartup_value
17895 != BGP_MAXMED_VALUE_DEFAULT
)
17896 vty_out(vty
, " %u",
17897 bgp
->maxmed_onstartup_value
);
17898 vty_out(vty
, "\n");
17900 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17901 vty_out(vty
, " bgp max-med administrative");
17902 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17903 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17904 vty_out(vty
, "\n");
17908 bgp_config_write_wpkt_quanta(vty
, bgp
);
17910 bgp_config_write_rpkt_quanta(vty
, bgp
);
17912 /* coalesce time */
17913 bgp_config_write_coalesce_time(vty
, bgp
);
17915 /* BGP per-instance graceful-shutdown */
17916 /* BGP-wide settings and per-instance settings are mutually
17919 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17920 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17921 vty_out(vty
, " bgp graceful-shutdown\n");
17923 /* Long-lived Graceful Restart */
17924 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17926 " bgp long-lived-graceful-restart stale-time %u\n",
17927 bgp
->llgr_stale_time
);
17929 /* BGP graceful-restart. */
17930 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17932 " bgp graceful-restart stalepath-time %u\n",
17933 bgp
->stalepath_time
);
17935 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17936 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17937 bgp
->restart_time
);
17939 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17940 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17941 vty_out(vty
, " %sbgp graceful-restart notification\n",
17942 CHECK_FLAG(bgp
->flags
,
17943 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17947 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17949 " bgp graceful-restart select-defer-time %u\n",
17950 bgp
->select_defer_time
);
17952 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17953 vty_out(vty
, " bgp graceful-restart\n");
17955 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17956 vty_out(vty
, " bgp graceful-restart-disable\n");
17958 /* BGP graceful-restart Preserve State F bit. */
17959 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17961 " bgp graceful-restart preserve-fw-state\n");
17963 /* BGP TCP keepalive */
17964 bgp_config_tcp_keepalive(vty
, bgp
);
17966 /* Stale timer for RIB */
17967 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17969 " bgp graceful-restart rib-stale-time %u\n",
17970 bgp
->rib_stale_time
);
17972 /* BGP bestpath method. */
17973 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17974 vty_out(vty
, " bgp bestpath as-path ignore\n");
17975 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17976 vty_out(vty
, " bgp bestpath as-path confed\n");
17978 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17979 if (CHECK_FLAG(bgp
->flags
,
17980 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17982 " bgp bestpath as-path multipath-relax as-set\n");
17985 " bgp bestpath as-path multipath-relax\n");
17989 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17991 " bgp route-reflector allow-outbound-policy\n");
17993 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17994 vty_out(vty
, " bgp bestpath compare-routerid\n");
17995 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17996 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17997 vty_out(vty
, " bgp bestpath med");
17998 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17999 vty_out(vty
, " confed");
18000 if (CHECK_FLAG(bgp
->flags
,
18001 BGP_FLAG_MED_MISSING_AS_WORST
))
18002 vty_out(vty
, " missing-as-worst");
18003 vty_out(vty
, "\n");
18006 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18008 " bgp bestpath peer-type multipath-relax\n");
18010 /* Link bandwidth handling. */
18011 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18012 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18013 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18014 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18015 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18016 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18018 /* BGP network import check. */
18019 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18020 != SAVE_BGP_IMPORT_CHECK
)
18021 vty_out(vty
, " %sbgp network import-check\n",
18022 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18026 /* BGP timers configuration. */
18027 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18028 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18029 vty_out(vty
, " timers bgp %u %u\n",
18030 bgp
->default_keepalive
, bgp
->default_holdtime
);
18032 /* BGP minimum holdtime configuration. */
18033 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18034 && bgp
->default_min_holdtime
!= 0)
18035 vty_out(vty
, " bgp minimum-holdtime %u\n",
18036 bgp
->default_min_holdtime
);
18038 /* Conditional advertisement timer configuration */
18039 if (bgp
->condition_check_period
18040 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18042 " bgp conditional-advertisement timer %u\n",
18043 bgp
->condition_check_period
);
18046 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18047 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18050 /* Normal neighbor configuration. */
18051 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18052 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18053 bgp_config_write_peer_global(vty
, bgp
, peer
);
18056 /* listen range and limit for dynamic BGP neighbors */
18057 bgp_config_write_listen(vty
, bgp
);
18060 * BGP default autoshutdown neighbors
18062 * This must be placed after any peer and peer-group
18063 * configuration, to avoid setting all peers to shutdown after
18064 * a daemon restart, which is undesired behavior. (see #2286)
18066 if (bgp
->autoshutdown
)
18067 vty_out(vty
, " bgp default shutdown\n");
18069 /* BGP instance administrative shutdown */
18070 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18071 vty_out(vty
, " bgp shutdown\n");
18073 if (bgp
->allow_martian
)
18074 vty_out(vty
, " bgp allow-martian-nexthop\n");
18076 if (bgp
->fast_convergence
)
18077 vty_out(vty
, " bgp fast-convergence\n");
18079 if (bgp
->srv6_enabled
) {
18080 vty_frame(vty
, " !\n segment-routing srv6\n");
18081 if (strlen(bgp
->srv6_locator_name
))
18082 vty_out(vty
, " locator %s\n",
18083 bgp
->srv6_locator_name
);
18084 vty_endframe(vty
, " exit\n");
18087 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18088 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18089 vty_out(vty
, " sid vpn per-vrf export auto\n");
18090 } else if (tovpn_sid_index
!= 0) {
18091 vty_out(vty
, " sid vpn per-vrf export %d\n",
18095 /* IPv4 unicast configuration. */
18096 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18098 /* IPv4 multicast configuration. */
18099 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18101 /* IPv4 labeled-unicast configuration. */
18102 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18104 /* IPv4 VPN configuration. */
18105 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18107 /* ENCAPv4 configuration. */
18108 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18110 /* FLOWSPEC v4 configuration. */
18111 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18113 /* IPv6 unicast configuration. */
18114 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18116 /* IPv6 multicast configuration. */
18117 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18119 /* IPv6 labeled-unicast configuration. */
18120 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18121 SAFI_LABELED_UNICAST
);
18123 /* IPv6 VPN configuration. */
18124 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18126 /* ENCAPv6 configuration. */
18127 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18129 /* FLOWSPEC v6 configuration. */
18130 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18132 /* EVPN configuration. */
18133 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18135 hook_call(bgp_inst_config_write
, bgp
, vty
);
18137 #ifdef ENABLE_BGP_VNC
18138 bgp_rfapi_cfg_write(vty
, bgp
);
18141 vty_out(vty
, "exit\n");
18142 vty_out(vty
, "!\n");
18148 /* BGP node structure. */
18149 static struct cmd_node bgp_node
= {
18152 .parent_node
= CONFIG_NODE
,
18153 .prompt
= "%s(config-router)# ",
18154 .config_write
= bgp_config_write
,
18157 static struct cmd_node bgp_ipv4_unicast_node
= {
18158 .name
= "bgp ipv4 unicast",
18159 .node
= BGP_IPV4_NODE
,
18160 .parent_node
= BGP_NODE
,
18161 .prompt
= "%s(config-router-af)# ",
18165 static struct cmd_node bgp_ipv4_multicast_node
= {
18166 .name
= "bgp ipv4 multicast",
18167 .node
= BGP_IPV4M_NODE
,
18168 .parent_node
= BGP_NODE
,
18169 .prompt
= "%s(config-router-af)# ",
18173 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18174 .name
= "bgp ipv4 labeled unicast",
18175 .node
= BGP_IPV4L_NODE
,
18176 .parent_node
= BGP_NODE
,
18177 .prompt
= "%s(config-router-af)# ",
18181 static struct cmd_node bgp_ipv6_unicast_node
= {
18182 .name
= "bgp ipv6 unicast",
18183 .node
= BGP_IPV6_NODE
,
18184 .parent_node
= BGP_NODE
,
18185 .prompt
= "%s(config-router-af)# ",
18189 static struct cmd_node bgp_ipv6_multicast_node
= {
18190 .name
= "bgp ipv6 multicast",
18191 .node
= BGP_IPV6M_NODE
,
18192 .parent_node
= BGP_NODE
,
18193 .prompt
= "%s(config-router-af)# ",
18197 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18198 .name
= "bgp ipv6 labeled unicast",
18199 .node
= BGP_IPV6L_NODE
,
18200 .parent_node
= BGP_NODE
,
18201 .prompt
= "%s(config-router-af)# ",
18205 static struct cmd_node bgp_vpnv4_node
= {
18206 .name
= "bgp vpnv4",
18207 .node
= BGP_VPNV4_NODE
,
18208 .parent_node
= BGP_NODE
,
18209 .prompt
= "%s(config-router-af)# ",
18213 static struct cmd_node bgp_vpnv6_node
= {
18214 .name
= "bgp vpnv6",
18215 .node
= BGP_VPNV6_NODE
,
18216 .parent_node
= BGP_NODE
,
18217 .prompt
= "%s(config-router-af-vpnv6)# ",
18221 static struct cmd_node bgp_evpn_node
= {
18222 .name
= "bgp evpn",
18223 .node
= BGP_EVPN_NODE
,
18224 .parent_node
= BGP_NODE
,
18225 .prompt
= "%s(config-router-evpn)# ",
18229 static struct cmd_node bgp_evpn_vni_node
= {
18230 .name
= "bgp evpn vni",
18231 .node
= BGP_EVPN_VNI_NODE
,
18232 .parent_node
= BGP_EVPN_NODE
,
18233 .prompt
= "%s(config-router-af-vni)# ",
18236 static struct cmd_node bgp_flowspecv4_node
= {
18237 .name
= "bgp ipv4 flowspec",
18238 .node
= BGP_FLOWSPECV4_NODE
,
18239 .parent_node
= BGP_NODE
,
18240 .prompt
= "%s(config-router-af)# ",
18244 static struct cmd_node bgp_flowspecv6_node
= {
18245 .name
= "bgp ipv6 flowspec",
18246 .node
= BGP_FLOWSPECV6_NODE
,
18247 .parent_node
= BGP_NODE
,
18248 .prompt
= "%s(config-router-af-vpnv6)# ",
18252 static struct cmd_node bgp_srv6_node
= {
18253 .name
= "bgp srv6",
18254 .node
= BGP_SRV6_NODE
,
18255 .parent_node
= BGP_NODE
,
18256 .prompt
= "%s(config-router-srv6)# ",
18259 static void community_list_vty(void);
18261 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18264 struct peer_group
*group
;
18265 struct listnode
*lnbgp
, *lnpeer
;
18267 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18268 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18270 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18274 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18278 struct listnode
*lnbgp
, *lnpeer
;
18280 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18281 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18282 /* only provide suggestions on the appropriate input
18284 * they'll otherwise show up multiple times */
18285 enum cmd_token_type match_type
;
18286 char *name
= peer
->host
;
18288 if (peer
->conf_if
) {
18289 match_type
= VARIABLE_TKN
;
18290 name
= peer
->conf_if
;
18291 } else if (strchr(peer
->host
, ':'))
18292 match_type
= IPV6_TKN
;
18294 match_type
= IPV4_TKN
;
18296 if (token
->type
!= match_type
)
18299 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18304 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18306 bgp_ac_peer(comps
, token
);
18308 if (token
->type
== VARIABLE_TKN
)
18309 bgp_ac_peergroup(comps
, token
);
18312 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18313 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18314 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18315 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18316 {.completions
= NULL
}};
18318 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18319 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18320 {.completions
= NULL
} };
18322 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18324 static struct thread
*t_bgp_cfg
;
18326 bool bgp_config_inprocess(void)
18328 return thread_is_scheduled(t_bgp_cfg
);
18331 static void bgp_config_finish(struct thread
*t
)
18333 struct listnode
*node
;
18336 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18337 hook_call(bgp_config_end
, bgp
);
18340 static void bgp_config_start(void)
18342 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18343 THREAD_OFF(t_bgp_cfg
);
18344 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18345 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18348 /* When we receive a hook the configuration is read,
18349 * we start a timer to make sure we postpone sending
18350 * EoR before route-maps are processed.
18351 * This is especially valid if using `bgp route-map delay-timer`.
18353 static void bgp_config_end(void)
18355 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18356 uint32_t bgp_post_config_delay
=
18357 thread_is_scheduled(bm
->t_rmap_update
)
18358 ? thread_timer_remain_second(bm
->t_rmap_update
)
18359 : BGP_POST_CONFIG_DELAY_SECONDS
;
18361 /* If BGP config processing thread isn't running, then
18362 * we can return and rely it's properly handled.
18364 if (!bgp_config_inprocess())
18367 THREAD_OFF(t_bgp_cfg
);
18369 /* Start a new timer to make sure we don't send EoR
18370 * before route-maps are processed.
18372 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18373 bgp_post_config_delay
, &t_bgp_cfg
);
18376 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18379 struct interface
*ifp
;
18380 struct bgp_interface
*iifp
;
18382 FOR_ALL_INTERFACES (vrf
, ifp
) {
18387 if_vty_config_start(vty
, ifp
);
18389 if (CHECK_FLAG(iifp
->flags
,
18390 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18391 vty_out(vty
, " mpls bgp forwarding\n");
18395 if_vty_config_end(vty
);
18401 /* Configuration write function for bgpd. */
18402 static int config_write_interface(struct vty
*vty
)
18405 struct vrf
*vrf
= NULL
;
18407 /* Display all VRF aware OSPF interface configuration */
18408 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18409 write
+= config_write_interface_one(vty
, vrf
);
18415 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18416 "[no$no] mpls bgp forwarding",
18417 NO_STR MPLS_STR BGP_STR
18418 "Enable MPLS forwarding for eBGP directly connected peers\n")
18421 struct bgp_interface
*iifp
;
18423 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18426 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18427 return CMD_WARNING_CONFIG_FAILED
;
18429 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18430 if (check
!= !no
) {
18432 UNSET_FLAG(iifp
->flags
,
18433 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18435 SET_FLAG(iifp
->flags
,
18436 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18437 /* trigger a nht update on eBGP sessions */
18438 if (if_is_operative(ifp
))
18439 bgp_nht_ifp_up(ifp
);
18441 return CMD_SUCCESS
;
18444 DEFPY (bgp_inq_limit
,
18446 "bgp input-queue-limit (1-4294967295)$limit",
18448 "Set the BGP Input Queue limit for all peers when message parsing\n"
18449 "Input-Queue limit\n")
18451 bm
->inq_limit
= limit
;
18453 return CMD_SUCCESS
;
18456 DEFPY (no_bgp_inq_limit
,
18457 no_bgp_inq_limit_cmd
,
18458 "no bgp input-queue-limit [(1-4294967295)$limit]",
18461 "Set the BGP Input Queue limit for all peers when message parsing\n"
18462 "Input-Queue limit\n")
18464 bm
->inq_limit
= BM_DEFAULT_INQ_LIMIT
;
18466 return CMD_SUCCESS
;
18469 /* Initialization of BGP interface. */
18470 static void bgp_vty_if_init(void)
18472 /* Install interface node. */
18473 if_cmd_init(config_write_interface
);
18475 /* "mpls bgp forwarding" commands. */
18476 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18479 void bgp_vty_init(void)
18481 cmd_variable_handler_register(bgp_var_neighbor
);
18482 cmd_variable_handler_register(bgp_var_peergroup
);
18484 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18486 /* Install bgp top node. */
18487 install_node(&bgp_node
);
18488 install_node(&bgp_ipv4_unicast_node
);
18489 install_node(&bgp_ipv4_multicast_node
);
18490 install_node(&bgp_ipv4_labeled_unicast_node
);
18491 install_node(&bgp_ipv6_unicast_node
);
18492 install_node(&bgp_ipv6_multicast_node
);
18493 install_node(&bgp_ipv6_labeled_unicast_node
);
18494 install_node(&bgp_vpnv4_node
);
18495 install_node(&bgp_vpnv6_node
);
18496 install_node(&bgp_evpn_node
);
18497 install_node(&bgp_evpn_vni_node
);
18498 install_node(&bgp_flowspecv4_node
);
18499 install_node(&bgp_flowspecv6_node
);
18500 install_node(&bgp_srv6_node
);
18502 /* Install default VTY commands to new nodes. */
18503 install_default(BGP_NODE
);
18504 install_default(BGP_IPV4_NODE
);
18505 install_default(BGP_IPV4M_NODE
);
18506 install_default(BGP_IPV4L_NODE
);
18507 install_default(BGP_IPV6_NODE
);
18508 install_default(BGP_IPV6M_NODE
);
18509 install_default(BGP_IPV6L_NODE
);
18510 install_default(BGP_VPNV4_NODE
);
18511 install_default(BGP_VPNV6_NODE
);
18512 install_default(BGP_FLOWSPECV4_NODE
);
18513 install_default(BGP_FLOWSPECV6_NODE
);
18514 install_default(BGP_EVPN_NODE
);
18515 install_default(BGP_EVPN_VNI_NODE
);
18516 install_default(BGP_SRV6_NODE
);
18518 /* "global bgp inq-limit command */
18519 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18520 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18522 /* "bgp local-mac" hidden commands. */
18523 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18524 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18526 /* "bgp suppress-fib-pending" global */
18527 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18529 /* bgp route-map delay-timer commands. */
18530 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18531 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18533 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18535 /* bgp fast-convergence command */
18536 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18537 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18539 /* global bgp update-delay command */
18540 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18541 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18543 /* global bgp graceful-shutdown command */
18544 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18545 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18547 /* Dummy commands (Currently not supported) */
18548 install_element(BGP_NODE
, &no_synchronization_cmd
);
18549 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18551 /* "router bgp" commands. */
18552 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18554 /* "no router bgp" commands. */
18555 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18557 /* "bgp session-dscp command */
18558 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18559 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18561 /* "bgp router-id" commands. */
18562 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18563 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18565 /* "bgp suppress-fib-pending" command */
18566 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18568 /* "bgp cluster-id" commands. */
18569 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18570 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18572 /* "bgp no-rib" commands. */
18573 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18574 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18576 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18578 /* "bgp confederation" commands. */
18579 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18580 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18582 /* "bgp confederation peers" commands. */
18583 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18584 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18586 /* bgp max-med command */
18587 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18588 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18589 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18590 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18591 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18593 /* "neighbor role" commands. */
18594 install_element(BGP_NODE
, &neighbor_role_cmd
);
18595 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18596 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18598 /* bgp disable-ebgp-connected-nh-check */
18599 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18600 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18602 /* bgp update-delay command */
18603 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18604 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18606 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18607 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18609 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18610 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18612 /* "maximum-paths" commands. */
18613 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18614 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18615 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18616 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18617 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18618 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18619 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18620 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18621 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18622 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18623 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18624 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18625 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18626 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18627 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18629 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18630 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18631 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18632 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18633 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18634 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18635 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18636 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18637 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18638 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18640 /* "timers bgp" commands. */
18641 install_element(BGP_NODE
, &bgp_timers_cmd
);
18642 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18644 /* "minimum-holdtime" commands. */
18645 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18646 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18648 /* route-map delay-timer commands - per instance for backwards compat.
18650 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18651 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18653 /* "bgp client-to-client reflection" commands */
18654 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18655 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18657 /* "bgp always-compare-med" commands */
18658 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18659 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18661 /* bgp ebgp-requires-policy */
18662 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18663 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18665 /* bgp suppress-duplicates */
18666 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18667 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18669 /* bgp reject-as-sets */
18670 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18671 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18673 /* "bgp deterministic-med" commands */
18674 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18675 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18677 /* "bgp graceful-restart" command */
18678 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18679 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18681 /* "bgp graceful-restart-disable" command */
18682 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18683 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18685 /* "neighbor a:b:c:d graceful-restart" command */
18686 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18687 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18689 /* "neighbor a:b:c:d graceful-restart-disable" command */
18690 install_element(BGP_NODE
,
18691 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18692 install_element(BGP_NODE
,
18693 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18695 /* "neighbor a:b:c:d graceful-restart-helper" command */
18696 install_element(BGP_NODE
,
18697 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18698 install_element(BGP_NODE
,
18699 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18701 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18702 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18703 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18704 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18705 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18706 install_element(BGP_NODE
,
18707 &no_bgp_graceful_restart_select_defer_time_cmd
);
18708 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18709 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18710 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18712 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18713 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18714 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18715 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18717 /* "bgp inq-limit command */
18718 install_element(BGP_NODE
, &bgp_inq_limit_cmd
);
18719 install_element(BGP_NODE
, &no_bgp_inq_limit_cmd
);
18721 /* "bgp graceful-shutdown" commands */
18722 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18723 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18725 /* "bgp hard-administrative-reset" commands */
18726 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18728 /* "bgp long-lived-graceful-restart" commands */
18729 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18730 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18732 /* "bgp fast-external-failover" commands */
18733 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18734 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18736 /* "bgp bestpath compare-routerid" commands */
18737 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18738 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18740 /* "bgp bestpath as-path ignore" commands */
18741 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18742 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18744 /* "bgp bestpath as-path confed" commands */
18745 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18746 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18748 /* "bgp bestpath as-path multipath-relax" commands */
18749 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18750 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18752 /* "bgp bestpath peer-type multipath-relax" commands */
18753 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18754 install_element(BGP_NODE
,
18755 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18757 /* "bgp log-neighbor-changes" commands */
18758 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18759 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18761 /* "bgp bestpath med" commands */
18762 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18763 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18765 /* "bgp bestpath bandwidth" commands */
18766 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18767 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18769 /* "no bgp default <afi>-<safi>" commands. */
18770 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18772 /* "bgp network import-check" commands. */
18773 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18774 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18775 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18777 /* "bgp default local-preference" commands. */
18778 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18779 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18781 /* bgp default show-hostname */
18782 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18783 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18785 /* bgp default show-nexthop-hostname */
18786 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18787 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18789 /* "bgp default subgroup-pkt-queue-max" commands. */
18790 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18791 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18793 /* bgp ibgp-allow-policy-mods command */
18794 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18795 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18797 /* "bgp listen limit" commands. */
18798 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18799 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18801 /* "bgp listen range" commands. */
18802 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18803 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18805 /* "bgp default shutdown" command */
18806 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18808 /* "bgp shutdown" commands */
18809 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18810 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18811 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18812 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18814 /* "neighbor remote-as" commands. */
18815 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18816 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18817 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18818 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18819 install_element(BGP_NODE
,
18820 &neighbor_interface_v6only_config_remote_as_cmd
);
18821 install_element(BGP_NODE
, &no_neighbor_cmd
);
18822 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18824 /* "neighbor peer-group" commands. */
18825 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18826 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18827 install_element(BGP_NODE
,
18828 &no_neighbor_interface_peer_group_remote_as_cmd
);
18830 /* "neighbor local-as" commands. */
18831 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18832 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18833 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18834 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18836 /* "neighbor solo" commands. */
18837 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18838 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18840 /* "neighbor password" commands. */
18841 install_element(BGP_NODE
, &neighbor_password_cmd
);
18842 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18844 /* "neighbor activate" commands. */
18845 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18846 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18847 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18848 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18849 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18850 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18851 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18852 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18853 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18854 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18855 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18856 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18858 /* "no neighbor activate" commands. */
18859 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18860 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18861 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18862 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18863 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18864 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18865 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18866 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18867 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18868 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18869 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18870 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18872 /* "neighbor peer-group" set commands. */
18873 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18874 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18875 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18876 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18877 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18878 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18879 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18880 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18881 install_element(BGP_FLOWSPECV4_NODE
,
18882 &neighbor_set_peer_group_hidden_cmd
);
18883 install_element(BGP_FLOWSPECV6_NODE
,
18884 &neighbor_set_peer_group_hidden_cmd
);
18886 /* "no neighbor peer-group unset" commands. */
18887 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18888 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18889 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18890 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18891 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18892 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18893 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18894 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18895 install_element(BGP_FLOWSPECV4_NODE
,
18896 &no_neighbor_set_peer_group_hidden_cmd
);
18897 install_element(BGP_FLOWSPECV6_NODE
,
18898 &no_neighbor_set_peer_group_hidden_cmd
);
18900 /* "neighbor softreconfiguration inbound" commands.*/
18901 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18902 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18903 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18904 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18905 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18906 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18907 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18908 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18909 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18910 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18911 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18912 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18913 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18914 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18915 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18916 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18917 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18918 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18919 install_element(BGP_FLOWSPECV4_NODE
,
18920 &neighbor_soft_reconfiguration_cmd
);
18921 install_element(BGP_FLOWSPECV4_NODE
,
18922 &no_neighbor_soft_reconfiguration_cmd
);
18923 install_element(BGP_FLOWSPECV6_NODE
,
18924 &neighbor_soft_reconfiguration_cmd
);
18925 install_element(BGP_FLOWSPECV6_NODE
,
18926 &no_neighbor_soft_reconfiguration_cmd
);
18927 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18928 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18930 /* "neighbor attribute-unchanged" commands. */
18931 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18932 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18933 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18934 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18935 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18936 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18937 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18938 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18939 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18940 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18941 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18942 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18943 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18944 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18945 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18946 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18947 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18948 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18950 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18951 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18953 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18954 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18955 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18956 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18958 /* "nexthop-local unchanged" commands */
18959 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18960 install_element(BGP_IPV6_NODE
,
18961 &no_neighbor_nexthop_local_unchanged_cmd
);
18963 /* "neighbor next-hop-self" commands. */
18964 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18965 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18966 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18967 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18968 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18969 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18970 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18971 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18972 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18973 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18974 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18975 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18976 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18977 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18978 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18979 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18980 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18981 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18982 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18983 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18985 /* "neighbor next-hop-self force" commands. */
18986 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18987 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18988 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18989 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18990 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18991 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18992 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18993 install_element(BGP_IPV4_NODE
,
18994 &no_neighbor_nexthop_self_all_hidden_cmd
);
18995 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18996 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18997 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18998 install_element(BGP_IPV4M_NODE
,
18999 &no_neighbor_nexthop_self_all_hidden_cmd
);
19000 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19001 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19002 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19003 install_element(BGP_IPV4L_NODE
,
19004 &no_neighbor_nexthop_self_all_hidden_cmd
);
19005 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19006 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19007 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19008 install_element(BGP_IPV6_NODE
,
19009 &no_neighbor_nexthop_self_all_hidden_cmd
);
19010 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19011 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19012 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19013 install_element(BGP_IPV6M_NODE
,
19014 &no_neighbor_nexthop_self_all_hidden_cmd
);
19015 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19016 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19017 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19018 install_element(BGP_IPV6L_NODE
,
19019 &no_neighbor_nexthop_self_all_hidden_cmd
);
19020 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19021 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19022 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19023 install_element(BGP_VPNV4_NODE
,
19024 &no_neighbor_nexthop_self_all_hidden_cmd
);
19025 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19026 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19027 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19028 install_element(BGP_VPNV6_NODE
,
19029 &no_neighbor_nexthop_self_all_hidden_cmd
);
19030 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19031 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19033 /* "neighbor as-override" commands. */
19034 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19035 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19036 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19037 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19038 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19039 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19040 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19041 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19042 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19043 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19044 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19045 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19046 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19047 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19048 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19049 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19050 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19051 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19053 /* "neighbor remove-private-AS" commands. */
19054 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19055 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19056 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19057 install_element(BGP_NODE
,
19058 &no_neighbor_remove_private_as_all_hidden_cmd
);
19059 install_element(BGP_NODE
,
19060 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19061 install_element(BGP_NODE
,
19062 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19063 install_element(BGP_NODE
,
19064 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19067 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19068 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19069 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19070 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19071 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19072 install_element(BGP_IPV4_NODE
,
19073 &neighbor_remove_private_as_replace_as_cmd
);
19074 install_element(BGP_IPV4_NODE
,
19075 &no_neighbor_remove_private_as_replace_as_cmd
);
19076 install_element(BGP_IPV4_NODE
,
19077 &neighbor_remove_private_as_all_replace_as_cmd
);
19078 install_element(BGP_IPV4_NODE
,
19079 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19080 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19081 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19082 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19083 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19084 install_element(BGP_IPV4M_NODE
,
19085 &neighbor_remove_private_as_replace_as_cmd
);
19086 install_element(BGP_IPV4M_NODE
,
19087 &no_neighbor_remove_private_as_replace_as_cmd
);
19088 install_element(BGP_IPV4M_NODE
,
19089 &neighbor_remove_private_as_all_replace_as_cmd
);
19090 install_element(BGP_IPV4M_NODE
,
19091 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19092 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19093 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19094 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19095 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19096 install_element(BGP_IPV4L_NODE
,
19097 &neighbor_remove_private_as_replace_as_cmd
);
19098 install_element(BGP_IPV4L_NODE
,
19099 &no_neighbor_remove_private_as_replace_as_cmd
);
19100 install_element(BGP_IPV4L_NODE
,
19101 &neighbor_remove_private_as_all_replace_as_cmd
);
19102 install_element(BGP_IPV4L_NODE
,
19103 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19104 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19105 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19106 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19107 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19108 install_element(BGP_IPV6_NODE
,
19109 &neighbor_remove_private_as_replace_as_cmd
);
19110 install_element(BGP_IPV6_NODE
,
19111 &no_neighbor_remove_private_as_replace_as_cmd
);
19112 install_element(BGP_IPV6_NODE
,
19113 &neighbor_remove_private_as_all_replace_as_cmd
);
19114 install_element(BGP_IPV6_NODE
,
19115 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19116 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19117 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19118 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19119 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19120 install_element(BGP_IPV6M_NODE
,
19121 &neighbor_remove_private_as_replace_as_cmd
);
19122 install_element(BGP_IPV6M_NODE
,
19123 &no_neighbor_remove_private_as_replace_as_cmd
);
19124 install_element(BGP_IPV6M_NODE
,
19125 &neighbor_remove_private_as_all_replace_as_cmd
);
19126 install_element(BGP_IPV6M_NODE
,
19127 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19128 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19129 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19130 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19131 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19132 install_element(BGP_IPV6L_NODE
,
19133 &neighbor_remove_private_as_replace_as_cmd
);
19134 install_element(BGP_IPV6L_NODE
,
19135 &no_neighbor_remove_private_as_replace_as_cmd
);
19136 install_element(BGP_IPV6L_NODE
,
19137 &neighbor_remove_private_as_all_replace_as_cmd
);
19138 install_element(BGP_IPV6L_NODE
,
19139 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19140 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19141 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19142 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19143 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19144 install_element(BGP_VPNV4_NODE
,
19145 &neighbor_remove_private_as_replace_as_cmd
);
19146 install_element(BGP_VPNV4_NODE
,
19147 &no_neighbor_remove_private_as_replace_as_cmd
);
19148 install_element(BGP_VPNV4_NODE
,
19149 &neighbor_remove_private_as_all_replace_as_cmd
);
19150 install_element(BGP_VPNV4_NODE
,
19151 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19152 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19153 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19154 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19155 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19156 install_element(BGP_VPNV6_NODE
,
19157 &neighbor_remove_private_as_replace_as_cmd
);
19158 install_element(BGP_VPNV6_NODE
,
19159 &no_neighbor_remove_private_as_replace_as_cmd
);
19160 install_element(BGP_VPNV6_NODE
,
19161 &neighbor_remove_private_as_all_replace_as_cmd
);
19162 install_element(BGP_VPNV6_NODE
,
19163 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19165 /* "neighbor send-community" commands.*/
19166 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19167 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19168 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19169 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19170 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19171 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19172 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19173 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19174 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19175 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19176 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19177 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19178 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19179 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19180 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19181 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19182 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19183 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19184 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19185 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19186 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19187 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19188 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19189 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19190 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19191 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19192 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19193 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19194 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19195 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19196 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19197 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19198 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19199 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19200 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19201 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19203 /* "neighbor route-reflector" commands.*/
19204 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19205 install_element(BGP_NODE
,
19206 &no_neighbor_route_reflector_client_hidden_cmd
);
19207 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19208 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19209 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19210 install_element(BGP_IPV4M_NODE
,
19211 &no_neighbor_route_reflector_client_cmd
);
19212 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19213 install_element(BGP_IPV4L_NODE
,
19214 &no_neighbor_route_reflector_client_cmd
);
19215 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19216 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19217 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19218 install_element(BGP_IPV6M_NODE
,
19219 &no_neighbor_route_reflector_client_cmd
);
19220 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19221 install_element(BGP_IPV6L_NODE
,
19222 &no_neighbor_route_reflector_client_cmd
);
19223 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19224 install_element(BGP_VPNV4_NODE
,
19225 &no_neighbor_route_reflector_client_cmd
);
19226 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19227 install_element(BGP_VPNV6_NODE
,
19228 &no_neighbor_route_reflector_client_cmd
);
19229 install_element(BGP_FLOWSPECV4_NODE
,
19230 &neighbor_route_reflector_client_cmd
);
19231 install_element(BGP_FLOWSPECV4_NODE
,
19232 &no_neighbor_route_reflector_client_cmd
);
19233 install_element(BGP_FLOWSPECV6_NODE
,
19234 &neighbor_route_reflector_client_cmd
);
19235 install_element(BGP_FLOWSPECV6_NODE
,
19236 &no_neighbor_route_reflector_client_cmd
);
19237 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19238 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19240 /* "optimal-route-reflection" commands */
19241 install_element(BGP_IPV4_NODE
, &optimal_route_reflection_cmd
);
19242 install_element(BGP_IPV4M_NODE
, &optimal_route_reflection_cmd
);
19243 install_element(BGP_IPV4L_NODE
, &optimal_route_reflection_cmd
);
19244 install_element(BGP_IPV6_NODE
, &optimal_route_reflection_cmd
);
19245 install_element(BGP_IPV6M_NODE
, &optimal_route_reflection_cmd
);
19246 install_element(BGP_IPV6L_NODE
, &optimal_route_reflection_cmd
);
19247 install_element(BGP_VPNV4_NODE
, &optimal_route_reflection_cmd
);
19248 install_element(BGP_VPNV6_NODE
, &optimal_route_reflection_cmd
);
19249 install_element(BGP_FLOWSPECV4_NODE
, &optimal_route_reflection_cmd
);
19250 install_element(BGP_FLOWSPECV6_NODE
, &optimal_route_reflection_cmd
);
19251 install_element(BGP_EVPN_NODE
, &optimal_route_reflection_cmd
);
19253 /* "neighbor optimal-route-reflection" commands */
19254 install_element(BGP_IPV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19255 install_element(BGP_IPV4M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19256 install_element(BGP_IPV4L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19257 install_element(BGP_IPV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19258 install_element(BGP_IPV6M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19259 install_element(BGP_IPV6L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19260 install_element(BGP_VPNV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19261 install_element(BGP_VPNV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19262 install_element(BGP_FLOWSPECV4_NODE
,
19263 &neighbor_optimal_route_reflection_cmd
);
19264 install_element(BGP_FLOWSPECV6_NODE
,
19265 &neighbor_optimal_route_reflection_cmd
);
19266 install_element(BGP_EVPN_NODE
, &neighbor_optimal_route_reflection_cmd
);
19268 /* "neighbor route-server" commands.*/
19269 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19270 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19271 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19272 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19273 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19274 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19275 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19276 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19277 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19278 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19279 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19280 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19281 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19282 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19283 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19284 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19285 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19286 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19287 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19288 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19289 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19290 install_element(BGP_FLOWSPECV4_NODE
,
19291 &no_neighbor_route_server_client_cmd
);
19292 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19293 install_element(BGP_FLOWSPECV6_NODE
,
19294 &no_neighbor_route_server_client_cmd
);
19296 /* "neighbor disable-addpath-rx" commands. */
19297 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19298 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19299 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19300 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19301 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19302 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19303 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19304 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19305 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19306 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19307 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19308 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19309 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19310 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19311 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19312 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19314 /* "neighbor addpath-tx-all-paths" commands.*/
19315 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19316 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19317 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19318 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19319 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19320 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19321 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19322 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19323 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19324 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19325 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19326 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19327 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19328 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19329 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19330 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19331 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19332 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19334 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19335 install_element(BGP_NODE
,
19336 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19337 install_element(BGP_NODE
,
19338 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19339 install_element(BGP_IPV4_NODE
,
19340 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19341 install_element(BGP_IPV4_NODE
,
19342 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19343 install_element(BGP_IPV4M_NODE
,
19344 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19345 install_element(BGP_IPV4M_NODE
,
19346 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19347 install_element(BGP_IPV4L_NODE
,
19348 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19349 install_element(BGP_IPV4L_NODE
,
19350 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19351 install_element(BGP_IPV6_NODE
,
19352 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19353 install_element(BGP_IPV6_NODE
,
19354 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19355 install_element(BGP_IPV6M_NODE
,
19356 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19357 install_element(BGP_IPV6M_NODE
,
19358 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19359 install_element(BGP_IPV6L_NODE
,
19360 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19361 install_element(BGP_IPV6L_NODE
,
19362 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19363 install_element(BGP_VPNV4_NODE
,
19364 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19365 install_element(BGP_VPNV4_NODE
,
19366 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19367 install_element(BGP_VPNV6_NODE
,
19368 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19369 install_element(BGP_VPNV6_NODE
,
19370 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19372 /* "neighbor sender-as-path-loop-detection" commands. */
19373 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19374 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19376 /* "neighbor passive" commands. */
19377 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19378 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19381 /* "neighbor shutdown" commands. */
19382 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19383 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19384 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19385 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19386 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19387 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19389 /* "neighbor capability extended-nexthop" commands.*/
19390 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19391 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19393 /* "neighbor capability orf prefix-list" commands.*/
19394 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19395 install_element(BGP_NODE
,
19396 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19397 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19398 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19399 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19400 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19401 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19402 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19403 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19404 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19405 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19406 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19407 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19408 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19410 /* "neighbor capability dynamic" commands.*/
19411 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19412 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19414 /* "neighbor dont-capability-negotiate" commands. */
19415 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19416 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19418 /* "neighbor ebgp-multihop" commands. */
19419 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19420 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19421 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19423 /* "neighbor disable-connected-check" commands. */
19424 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19425 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19427 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19428 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19429 install_element(BGP_NODE
,
19430 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19432 /* "neighbor extended-optional-parameters" commands. */
19433 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19434 install_element(BGP_NODE
,
19435 &no_neighbor_extended_optional_parameters_cmd
);
19437 /* "neighbor enforce-first-as" commands. */
19438 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19439 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19441 /* "neighbor description" commands. */
19442 install_element(BGP_NODE
, &neighbor_description_cmd
);
19443 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19444 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19446 /* "neighbor update-source" commands. "*/
19447 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19448 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19450 /* "neighbor default-originate" commands. */
19451 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19452 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19453 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19454 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19455 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19456 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19457 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19458 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19459 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19460 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19461 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19462 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19463 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19464 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19465 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19466 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19467 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19468 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19469 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19470 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19471 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19473 /* "neighbor port" commands. */
19474 install_element(BGP_NODE
, &neighbor_port_cmd
);
19475 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19477 /* "neighbor weight" commands. */
19478 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19479 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19481 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19482 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19483 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19484 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19485 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19486 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19487 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19488 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19489 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19490 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19491 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19492 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19493 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19494 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19495 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19496 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19498 /* "neighbor override-capability" commands. */
19499 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19500 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19502 /* "neighbor strict-capability-match" commands. */
19503 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19504 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19506 /* "neighbor timers" commands. */
19507 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19508 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19510 /* "neighbor timers connect" commands. */
19511 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19512 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19514 /* "neighbor timers delayopen" commands. */
19515 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19516 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19518 /* "neighbor advertisement-interval" commands. */
19519 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19520 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19522 /* "neighbor interface" commands. */
19523 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19524 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19526 /* "neighbor distribute" commands. */
19527 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19528 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19529 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19530 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19531 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19532 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19533 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19534 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19535 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19536 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19537 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19538 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19539 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19540 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19541 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19542 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19543 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19544 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19546 /* "neighbor prefix-list" commands. */
19547 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19548 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19549 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19550 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19551 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19552 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19553 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19554 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19555 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19556 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19557 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19558 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19559 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19560 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19561 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19562 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19563 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19564 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19565 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19566 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19567 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19568 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19570 /* "neighbor filter-list" commands. */
19571 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19572 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19573 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19574 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19575 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19576 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19577 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19578 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19579 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19580 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19581 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19582 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19583 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19584 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19585 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19586 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19587 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19588 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19589 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19590 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19591 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19592 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19594 /* "neighbor route-map" commands. */
19595 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19596 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19597 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19598 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19599 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19600 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19601 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19602 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19603 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19604 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19605 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19606 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19607 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19608 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19609 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19610 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19611 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19612 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19613 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19614 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19615 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19616 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19617 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19618 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19620 /* "neighbor unsuppress-map" commands. */
19621 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19622 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19623 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19624 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19625 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19626 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19627 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19628 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19629 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19630 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19631 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19632 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19633 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19634 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19635 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19636 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19637 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19638 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19640 /* "neighbor advertise-map" commands. */
19641 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19642 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19643 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19644 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19645 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19646 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19647 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19648 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19649 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19650 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19652 /* neighbor maximum-prefix-out commands. */
19653 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19654 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19655 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19656 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19657 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19658 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19659 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19660 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19661 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19662 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19663 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19664 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19665 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19666 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19667 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19668 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19669 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19670 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19672 /* "neighbor maximum-prefix" commands. */
19673 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19674 install_element(BGP_NODE
,
19675 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19676 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19677 install_element(BGP_NODE
,
19678 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19679 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19680 install_element(BGP_NODE
,
19681 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19682 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19683 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19684 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19685 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19686 install_element(BGP_IPV4_NODE
,
19687 &neighbor_maximum_prefix_threshold_warning_cmd
);
19688 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19689 install_element(BGP_IPV4_NODE
,
19690 &neighbor_maximum_prefix_threshold_restart_cmd
);
19691 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19692 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19693 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19694 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19695 install_element(BGP_IPV4M_NODE
,
19696 &neighbor_maximum_prefix_threshold_warning_cmd
);
19697 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19698 install_element(BGP_IPV4M_NODE
,
19699 &neighbor_maximum_prefix_threshold_restart_cmd
);
19700 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19701 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19702 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19703 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19704 install_element(BGP_IPV4L_NODE
,
19705 &neighbor_maximum_prefix_threshold_warning_cmd
);
19706 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19707 install_element(BGP_IPV4L_NODE
,
19708 &neighbor_maximum_prefix_threshold_restart_cmd
);
19709 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19710 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19711 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19712 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19713 install_element(BGP_IPV6_NODE
,
19714 &neighbor_maximum_prefix_threshold_warning_cmd
);
19715 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19716 install_element(BGP_IPV6_NODE
,
19717 &neighbor_maximum_prefix_threshold_restart_cmd
);
19718 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19719 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19720 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19721 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19722 install_element(BGP_IPV6M_NODE
,
19723 &neighbor_maximum_prefix_threshold_warning_cmd
);
19724 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19725 install_element(BGP_IPV6M_NODE
,
19726 &neighbor_maximum_prefix_threshold_restart_cmd
);
19727 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19728 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19729 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19730 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19731 install_element(BGP_IPV6L_NODE
,
19732 &neighbor_maximum_prefix_threshold_warning_cmd
);
19733 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19734 install_element(BGP_IPV6L_NODE
,
19735 &neighbor_maximum_prefix_threshold_restart_cmd
);
19736 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19737 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19738 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19739 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19740 install_element(BGP_VPNV4_NODE
,
19741 &neighbor_maximum_prefix_threshold_warning_cmd
);
19742 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19743 install_element(BGP_VPNV4_NODE
,
19744 &neighbor_maximum_prefix_threshold_restart_cmd
);
19745 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19746 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19747 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19748 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19749 install_element(BGP_VPNV6_NODE
,
19750 &neighbor_maximum_prefix_threshold_warning_cmd
);
19751 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19752 install_element(BGP_VPNV6_NODE
,
19753 &neighbor_maximum_prefix_threshold_restart_cmd
);
19754 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19756 /* "neighbor allowas-in" */
19757 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19758 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19759 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19760 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19761 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19762 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19763 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19764 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19765 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19766 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19767 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19768 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19769 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19770 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19771 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19772 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19773 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19774 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19775 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19776 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19778 /* neighbor accept-own */
19779 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19780 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19782 /* "neighbor soo" */
19783 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19784 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19785 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19786 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19787 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19788 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19789 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19790 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19791 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19792 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19793 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19794 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19795 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19796 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19797 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19798 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19799 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19800 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19802 /* address-family commands. */
19803 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19804 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19805 #ifdef KEEP_OLD_VPN_COMMANDS
19806 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19807 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19808 #endif /* KEEP_OLD_VPN_COMMANDS */
19810 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19812 /* "exit-address-family" command. */
19813 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19814 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19815 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19816 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19817 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19818 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19819 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19820 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19821 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19822 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19823 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19825 /* BGP retain all route-target */
19826 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19827 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19829 /* "clear ip bgp commands" */
19830 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19832 /* clear ip bgp prefix */
19833 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19834 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19835 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19837 /* "show [ip] bgp summary" commands. */
19838 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19839 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19840 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19841 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19842 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19843 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19844 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19846 /* "show [ip] bgp neighbors" commands. */
19847 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19849 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19851 /* "show [ip] bgp peer-group" commands. */
19852 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19854 /* "show [ip] bgp paths" commands. */
19855 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19857 /* "show [ip] bgp community" commands. */
19858 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19860 /* "show ip bgp large-community" commands. */
19861 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19862 /* "show [ip] bgp attribute-info" commands. */
19863 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19864 /* "show [ip] bgp route-leak" command */
19865 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19867 /* "redistribute" commands. */
19868 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19869 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19870 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19871 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19872 install_element(BGP_NODE
,
19873 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19874 install_element(BGP_NODE
,
19875 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19876 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19877 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19878 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19879 install_element(BGP_NODE
,
19880 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19881 install_element(BGP_NODE
,
19882 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19883 install_element(BGP_NODE
,
19884 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19885 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19886 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19887 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19888 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19889 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19890 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19891 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19892 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19893 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19894 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19895 install_element(BGP_IPV4_NODE
,
19896 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19897 install_element(BGP_IPV4_NODE
,
19898 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19899 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19900 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19901 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19902 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19903 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19904 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19906 /* import|export vpn [route-map RMAP_NAME] */
19907 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19908 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19910 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19911 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19913 /* ttl_security commands */
19914 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19915 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19917 /* "bgp tcp-keepalive" commands */
19918 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19919 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19921 /* "show [ip] bgp memory" commands. */
19922 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19924 /* "show bgp martian next-hop" */
19925 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19927 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19929 /* "show [ip] bgp views" commands. */
19930 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19932 /* "show [ip] bgp vrfs" commands. */
19933 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19935 /* Community-list. */
19936 community_list_vty();
19938 community_alias_vty();
19940 /* vpn-policy commands */
19941 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19942 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19943 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19944 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19945 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19946 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19947 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19948 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19949 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19950 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19951 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19952 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19954 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19955 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19957 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19958 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19959 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19960 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19961 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19962 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19963 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19964 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19965 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19966 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19968 /* tcp-mss command */
19969 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19970 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19972 /* srv6 commands */
19973 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19974 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19975 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19976 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19977 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19978 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19979 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19980 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
19981 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
19986 #include "memory.h"
19987 #include "bgp_regex.h"
19988 #include "bgp_clist.h"
19989 #include "bgp_ecommunity.h"
19991 /* VTY functions. */
19993 /* Direction value to string conversion. */
19994 static const char *community_direct_str(int direct
)
19997 case COMMUNITY_DENY
:
19999 case COMMUNITY_PERMIT
:
20006 /* Display error string. */
20007 static void community_list_perror(struct vty
*vty
, int ret
)
20010 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20011 vty_out(vty
, "%% Can't find community-list\n");
20013 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20014 vty_out(vty
, "%% Malformed community-list value\n");
20016 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20018 "%% Community name conflict, previously defined as standard community\n");
20020 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20022 "%% Community name conflict, previously defined as expanded community\n");
20027 /* "community-list" keyword help string. */
20028 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20030 /*community-list standard */
20031 DEFUN (community_list_standard
,
20032 bgp_community_list_standard_cmd
,
20033 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20036 "Community list number (standard)\n"
20037 "Add an standard community-list entry\n"
20038 "Community list name\n"
20039 "Sequence number of an entry\n"
20040 "Sequence number\n"
20041 "Specify community to reject\n"
20042 "Specify community to accept\n"
20045 char *cl_name_or_number
= NULL
;
20048 int style
= COMMUNITY_LIST_STANDARD
;
20051 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20052 seq
= argv
[idx
]->arg
;
20055 argv_find(argv
, argc
, "(1-99)", &idx
);
20056 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20057 cl_name_or_number
= argv
[idx
]->arg
;
20058 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20060 argv_find(argv
, argc
, "AA:NN", &idx
);
20061 char *str
= argv_concat(argv
, argc
, idx
);
20063 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20066 XFREE(MTYPE_TMP
, str
);
20069 /* Display error string. */
20070 community_list_perror(vty
, ret
);
20071 return CMD_WARNING_CONFIG_FAILED
;
20074 return CMD_SUCCESS
;
20077 DEFUN (no_community_list_standard_all
,
20078 no_bgp_community_list_standard_all_cmd
,
20079 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20083 "Community list number (standard)\n"
20084 "Add an standard community-list entry\n"
20085 "Community list name\n"
20086 "Sequence number of an entry\n"
20087 "Sequence number\n"
20088 "Specify community to reject\n"
20089 "Specify community to accept\n"
20092 char *cl_name_or_number
= NULL
;
20095 int style
= COMMUNITY_LIST_STANDARD
;
20099 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20100 seq
= argv
[idx
]->arg
;
20103 argv_find(argv
, argc
, "permit", &idx
);
20104 argv_find(argv
, argc
, "deny", &idx
);
20107 direct
= argv_find(argv
, argc
, "permit", &idx
)
20112 argv_find(argv
, argc
, "AA:NN", &idx
);
20113 str
= argv_concat(argv
, argc
, idx
);
20117 argv_find(argv
, argc
, "(1-99)", &idx
);
20118 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20119 cl_name_or_number
= argv
[idx
]->arg
;
20121 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20124 XFREE(MTYPE_TMP
, str
);
20127 community_list_perror(vty
, ret
);
20128 return CMD_WARNING_CONFIG_FAILED
;
20131 return CMD_SUCCESS
;
20134 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20135 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20136 NO_STR BGP_STR COMMUNITY_LIST_STR
20137 "Community list number (standard)\n"
20138 "Add an standard community-list entry\n"
20139 "Community list name\n")
20141 /*community-list expanded */
20142 DEFUN (community_list_expanded_all
,
20143 bgp_community_list_expanded_all_cmd
,
20144 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20147 "Community list number (expanded)\n"
20148 "Add an expanded community-list entry\n"
20149 "Community list name\n"
20150 "Sequence number of an entry\n"
20151 "Sequence number\n"
20152 "Specify community to reject\n"
20153 "Specify community to accept\n"
20156 char *cl_name_or_number
= NULL
;
20159 int style
= COMMUNITY_LIST_EXPANDED
;
20162 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20163 seq
= argv
[idx
]->arg
;
20167 argv_find(argv
, argc
, "(100-500)", &idx
);
20168 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20169 cl_name_or_number
= argv
[idx
]->arg
;
20170 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20172 argv_find(argv
, argc
, "AA:NN", &idx
);
20173 char *str
= argv_concat(argv
, argc
, idx
);
20175 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20178 XFREE(MTYPE_TMP
, str
);
20181 /* Display error string. */
20182 community_list_perror(vty
, ret
);
20183 return CMD_WARNING_CONFIG_FAILED
;
20186 return CMD_SUCCESS
;
20189 DEFUN (no_community_list_expanded_all
,
20190 no_bgp_community_list_expanded_all_cmd
,
20191 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20195 "Community list number (expanded)\n"
20196 "Add an expanded community-list entry\n"
20197 "Community list name\n"
20198 "Sequence number of an entry\n"
20199 "Sequence number\n"
20200 "Specify community to reject\n"
20201 "Specify community to accept\n"
20204 char *cl_name_or_number
= NULL
;
20208 int style
= COMMUNITY_LIST_EXPANDED
;
20211 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20212 seq
= argv
[idx
]->arg
;
20215 argv_find(argv
, argc
, "permit", &idx
);
20216 argv_find(argv
, argc
, "deny", &idx
);
20219 direct
= argv_find(argv
, argc
, "permit", &idx
)
20224 argv_find(argv
, argc
, "AA:NN", &idx
);
20225 str
= argv_concat(argv
, argc
, idx
);
20229 argv_find(argv
, argc
, "(100-500)", &idx
);
20230 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20231 cl_name_or_number
= argv
[idx
]->arg
;
20233 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20236 XFREE(MTYPE_TMP
, str
);
20239 community_list_perror(vty
, ret
);
20240 return CMD_WARNING_CONFIG_FAILED
;
20243 return CMD_SUCCESS
;
20246 ALIAS(no_community_list_expanded_all
,
20247 no_bgp_community_list_expanded_all_list_cmd
,
20248 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20249 NO_STR BGP_STR COMMUNITY_LIST_STR
20250 "Community list number (expanded)\n"
20251 "Add an expanded community-list entry\n"
20252 "Community list name\n")
20254 /* Return configuration string of community-list entry. */
20255 static const char *community_list_config_str(struct community_entry
*entry
)
20262 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20263 str
= community_str(entry
->u
.com
, false, false);
20264 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20265 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20267 str
= entry
->config
;
20272 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20274 struct community_entry
*entry
;
20276 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20277 if (entry
== list
->head
) {
20278 if (all_digit(list
->name
))
20279 vty_out(vty
, "Community %s list %s\n",
20280 entry
->style
== COMMUNITY_LIST_STANDARD
20282 : "(expanded) access",
20285 vty_out(vty
, "Named Community %s list %s\n",
20286 entry
->style
== COMMUNITY_LIST_STANDARD
20292 vty_out(vty
, " %s\n",
20293 community_direct_str(entry
->direct
));
20295 vty_out(vty
, " %s %s\n",
20296 community_direct_str(entry
->direct
),
20297 community_list_config_str(entry
));
20301 DEFUN (show_community_list
,
20302 show_bgp_community_list_cmd
,
20303 "show bgp community-list",
20306 "List community-list\n")
20308 struct community_list
*list
;
20309 struct community_list_master
*cm
;
20311 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20313 return CMD_SUCCESS
;
20315 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20316 community_list_show(vty
, list
);
20318 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20319 community_list_show(vty
, list
);
20321 return CMD_SUCCESS
;
20324 DEFUN (show_community_list_arg
,
20325 show_bgp_community_list_arg_cmd
,
20326 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20329 "List community-list\n"
20330 "Community-list number\n"
20331 "Community-list name\n"
20332 "Detailed information on community-list\n")
20334 int idx_comm_list
= 3;
20335 struct community_list
*list
;
20337 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20338 COMMUNITY_LIST_MASTER
);
20340 vty_out(vty
, "%% Can't find community-list\n");
20341 return CMD_WARNING
;
20344 community_list_show(vty
, list
);
20346 return CMD_SUCCESS
;
20350 * Large Community code.
20352 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20353 struct cmd_token
**argv
, int style
,
20354 int reject_all_digit_name
)
20363 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20364 seq
= argv
[idx
]->arg
;
20367 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20370 /* All digit name check. */
20372 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20373 argv_find(argv
, argc
, "(1-99)", &idx
);
20374 argv_find(argv
, argc
, "(100-500)", &idx
);
20375 cl_name
= argv
[idx
]->arg
;
20376 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20377 vty_out(vty
, "%% Community name cannot have all digits\n");
20378 return CMD_WARNING_CONFIG_FAILED
;
20382 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20383 argv_find(argv
, argc
, "LINE", &idx
);
20384 /* Concat community string argument. */
20386 str
= argv_concat(argv
, argc
, idx
);
20390 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20392 /* Free temporary community list string allocated by
20394 XFREE(MTYPE_TMP
, str
);
20397 community_list_perror(vty
, ret
);
20398 return CMD_WARNING_CONFIG_FAILED
;
20400 return CMD_SUCCESS
;
20403 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20404 struct cmd_token
**argv
, int style
)
20412 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20413 seq
= argv
[idx
]->arg
;
20416 argv_find(argv
, argc
, "permit", &idx
);
20417 argv_find(argv
, argc
, "deny", &idx
);
20420 /* Check the list direct. */
20421 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20422 direct
= COMMUNITY_PERMIT
;
20424 direct
= COMMUNITY_DENY
;
20427 argv_find(argv
, argc
, "LINE", &idx
);
20428 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20429 /* Concat community string argument. */
20430 str
= argv_concat(argv
, argc
, idx
);
20434 argv_find(argv
, argc
, "(1-99)", &idx
);
20435 argv_find(argv
, argc
, "(100-500)", &idx
);
20436 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20438 /* Unset community list. */
20439 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20442 /* Free temporary community list string allocated by
20444 XFREE(MTYPE_TMP
, str
);
20447 community_list_perror(vty
, ret
);
20448 return CMD_WARNING_CONFIG_FAILED
;
20451 return CMD_SUCCESS
;
20454 /* "large-community-list" keyword help string. */
20455 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20456 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20458 DEFUN (lcommunity_list_standard
,
20459 bgp_lcommunity_list_standard_cmd
,
20460 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20462 LCOMMUNITY_LIST_STR
20463 "Large Community list number (standard)\n"
20464 "Sequence number of an entry\n"
20465 "Sequence number\n"
20466 "Specify large community to reject\n"
20467 "Specify large community to accept\n"
20468 LCOMMUNITY_VAL_STR
)
20470 return lcommunity_list_set_vty(vty
, argc
, argv
,
20471 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20474 DEFUN (lcommunity_list_expanded
,
20475 bgp_lcommunity_list_expanded_cmd
,
20476 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20478 LCOMMUNITY_LIST_STR
20479 "Large Community list number (expanded)\n"
20480 "Sequence number of an entry\n"
20481 "Sequence number\n"
20482 "Specify large community to reject\n"
20483 "Specify large community to accept\n"
20484 "An ordered list as a regular-expression\n")
20486 return lcommunity_list_set_vty(vty
, argc
, argv
,
20487 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20490 DEFUN (lcommunity_list_name_standard
,
20491 bgp_lcommunity_list_name_standard_cmd
,
20492 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20494 LCOMMUNITY_LIST_STR
20495 "Specify standard large-community-list\n"
20496 "Large Community list name\n"
20497 "Sequence number of an entry\n"
20498 "Sequence number\n"
20499 "Specify large community to reject\n"
20500 "Specify large community to accept\n"
20501 LCOMMUNITY_VAL_STR
)
20503 return lcommunity_list_set_vty(vty
, argc
, argv
,
20504 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20507 DEFUN (lcommunity_list_name_expanded
,
20508 bgp_lcommunity_list_name_expanded_cmd
,
20509 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20511 LCOMMUNITY_LIST_STR
20512 "Specify expanded large-community-list\n"
20513 "Large Community list name\n"
20514 "Sequence number of an entry\n"
20515 "Sequence number\n"
20516 "Specify large community to reject\n"
20517 "Specify large community to accept\n"
20518 "An ordered list as a regular-expression\n")
20520 return lcommunity_list_set_vty(vty
, argc
, argv
,
20521 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20524 DEFUN (no_lcommunity_list_all
,
20525 no_bgp_lcommunity_list_all_cmd
,
20526 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20529 LCOMMUNITY_LIST_STR
20530 "Large Community list number (standard)\n"
20531 "Large Community list number (expanded)\n"
20532 "Large Community list name\n")
20534 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20535 LARGE_COMMUNITY_LIST_STANDARD
);
20538 DEFUN (no_lcommunity_list_name_standard_all
,
20539 no_bgp_lcommunity_list_name_standard_all_cmd
,
20540 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20543 LCOMMUNITY_LIST_STR
20544 "Specify standard large-community-list\n"
20545 "Large Community list name\n")
20547 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20548 LARGE_COMMUNITY_LIST_STANDARD
);
20551 DEFUN (no_lcommunity_list_name_expanded_all
,
20552 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20553 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20556 LCOMMUNITY_LIST_STR
20557 "Specify expanded large-community-list\n"
20558 "Large Community list name\n")
20560 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20561 LARGE_COMMUNITY_LIST_EXPANDED
);
20564 DEFUN (no_lcommunity_list_standard
,
20565 no_bgp_lcommunity_list_standard_cmd
,
20566 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20569 LCOMMUNITY_LIST_STR
20570 "Large Community list number (standard)\n"
20571 "Sequence number of an entry\n"
20572 "Sequence number\n"
20573 "Specify large community to reject\n"
20574 "Specify large community to accept\n"
20575 LCOMMUNITY_VAL_STR
)
20577 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20578 LARGE_COMMUNITY_LIST_STANDARD
);
20581 DEFUN (no_lcommunity_list_expanded
,
20582 no_bgp_lcommunity_list_expanded_cmd
,
20583 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20586 LCOMMUNITY_LIST_STR
20587 "Large Community list number (expanded)\n"
20588 "Sequence number of an entry\n"
20589 "Sequence number\n"
20590 "Specify large community to reject\n"
20591 "Specify large community to accept\n"
20592 "An ordered list as a regular-expression\n")
20594 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20595 LARGE_COMMUNITY_LIST_EXPANDED
);
20598 DEFUN (no_lcommunity_list_name_standard
,
20599 no_bgp_lcommunity_list_name_standard_cmd
,
20600 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20603 LCOMMUNITY_LIST_STR
20604 "Specify standard large-community-list\n"
20605 "Large Community list name\n"
20606 "Sequence number of an entry\n"
20607 "Sequence number\n"
20608 "Specify large community to reject\n"
20609 "Specify large community to accept\n"
20610 LCOMMUNITY_VAL_STR
)
20612 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20613 LARGE_COMMUNITY_LIST_STANDARD
);
20616 DEFUN (no_lcommunity_list_name_expanded
,
20617 no_bgp_lcommunity_list_name_expanded_cmd
,
20618 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20621 LCOMMUNITY_LIST_STR
20622 "Specify expanded large-community-list\n"
20623 "Large community list name\n"
20624 "Sequence number of an entry\n"
20625 "Sequence number\n"
20626 "Specify large community to reject\n"
20627 "Specify large community to accept\n"
20628 "An ordered list as a regular-expression\n")
20630 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20631 LARGE_COMMUNITY_LIST_EXPANDED
);
20634 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20636 struct community_entry
*entry
;
20638 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20639 if (entry
== list
->head
) {
20640 if (all_digit(list
->name
))
20641 vty_out(vty
, "Large community %s list %s\n",
20643 LARGE_COMMUNITY_LIST_STANDARD
20645 : "(expanded) access",
20649 "Named large community %s list %s\n",
20651 LARGE_COMMUNITY_LIST_STANDARD
20657 vty_out(vty
, " %s\n",
20658 community_direct_str(entry
->direct
));
20660 vty_out(vty
, " %s %s\n",
20661 community_direct_str(entry
->direct
),
20662 community_list_config_str(entry
));
20666 DEFUN (show_lcommunity_list
,
20667 show_bgp_lcommunity_list_cmd
,
20668 "show bgp large-community-list",
20671 "List large-community list\n")
20673 struct community_list
*list
;
20674 struct community_list_master
*cm
;
20676 cm
= community_list_master_lookup(bgp_clist
,
20677 LARGE_COMMUNITY_LIST_MASTER
);
20679 return CMD_SUCCESS
;
20681 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20682 lcommunity_list_show(vty
, list
);
20684 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20685 lcommunity_list_show(vty
, list
);
20687 return CMD_SUCCESS
;
20690 DEFUN (show_lcommunity_list_arg
,
20691 show_bgp_lcommunity_list_arg_cmd
,
20692 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20695 "List large-community list\n"
20696 "Large-community-list number\n"
20697 "Large-community-list name\n"
20698 "Detailed information on large-community-list\n")
20700 struct community_list
*list
;
20702 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20703 LARGE_COMMUNITY_LIST_MASTER
);
20705 vty_out(vty
, "%% Can't find large-community-list\n");
20706 return CMD_WARNING
;
20709 lcommunity_list_show(vty
, list
);
20711 return CMD_SUCCESS
;
20714 /* "extcommunity-list" keyword help string. */
20715 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20716 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20718 DEFUN (extcommunity_list_standard
,
20719 bgp_extcommunity_list_standard_cmd
,
20720 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20722 EXTCOMMUNITY_LIST_STR
20723 "Extended Community list number (standard)\n"
20724 "Specify standard extcommunity-list\n"
20725 "Community list name\n"
20726 "Sequence number of an entry\n"
20727 "Sequence number\n"
20728 "Specify community to reject\n"
20729 "Specify community to accept\n"
20730 EXTCOMMUNITY_VAL_STR
)
20732 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20734 char *cl_number_or_name
= NULL
;
20739 argv_find(argv
, argc
, "(1-99)", &idx
);
20740 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20741 cl_number_or_name
= argv
[idx
]->arg
;
20743 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20744 seq
= argv
[idx
]->arg
;
20746 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20748 argv_find(argv
, argc
, "AA:NN", &idx
);
20749 char *str
= argv_concat(argv
, argc
, idx
);
20751 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20754 XFREE(MTYPE_TMP
, str
);
20757 community_list_perror(vty
, ret
);
20758 return CMD_WARNING_CONFIG_FAILED
;
20761 return CMD_SUCCESS
;
20764 DEFUN (extcommunity_list_name_expanded
,
20765 bgp_extcommunity_list_name_expanded_cmd
,
20766 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20768 EXTCOMMUNITY_LIST_STR
20769 "Extended Community list number (expanded)\n"
20770 "Specify expanded extcommunity-list\n"
20771 "Extended Community list name\n"
20772 "Sequence number of an entry\n"
20773 "Sequence number\n"
20774 "Specify community to reject\n"
20775 "Specify community to accept\n"
20776 "An ordered list as a regular-expression\n")
20778 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20780 char *cl_number_or_name
= NULL
;
20784 argv_find(argv
, argc
, "(100-500)", &idx
);
20785 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20786 cl_number_or_name
= argv
[idx
]->arg
;
20788 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20789 seq
= argv
[idx
]->arg
;
20791 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20793 argv_find(argv
, argc
, "LINE", &idx
);
20794 char *str
= argv_concat(argv
, argc
, idx
);
20796 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20799 XFREE(MTYPE_TMP
, str
);
20802 community_list_perror(vty
, ret
);
20803 return CMD_WARNING_CONFIG_FAILED
;
20806 return CMD_SUCCESS
;
20809 DEFUN (no_extcommunity_list_standard_all
,
20810 no_bgp_extcommunity_list_standard_all_cmd
,
20811 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20814 EXTCOMMUNITY_LIST_STR
20815 "Extended Community list number (standard)\n"
20816 "Specify standard extcommunity-list\n"
20817 "Community list name\n"
20818 "Sequence number of an entry\n"
20819 "Sequence number\n"
20820 "Specify community to reject\n"
20821 "Specify community to accept\n"
20822 EXTCOMMUNITY_VAL_STR
)
20824 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20826 char *cl_number_or_name
= NULL
;
20831 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20832 seq
= argv
[idx
]->arg
;
20835 argv_find(argv
, argc
, "permit", &idx
);
20836 argv_find(argv
, argc
, "deny", &idx
);
20838 direct
= argv_find(argv
, argc
, "permit", &idx
)
20843 argv_find(argv
, argc
, "AA:NN", &idx
);
20844 str
= argv_concat(argv
, argc
, idx
);
20848 argv_find(argv
, argc
, "(1-99)", &idx
);
20849 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20850 cl_number_or_name
= argv
[idx
]->arg
;
20852 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20853 seq
, direct
, style
);
20855 XFREE(MTYPE_TMP
, str
);
20858 community_list_perror(vty
, ret
);
20859 return CMD_WARNING_CONFIG_FAILED
;
20862 return CMD_SUCCESS
;
20865 ALIAS(no_extcommunity_list_standard_all
,
20866 no_bgp_extcommunity_list_standard_all_list_cmd
,
20867 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20868 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20869 "Extended Community list number (standard)\n"
20870 "Specify standard extcommunity-list\n"
20871 "Community list name\n")
20873 DEFUN (no_extcommunity_list_expanded_all
,
20874 no_bgp_extcommunity_list_expanded_all_cmd
,
20875 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20878 EXTCOMMUNITY_LIST_STR
20879 "Extended Community list number (expanded)\n"
20880 "Specify expanded extcommunity-list\n"
20881 "Extended Community list name\n"
20882 "Sequence number of an entry\n"
20883 "Sequence number\n"
20884 "Specify community to reject\n"
20885 "Specify community to accept\n"
20886 "An ordered list as a regular-expression\n")
20888 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20890 char *cl_number_or_name
= NULL
;
20895 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20896 seq
= argv
[idx
]->arg
;
20899 argv_find(argv
, argc
, "permit", &idx
);
20900 argv_find(argv
, argc
, "deny", &idx
);
20903 direct
= argv_find(argv
, argc
, "permit", &idx
)
20908 argv_find(argv
, argc
, "LINE", &idx
);
20909 str
= argv_concat(argv
, argc
, idx
);
20913 argv_find(argv
, argc
, "(100-500)", &idx
);
20914 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20915 cl_number_or_name
= argv
[idx
]->arg
;
20917 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20918 seq
, direct
, style
);
20920 XFREE(MTYPE_TMP
, str
);
20923 community_list_perror(vty
, ret
);
20924 return CMD_WARNING_CONFIG_FAILED
;
20927 return CMD_SUCCESS
;
20930 ALIAS(no_extcommunity_list_expanded_all
,
20931 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20932 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20933 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20934 "Extended Community list number (expanded)\n"
20935 "Specify expanded extcommunity-list\n"
20936 "Extended Community list name\n")
20938 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20940 struct community_entry
*entry
;
20942 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20943 if (entry
== list
->head
) {
20944 if (all_digit(list
->name
))
20945 vty_out(vty
, "Extended community %s list %s\n",
20946 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20948 : "(expanded) access",
20952 "Named extended community %s list %s\n",
20953 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20959 vty_out(vty
, " %s\n",
20960 community_direct_str(entry
->direct
));
20962 vty_out(vty
, " %s %s\n",
20963 community_direct_str(entry
->direct
),
20964 community_list_config_str(entry
));
20968 DEFUN (show_extcommunity_list
,
20969 show_bgp_extcommunity_list_cmd
,
20970 "show bgp extcommunity-list",
20973 "List extended-community list\n")
20975 struct community_list
*list
;
20976 struct community_list_master
*cm
;
20978 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20980 return CMD_SUCCESS
;
20982 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20983 extcommunity_list_show(vty
, list
);
20985 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20986 extcommunity_list_show(vty
, list
);
20988 return CMD_SUCCESS
;
20991 DEFUN (show_extcommunity_list_arg
,
20992 show_bgp_extcommunity_list_arg_cmd
,
20993 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20996 "List extended-community list\n"
20997 "Extcommunity-list number\n"
20998 "Extcommunity-list name\n"
20999 "Detailed information on extcommunity-list\n")
21001 int idx_comm_list
= 3;
21002 struct community_list
*list
;
21004 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21005 EXTCOMMUNITY_LIST_MASTER
);
21007 vty_out(vty
, "%% Can't find extcommunity-list\n");
21008 return CMD_WARNING
;
21011 extcommunity_list_show(vty
, list
);
21013 return CMD_SUCCESS
;
21016 /* Display community-list and extcommunity-list configuration. */
21017 static int community_list_config_write(struct vty
*vty
)
21019 struct community_list
*list
;
21020 struct community_entry
*entry
;
21021 struct community_list_master
*cm
;
21024 /* Community-list. */
21025 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21027 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21028 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21030 "bgp community-list %s seq %" PRId64
" %s %s\n",
21031 list
->name
, entry
->seq
,
21032 community_direct_str(entry
->direct
),
21033 community_list_config_str(entry
));
21036 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21037 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21039 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21040 entry
->style
== COMMUNITY_LIST_STANDARD
21043 list
->name
, entry
->seq
,
21044 community_direct_str(entry
->direct
),
21045 community_list_config_str(entry
));
21049 /* Extcommunity-list. */
21050 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21052 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21053 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21055 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21056 list
->name
, entry
->seq
,
21057 community_direct_str(entry
->direct
),
21058 community_list_config_str(entry
));
21061 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21062 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21064 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21065 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21068 list
->name
, entry
->seq
,
21069 community_direct_str(entry
->direct
),
21070 community_list_config_str(entry
));
21075 /* lcommunity-list. */
21076 cm
= community_list_master_lookup(bgp_clist
,
21077 LARGE_COMMUNITY_LIST_MASTER
);
21079 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21080 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21082 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21083 list
->name
, entry
->seq
,
21084 community_direct_str(entry
->direct
),
21085 community_list_config_str(entry
));
21088 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21089 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21091 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21093 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21096 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21097 community_list_config_str(entry
));
21104 static int community_list_config_write(struct vty
*vty
);
21105 static struct cmd_node community_list_node
= {
21106 .name
= "community list",
21107 .node
= COMMUNITY_LIST_NODE
,
21109 .config_write
= community_list_config_write
,
21112 static void community_list_vty(void)
21114 install_node(&community_list_node
);
21116 /* Community-list. */
21117 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21118 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21119 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21120 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21121 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21122 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21123 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21124 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21126 /* Extcommunity-list. */
21127 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21128 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21129 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21130 install_element(CONFIG_NODE
,
21131 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21132 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21133 install_element(CONFIG_NODE
,
21134 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21135 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21136 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21138 /* Large Community List */
21139 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21140 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21141 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21142 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21143 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21144 install_element(CONFIG_NODE
,
21145 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21146 install_element(CONFIG_NODE
,
21147 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21148 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21149 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21150 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21151 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21152 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21153 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21155 bgp_community_list_command_completion_setup();
21158 static struct cmd_node community_alias_node
= {
21159 .name
= "community alias",
21160 .node
= COMMUNITY_ALIAS_NODE
,
21162 .config_write
= bgp_community_alias_write
,
21165 void community_alias_vty(void)
21167 install_node(&community_alias_node
);
21169 /* Community-list. */
21170 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21172 bgp_community_alias_command_completion_setup();