1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
10 #include "lib/sockopt.h"
11 #include "lib_errors.h"
12 #include "lib/zclient.h"
13 #include "lib/printfrr.h"
28 #include "bgpd/bgpd.h"
29 #include "bgpd/bgp_attr_evpn.h"
30 #include "bgpd/bgp_advertise.h"
31 #include "bgpd/bgp_attr.h"
32 #include "bgpd/bgp_aspath.h"
33 #include "bgpd/bgp_community.h"
34 #include "bgpd/bgp_community_alias.h"
35 #include "bgpd/bgp_ecommunity.h"
36 #include "bgpd/bgp_lcommunity.h"
37 #include "bgpd/bgp_damp.h"
38 #include "bgpd/bgp_debug.h"
39 #include "bgpd/bgp_errors.h"
40 #include "bgpd/bgp_fsm.h"
41 #include "bgpd/bgp_nht.h"
42 #include "bgpd/bgp_nexthop.h"
43 #include "bgpd/bgp_network.h"
44 #include "bgpd/bgp_open.h"
45 #include "bgpd/bgp_regex.h"
46 #include "bgpd/bgp_route.h"
47 #include "bgpd/bgp_mplsvpn.h"
48 #include "bgpd/bgp_zebra.h"
49 #include "bgpd/bgp_table.h"
50 #include "bgpd/bgp_vty.h"
51 #include "bgpd/bgp_mpath.h"
52 #include "bgpd/bgp_packet.h"
53 #include "bgpd/bgp_updgrp.h"
54 #include "bgpd/bgp_bfd.h"
55 #include "bgpd/bgp_io.h"
56 #include "bgpd/bgp_evpn.h"
57 #include "bgpd/bgp_evpn_vty.h"
58 #include "bgpd/bgp_evpn_mh.h"
59 #include "bgpd/bgp_addpath.h"
60 #include "bgpd/bgp_mac.h"
61 #include "bgpd/bgp_flowspec.h"
62 #include "bgpd/bgp_conditional_adv.h"
64 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
67 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
70 .match_profile
= "traditional",
71 .match_version
= "< 7.4",
75 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
76 { .val_bool
= true, .match_profile
= "datacenter", },
77 { .val_bool
= false },
79 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
80 { .val_bool
= true, .match_profile
= "datacenter", },
81 { .val_bool
= false },
83 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
84 { .val_bool
= true, .match_profile
= "datacenter", },
85 { .val_bool
= false },
87 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
88 { .val_bool
= true, .match_profile
= "datacenter", },
89 { .val_bool
= false },
91 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
92 { .val_ulong
= 10, .match_profile
= "datacenter", },
95 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
96 { .val_ulong
= 9, .match_profile
= "datacenter", },
99 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
100 { .val_ulong
= 3, .match_profile
= "datacenter", },
103 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
104 { .val_bool
= false, .match_profile
= "datacenter", },
105 { .val_bool
= false, .match_version
= "< 7.4", },
106 { .val_bool
= true },
108 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
109 { .val_bool
= false, .match_version
= "< 7.6", },
110 { .val_bool
= true },
112 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
113 { .val_bool
= false, .match_version
= "< 8.3", },
114 { .val_bool
= true },
116 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
117 { .val_bool
= false, .match_version
= "< 8.3", },
118 { .val_bool
= true },
121 DEFINE_HOOK(bgp_inst_config_write
,
122 (struct bgp
*bgp
, struct vty
*vty
),
124 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
125 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
127 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
128 struct prefix
*range
, int exact
);
130 /* Show BGP peer's information. */
140 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
141 struct prefix
*range
, int exact
);
143 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
146 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
149 afi_t afi
, bool use_json
);
151 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
157 return BGP_IPV4_NODE
;
159 return BGP_IPV4M_NODE
;
160 case SAFI_LABELED_UNICAST
:
161 return BGP_IPV4L_NODE
;
163 return BGP_VPNV4_NODE
;
165 return BGP_FLOWSPECV4_NODE
;
171 return BGP_IPV4_NODE
;
177 return BGP_IPV6_NODE
;
179 return BGP_IPV6M_NODE
;
180 case SAFI_LABELED_UNICAST
:
181 return BGP_IPV6L_NODE
;
183 return BGP_VPNV6_NODE
;
185 return BGP_FLOWSPECV6_NODE
;
190 /* not expected and the return value seems wrong */
191 return BGP_IPV4_NODE
;
195 return BGP_EVPN_NODE
;
198 // We should never be here but to clarify the switch statement..
199 return BGP_IPV4_NODE
;
202 // Impossible to happen
203 return BGP_IPV4_NODE
;
206 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
209 if (safi
== SAFI_UNICAST
)
210 return "IPv4 Unicast";
211 if (safi
== SAFI_MULTICAST
)
212 return "IPv4 Multicast";
213 if (safi
== SAFI_LABELED_UNICAST
)
214 return "IPv4 Labeled Unicast";
215 if (safi
== SAFI_MPLS_VPN
)
217 if (safi
== SAFI_ENCAP
)
219 if (safi
== SAFI_FLOWSPEC
)
220 return "IPv4 Flowspec";
221 } else if (afi
== AFI_IP6
) {
222 if (safi
== SAFI_UNICAST
)
223 return "IPv6 Unicast";
224 if (safi
== SAFI_MULTICAST
)
225 return "IPv6 Multicast";
226 if (safi
== SAFI_LABELED_UNICAST
)
227 return "IPv6 Labeled Unicast";
228 if (safi
== SAFI_MPLS_VPN
)
230 if (safi
== SAFI_ENCAP
)
232 if (safi
== SAFI_FLOWSPEC
)
233 return "IPv6 Flowspec";
234 } else if (afi
== AFI_L2VPN
) {
235 if (safi
== SAFI_EVPN
)
243 * Please note that we have intentionally camelCased
244 * the return strings here. So if you want
245 * to use this function, please ensure you
246 * are doing this within json output
248 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
251 if (safi
== SAFI_UNICAST
)
252 return "ipv4Unicast";
253 if (safi
== SAFI_MULTICAST
)
254 return "ipv4Multicast";
255 if (safi
== SAFI_LABELED_UNICAST
)
256 return "ipv4LabeledUnicast";
257 if (safi
== SAFI_MPLS_VPN
)
259 if (safi
== SAFI_ENCAP
)
261 if (safi
== SAFI_FLOWSPEC
)
262 return "ipv4Flowspec";
263 } else if (afi
== AFI_IP6
) {
264 if (safi
== SAFI_UNICAST
)
265 return "ipv6Unicast";
266 if (safi
== SAFI_MULTICAST
)
267 return "ipv6Multicast";
268 if (safi
== SAFI_LABELED_UNICAST
)
269 return "ipv6LabeledUnicast";
270 if (safi
== SAFI_MPLS_VPN
)
272 if (safi
== SAFI_ENCAP
)
274 if (safi
== SAFI_FLOWSPEC
)
275 return "ipv6Flowspec";
276 } else if (afi
== AFI_L2VPN
) {
277 if (safi
== SAFI_EVPN
)
284 /* unset srv6 locator */
285 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
288 struct listnode
*node
, *nnode
;
289 struct srv6_locator_chunk
*chunk
;
290 struct bgp_srv6_function
*func
;
293 /* release chunk notification via ZAPI */
294 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
295 bgp
->srv6_locator_name
);
300 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
301 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
302 srv6_locator_chunk_free(&chunk
);
305 /* refresh functions */
306 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
307 listnode_delete(bgp
->srv6_functions
, func
);
308 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
311 /* refresh tovpn_sid */
312 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
313 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
316 /* refresh vpnv4 tovpn_sid */
317 XFREE(MTYPE_BGP_SRV6_SID
,
318 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
320 /* refresh vpnv6 tovpn_sid */
321 XFREE(MTYPE_BGP_SRV6_SID
,
322 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
324 /* refresh per-vrf tovpn_sid */
325 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
328 /* update vpn bgp processes */
329 vpn_leak_postchange_all();
331 /* refresh tovpn_sid_locator */
332 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
333 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
336 /* refresh vpnv4 tovpn_sid_locator */
337 srv6_locator_chunk_free(
338 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
340 /* refresh vpnv6 tovpn_sid_locator */
341 srv6_locator_chunk_free(
342 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
344 /* refresh per-vrf tovpn_sid_locator */
345 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
348 /* clear locator name */
349 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
354 /* Utility function to get address family from current node. */
355 afi_t
bgp_node_afi(struct vty
*vty
)
363 case BGP_FLOWSPECV6_NODE
:
376 /* Utility function to get subsequent address family from current
378 safi_t
bgp_node_safi(struct vty
*vty
)
384 safi
= SAFI_MPLS_VPN
;
388 safi
= SAFI_MULTICAST
;
395 safi
= SAFI_LABELED_UNICAST
;
397 case BGP_FLOWSPECV4_NODE
:
398 case BGP_FLOWSPECV6_NODE
:
399 safi
= SAFI_FLOWSPEC
;
409 * Converts an AFI in string form to afi_t
411 * @param afi string, one of
415 * @return the corresponding afi_t
417 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
419 afi_t afi
= AFI_MAX
; /* unknown */
420 if (strmatch(afi_str
, "ipv4"))
422 else if (strmatch(afi_str
, "ipv6"))
424 else if (strmatch(afi_str
, "l2vpn"))
429 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
433 if (argv_find(argv
, argc
, "ipv4", index
)) {
437 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
441 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
449 /* supports <unicast|multicast|vpn|labeled-unicast> */
450 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
452 safi_t safi
= SAFI_MAX
; /* unknown */
453 if (strmatch(safi_str
, "multicast"))
454 safi
= SAFI_MULTICAST
;
455 else if (strmatch(safi_str
, "unicast"))
457 else if (strmatch(safi_str
, "vpn"))
458 safi
= SAFI_MPLS_VPN
;
459 else if (strmatch(safi_str
, "evpn"))
461 else if (strmatch(safi_str
, "labeled-unicast"))
462 safi
= SAFI_LABELED_UNICAST
;
463 else if (strmatch(safi_str
, "flowspec"))
464 safi
= SAFI_FLOWSPEC
;
468 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
472 if (argv_find(argv
, argc
, "unicast", index
)) {
475 *safi
= SAFI_UNICAST
;
476 } else if (argv_find(argv
, argc
, "multicast", index
)) {
479 *safi
= SAFI_MULTICAST
;
480 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
483 *safi
= SAFI_LABELED_UNICAST
;
484 } else if (argv_find(argv
, argc
, "vpn", index
)) {
487 *safi
= SAFI_MPLS_VPN
;
488 } else if (argv_find(argv
, argc
, "evpn", index
)) {
492 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
495 *safi
= SAFI_FLOWSPEC
;
501 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
504 * address-family identifier
507 * subsequent address-family identifier
510 * default_af string corresponding to the supplied afi/safi pair.
511 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
514 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
520 return "ipv4-unicast";
522 return "ipv4-multicast";
527 case SAFI_LABELED_UNICAST
:
528 return "ipv4-labeled-unicast";
530 return "ipv4-flowspec";
534 return "unknown-afi/safi";
540 return "ipv6-unicast";
542 return "ipv6-multicast";
547 case SAFI_LABELED_UNICAST
:
548 return "ipv6-labeled-unicast";
550 return "ipv6-flowspec";
554 return "unknown-afi/safi";
565 case SAFI_LABELED_UNICAST
:
569 return "unknown-afi/safi";
574 return "unknown-afi/safi";
576 /* all AFIs are accounted for above, so this shouldn't happen */
578 assert(!"Reached end of function where we did not expect to");
581 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
582 enum bgp_instance_type inst_type
)
584 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
586 if (ret
== BGP_CREATED
) {
587 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
588 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
590 if (DFLT_BGP_IMPORT_CHECK
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
592 if (DFLT_BGP_SHOW_HOSTNAME
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
594 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
596 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
598 if (DFLT_BGP_DETERMINISTIC_MED
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
600 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
602 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
604 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
606 if (DFLT_BGP_HARD_ADMIN_RESET
)
607 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
615 * bgp_vty_find_and_parse_afi_safi_bgp
617 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
618 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
619 * to appropriate values for the calling function. This is to allow the
620 * calling function to make decisions appropriate for the show command
621 * that is being parsed.
623 * The show commands are generally of the form:
624 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
625 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
627 * Since we use argv_find if the show command in particular doesn't have:
629 * [<view|vrf> VIEWVRFNAME]
630 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
631 * The command parsing should still be ok.
633 * vty -> The vty for the command so we can output some useful data in
634 * the event of a parse error in the vrf.
635 * argv -> The command tokens
636 * argc -> How many command tokens we have
637 * idx -> The current place in the command, generally should be 0 for this
639 * afi -> The parsed afi if it was included in the show command, returned here
640 * safi -> The parsed safi if it was included in the show command, returned here
641 * bgp -> Pointer to the bgp data structure we need to fill in.
642 * use_json -> json is configured or not
644 * The function returns the correct location in the parse tree for the
647 * Returns 0 for failure to parse correctly, else the idx position of where
648 * it found the last token.
650 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
651 struct cmd_token
**argv
, int argc
,
652 int *idx
, afi_t
*afi
, safi_t
*safi
,
653 struct bgp
**bgp
, bool use_json
)
655 char *vrf_name
= NULL
;
661 if (argv_find(argv
, argc
, "ip", idx
))
664 if (argv_find(argv
, argc
, "view", idx
))
665 vrf_name
= argv
[*idx
+ 1]->arg
;
666 else if (argv_find(argv
, argc
, "vrf", idx
)) {
667 vrf_name
= argv
[*idx
+ 1]->arg
;
668 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
672 if (strmatch(vrf_name
, "all"))
675 *bgp
= bgp_lookup_by_name(vrf_name
);
678 json_object
*json
= NULL
;
679 json
= json_object_new_object();
680 json_object_string_add(
682 "View/Vrf is unknown");
686 vty_out(vty
, "View/Vrf %s is unknown\n",
693 *bgp
= bgp_get_default();
696 json_object
*json
= NULL
;
697 json
= json_object_new_object();
698 json_object_string_add(
700 "Default BGP instance not found");
705 "Default BGP instance not found\n");
711 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
712 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
718 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
720 struct interface
*ifp
= NULL
;
721 struct listnode
*node
;
722 struct bgp_listener
*listener
;
723 union sockunion all_su
;
725 if (su
->sa
.sa_family
== AF_INET
) {
726 (void)str2sockunion("0.0.0.0", &all_su
);
727 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
728 } else if (su
->sa
.sa_family
== AF_INET6
) {
729 (void)str2sockunion("::", &all_su
);
730 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
731 su
->sin6
.sin6_scope_id
,
736 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
737 if (sockunion_family(su
) !=
738 sockunion_family(&listener
->su
))
741 /* If 0.0.0.0/:: is a listener, then treat as self and
744 if (!sockunion_cmp(&listener
->su
, su
) ||
745 !sockunion_cmp(&listener
->su
, &all_su
))
753 /* Utility function for looking up peer from VTY. */
754 /* This is used only for configuration, so disallow if attempted on
755 * a dynamic neighbor.
757 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
759 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
768 ret
= str2sockunion(ip_str
, &su
);
770 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
772 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
775 "%% Malformed address or name: %s\n",
781 peer
= peer_lookup(bgp
, &su
);
784 "%% Specify remote-as or peer-group commands first\n");
787 if (peer_dynamic_neighbor(peer
)) {
789 "%% Operation not allowed on a dynamic neighbor\n");
796 /* Utility function for looking up peer or peer group. */
797 /* This is used only for configuration, so disallow if attempted on
798 * a dynamic neighbor.
800 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
802 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
805 struct peer
*peer
= NULL
;
806 struct peer_group
*group
= NULL
;
812 ret
= str2sockunion(peer_str
, &su
);
814 /* IP address, locate peer. */
815 peer
= peer_lookup(bgp
, &su
);
817 /* Not IP, could match either peer configured on interface or a
819 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
821 group
= peer_group_lookup(bgp
, peer_str
);
825 if (peer_dynamic_neighbor(peer
)) {
827 "%pBP: Operation not allowed on a dynamic neighbor",
830 "%% Operation not allowed on a dynamic neighbor\n");
840 zlog_warn("Specify remote-as or peer-group commands first before: %s",
842 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
847 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
849 const char *str
= NULL
;
854 case BGP_GR_NO_OPERATION
:
856 case BGP_ERR_INVALID_VALUE
:
857 str
= "Invalid value";
859 case BGP_ERR_INVALID_FLAG
:
860 str
= "Invalid flag";
862 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
863 str
= "Peer-group has been shutdown. Activate the peer-group first";
865 case BGP_ERR_PEER_FLAG_CONFLICT
:
866 str
= "Can't set override-capability and strict-capability-match at the same time";
868 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
869 str
= "Specify remote-as or peer-group remote AS first";
871 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
872 str
= "Cannot change the peer-group. Deconfigure first";
874 case BGP_ERR_PEER_GROUP_MISMATCH
:
875 str
= "Peer is not a member of this peer-group";
877 case BGP_ERR_PEER_FILTER_CONFLICT
:
878 str
= "Prefix/distribute list can not co-exist";
880 case BGP_ERR_NOT_INTERNAL_PEER
:
881 str
= "Invalid command. Not an internal neighbor";
883 case BGP_ERR_REMOVE_PRIVATE_AS
:
884 str
= "remove-private-AS cannot be configured for IBGP peers";
886 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
887 str
= "Cannot have local-as same as BGP AS number";
889 case BGP_ERR_TCPSIG_FAILED
:
890 str
= "Error while applying TCP-Sig to session(s)";
892 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
893 str
= "ebgp-multihop and ttl-security cannot be configured together";
895 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
896 str
= "ttl-security only allowed for EBGP peers";
898 case BGP_ERR_AS_OVERRIDE
:
899 str
= "as-override cannot be configured for IBGP peers";
901 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
902 str
= "Invalid limit for number of dynamic neighbors";
904 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
905 str
= "Dynamic neighbor listen range already exists";
907 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
908 str
= "Operation not allowed on a dynamic neighbor";
910 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
911 str
= "Operation not allowed on a directly connected neighbor";
913 case BGP_ERR_PEER_SAFI_CONFLICT
:
914 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
916 case BGP_ERR_GR_INVALID_CMD
:
917 str
= "The Graceful Restart command used is not valid at this moment.";
919 case BGP_ERR_GR_OPERATION_FAILED
:
920 str
= "The Graceful Restart Operation failed due to an err.";
922 case BGP_ERR_PEER_GROUP_MEMBER
:
923 str
= "Peer-group member cannot override remote-as of peer-group.";
925 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
926 str
= "Peer-group members must be all internal or all external.";
928 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
929 str
= "Range specified cannot be deleted because it is not part of current config.";
931 case BGP_ERR_INSTANCE_MISMATCH
:
932 str
= "Instance specified does not match the current instance.";
934 case BGP_ERR_NO_INTERFACE_CONFIG
:
935 str
= "Interface specified is not being used for interface based peer.";
937 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
938 str
= "No configuration already specified for soft reconfiguration.";
940 case BGP_ERR_AS_MISMATCH
:
941 str
= "BGP is already running.";
943 case BGP_ERR_AF_UNCONFIGURED
:
944 str
= "AFI/SAFI specified is not currently configured.";
946 case BGP_ERR_INVALID_AS
:
947 str
= "Confederation AS specified is the same AS as our AS.";
949 case BGP_ERR_INVALID_ROLE_NAME
:
950 str
= "Invalid role name";
952 case BGP_ERR_INVALID_INTERNAL_ROLE
:
953 str
= "External roles can be set only on eBGP session";
957 vty_out(vty
, "%% %s\n", str
);
958 return CMD_WARNING_CONFIG_FAILED
;
963 /* BGP clear sort. */
972 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
973 safi_t safi
, int error
)
976 case BGP_ERR_AF_UNCONFIGURED
:
979 "%% BGP: Enable %s address family for the neighbor %s\n",
980 get_afi_safi_str(afi
, safi
, false), peer
->host
);
983 "%% BGP: Enable %s address family for the neighbor %s",
984 get_afi_safi_str(afi
, safi
, false), peer
->host
);
986 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
989 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
993 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
1001 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1002 struct listnode
**nnode
, enum bgp_clear_type stype
)
1005 struct peer_af
*paf
;
1007 /* if afi/.safi not specified, spin thru all of them */
1008 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1011 enum bgp_af_index index
;
1013 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1014 paf
= peer
->peer_af_array
[index
];
1018 if (paf
&& paf
->subgroup
)
1019 SET_FLAG(paf
->subgroup
->sflags
,
1020 SUBGRP_STATUS_FORCE_UPDATES
);
1023 tmp_safi
= paf
->safi
;
1024 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1027 if (stype
== BGP_CLEAR_SOFT_NONE
)
1028 ret
= peer_clear(peer
, nnode
);
1030 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1033 /* if afi specified and safi not, spin thru safis on this afi */
1034 } else if (safi
== SAFI_UNSPEC
) {
1037 for (tmp_safi
= SAFI_UNICAST
;
1038 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1039 if (!peer
->afc
[afi
][tmp_safi
])
1042 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1043 if (paf
&& paf
->subgroup
)
1044 SET_FLAG(paf
->subgroup
->sflags
,
1045 SUBGRP_STATUS_FORCE_UPDATES
);
1047 if (stype
== BGP_CLEAR_SOFT_NONE
)
1048 ret
= peer_clear(peer
, nnode
);
1050 ret
= peer_clear_soft(peer
, afi
,
1053 /* both afi/safi specified, let the caller know if not defined */
1055 if (!peer
->afc
[afi
][safi
])
1058 paf
= peer_af_find(peer
, afi
, safi
);
1059 if (paf
&& paf
->subgroup
)
1060 SET_FLAG(paf
->subgroup
->sflags
,
1061 SUBGRP_STATUS_FORCE_UPDATES
);
1063 if (stype
== BGP_CLEAR_SOFT_NONE
)
1064 ret
= peer_clear(peer
, nnode
);
1066 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1072 /* `clear ip bgp' functions. */
1073 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1074 enum clear_sort sort
, enum bgp_clear_type stype
,
1081 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1083 /* Clear all neighbors. */
1085 * Pass along pointer to next node to peer_clear() when walking all
1086 * nodes on the BGP instance as that may get freed if it is a
1089 if (sort
== clear_all
) {
1090 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1092 bgp_peer_gr_flags_update(peer
);
1094 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1095 gr_router_detected
= true;
1097 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1101 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1104 if (gr_router_detected
1105 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1106 bgp_zebra_send_capabilities(bgp
, false);
1107 } else if (!gr_router_detected
1108 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1109 bgp_zebra_send_capabilities(bgp
, true);
1112 /* This is to apply read-only mode on this clear. */
1113 if (stype
== BGP_CLEAR_SOFT_NONE
)
1114 bgp
->update_delay_over
= 0;
1119 /* Clear specified neighbor. */
1120 if (sort
== clear_peer
) {
1123 /* Make sockunion for lookup. */
1124 ret
= str2sockunion(arg
, &su
);
1126 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1128 peer
= peer_lookup_by_hostname(bgp
, arg
);
1131 "Malformed address or name: %s\n",
1137 peer
= peer_lookup(bgp
, &su
);
1140 "%% BGP: Unknown neighbor - \"%s\"\n",
1146 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1147 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1149 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1151 /* if afi/safi not defined for this peer, let caller know */
1153 ret
= BGP_ERR_AF_UNCONFIGURED
;
1156 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1161 /* Clear all neighbors belonging to a specific peer-group. */
1162 if (sort
== clear_group
) {
1163 struct peer_group
*group
;
1165 group
= peer_group_lookup(bgp
, arg
);
1167 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1171 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1172 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1175 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1182 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1183 get_afi_safi_str(afi
, safi
, false), arg
);
1188 /* Clear all external (eBGP) neighbors. */
1189 if (sort
== clear_external
) {
1190 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1191 if (peer
->sort
== BGP_PEER_IBGP
)
1194 bgp_peer_gr_flags_update(peer
);
1196 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1197 gr_router_detected
= true;
1199 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1202 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1207 if (gr_router_detected
1208 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1209 bgp_zebra_send_capabilities(bgp
, false);
1210 } else if (!gr_router_detected
1211 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1212 bgp_zebra_send_capabilities(bgp
, true);
1217 "%% BGP: No external %s peer is configured\n",
1218 get_afi_safi_str(afi
, safi
, false));
1223 /* Clear all neighbors belonging to a specific AS. */
1224 if (sort
== clear_as
) {
1225 as_t as
= strtoul(arg
, NULL
, 10);
1227 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1231 bgp_peer_gr_flags_update(peer
);
1233 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1234 gr_router_detected
= true;
1236 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1239 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1244 if (gr_router_detected
1245 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1246 bgp_zebra_send_capabilities(bgp
, false);
1247 } else if (!gr_router_detected
1248 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1249 bgp_zebra_send_capabilities(bgp
, true);
1254 "%% BGP: No %s peer is configured with AS %s\n",
1255 get_afi_safi_str(afi
, safi
, false), arg
);
1263 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1264 safi_t safi
, enum clear_sort sort
,
1265 enum bgp_clear_type stype
, const char *arg
)
1269 /* BGP structure lookup. */
1271 bgp
= bgp_lookup_by_name(name
);
1273 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1277 bgp
= bgp_get_default();
1279 vty_out(vty
, "No BGP process is configured\n");
1284 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1287 /* clear soft inbound */
1288 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1293 FOREACH_AFI_SAFI (afi
, safi
)
1294 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1295 BGP_CLEAR_SOFT_IN
, NULL
);
1298 /* clear soft outbound */
1299 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1304 FOREACH_AFI_SAFI (afi
, safi
)
1305 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1306 BGP_CLEAR_SOFT_OUT
, NULL
);
1310 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1312 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1315 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1316 uint64_t flag
, int set
)
1321 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1323 return CMD_WARNING_CONFIG_FAILED
;
1326 * If 'neighbor <interface>', then this is for directly connected peers,
1327 * we should not accept disable-connected-check.
1329 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1331 "%s is directly connected peer, cannot accept disable-connected-check\n",
1333 return CMD_WARNING_CONFIG_FAILED
;
1336 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1337 peer_tx_shutdown_message_unset(peer
);
1340 ret
= peer_flag_set(peer
, flag
);
1342 ret
= peer_flag_unset(peer
, flag
);
1344 return bgp_vty_return(vty
, ret
);
1347 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1349 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1352 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1355 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1358 #include "bgpd/bgp_vty_clippy.c"
1360 DEFUN_HIDDEN (bgp_local_mac
,
1362 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1364 "Local MAC config\n"
1365 "VxLAN Network Identifier\n"
1369 "mac-mobility sequence\n"
1379 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1380 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1381 vty_out(vty
, "%% Malformed MAC address\n");
1384 memset(&ip
, 0, sizeof(ip
));
1385 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1387 bgp
= bgp_get_default();
1389 vty_out(vty
, "Default BGP instance is not there\n");
1393 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1396 vty_out(vty
, "Internal error\n");
1403 DEFUN_HIDDEN (no_bgp_local_mac
,
1404 no_bgp_local_mac_cmd
,
1405 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1408 "Local MAC config\n"
1409 "VxLAN Network Identifier\n"
1420 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1421 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1422 vty_out(vty
, "%% Malformed MAC address\n");
1425 memset(&ip
, 0, sizeof(ip
));
1427 bgp
= bgp_get_default();
1429 vty_out(vty
, "Default BGP instance is not there\n");
1433 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1435 vty_out(vty
, "Internal error\n");
1442 DEFUN (no_synchronization
,
1443 no_synchronization_cmd
,
1444 "no synchronization",
1446 "Perform IGP synchronization\n")
1451 DEFUN (no_auto_summary
,
1452 no_auto_summary_cmd
,
1455 "Enable automatic network number summarization\n")
1460 /* "router bgp" commands. */
1461 DEFUN_NOSH (router_bgp
,
1463 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1467 BGP_INSTANCE_HELP_STR
)
1470 int idx_view_vrf
= 3;
1476 const char *name
= NULL
;
1477 enum bgp_instance_type inst_type
;
1479 // "router bgp" without an ASN
1481 // Pending: Make VRF option available for ASN less config
1482 bgp
= bgp_get_default();
1485 vty_out(vty
, "%% No BGP process is configured\n");
1486 return CMD_WARNING_CONFIG_FAILED
;
1489 if (listcount(bm
->bgp
) > 1) {
1490 vty_out(vty
, "%% Please specify ASN and VRF\n");
1491 return CMD_WARNING_CONFIG_FAILED
;
1497 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1499 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1500 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1501 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1503 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1505 name
= argv
[idx_vrf
]->arg
;
1507 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1508 if (strmatch(name
, VRF_DEFAULT_NAME
))
1511 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1512 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1513 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1516 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1517 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1519 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1521 case BGP_ERR_AS_MISMATCH
:
1522 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1523 return CMD_WARNING_CONFIG_FAILED
;
1524 case BGP_ERR_INSTANCE_MISMATCH
:
1526 "BGP instance name and AS number mismatch\n");
1528 "BGP instance is already running; AS is %u\n",
1530 return CMD_WARNING_CONFIG_FAILED
;
1534 * If we just instantiated the default instance, complete
1535 * any pending VRF-VPN leaking that was configured via
1536 * earlier "router bgp X vrf FOO" blocks.
1538 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1539 vpn_leak_postchange_all();
1541 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1542 bgp_vpn_leak_export(bgp
);
1543 /* Pending: handle when user tries to change a view to vrf n vv.
1547 /* unset the auto created flag as the user config is now present */
1548 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1549 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1554 /* "no router bgp" commands. */
1555 DEFUN (no_router_bgp
,
1557 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1562 BGP_INSTANCE_HELP_STR
)
1568 const char *name
= NULL
;
1570 // "no router bgp" without an ASN
1572 // Pending: Make VRF option available for ASN less config
1573 bgp
= bgp_get_default();
1576 vty_out(vty
, "%% No BGP process is configured\n");
1577 return CMD_WARNING_CONFIG_FAILED
;
1580 if (listcount(bm
->bgp
) > 1) {
1581 vty_out(vty
, "%% Please specify ASN and VRF\n");
1582 return CMD_WARNING_CONFIG_FAILED
;
1586 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1588 return CMD_WARNING_CONFIG_FAILED
;
1591 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1594 name
= argv
[idx_vrf
]->arg
;
1595 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1596 && strmatch(name
, VRF_DEFAULT_NAME
))
1600 /* Lookup bgp structure. */
1601 bgp
= bgp_lookup(as
, name
);
1603 vty_out(vty
, "%% Can't find BGP instance\n");
1604 return CMD_WARNING_CONFIG_FAILED
;
1608 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1610 return CMD_WARNING_CONFIG_FAILED
;
1613 /* Cannot delete default instance if vrf instances exist */
1614 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1615 struct listnode
*node
;
1616 struct bgp
*tmp_bgp
;
1618 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1619 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1621 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1622 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1623 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1624 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1625 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1626 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1627 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1628 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1629 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1630 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1631 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1632 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1633 (bgp
== bgp_get_evpn() &&
1634 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1635 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1636 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1637 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1638 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1639 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1640 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1641 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1642 (hashcount(tmp_bgp
->vnihash
))) {
1644 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1645 return CMD_WARNING_CONFIG_FAILED
;
1656 /* bgp session-dscp */
1658 DEFPY (bgp_session_dscp
,
1659 bgp_session_dscp_cmd
,
1660 "bgp session-dscp (0-63)$dscp",
1662 "Override default (C6) bgp TCP session DSCP value\n"
1663 "Manually configured dscp parameter\n")
1665 bm
->tcp_dscp
= dscp
<< 2;
1670 DEFPY (no_bgp_session_dscp
,
1671 no_bgp_session_dscp_cmd
,
1672 "no bgp session-dscp [(0-63)]",
1675 "Override default (C6) bgp TCP session DSCP value\n"
1676 "Manually configured dscp parameter\n")
1678 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1683 /* BGP router-id. */
1685 DEFPY (bgp_router_id
,
1687 "bgp router-id A.B.C.D",
1689 "Override configured router identifier\n"
1690 "Manually configured router identifier\n")
1692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1693 bgp_router_id_static_set(bgp
, router_id
);
1697 DEFPY (no_bgp_router_id
,
1698 no_bgp_router_id_cmd
,
1699 "no bgp router-id [A.B.C.D]",
1702 "Override configured router identifier\n"
1703 "Manually configured router identifier\n")
1705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1707 if (router_id_str
) {
1708 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1709 vty_out(vty
, "%% BGP router-id doesn't match\n");
1710 return CMD_WARNING_CONFIG_FAILED
;
1714 router_id
.s_addr
= 0;
1715 bgp_router_id_static_set(bgp
, router_id
);
1720 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1721 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1723 "Add community specific parameters\n"
1724 "Create an alias for a community\n"
1725 "Community (AA:BB or AA:BB:CC)\n"
1728 struct community_alias ca
= {};
1729 struct community_alias
*lookup_community
;
1730 struct community_alias
*lookup_alias
;
1731 struct community
*comm
;
1732 struct lcommunity
*lcomm
;
1733 uint8_t invalid
= 0;
1735 comm
= community_str2com(community
);
1738 community_free(&comm
);
1740 lcomm
= lcommunity_str2com(community
);
1743 lcommunity_free(&lcomm
);
1746 vty_out(vty
, "Invalid community format\n");
1750 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1751 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1753 lookup_community
= bgp_ca_community_lookup(&ca
);
1754 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1757 bgp_ca_alias_delete(&ca
);
1758 bgp_ca_community_delete(&ca
);
1761 /* Lookup if community hash table has an item
1762 * with the same alias name.
1764 strlcpy(ca
.community
, lookup_alias
->community
,
1765 sizeof(ca
.community
));
1766 if (bgp_ca_community_lookup(&ca
)) {
1768 "community (%s) already has this alias (%s)\n",
1769 lookup_alias
->community
,
1770 lookup_alias
->alias
);
1773 bgp_ca_alias_delete(&ca
);
1776 if (lookup_community
) {
1777 /* Lookup if alias hash table has an item
1778 * with the same community.
1780 strlcpy(ca
.alias
, lookup_community
->alias
,
1782 if (bgp_ca_alias_lookup(&ca
)) {
1784 "alias (%s) already has this community (%s)\n",
1785 lookup_community
->alias
,
1786 lookup_community
->community
);
1789 bgp_ca_community_delete(&ca
);
1792 bgp_ca_alias_insert(&ca
);
1793 bgp_ca_community_insert(&ca
);
1799 DEFPY (bgp_global_suppress_fib_pending
,
1800 bgp_global_suppress_fib_pending_cmd
,
1801 "[no] bgp suppress-fib-pending",
1804 "Advertise only routes that are programmed in kernel to peers globally\n")
1806 bm_wait_for_fib_set(!no
);
1811 DEFPY (bgp_suppress_fib_pending
,
1812 bgp_suppress_fib_pending_cmd
,
1813 "[no] bgp suppress-fib-pending",
1816 "Advertise only routes that are programmed in kernel to peers\n")
1818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1820 bgp_suppress_fib_pending_set(bgp
, !no
);
1825 /* BGP Cluster ID. */
1826 DEFUN (bgp_cluster_id
,
1828 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1830 "Configure Route-Reflector Cluster-id\n"
1831 "Route-Reflector Cluster-id in IP address format\n"
1832 "Route-Reflector Cluster-id as 32 bit quantity\n")
1834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1837 struct in_addr cluster
;
1839 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1841 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1842 return CMD_WARNING_CONFIG_FAILED
;
1845 bgp_cluster_id_set(bgp
, &cluster
);
1846 bgp_clear_star_soft_out(vty
, bgp
->name
);
1851 DEFUN (no_bgp_cluster_id
,
1852 no_bgp_cluster_id_cmd
,
1853 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1856 "Configure Route-Reflector Cluster-id\n"
1857 "Route-Reflector Cluster-id in IP address format\n"
1858 "Route-Reflector Cluster-id as 32 bit quantity\n")
1860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1861 bgp_cluster_id_unset(bgp
);
1862 bgp_clear_star_soft_out(vty
, bgp
->name
);
1871 "Disable BGP route installation to RIB (Zebra)\n")
1873 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1875 "%% No-RIB option is already set, nothing to do here.\n");
1879 bgp_option_norib_set_runtime();
1884 DEFPY (no_bgp_norib
,
1889 "Disable BGP route installation to RIB (Zebra)\n")
1891 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1893 "%% No-RIB option is not set, nothing to do here.\n");
1897 bgp_option_norib_unset_runtime();
1902 DEFPY (no_bgp_send_extra_data
,
1903 no_bgp_send_extra_data_cmd
,
1904 "[no] bgp send-extra-data zebra",
1907 "Extra data to Zebra for display/use\n"
1911 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1913 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1918 DEFUN (bgp_confederation_identifier
,
1919 bgp_confederation_identifier_cmd
,
1920 "bgp confederation identifier (1-4294967295)",
1922 "AS confederation parameters\n"
1924 "Set routing domain confederation AS\n")
1926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1930 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1932 bgp_confederation_id_set(bgp
, as
);
1937 DEFUN (no_bgp_confederation_identifier
,
1938 no_bgp_confederation_identifier_cmd
,
1939 "no bgp confederation identifier [(1-4294967295)]",
1942 "AS confederation parameters\n"
1944 "Set routing domain confederation AS\n")
1946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1947 bgp_confederation_id_unset(bgp
);
1952 DEFUN (bgp_confederation_peers
,
1953 bgp_confederation_peers_cmd
,
1954 "bgp confederation peers (1-4294967295)...",
1956 "AS confederation parameters\n"
1957 "Peer ASs in BGP confederation\n"
1960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 for (i
= idx_asn
; i
< argc
; i
++) {
1966 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1967 bgp_confederation_peers_add(bgp
, as
);
1972 DEFUN (no_bgp_confederation_peers
,
1973 no_bgp_confederation_peers_cmd
,
1974 "no bgp confederation peers (1-4294967295)...",
1977 "AS confederation parameters\n"
1978 "Peer ASs in BGP confederation\n"
1981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1986 for (i
= idx_asn
; i
< argc
; i
++) {
1987 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1989 bgp_confederation_peers_remove(bgp
, as
);
1995 * Central routine for maximum-paths configuration.
1996 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1997 * @set: 1 for setting values, 0 for removing the max-paths config.
1999 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
2000 const char *mpaths
, uint16_t options
,
2003 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 uint16_t maxpaths
= 0;
2009 afi
= bgp_node_afi(vty
);
2010 safi
= bgp_node_safi(vty
);
2013 maxpaths
= strtol(mpaths
, NULL
, 10);
2014 if (maxpaths
> multipath_num
) {
2016 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2017 maxpaths
, multipath_num
);
2018 return CMD_WARNING_CONFIG_FAILED
;
2020 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2023 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2027 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2028 (set
== 1) ? "" : "un",
2029 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2030 maxpaths
, afi
, safi
);
2031 return CMD_WARNING_CONFIG_FAILED
;
2034 bgp_recalculate_all_bestpaths(bgp
);
2039 DEFUN (bgp_maxmed_admin
,
2040 bgp_maxmed_admin_cmd
,
2041 "bgp max-med administrative ",
2043 "Advertise routes with max-med\n"
2044 "Administratively applied, for an indefinite period\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2048 bgp
->v_maxmed_admin
= 1;
2049 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2051 bgp_maxmed_update(bgp
);
2056 DEFUN (bgp_maxmed_admin_medv
,
2057 bgp_maxmed_admin_medv_cmd
,
2058 "bgp max-med administrative (0-4294967295)",
2060 "Advertise routes with max-med\n"
2061 "Administratively applied, for an indefinite period\n"
2062 "Max MED value to be used\n")
2064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2067 bgp
->v_maxmed_admin
= 1;
2068 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2070 bgp_maxmed_update(bgp
);
2075 DEFUN (no_bgp_maxmed_admin
,
2076 no_bgp_maxmed_admin_cmd
,
2077 "no bgp max-med administrative [(0-4294967295)]",
2080 "Advertise routes with max-med\n"
2081 "Administratively applied, for an indefinite period\n"
2082 "Max MED value to be used\n")
2084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2085 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2086 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2087 bgp_maxmed_update(bgp
);
2092 DEFUN (bgp_maxmed_onstartup
,
2093 bgp_maxmed_onstartup_cmd
,
2094 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2096 "Advertise routes with max-med\n"
2097 "Effective on a startup\n"
2098 "Time (seconds) period for max-med\n"
2099 "Max MED value to be used\n")
2101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2104 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2105 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2106 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2107 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2109 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2111 bgp_maxmed_update(bgp
);
2116 DEFUN (no_bgp_maxmed_onstartup
,
2117 no_bgp_maxmed_onstartup_cmd
,
2118 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2121 "Advertise routes with max-med\n"
2122 "Effective on a startup\n"
2123 "Time (seconds) period for max-med\n"
2124 "Max MED value to be used\n")
2126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2128 /* Cancel max-med onstartup if its on */
2129 if (bgp
->t_maxmed_onstartup
) {
2130 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2131 bgp
->maxmed_onstartup_over
= 1;
2134 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2135 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2137 bgp_maxmed_update(bgp
);
2142 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2143 uint16_t update_delay
,
2144 uint16_t establish_wait
)
2146 struct listnode
*node
, *nnode
;
2148 bool vrf_cfg
= false;
2151 * See if update-delay is set per-vrf and warn user to delete it
2152 * Note that we only need to check this if this is the first time
2153 * setting the global config.
2155 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2156 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2157 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2159 "%% update-delay configuration found in vrf %s\n",
2160 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2170 "%%Failed: global update-delay config not permitted\n");
2174 if (!establish_wait
) { /* update-delay <delay> */
2175 bm
->v_update_delay
= update_delay
;
2176 bm
->v_establish_wait
= bm
->v_update_delay
;
2178 /* update-delay <delay> <establish-wait> */
2179 if (update_delay
< establish_wait
) {
2181 "%%Failed: update-delay less than the establish-wait!\n");
2182 return CMD_WARNING_CONFIG_FAILED
;
2185 bm
->v_update_delay
= update_delay
;
2186 bm
->v_establish_wait
= establish_wait
;
2189 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2190 bgp
->v_update_delay
= bm
->v_update_delay
;
2191 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2197 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2199 struct listnode
*node
, *nnode
;
2202 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2203 bm
->v_establish_wait
= bm
->v_update_delay
;
2205 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2206 bgp
->v_update_delay
= bm
->v_update_delay
;
2207 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2213 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2214 uint16_t establish_wait
)
2216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2218 /* if configured globally, per-instance config is not allowed */
2219 if (bm
->v_update_delay
) {
2221 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2222 return CMD_WARNING_CONFIG_FAILED
;
2226 if (!establish_wait
) /* update-delay <delay> */
2228 bgp
->v_update_delay
= update_delay
;
2229 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2233 /* update-delay <delay> <establish-wait> */
2234 if (update_delay
< establish_wait
) {
2236 "%%Failed: update-delay less than the establish-wait!\n");
2237 return CMD_WARNING_CONFIG_FAILED
;
2240 bgp
->v_update_delay
= update_delay
;
2241 bgp
->v_establish_wait
= establish_wait
;
2246 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2250 /* If configured globally, cannot remove from one bgp instance */
2251 if (bm
->v_update_delay
) {
2253 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2254 return CMD_WARNING_CONFIG_FAILED
;
2256 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2257 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2262 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2264 /* If configured globally, no need to display per-instance value */
2265 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2266 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2267 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2268 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2273 /* Global update-delay configuration */
2274 DEFPY (bgp_global_update_delay
,
2275 bgp_global_update_delay_cmd
,
2276 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2278 "Force initial delay for best-path and updates for all bgp instances\n"
2279 "Max delay in seconds\n"
2280 "Establish wait in seconds\n")
2282 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2285 /* Global update-delay deconfiguration */
2286 DEFPY (no_bgp_global_update_delay
,
2287 no_bgp_global_update_delay_cmd
,
2288 "no bgp update-delay [(0-3600) [(1-3600)]]",
2291 "Force initial delay for best-path and updates\n"
2292 "Max delay in seconds\n"
2293 "Establish wait in seconds\n")
2295 return bgp_global_update_delay_deconfig_vty(vty
);
2298 /* Update-delay configuration */
2300 DEFPY (bgp_update_delay
,
2301 bgp_update_delay_cmd
,
2302 "update-delay (0-3600)$delay [(1-3600)$wait]",
2303 "Force initial delay for best-path and updates\n"
2304 "Max delay in seconds\n"
2305 "Establish wait in seconds\n")
2307 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2310 /* Update-delay deconfiguration */
2311 DEFPY (no_bgp_update_delay
,
2312 no_bgp_update_delay_cmd
,
2313 "no update-delay [(0-3600) [(1-3600)]]",
2315 "Force initial delay for best-path and updates\n"
2316 "Max delay in seconds\n"
2317 "Establish wait in seconds\n")
2319 return bgp_update_delay_deconfig_vty(vty
);
2323 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2328 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2329 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2334 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2339 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2340 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2345 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2348 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2349 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2350 vty_out(vty
, " write-quanta %d\n", quanta
);
2353 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2356 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2357 if (quanta
!= BGP_READ_PACKET_MAX
)
2358 vty_out(vty
, " read-quanta %d\n", quanta
);
2361 /* Packet quanta configuration
2363 * XXX: The value set here controls the size of a stack buffer in the IO
2364 * thread. When changing these limits be careful to prevent stack overflow.
2366 * Furthermore, the maximums used here should correspond to
2367 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2369 DEFPY (bgp_wpkt_quanta
,
2370 bgp_wpkt_quanta_cmd
,
2371 "[no] write-quanta (1-64)$quanta",
2373 "How many packets to write to peer socket per run\n"
2374 "Number of packets\n")
2376 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2379 DEFPY (bgp_rpkt_quanta
,
2380 bgp_rpkt_quanta_cmd
,
2381 "[no] read-quanta (1-10)$quanta",
2383 "How many packets to read from peer socket per I/O cycle\n"
2384 "Number of packets\n")
2386 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2389 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2391 if (!bgp
->heuristic_coalesce
)
2392 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2395 /* BGP TCP keepalive */
2396 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2398 if (bgp
->tcp_keepalive_idle
) {
2399 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2400 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2401 bgp
->tcp_keepalive_probes
);
2405 DEFUN (bgp_coalesce_time
,
2406 bgp_coalesce_time_cmd
,
2407 "coalesce-time (0-4294967295)",
2408 "Subgroup coalesce timer\n"
2409 "Subgroup coalesce timer value (in ms)\n")
2411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2415 bgp
->heuristic_coalesce
= false;
2417 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2418 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2423 DEFUN (no_bgp_coalesce_time
,
2424 no_bgp_coalesce_time_cmd
,
2425 "no coalesce-time (0-4294967295)",
2427 "Subgroup coalesce timer\n"
2428 "Subgroup coalesce timer value (in ms)\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2432 bgp
->heuristic_coalesce
= true;
2433 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2437 /* Maximum-paths configuration */
2438 DEFUN (bgp_maxpaths
,
2440 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2441 "Forward packets over multiple paths\n"
2442 "Number of paths\n")
2445 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2446 argv
[idx_number
]->arg
, 0, 1);
2449 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2450 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2451 "Forward packets over multiple paths\n"
2452 "Number of paths\n")
2454 DEFUN (bgp_maxpaths_ibgp
,
2455 bgp_maxpaths_ibgp_cmd
,
2456 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2457 "Forward packets over multiple paths\n"
2459 "Number of paths\n")
2462 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2463 argv
[idx_number
]->arg
, 0, 1);
2466 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2467 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2468 "Forward packets over multiple paths\n"
2470 "Number of paths\n")
2472 DEFUN (bgp_maxpaths_ibgp_cluster
,
2473 bgp_maxpaths_ibgp_cluster_cmd
,
2474 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2475 "Forward packets over multiple paths\n"
2478 "Match the cluster length\n")
2481 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2482 argv
[idx_number
]->arg
, true, 1);
2485 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2486 "maximum-paths ibgp " CMD_RANGE_STR(
2487 1, MULTIPATH_NUM
) " equal-cluster-length",
2488 "Forward packets over multiple paths\n"
2491 "Match the cluster length\n")
2493 DEFUN (no_bgp_maxpaths
,
2494 no_bgp_maxpaths_cmd
,
2495 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2497 "Forward packets over multiple paths\n"
2498 "Number of paths\n")
2500 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2503 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2504 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2505 "Forward packets over multiple paths\n"
2506 "Number of paths\n")
2508 DEFUN (no_bgp_maxpaths_ibgp
,
2509 no_bgp_maxpaths_ibgp_cmd
,
2510 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2512 "Forward packets over multiple paths\n"
2515 "Match the cluster length\n")
2517 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2520 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2521 "no maximum-paths ibgp [" CMD_RANGE_STR(
2522 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2524 "Forward packets over multiple paths\n"
2527 "Match the cluster length\n")
2529 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2530 afi_t afi
, safi_t safi
)
2532 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2533 vty_out(vty
, " maximum-paths %d\n",
2534 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2537 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2538 vty_out(vty
, " maximum-paths ibgp %d",
2539 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2540 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2541 vty_out(vty
, " equal-cluster-length");
2550 "timers bgp (0-65535) (0-65535)",
2551 "Adjust routing timers\n"
2553 "Keepalive interval\n"
2556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2558 int idx_number_2
= 3;
2559 unsigned long keepalive
= 0;
2560 unsigned long holdtime
= 0;
2562 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2563 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2565 /* Holdtime value check. */
2566 if (holdtime
< 3 && holdtime
!= 0) {
2568 "%% hold time value must be either 0 or greater than 3\n");
2569 return CMD_WARNING_CONFIG_FAILED
;
2572 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2573 BGP_DEFAULT_DELAYOPEN
);
2578 DEFUN (no_bgp_timers
,
2580 "no timers bgp [(0-65535) (0-65535)]",
2582 "Adjust routing timers\n"
2584 "Keepalive interval\n"
2587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2588 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2589 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2594 /* BGP minimum holdtime. */
2596 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2597 "bgp minimum-holdtime (1-65535)",
2598 "BGP specific commands\n"
2599 "BGP minimum holdtime\n"
2602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2604 unsigned long min_holdtime
;
2606 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2608 bgp
->default_min_holdtime
= min_holdtime
;
2613 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2614 "no bgp minimum-holdtime [(1-65535)]",
2616 "BGP specific commands\n"
2617 "BGP minimum holdtime\n"
2620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2622 bgp
->default_min_holdtime
= 0;
2627 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2628 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2630 "TCP keepalive parameters\n"
2631 "TCP keepalive idle time (seconds)\n"
2632 "TCP keepalive interval (seconds)\n"
2633 "TCP keepalive maximum probes\n")
2635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2637 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2643 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2644 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2647 "TCP keepalive parameters\n"
2648 "TCP keepalive idle time (seconds)\n"
2649 "TCP keepalive interval (seconds)\n"
2650 "TCP keepalive maximum probes\n")
2652 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2654 bgp_tcp_keepalive_unset(bgp
);
2659 DEFUN (bgp_client_to_client_reflection
,
2660 bgp_client_to_client_reflection_cmd
,
2661 "bgp client-to-client reflection",
2663 "Configure client to client route reflection\n"
2664 "reflection of routes allowed\n")
2666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2667 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2668 bgp_clear_star_soft_out(vty
, bgp
->name
);
2673 DEFUN (no_bgp_client_to_client_reflection
,
2674 no_bgp_client_to_client_reflection_cmd
,
2675 "no bgp client-to-client reflection",
2678 "Configure client to client route reflection\n"
2679 "reflection of routes allowed\n")
2681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2682 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2683 bgp_clear_star_soft_out(vty
, bgp
->name
);
2688 /* "bgp always-compare-med" configuration. */
2689 DEFUN (bgp_always_compare_med
,
2690 bgp_always_compare_med_cmd
,
2691 "bgp always-compare-med",
2693 "Allow comparing MED from different neighbors\n")
2695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2696 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2697 bgp_recalculate_all_bestpaths(bgp
);
2702 DEFUN (no_bgp_always_compare_med
,
2703 no_bgp_always_compare_med_cmd
,
2704 "no bgp always-compare-med",
2707 "Allow comparing MED from different neighbors\n")
2709 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2710 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2711 bgp_recalculate_all_bestpaths(bgp
);
2717 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2718 "bgp ebgp-requires-policy",
2720 "Require in and out policy for eBGP peers (RFC8212)\n")
2722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2723 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2727 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2728 "no bgp ebgp-requires-policy",
2731 "Require in and out policy for eBGP peers (RFC8212)\n")
2733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2734 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2738 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2739 "bgp suppress-duplicates",
2741 "Suppress duplicate updates if the route actually not changed\n")
2743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2744 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2748 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2749 "no bgp suppress-duplicates",
2752 "Suppress duplicate updates if the route actually not changed\n")
2754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2755 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2759 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2760 "bgp reject-as-sets",
2762 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2765 struct listnode
*node
, *nnode
;
2768 bgp
->reject_as_sets
= true;
2770 /* Reset existing BGP sessions to reject routes
2771 * with aspath containing AS_SET or AS_CONFED_SET.
2773 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2774 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2775 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2776 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2777 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2784 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2785 "no bgp reject-as-sets",
2788 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2791 struct listnode
*node
, *nnode
;
2794 bgp
->reject_as_sets
= false;
2796 /* Reset existing BGP sessions to reject routes
2797 * with aspath containing AS_SET or AS_CONFED_SET.
2799 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2800 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2801 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2802 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2803 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2810 /* "bgp deterministic-med" configuration. */
2811 DEFUN (bgp_deterministic_med
,
2812 bgp_deterministic_med_cmd
,
2813 "bgp deterministic-med",
2815 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2819 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2820 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2821 bgp_recalculate_all_bestpaths(bgp
);
2827 DEFUN (no_bgp_deterministic_med
,
2828 no_bgp_deterministic_med_cmd
,
2829 "no bgp deterministic-med",
2832 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2835 int bestpath_per_as_used
;
2839 struct listnode
*node
, *nnode
;
2841 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2842 bestpath_per_as_used
= 0;
2844 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2845 FOREACH_AFI_SAFI (afi
, safi
)
2846 if (bgp_addpath_dmed_required(
2847 peer
->addpath_type
[afi
][safi
])) {
2848 bestpath_per_as_used
= 1;
2852 if (bestpath_per_as_used
)
2856 if (bestpath_per_as_used
) {
2858 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2859 return CMD_WARNING_CONFIG_FAILED
;
2861 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2862 bgp_recalculate_all_bestpaths(bgp
);
2869 /* "bgp graceful-restart mode" configuration. */
2870 DEFUN (bgp_graceful_restart
,
2871 bgp_graceful_restart_cmd
,
2872 "bgp graceful-restart",
2877 int ret
= BGP_GR_FAILURE
;
2879 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2880 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2884 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2886 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2889 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2890 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2892 "Graceful restart configuration changed, reset all peers to take effect\n");
2893 return bgp_vty_return(vty
, ret
);
2896 DEFUN (no_bgp_graceful_restart
,
2897 no_bgp_graceful_restart_cmd
,
2898 "no bgp graceful-restart",
2904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2907 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2909 int ret
= BGP_GR_FAILURE
;
2911 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2913 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2916 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2917 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2919 "Graceful restart configuration changed, reset all peers to take effect\n");
2921 return bgp_vty_return(vty
, ret
);
2924 DEFUN (bgp_graceful_restart_stalepath_time
,
2925 bgp_graceful_restart_stalepath_time_cmd
,
2926 "bgp graceful-restart stalepath-time (1-4095)",
2928 "Graceful restart capability parameters\n"
2929 "Set the max time to hold onto restarting peer's stale paths\n"
2930 "Delay value (seconds)\n")
2932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2936 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2937 bgp
->stalepath_time
= stalepath
;
2941 DEFUN (bgp_graceful_restart_restart_time
,
2942 bgp_graceful_restart_restart_time_cmd
,
2943 "bgp graceful-restart restart-time (0-4095)",
2945 "Graceful restart capability parameters\n"
2946 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2947 "Delay value (seconds)\n")
2949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2953 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2954 bgp
->restart_time
= restart
;
2958 DEFUN (bgp_graceful_restart_select_defer_time
,
2959 bgp_graceful_restart_select_defer_time_cmd
,
2960 "bgp graceful-restart select-defer-time (0-3600)",
2962 "Graceful restart capability parameters\n"
2963 "Set the time to defer the BGP route selection after restart\n"
2964 "Delay value (seconds, 0 - disable)\n")
2966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2968 uint32_t defer_time
;
2970 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2971 bgp
->select_defer_time
= defer_time
;
2972 if (defer_time
== 0)
2973 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2975 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2980 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2981 no_bgp_graceful_restart_stalepath_time_cmd
,
2982 "no bgp graceful-restart stalepath-time [(1-4095)]",
2985 "Graceful restart capability parameters\n"
2986 "Set the max time to hold onto restarting peer's stale paths\n"
2987 "Delay value (seconds)\n")
2989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2991 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2995 DEFUN (no_bgp_graceful_restart_restart_time
,
2996 no_bgp_graceful_restart_restart_time_cmd
,
2997 "no bgp graceful-restart restart-time [(0-4095)]",
3000 "Graceful restart capability parameters\n"
3001 "Set the time to wait to delete stale routes before a BGP open message is received\n"
3002 "Delay value (seconds)\n")
3004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3006 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3010 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3011 no_bgp_graceful_restart_select_defer_time_cmd
,
3012 "no bgp graceful-restart select-defer-time [(0-3600)]",
3015 "Graceful restart capability parameters\n"
3016 "Set the time to defer the BGP route selection after restart\n"
3017 "Delay value (seconds)\n")
3019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3021 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3022 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3027 DEFUN (bgp_graceful_restart_preserve_fw
,
3028 bgp_graceful_restart_preserve_fw_cmd
,
3029 "bgp graceful-restart preserve-fw-state",
3031 "Graceful restart capability parameters\n"
3032 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3035 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3039 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3040 no_bgp_graceful_restart_preserve_fw_cmd
,
3041 "no bgp graceful-restart preserve-fw-state",
3044 "Graceful restart capability parameters\n"
3045 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3048 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3052 DEFPY (bgp_graceful_restart_notification
,
3053 bgp_graceful_restart_notification_cmd
,
3054 "[no$no] bgp graceful-restart notification",
3057 "Graceful restart capability parameters\n"
3058 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3063 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3065 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3070 DEFPY (bgp_administrative_reset
,
3071 bgp_administrative_reset_cmd
,
3072 "[no$no] bgp hard-administrative-reset",
3075 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3080 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3082 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3087 DEFUN (bgp_graceful_restart_disable
,
3088 bgp_graceful_restart_disable_cmd
,
3089 "bgp graceful-restart-disable",
3093 int ret
= BGP_GR_FAILURE
;
3095 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3097 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3101 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3103 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3106 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3108 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3110 "Graceful restart configuration changed, reset all peers to take effect\n");
3112 return bgp_vty_return(vty
, ret
);
3115 DEFUN (no_bgp_graceful_restart_disable
,
3116 no_bgp_graceful_restart_disable_cmd
,
3117 "no bgp graceful-restart-disable",
3123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3125 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3127 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3129 int ret
= BGP_GR_FAILURE
;
3131 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3133 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3136 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3138 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3140 "Graceful restart configuration changed, reset all peers to take effect\n");
3142 return bgp_vty_return(vty
, ret
);
3145 DEFUN (bgp_neighbor_graceful_restart_set
,
3146 bgp_neighbor_graceful_restart_set_cmd
,
3147 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3155 int ret
= BGP_GR_FAILURE
;
3157 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3159 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3161 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3163 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3165 return CMD_WARNING_CONFIG_FAILED
;
3167 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3169 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3170 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3172 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3174 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3176 "Graceful restart configuration changed, reset this peer to take effect\n");
3178 return bgp_vty_return(vty
, ret
);
3181 DEFUN (no_bgp_neighbor_graceful_restart
,
3182 no_bgp_neighbor_graceful_restart_set_cmd
,
3183 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3191 int ret
= BGP_GR_FAILURE
;
3194 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3196 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3198 return CMD_WARNING_CONFIG_FAILED
;
3200 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3202 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3204 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_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] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3213 "Graceful restart configuration changed, reset this peer to take effect\n");
3215 return bgp_vty_return(vty
, ret
);
3218 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3219 bgp_neighbor_graceful_restart_helper_set_cmd
,
3220 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3223 GR_NEIGHBOR_HELPER_CMD
3228 int ret
= BGP_GR_FAILURE
;
3230 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3232 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3234 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3236 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3239 return CMD_WARNING_CONFIG_FAILED
;
3242 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3244 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3245 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3247 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3249 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3251 "Graceful restart configuration changed, reset this peer to take effect\n");
3253 return bgp_vty_return(vty
, ret
);
3256 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3257 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3258 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3262 NO_GR_NEIGHBOR_HELPER_CMD
3266 int ret
= BGP_GR_FAILURE
;
3269 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3271 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3273 return CMD_WARNING_CONFIG_FAILED
;
3275 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3277 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3279 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3281 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3282 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3284 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3286 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3288 "Graceful restart configuration changed, reset this peer to take effect\n");
3290 return bgp_vty_return(vty
, ret
);
3293 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3294 bgp_neighbor_graceful_restart_disable_set_cmd
,
3295 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3298 GR_NEIGHBOR_DISABLE_CMD
3303 int ret
= BGP_GR_FAILURE
;
3305 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3307 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3309 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3317 if (peer
->bgp
->t_startup
)
3318 bgp_peer_gr_flags_update(peer
);
3320 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3321 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3323 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3325 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3327 "Graceful restart configuration changed, reset this peer to take effect\n");
3329 return bgp_vty_return(vty
, ret
);
3332 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3333 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3334 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3338 NO_GR_NEIGHBOR_DISABLE_CMD
3342 int ret
= BGP_GR_FAILURE
;
3345 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3349 return CMD_WARNING_CONFIG_FAILED
;
3351 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3353 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3355 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3357 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3358 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3360 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3362 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3364 "Graceful restart configuration changed, reset this peer to take effect\n");
3366 return bgp_vty_return(vty
, ret
);
3369 DEFPY (neighbor_graceful_shutdown
,
3370 neighbor_graceful_shutdown_cmd
,
3371 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3375 "Graceful shutdown\n")
3380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3383 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3385 return CMD_WARNING_CONFIG_FAILED
;
3388 ret
= peer_flag_unset_vty(vty
, neighbor
,
3389 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3391 ret
= peer_flag_set_vty(vty
, neighbor
,
3392 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3394 FOREACH_AFI_SAFI (afi
, safi
) {
3395 if (!peer
->afc
[afi
][safi
])
3398 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3405 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3406 bgp_graceful_restart_disable_eor_cmd
,
3407 "bgp graceful-restart disable-eor",
3409 "Graceful restart configuration parameters\n"
3410 "Disable EOR Check\n")
3412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3413 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3418 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3419 no_bgp_graceful_restart_disable_eor_cmd
,
3420 "no bgp graceful-restart disable-eor",
3423 "Graceful restart configuration parameters\n"
3424 "Disable EOR Check\n")
3426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3427 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3432 DEFUN (bgp_graceful_restart_rib_stale_time
,
3433 bgp_graceful_restart_rib_stale_time_cmd
,
3434 "bgp graceful-restart rib-stale-time (1-3600)",
3436 "Graceful restart configuration parameters\n"
3437 "Specify the stale route removal timer in rib\n"
3438 "Delay value (seconds)\n")
3440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3442 uint32_t stale_time
;
3444 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3445 bgp
->rib_stale_time
= stale_time
;
3446 /* Send the stale timer update message to RIB */
3447 if (bgp_zebra_stale_timer_update(bgp
))
3453 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3454 no_bgp_graceful_restart_rib_stale_time_cmd
,
3455 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3458 "Graceful restart configuration parameters\n"
3459 "Specify the stale route removal timer in rib\n"
3460 "Delay value (seconds)\n")
3462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3464 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3465 /* Send the stale timer update message to RIB */
3466 if (bgp_zebra_stale_timer_update(bgp
))
3472 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3473 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3475 "Enable Long-lived Graceful Restart\n"
3476 "Specifies maximum time to wait before purging long-lived stale routes\n"
3477 "Stale time value (seconds)\n")
3479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3481 uint32_t llgr_stale_time
;
3483 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3484 bgp
->llgr_stale_time
= llgr_stale_time
;
3489 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3490 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3492 "Enable Long-lived Graceful Restart\n"
3493 "Specifies maximum time to wait before purging long-lived stale routes\n"
3494 "Stale time value (seconds)\n")
3496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3498 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3503 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3506 bgp_static_redo_import_check(bgp
);
3507 bgp_redistribute_redo(bgp
);
3508 bgp_clear_star_soft_out(vty
, bgp
->name
);
3509 bgp_clear_star_soft_in(vty
, bgp
->name
);
3512 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3514 struct listnode
*node
, *nnode
;
3516 bool vrf_cfg
= false;
3518 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3521 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3522 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3523 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3525 "%% graceful-shutdown configuration found in vrf %s\n",
3526 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3527 VRF_DEFAULT_NAME
: bgp
->name
);
3534 "%%Failed: global graceful-shutdown not permitted\n");
3538 /* Set flag globally */
3539 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3541 /* Initiate processing for all BGP instances. */
3542 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3543 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3548 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3550 struct listnode
*node
, *nnode
;
3553 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3556 /* Unset flag globally */
3557 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3559 /* Initiate processing for all BGP instances. */
3560 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3561 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3566 /* "bgp graceful-shutdown" configuration */
3567 DEFUN (bgp_graceful_shutdown
,
3568 bgp_graceful_shutdown_cmd
,
3569 "bgp graceful-shutdown",
3571 "Graceful shutdown parameters\n")
3573 if (vty
->node
== CONFIG_NODE
)
3574 return bgp_global_graceful_shutdown_config_vty(vty
);
3576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3578 /* if configured globally, per-instance config is not allowed */
3579 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3581 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3582 return CMD_WARNING_CONFIG_FAILED
;
3585 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3586 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3587 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3593 DEFUN (no_bgp_graceful_shutdown
,
3594 no_bgp_graceful_shutdown_cmd
,
3595 "no bgp graceful-shutdown",
3598 "Graceful shutdown parameters\n")
3600 if (vty
->node
== CONFIG_NODE
)
3601 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3605 /* If configured globally, cannot remove from one bgp instance */
3606 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3608 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3609 return CMD_WARNING_CONFIG_FAILED
;
3612 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3613 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3614 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3620 /* "bgp fast-external-failover" configuration. */
3621 DEFUN (bgp_fast_external_failover
,
3622 bgp_fast_external_failover_cmd
,
3623 "bgp fast-external-failover",
3625 "Immediately reset session if a link to a directly connected external peer goes down\n")
3627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3628 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3632 DEFUN (no_bgp_fast_external_failover
,
3633 no_bgp_fast_external_failover_cmd
,
3634 "no bgp fast-external-failover",
3637 "Immediately reset session if a link to a directly connected external peer goes down\n")
3639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3640 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3644 DEFPY (bgp_bestpath_aigp
,
3645 bgp_bestpath_aigp_cmd
,
3646 "[no$no] bgp bestpath aigp",
3649 "Change the default bestpath selection\n"
3650 "Evaluate the AIGP attribute during the best path selection process\n")
3652 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3655 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3657 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3659 bgp_recalculate_all_bestpaths(bgp
);
3664 /* "bgp bestpath compare-routerid" configuration. */
3665 DEFUN (bgp_bestpath_compare_router_id
,
3666 bgp_bestpath_compare_router_id_cmd
,
3667 "bgp bestpath compare-routerid",
3669 "Change the default bestpath selection\n"
3670 "Compare router-id for identical EBGP paths\n")
3672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3673 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3674 bgp_recalculate_all_bestpaths(bgp
);
3679 DEFUN (no_bgp_bestpath_compare_router_id
,
3680 no_bgp_bestpath_compare_router_id_cmd
,
3681 "no bgp bestpath compare-routerid",
3684 "Change the default bestpath selection\n"
3685 "Compare router-id for identical EBGP paths\n")
3687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3688 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3689 bgp_recalculate_all_bestpaths(bgp
);
3694 /* "bgp bestpath as-path ignore" configuration. */
3695 DEFUN (bgp_bestpath_aspath_ignore
,
3696 bgp_bestpath_aspath_ignore_cmd
,
3697 "bgp bestpath as-path ignore",
3699 "Change the default bestpath selection\n"
3700 "AS-path attribute\n"
3701 "Ignore as-path length in selecting a route\n")
3703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3704 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3705 bgp_recalculate_all_bestpaths(bgp
);
3710 DEFUN (no_bgp_bestpath_aspath_ignore
,
3711 no_bgp_bestpath_aspath_ignore_cmd
,
3712 "no bgp bestpath as-path ignore",
3715 "Change the default bestpath selection\n"
3716 "AS-path attribute\n"
3717 "Ignore as-path length in selecting a route\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3721 bgp_recalculate_all_bestpaths(bgp
);
3726 /* "bgp bestpath as-path confed" configuration. */
3727 DEFUN (bgp_bestpath_aspath_confed
,
3728 bgp_bestpath_aspath_confed_cmd
,
3729 "bgp bestpath as-path confed",
3731 "Change the default bestpath selection\n"
3732 "AS-path attribute\n"
3733 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3736 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3737 bgp_recalculate_all_bestpaths(bgp
);
3742 DEFUN (no_bgp_bestpath_aspath_confed
,
3743 no_bgp_bestpath_aspath_confed_cmd
,
3744 "no bgp bestpath as-path confed",
3747 "Change the default bestpath selection\n"
3748 "AS-path attribute\n"
3749 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3752 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3753 bgp_recalculate_all_bestpaths(bgp
);
3758 /* "bgp bestpath as-path multipath-relax" configuration. */
3759 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3760 bgp_bestpath_aspath_multipath_relax_cmd
,
3761 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3763 "Change the default bestpath selection\n"
3764 "AS-path attribute\n"
3765 "Allow load sharing across routes that have different AS paths (but same length)\n"
3766 "Generate an AS_SET\n"
3767 "Do not generate an AS_SET\n")
3769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3771 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3773 /* no-as-set is now the default behavior so we can silently
3775 if (argv_find(argv
, argc
, "as-set", &idx
))
3776 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3778 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3780 bgp_recalculate_all_bestpaths(bgp
);
3785 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3786 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3787 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3790 "Change the default bestpath selection\n"
3791 "AS-path attribute\n"
3792 "Allow load sharing across routes that have different AS paths (but same length)\n"
3793 "Generate an AS_SET\n"
3794 "Do not generate an AS_SET\n")
3796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3797 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3798 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3799 bgp_recalculate_all_bestpaths(bgp
);
3804 /* "bgp bestpath peer-type multipath-relax" configuration. */
3805 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3806 bgp_bestpath_peer_type_multipath_relax_cmd
,
3807 "bgp bestpath peer-type multipath-relax",
3809 "Change the default bestpath selection\n"
3811 "Allow load sharing across routes learned from different peer types\n")
3813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3814 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3815 bgp_recalculate_all_bestpaths(bgp
);
3820 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3821 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3822 "no bgp bestpath peer-type multipath-relax",
3824 "Change the default bestpath selection\n"
3826 "Allow load sharing across routes learned from different peer types\n")
3828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3829 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3830 bgp_recalculate_all_bestpaths(bgp
);
3835 /* "bgp log-neighbor-changes" configuration. */
3836 DEFUN (bgp_log_neighbor_changes
,
3837 bgp_log_neighbor_changes_cmd
,
3838 "bgp log-neighbor-changes",
3840 "Log neighbor up/down and reset reason\n")
3842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3843 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3847 DEFUN (no_bgp_log_neighbor_changes
,
3848 no_bgp_log_neighbor_changes_cmd
,
3849 "no bgp log-neighbor-changes",
3852 "Log neighbor up/down and reset reason\n")
3854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3855 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3859 /* "bgp bestpath med" configuration. */
3860 DEFUN (bgp_bestpath_med
,
3861 bgp_bestpath_med_cmd
,
3862 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3864 "Change the default bestpath selection\n"
3866 "Compare MED among confederation paths\n"
3867 "Treat missing MED as the least preferred one\n"
3868 "Treat missing MED as the least preferred one\n"
3869 "Compare MED among confederation paths\n")
3871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3874 if (argv_find(argv
, argc
, "confed", &idx
))
3875 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3877 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3878 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3880 bgp_recalculate_all_bestpaths(bgp
);
3885 DEFUN (no_bgp_bestpath_med
,
3886 no_bgp_bestpath_med_cmd
,
3887 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3890 "Change the default bestpath selection\n"
3892 "Compare MED among confederation paths\n"
3893 "Treat missing MED as the least preferred one\n"
3894 "Treat missing MED as the least preferred one\n"
3895 "Compare MED among confederation paths\n")
3897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3900 if (argv_find(argv
, argc
, "confed", &idx
))
3901 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3903 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3904 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3906 bgp_recalculate_all_bestpaths(bgp
);
3911 /* "bgp bestpath bandwidth" configuration. */
3912 DEFPY (bgp_bestpath_bw
,
3913 bgp_bestpath_bw_cmd
,
3914 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3916 "Change the default bestpath selection\n"
3917 "Link Bandwidth attribute\n"
3918 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3919 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3920 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3927 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3928 return CMD_ERR_INCOMPLETE
;
3930 if (!strcmp(bw_cfg
, "ignore"))
3931 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3932 else if (!strcmp(bw_cfg
, "skip-missing"))
3933 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3934 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3935 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3937 return CMD_ERR_NO_MATCH
;
3939 /* This config is used in route install, so redo that. */
3940 FOREACH_AFI_SAFI (afi
, safi
) {
3941 if (!bgp_fibupd_safi(safi
))
3943 bgp_zebra_announce_table(bgp
, afi
, safi
);
3949 DEFPY (no_bgp_bestpath_bw
,
3950 no_bgp_bestpath_bw_cmd
,
3951 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3954 "Change the default bestpath selection\n"
3955 "Link Bandwidth attribute\n"
3956 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3957 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3958 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3964 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3966 /* This config is used in route install, so redo that. */
3967 FOREACH_AFI_SAFI (afi
, safi
) {
3968 if (!bgp_fibupd_safi(safi
))
3970 bgp_zebra_announce_table(bgp
, afi
, safi
);
3975 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3976 "[no] bgp default <ipv4-unicast|"
3979 "ipv4-labeled-unicast|"
3984 "ipv6-labeled-unicast|"
3986 "l2vpn-evpn>$afi_safi",
3989 "Configure BGP defaults\n"
3990 "Activate ipv4-unicast for a peer by default\n"
3991 "Activate ipv4-multicast for a peer by default\n"
3992 "Activate ipv4-vpn for a peer by default\n"
3993 "Activate ipv4-labeled-unicast for a peer by default\n"
3994 "Activate ipv4-flowspec for a peer by default\n"
3995 "Activate ipv6-unicast for a peer by default\n"
3996 "Activate ipv6-multicast for a peer by default\n"
3997 "Activate ipv6-vpn for a peer by default\n"
3998 "Activate ipv6-labeled-unicast for a peer by default\n"
3999 "Activate ipv6-flowspec for a peer by default\n"
4000 "Activate l2vpn-evpn for a peer by default\n")
4002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4003 char afi_safi_str
[strlen(afi_safi
) + 1];
4004 char *afi_safi_str_tok
;
4006 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4007 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4008 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4009 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4013 * Impossible situation but making coverity happy
4015 assert(afi
!= AFI_MAX
);
4017 if (strmatch(safi_str
, "labeled"))
4018 safi
= bgp_vty_safi_from_str("labeled-unicast");
4020 safi
= bgp_vty_safi_from_str(safi_str
);
4022 assert(safi
!= SAFI_MAX
);
4024 bgp
->default_af
[afi
][safi
] = false;
4026 if ((safi
== SAFI_LABELED_UNICAST
4027 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4028 || (safi
== SAFI_UNICAST
4029 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4030 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4032 bgp
->default_af
[afi
][safi
] = true;
4038 /* Display hostname in certain command outputs */
4039 DEFUN (bgp_default_show_hostname
,
4040 bgp_default_show_hostname_cmd
,
4041 "bgp default show-hostname",
4043 "Configure BGP defaults\n"
4044 "Show hostname in certain command outputs\n")
4046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4047 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4051 DEFUN (no_bgp_default_show_hostname
,
4052 no_bgp_default_show_hostname_cmd
,
4053 "no bgp default show-hostname",
4056 "Configure BGP defaults\n"
4057 "Show hostname in certain command outputs\n")
4059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4060 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4064 /* Display hostname in certain command outputs */
4065 DEFUN (bgp_default_show_nexthop_hostname
,
4066 bgp_default_show_nexthop_hostname_cmd
,
4067 "bgp default show-nexthop-hostname",
4069 "Configure BGP defaults\n"
4070 "Show hostname for nexthop in certain command outputs\n")
4072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4073 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4077 DEFUN (no_bgp_default_show_nexthop_hostname
,
4078 no_bgp_default_show_nexthop_hostname_cmd
,
4079 "no bgp default show-nexthop-hostname",
4082 "Configure BGP defaults\n"
4083 "Show hostname for nexthop in certain command outputs\n")
4085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4086 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4090 /* "bgp network import-check" configuration. */
4091 DEFUN (bgp_network_import_check
,
4092 bgp_network_import_check_cmd
,
4093 "bgp network import-check",
4095 "BGP network command\n"
4096 "Check BGP network route exists in IGP\n")
4098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4099 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4100 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4101 bgp_static_redo_import_check(bgp
);
4107 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4108 "bgp network import-check exact",
4110 "BGP network command\n"
4111 "Check BGP network route exists in IGP\n"
4112 "Match route precisely\n")
4114 DEFUN (no_bgp_network_import_check
,
4115 no_bgp_network_import_check_cmd
,
4116 "no bgp network import-check",
4119 "BGP network command\n"
4120 "Check BGP network route exists in IGP\n")
4122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4123 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4124 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4125 bgp_static_redo_import_check(bgp
);
4131 DEFUN (bgp_default_local_preference
,
4132 bgp_default_local_preference_cmd
,
4133 "bgp default local-preference (0-4294967295)",
4135 "Configure BGP defaults\n"
4136 "local preference (higher=more preferred)\n"
4137 "Configure default local preference value\n")
4139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4141 uint32_t local_pref
;
4143 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4145 bgp_default_local_preference_set(bgp
, local_pref
);
4146 bgp_clear_star_soft_in(vty
, bgp
->name
);
4151 DEFUN (no_bgp_default_local_preference
,
4152 no_bgp_default_local_preference_cmd
,
4153 "no bgp default local-preference [(0-4294967295)]",
4156 "Configure BGP defaults\n"
4157 "local preference (higher=more preferred)\n"
4158 "Configure default local preference value\n")
4160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4161 bgp_default_local_preference_unset(bgp
);
4162 bgp_clear_star_soft_in(vty
, bgp
->name
);
4168 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4169 bgp_default_subgroup_pkt_queue_max_cmd
,
4170 "bgp default subgroup-pkt-queue-max (20-100)",
4172 "Configure BGP defaults\n"
4173 "subgroup-pkt-queue-max\n"
4174 "Configure subgroup packet queue max\n")
4176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4180 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4182 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4187 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4188 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4189 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4192 "Configure BGP defaults\n"
4193 "subgroup-pkt-queue-max\n"
4194 "Configure subgroup packet queue max\n")
4196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4197 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4202 DEFUN (bgp_rr_allow_outbound_policy
,
4203 bgp_rr_allow_outbound_policy_cmd
,
4204 "bgp route-reflector allow-outbound-policy",
4206 "Allow modifications made by out route-map\n"
4207 "on ibgp neighbors\n")
4209 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4211 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4212 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4213 update_group_announce_rrclients(bgp
);
4214 bgp_clear_star_soft_out(vty
, bgp
->name
);
4220 DEFUN (no_bgp_rr_allow_outbound_policy
,
4221 no_bgp_rr_allow_outbound_policy_cmd
,
4222 "no bgp route-reflector allow-outbound-policy",
4225 "Allow modifications made by out route-map\n"
4226 "on ibgp neighbors\n")
4228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4230 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4231 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4232 update_group_announce_rrclients(bgp
);
4233 bgp_clear_star_soft_out(vty
, bgp
->name
);
4239 DEFUN (bgp_listen_limit
,
4240 bgp_listen_limit_cmd
,
4241 "bgp listen limit (1-65535)",
4243 "BGP Dynamic Neighbors listen commands\n"
4244 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4245 "Configure Dynamic Neighbors listen limit value\n")
4247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4251 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4253 bgp_listen_limit_set(bgp
, listen_limit
);
4258 DEFUN (no_bgp_listen_limit
,
4259 no_bgp_listen_limit_cmd
,
4260 "no bgp listen limit [(1-65535)]",
4263 "BGP Dynamic Neighbors listen commands\n"
4264 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4265 "Configure Dynamic Neighbors listen limit value\n")
4267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4268 bgp_listen_limit_unset(bgp
);
4274 * Check if this listen range is already configured. Check for exact
4275 * match or overlap based on input.
4277 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4278 struct prefix
*range
, int exact
)
4280 struct listnode
*node
, *nnode
;
4281 struct listnode
*node1
, *nnode1
;
4282 struct peer_group
*group
;
4287 afi
= family2afi(range
->family
);
4288 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4289 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4292 match
= prefix_same(range
, lr
);
4294 match
= (prefix_match(range
, lr
)
4295 || prefix_match(lr
, range
));
4304 DEFUN (bgp_listen_range
,
4305 bgp_listen_range_cmd
,
4306 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4308 "Configure BGP dynamic neighbors listen range\n"
4309 "Configure BGP dynamic neighbors listen range\n"
4311 "Member of the peer-group\n"
4312 "Peer-group name\n")
4314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4315 struct prefix range
;
4316 struct peer_group
*group
, *existing_group
;
4321 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4322 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4323 char *prefix
= argv
[idx
]->arg
;
4324 argv_find(argv
, argc
, "PGNAME", &idx
);
4325 char *peergroup
= argv
[idx
]->arg
;
4327 /* Convert IP prefix string to struct prefix. */
4328 ret
= str2prefix(prefix
, &range
);
4330 vty_out(vty
, "%% Malformed listen range\n");
4331 return CMD_WARNING_CONFIG_FAILED
;
4334 afi
= family2afi(range
.family
);
4336 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4338 "%% Malformed listen range (link-local address)\n");
4339 return CMD_WARNING_CONFIG_FAILED
;
4344 /* Check if same listen range is already configured. */
4345 existing_group
= listen_range_exists(bgp
, &range
, 1);
4346 if (existing_group
) {
4347 if (strcmp(existing_group
->name
, peergroup
) == 0)
4351 "%% Same listen range is attached to peer-group %s\n",
4352 existing_group
->name
);
4353 return CMD_WARNING_CONFIG_FAILED
;
4357 /* Check if an overlapping listen range exists. */
4358 if (listen_range_exists(bgp
, &range
, 0)) {
4360 "%% Listen range overlaps with existing listen range\n");
4361 return CMD_WARNING_CONFIG_FAILED
;
4364 group
= peer_group_lookup(bgp
, peergroup
);
4366 vty_out(vty
, "%% Configure the peer-group first\n");
4367 return CMD_WARNING_CONFIG_FAILED
;
4370 ret
= peer_group_listen_range_add(group
, &range
);
4371 return bgp_vty_return(vty
, ret
);
4374 DEFUN (no_bgp_listen_range
,
4375 no_bgp_listen_range_cmd
,
4376 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4379 "Unconfigure BGP dynamic neighbors listen range\n"
4380 "Unconfigure BGP dynamic neighbors listen range\n"
4382 "Member of the peer-group\n"
4383 "Peer-group name\n")
4385 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4386 struct prefix range
;
4387 struct peer_group
*group
;
4392 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4393 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4394 char *prefix
= argv
[idx
]->arg
;
4395 argv_find(argv
, argc
, "PGNAME", &idx
);
4396 char *peergroup
= argv
[idx
]->arg
;
4398 /* Convert IP prefix string to struct prefix. */
4399 ret
= str2prefix(prefix
, &range
);
4401 vty_out(vty
, "%% Malformed listen range\n");
4402 return CMD_WARNING_CONFIG_FAILED
;
4405 afi
= family2afi(range
.family
);
4407 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4409 "%% Malformed listen range (link-local address)\n");
4410 return CMD_WARNING_CONFIG_FAILED
;
4415 group
= peer_group_lookup(bgp
, peergroup
);
4417 vty_out(vty
, "%% Peer-group does not exist\n");
4418 return CMD_WARNING_CONFIG_FAILED
;
4421 ret
= peer_group_listen_range_del(group
, &range
);
4422 return bgp_vty_return(vty
, ret
);
4425 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4427 struct peer_group
*group
;
4428 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4429 struct prefix
*range
;
4432 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4433 vty_out(vty
, " bgp listen limit %d\n",
4434 bgp
->dynamic_neighbors_limit
);
4436 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4437 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4438 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4441 " bgp listen range %pFX peer-group %s\n",
4442 range
, group
->name
);
4449 DEFUN (bgp_disable_connected_route_check
,
4450 bgp_disable_connected_route_check_cmd
,
4451 "bgp disable-ebgp-connected-route-check",
4453 "Disable checking if nexthop is connected on ebgp sessions\n")
4455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4456 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4457 bgp_clear_star_soft_in(vty
, bgp
->name
);
4462 DEFUN (no_bgp_disable_connected_route_check
,
4463 no_bgp_disable_connected_route_check_cmd
,
4464 "no bgp disable-ebgp-connected-route-check",
4467 "Disable checking if nexthop is connected on ebgp sessions\n")
4469 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4470 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4471 bgp_clear_star_soft_in(vty
, bgp
->name
);
4477 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4483 int as_type
= AS_SPECIFIED
;
4486 if (as_str
[0] == 'i') {
4488 as_type
= AS_INTERNAL
;
4489 } else if (as_str
[0] == 'e') {
4491 as_type
= AS_EXTERNAL
;
4493 /* Get AS number. */
4494 as
= strtoul(as_str
, NULL
, 10);
4497 /* If peer is peer group or interface peer, call proper function. */
4498 ret
= str2sockunion(peer_str
, &su
);
4502 /* Check if existing interface peer */
4503 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4505 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4507 /* if not interface peer, check peer-group settings */
4508 if (ret
< 0 && !peer
) {
4509 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4512 "%% Create the peer-group or interface first\n");
4513 return CMD_WARNING_CONFIG_FAILED
;
4518 if (peer_address_self_check(bgp
, &su
)) {
4520 "%% Can not configure the local system as neighbor\n");
4521 return CMD_WARNING_CONFIG_FAILED
;
4523 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4526 return bgp_vty_return(vty
, ret
);
4529 DEFUN (bgp_default_shutdown
,
4530 bgp_default_shutdown_cmd
,
4531 "[no] bgp default shutdown",
4534 "Configure BGP defaults\n"
4535 "Apply administrative shutdown to newly configured peers\n")
4537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4538 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4542 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4544 "Administrative shutdown of the BGP instance\n"
4545 "Add a shutdown message (RFC 8203)\n"
4546 "Shutdown message\n")
4548 char *msgstr
= NULL
;
4550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4553 msgstr
= argv_concat(argv
, argc
, 3);
4555 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4556 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4557 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4558 return CMD_WARNING_CONFIG_FAILED
;
4561 bgp_shutdown_enable(bgp
, msgstr
);
4562 XFREE(MTYPE_TMP
, msgstr
);
4567 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4568 BGP_STR
"Administrative shutdown of the BGP instance\n")
4570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4572 bgp_shutdown_enable(bgp
, NULL
);
4577 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4578 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4582 bgp_shutdown_disable(bgp
);
4587 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4588 "no bgp shutdown message MSG...", NO_STR BGP_STR
4589 "Administrative shutdown of the BGP instance\n"
4590 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4592 DEFUN (neighbor_remote_as
,
4593 neighbor_remote_as_cmd
,
4594 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4597 "Specify a BGP neighbor\n"
4599 "Internal BGP peer\n"
4600 "External BGP peer\n")
4603 int idx_remote_as
= 3;
4604 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4605 argv
[idx_remote_as
]->arg
);
4608 DEFPY (bgp_allow_martian
,
4609 bgp_allow_martian_cmd
,
4610 "[no]$no bgp allow-martian-nexthop",
4613 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4618 bgp
->allow_martian
= false;
4620 bgp
->allow_martian
= true;
4625 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4626 * sessions do not wait for hold timer expiry to bring down the sessions
4627 * when nexthop becomes unreachable
4629 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4630 BGP_STR
"Fast convergence for bgp sessions\n")
4632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4633 bgp
->fast_convergence
= true;
4638 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4639 "no bgp fast-convergence",
4640 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4643 bgp
->fast_convergence
= false;
4648 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4650 const char *peer_group_name
,
4653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4655 int as_type
= AS_UNSPECIFIED
;
4657 struct peer_group
*group
;
4660 group
= peer_group_lookup(bgp
, conf_if
);
4663 vty_out(vty
, "%% Name conflict with peer-group \n");
4664 return CMD_WARNING_CONFIG_FAILED
;
4668 if (as_str
[0] == 'i') {
4669 as_type
= AS_INTERNAL
;
4670 } else if (as_str
[0] == 'e') {
4671 as_type
= AS_EXTERNAL
;
4673 /* Get AS number. */
4674 as
= strtoul(as_str
, NULL
, 10);
4675 as_type
= AS_SPECIFIED
;
4679 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4682 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4684 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4688 vty_out(vty
, "%% BGP failed to create peer\n");
4689 return CMD_WARNING_CONFIG_FAILED
;
4693 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4695 /* Request zebra to initiate IPv6 RAs on this interface. We do
4697 * any unnumbered peer in order to not worry about run-time
4699 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4701 * gets deleted later etc.)
4704 bgp_zebra_initiate_radv(bgp
, peer
);
4707 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4708 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4710 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4712 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4714 /* v6only flag changed. Reset bgp seesion */
4715 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4716 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4717 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4718 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4720 bgp_session_reset(peer
);
4723 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4724 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4725 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4726 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4729 if (peer_group_name
) {
4730 group
= peer_group_lookup(bgp
, peer_group_name
);
4732 vty_out(vty
, "%% Configure the peer-group first\n");
4733 return CMD_WARNING_CONFIG_FAILED
;
4736 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4739 return bgp_vty_return(vty
, ret
);
4742 DEFUN (neighbor_interface_config
,
4743 neighbor_interface_config_cmd
,
4744 "neighbor WORD interface [peer-group PGNAME]",
4746 "Interface name or neighbor tag\n"
4747 "Enable BGP on interface\n"
4748 "Member of the peer-group\n"
4749 "Peer-group name\n")
4752 int idx_peer_group_word
= 4;
4754 if (argc
> idx_peer_group_word
)
4755 return peer_conf_interface_get(
4756 vty
, argv
[idx_word
]->arg
, 0,
4757 argv
[idx_peer_group_word
]->arg
, NULL
);
4759 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4763 DEFUN (neighbor_interface_config_v6only
,
4764 neighbor_interface_config_v6only_cmd
,
4765 "neighbor WORD interface v6only [peer-group PGNAME]",
4767 "Interface name or neighbor tag\n"
4768 "Enable BGP on interface\n"
4769 "Enable BGP with v6 link-local only\n"
4770 "Member of the peer-group\n"
4771 "Peer-group name\n")
4774 int idx_peer_group_word
= 5;
4776 if (argc
> idx_peer_group_word
)
4777 return peer_conf_interface_get(
4778 vty
, argv
[idx_word
]->arg
, 1,
4779 argv
[idx_peer_group_word
]->arg
, NULL
);
4781 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4785 DEFUN (neighbor_interface_config_remote_as
,
4786 neighbor_interface_config_remote_as_cmd
,
4787 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4789 "Interface name or neighbor tag\n"
4790 "Enable BGP on interface\n"
4791 "Specify a BGP neighbor\n"
4793 "Internal BGP peer\n"
4794 "External BGP peer\n")
4797 int idx_remote_as
= 4;
4798 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4799 argv
[idx_remote_as
]->arg
);
4802 DEFUN (neighbor_interface_v6only_config_remote_as
,
4803 neighbor_interface_v6only_config_remote_as_cmd
,
4804 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4806 "Interface name or neighbor tag\n"
4807 "Enable BGP with v6 link-local only\n"
4808 "Enable BGP on interface\n"
4809 "Specify a BGP neighbor\n"
4811 "Internal BGP peer\n"
4812 "External BGP peer\n")
4815 int idx_remote_as
= 5;
4816 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4817 argv
[idx_remote_as
]->arg
);
4820 DEFUN (neighbor_peer_group
,
4821 neighbor_peer_group_cmd
,
4822 "neighbor WORD peer-group",
4824 "Interface name or neighbor tag\n"
4825 "Configure peer-group\n")
4827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4830 struct peer_group
*group
;
4832 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4834 vty_out(vty
, "%% Name conflict with interface: \n");
4835 return CMD_WARNING_CONFIG_FAILED
;
4838 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4840 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4841 return CMD_WARNING_CONFIG_FAILED
;
4849 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4853 "Specify a BGP neighbor\n"
4855 "Internal BGP peer\n"
4856 "External BGP peer\n")
4858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4862 struct peer_group
*group
;
4866 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4868 /* look up for neighbor by interface name config. */
4869 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4871 /* Request zebra to terminate IPv6 RAs on this
4874 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4875 peer_notify_unconfig(peer
);
4880 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4882 peer_group_notify_unconfig(group
);
4883 peer_group_delete(group
);
4885 vty_out(vty
, "%% Create the peer-group first\n");
4886 return CMD_WARNING_CONFIG_FAILED
;
4889 peer
= peer_lookup(bgp
, &su
);
4891 if (peer_dynamic_neighbor(peer
)) {
4893 "%% Operation not allowed on a dynamic neighbor\n");
4894 return CMD_WARNING_CONFIG_FAILED
;
4897 other
= peer
->doppelganger
;
4899 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4900 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4902 peer_notify_unconfig(peer
);
4904 if (other
&& other
->status
!= Deleted
) {
4905 peer_notify_unconfig(other
);
4914 DEFUN (no_neighbor_interface_config
,
4915 no_neighbor_interface_config_cmd
,
4916 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4920 "Configure BGP on interface\n"
4921 "Enable BGP with v6 link-local only\n"
4922 "Member of the peer-group\n"
4924 "Specify a BGP neighbor\n"
4926 "Internal BGP peer\n"
4927 "External BGP peer\n")
4929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4933 /* look up for neighbor by interface name config. */
4934 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4936 /* Request zebra to terminate IPv6 RAs on this interface. */
4938 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4939 peer_notify_unconfig(peer
);
4942 vty_out(vty
, "%% Create the bgp interface first\n");
4943 return CMD_WARNING_CONFIG_FAILED
;
4948 DEFUN (no_neighbor_peer_group
,
4949 no_neighbor_peer_group_cmd
,
4950 "no neighbor WORD peer-group",
4954 "Configure peer-group\n")
4956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4958 struct peer_group
*group
;
4960 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4962 peer_group_notify_unconfig(group
);
4963 peer_group_delete(group
);
4965 vty_out(vty
, "%% Create the peer-group first\n");
4966 return CMD_WARNING_CONFIG_FAILED
;
4971 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4972 no_neighbor_interface_peer_group_remote_as_cmd
,
4973 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4976 "Interface name or neighbor tag\n"
4977 "Specify a BGP neighbor\n"
4979 "Internal BGP peer\n"
4980 "External BGP peer\n")
4982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4984 struct peer_group
*group
;
4987 /* look up for neighbor by interface name config. */
4988 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4990 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4994 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4996 peer_group_remote_as_delete(group
);
4998 vty_out(vty
, "%% Create the peer-group or interface first\n");
4999 return CMD_WARNING_CONFIG_FAILED
;
5004 DEFUN (neighbor_local_as
,
5005 neighbor_local_as_cmd
,
5006 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
5009 "Specify a local-as number\n"
5010 "AS number used as local AS\n")
5018 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5022 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5023 ret
= peer_local_as_set(peer
, as
, 0, 0);
5024 return bgp_vty_return(vty
, ret
);
5027 DEFUN (neighbor_local_as_no_prepend
,
5028 neighbor_local_as_no_prepend_cmd
,
5029 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
5032 "Specify a local-as number\n"
5033 "AS number used as local AS\n"
5034 "Do not prepend local-as to updates from ebgp peers\n")
5042 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5044 return CMD_WARNING_CONFIG_FAILED
;
5046 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5047 ret
= peer_local_as_set(peer
, as
, 1, 0);
5048 return bgp_vty_return(vty
, ret
);
5051 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5052 neighbor_local_as_no_prepend_replace_as_cmd
,
5053 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
5056 "Specify a local-as number\n"
5057 "AS number used as local AS\n"
5058 "Do not prepend local-as to updates from ebgp peers\n"
5059 "Do not prepend local-as to updates from ibgp peers\n")
5067 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5069 return CMD_WARNING_CONFIG_FAILED
;
5071 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5072 ret
= peer_local_as_set(peer
, as
, 1, 1);
5073 return bgp_vty_return(vty
, ret
);
5076 DEFUN (no_neighbor_local_as
,
5077 no_neighbor_local_as_cmd
,
5078 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
5082 "Specify a local-as number\n"
5083 "AS number used as local AS\n"
5084 "Do not prepend local-as to updates from ebgp peers\n"
5085 "Do not prepend local-as to updates from ibgp peers\n")
5091 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5093 return CMD_WARNING_CONFIG_FAILED
;
5095 ret
= peer_local_as_unset(peer
);
5096 return bgp_vty_return(vty
, ret
);
5100 DEFUN (neighbor_solo
,
5102 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5105 "Solo peer - part of its own update group\n")
5111 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5113 return CMD_WARNING_CONFIG_FAILED
;
5115 ret
= update_group_adjust_soloness(peer
, 1);
5116 return bgp_vty_return(vty
, ret
);
5119 DEFUN (no_neighbor_solo
,
5120 no_neighbor_solo_cmd
,
5121 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5125 "Solo peer - part of its own update group\n")
5131 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5133 return CMD_WARNING_CONFIG_FAILED
;
5135 ret
= update_group_adjust_soloness(peer
, 0);
5136 return bgp_vty_return(vty
, ret
);
5139 DEFUN (neighbor_password
,
5140 neighbor_password_cmd
,
5141 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5152 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5156 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5157 return bgp_vty_return(vty
, ret
);
5160 DEFUN (no_neighbor_password
,
5161 no_neighbor_password_cmd
,
5162 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5173 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5175 return CMD_WARNING_CONFIG_FAILED
;
5177 ret
= peer_password_unset(peer
);
5178 return bgp_vty_return(vty
, ret
);
5181 DEFUN (neighbor_activate
,
5182 neighbor_activate_cmd
,
5183 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5186 "Enable the Address Family for this Neighbor\n")
5192 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5194 return CMD_WARNING_CONFIG_FAILED
;
5196 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5197 return bgp_vty_return(vty
, ret
);
5200 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5201 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5202 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5203 "Enable the Address Family for this Neighbor\n")
5205 DEFUN (no_neighbor_activate
,
5206 no_neighbor_activate_cmd
,
5207 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5211 "Enable the Address Family for this Neighbor\n")
5218 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5220 return CMD_WARNING_CONFIG_FAILED
;
5222 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5223 return bgp_vty_return(vty
, ret
);
5226 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5227 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5228 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5229 "Enable the Address Family for this Neighbor\n")
5231 DEFUN (neighbor_set_peer_group
,
5232 neighbor_set_peer_group_cmd
,
5233 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5236 "Member of the peer-group\n"
5237 "Peer-group name\n")
5239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5246 struct peer_group
*group
;
5248 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5250 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5252 vty_out(vty
, "%% Malformed address or name: %s\n",
5253 argv
[idx_peer
]->arg
);
5254 return CMD_WARNING_CONFIG_FAILED
;
5257 if (peer_address_self_check(bgp
, &su
)) {
5259 "%% Can not configure the local system as neighbor\n");
5260 return CMD_WARNING_CONFIG_FAILED
;
5263 /* Disallow for dynamic neighbor. */
5264 peer
= peer_lookup(bgp
, &su
);
5265 if (peer
&& peer_dynamic_neighbor(peer
)) {
5267 "%% Operation not allowed on a dynamic neighbor\n");
5268 return CMD_WARNING_CONFIG_FAILED
;
5272 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5274 vty_out(vty
, "%% Configure the peer-group first\n");
5275 return CMD_WARNING_CONFIG_FAILED
;
5278 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5280 return bgp_vty_return(vty
, ret
);
5283 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5284 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5285 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5286 "Member of the peer-group\n"
5287 "Peer-group name\n")
5289 DEFUN (no_neighbor_set_peer_group
,
5290 no_neighbor_set_peer_group_cmd
,
5291 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5295 "Member of the peer-group\n"
5296 "Peer-group name\n")
5298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5303 struct peer_group
*group
;
5305 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5307 return CMD_WARNING_CONFIG_FAILED
;
5309 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5311 vty_out(vty
, "%% Configure the peer-group first\n");
5312 return CMD_WARNING_CONFIG_FAILED
;
5315 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5316 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5318 peer_notify_unconfig(peer
);
5319 ret
= peer_delete(peer
);
5321 return bgp_vty_return(vty
, ret
);
5324 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5325 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5326 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5327 "Member of the peer-group\n"
5328 "Peer-group name\n")
5330 /* neighbor passive. */
5331 DEFUN (neighbor_passive
,
5332 neighbor_passive_cmd
,
5333 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5336 "Don't send open messages to this neighbor\n")
5339 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5342 DEFUN (no_neighbor_passive
,
5343 no_neighbor_passive_cmd
,
5344 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5348 "Don't send open messages to this neighbor\n")
5351 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5354 /* neighbor shutdown. */
5355 DEFUN (neighbor_shutdown_msg
,
5356 neighbor_shutdown_msg_cmd
,
5357 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5360 "Administratively shut down this neighbor\n"
5361 "Add a shutdown message (RFC 8203)\n"
5362 "Shutdown message\n")
5368 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5372 return CMD_WARNING_CONFIG_FAILED
;
5373 message
= argv_concat(argv
, argc
, 4);
5374 peer_tx_shutdown_message_set(peer
, message
);
5375 XFREE(MTYPE_TMP
, message
);
5378 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5381 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5382 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5383 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5384 "Administratively shut down this neighbor\n")
5386 DEFUN (no_neighbor_shutdown_msg
,
5387 no_neighbor_shutdown_msg_cmd
,
5388 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5392 "Administratively shut down this neighbor\n"
5393 "Remove a shutdown message (RFC 8203)\n"
5394 "Shutdown message\n")
5398 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5399 PEER_FLAG_SHUTDOWN
);
5402 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5403 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5404 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5405 "Administratively shut down this neighbor\n")
5407 DEFUN(neighbor_shutdown_rtt
,
5408 neighbor_shutdown_rtt_cmd
,
5409 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5412 "Administratively shut down this neighbor\n"
5413 "Shutdown if round-trip-time is higher than expected\n"
5414 "Round-trip-time in milliseconds\n"
5415 "Specify the number of keepalives before shutdown\n"
5416 "The number of keepalives with higher RTT to shutdown\n")
5423 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5426 return CMD_WARNING_CONFIG_FAILED
;
5428 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5430 if (argv_find(argv
, argc
, "count", &idx_count
))
5431 peer
->rtt_keepalive_conf
=
5432 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5434 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5435 PEER_FLAG_RTT_SHUTDOWN
);
5438 DEFUN(no_neighbor_shutdown_rtt
,
5439 no_neighbor_shutdown_rtt_cmd
,
5440 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5444 "Administratively shut down this neighbor\n"
5445 "Shutdown if round-trip-time is higher than expected\n"
5446 "Round-trip-time in milliseconds\n"
5447 "Specify the number of keepalives before shutdown\n"
5448 "The number of keepalives with higher RTT to shutdown\n")
5453 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5456 return CMD_WARNING_CONFIG_FAILED
;
5458 peer
->rtt_expected
= 0;
5459 peer
->rtt_keepalive_conf
= 1;
5461 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5462 PEER_FLAG_RTT_SHUTDOWN
);
5465 /* neighbor capability dynamic. */
5466 DEFUN (neighbor_capability_dynamic
,
5467 neighbor_capability_dynamic_cmd
,
5468 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5471 "Advertise capability to the peer\n"
5472 "Advertise dynamic capability to this neighbor\n")
5475 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5476 PEER_FLAG_DYNAMIC_CAPABILITY
);
5479 DEFUN (no_neighbor_capability_dynamic
,
5480 no_neighbor_capability_dynamic_cmd
,
5481 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5485 "Advertise capability to the peer\n"
5486 "Advertise dynamic capability to this neighbor\n")
5489 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5490 PEER_FLAG_DYNAMIC_CAPABILITY
);
5493 /* neighbor dont-capability-negotiate */
5494 DEFUN (neighbor_dont_capability_negotiate
,
5495 neighbor_dont_capability_negotiate_cmd
,
5496 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5499 "Do not perform capability negotiation\n")
5502 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5503 PEER_FLAG_DONT_CAPABILITY
);
5506 DEFUN (no_neighbor_dont_capability_negotiate
,
5507 no_neighbor_dont_capability_negotiate_cmd
,
5508 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5512 "Do not perform capability negotiation\n")
5515 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5516 PEER_FLAG_DONT_CAPABILITY
);
5519 /* neighbor capability extended next hop encoding */
5520 DEFUN (neighbor_capability_enhe
,
5521 neighbor_capability_enhe_cmd
,
5522 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5525 "Advertise capability to the peer\n"
5526 "Advertise extended next-hop capability to the peer\n")
5531 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5532 if (peer
&& peer
->conf_if
)
5535 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5536 PEER_FLAG_CAPABILITY_ENHE
);
5539 DEFUN (no_neighbor_capability_enhe
,
5540 no_neighbor_capability_enhe_cmd
,
5541 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5545 "Advertise capability to the peer\n"
5546 "Advertise extended next-hop capability to the peer\n")
5551 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5552 if (peer
&& peer
->conf_if
) {
5554 "Peer %s cannot have capability extended-nexthop turned off\n",
5555 argv
[idx_peer
]->arg
);
5556 return CMD_WARNING_CONFIG_FAILED
;
5559 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5560 PEER_FLAG_CAPABILITY_ENHE
);
5563 /* neighbor capability software-version */
5564 DEFPY(neighbor_capability_software_version
,
5565 neighbor_capability_software_version_cmd
,
5566 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor capability software-version",
5570 "Advertise capability to the peer\n"
5571 "Advertise Software Version capability to the peer\n")
5575 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
5576 if (peer
&& peer
->conf_if
)
5580 return peer_flag_unset_vty(vty
, neighbor
,
5581 PEER_FLAG_CAPABILITY_SOFT_VERSION
);
5583 return peer_flag_set_vty(vty
, neighbor
,
5584 PEER_FLAG_CAPABILITY_SOFT_VERSION
);
5587 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5588 afi_t afi
, safi_t safi
, uint32_t flag
,
5594 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5596 return CMD_WARNING_CONFIG_FAILED
;
5599 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5601 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5603 return bgp_vty_return(vty
, ret
);
5606 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5607 afi_t afi
, safi_t safi
, uint32_t flag
)
5609 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5612 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5613 afi_t afi
, safi_t safi
, uint32_t flag
)
5615 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5618 /* neighbor capability orf prefix-list. */
5619 DEFUN (neighbor_capability_orf_prefix
,
5620 neighbor_capability_orf_prefix_cmd
,
5621 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5624 "Advertise capability to the peer\n"
5625 "Advertise ORF capability to the peer\n"
5626 "Advertise prefixlist ORF capability to this neighbor\n"
5627 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5628 "Capability to RECEIVE the ORF from this neighbor\n"
5629 "Capability to SEND the ORF to this neighbor\n")
5631 int idx_send_recv
= 5;
5632 char *peer_str
= argv
[1]->arg
;
5634 afi_t afi
= bgp_node_afi(vty
);
5635 safi_t safi
= bgp_node_safi(vty
);
5637 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5639 return CMD_WARNING_CONFIG_FAILED
;
5641 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5642 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5643 PEER_FLAG_ORF_PREFIX_SM
);
5645 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5646 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5647 PEER_FLAG_ORF_PREFIX_RM
);
5649 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5650 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5651 PEER_FLAG_ORF_PREFIX_SM
)
5652 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5653 PEER_FLAG_ORF_PREFIX_RM
);
5655 return CMD_WARNING_CONFIG_FAILED
;
5659 neighbor_capability_orf_prefix
,
5660 neighbor_capability_orf_prefix_hidden_cmd
,
5661 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5662 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5663 "Advertise capability to the peer\n"
5664 "Advertise ORF capability to the peer\n"
5665 "Advertise prefixlist ORF capability to this neighbor\n"
5666 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5667 "Capability to RECEIVE the ORF from this neighbor\n"
5668 "Capability to SEND the ORF to this neighbor\n")
5670 DEFUN (no_neighbor_capability_orf_prefix
,
5671 no_neighbor_capability_orf_prefix_cmd
,
5672 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5676 "Advertise capability to the peer\n"
5677 "Advertise ORF capability to the peer\n"
5678 "Advertise prefixlist ORF capability to this neighbor\n"
5679 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5680 "Capability to RECEIVE the ORF from this neighbor\n"
5681 "Capability to SEND the ORF to this neighbor\n")
5683 int idx_send_recv
= 6;
5684 char *peer_str
= argv
[2]->arg
;
5686 afi_t afi
= bgp_node_afi(vty
);
5687 safi_t safi
= bgp_node_safi(vty
);
5689 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5691 return CMD_WARNING_CONFIG_FAILED
;
5693 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5694 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5695 PEER_FLAG_ORF_PREFIX_SM
);
5697 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5698 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5699 PEER_FLAG_ORF_PREFIX_RM
);
5701 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5702 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5703 PEER_FLAG_ORF_PREFIX_SM
)
5704 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5705 PEER_FLAG_ORF_PREFIX_RM
);
5707 return CMD_WARNING_CONFIG_FAILED
;
5711 no_neighbor_capability_orf_prefix
,
5712 no_neighbor_capability_orf_prefix_hidden_cmd
,
5713 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5714 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Advertise capability to the peer\n"
5716 "Advertise ORF capability to the peer\n"
5717 "Advertise prefixlist ORF capability to this neighbor\n"
5718 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5719 "Capability to RECEIVE the ORF from this neighbor\n"
5720 "Capability to SEND the ORF to this neighbor\n")
5722 /* neighbor next-hop-self. */
5723 DEFUN (neighbor_nexthop_self
,
5724 neighbor_nexthop_self_cmd
,
5725 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5728 "Disable the next hop calculation for this neighbor\n")
5731 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5732 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5735 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5736 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5737 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5738 "Disable the next hop calculation for this neighbor\n")
5740 /* neighbor next-hop-self. */
5741 DEFUN (neighbor_nexthop_self_force
,
5742 neighbor_nexthop_self_force_cmd
,
5743 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5746 "Disable the next hop calculation for this neighbor\n"
5747 "Set the next hop to self for reflected routes\n")
5750 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5752 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5755 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5756 neighbor_nexthop_self_force_hidden_cmd
,
5757 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5758 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5759 "Disable the next hop calculation for this neighbor\n"
5760 "Set the next hop to self for reflected routes\n")
5762 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5763 neighbor_nexthop_self_all_hidden_cmd
,
5764 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5765 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5766 "Disable the next hop calculation for this neighbor\n"
5767 "Set the next hop to self for reflected routes\n")
5769 DEFUN (no_neighbor_nexthop_self
,
5770 no_neighbor_nexthop_self_cmd
,
5771 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5775 "Disable the next hop calculation for this neighbor\n")
5778 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5779 bgp_node_afi(vty
), bgp_node_safi(vty
),
5780 PEER_FLAG_NEXTHOP_SELF
);
5783 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5784 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5785 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5786 "Disable the next hop calculation for this neighbor\n")
5788 DEFUN (no_neighbor_nexthop_self_force
,
5789 no_neighbor_nexthop_self_force_cmd
,
5790 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5794 "Disable the next hop calculation for this neighbor\n"
5795 "Set the next hop to self for reflected routes\n")
5798 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5799 bgp_node_afi(vty
), bgp_node_safi(vty
),
5800 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5803 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5804 no_neighbor_nexthop_self_force_hidden_cmd
,
5805 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5806 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5807 "Disable the next hop calculation for this neighbor\n"
5808 "Set the next hop to self for reflected routes\n")
5810 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5811 no_neighbor_nexthop_self_all_hidden_cmd
,
5812 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5813 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5814 "Disable the next hop calculation for this neighbor\n"
5815 "Set the next hop to self for reflected routes\n")
5817 /* neighbor as-override */
5818 DEFUN (neighbor_as_override
,
5819 neighbor_as_override_cmd
,
5820 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5823 "Override ASNs in outbound updates if aspath equals remote-as\n")
5826 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5827 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5830 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5831 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5832 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5833 "Override ASNs in outbound updates if aspath equals remote-as\n")
5835 DEFUN (no_neighbor_as_override
,
5836 no_neighbor_as_override_cmd
,
5837 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5841 "Override ASNs in outbound updates if aspath equals remote-as\n")
5844 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5845 bgp_node_afi(vty
), bgp_node_safi(vty
),
5846 PEER_FLAG_AS_OVERRIDE
);
5849 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5850 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5851 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5852 "Override ASNs in outbound updates if aspath equals remote-as\n")
5854 /* neighbor remove-private-AS. */
5855 DEFUN (neighbor_remove_private_as
,
5856 neighbor_remove_private_as_cmd
,
5857 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5860 "Remove private ASNs in outbound updates\n")
5863 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5865 PEER_FLAG_REMOVE_PRIVATE_AS
);
5868 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5869 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5870 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5871 "Remove private ASNs in outbound updates\n")
5873 DEFUN (neighbor_remove_private_as_all
,
5874 neighbor_remove_private_as_all_cmd
,
5875 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5878 "Remove private ASNs in outbound updates\n"
5879 "Apply to all AS numbers\n")
5882 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5884 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5887 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5888 neighbor_remove_private_as_all_hidden_cmd
,
5889 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5890 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5891 "Remove private ASNs in outbound updates\n"
5892 "Apply to all AS numbers\n")
5894 DEFUN (neighbor_remove_private_as_replace_as
,
5895 neighbor_remove_private_as_replace_as_cmd
,
5896 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5899 "Remove private ASNs in outbound updates\n"
5900 "Replace private ASNs with our ASN in outbound updates\n")
5903 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5905 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5908 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5909 neighbor_remove_private_as_replace_as_hidden_cmd
,
5910 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5911 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5912 "Remove private ASNs in outbound updates\n"
5913 "Replace private ASNs with our ASN in outbound updates\n")
5915 DEFUN (neighbor_remove_private_as_all_replace_as
,
5916 neighbor_remove_private_as_all_replace_as_cmd
,
5917 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5920 "Remove private ASNs in outbound updates\n"
5921 "Apply to all AS numbers\n"
5922 "Replace private ASNs with our ASN in outbound updates\n")
5925 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5927 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5931 neighbor_remove_private_as_all_replace_as
,
5932 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5933 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5935 "Remove private ASNs in outbound updates\n"
5936 "Apply to all AS numbers\n"
5937 "Replace private ASNs with our ASN in outbound updates\n")
5939 DEFUN (no_neighbor_remove_private_as
,
5940 no_neighbor_remove_private_as_cmd
,
5941 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5945 "Remove private ASNs in outbound updates\n")
5948 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5949 bgp_node_afi(vty
), bgp_node_safi(vty
),
5950 PEER_FLAG_REMOVE_PRIVATE_AS
);
5953 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5954 no_neighbor_remove_private_as_hidden_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Remove private ASNs in outbound updates\n")
5959 DEFUN (no_neighbor_remove_private_as_all
,
5960 no_neighbor_remove_private_as_all_cmd
,
5961 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5965 "Remove private ASNs in outbound updates\n"
5966 "Apply to all AS numbers\n")
5969 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5970 bgp_node_afi(vty
), bgp_node_safi(vty
),
5971 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5974 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5975 no_neighbor_remove_private_as_all_hidden_cmd
,
5976 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5977 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5978 "Remove private ASNs in outbound updates\n"
5979 "Apply to all AS numbers\n")
5981 DEFUN (no_neighbor_remove_private_as_replace_as
,
5982 no_neighbor_remove_private_as_replace_as_cmd
,
5983 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5987 "Remove private ASNs in outbound updates\n"
5988 "Replace private ASNs with our ASN in outbound updates\n")
5991 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5992 bgp_node_afi(vty
), bgp_node_safi(vty
),
5993 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5996 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5997 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5998 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5999 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6000 "Remove private ASNs in outbound updates\n"
6001 "Replace private ASNs with our ASN in outbound updates\n")
6003 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
6004 no_neighbor_remove_private_as_all_replace_as_cmd
,
6005 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6009 "Remove private ASNs in outbound updates\n"
6010 "Apply to all AS numbers\n"
6011 "Replace private ASNs with our ASN in outbound updates\n")
6014 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6015 bgp_node_afi(vty
), bgp_node_safi(vty
),
6016 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
6020 no_neighbor_remove_private_as_all_replace_as
,
6021 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6022 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6023 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6024 "Remove private ASNs in outbound updates\n"
6025 "Apply to all AS numbers\n"
6026 "Replace private ASNs with our ASN in outbound updates\n")
6029 /* neighbor send-community. */
6030 DEFUN (neighbor_send_community
,
6031 neighbor_send_community_cmd
,
6032 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6035 "Send Community attribute to this neighbor\n")
6039 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6041 PEER_FLAG_SEND_COMMUNITY
);
6044 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6045 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6046 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6047 "Send Community attribute to this neighbor\n")
6049 DEFUN (no_neighbor_send_community
,
6050 no_neighbor_send_community_cmd
,
6051 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6055 "Send Community attribute to this neighbor\n")
6059 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6060 bgp_node_afi(vty
), bgp_node_safi(vty
),
6061 PEER_FLAG_SEND_COMMUNITY
);
6064 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6065 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6066 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6067 "Send Community attribute to this neighbor\n")
6069 /* neighbor send-community extended. */
6070 DEFUN (neighbor_send_community_type
,
6071 neighbor_send_community_type_cmd
,
6072 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6075 "Send Community attribute to this neighbor\n"
6076 "Send Standard and Extended Community attributes\n"
6077 "Send Standard, Large and Extended Community attributes\n"
6078 "Send Extended Community attributes\n"
6079 "Send Standard Community attributes\n"
6080 "Send Large Community attributes\n")
6082 const char *type
= argv
[argc
- 1]->text
;
6083 char *peer_str
= argv
[1]->arg
;
6085 afi_t afi
= bgp_node_afi(vty
);
6086 safi_t safi
= bgp_node_safi(vty
);
6088 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6090 return CMD_WARNING_CONFIG_FAILED
;
6092 if (strmatch(type
, "standard"))
6093 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6094 PEER_FLAG_SEND_COMMUNITY
);
6096 if (strmatch(type
, "extended"))
6097 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6098 PEER_FLAG_SEND_EXT_COMMUNITY
);
6100 if (strmatch(type
, "large"))
6101 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6102 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6104 if (strmatch(type
, "both")) {
6105 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6106 PEER_FLAG_SEND_COMMUNITY
)
6107 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6108 PEER_FLAG_SEND_EXT_COMMUNITY
);
6110 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6111 PEER_FLAG_SEND_COMMUNITY
)
6112 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6113 PEER_FLAG_SEND_EXT_COMMUNITY
)
6114 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6115 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6119 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6120 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6121 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6122 "Send Community attribute to this neighbor\n"
6123 "Send Standard and Extended Community attributes\n"
6124 "Send Standard, Large and Extended Community attributes\n"
6125 "Send Extended Community attributes\n"
6126 "Send Standard Community attributes\n"
6127 "Send Large Community attributes\n")
6129 DEFUN (no_neighbor_send_community_type
,
6130 no_neighbor_send_community_type_cmd
,
6131 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6135 "Send Community attribute to this neighbor\n"
6136 "Send Standard and Extended Community attributes\n"
6137 "Send Standard, Large and Extended Community attributes\n"
6138 "Send Extended Community attributes\n"
6139 "Send Standard Community attributes\n"
6140 "Send Large Community attributes\n")
6142 const char *type
= argv
[argc
- 1]->text
;
6143 char *peer_str
= argv
[2]->arg
;
6145 afi_t afi
= bgp_node_afi(vty
);
6146 safi_t safi
= bgp_node_safi(vty
);
6148 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6150 return CMD_WARNING_CONFIG_FAILED
;
6152 if (strmatch(type
, "standard"))
6153 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6154 PEER_FLAG_SEND_COMMUNITY
);
6156 if (strmatch(type
, "extended"))
6157 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6158 PEER_FLAG_SEND_EXT_COMMUNITY
);
6160 if (strmatch(type
, "large"))
6161 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6162 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6164 if (strmatch(type
, "both")) {
6166 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6167 PEER_FLAG_SEND_COMMUNITY
)
6168 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6169 PEER_FLAG_SEND_EXT_COMMUNITY
);
6172 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6173 PEER_FLAG_SEND_COMMUNITY
)
6174 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6175 PEER_FLAG_SEND_EXT_COMMUNITY
)
6176 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6177 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6181 no_neighbor_send_community_type
,
6182 no_neighbor_send_community_type_hidden_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6185 "Send Community attribute to this neighbor\n"
6186 "Send Standard and Extended Community attributes\n"
6187 "Send Standard, Large and Extended Community attributes\n"
6188 "Send Extended Community attributes\n"
6189 "Send Standard Community attributes\n"
6190 "Send Large Community attributes\n")
6192 /* neighbor soft-reconfig. */
6193 DEFUN (neighbor_soft_reconfiguration
,
6194 neighbor_soft_reconfiguration_cmd
,
6195 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6198 "Per neighbor soft reconfiguration\n"
6199 "Allow inbound soft reconfiguration for this neighbor\n")
6202 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6204 PEER_FLAG_SOFT_RECONFIG
);
6207 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6208 neighbor_soft_reconfiguration_hidden_cmd
,
6209 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6210 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6211 "Per neighbor soft reconfiguration\n"
6212 "Allow inbound soft reconfiguration for this neighbor\n")
6214 DEFUN (no_neighbor_soft_reconfiguration
,
6215 no_neighbor_soft_reconfiguration_cmd
,
6216 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6220 "Per neighbor soft reconfiguration\n"
6221 "Allow inbound soft reconfiguration for this neighbor\n")
6224 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6225 bgp_node_afi(vty
), bgp_node_safi(vty
),
6226 PEER_FLAG_SOFT_RECONFIG
);
6229 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6230 no_neighbor_soft_reconfiguration_hidden_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6233 "Per neighbor soft reconfiguration\n"
6234 "Allow inbound soft reconfiguration for this neighbor\n")
6236 DEFUN (neighbor_route_reflector_client
,
6237 neighbor_route_reflector_client_cmd
,
6238 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6241 "Configure a neighbor as Route Reflector client\n")
6247 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6249 return CMD_WARNING_CONFIG_FAILED
;
6251 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6253 PEER_FLAG_REFLECTOR_CLIENT
);
6256 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6257 neighbor_route_reflector_client_hidden_cmd
,
6258 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6259 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6260 "Configure a neighbor as Route Reflector client\n")
6262 DEFUN (no_neighbor_route_reflector_client
,
6263 no_neighbor_route_reflector_client_cmd
,
6264 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6268 "Configure a neighbor as Route Reflector client\n")
6271 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6272 bgp_node_afi(vty
), bgp_node_safi(vty
),
6273 PEER_FLAG_REFLECTOR_CLIENT
);
6276 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6277 no_neighbor_route_reflector_client_hidden_cmd
,
6278 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6279 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6280 "Configure a neighbor as Route Reflector client\n")
6282 /* neighbor route-server-client. */
6283 DEFUN (neighbor_route_server_client
,
6284 neighbor_route_server_client_cmd
,
6285 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6288 "Configure a neighbor as Route Server client\n")
6293 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6295 return CMD_WARNING_CONFIG_FAILED
;
6296 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6298 PEER_FLAG_RSERVER_CLIENT
);
6301 ALIAS_HIDDEN(neighbor_route_server_client
,
6302 neighbor_route_server_client_hidden_cmd
,
6303 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6304 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6305 "Configure a neighbor as Route Server client\n")
6307 DEFUN (no_neighbor_route_server_client
,
6308 no_neighbor_route_server_client_cmd
,
6309 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6313 "Configure a neighbor as Route Server client\n")
6316 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6317 bgp_node_afi(vty
), bgp_node_safi(vty
),
6318 PEER_FLAG_RSERVER_CLIENT
);
6321 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6322 no_neighbor_route_server_client_hidden_cmd
,
6323 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6324 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6325 "Configure a neighbor as Route Server client\n")
6327 DEFUN (neighbor_nexthop_local_unchanged
,
6328 neighbor_nexthop_local_unchanged_cmd
,
6329 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6332 "Configure treatment of outgoing link-local nexthop attribute\n"
6333 "Leave link-local nexthop unchanged for this peer\n")
6336 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6338 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6341 DEFUN (no_neighbor_nexthop_local_unchanged
,
6342 no_neighbor_nexthop_local_unchanged_cmd
,
6343 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6347 "Configure treatment of outgoing link-local-nexthop attribute\n"
6348 "Leave link-local nexthop unchanged for this peer\n")
6351 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6352 bgp_node_afi(vty
), bgp_node_safi(vty
),
6353 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6356 DEFUN (neighbor_attr_unchanged
,
6357 neighbor_attr_unchanged_cmd
,
6358 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6361 "BGP attribute is propagated unchanged to this neighbor\n"
6362 "As-path attribute\n"
6363 "Nexthop attribute\n"
6367 char *peer_str
= argv
[1]->arg
;
6369 bool aspath
= false;
6370 bool nexthop
= false;
6372 afi_t afi
= bgp_node_afi(vty
);
6373 safi_t safi
= bgp_node_safi(vty
);
6376 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6378 return CMD_WARNING_CONFIG_FAILED
;
6380 if (argv_find(argv
, argc
, "as-path", &idx
))
6384 if (argv_find(argv
, argc
, "next-hop", &idx
))
6388 if (argv_find(argv
, argc
, "med", &idx
))
6391 /* no flags means all of them! */
6392 if (!aspath
&& !nexthop
&& !med
) {
6393 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6394 PEER_FLAG_AS_PATH_UNCHANGED
);
6395 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6396 PEER_FLAG_NEXTHOP_UNCHANGED
);
6397 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6398 PEER_FLAG_MED_UNCHANGED
);
6401 if (peer_af_flag_check(peer
, afi
, safi
,
6402 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6403 ret
|= peer_af_flag_unset_vty(
6404 vty
, peer_str
, afi
, safi
,
6405 PEER_FLAG_AS_PATH_UNCHANGED
);
6408 ret
|= peer_af_flag_set_vty(
6409 vty
, peer_str
, afi
, safi
,
6410 PEER_FLAG_AS_PATH_UNCHANGED
);
6413 if (peer_af_flag_check(peer
, afi
, safi
,
6414 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6415 ret
|= peer_af_flag_unset_vty(
6416 vty
, peer_str
, afi
, safi
,
6417 PEER_FLAG_NEXTHOP_UNCHANGED
);
6420 ret
|= peer_af_flag_set_vty(
6421 vty
, peer_str
, afi
, safi
,
6422 PEER_FLAG_NEXTHOP_UNCHANGED
);
6425 if (peer_af_flag_check(peer
, afi
, safi
,
6426 PEER_FLAG_MED_UNCHANGED
)) {
6427 ret
|= peer_af_flag_unset_vty(
6428 vty
, peer_str
, afi
, safi
,
6429 PEER_FLAG_MED_UNCHANGED
);
6432 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6433 PEER_FLAG_MED_UNCHANGED
);
6440 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6441 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6442 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6443 "BGP attribute is propagated unchanged to this neighbor\n"
6444 "As-path attribute\n"
6445 "Nexthop attribute\n"
6448 DEFUN (no_neighbor_attr_unchanged
,
6449 no_neighbor_attr_unchanged_cmd
,
6450 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6454 "BGP attribute is propagated unchanged to this neighbor\n"
6455 "As-path attribute\n"
6456 "Nexthop attribute\n"
6460 char *peer_str
= argv
[2]->arg
;
6462 bool aspath
= false;
6463 bool nexthop
= false;
6465 afi_t afi
= bgp_node_afi(vty
);
6466 safi_t safi
= bgp_node_safi(vty
);
6469 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6471 return CMD_WARNING_CONFIG_FAILED
;
6473 if (argv_find(argv
, argc
, "as-path", &idx
))
6477 if (argv_find(argv
, argc
, "next-hop", &idx
))
6481 if (argv_find(argv
, argc
, "med", &idx
))
6484 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6485 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6486 PEER_FLAG_AS_PATH_UNCHANGED
)
6487 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6488 PEER_FLAG_NEXTHOP_UNCHANGED
)
6489 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6490 PEER_FLAG_MED_UNCHANGED
);
6493 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6494 PEER_FLAG_AS_PATH_UNCHANGED
);
6497 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6498 PEER_FLAG_NEXTHOP_UNCHANGED
);
6501 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6502 PEER_FLAG_MED_UNCHANGED
);
6508 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6509 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6510 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6511 "BGP attribute is propagated unchanged to this neighbor\n"
6512 "As-path attribute\n"
6513 "Nexthop attribute\n"
6516 /* EBGP multihop configuration. */
6517 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6518 const char *ttl_str
)
6523 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6525 return CMD_WARNING_CONFIG_FAILED
;
6528 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6533 ttl
= strtoul(ttl_str
, NULL
, 10);
6535 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6538 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6542 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6544 return CMD_WARNING_CONFIG_FAILED
;
6546 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6549 /* neighbor ebgp-multihop. */
6550 DEFUN (neighbor_ebgp_multihop
,
6551 neighbor_ebgp_multihop_cmd
,
6552 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6555 "Allow EBGP neighbors not on directly connected networks\n")
6558 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6561 DEFUN (neighbor_ebgp_multihop_ttl
,
6562 neighbor_ebgp_multihop_ttl_cmd
,
6563 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6566 "Allow EBGP neighbors not on directly connected networks\n"
6567 "maximum hop count\n")
6571 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6572 argv
[idx_number
]->arg
);
6575 DEFUN (no_neighbor_ebgp_multihop
,
6576 no_neighbor_ebgp_multihop_cmd
,
6577 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6581 "Allow EBGP neighbors not on directly connected networks\n"
6582 "maximum hop count\n")
6585 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6588 DEFPY (neighbor_aigp
,
6590 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6594 "Enable send and receive of the AIGP attribute per neighbor\n")
6598 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6600 return CMD_WARNING_CONFIG_FAILED
;
6603 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6605 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6608 static uint8_t get_role_by_name(const char *role_str
)
6610 if (strncmp(role_str
, "peer", 2) == 0)
6612 if (strncmp(role_str
, "provider", 2) == 0)
6613 return ROLE_PROVIDER
;
6614 if (strncmp(role_str
, "customer", 2) == 0)
6615 return ROLE_CUSTOMER
;
6616 if (strncmp(role_str
, "rs-server", 4) == 0)
6617 return ROLE_RS_SERVER
;
6618 if (strncmp(role_str
, "rs-client", 4) == 0)
6619 return ROLE_RS_CLIENT
;
6620 return ROLE_UNDEFINED
;
6623 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6624 const char *role_str
, bool strict_mode
)
6628 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6630 return CMD_WARNING_CONFIG_FAILED
;
6631 uint8_t role
= get_role_by_name(role_str
);
6633 if (role
== ROLE_UNDEFINED
)
6634 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6635 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6638 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6642 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6644 return CMD_WARNING_CONFIG_FAILED
;
6645 return bgp_vty_return(vty
, peer_role_unset(peer
));
6648 DEFPY(neighbor_role
,
6650 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6653 "Set session role\n"
6659 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6663 DEFPY(neighbor_role_strict
,
6664 neighbor_role_strict_cmd
,
6665 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6668 "Set session role\n"
6670 "Use additional restriction on peer\n")
6675 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6679 DEFPY(no_neighbor_role
,
6680 no_neighbor_role_cmd
,
6681 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6685 "Set session role\n"
6687 "Use additional restriction on peer\n")
6691 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6694 /* disable-connected-check */
6695 DEFUN (neighbor_disable_connected_check
,
6696 neighbor_disable_connected_check_cmd
,
6697 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6700 "one-hop away EBGP peer using loopback address\n"
6701 "Enforce EBGP neighbors perform multihop\n")
6704 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6705 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6708 DEFUN (no_neighbor_disable_connected_check
,
6709 no_neighbor_disable_connected_check_cmd
,
6710 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6714 "one-hop away EBGP peer using loopback address\n"
6715 "Enforce EBGP neighbors perform multihop\n")
6718 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6719 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6722 /* disable-link-bw-encoding-ieee */
6723 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6724 neighbor_disable_link_bw_encoding_ieee_cmd
,
6725 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6726 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6727 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6731 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6732 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6735 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6736 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6737 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6738 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6739 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6743 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6744 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6747 /* extended-optional-parameters */
6748 DEFUN(neighbor_extended_optional_parameters
,
6749 neighbor_extended_optional_parameters_cmd
,
6750 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6751 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6752 "Force the extended optional parameters format for OPEN messages\n")
6756 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6757 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6760 DEFUN(no_neighbor_extended_optional_parameters
,
6761 no_neighbor_extended_optional_parameters_cmd
,
6762 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6763 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6764 "Force the extended optional parameters format for OPEN messages\n")
6768 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6769 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6772 /* enforce-first-as */
6773 DEFUN (neighbor_enforce_first_as
,
6774 neighbor_enforce_first_as_cmd
,
6775 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6778 "Enforce the first AS for EBGP routes\n")
6782 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6783 PEER_FLAG_ENFORCE_FIRST_AS
);
6786 DEFUN (no_neighbor_enforce_first_as
,
6787 no_neighbor_enforce_first_as_cmd
,
6788 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6792 "Enforce the first AS for EBGP routes\n")
6796 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6797 PEER_FLAG_ENFORCE_FIRST_AS
);
6801 DEFUN (neighbor_description
,
6802 neighbor_description_cmd
,
6803 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6806 "Neighbor specific description\n"
6807 "Up to 80 characters describing this neighbor\n")
6814 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6816 return CMD_WARNING_CONFIG_FAILED
;
6818 str
= argv_concat(argv
, argc
, idx_line
);
6820 peer_description_set(peer
, str
);
6822 XFREE(MTYPE_TMP
, str
);
6827 DEFUN (no_neighbor_description
,
6828 no_neighbor_description_cmd
,
6829 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6833 "Neighbor specific description\n")
6838 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6840 return CMD_WARNING_CONFIG_FAILED
;
6842 peer_description_unset(peer
);
6847 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6848 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6849 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6850 "Neighbor specific description\n"
6851 "Up to 80 characters describing this neighbor\n")
6853 /* Neighbor update-source. */
6854 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6855 const char *source_str
)
6861 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6863 return CMD_WARNING_CONFIG_FAILED
;
6869 if (str2sockunion(source_str
, &su
) == 0)
6870 peer_update_source_addr_set(peer
, &su
);
6872 if (str2prefix(source_str
, &p
)) {
6874 "%% Invalid update-source, remove prefix length \n");
6875 return CMD_WARNING_CONFIG_FAILED
;
6877 peer_update_source_if_set(peer
, source_str
);
6880 peer_update_source_unset(peer
);
6885 #define BGP_UPDATE_SOURCE_HELP_STR \
6888 "Interface name (requires zebra to be running)\n"
6890 DEFUN (neighbor_update_source
,
6891 neighbor_update_source_cmd
,
6892 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6895 "Source of routing updates\n"
6896 BGP_UPDATE_SOURCE_HELP_STR
)
6900 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6901 argv
[idx_peer_2
]->arg
);
6904 DEFUN (no_neighbor_update_source
,
6905 no_neighbor_update_source_cmd
,
6906 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6910 "Source of routing updates\n"
6911 BGP_UPDATE_SOURCE_HELP_STR
)
6914 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6917 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6918 afi_t afi
, safi_t safi
,
6919 const char *rmap
, int set
)
6923 struct route_map
*route_map
= NULL
;
6925 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6927 return CMD_WARNING_CONFIG_FAILED
;
6931 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6932 ret
= peer_default_originate_set(peer
, afi
, safi
,
6935 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6937 return bgp_vty_return(vty
, ret
);
6940 /* neighbor default-originate. */
6941 DEFUN (neighbor_default_originate
,
6942 neighbor_default_originate_cmd
,
6943 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6946 "Originate default route to this neighbor\n")
6949 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6951 bgp_node_safi(vty
), NULL
, 1);
6954 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6955 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6956 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6957 "Originate default route to this neighbor\n")
6959 DEFUN (neighbor_default_originate_rmap
,
6960 neighbor_default_originate_rmap_cmd
,
6961 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6964 "Originate default route to this neighbor\n"
6965 "Route-map to specify criteria to originate default\n"
6970 return peer_default_originate_set_vty(
6971 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6972 argv
[idx_word
]->arg
, 1);
6976 neighbor_default_originate_rmap
,
6977 neighbor_default_originate_rmap_hidden_cmd
,
6978 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6979 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6980 "Originate default route to this neighbor\n"
6981 "Route-map to specify criteria to originate default\n"
6984 DEFUN (no_neighbor_default_originate
,
6985 no_neighbor_default_originate_cmd
,
6986 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6990 "Originate default route to this neighbor\n"
6991 "Route-map to specify criteria to originate default\n"
6995 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6997 bgp_node_safi(vty
), NULL
, 0);
7001 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7002 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
7003 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7004 "Originate default route to this neighbor\n"
7005 "Route-map to specify criteria to originate default\n"
7009 /* Set neighbor's BGP port. */
7010 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
7011 const char *port_str
)
7017 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7019 return CMD_WARNING_CONFIG_FAILED
;
7022 sp
= getservbyname("bgp", "tcp");
7023 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
7025 port
= strtoul(port_str
, NULL
, 10);
7028 peer_port_set(peer
, port
);
7033 /* Set specified peer's BGP port. */
7034 DEFUN (neighbor_port
,
7036 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7039 "Neighbor's BGP port\n"
7040 "TCP port number\n")
7044 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7045 argv
[idx_number
]->arg
);
7048 DEFUN (no_neighbor_port
,
7049 no_neighbor_port_cmd
,
7050 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7054 "Neighbor's BGP port\n"
7055 "TCP port number\n")
7058 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7062 /* neighbor weight. */
7063 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7064 safi_t safi
, const char *weight_str
)
7068 unsigned long weight
;
7070 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7072 return CMD_WARNING_CONFIG_FAILED
;
7074 weight
= strtoul(weight_str
, NULL
, 10);
7076 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7077 return bgp_vty_return(vty
, ret
);
7080 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7086 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7088 return CMD_WARNING_CONFIG_FAILED
;
7090 ret
= peer_weight_unset(peer
, afi
, safi
);
7091 return bgp_vty_return(vty
, ret
);
7094 DEFUN (neighbor_weight
,
7095 neighbor_weight_cmd
,
7096 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7099 "Set default weight for routes from this neighbor\n"
7104 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7105 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7108 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7109 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7110 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7111 "Set default weight for routes from this neighbor\n"
7114 DEFUN (no_neighbor_weight
,
7115 no_neighbor_weight_cmd
,
7116 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7120 "Set default weight for routes from this neighbor\n"
7124 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7125 bgp_node_afi(vty
), bgp_node_safi(vty
));
7128 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7129 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7130 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7131 "Set default weight for routes from this neighbor\n"
7135 /* Override capability negotiation. */
7136 DEFUN (neighbor_override_capability
,
7137 neighbor_override_capability_cmd
,
7138 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7141 "Override capability negotiation result\n")
7144 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7145 PEER_FLAG_OVERRIDE_CAPABILITY
);
7148 DEFUN (no_neighbor_override_capability
,
7149 no_neighbor_override_capability_cmd
,
7150 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7154 "Override capability negotiation result\n")
7157 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7158 PEER_FLAG_OVERRIDE_CAPABILITY
);
7161 DEFUN (neighbor_strict_capability
,
7162 neighbor_strict_capability_cmd
,
7163 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7166 "Strict capability negotiation match\n")
7170 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7171 PEER_FLAG_STRICT_CAP_MATCH
);
7174 DEFUN (no_neighbor_strict_capability
,
7175 no_neighbor_strict_capability_cmd
,
7176 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7180 "Strict capability negotiation match\n")
7184 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7185 PEER_FLAG_STRICT_CAP_MATCH
);
7188 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7189 const char *keep_str
, const char *hold_str
)
7196 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7198 return CMD_WARNING_CONFIG_FAILED
;
7200 keepalive
= strtoul(keep_str
, NULL
, 10);
7201 holdtime
= strtoul(hold_str
, NULL
, 10);
7203 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7205 return bgp_vty_return(vty
, ret
);
7208 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7213 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7215 return CMD_WARNING_CONFIG_FAILED
;
7217 ret
= peer_timers_unset(peer
);
7219 return bgp_vty_return(vty
, ret
);
7222 DEFUN (neighbor_timers
,
7223 neighbor_timers_cmd
,
7224 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7227 "BGP per neighbor timers\n"
7228 "Keepalive interval\n"
7233 int idx_number_2
= 4;
7234 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7235 argv
[idx_number
]->arg
,
7236 argv
[idx_number_2
]->arg
);
7239 DEFUN (no_neighbor_timers
,
7240 no_neighbor_timers_cmd
,
7241 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7245 "BGP per neighbor timers\n"
7246 "Keepalive interval\n"
7250 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7254 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7255 const char *time_str
)
7261 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7263 return CMD_WARNING_CONFIG_FAILED
;
7265 connect
= strtoul(time_str
, NULL
, 10);
7267 ret
= peer_timers_connect_set(peer
, connect
);
7269 return bgp_vty_return(vty
, ret
);
7272 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7277 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7279 return CMD_WARNING_CONFIG_FAILED
;
7281 ret
= peer_timers_connect_unset(peer
);
7283 return bgp_vty_return(vty
, ret
);
7286 DEFUN (neighbor_timers_connect
,
7287 neighbor_timers_connect_cmd
,
7288 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7291 "BGP per neighbor timers\n"
7292 "BGP connect timer\n"
7297 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7298 argv
[idx_number
]->arg
);
7301 DEFUN (no_neighbor_timers_connect
,
7302 no_neighbor_timers_connect_cmd
,
7303 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7307 "BGP per neighbor timers\n"
7308 "BGP connect timer\n"
7312 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7315 DEFPY (neighbor_timers_delayopen
,
7316 neighbor_timers_delayopen_cmd
,
7317 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7320 "BGP per neighbor timers\n"
7321 "RFC 4271 DelayOpenTimer\n"
7322 "DelayOpenTime timer interval\n")
7326 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7328 return CMD_WARNING_CONFIG_FAILED
;
7331 if (peer_timers_delayopen_unset(peer
))
7332 return CMD_WARNING_CONFIG_FAILED
;
7334 if (peer_timers_delayopen_set(peer
, interval
))
7335 return CMD_WARNING_CONFIG_FAILED
;
7341 DEFPY (no_neighbor_timers_delayopen
,
7342 no_neighbor_timers_delayopen_cmd
,
7343 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7347 "BGP per neighbor timers\n"
7348 "RFC 4271 DelayOpenTimer\n"
7349 "DelayOpenTime timer interval\n")
7353 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7355 return CMD_WARNING_CONFIG_FAILED
;
7357 if (peer_timers_delayopen_unset(peer
))
7358 return CMD_WARNING_CONFIG_FAILED
;
7363 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7364 const char *time_str
, int set
)
7368 uint32_t routeadv
= 0;
7370 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7372 return CMD_WARNING_CONFIG_FAILED
;
7375 routeadv
= strtoul(time_str
, NULL
, 10);
7378 ret
= peer_advertise_interval_set(peer
, routeadv
);
7380 ret
= peer_advertise_interval_unset(peer
);
7382 return bgp_vty_return(vty
, ret
);
7385 DEFUN (neighbor_advertise_interval
,
7386 neighbor_advertise_interval_cmd
,
7387 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7390 "Minimum interval between sending BGP routing updates\n"
7391 "time in seconds\n")
7395 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7396 argv
[idx_number
]->arg
, 1);
7399 DEFUN (no_neighbor_advertise_interval
,
7400 no_neighbor_advertise_interval_cmd
,
7401 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7405 "Minimum interval between sending BGP routing updates\n"
7406 "time in seconds\n")
7409 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7413 /* Time to wait before processing route-map updates */
7414 DEFUN (bgp_set_route_map_delay_timer
,
7415 bgp_set_route_map_delay_timer_cmd
,
7416 "bgp route-map delay-timer (0-600)",
7418 "BGP route-map delay timer\n"
7419 "Time in secs to wait before processing route-map changes\n"
7420 "0 disables the timer, no route updates happen when route-maps change\n")
7423 uint32_t rmap_delay_timer
;
7425 if (argv
[idx_number
]->arg
) {
7426 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7427 bm
->rmap_update_timer
= rmap_delay_timer
;
7429 /* if the dynamic update handling is being disabled, and a timer
7431 * running, stop the timer and act as if the timer has already
7434 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7435 THREAD_OFF(bm
->t_rmap_update
);
7436 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7441 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7442 return CMD_WARNING_CONFIG_FAILED
;
7446 DEFUN (no_bgp_set_route_map_delay_timer
,
7447 no_bgp_set_route_map_delay_timer_cmd
,
7448 "no bgp route-map delay-timer [(0-600)]",
7451 "Default BGP route-map delay timer\n"
7452 "Reset to default time to wait for processing route-map changes\n"
7453 "0 disables the timer, no route updates happen when route-maps change\n")
7456 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7461 /* neighbor interface */
7462 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7467 peer
= peer_lookup_vty(vty
, ip_str
);
7468 if (!peer
|| peer
->conf_if
) {
7469 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7470 return CMD_WARNING_CONFIG_FAILED
;
7474 peer_interface_set(peer
, str
);
7476 peer_interface_unset(peer
);
7481 DEFUN (neighbor_interface
,
7482 neighbor_interface_cmd
,
7483 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7492 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7495 DEFUN (no_neighbor_interface
,
7496 no_neighbor_interface_cmd
,
7497 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7506 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7509 DEFUN (neighbor_distribute_list
,
7510 neighbor_distribute_list_cmd
,
7511 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7514 "Filter updates to/from this neighbor\n"
7515 "IP Access-list name\n"
7516 "Filter incoming updates\n"
7517 "Filter outgoing updates\n")
7524 const char *pstr
= argv
[idx_peer
]->arg
;
7525 const char *acl
= argv
[idx_acl
]->arg
;
7526 const char *inout
= argv
[argc
- 1]->text
;
7528 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7530 return CMD_WARNING_CONFIG_FAILED
;
7532 /* Check filter direction. */
7533 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7534 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7537 return bgp_vty_return(vty
, ret
);
7541 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7542 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7543 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7544 "Filter updates to/from this neighbor\n"
7545 "IP Access-list name\n"
7546 "Filter incoming updates\n"
7547 "Filter outgoing updates\n")
7549 DEFUN (no_neighbor_distribute_list
,
7550 no_neighbor_distribute_list_cmd
,
7551 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7555 "Filter updates to/from this neighbor\n"
7556 "IP Access-list name\n"
7557 "Filter incoming updates\n"
7558 "Filter outgoing updates\n")
7564 const char *pstr
= argv
[idx_peer
]->arg
;
7565 const char *inout
= argv
[argc
- 1]->text
;
7567 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7569 return CMD_WARNING_CONFIG_FAILED
;
7571 /* Check filter direction. */
7572 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7573 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7576 return bgp_vty_return(vty
, ret
);
7580 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7581 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7582 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7583 "Filter updates to/from this neighbor\n"
7584 "IP Access-list name\n"
7585 "Filter incoming updates\n"
7586 "Filter outgoing updates\n")
7588 /* Set prefix list to the peer. */
7589 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7590 afi_t afi
, safi_t safi
,
7591 const char *name_str
,
7592 const char *direct_str
)
7595 int direct
= FILTER_IN
;
7598 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7600 return CMD_WARNING_CONFIG_FAILED
;
7602 /* Check filter direction. */
7603 if (strncmp(direct_str
, "i", 1) == 0)
7605 else if (strncmp(direct_str
, "o", 1) == 0)
7606 direct
= FILTER_OUT
;
7608 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7610 return bgp_vty_return(vty
, ret
);
7613 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7614 afi_t afi
, safi_t safi
,
7615 const char *direct_str
)
7619 int direct
= FILTER_IN
;
7621 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7623 return CMD_WARNING_CONFIG_FAILED
;
7625 /* Check filter direction. */
7626 if (strncmp(direct_str
, "i", 1) == 0)
7628 else if (strncmp(direct_str
, "o", 1) == 0)
7629 direct
= FILTER_OUT
;
7631 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7633 return bgp_vty_return(vty
, ret
);
7636 DEFUN (neighbor_prefix_list
,
7637 neighbor_prefix_list_cmd
,
7638 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7641 "Filter updates to/from this neighbor\n"
7642 "Name of a prefix list\n"
7643 "Filter incoming updates\n"
7644 "Filter outgoing updates\n")
7649 return peer_prefix_list_set_vty(
7650 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7651 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7654 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7655 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7656 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7657 "Filter updates to/from this neighbor\n"
7658 "Name of a prefix list\n"
7659 "Filter incoming updates\n"
7660 "Filter outgoing updates\n")
7662 DEFUN (no_neighbor_prefix_list
,
7663 no_neighbor_prefix_list_cmd
,
7664 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7668 "Filter updates to/from this neighbor\n"
7669 "Name of a prefix list\n"
7670 "Filter incoming updates\n"
7671 "Filter outgoing updates\n")
7675 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7676 bgp_node_afi(vty
), bgp_node_safi(vty
),
7677 argv
[idx_in_out
]->arg
);
7680 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7681 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7682 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7683 "Filter updates to/from this neighbor\n"
7684 "Name of a prefix list\n"
7685 "Filter incoming updates\n"
7686 "Filter outgoing updates\n")
7688 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7689 safi_t safi
, const char *name_str
,
7690 const char *direct_str
)
7694 int direct
= FILTER_IN
;
7696 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7698 return CMD_WARNING_CONFIG_FAILED
;
7700 /* Check filter direction. */
7701 if (strncmp(direct_str
, "i", 1) == 0)
7703 else if (strncmp(direct_str
, "o", 1) == 0)
7704 direct
= FILTER_OUT
;
7706 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7708 return bgp_vty_return(vty
, ret
);
7711 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7712 safi_t safi
, const char *direct_str
)
7716 int direct
= FILTER_IN
;
7718 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7720 return CMD_WARNING_CONFIG_FAILED
;
7722 /* Check filter direction. */
7723 if (strncmp(direct_str
, "i", 1) == 0)
7725 else if (strncmp(direct_str
, "o", 1) == 0)
7726 direct
= FILTER_OUT
;
7728 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7730 return bgp_vty_return(vty
, ret
);
7733 DEFUN (neighbor_filter_list
,
7734 neighbor_filter_list_cmd
,
7735 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7738 "Establish BGP filters\n"
7739 "AS path access-list name\n"
7740 "Filter incoming routes\n"
7741 "Filter outgoing routes\n")
7746 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7747 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7748 argv
[idx_in_out
]->arg
);
7751 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7752 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7753 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7754 "Establish BGP filters\n"
7755 "AS path access-list name\n"
7756 "Filter incoming routes\n"
7757 "Filter outgoing routes\n")
7759 DEFUN (no_neighbor_filter_list
,
7760 no_neighbor_filter_list_cmd
,
7761 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7765 "Establish BGP filters\n"
7766 "AS path access-list name\n"
7767 "Filter incoming routes\n"
7768 "Filter outgoing routes\n")
7772 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7773 bgp_node_afi(vty
), bgp_node_safi(vty
),
7774 argv
[idx_in_out
]->arg
);
7777 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7778 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7779 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7780 "Establish BGP filters\n"
7781 "AS path access-list name\n"
7782 "Filter incoming routes\n"
7783 "Filter outgoing routes\n")
7785 /* Set advertise-map to the peer. */
7786 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7787 afi_t afi
, safi_t safi
,
7788 const char *advertise_str
,
7789 const char *condition_str
, bool condition
,
7792 int ret
= CMD_WARNING_CONFIG_FAILED
;
7794 struct route_map
*advertise_map
;
7795 struct route_map
*condition_map
;
7797 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7801 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7802 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7805 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7806 advertise_map
, condition_str
,
7807 condition_map
, condition
);
7809 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7810 advertise_map
, condition_str
,
7811 condition_map
, condition
);
7813 return bgp_vty_return(vty
, ret
);
7816 DEFPY (bgp_condadv_period
,
7817 bgp_condadv_period_cmd
,
7818 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7821 "Conditional advertisement settings\n"
7822 "Set period to rescan BGP table to check if condition is met\n"
7823 "Period between BGP table scans, in seconds; default 60\n")
7825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7827 bgp
->condition_check_period
=
7828 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7833 DEFPY (neighbor_advertise_map
,
7834 neighbor_advertise_map_cmd
,
7835 "[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",
7839 "Route-map to conditionally advertise routes\n"
7840 "Name of advertise map\n"
7841 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7842 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7843 "Name of the exist or non exist map\n")
7845 bool condition
= CONDITION_EXIST
;
7847 if (!strcmp(exist
, "non-exist-map"))
7848 condition
= CONDITION_NON_EXIST
;
7850 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7851 bgp_node_safi(vty
), advertise_str
,
7852 condition_str
, condition
, !no
);
7855 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7856 "[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",
7857 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7858 "Route-map to conditionally advertise routes\n"
7859 "Name of advertise map\n"
7860 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7861 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7862 "Name of the exist or non exist map\n")
7864 /* Set route-map to the peer. */
7865 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7866 afi_t afi
, safi_t safi
, const char *name_str
,
7867 const char *direct_str
)
7871 int direct
= RMAP_IN
;
7872 struct route_map
*route_map
;
7874 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7876 return CMD_WARNING_CONFIG_FAILED
;
7878 /* Check filter direction. */
7879 if (strncmp(direct_str
, "in", 2) == 0)
7881 else if (strncmp(direct_str
, "o", 1) == 0)
7884 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7885 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7887 return bgp_vty_return(vty
, ret
);
7890 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7891 afi_t afi
, safi_t safi
,
7892 const char *direct_str
)
7896 int direct
= RMAP_IN
;
7898 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7900 return CMD_WARNING_CONFIG_FAILED
;
7902 /* Check filter direction. */
7903 if (strncmp(direct_str
, "in", 2) == 0)
7905 else if (strncmp(direct_str
, "o", 1) == 0)
7908 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7910 return bgp_vty_return(vty
, ret
);
7913 DEFUN (neighbor_route_map
,
7914 neighbor_route_map_cmd
,
7915 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7918 "Apply route map to neighbor\n"
7919 "Name of route map\n"
7920 "Apply map to incoming routes\n"
7921 "Apply map to outbound routes\n")
7926 return peer_route_map_set_vty(
7927 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7928 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7931 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7932 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7933 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7934 "Apply route map to neighbor\n"
7935 "Name of route map\n"
7936 "Apply map to incoming routes\n"
7937 "Apply map to outbound routes\n")
7939 DEFUN (no_neighbor_route_map
,
7940 no_neighbor_route_map_cmd
,
7941 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7945 "Apply route map to neighbor\n"
7946 "Name of route map\n"
7947 "Apply map to incoming routes\n"
7948 "Apply map to outbound routes\n")
7952 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7953 bgp_node_afi(vty
), bgp_node_safi(vty
),
7954 argv
[idx_in_out
]->arg
);
7957 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7958 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7959 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7960 "Apply route map to neighbor\n"
7961 "Name of route map\n"
7962 "Apply map to incoming routes\n"
7963 "Apply map to outbound routes\n")
7965 /* Set unsuppress-map to the peer. */
7966 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7967 afi_t afi
, safi_t safi
,
7968 const char *name_str
)
7972 struct route_map
*route_map
;
7974 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7976 return CMD_WARNING_CONFIG_FAILED
;
7978 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7979 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7981 return bgp_vty_return(vty
, ret
);
7984 /* Unset route-map from the peer. */
7985 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7986 afi_t afi
, safi_t safi
)
7991 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7993 return CMD_WARNING_CONFIG_FAILED
;
7995 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7997 return bgp_vty_return(vty
, ret
);
8000 DEFUN (neighbor_unsuppress_map
,
8001 neighbor_unsuppress_map_cmd
,
8002 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8005 "Route-map to selectively unsuppress suppressed routes\n"
8006 "Name of route map\n")
8010 return peer_unsuppress_map_set_vty(
8011 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8012 argv
[idx_word
]->arg
);
8015 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8016 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8017 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8018 "Route-map to selectively unsuppress suppressed routes\n"
8019 "Name of route map\n")
8021 DEFUN (no_neighbor_unsuppress_map
,
8022 no_neighbor_unsuppress_map_cmd
,
8023 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8027 "Route-map to selectively unsuppress suppressed routes\n"
8028 "Name of route map\n")
8031 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8033 bgp_node_safi(vty
));
8036 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8037 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8038 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8039 "Route-map to selectively unsuppress suppressed routes\n"
8040 "Name of route map\n")
8042 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8043 afi_t afi
, safi_t safi
,
8044 const char *num_str
,
8045 const char *threshold_str
, int warning
,
8046 const char *restart_str
,
8047 const char *force_str
)
8055 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8057 return CMD_WARNING_CONFIG_FAILED
;
8059 max
= strtoul(num_str
, NULL
, 10);
8061 threshold
= atoi(threshold_str
);
8063 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8066 restart
= atoi(restart_str
);
8070 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8071 restart
, force_str
? true : false);
8073 return bgp_vty_return(vty
, ret
);
8076 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8077 afi_t afi
, safi_t safi
)
8082 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8084 return CMD_WARNING_CONFIG_FAILED
;
8086 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8088 return bgp_vty_return(vty
, ret
);
8091 /* Maximum number of prefix to be sent to the neighbor. */
8092 DEFUN(neighbor_maximum_prefix_out
,
8093 neighbor_maximum_prefix_out_cmd
,
8094 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8097 "Maximum number of prefixes to be sent to this peer\n"
8098 "Maximum no. of prefix limit\n")
8105 afi_t afi
= bgp_node_afi(vty
);
8106 safi_t safi
= bgp_node_safi(vty
);
8108 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8110 return CMD_WARNING_CONFIG_FAILED
;
8112 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8114 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8116 return bgp_vty_return(vty
, ret
);
8119 DEFUN(no_neighbor_maximum_prefix_out
,
8120 no_neighbor_maximum_prefix_out_cmd
,
8121 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8125 "Maximum number of prefixes to be sent to this peer\n"
8126 "Maximum no. of prefix limit\n")
8131 afi_t afi
= bgp_node_afi(vty
);
8132 safi_t safi
= bgp_node_safi(vty
);
8134 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8136 return CMD_WARNING_CONFIG_FAILED
;
8138 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8140 return bgp_vty_return(vty
, ret
);
8143 /* Maximum number of prefix configuration. Prefix count is different
8144 for each peer configuration. So this configuration can be set for
8145 each peer configuration. */
8146 DEFUN (neighbor_maximum_prefix
,
8147 neighbor_maximum_prefix_cmd
,
8148 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8151 "Maximum number of prefix accept from this peer\n"
8152 "maximum no. of prefix limit\n"
8153 "Force checking all received routes not only accepted\n")
8160 if (argv_find(argv
, argc
, "force", &idx_force
))
8161 force
= argv
[idx_force
]->arg
;
8163 return peer_maximum_prefix_set_vty(
8164 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8165 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8168 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8169 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8170 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8171 "Maximum number of prefix accept from this peer\n"
8172 "maximum no. of prefix limit\n"
8173 "Force checking all received routes not only accepted\n")
8175 DEFUN (neighbor_maximum_prefix_threshold
,
8176 neighbor_maximum_prefix_threshold_cmd
,
8177 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8180 "Maximum number of prefix accept from this peer\n"
8181 "maximum no. of prefix limit\n"
8182 "Threshold value (%) at which to generate a warning msg\n"
8183 "Force checking all received routes not only accepted\n")
8187 int idx_number_2
= 4;
8191 if (argv_find(argv
, argc
, "force", &idx_force
))
8192 force
= argv
[idx_force
]->arg
;
8194 return peer_maximum_prefix_set_vty(
8195 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8196 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8200 neighbor_maximum_prefix_threshold
,
8201 neighbor_maximum_prefix_threshold_hidden_cmd
,
8202 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8203 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8204 "Maximum number of prefix accept from this peer\n"
8205 "maximum no. of prefix limit\n"
8206 "Threshold value (%) at which to generate a warning msg\n"
8207 "Force checking all received routes not only accepted\n")
8209 DEFUN (neighbor_maximum_prefix_warning
,
8210 neighbor_maximum_prefix_warning_cmd
,
8211 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8214 "Maximum number of prefix accept from this peer\n"
8215 "maximum no. of prefix limit\n"
8216 "Only give warning message when limit is exceeded\n"
8217 "Force checking all received routes not only accepted\n")
8224 if (argv_find(argv
, argc
, "force", &idx_force
))
8225 force
= argv
[idx_force
]->arg
;
8227 return peer_maximum_prefix_set_vty(
8228 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8229 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8233 neighbor_maximum_prefix_warning
,
8234 neighbor_maximum_prefix_warning_hidden_cmd
,
8235 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8236 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8237 "Maximum number of prefix accept from this peer\n"
8238 "maximum no. of prefix limit\n"
8239 "Only give warning message when limit is exceeded\n"
8240 "Force checking all received routes not only accepted\n")
8242 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8243 neighbor_maximum_prefix_threshold_warning_cmd
,
8244 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8247 "Maximum number of prefix accept from this peer\n"
8248 "maximum no. of prefix limit\n"
8249 "Threshold value (%) at which to generate a warning msg\n"
8250 "Only give warning message when limit is exceeded\n"
8251 "Force checking all received routes not only accepted\n")
8255 int idx_number_2
= 4;
8259 if (argv_find(argv
, argc
, "force", &idx_force
))
8260 force
= argv
[idx_force
]->arg
;
8262 return peer_maximum_prefix_set_vty(
8263 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8264 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8268 neighbor_maximum_prefix_threshold_warning
,
8269 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8270 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8271 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8272 "Maximum number of prefix accept from this peer\n"
8273 "maximum no. of prefix limit\n"
8274 "Threshold value (%) at which to generate a warning msg\n"
8275 "Only give warning message when limit is exceeded\n"
8276 "Force checking all received routes not only accepted\n")
8278 DEFUN (neighbor_maximum_prefix_restart
,
8279 neighbor_maximum_prefix_restart_cmd
,
8280 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8283 "Maximum number of prefix accept from this peer\n"
8284 "maximum no. of prefix limit\n"
8285 "Restart bgp connection after limit is exceeded\n"
8286 "Restart interval in minutes\n"
8287 "Force checking all received routes not only accepted\n")
8291 int idx_number_2
= 5;
8295 if (argv_find(argv
, argc
, "force", &idx_force
))
8296 force
= argv
[idx_force
]->arg
;
8298 return peer_maximum_prefix_set_vty(
8299 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8300 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8304 neighbor_maximum_prefix_restart
,
8305 neighbor_maximum_prefix_restart_hidden_cmd
,
8306 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8308 "Maximum number of prefix accept from this peer\n"
8309 "maximum no. of prefix limit\n"
8310 "Restart bgp connection after limit is exceeded\n"
8311 "Restart interval in minutes\n"
8312 "Force checking all received routes not only accepted\n")
8314 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8315 neighbor_maximum_prefix_threshold_restart_cmd
,
8316 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8319 "Maximum number of prefixes to accept from this peer\n"
8320 "maximum no. of prefix limit\n"
8321 "Threshold value (%) at which to generate a warning msg\n"
8322 "Restart bgp connection after limit is exceeded\n"
8323 "Restart interval in minutes\n"
8324 "Force checking all received routes not only accepted\n")
8328 int idx_number_2
= 4;
8329 int idx_number_3
= 6;
8333 if (argv_find(argv
, argc
, "force", &idx_force
))
8334 force
= argv
[idx_force
]->arg
;
8336 return peer_maximum_prefix_set_vty(
8337 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8338 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8339 argv
[idx_number_3
]->arg
, force
);
8343 neighbor_maximum_prefix_threshold_restart
,
8344 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8345 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8346 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8347 "Maximum number of prefixes to accept from this peer\n"
8348 "maximum no. of prefix limit\n"
8349 "Threshold value (%) at which to generate a warning msg\n"
8350 "Restart bgp connection after limit is exceeded\n"
8351 "Restart interval in minutes\n"
8352 "Force checking all received routes not only accepted\n")
8354 DEFUN (no_neighbor_maximum_prefix
,
8355 no_neighbor_maximum_prefix_cmd
,
8356 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8360 "Maximum number of prefixes to accept from this peer\n"
8361 "maximum no. of prefix limit\n"
8362 "Threshold value (%) at which to generate a warning msg\n"
8363 "Restart bgp connection after limit is exceeded\n"
8364 "Restart interval in minutes\n"
8365 "Only give warning message when limit is exceeded\n"
8366 "Force checking all received routes not only accepted\n")
8369 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8371 bgp_node_safi(vty
));
8375 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8376 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8377 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8378 "Maximum number of prefixes to accept from this peer\n"
8379 "maximum no. of prefix limit\n"
8380 "Threshold value (%) at which to generate a warning msg\n"
8381 "Restart bgp connection after limit is exceeded\n"
8382 "Restart interval in minutes\n"
8383 "Only give warning message when limit is exceeded\n"
8384 "Force checking all received routes not only accepted\n")
8386 /* "neighbor accept-own" */
8387 DEFPY (neighbor_accept_own
,
8388 neighbor_accept_own_cmd
,
8389 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8393 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8396 afi_t afi
= bgp_node_afi(vty
);
8397 safi_t safi
= bgp_node_safi(vty
);
8400 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8402 return CMD_WARNING_CONFIG_FAILED
;
8405 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8407 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8409 return bgp_vty_return(vty
, ret
);
8412 /* "neighbor soo" */
8413 DEFPY (neighbor_soo
,
8415 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8418 "Set the Site-of-Origin (SoO) extended community\n"
8419 "VPN extended community\n")
8422 afi_t afi
= bgp_node_afi(vty
);
8423 safi_t safi
= bgp_node_safi(vty
);
8424 struct ecommunity
*ecomm_soo
;
8426 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8428 return CMD_WARNING_CONFIG_FAILED
;
8430 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8432 vty_out(vty
, "%% Malformed SoO extended community\n");
8435 ecommunity_str(ecomm_soo
);
8437 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8438 ecommunity_free(&peer
->soo
[afi
][safi
]);
8439 peer
->soo
[afi
][safi
] = ecomm_soo
;
8440 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8443 return bgp_vty_return(vty
,
8444 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8447 DEFPY (no_neighbor_soo
,
8448 no_neighbor_soo_cmd
,
8449 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8453 "Set the Site-of-Origin (SoO) extended community\n"
8454 "VPN extended community\n")
8457 afi_t afi
= bgp_node_afi(vty
);
8458 safi_t safi
= bgp_node_safi(vty
);
8460 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8462 return CMD_WARNING_CONFIG_FAILED
;
8464 ecommunity_free(&peer
->soo
[afi
][safi
]);
8466 return bgp_vty_return(
8467 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8470 /* "neighbor allowas-in" */
8471 DEFUN (neighbor_allowas_in
,
8472 neighbor_allowas_in_cmd
,
8473 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8476 "Accept as-path with my AS present in it\n"
8477 "Number of occurrences of AS number\n"
8478 "Only accept my AS in the as-path if the route was originated in my AS\n")
8481 int idx_number_origin
= 3;
8487 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8489 return CMD_WARNING_CONFIG_FAILED
;
8491 if (argc
<= idx_number_origin
)
8494 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8497 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8500 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8503 return bgp_vty_return(vty
, ret
);
8507 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8508 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8509 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8510 "Accept as-path with my AS present in it\n"
8511 "Number of occurrences of AS number\n"
8512 "Only accept my AS in the as-path if the route was originated in my AS\n")
8514 DEFUN (no_neighbor_allowas_in
,
8515 no_neighbor_allowas_in_cmd
,
8516 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8520 "allow local ASN appears in aspath attribute\n"
8521 "Number of occurrences of AS number\n"
8522 "Only accept my AS in the as-path if the route was originated in my AS\n")
8528 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8530 return CMD_WARNING_CONFIG_FAILED
;
8532 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8533 bgp_node_safi(vty
));
8535 return bgp_vty_return(vty
, ret
);
8539 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8540 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8541 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8542 "allow local ASN appears in aspath attribute\n"
8543 "Number of occurrences of AS number\n"
8544 "Only accept my AS in the as-path if the route was originated in my AS\n")
8546 DEFUN (neighbor_ttl_security
,
8547 neighbor_ttl_security_cmd
,
8548 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8551 "BGP ttl-security parameters\n"
8552 "Specify the maximum number of hops to the BGP peer\n"
8553 "Number of hops to BGP peer\n")
8560 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8562 return CMD_WARNING_CONFIG_FAILED
;
8564 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8567 * If 'neighbor swpX', then this is for directly connected peers,
8568 * we should not accept a ttl-security hops value greater than 1.
8570 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8572 "%s is directly connected peer, hops cannot exceed 1\n",
8573 argv
[idx_peer
]->arg
);
8574 return CMD_WARNING_CONFIG_FAILED
;
8577 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8580 DEFUN (no_neighbor_ttl_security
,
8581 no_neighbor_ttl_security_cmd
,
8582 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8586 "BGP ttl-security parameters\n"
8587 "Specify the maximum number of hops to the BGP peer\n"
8588 "Number of hops to BGP peer\n")
8593 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8595 return CMD_WARNING_CONFIG_FAILED
;
8597 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8600 /* disable-addpath-rx */
8601 DEFUN(neighbor_disable_addpath_rx
,
8602 neighbor_disable_addpath_rx_cmd
,
8603 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8606 "Do not accept additional paths\n")
8608 char *peer_str
= argv
[1]->arg
;
8610 afi_t afi
= bgp_node_afi(vty
);
8611 safi_t safi
= bgp_node_safi(vty
);
8613 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8615 return CMD_WARNING_CONFIG_FAILED
;
8617 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8618 PEER_FLAG_DISABLE_ADDPATH_RX
);
8621 DEFUN(no_neighbor_disable_addpath_rx
,
8622 no_neighbor_disable_addpath_rx_cmd
,
8623 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8627 "Do not accept additional paths\n")
8629 char *peer_str
= argv
[2]->arg
;
8631 afi_t afi
= bgp_node_afi(vty
);
8632 safi_t safi
= bgp_node_safi(vty
);
8634 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8636 return CMD_WARNING_CONFIG_FAILED
;
8638 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8639 PEER_FLAG_DISABLE_ADDPATH_RX
);
8642 DEFUN (neighbor_addpath_tx_all_paths
,
8643 neighbor_addpath_tx_all_paths_cmd
,
8644 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8647 "Use addpath to advertise all paths to a neighbor\n")
8652 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8654 return CMD_WARNING_CONFIG_FAILED
;
8656 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8661 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8662 neighbor_addpath_tx_all_paths_hidden_cmd
,
8663 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8664 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8665 "Use addpath to advertise all paths to a neighbor\n")
8667 DEFUN (no_neighbor_addpath_tx_all_paths
,
8668 no_neighbor_addpath_tx_all_paths_cmd
,
8669 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8673 "Use addpath to advertise all paths to a neighbor\n")
8678 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8680 return CMD_WARNING_CONFIG_FAILED
;
8682 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8683 != BGP_ADDPATH_ALL
) {
8685 "%% Peer not currently configured to transmit all paths.");
8686 return CMD_WARNING_CONFIG_FAILED
;
8689 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8695 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8696 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8697 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8698 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8699 "Use addpath to advertise all paths to a neighbor\n")
8701 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8702 neighbor_addpath_tx_bestpath_per_as_cmd
,
8703 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8706 "Use addpath to advertise the bestpath per each neighboring AS\n")
8711 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8713 return CMD_WARNING_CONFIG_FAILED
;
8715 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8716 BGP_ADDPATH_BEST_PER_AS
);
8721 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8722 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8723 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8724 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8725 "Use addpath to advertise the bestpath per each neighboring AS\n")
8727 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8728 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8729 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8733 "Use addpath to advertise the bestpath per each neighboring AS\n")
8738 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8740 return CMD_WARNING_CONFIG_FAILED
;
8742 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8743 != BGP_ADDPATH_BEST_PER_AS
) {
8745 "%% Peer not currently configured to transmit all best path per as.");
8746 return CMD_WARNING_CONFIG_FAILED
;
8749 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8755 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8756 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8757 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8758 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8759 "Use addpath to advertise the bestpath per each neighboring AS\n")
8762 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8763 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8766 "Detect AS loops before sending to neighbor\n")
8770 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8772 return CMD_WARNING_CONFIG_FAILED
;
8774 peer
->as_path_loop_detection
= true;
8780 no_neighbor_aspath_loop_detection
,
8781 no_neighbor_aspath_loop_detection_cmd
,
8782 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8786 "Detect AS loops before sending to neighbor\n")
8790 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8792 return CMD_WARNING_CONFIG_FAILED
;
8794 peer
->as_path_loop_detection
= false;
8799 DEFPY(neighbor_path_attribute_discard
,
8800 neighbor_path_attribute_discard_cmd
,
8801 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...",
8804 "Manipulate path attributes from incoming UPDATE messages\n"
8805 "Drop specified attributes from incoming UPDATE messages\n"
8806 "Attribute number\n")
8810 const char *discard_attrs
= NULL
;
8812 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8814 return CMD_WARNING_CONFIG_FAILED
;
8816 argv_find(argv
, argc
, "(1-255)", &idx
);
8818 discard_attrs
= argv_concat(argv
, argc
, idx
);
8820 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, true);
8825 DEFPY(no_neighbor_path_attribute_discard
,
8826 no_neighbor_path_attribute_discard_cmd
,
8827 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]",
8831 "Manipulate path attributes from incoming UPDATE messages\n"
8832 "Drop specified attributes from incoming UPDATE messages\n"
8833 "Attribute number\n")
8837 const char *discard_attrs
= NULL
;
8839 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8841 return CMD_WARNING_CONFIG_FAILED
;
8843 argv_find(argv
, argc
, "(1-255)", &idx
);
8845 discard_attrs
= argv
[idx
]->arg
;
8847 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, false);
8852 DEFPY(neighbor_path_attribute_treat_as_withdraw
,
8853 neighbor_path_attribute_treat_as_withdraw_cmd
,
8854 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8857 "Manipulate path attributes from incoming UPDATE messages\n"
8858 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8859 "Attribute number\n")
8863 const char *withdraw_attrs
= NULL
;
8865 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8867 return CMD_WARNING_CONFIG_FAILED
;
8869 argv_find(argv
, argc
, "(1-255)", &idx
);
8871 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8873 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, true);
8878 DEFPY(no_neighbor_path_attribute_treat_as_withdraw
,
8879 no_neighbor_path_attribute_treat_as_withdraw_cmd
,
8880 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8884 "Manipulate path attributes from incoming UPDATE messages\n"
8885 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8886 "Attribute number\n")
8890 const char *withdraw_attrs
= NULL
;
8892 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8894 return CMD_WARNING_CONFIG_FAILED
;
8896 argv_find(argv
, argc
, "(1-255)", &idx
);
8898 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8900 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, false);
8905 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8906 struct ecommunity
**list
, bool is_rt6
)
8908 struct ecommunity
*ecom
= NULL
;
8909 struct ecommunity
*ecomadd
;
8911 for (; argc
; --argc
, ++argv
) {
8913 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8914 ECOMMUNITY_ROUTE_TARGET
,
8917 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8918 ECOMMUNITY_ROUTE_TARGET
,
8921 vty_out(vty
, "Malformed community-list value\n");
8923 ecommunity_free(&ecom
);
8924 return CMD_WARNING_CONFIG_FAILED
;
8928 ecommunity_merge(ecom
, ecomadd
);
8929 ecommunity_free(&ecomadd
);
8936 ecommunity_free(&*list
);
8944 * v2vimport is true if we are handling a `import vrf ...` command
8946 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8950 switch (vty
->node
) {
8959 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8964 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8965 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8966 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8967 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8969 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8973 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8974 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8975 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8976 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8978 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8985 DEFPY (af_rd_vpn_export
,
8986 af_rd_vpn_export_cmd
,
8987 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8989 "Specify route distinguisher\n"
8990 "Between current address-family and vpn\n"
8991 "For routes leaked from current address-family to vpn\n"
8992 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8995 struct prefix_rd prd
;
9001 if (argv_find(argv
, argc
, "no", &idx
))
9005 ret
= str2prefix_rd(rd_str
, &prd
);
9007 vty_out(vty
, "%% Malformed rd\n");
9008 return CMD_WARNING_CONFIG_FAILED
;
9012 afi
= vpn_policy_getafi(vty
, bgp
, false);
9014 return CMD_WARNING_CONFIG_FAILED
;
9017 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9019 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9020 bgp_get_default(), bgp
);
9023 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
9024 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9025 BGP_VPN_POLICY_TOVPN_RD_SET
);
9027 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9028 BGP_VPN_POLICY_TOVPN_RD_SET
);
9031 /* post-change: re-export vpn routes */
9032 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9033 bgp_get_default(), bgp
);
9038 ALIAS (af_rd_vpn_export
,
9039 af_no_rd_vpn_export_cmd
,
9042 "Specify route distinguisher\n"
9043 "Between current address-family and vpn\n"
9044 "For routes leaked from current address-family to vpn\n")
9046 DEFPY (af_label_vpn_export
,
9047 af_label_vpn_export_cmd
,
9048 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9050 "label value for VRF\n"
9051 "Between current address-family and vpn\n"
9052 "For routes leaked from current address-family to vpn\n"
9053 "Label Value <0-1048575>\n"
9054 "Automatically assign a label\n")
9056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9057 mpls_label_t label
= MPLS_LABEL_NONE
;
9062 if (argv_find(argv
, argc
, "no", &idx
))
9065 /* If "no ...", squash trailing parameter */
9071 label
= label_val
; /* parser should force unsigned */
9074 afi
= vpn_policy_getafi(vty
, bgp
, false);
9076 return CMD_WARNING_CONFIG_FAILED
;
9079 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9080 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9085 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9087 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9088 bgp_get_default(), bgp
);
9090 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9091 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9093 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9096 * label has previously been automatically
9097 * assigned by labelpool: release it
9099 * NB if tovpn_label == MPLS_LABEL_NONE it
9100 * means the automatic assignment is in flight
9101 * and therefore the labelpool callback must
9102 * detect that the auto label is not needed.
9105 bgp_lp_release(LP_TYPE_VRF
,
9106 &bgp
->vpn_policy
[afi
],
9107 bgp
->vpn_policy
[afi
].tovpn_label
);
9109 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9110 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9113 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9115 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9116 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9117 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9118 vpn_leak_label_callback
);
9121 /* post-change: re-export vpn routes */
9122 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9123 bgp_get_default(), bgp
);
9125 hook_call(bgp_snmp_update_last_changed
, bgp
);
9129 DEFPY (af_sid_vpn_export
,
9130 af_sid_vpn_export_cmd
,
9131 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9133 "sid value for VRF\n"
9134 "Between current address-family and vpn\n"
9135 "For routes leaked from current address-family to vpn\n"
9136 "Sid allocation index\n"
9137 "Automatically assign a label\n")
9139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9145 if (argv_find(argv
, argc
, "no", &idx
))
9147 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9148 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9150 afi
= vpn_policy_getafi(vty
, bgp
, false);
9152 return CMD_WARNING_CONFIG_FAILED
;
9156 vty_out(vty
, "It's not implemented\n");
9157 return CMD_WARNING_CONFIG_FAILED
;
9160 if (bgp
->tovpn_sid_index
!= 0 ||
9161 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9163 "per-vrf sid and per-af sid are mutually exclusive\n"
9164 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9165 return CMD_WARNING_CONFIG_FAILED
;
9168 /* skip when it's already configured */
9169 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9170 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9171 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9175 * mode change between sid_idx and sid_auto isn't supported.
9176 * user must negate sid vpn export when they want to change the mode
9178 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9179 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9180 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9181 vty_out(vty
, "it's already configured as %s.\n",
9182 sid_auto
? "auto-mode" : "idx-mode");
9183 return CMD_WARNING_CONFIG_FAILED
;
9187 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9188 bgp_get_default(), bgp
);
9191 /* SID allocation auto-mode */
9193 zlog_debug("%s: auto sid alloc.", __func__
);
9194 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9195 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9197 /* SID allocation index-mode */
9199 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9200 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9204 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9205 bgp_get_default(), bgp
);
9209 DEFPY (bgp_sid_vpn_export
,
9210 bgp_sid_vpn_export_cmd
,
9211 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9213 "sid value for VRF\n"
9214 "Between current vrf and vpn\n"
9215 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9216 "For routes leaked from current vrf to vpn\n"
9217 "Sid allocation index\n"
9218 "Automatically assign a label\n")
9220 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9223 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9224 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9227 /* when per-VRF SID is not set, do nothing */
9228 if (bgp
->tovpn_sid_index
== 0 &&
9229 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9234 bgp
->tovpn_sid_index
= 0;
9235 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9238 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9239 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9240 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9241 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9242 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9243 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9245 "per-vrf sid and per-af sid are mutually exclusive\n"
9246 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9247 return CMD_WARNING_CONFIG_FAILED
;
9250 /* skip when it's already configured */
9251 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9252 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9256 * mode change between sid_idx and sid_auto isn't supported.
9257 * user must negate sid vpn export when they want to change the mode
9259 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9261 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9262 vty_out(vty
, "it's already configured as %s.\n",
9263 sid_auto
? "auto-mode" : "idx-mode");
9264 return CMD_WARNING_CONFIG_FAILED
;
9268 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9270 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9274 /* SID allocation auto-mode */
9276 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9277 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9278 } else if (sid_idx
!= 0) {
9279 /* SID allocation index-mode */
9281 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9283 bgp
->tovpn_sid_index
= sid_idx
;
9287 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9289 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9290 bgp_get_default(), bgp
);
9295 ALIAS (af_label_vpn_export
,
9296 af_no_label_vpn_export_cmd
,
9297 "no label vpn export",
9299 "label value for VRF\n"
9300 "Between current address-family and vpn\n"
9301 "For routes leaked from current address-family to vpn\n")
9303 ALIAS (bgp_sid_vpn_export
,
9304 no_bgp_sid_vpn_export_cmd
,
9305 "no$no sid vpn per-vrf export",
9307 "sid value for VRF\n"
9308 "Between current vrf and vpn\n"
9309 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9310 "For routes leaked from current vrf to vpn\n")
9312 DEFPY (af_nexthop_vpn_export
,
9313 af_nexthop_vpn_export_cmd
,
9314 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9316 "Specify next hop to use for VRF advertised prefixes\n"
9317 "Between current address-family and vpn\n"
9318 "For routes leaked from current address-family to vpn\n"
9322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9328 vty_out(vty
, "%% Nexthop required\n");
9329 return CMD_WARNING_CONFIG_FAILED
;
9331 if (!sockunion2hostprefix(nexthop_su
, &p
))
9332 return CMD_WARNING_CONFIG_FAILED
;
9335 afi
= vpn_policy_getafi(vty
, bgp
, false);
9337 return CMD_WARNING_CONFIG_FAILED
;
9340 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9342 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9343 bgp_get_default(), bgp
);
9346 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9347 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9348 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9350 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9351 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9354 /* post-change: re-export vpn routes */
9355 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9356 bgp_get_default(), bgp
);
9361 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9363 if (!strcmp(dstr
, "import")) {
9364 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9365 } else if (!strcmp(dstr
, "export")) {
9366 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9367 } else if (!strcmp(dstr
, "both")) {
9368 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9369 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9371 vty_out(vty
, "%% direction parse error\n");
9372 return CMD_WARNING_CONFIG_FAILED
;
9377 DEFPY (af_rt_vpn_imexport
,
9378 af_rt_vpn_imexport_cmd
,
9379 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9381 "Specify route target list\n"
9382 "Specify route target list\n"
9383 "Between current address-family and vpn\n"
9384 "For routes leaked from vpn to current address-family: match any\n"
9385 "For routes leaked from current address-family to vpn: set\n"
9386 "both import: match any and export: set\n"
9387 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9389 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9391 struct ecommunity
*ecom
= NULL
;
9392 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9393 enum vpn_policy_direction dir
;
9398 if (argv_find(argv
, argc
, "no", &idx
))
9401 afi
= vpn_policy_getafi(vty
, bgp
, false);
9403 return CMD_WARNING_CONFIG_FAILED
;
9405 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9406 if (ret
!= CMD_SUCCESS
)
9410 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9411 vty_out(vty
, "%% Missing RTLIST\n");
9412 return CMD_WARNING_CONFIG_FAILED
;
9414 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9415 if (ret
!= CMD_SUCCESS
) {
9420 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9424 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9427 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9429 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9430 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9431 ecommunity_dup(ecom
);
9433 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9435 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9436 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9439 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9443 ecommunity_free(&ecom
);
9448 ALIAS (af_rt_vpn_imexport
,
9449 af_no_rt_vpn_imexport_cmd
,
9450 "no <rt|route-target> vpn <import|export|both>$direction_str",
9452 "Specify route target list\n"
9453 "Specify route target list\n"
9454 "Between current address-family and vpn\n"
9455 "For routes leaked from vpn to current address-family\n"
9456 "For routes leaked from current address-family to vpn\n"
9457 "both import and export\n")
9459 DEFPY (af_route_map_vpn_imexport
,
9460 af_route_map_vpn_imexport_cmd
,
9461 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9462 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9464 "Specify route map\n"
9465 "Between current address-family and vpn\n"
9466 "For routes leaked from vpn to current address-family\n"
9467 "For routes leaked from current address-family to vpn\n"
9468 "name of route-map\n")
9470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9472 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9473 enum vpn_policy_direction dir
;
9478 if (argv_find(argv
, argc
, "no", &idx
))
9481 afi
= vpn_policy_getafi(vty
, bgp
, false);
9483 return CMD_WARNING_CONFIG_FAILED
;
9485 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9486 if (ret
!= CMD_SUCCESS
)
9489 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9493 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9496 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9497 XFREE(MTYPE_ROUTE_MAP_NAME
,
9498 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9499 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9500 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9501 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9502 route_map_lookup_warn_noexist(vty
, rmap_str
);
9503 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9506 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9507 XFREE(MTYPE_ROUTE_MAP_NAME
,
9508 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9509 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9510 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9513 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9519 ALIAS (af_route_map_vpn_imexport
,
9520 af_no_route_map_vpn_imexport_cmd
,
9521 "no route-map vpn <import|export>$direction_str",
9523 "Specify route map\n"
9524 "Between current address-family and vpn\n"
9525 "For routes leaked from vpn to current address-family\n"
9526 "For routes leaked from current address-family to vpn\n")
9528 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9529 "import vrf route-map RMAP$rmap_str",
9530 "Import routes from another VRF\n"
9531 "Vrf routes being filtered\n"
9532 "Specify route map\n"
9533 "name of route-map\n")
9535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9536 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9538 struct bgp
*bgp_default
;
9540 afi
= vpn_policy_getafi(vty
, bgp
, true);
9542 return CMD_WARNING_CONFIG_FAILED
;
9544 bgp_default
= bgp_get_default();
9549 /* Auto-create assuming the same AS */
9550 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9551 BGP_INSTANCE_TYPE_DEFAULT
);
9555 "VRF default is not configured as a bgp instance\n");
9560 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9562 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9563 XFREE(MTYPE_ROUTE_MAP_NAME
,
9564 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9565 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9566 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9567 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9568 route_map_lookup_warn_noexist(vty
, rmap_str
);
9569 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9572 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9573 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9575 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9580 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9581 "no import vrf route-map [RMAP$rmap_str]",
9583 "Import routes from another VRF\n"
9584 "Vrf routes being filtered\n"
9585 "Specify route map\n"
9586 "name of route-map\n")
9588 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9589 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9592 afi
= vpn_policy_getafi(vty
, bgp
, true);
9594 return CMD_WARNING_CONFIG_FAILED
;
9596 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9598 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9599 XFREE(MTYPE_ROUTE_MAP_NAME
,
9600 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9601 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9602 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9604 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9605 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9606 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9608 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9613 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9614 "[no] import vrf VIEWVRFNAME$import_name",
9616 "Import routes from another VRF\n"
9617 "VRF to import from\n"
9618 "The name of the VRF\n")
9620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9621 struct listnode
*node
;
9622 struct bgp
*vrf_bgp
, *bgp_default
;
9625 bool remove
= false;
9628 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9632 if (import_name
== NULL
) {
9633 vty_out(vty
, "%% Missing import name\n");
9637 if (strcmp(import_name
, "route-map") == 0) {
9638 vty_out(vty
, "%% Must include route-map name\n");
9642 if (argv_find(argv
, argc
, "no", &idx
))
9645 afi
= vpn_policy_getafi(vty
, bgp
, true);
9647 return CMD_WARNING_CONFIG_FAILED
;
9649 safi
= bgp_node_safi(vty
);
9651 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9652 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9653 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9654 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9655 remove
? "unimport" : "import", import_name
);
9659 bgp_default
= bgp_get_default();
9661 /* Auto-create assuming the same AS */
9662 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9663 BGP_INSTANCE_TYPE_DEFAULT
);
9667 "VRF default is not configured as a bgp instance\n");
9672 vrf_bgp
= bgp_lookup_by_name(import_name
);
9674 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9675 vrf_bgp
= bgp_default
;
9677 /* Auto-create assuming the same AS */
9678 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9682 "VRF %s is not configured as a bgp instance\n",
9689 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9691 /* Already importing from "import_vrf"? */
9692 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9694 if (strcmp(vname
, import_name
) == 0)
9698 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9704 /* This command is valid only in a bgp vrf instance or the default instance */
9705 DEFPY (bgp_imexport_vpn
,
9706 bgp_imexport_vpn_cmd
,
9707 "[no] <import|export>$direction_str vpn",
9709 "Import routes to this address-family\n"
9710 "Export routes from this address-family\n"
9711 "to/from default instance VPN RIB\n")
9713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9720 enum vpn_policy_direction dir
;
9722 if (argv_find(argv
, argc
, "no", &idx
))
9725 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9726 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9728 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9729 return CMD_WARNING_CONFIG_FAILED
;
9732 afi
= bgp_node_afi(vty
);
9733 safi
= bgp_node_safi(vty
);
9734 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9735 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9736 return CMD_WARNING_CONFIG_FAILED
;
9739 if (!strcmp(direction_str
, "import")) {
9740 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9741 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9742 } else if (!strcmp(direction_str
, "export")) {
9743 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9744 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9746 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9747 return CMD_WARNING_CONFIG_FAILED
;
9750 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9753 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9754 if (!previous_state
) {
9755 /* trigger export current vrf */
9756 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9759 if (previous_state
) {
9760 /* trigger un-export current vrf */
9761 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9763 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9766 hook_call(bgp_snmp_init_stats
, bgp
);
9771 DEFPY (af_routetarget_import
,
9772 af_routetarget_import_cmd
,
9773 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9775 "Specify route target list\n"
9776 "Specify route target list\n"
9777 "Specify route target list\n"
9778 "Specify route target list\n"
9779 "Flow-spec redirect type route target\n"
9780 "Import routes to this address-family\n"
9781 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9785 struct ecommunity
*ecom
= NULL
;
9787 int idx
= 0, idx_unused
= 0;
9791 if (argv_find(argv
, argc
, "no", &idx
))
9794 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9795 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9798 afi
= vpn_policy_getafi(vty
, bgp
, false);
9800 return CMD_WARNING_CONFIG_FAILED
;
9802 if (rt6
&& afi
!= AFI_IP6
)
9803 return CMD_WARNING_CONFIG_FAILED
;
9806 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9807 vty_out(vty
, "%% Missing RTLIST\n");
9808 return CMD_WARNING_CONFIG_FAILED
;
9810 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9811 if (ret
!= CMD_SUCCESS
)
9816 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9817 ecommunity_free(&bgp
->vpn_policy
[afi
]
9818 .import_redirect_rtlist
);
9819 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9820 ecommunity_dup(ecom
);
9822 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9823 ecommunity_free(&bgp
->vpn_policy
[afi
]
9824 .import_redirect_rtlist
);
9825 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9829 ecommunity_free(&ecom
);
9834 DEFUN_NOSH (address_family_ipv4_safi
,
9835 address_family_ipv4_safi_cmd
,
9836 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9837 "Enter Address Family command mode\n"
9839 BGP_SAFI_WITH_LABEL_HELP_STR
)
9843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9844 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9845 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9846 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9847 && safi
!= SAFI_EVPN
) {
9849 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9850 return CMD_WARNING_CONFIG_FAILED
;
9852 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9854 vty
->node
= BGP_IPV4_NODE
;
9859 DEFUN_NOSH (address_family_ipv6_safi
,
9860 address_family_ipv6_safi_cmd
,
9861 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9862 "Enter Address Family command mode\n"
9864 BGP_SAFI_WITH_LABEL_HELP_STR
)
9867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9868 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9869 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9870 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9871 && safi
!= SAFI_EVPN
) {
9873 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9874 return CMD_WARNING_CONFIG_FAILED
;
9876 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9878 vty
->node
= BGP_IPV6_NODE
;
9883 #ifdef KEEP_OLD_VPN_COMMANDS
9884 DEFUN_NOSH (address_family_vpnv4
,
9885 address_family_vpnv4_cmd
,
9886 "address-family vpnv4 [unicast]",
9887 "Enter Address Family command mode\n"
9889 BGP_AF_MODIFIER_STR
)
9891 vty
->node
= BGP_VPNV4_NODE
;
9895 DEFUN_NOSH (address_family_vpnv6
,
9896 address_family_vpnv6_cmd
,
9897 "address-family vpnv6 [unicast]",
9898 "Enter Address Family command mode\n"
9900 BGP_AF_MODIFIER_STR
)
9902 vty
->node
= BGP_VPNV6_NODE
;
9905 #endif /* KEEP_OLD_VPN_COMMANDS */
9907 DEFUN_NOSH (address_family_evpn
,
9908 address_family_evpn_cmd
,
9909 "address-family l2vpn evpn",
9910 "Enter Address Family command mode\n"
9912 BGP_AF_MODIFIER_STR
)
9914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9915 vty
->node
= BGP_EVPN_NODE
;
9919 DEFUN_NOSH (bgp_segment_routing_srv6
,
9920 bgp_segment_routing_srv6_cmd
,
9921 "segment-routing srv6",
9922 "Segment-Routing configuration\n"
9923 "Segment-Routing SRv6 configuration\n")
9925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9926 bgp
->srv6_enabled
= true;
9927 vty
->node
= BGP_SRV6_NODE
;
9931 DEFUN (no_bgp_segment_routing_srv6
,
9932 no_bgp_segment_routing_srv6_cmd
,
9933 "no segment-routing srv6",
9935 "Segment-Routing configuration\n"
9936 "Segment-Routing SRv6 configuration\n")
9938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9940 if (strlen(bgp
->srv6_locator_name
) > 0)
9941 if (bgp_srv6_locator_unset(bgp
) < 0)
9942 return CMD_WARNING_CONFIG_FAILED
;
9944 bgp
->srv6_enabled
= false;
9948 DEFPY (bgp_srv6_locator
,
9949 bgp_srv6_locator_cmd
,
9950 "locator NAME$name",
9951 "Specify SRv6 locator\n"
9952 "Specify SRv6 locator\n")
9954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9957 if (strlen(bgp
->srv6_locator_name
) > 0
9958 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9959 vty_out(vty
, "srv6 locator is already configured\n");
9960 return CMD_WARNING_CONFIG_FAILED
;
9963 snprintf(bgp
->srv6_locator_name
,
9964 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9966 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9968 return CMD_WARNING_CONFIG_FAILED
;
9973 DEFPY (no_bgp_srv6_locator
,
9974 no_bgp_srv6_locator_cmd
,
9975 "no locator NAME$name",
9977 "Specify SRv6 locator\n"
9978 "Specify SRv6 locator\n")
9980 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9982 /* when locator isn't configured, do nothing */
9983 if (strlen(bgp
->srv6_locator_name
) < 1)
9986 /* name validation */
9987 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9988 vty_out(vty
, "%% No srv6 locator is configured\n");
9989 return CMD_WARNING_CONFIG_FAILED
;
9993 if (bgp_srv6_locator_unset(bgp
) < 0)
9994 return CMD_WARNING_CONFIG_FAILED
;
9999 DEFPY (show_bgp_srv6
,
10001 "show bgp segment-routing srv6",
10004 "BGP Segment Routing\n"
10005 "BGP Segment Routing SRv6\n")
10008 struct listnode
*node
;
10009 struct srv6_locator_chunk
*chunk
;
10010 struct bgp_srv6_function
*func
;
10012 bgp
= bgp_get_default();
10014 return CMD_SUCCESS
;
10016 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
10017 vty_out(vty
, "locator_chunks:\n");
10018 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10019 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
10020 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
10021 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
10022 vty_out(vty
, " func-length: %d\n",
10023 chunk
->function_bits_length
);
10024 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
10027 vty_out(vty
, "functions:\n");
10028 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10029 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
10030 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10033 vty_out(vty
, "bgps:\n");
10034 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10035 vty_out(vty
, "- name: %s\n",
10036 bgp
->name
? bgp
->name
: "default");
10038 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
10039 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
10040 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
10041 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
10042 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
10045 return CMD_SUCCESS
;
10048 DEFUN_NOSH (exit_address_family
,
10049 exit_address_family_cmd
,
10050 "exit-address-family",
10051 "Exit from Address Family configuration mode\n")
10053 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10054 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10055 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10056 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10057 || vty
->node
== BGP_EVPN_NODE
10058 || vty
->node
== BGP_FLOWSPECV4_NODE
10059 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10060 vty
->node
= BGP_NODE
;
10061 return CMD_SUCCESS
;
10064 /* Recalculate bestpath and re-advertise a prefix */
10065 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10066 const char *ip_str
, afi_t afi
, safi_t safi
,
10067 struct prefix_rd
*prd
)
10070 struct prefix match
;
10071 struct bgp_dest
*dest
;
10072 struct bgp_dest
*rm
;
10074 struct bgp_table
*table
;
10075 struct bgp_table
*rib
;
10077 /* BGP structure lookup. */
10079 bgp
= bgp_lookup_by_name(view_name
);
10081 vty_out(vty
, "%% Can't find BGP instance %s\n",
10083 return CMD_WARNING
;
10086 bgp
= bgp_get_default();
10088 vty_out(vty
, "%% No BGP process is configured\n");
10089 return CMD_WARNING
;
10093 /* Check IP address argument. */
10094 ret
= str2prefix(ip_str
, &match
);
10096 vty_out(vty
, "%% address is malformed\n");
10097 return CMD_WARNING
;
10100 match
.family
= afi2family(afi
);
10101 rib
= bgp
->rib
[afi
][safi
];
10103 if (safi
== SAFI_MPLS_VPN
) {
10104 for (dest
= bgp_table_top(rib
); dest
;
10105 dest
= bgp_route_next(dest
)) {
10106 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10108 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10111 table
= bgp_dest_get_bgp_table_info(dest
);
10115 rm
= bgp_node_match(table
, &match
);
10117 const struct prefix
*rm_p
=
10118 bgp_dest_get_prefix(rm
);
10120 if (rm_p
->prefixlen
== match
.prefixlen
) {
10121 SET_FLAG(rm
->flags
,
10122 BGP_NODE_USER_CLEAR
);
10123 bgp_process(bgp
, rm
, afi
, safi
);
10125 bgp_dest_unlock_node(rm
);
10129 dest
= bgp_node_match(rib
, &match
);
10130 if (dest
!= NULL
) {
10131 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10133 if (dest_p
->prefixlen
== match
.prefixlen
) {
10134 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10135 bgp_process(bgp
, dest
, afi
, safi
);
10137 bgp_dest_unlock_node(dest
);
10141 return CMD_SUCCESS
;
10144 /* one clear bgp command to rule them all */
10145 DEFUN (clear_ip_bgp_all
,
10146 clear_ip_bgp_all_cmd
,
10147 "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>]",
10151 BGP_INSTANCE_HELP_STR
10154 BGP_SAFI_WITH_LABEL_HELP_STR
10155 BGP_AF_MODIFIER_STR
10156 "Clear all peers\n"
10157 "BGP IPv4 neighbor to clear\n"
10158 "BGP IPv6 neighbor to clear\n"
10159 "BGP neighbor on interface to clear\n"
10160 "Clear peers with the AS number\n"
10161 "Clear all external peers\n"
10162 "Clear all members of peer-group\n"
10163 "BGP peer-group name\n"
10168 "Push out prefix-list ORF and do inbound soft reconfig\n"
10170 "Reset message statistics\n")
10174 afi_t afi
= AFI_UNSPEC
;
10175 safi_t safi
= SAFI_UNSPEC
;
10176 enum clear_sort clr_sort
= clear_peer
;
10177 enum bgp_clear_type clr_type
;
10178 char *clr_arg
= NULL
;
10182 /* clear [ip] bgp */
10183 if (argv_find(argv
, argc
, "ip", &idx
))
10186 /* [<vrf> VIEWVRFNAME] */
10187 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10188 vrf
= argv
[idx
+ 1]->arg
;
10190 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10192 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10193 /* [<view> VIEWVRFNAME] */
10194 vrf
= argv
[idx
+ 1]->arg
;
10197 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10198 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10199 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10201 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10202 if (argv_find(argv
, argc
, "*", &idx
)) {
10203 clr_sort
= clear_all
;
10204 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10205 clr_sort
= clear_peer
;
10206 clr_arg
= argv
[idx
]->arg
;
10207 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10208 clr_sort
= clear_peer
;
10209 clr_arg
= argv
[idx
]->arg
;
10210 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10211 clr_sort
= clear_group
;
10213 clr_arg
= argv
[idx
]->arg
;
10214 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10215 clr_sort
= clear_peer
;
10216 clr_arg
= argv
[idx
]->arg
;
10217 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10218 clr_sort
= clear_peer
;
10219 clr_arg
= argv
[idx
]->arg
;
10220 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10221 clr_sort
= clear_as
;
10222 clr_arg
= argv
[idx
]->arg
;
10223 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10224 clr_sort
= clear_external
;
10227 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10228 if (argv_find(argv
, argc
, "soft", &idx
)) {
10229 if (argv_find(argv
, argc
, "in", &idx
)
10230 || argv_find(argv
, argc
, "out", &idx
))
10231 clr_type
= strmatch(argv
[idx
]->text
, "in")
10232 ? BGP_CLEAR_SOFT_IN
10233 : BGP_CLEAR_SOFT_OUT
;
10235 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10236 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10237 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10238 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10239 : BGP_CLEAR_SOFT_IN
;
10240 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10241 clr_type
= BGP_CLEAR_SOFT_OUT
;
10242 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10243 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10245 clr_type
= BGP_CLEAR_SOFT_NONE
;
10247 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10250 DEFUN (clear_ip_bgp_prefix
,
10251 clear_ip_bgp_prefix_cmd
,
10252 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10256 BGP_INSTANCE_HELP_STR
10257 "Clear bestpath and re-advertise\n"
10261 char *prefix
= NULL
;
10265 /* [<view|vrf> VIEWVRFNAME] */
10266 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10267 vrf
= argv
[idx
+ 1]->arg
;
10269 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10271 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10272 /* [<view> VIEWVRFNAME] */
10273 vrf
= argv
[idx
+ 1]->arg
;
10277 prefix
= argv
[argc
- 1]->arg
;
10279 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10282 DEFUN (clear_bgp_ipv6_safi_prefix
,
10283 clear_bgp_ipv6_safi_prefix_cmd
,
10284 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10290 "Clear bestpath and re-advertise\n"
10294 int idx_ipv6_prefix
= 0;
10295 safi_t safi
= SAFI_UNICAST
;
10296 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10297 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10299 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10300 return bgp_clear_prefix(
10301 vty
, NULL
, prefix
, AFI_IP6
,
10305 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10306 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10307 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10311 BGP_INSTANCE_HELP_STR
10314 "Clear bestpath and re-advertise\n"
10318 int idx_vrfview
= 0;
10319 int idx_ipv6_prefix
= 0;
10320 safi_t safi
= SAFI_UNICAST
;
10321 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10322 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10323 char *vrfview
= NULL
;
10325 /* [<view|vrf> VIEWVRFNAME] */
10326 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10327 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10328 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10330 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10331 /* [<view> VIEWVRFNAME] */
10332 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10334 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10336 return bgp_clear_prefix(
10337 vty
, vrfview
, prefix
,
10338 AFI_IP6
, safi
, NULL
);
10341 DEFUN (show_bgp_views
,
10342 show_bgp_views_cmd
,
10343 "show [ip] bgp views",
10347 "Show the defined BGP views\n")
10349 struct list
*inst
= bm
->bgp
;
10350 struct listnode
*node
;
10353 vty_out(vty
, "Defined BGP views:\n");
10354 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10356 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10358 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10362 return CMD_SUCCESS
;
10365 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10369 struct listnode
*node
;
10371 *peers_cfgd
= *peers_estbd
= 0;
10372 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10373 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10376 if (peer_established(peer
))
10381 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10384 int peers_cfg
, peers_estb
;
10386 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10389 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10391 : (int64_t)bgp
->vrf_id
;
10392 json_object_string_add(json
, "type", type
);
10393 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10394 json_object_string_addf(json
, "routerId", "%pI4",
10396 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10397 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10398 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10399 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10400 json_object_string_add(
10402 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10406 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10407 json_object
*json
, const char *name
,
10408 const char *type
, bool use_vrf
)
10410 int peers_cfg
, peers_estb
;
10412 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10416 print_bgp_vrfs(bgp
, vty
, json
, type
);
10418 vty_out(vty
, "BGP instance %s VRF id %d\n",
10420 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10421 : (int)bgp
->vrf_id
);
10422 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10424 "Num Configured Peers %d, Established %d\n",
10425 peers_cfg
, peers_estb
);
10428 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10430 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10437 print_bgp_vrfs(bgp
, vty
, json
, type
);
10439 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10441 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10442 : (int)bgp
->vrf_id
,
10443 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10444 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10445 bgp
->l3vni
, &bgp
->rmac
,
10446 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10451 return CMD_SUCCESS
;
10454 DEFPY (show_bgp_vrfs
,
10456 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10461 "Specific VRF name\n"
10464 struct list
*inst
= bm
->bgp
;
10465 struct listnode
*node
;
10467 bool uj
= use_json(argc
, argv
);
10468 json_object
*json
= NULL
;
10469 json_object
*json_vrfs
= NULL
;
10470 json_object
*json_vrf
= NULL
;
10472 const char *name
= vrf_name
;
10476 json
= json_object_new_object();
10479 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10480 bgp
= bgp_get_default();
10483 bgp
= bgp_lookup_by_name(name
);
10488 vty_json(vty
, json
);
10491 "%% Specified BGP instance not found\n");
10493 return CMD_WARNING
;
10499 json_vrf
= json_object_new_object();
10501 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10505 json_object_object_add(json
, name
, json_vrf
);
10506 vty_json(vty
, json
);
10509 return CMD_SUCCESS
;
10513 json_vrfs
= json_object_new_object();
10515 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10519 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10523 if (!uj
&& count
== 1) {
10525 "%4s %-5s %-16s %9s %10s %-37s\n",
10526 "Type", "Id", "routerId", "#PeersCfg",
10527 "#PeersEstb", "Name");
10528 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10529 "L3-VNI", "RouterMAC", "Interface");
10532 json_vrf
= json_object_new_object();
10534 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10535 name
= VRF_DEFAULT_NAME
;
10542 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10546 json_object_object_add(json_vrfs
, name
, json_vrf
);
10550 json_object_object_add(json
, "vrfs", json_vrfs
);
10551 json_object_int_add(json
, "totalVrfs", count
);
10552 vty_json(vty
, json
);
10556 "\nTotal number of VRFs (including default): %d\n",
10560 return CMD_SUCCESS
;
10563 DEFUN (show_bgp_mac_hash
,
10564 show_bgp_mac_hash_cmd
,
10565 "show bgp mac hash",
10569 "Mac Address database\n")
10571 bgp_mac_dump_table(vty
);
10573 return CMD_SUCCESS
;
10576 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10578 struct vty
*vty
= (struct vty
*)args
;
10579 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10581 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10584 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10586 vty_out(vty
, "self nexthop database:\n");
10587 bgp_nexthop_show_address_hash(vty
, bgp
);
10589 vty_out(vty
, "Tunnel-ip database:\n");
10590 hash_iterate(bgp
->tip_hash
,
10591 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10595 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10596 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10597 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10598 "martian next-hops\n"
10599 "martian next-hop database\n")
10601 struct bgp
*bgp
= NULL
;
10605 /* [<vrf> VIEWVRFNAME] */
10606 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10607 name
= argv
[idx
+ 1]->arg
;
10608 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10610 } else if (argv_find(argv
, argc
, "view", &idx
))
10611 /* [<view> VIEWVRFNAME] */
10612 name
= argv
[idx
+ 1]->arg
;
10614 bgp
= bgp_lookup_by_name(name
);
10616 bgp
= bgp_get_default();
10619 vty_out(vty
, "%% No BGP process is configured\n");
10620 return CMD_WARNING
;
10622 bgp_show_martian_nexthops(vty
, bgp
);
10624 return CMD_SUCCESS
;
10627 DEFUN (show_bgp_memory
,
10628 show_bgp_memory_cmd
,
10629 "show [ip] bgp memory",
10633 "Global BGP memory statistics\n")
10635 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10636 unsigned long count
;
10638 /* RIB related usage stats */
10639 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10640 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10641 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10642 count
* sizeof(struct bgp_dest
)));
10644 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10645 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10646 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10647 count
* sizeof(struct bgp_path_info
)));
10648 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10649 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10652 memstrbuf
, sizeof(memstrbuf
),
10653 count
* sizeof(struct bgp_path_info_extra
)));
10655 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10656 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10657 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10658 count
* sizeof(struct bgp_static
)));
10660 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10661 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10662 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10663 count
* sizeof(struct bpacket
)));
10666 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10667 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10668 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10669 count
* sizeof(struct bgp_adj_in
)));
10670 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10671 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10672 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10673 count
* sizeof(struct bgp_adj_out
)));
10675 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10676 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10678 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10679 count
* sizeof(struct bgp_nexthop_cache
)));
10681 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10682 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10684 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10685 count
* sizeof(struct bgp_damp_info
)));
10688 count
= attr_count();
10689 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10690 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10691 count
* sizeof(struct attr
)));
10693 if ((count
= attr_unknown_count()))
10694 vty_out(vty
, "%ld unknown attributes\n", count
);
10696 /* AS_PATH attributes */
10697 count
= aspath_count();
10698 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10699 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10700 count
* sizeof(struct aspath
)));
10702 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10703 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10704 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10705 count
* sizeof(struct assegment
)));
10707 /* Other attributes */
10708 if ((count
= community_count()))
10709 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10710 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10711 count
* sizeof(struct community
)));
10712 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10714 "%ld BGP ext-community entries, using %s of memory\n",
10716 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10717 count
* sizeof(struct ecommunity
)));
10718 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10720 "%ld BGP large-community entries, using %s of memory\n",
10721 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10722 count
* sizeof(struct lcommunity
)));
10724 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10725 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10726 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10727 count
* sizeof(struct cluster_list
)));
10729 /* Peer related usage */
10730 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10731 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10732 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10733 count
* sizeof(struct peer
)));
10735 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10736 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10737 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10738 count
* sizeof(struct peer_group
)));
10741 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10742 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10743 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10744 count
* sizeof(regex_t
)));
10745 return CMD_SUCCESS
;
10748 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10750 json_object
*bestpath
= json_object_new_object();
10752 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10753 json_object_string_add(bestpath
, "asPath", "ignore");
10755 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10756 json_object_string_add(bestpath
, "asPath", "confed");
10758 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10759 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10760 json_object_string_add(bestpath
, "multiPathRelax",
10763 json_object_string_add(bestpath
, "multiPathRelax",
10766 json_object_string_add(bestpath
, "multiPathRelax", "false");
10768 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10769 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10771 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10772 json_object_string_add(bestpath
, "compareRouterId", "true");
10773 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10774 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10775 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10776 json_object_string_add(bestpath
, "med", "confed");
10777 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10778 json_object_string_add(bestpath
, "med",
10779 "missing-as-worst");
10781 json_object_string_add(bestpath
, "med", "true");
10784 json_object_object_add(json
, "bestPath", bestpath
);
10787 /* Print the error code/subcode for why the peer is down */
10788 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10789 json_object
*json_peer
, bool use_json
)
10791 const char *code_str
;
10792 const char *subcode_str
;
10795 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10796 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10797 char errorcodesubcode_hexstr
[5];
10798 char errorcodesubcode_str
[256];
10800 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10801 subcode_str
= bgp_notify_subcode_str(
10803 peer
->notify
.subcode
);
10805 snprintf(errorcodesubcode_hexstr
,
10806 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10807 peer
->notify
.code
, peer
->notify
.subcode
);
10808 json_object_string_add(json_peer
,
10809 "lastErrorCodeSubcode",
10810 errorcodesubcode_hexstr
);
10811 snprintf(errorcodesubcode_str
, 255, "%s%s",
10812 code_str
, subcode_str
);
10813 json_object_string_add(json_peer
,
10814 "lastNotificationReason",
10815 errorcodesubcode_str
);
10816 json_object_boolean_add(json_peer
,
10817 "lastNotificationHardReset",
10818 peer
->notify
.hard_reset
);
10819 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10820 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10821 && (peer
->notify
.subcode
10822 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10823 || peer
->notify
.subcode
10824 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10825 && peer
->notify
.length
) {
10827 const char *msg_str
;
10829 msg_str
= bgp_notify_admin_message(
10830 msgbuf
, sizeof(msgbuf
),
10831 (uint8_t *)peer
->notify
.data
,
10832 peer
->notify
.length
);
10834 json_object_string_add(
10836 "lastShutdownDescription",
10841 json_object_string_add(json_peer
, "lastResetDueTo",
10842 peer_down_str
[(int)peer
->last_reset
]);
10843 json_object_int_add(json_peer
, "lastResetCode",
10845 json_object_string_add(json_peer
, "softwareVersion",
10846 peer
->soft_version
? peer
->soft_version
10849 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10850 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10851 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10853 bgp_notify_subcode_str(peer
->notify
.code
,
10854 peer
->notify
.subcode
);
10855 vty_out(vty
, " Notification %s (%s%s%s)\n",
10856 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10859 code_str
, subcode_str
,
10860 peer
->notify
.hard_reset
10861 ? bgp_notify_subcode_str(
10863 BGP_NOTIFY_CEASE_HARD_RESET
)
10866 vty_out(vty
, " %s (%s)\n",
10867 peer_down_str
[(int)peer
->last_reset
],
10868 peer
->soft_version
? peer
->soft_version
10874 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10877 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10880 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10881 struct peer
*peer
, json_object
*json_peer
,
10882 int max_neighbor_width
, bool use_json
)
10884 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10888 if (peer_dynamic_neighbor(peer
))
10889 json_object_boolean_true_add(json_peer
,
10891 if (peer
->hostname
)
10892 json_object_string_add(json_peer
, "hostname",
10895 if (peer
->domainname
)
10896 json_object_string_add(json_peer
, "domainname",
10898 json_object_int_add(json_peer
, "connectionsEstablished",
10899 peer
->established
);
10900 json_object_int_add(json_peer
, "connectionsDropped",
10902 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10903 use_json
, json_peer
);
10904 if (peer_established(peer
))
10905 json_object_string_add(json_peer
, "lastResetDueTo",
10906 "AFI/SAFI Not Negotiated");
10908 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10911 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10913 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10914 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10915 peer
->hostname
, peer
->host
);
10917 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10919 /* pad the neighbor column with spaces */
10920 if (len
< max_neighbor_width
)
10921 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10923 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10925 peer_uptime(peer
->uptime
, timebuf
,
10926 BGP_UPTIME_LEN
, 0, NULL
));
10927 if (peer_established(peer
))
10928 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10930 bgp_show_peer_reset(vty
, peer
, NULL
,
10935 /* Strip peer's description to the given size. */
10936 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10938 static char stripped
[BUFSIZ
];
10940 uint32_t last_space
= 0;
10943 if (*(desc
+ i
) == 0) {
10944 stripped
[i
] = '\0';
10947 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10949 stripped
[i
] = *(desc
+ i
);
10953 if (last_space
> size
)
10954 stripped
[size
+ 1] = '\0';
10956 stripped
[last_space
] = '\0';
10961 /* Determine whether var peer should be filtered out of the summary. */
10962 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10963 struct peer
*fpeer
, int as_type
,
10967 /* filter neighbor XXXX */
10968 if (fpeer
&& fpeer
!= peer
)
10971 /* filter remote-as (internal|external) */
10972 if (as_type
!= AS_UNSPECIFIED
) {
10973 if (peer
->as_type
== AS_SPECIFIED
) {
10974 if (as_type
== AS_INTERNAL
) {
10975 if (peer
->as
!= peer
->local_as
)
10977 } else if (peer
->as
== peer
->local_as
)
10979 } else if (as_type
!= peer
->as_type
)
10981 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10987 /* Show BGP peer's summary information.
10989 * Peer's description is stripped according to if `wide` option is given
10992 * When adding new columns to `show bgp summary` output, please make
10993 * sure `Desc` is the lastest column to show because it can contain
10994 * whitespaces and the whole output will be tricky.
10996 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10997 struct peer
*fpeer
, int as_type
, as_t as
,
10998 uint16_t show_flags
)
11001 struct listnode
*node
, *nnode
;
11002 unsigned int count
= 0, dn_count
= 0;
11003 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
11004 char neighbor_buf
[VTY_BUFSIZ
];
11005 int neighbor_col_default_width
= 16;
11006 int len
, failed_count
= 0;
11007 unsigned int filtered_count
= 0;
11008 int max_neighbor_width
= 0;
11010 json_object
*json
= NULL
;
11011 json_object
*json_peer
= NULL
;
11012 json_object
*json_peers
= NULL
;
11013 struct peer_af
*paf
;
11014 struct bgp_filter
*filter
;
11015 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11016 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11017 bool show_established
=
11018 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11019 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11020 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11022 /* labeled-unicast routes are installed in the unicast table so in order
11024 * display the correct PfxRcd value we must look at SAFI_UNICAST
11027 if (safi
== SAFI_LABELED_UNICAST
)
11028 pfx_rcd_safi
= SAFI_UNICAST
;
11030 pfx_rcd_safi
= safi
;
11033 json
= json_object_new_object();
11034 json_peers
= json_object_new_object();
11035 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11036 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11043 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11046 if (peer
->afc
[afi
][safi
]) {
11047 /* See if we have at least a single failed peer */
11048 if (bgp_has_peer_failed(peer
, afi
, safi
))
11052 if (peer_dynamic_neighbor(peer
))
11057 /* Loop over all neighbors that will be displayed to determine
11059 * characters are needed for the Neighbor column
11061 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11062 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11069 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11072 if (peer
->afc
[afi
][safi
]) {
11073 memset(dn_flag
, '\0', sizeof(dn_flag
));
11074 if (peer_dynamic_neighbor(peer
))
11078 && CHECK_FLAG(bgp
->flags
,
11079 BGP_FLAG_SHOW_HOSTNAME
))
11080 snprintf(neighbor_buf
,
11081 sizeof(neighbor_buf
),
11082 "%s%s(%s) ", dn_flag
,
11083 peer
->hostname
, peer
->host
);
11085 snprintf(neighbor_buf
,
11086 sizeof(neighbor_buf
), "%s%s ",
11087 dn_flag
, peer
->host
);
11089 len
= strlen(neighbor_buf
);
11091 if (len
> max_neighbor_width
)
11092 max_neighbor_width
= len
;
11094 /* See if we have at least a single failed peer */
11095 if (bgp_has_peer_failed(peer
, afi
, safi
))
11101 /* Originally we displayed the Neighbor column as 16
11102 * characters wide so make that the default
11104 if (max_neighbor_width
< neighbor_col_default_width
)
11105 max_neighbor_width
= neighbor_col_default_width
;
11108 if (show_failed
&& !failed_count
) {
11110 json_object_int_add(json
, "failedPeersCount", 0);
11111 json_object_int_add(json
, "dynamicPeers", dn_count
);
11112 json_object_int_add(json
, "totalPeers", count
);
11114 vty_json(vty
, json
);
11116 vty_out(vty
, "%% No failed BGP neighbors found\n");
11118 return CMD_SUCCESS
;
11121 count
= 0; /* Reset the value as its used again */
11122 filtered_count
= 0;
11124 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11125 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11128 if (!peer
->afc
[afi
][safi
])
11132 unsigned long ents
;
11133 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11136 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11138 : (int64_t)bgp
->vrf_id
;
11140 /* Usage summary and header */
11142 json_object_string_addf(json
, "routerId",
11145 json_object_int_add(json
, "as", bgp
->as
);
11146 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11147 json_object_string_add(
11150 == BGP_INSTANCE_TYPE_DEFAULT
)
11155 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11156 &bgp
->router_id
, bgp
->as
,
11157 bgp
->vrf_id
== VRF_UNKNOWN
11159 : (int)bgp
->vrf_id
);
11160 vty_out(vty
, "\n");
11163 if (bgp_update_delay_configured(bgp
)) {
11165 json_object_int_add(
11166 json
, "updateDelayLimit",
11167 bgp
->v_update_delay
);
11169 if (bgp
->v_update_delay
11170 != bgp
->v_establish_wait
)
11171 json_object_int_add(
11173 "updateDelayEstablishWait",
11174 bgp
->v_establish_wait
);
11176 if (bgp_update_delay_active(bgp
)) {
11177 json_object_string_add(
11179 "updateDelayFirstNeighbor",
11180 bgp
->update_delay_begin_time
);
11181 json_object_boolean_true_add(
11183 "updateDelayInProgress");
11185 if (bgp
->update_delay_over
) {
11186 json_object_string_add(
11188 "updateDelayFirstNeighbor",
11189 bgp
->update_delay_begin_time
);
11190 json_object_string_add(
11192 "updateDelayBestpathResumed",
11193 bgp
->update_delay_end_time
);
11194 json_object_string_add(
11196 "updateDelayZebraUpdateResume",
11197 bgp
->update_delay_zebra_resume_time
);
11198 json_object_string_add(
11200 "updateDelayPeerUpdateResume",
11201 bgp
->update_delay_peers_resume_time
);
11206 "Read-only mode update-delay limit: %d seconds\n",
11207 bgp
->v_update_delay
);
11208 if (bgp
->v_update_delay
11209 != bgp
->v_establish_wait
)
11211 " Establish wait: %d seconds\n",
11212 bgp
->v_establish_wait
);
11214 if (bgp_update_delay_active(bgp
)) {
11216 " First neighbor established: %s\n",
11217 bgp
->update_delay_begin_time
);
11219 " Delay in progress\n");
11221 if (bgp
->update_delay_over
) {
11223 " First neighbor established: %s\n",
11224 bgp
->update_delay_begin_time
);
11226 " Best-paths resumed: %s\n",
11227 bgp
->update_delay_end_time
);
11229 " zebra update resumed: %s\n",
11230 bgp
->update_delay_zebra_resume_time
);
11232 " peers update resumed: %s\n",
11233 bgp
->update_delay_peers_resume_time
);
11240 if (bgp_maxmed_onstartup_configured(bgp
)
11241 && bgp
->maxmed_active
)
11242 json_object_boolean_true_add(
11243 json
, "maxMedOnStartup");
11244 if (bgp
->v_maxmed_admin
)
11245 json_object_boolean_true_add(
11246 json
, "maxMedAdministrative");
11248 json_object_int_add(
11249 json
, "tableVersion",
11250 bgp_table_version(bgp
->rib
[afi
][safi
]));
11252 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11253 json_object_int_add(json
, "ribCount", ents
);
11254 json_object_int_add(
11256 ents
* sizeof(struct bgp_dest
));
11258 ents
= bgp
->af_peer_count
[afi
][safi
];
11259 json_object_int_add(json
, "peerCount", ents
);
11260 json_object_int_add(json
, "peerMemory",
11261 ents
* sizeof(struct peer
));
11263 if ((ents
= listcount(bgp
->group
))) {
11264 json_object_int_add(
11265 json
, "peerGroupCount", ents
);
11266 json_object_int_add(
11267 json
, "peerGroupMemory",
11268 ents
* sizeof(struct
11272 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11273 BGP_CONFIG_DAMPENING
))
11274 json_object_boolean_true_add(
11275 json
, "dampeningEnabled");
11278 if (bgp_maxmed_onstartup_configured(bgp
)
11279 && bgp
->maxmed_active
)
11281 "Max-med on-startup active\n");
11282 if (bgp
->v_maxmed_admin
)
11284 "Max-med administrative active\n");
11287 "BGP table version %" PRIu64
11290 bgp
->rib
[afi
][safi
]));
11292 ents
= bgp_table_count(
11293 bgp
->rib
[afi
][safi
]);
11295 "RIB entries %ld, using %s of memory\n",
11305 /* Peer related usage */
11306 ents
= bgp
->af_peer_count
[afi
][safi
];
11308 "Peers %ld, using %s of memory\n",
11318 if ((ents
= listcount(bgp
->group
)))
11320 "Peer groups %ld, using %s of memory\n",
11330 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11331 BGP_CONFIG_DAMPENING
))
11333 "Dampening enabled.\n");
11336 vty_out(vty
, "\n");
11338 /* Subtract 8 here because 'Neighbor' is
11340 vty_out(vty
, "Neighbor");
11341 vty_out(vty
, "%*s",
11342 max_neighbor_width
- 8, " ");
11344 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11349 paf
= peer_af_find(peer
, afi
, safi
);
11350 filter
= &peer
->filter
[afi
][safi
];
11353 /* Works for both failed & successful cases */
11354 if (peer_dynamic_neighbor(peer
))
11359 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11365 bgp_has_peer_failed(peer
, afi
, safi
)) {
11366 json_peer
= json_object_new_object();
11367 bgp_show_failed_summary(vty
, bgp
, peer
,
11368 json_peer
, 0, use_json
);
11369 } else if (!show_failed
) {
11370 if (show_established
11371 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11376 json_peer
= json_object_new_object();
11377 if (peer_dynamic_neighbor(peer
)) {
11378 json_object_boolean_true_add(json_peer
,
11382 if (peer
->hostname
)
11383 json_object_string_add(json_peer
, "hostname",
11386 if (peer
->domainname
)
11387 json_object_string_add(json_peer
, "domainname",
11390 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11391 json_object_int_add(
11392 json_peer
, "localAs",
11393 peer
->change_local_as
11394 ? peer
->change_local_as
11396 json_object_int_add(json_peer
, "version", 4);
11397 json_object_int_add(json_peer
, "msgRcvd",
11398 PEER_TOTAL_RX(peer
));
11399 json_object_int_add(json_peer
, "msgSent",
11400 PEER_TOTAL_TX(peer
));
11402 atomic_size_t outq_count
, inq_count
;
11403 outq_count
= atomic_load_explicit(
11404 &peer
->obuf
->count
,
11405 memory_order_relaxed
);
11406 inq_count
= atomic_load_explicit(
11407 &peer
->ibuf
->count
,
11408 memory_order_relaxed
);
11410 json_object_int_add(json_peer
, "tableVersion",
11411 peer
->version
[afi
][safi
]);
11412 json_object_int_add(json_peer
, "outq",
11414 json_object_int_add(json_peer
, "inq",
11416 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11417 use_json
, json_peer
);
11419 json_object_int_add(json_peer
, "pfxRcd",
11420 peer
->pcount
[afi
][pfx_rcd_safi
]);
11422 if (paf
&& PAF_SUBGRP(paf
))
11423 json_object_int_add(
11424 json_peer
, "pfxSnt",
11425 (PAF_SUBGRP(paf
))->scount
);
11427 json_object_int_add(json_peer
, "pfxSnt",
11430 /* BGP FSM state */
11431 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11432 || CHECK_FLAG(peer
->bgp
->flags
,
11433 BGP_FLAG_SHUTDOWN
))
11434 json_object_string_add(json_peer
,
11437 else if (peer
->afc_recv
[afi
][safi
])
11438 json_object_string_add(
11439 json_peer
, "state",
11440 lookup_msg(bgp_status_msg
,
11441 peer
->status
, NULL
));
11442 else if (CHECK_FLAG(
11444 PEER_STATUS_PREFIX_OVERFLOW
))
11445 json_object_string_add(json_peer
,
11449 json_object_string_add(
11450 json_peer
, "state",
11451 lookup_msg(bgp_status_msg
,
11452 peer
->status
, NULL
));
11454 /* BGP peer state */
11455 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11456 || CHECK_FLAG(peer
->bgp
->flags
,
11457 BGP_FLAG_SHUTDOWN
))
11458 json_object_string_add(json_peer
,
11461 else if (CHECK_FLAG(
11463 PEER_STATUS_PREFIX_OVERFLOW
))
11464 json_object_string_add(json_peer
,
11467 else if (CHECK_FLAG(peer
->flags
,
11468 PEER_FLAG_PASSIVE
))
11469 json_object_string_add(json_peer
,
11472 else if (CHECK_FLAG(peer
->sflags
,
11473 PEER_STATUS_NSF_WAIT
))
11474 json_object_string_add(json_peer
,
11477 else if (CHECK_FLAG(
11479 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11480 && (!bgp_inbound_policy_exists(peer
,
11482 || !bgp_outbound_policy_exists(
11484 json_object_string_add(json_peer
,
11488 json_object_string_add(
11489 json_peer
, "peerState", "OK");
11491 json_object_int_add(json_peer
, "connectionsEstablished",
11492 peer
->established
);
11493 json_object_int_add(json_peer
, "connectionsDropped",
11496 json_object_string_add(
11497 json_peer
, "desc", peer
->desc
);
11499 /* Avoid creating empty peer dicts in JSON */
11500 if (json_peer
== NULL
)
11504 json_object_string_add(json_peer
, "idType",
11506 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11507 json_object_string_add(json_peer
, "idType",
11509 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11510 json_object_string_add(json_peer
, "idType",
11512 json_object_object_add(json_peers
, peer
->host
,
11515 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11521 bgp_has_peer_failed(peer
, afi
, safi
)) {
11522 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11523 max_neighbor_width
,
11525 } else if (!show_failed
) {
11526 if (show_established
11527 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11532 if ((count
- filtered_count
) == 1) {
11533 /* display headline before the first
11535 vty_out(vty
, "\n");
11537 /* Subtract 8 here because 'Neighbor' is
11539 vty_out(vty
, "Neighbor");
11540 vty_out(vty
, "%*s",
11541 max_neighbor_width
- 8, " ");
11544 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11545 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11548 memset(dn_flag
, '\0', sizeof(dn_flag
));
11549 if (peer_dynamic_neighbor(peer
)) {
11554 && CHECK_FLAG(bgp
->flags
,
11555 BGP_FLAG_SHOW_HOSTNAME
))
11556 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11560 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11562 /* pad the neighbor column with spaces */
11563 if (len
< max_neighbor_width
)
11564 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11567 atomic_size_t outq_count
, inq_count
;
11568 outq_count
= atomic_load_explicit(
11569 &peer
->obuf
->count
,
11570 memory_order_relaxed
);
11571 inq_count
= atomic_load_explicit(
11572 &peer
->ibuf
->count
,
11573 memory_order_relaxed
);
11577 "4 %10u %10u %9u %9u %8" PRIu64
11580 peer
->change_local_as
11581 ? peer
->change_local_as
11583 PEER_TOTAL_RX(peer
),
11584 PEER_TOTAL_TX(peer
),
11585 peer
->version
[afi
][safi
],
11586 inq_count
, outq_count
,
11587 peer_uptime(peer
->uptime
,
11592 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11594 peer
->as
, PEER_TOTAL_RX(peer
),
11595 PEER_TOTAL_TX(peer
),
11596 peer
->version
[afi
][safi
],
11597 inq_count
, outq_count
,
11598 peer_uptime(peer
->uptime
,
11603 if (peer_established(peer
)) {
11604 if (peer
->afc_recv
[afi
][safi
]) {
11607 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11608 && !bgp_inbound_policy_exists(
11610 vty_out(vty
, " %12s",
11619 vty_out(vty
, " NoNeg");
11622 if (paf
&& PAF_SUBGRP(paf
)) {
11625 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11626 && !bgp_outbound_policy_exists(
11628 vty_out(vty
, " %8s",
11637 vty_out(vty
, " NoNeg");
11640 if (CHECK_FLAG(peer
->flags
,
11641 PEER_FLAG_SHUTDOWN
)
11642 || CHECK_FLAG(peer
->bgp
->flags
,
11643 BGP_FLAG_SHUTDOWN
))
11644 vty_out(vty
, " Idle (Admin)");
11645 else if (CHECK_FLAG(
11647 PEER_STATUS_PREFIX_OVERFLOW
))
11648 vty_out(vty
, " Idle (PfxCt)");
11650 vty_out(vty
, " %12s",
11651 lookup_msg(bgp_status_msg
,
11652 peer
->status
, NULL
));
11654 vty_out(vty
, " %8u", 0);
11656 /* Make sure `Desc` column is the lastest in
11660 vty_out(vty
, " %s",
11661 bgp_peer_description_stripped(
11663 show_wide
? 64 : 20));
11665 vty_out(vty
, " N/A");
11666 vty_out(vty
, "\n");
11673 json_object_object_add(json
, "peers", json_peers
);
11674 json_object_int_add(json
, "failedPeers", failed_count
);
11675 json_object_int_add(json
, "displayedPeers",
11676 count
- filtered_count
);
11677 json_object_int_add(json
, "totalPeers", count
);
11678 json_object_int_add(json
, "dynamicPeers", dn_count
);
11681 bgp_show_bestpath_json(bgp
, json
);
11683 vty_json(vty
, json
);
11686 if (filtered_count
== count
)
11687 vty_out(vty
, "\n%% No matching neighbor\n");
11690 vty_out(vty
, "\nDisplayed neighbors %d",
11692 else if (as_type
!= AS_UNSPECIFIED
|| as
11693 || fpeer
|| show_established
)
11694 vty_out(vty
, "\nDisplayed neighbors %d",
11695 count
- filtered_count
);
11697 vty_out(vty
, "\nTotal number of neighbors %d\n",
11701 vty_out(vty
, "No %s neighbor is configured\n",
11702 get_afi_safi_str(afi
, safi
, false));
11706 vty_out(vty
, "* - dynamic neighbor\n");
11707 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11708 dn_count
, bgp
->dynamic_neighbors_limit
);
11712 return CMD_SUCCESS
;
11715 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11716 int safi
, struct peer
*fpeer
, int as_type
,
11717 as_t as
, uint16_t show_flags
)
11720 int afi_wildcard
= (afi
== AFI_MAX
);
11721 int safi_wildcard
= (safi
== SAFI_MAX
);
11722 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11723 bool nbr_output
= false;
11724 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11726 if (use_json
&& is_wildcard
)
11727 vty_out(vty
, "{\n");
11729 afi
= 1; /* AFI_IP */
11730 while (afi
< AFI_MAX
) {
11732 safi
= 1; /* SAFI_UNICAST */
11733 while (safi
< SAFI_MAX
) {
11734 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11739 * So limit output to those afi/safi
11741 * actualy have something interesting in
11746 vty_out(vty
, ",\n");
11750 vty_out(vty
, "\"%s\":",
11751 get_afi_safi_str(afi
,
11756 "\n%s Summary (%s):\n",
11757 get_afi_safi_str(afi
,
11763 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11764 as_type
, as
, show_flags
);
11767 if (!safi_wildcard
)
11775 if (use_json
&& is_wildcard
)
11776 vty_out(vty
, "}\n");
11777 else if (!nbr_output
) {
11779 vty_out(vty
, "{}\n");
11781 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11786 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11788 const char *neighbor
,
11789 int as_type
, as_t as
,
11790 uint16_t show_flags
)
11792 struct listnode
*node
, *nnode
;
11794 struct peer
*fpeer
= NULL
;
11796 bool nbr_output
= false;
11797 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11800 vty_out(vty
, "{\n");
11802 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11806 vty_out(vty
, ",\n");
11810 vty_out(vty
, "\"%s\":",
11811 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11816 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11821 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11826 vty_out(vty
, "}\n");
11827 else if (!nbr_output
)
11828 vty_out(vty
, "%% BGP instance not found\n");
11831 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11832 safi_t safi
, const char *neighbor
, int as_type
,
11833 as_t as
, uint16_t show_flags
)
11836 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11837 struct peer
*fpeer
= NULL
;
11840 if (strmatch(name
, "all")) {
11841 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11844 return CMD_SUCCESS
;
11846 bgp
= bgp_lookup_by_name(name
);
11850 vty_out(vty
, "{}\n");
11853 "%% BGP instance not found\n");
11854 return CMD_WARNING
;
11858 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11861 return CMD_WARNING
;
11863 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11864 as_type
, as
, show_flags
);
11865 return CMD_SUCCESS
;
11869 bgp
= bgp_get_default();
11873 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11876 return CMD_WARNING
;
11878 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11882 vty_out(vty
, "{}\n");
11884 vty_out(vty
, "%% BGP instance not found\n");
11885 return CMD_WARNING
;
11888 return CMD_SUCCESS
;
11891 /* `show [ip] bgp summary' commands. */
11892 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11893 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11894 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11895 "]] [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]",
11896 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11897 BGP_SAFI_WITH_LABEL_HELP_STR
11898 "Display the entries for all address families\n"
11899 "Summary of BGP neighbor status\n"
11900 "Show only sessions in Established state\n"
11901 "Show only sessions not in Established state\n"
11902 "Show only the specified neighbor session\n"
11903 "Neighbor to display information about\n"
11904 "Neighbor to display information about\n"
11905 "Neighbor on BGP configured interface\n"
11906 "Show only the specified remote AS sessions\n"
11908 "Internal (iBGP) AS sessions\n"
11909 "External (eBGP) AS sessions\n"
11910 "Shorten the information on BGP instances\n"
11911 "Increase table width for longer output\n" JSON_STR
)
11914 afi_t afi
= AFI_MAX
;
11915 safi_t safi
= SAFI_MAX
;
11916 as_t as
= 0; /* 0 means AS filter not set */
11917 int as_type
= AS_UNSPECIFIED
;
11918 uint16_t show_flags
= 0;
11922 /* show [ip] bgp */
11923 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11925 /* [<vrf> VIEWVRFNAME] */
11926 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11927 vrf
= argv
[idx
+ 1]->arg
;
11928 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11930 } else if (argv_find(argv
, argc
, "view", &idx
))
11931 /* [<view> VIEWVRFNAME] */
11932 vrf
= argv
[idx
+ 1]->arg
;
11933 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11934 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11935 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11938 if (argv_find(argv
, argc
, "failed", &idx
))
11939 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11941 if (argv_find(argv
, argc
, "established", &idx
))
11942 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11944 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11945 if (argv
[idx
+ 1]->arg
[0] == 'i')
11946 as_type
= AS_INTERNAL
;
11947 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11948 as_type
= AS_EXTERNAL
;
11950 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11953 if (argv_find(argv
, argc
, "terse", &idx
))
11954 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11956 if (argv_find(argv
, argc
, "wide", &idx
))
11957 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11959 if (argv_find(argv
, argc
, "json", &idx
))
11960 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11962 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11966 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11969 return get_afi_safi_json_str(afi
, safi
);
11971 return get_afi_safi_vty_str(afi
, safi
);
11975 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11976 afi_t afi
, safi_t safi
,
11977 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11978 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11979 bool use_json
, json_object
*json_pref
)
11982 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11983 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11985 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11986 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11987 json_object_string_add(json_pref
, "sendMode",
11988 "advertisedAndReceived");
11989 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11990 json_object_string_add(json_pref
, "sendMode",
11992 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11993 json_object_string_add(json_pref
, "sendMode",
11996 vty_out(vty
, " Send-mode: ");
11997 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11998 vty_out(vty
, "advertised");
11999 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
12000 vty_out(vty
, "%sreceived",
12001 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12005 vty_out(vty
, "\n");
12010 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12011 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
12013 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12014 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12015 json_object_string_add(json_pref
, "recvMode",
12016 "advertisedAndReceived");
12017 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12018 json_object_string_add(json_pref
, "recvMode",
12020 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12021 json_object_string_add(json_pref
, "recvMode",
12024 vty_out(vty
, " Receive-mode: ");
12025 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12026 vty_out(vty
, "advertised");
12027 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12028 vty_out(vty
, "%sreceived",
12029 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12033 vty_out(vty
, "\n");
12038 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
12045 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12046 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12047 && (peer_established(p
))) {
12048 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
12049 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
12053 json_object_boolean_add(json
, "rBit", rbit
);
12054 json_object_boolean_add(json
, "nBit", nbit
);
12056 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
12057 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
12061 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12065 const char *mode
= "NotApplicable";
12068 vty_out(vty
, "\n Remote GR Mode: ");
12070 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12071 && (peer_established(peer
))) {
12073 if ((peer
->nsf_af_count
== 0)
12074 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12078 } else if (peer
->nsf_af_count
== 0
12079 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12083 } else if (peer
->nsf_af_count
!= 0
12084 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12091 json_object_string_add(json
, "remoteGrMode", mode
);
12093 vty_out(vty
, "%s\n", mode
);
12096 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12100 const char *mode
= "Invalid";
12103 vty_out(vty
, " Local GR Mode: ");
12105 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12107 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12109 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12111 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12112 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12114 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12116 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12123 json_object_string_add(json
, "localGrMode", mode
);
12125 vty_out(vty
, "%s\n", mode
);
12128 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12129 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12133 json_object
*json_afi_safi
= NULL
;
12134 json_object
*json_timer
= NULL
;
12135 json_object
*json_endofrib_status
= NULL
;
12136 bool eor_flag
= false;
12138 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12139 if (!peer
->afc
[afi
][safi
])
12142 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12143 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12147 json_afi_safi
= json_object_new_object();
12148 json_endofrib_status
= json_object_new_object();
12149 json_timer
= json_object_new_object();
12152 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12158 vty_out(vty
, " %s:\n",
12159 get_afi_safi_str(afi
, safi
, false));
12161 vty_out(vty
, " F bit: ");
12164 if (peer
->nsf
[afi
][safi
] &&
12165 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12166 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12169 json_object_boolean_true_add(json_afi_safi
,
12172 vty_out(vty
, "True\n");
12175 json_object_boolean_false_add(json_afi_safi
,
12178 vty_out(vty
, "False\n");
12182 vty_out(vty
, " End-of-RIB sent: ");
12184 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12185 PEER_STATUS_EOR_SEND
)) {
12187 json_object_boolean_true_add(
12188 json_endofrib_status
, "endOfRibSend");
12190 PRINT_EOR_JSON(eor_flag
);
12192 vty_out(vty
, "Yes\n");
12194 " End-of-RIB sent after update: ");
12196 PRINT_EOR(eor_flag
);
12200 json_object_boolean_false_add(
12201 json_endofrib_status
, "endOfRibSend");
12202 json_object_boolean_false_add(
12203 json_endofrib_status
,
12204 "endOfRibSentAfterUpdate");
12206 vty_out(vty
, "No\n");
12208 " End-of-RIB sent after update: ");
12209 vty_out(vty
, "No\n");
12214 vty_out(vty
, " End-of-RIB received: ");
12216 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12217 PEER_STATUS_EOR_RECEIVED
)) {
12219 json_object_boolean_true_add(
12220 json_endofrib_status
, "endOfRibRecv");
12222 vty_out(vty
, "Yes\n");
12225 json_object_boolean_false_add(
12226 json_endofrib_status
, "endOfRibRecv");
12228 vty_out(vty
, "No\n");
12232 json_object_int_add(json_timer
, "stalePathTimer",
12233 peer
->bgp
->stalepath_time
);
12235 if (peer
->t_gr_stale
!= NULL
) {
12236 json_object_int_add(json_timer
,
12237 "stalePathTimerRemaining",
12238 thread_timer_remain_second(
12239 peer
->t_gr_stale
));
12242 /* Display Configured Selection
12243 * Deferral only when when
12244 * Gr mode is enabled.
12246 if (CHECK_FLAG(peer
->flags
,
12247 PEER_FLAG_GRACEFUL_RESTART
)) {
12248 json_object_int_add(json_timer
,
12249 "selectionDeferralTimer",
12250 peer
->bgp
->stalepath_time
);
12253 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12256 json_object_int_add(
12258 "selectionDeferralTimerRemaining",
12259 thread_timer_remain_second(
12260 peer
->bgp
->gr_info
[afi
][safi
]
12261 .t_select_deferral
));
12264 vty_out(vty
, " Timers:\n");
12266 " Configured Stale Path Time(sec): %u\n",
12267 peer
->bgp
->stalepath_time
);
12269 if (peer
->t_gr_stale
!= NULL
)
12271 " Stale Path Remaining(sec): %ld\n",
12272 thread_timer_remain_second(
12273 peer
->t_gr_stale
));
12274 /* Display Configured Selection
12275 * Deferral only when when
12276 * Gr mode is enabled.
12278 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12280 " Configured Selection Deferral Time(sec): %u\n",
12281 peer
->bgp
->select_defer_time
);
12283 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12286 " Selection Deferral Time Remaining(sec): %ld\n",
12287 thread_timer_remain_second(
12288 peer
->bgp
->gr_info
[afi
][safi
]
12289 .t_select_deferral
));
12292 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12293 json_endofrib_status
);
12294 json_object_object_add(json_afi_safi
, "timers",
12296 json_object_object_add(
12297 json
, get_afi_safi_str(afi
, safi
, true),
12303 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12308 json_object
*json_timer
= NULL
;
12310 json_timer
= json_object_new_object();
12312 json_object_int_add(json_timer
, "configuredRestartTimer",
12313 p
->bgp
->restart_time
);
12315 json_object_int_add(json_timer
, "receivedRestartTimer",
12318 if (p
->t_gr_restart
!= NULL
)
12319 json_object_int_add(
12320 json_timer
, "restartTimerRemaining",
12321 thread_timer_remain_second(p
->t_gr_restart
));
12323 json_object_object_add(json
, "timers", json_timer
);
12326 vty_out(vty
, " Timers:\n");
12327 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12328 p
->bgp
->restart_time
);
12330 vty_out(vty
, " Received Restart Time(sec): %u\n",
12332 if (p
->t_gr_restart
!= NULL
)
12333 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12334 thread_timer_remain_second(p
->t_gr_restart
));
12335 if (p
->t_gr_restart
!= NULL
) {
12336 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12337 thread_timer_remain_second(p
->t_gr_restart
));
12342 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12345 char dn_flag
[2] = {0};
12346 /* '*' + v6 address of neighbor */
12347 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12349 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12354 json_object_string_addf(json
, "neighborAddr", "%pSU",
12357 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12360 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12364 json_object_string_add(json
, "neighborAddr",
12367 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12370 /* more gr info in new format */
12371 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12374 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12375 safi_t safi
, bool use_json
,
12376 json_object
*json_neigh
)
12378 struct bgp_filter
*filter
;
12379 struct peer_af
*paf
;
12380 char orf_pfx_name
[BUFSIZ
];
12382 json_object
*json_af
= NULL
;
12383 json_object
*json_prefA
= NULL
;
12384 json_object
*json_prefB
= NULL
;
12385 json_object
*json_addr
= NULL
;
12386 json_object
*json_advmap
= NULL
;
12389 json_addr
= json_object_new_object();
12390 json_af
= json_object_new_object();
12391 filter
= &p
->filter
[afi
][safi
];
12393 if (peer_group_active(p
))
12394 json_object_string_add(json_addr
, "peerGroupMember",
12397 paf
= peer_af_find(p
, afi
, safi
);
12398 if (paf
&& PAF_SUBGRP(paf
)) {
12399 json_object_int_add(json_addr
, "updateGroupId",
12400 PAF_UPDGRP(paf
)->id
);
12401 json_object_int_add(json_addr
, "subGroupId",
12402 PAF_SUBGRP(paf
)->id
);
12403 json_object_int_add(json_addr
, "packetQueueLength",
12404 bpacket_queue_virtual_length(paf
));
12407 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12408 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12409 PEER_CAP_ORF_PREFIX_SM_RCV
)
12410 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12411 PEER_CAP_ORF_PREFIX_RM_ADV
)
12412 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12413 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12414 json_object_int_add(json_af
, "orfType",
12416 json_prefA
= json_object_new_object();
12417 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12418 PEER_CAP_ORF_PREFIX_SM_ADV
,
12419 PEER_CAP_ORF_PREFIX_RM_ADV
,
12420 PEER_CAP_ORF_PREFIX_SM_RCV
,
12421 PEER_CAP_ORF_PREFIX_RM_RCV
,
12422 use_json
, json_prefA
);
12423 json_object_object_add(json_af
, "orfPrefixList",
12427 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12428 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12429 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12430 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12431 PEER_CAP_ORF_PREFIX_RM_ADV
)
12432 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12433 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12434 json_object_int_add(json_af
, "orfOldType",
12435 ORF_TYPE_PREFIX_OLD
);
12436 json_prefB
= json_object_new_object();
12437 bgp_show_peer_afi_orf_cap(
12438 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12439 PEER_CAP_ORF_PREFIX_RM_ADV
,
12440 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12441 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12443 json_object_object_add(json_af
, "orfOldPrefixList",
12447 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12448 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12449 PEER_CAP_ORF_PREFIX_SM_RCV
)
12450 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12451 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12452 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12453 PEER_CAP_ORF_PREFIX_RM_ADV
)
12454 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12455 PEER_CAP_ORF_PREFIX_RM_RCV
)
12456 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12457 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12458 json_object_object_add(json_addr
, "afDependentCap",
12461 json_object_free(json_af
);
12463 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12464 p
->host
, afi
, safi
);
12465 orf_pfx_count
= prefix_bgp_show_prefix_list(
12466 NULL
, afi
, orf_pfx_name
, use_json
);
12468 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12469 PEER_STATUS_ORF_PREFIX_SEND
)
12470 || orf_pfx_count
) {
12471 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12472 PEER_STATUS_ORF_PREFIX_SEND
))
12473 json_object_boolean_true_add(json_neigh
,
12476 json_object_int_add(json_addr
, "orfRecvCounter",
12479 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12480 PEER_STATUS_ORF_WAIT_REFRESH
))
12481 json_object_string_add(
12482 json_addr
, "orfFirstUpdate",
12483 "deferredUntilORFOrRouteRefreshRecvd");
12485 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12486 PEER_FLAG_REFLECTOR_CLIENT
))
12487 json_object_boolean_true_add(json_addr
,
12488 "routeReflectorClient");
12489 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12490 PEER_FLAG_RSERVER_CLIENT
))
12491 json_object_boolean_true_add(json_addr
,
12492 "routeServerClient");
12493 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12494 json_object_boolean_true_add(json_addr
,
12495 "inboundSoftConfigPermit");
12497 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12498 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12499 json_object_boolean_true_add(
12501 "privateAsNumsAllReplacedInUpdatesToNbr");
12502 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12503 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12504 json_object_boolean_true_add(
12506 "privateAsNumsReplacedInUpdatesToNbr");
12507 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12508 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12509 json_object_boolean_true_add(
12511 "privateAsNumsAllRemovedInUpdatesToNbr");
12512 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12513 PEER_FLAG_REMOVE_PRIVATE_AS
))
12514 json_object_boolean_true_add(
12516 "privateAsNumsRemovedInUpdatesToNbr");
12518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12519 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12520 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12521 json_object_boolean_true_add(json_addr
,
12522 "allowAsInOrigin");
12524 json_object_int_add(json_addr
, "allowAsInCount",
12525 p
->allowas_in
[afi
][safi
]);
12528 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12529 json_object_boolean_true_add(
12531 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12535 json_object_string_add(json_addr
,
12536 "overrideASNsInOutboundUpdates",
12537 "ifAspathEqualRemoteAs");
12539 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12540 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12541 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12542 json_object_boolean_true_add(json_addr
,
12543 "routerAlwaysNextHop");
12544 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12545 PEER_FLAG_AS_PATH_UNCHANGED
))
12546 json_object_boolean_true_add(
12547 json_addr
, "unchangedAsPathPropogatedToNbr");
12548 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12549 PEER_FLAG_NEXTHOP_UNCHANGED
))
12550 json_object_boolean_true_add(
12551 json_addr
, "unchangedNextHopPropogatedToNbr");
12552 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12553 json_object_boolean_true_add(
12554 json_addr
, "unchangedMedPropogatedToNbr");
12555 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12556 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12557 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12558 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12559 PEER_FLAG_SEND_COMMUNITY
)
12560 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12561 PEER_FLAG_SEND_EXT_COMMUNITY
))
12562 json_object_string_add(json_addr
,
12563 "commAttriSentToNbr",
12564 "extendedAndStandard");
12565 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12566 PEER_FLAG_SEND_EXT_COMMUNITY
))
12567 json_object_string_add(json_addr
,
12568 "commAttriSentToNbr",
12571 json_object_string_add(json_addr
,
12572 "commAttriSentToNbr",
12575 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12576 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12577 if (p
->default_rmap
[afi
][safi
].name
)
12578 json_object_string_add(
12579 json_addr
, "defaultRouteMap",
12580 p
->default_rmap
[afi
][safi
].name
);
12582 if (paf
&& PAF_SUBGRP(paf
)
12583 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12584 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12585 json_object_boolean_true_add(json_addr
,
12588 json_object_boolean_true_add(json_addr
,
12592 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12593 if (is_evpn_enabled())
12594 json_object_boolean_true_add(
12595 json_addr
, "advertiseAllVnis");
12598 if (filter
->plist
[FILTER_IN
].name
12599 || filter
->dlist
[FILTER_IN
].name
12600 || filter
->aslist
[FILTER_IN
].name
12601 || filter
->map
[RMAP_IN
].name
)
12602 json_object_boolean_true_add(json_addr
,
12603 "inboundPathPolicyConfig");
12604 if (filter
->plist
[FILTER_OUT
].name
12605 || filter
->dlist
[FILTER_OUT
].name
12606 || filter
->aslist
[FILTER_OUT
].name
12607 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12608 json_object_boolean_true_add(
12609 json_addr
, "outboundPathPolicyConfig");
12612 if (filter
->plist
[FILTER_IN
].name
)
12613 json_object_string_add(json_addr
,
12614 "incomingUpdatePrefixFilterList",
12615 filter
->plist
[FILTER_IN
].name
);
12616 if (filter
->plist
[FILTER_OUT
].name
)
12617 json_object_string_add(json_addr
,
12618 "outgoingUpdatePrefixFilterList",
12619 filter
->plist
[FILTER_OUT
].name
);
12621 /* distribute-list */
12622 if (filter
->dlist
[FILTER_IN
].name
)
12623 json_object_string_add(
12624 json_addr
, "incomingUpdateNetworkFilterList",
12625 filter
->dlist
[FILTER_IN
].name
);
12626 if (filter
->dlist
[FILTER_OUT
].name
)
12627 json_object_string_add(
12628 json_addr
, "outgoingUpdateNetworkFilterList",
12629 filter
->dlist
[FILTER_OUT
].name
);
12632 if (filter
->aslist
[FILTER_IN
].name
)
12633 json_object_string_add(json_addr
,
12634 "incomingUpdateAsPathFilterList",
12635 filter
->aslist
[FILTER_IN
].name
);
12636 if (filter
->aslist
[FILTER_OUT
].name
)
12637 json_object_string_add(json_addr
,
12638 "outgoingUpdateAsPathFilterList",
12639 filter
->aslist
[FILTER_OUT
].name
);
12642 if (filter
->map
[RMAP_IN
].name
)
12643 json_object_string_add(
12644 json_addr
, "routeMapForIncomingAdvertisements",
12645 filter
->map
[RMAP_IN
].name
);
12646 if (filter
->map
[RMAP_OUT
].name
)
12647 json_object_string_add(
12648 json_addr
, "routeMapForOutgoingAdvertisements",
12649 filter
->map
[RMAP_OUT
].name
);
12651 /* ebgp-requires-policy (inbound) */
12652 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12653 && !bgp_inbound_policy_exists(p
, filter
))
12654 json_object_string_add(
12655 json_addr
, "inboundEbgpRequiresPolicy",
12656 "Inbound updates discarded due to missing policy");
12658 /* ebgp-requires-policy (outbound) */
12659 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12660 && (!bgp_outbound_policy_exists(p
, filter
)))
12661 json_object_string_add(
12662 json_addr
, "outboundEbgpRequiresPolicy",
12663 "Outbound updates discarded due to missing policy");
12665 /* unsuppress-map */
12666 if (filter
->usmap
.name
)
12667 json_object_string_add(json_addr
,
12668 "selectiveUnsuppressRouteMap",
12669 filter
->usmap
.name
);
12671 /* advertise-map */
12672 if (filter
->advmap
.aname
) {
12673 json_advmap
= json_object_new_object();
12674 json_object_string_add(json_advmap
, "condition",
12675 filter
->advmap
.condition
12678 json_object_string_add(json_advmap
, "conditionMap",
12679 filter
->advmap
.cname
);
12680 json_object_string_add(json_advmap
, "advertiseMap",
12681 filter
->advmap
.aname
);
12682 json_object_string_add(
12683 json_advmap
, "advertiseStatus",
12684 filter
->advmap
.update_type
==
12685 UPDATE_TYPE_ADVERTISE
12688 json_object_object_add(json_addr
, "advertiseMap",
12692 /* Receive prefix count */
12693 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12694 p
->pcount
[afi
][safi
]);
12695 if (paf
&& PAF_SUBGRP(paf
))
12696 json_object_int_add(json_addr
, "sentPrefixCounter",
12697 (PAF_SUBGRP(paf
))->scount
);
12699 /* Maximum prefix */
12700 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12701 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12702 p
->pmax_out
[afi
][safi
]);
12704 /* Maximum prefix */
12705 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12706 json_object_int_add(json_addr
, "prefixAllowedMax",
12707 p
->pmax
[afi
][safi
]);
12708 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12709 PEER_FLAG_MAX_PREFIX_WARNING
))
12710 json_object_boolean_true_add(
12711 json_addr
, "prefixAllowedMaxWarning");
12712 json_object_int_add(json_addr
,
12713 "prefixAllowedWarningThresh",
12714 p
->pmax_threshold
[afi
][safi
]);
12715 if (p
->pmax_restart
[afi
][safi
])
12716 json_object_int_add(
12718 "prefixAllowedRestartIntervalMsecs",
12719 p
->pmax_restart
[afi
][safi
] * 60000);
12721 json_object_object_add(json_neigh
,
12722 get_afi_safi_str(afi
, safi
, true),
12726 filter
= &p
->filter
[afi
][safi
];
12728 vty_out(vty
, " For address family: %s\n",
12729 get_afi_safi_str(afi
, safi
, false));
12731 if (peer_group_active(p
))
12732 vty_out(vty
, " %s peer-group member\n",
12735 paf
= peer_af_find(p
, afi
, safi
);
12736 if (paf
&& PAF_SUBGRP(paf
)) {
12737 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12738 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12739 vty_out(vty
, " Packet Queue length %d\n",
12740 bpacket_queue_virtual_length(paf
));
12742 vty_out(vty
, " Not part of any update group\n");
12744 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12745 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12746 PEER_CAP_ORF_PREFIX_SM_RCV
)
12747 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12748 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12749 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12750 PEER_CAP_ORF_PREFIX_RM_ADV
)
12751 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12752 PEER_CAP_ORF_PREFIX_RM_RCV
)
12753 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12754 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12755 vty_out(vty
, " AF-dependant capabilities:\n");
12757 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12758 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12759 PEER_CAP_ORF_PREFIX_SM_RCV
)
12760 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12761 PEER_CAP_ORF_PREFIX_RM_ADV
)
12762 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12763 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12765 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12767 bgp_show_peer_afi_orf_cap(
12768 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12769 PEER_CAP_ORF_PREFIX_RM_ADV
,
12770 PEER_CAP_ORF_PREFIX_SM_RCV
,
12771 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12773 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12774 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12775 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12776 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12777 PEER_CAP_ORF_PREFIX_RM_ADV
)
12778 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12779 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12781 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12782 ORF_TYPE_PREFIX_OLD
);
12783 bgp_show_peer_afi_orf_cap(
12784 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12785 PEER_CAP_ORF_PREFIX_RM_ADV
,
12786 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12787 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12790 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12791 p
->host
, afi
, safi
);
12792 orf_pfx_count
= prefix_bgp_show_prefix_list(
12793 NULL
, afi
, orf_pfx_name
, use_json
);
12795 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12796 PEER_STATUS_ORF_PREFIX_SEND
)
12797 || orf_pfx_count
) {
12798 vty_out(vty
, " Outbound Route Filter (ORF):");
12799 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12800 PEER_STATUS_ORF_PREFIX_SEND
))
12801 vty_out(vty
, " sent;");
12803 vty_out(vty
, " received (%d entries)",
12805 vty_out(vty
, "\n");
12807 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12808 PEER_STATUS_ORF_WAIT_REFRESH
))
12810 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12812 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12813 PEER_FLAG_REFLECTOR_CLIENT
))
12814 vty_out(vty
, " Route-Reflector Client\n");
12815 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12816 PEER_FLAG_RSERVER_CLIENT
))
12817 vty_out(vty
, " Route-Server Client\n");
12818 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12820 " Inbound soft reconfiguration allowed\n");
12822 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12823 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12825 " Private AS numbers (all) replaced in updates to this neighbor\n");
12826 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12827 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12829 " Private AS numbers replaced in updates to this neighbor\n");
12830 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12831 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12833 " Private AS numbers (all) removed in updates to this neighbor\n");
12834 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12835 PEER_FLAG_REMOVE_PRIVATE_AS
))
12837 " Private AS numbers removed in updates to this neighbor\n");
12839 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12840 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12841 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12843 " Local AS allowed as path origin\n");
12846 " Local AS allowed in path, %d occurrences\n",
12847 p
->allowas_in
[afi
][safi
]);
12850 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12851 vty_out(vty
, " %s\n",
12852 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12853 ->human_description
);
12855 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12857 " Override ASNs in outbound updates if aspath equals remote-as\n");
12859 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12860 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12861 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12862 vty_out(vty
, " NEXT_HOP is always this router\n");
12863 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12864 PEER_FLAG_AS_PATH_UNCHANGED
))
12866 " AS_PATH is propagated unchanged to this neighbor\n");
12867 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12868 PEER_FLAG_NEXTHOP_UNCHANGED
))
12870 " NEXT_HOP is propagated unchanged to this neighbor\n");
12871 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12873 " MED is propagated unchanged to this neighbor\n");
12874 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12875 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12876 PEER_FLAG_SEND_EXT_COMMUNITY
)
12877 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12878 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12880 " Community attribute sent to this neighbor");
12881 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12882 PEER_FLAG_SEND_COMMUNITY
)
12883 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12884 PEER_FLAG_SEND_EXT_COMMUNITY
)
12885 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12886 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12887 vty_out(vty
, "(all)\n");
12888 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12889 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12890 vty_out(vty
, "(large)\n");
12891 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12892 PEER_FLAG_SEND_EXT_COMMUNITY
))
12893 vty_out(vty
, "(extended)\n");
12895 vty_out(vty
, "(standard)\n");
12897 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12898 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12899 vty_out(vty
, " Default information originate,");
12901 if (p
->default_rmap
[afi
][safi
].name
)
12902 vty_out(vty
, " default route-map %s%s,",
12903 p
->default_rmap
[afi
][safi
].map
? "*"
12905 p
->default_rmap
[afi
][safi
].name
);
12906 if (paf
&& PAF_SUBGRP(paf
)
12907 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12908 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12909 vty_out(vty
, " default sent\n");
12911 vty_out(vty
, " default not sent\n");
12914 /* advertise-vni-all */
12915 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12916 if (is_evpn_enabled())
12917 vty_out(vty
, " advertise-all-vni\n");
12920 if (filter
->plist
[FILTER_IN
].name
12921 || filter
->dlist
[FILTER_IN
].name
12922 || filter
->aslist
[FILTER_IN
].name
12923 || filter
->map
[RMAP_IN
].name
)
12924 vty_out(vty
, " Inbound path policy configured\n");
12925 if (filter
->plist
[FILTER_OUT
].name
12926 || filter
->dlist
[FILTER_OUT
].name
12927 || filter
->aslist
[FILTER_OUT
].name
12928 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12929 vty_out(vty
, " Outbound path policy configured\n");
12932 if (filter
->plist
[FILTER_IN
].name
)
12934 " Incoming update prefix filter list is %s%s\n",
12935 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12936 filter
->plist
[FILTER_IN
].name
);
12937 if (filter
->plist
[FILTER_OUT
].name
)
12939 " Outgoing update prefix filter list is %s%s\n",
12940 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12941 filter
->plist
[FILTER_OUT
].name
);
12943 /* distribute-list */
12944 if (filter
->dlist
[FILTER_IN
].name
)
12946 " Incoming update network filter list is %s%s\n",
12947 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12948 filter
->dlist
[FILTER_IN
].name
);
12949 if (filter
->dlist
[FILTER_OUT
].name
)
12951 " Outgoing update network filter list is %s%s\n",
12952 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12953 filter
->dlist
[FILTER_OUT
].name
);
12956 if (filter
->aslist
[FILTER_IN
].name
)
12958 " Incoming update AS path filter list is %s%s\n",
12959 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12960 filter
->aslist
[FILTER_IN
].name
);
12961 if (filter
->aslist
[FILTER_OUT
].name
)
12963 " Outgoing update AS path filter list is %s%s\n",
12964 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12965 filter
->aslist
[FILTER_OUT
].name
);
12968 if (filter
->map
[RMAP_IN
].name
)
12970 " Route map for incoming advertisements is %s%s\n",
12971 filter
->map
[RMAP_IN
].map
? "*" : "",
12972 filter
->map
[RMAP_IN
].name
);
12973 if (filter
->map
[RMAP_OUT
].name
)
12975 " Route map for outgoing advertisements is %s%s\n",
12976 filter
->map
[RMAP_OUT
].map
? "*" : "",
12977 filter
->map
[RMAP_OUT
].name
);
12979 /* ebgp-requires-policy (inbound) */
12980 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12981 && !bgp_inbound_policy_exists(p
, filter
))
12983 " Inbound updates discarded due to missing policy\n");
12985 /* ebgp-requires-policy (outbound) */
12986 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12987 && !bgp_outbound_policy_exists(p
, filter
))
12989 " Outbound updates discarded due to missing policy\n");
12991 /* unsuppress-map */
12992 if (filter
->usmap
.name
)
12994 " Route map for selective unsuppress is %s%s\n",
12995 filter
->usmap
.map
? "*" : "",
12996 filter
->usmap
.name
);
12998 /* advertise-map */
12999 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
13001 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
13002 filter
->advmap
.condition
? "EXIST"
13004 filter
->advmap
.cmap
? "*" : "",
13005 filter
->advmap
.cname
,
13006 filter
->advmap
.amap
? "*" : "",
13007 filter
->advmap
.aname
,
13008 filter
->advmap
.update_type
==
13009 UPDATE_TYPE_ADVERTISE
13013 /* Receive prefix count */
13014 vty_out(vty
, " %u accepted prefixes\n",
13015 p
->pcount
[afi
][safi
]);
13017 /* maximum-prefix-out */
13018 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
13019 PEER_FLAG_MAX_PREFIX_OUT
))
13021 " Maximum allowed prefixes sent %u\n",
13022 p
->pmax_out
[afi
][safi
]);
13024 /* Maximum prefix */
13025 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13027 " Maximum prefixes allowed %u%s\n",
13028 p
->pmax
[afi
][safi
],
13029 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13030 PEER_FLAG_MAX_PREFIX_WARNING
)
13031 ? " (warning-only)"
13033 vty_out(vty
, " Threshold for warning message %d%%",
13034 p
->pmax_threshold
[afi
][safi
]);
13035 if (p
->pmax_restart
[afi
][safi
])
13036 vty_out(vty
, ", restart interval %d min",
13037 p
->pmax_restart
[afi
][safi
]);
13038 vty_out(vty
, "\n");
13041 vty_out(vty
, "\n");
13045 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13049 char timebuf
[BGP_UPTIME_LEN
];
13055 json_object
*json_neigh
= NULL
;
13057 uint32_t sync_tcp_mss
;
13062 json_neigh
= json_object_new_object();
13064 memset(dn_flag
, '\0', sizeof(dn_flag
));
13065 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13069 if (p
->conf_if
) /* Configured interface name. */
13070 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
13072 else /* Configured IP address. */
13073 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13078 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13079 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13081 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13082 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
13085 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13087 if (p
->change_local_as
)
13088 json_object_int_add(json_neigh
, "localAs",
13089 p
->change_local_as
);
13091 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13093 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13094 json_object_boolean_true_add(json_neigh
,
13095 "localAsNoPrepend");
13097 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13098 json_object_boolean_true_add(json_neigh
,
13099 "localAsReplaceAs");
13101 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13102 || (p
->as_type
== AS_INTERNAL
))
13103 vty_out(vty
, "remote AS %u, ", p
->as
);
13105 vty_out(vty
, "remote AS Unspecified, ");
13106 vty_out(vty
, "local AS %u%s%s, ",
13107 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13108 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13111 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13115 /* peer type internal or confed-internal */
13116 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13118 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13119 json_object_boolean_true_add(
13120 json_neigh
, "nbrConfedInternalLink");
13122 json_object_boolean_true_add(json_neigh
,
13123 "nbrInternalLink");
13125 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13126 vty_out(vty
, "confed-internal link\n");
13128 vty_out(vty
, "internal link\n");
13130 /* peer type external or confed-external */
13131 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13133 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13134 json_object_boolean_true_add(
13135 json_neigh
, "nbrConfedExternalLink");
13137 json_object_boolean_true_add(json_neigh
,
13138 "nbrExternalLink");
13140 if (bgp_confederation_peers_check(bgp
, p
->as
))
13141 vty_out(vty
, "confed-external link\n");
13143 vty_out(vty
, "external link\n");
13147 json_object_boolean_true_add(json_neigh
,
13148 "nbrUnspecifiedLink");
13150 vty_out(vty
, "unspecified link\n");
13155 json_object_string_add(json_neigh
, "localRole",
13156 bgp_get_name_by_role(p
->local_role
));
13157 json_object_string_add(json_neigh
, "remoteRole",
13158 bgp_get_name_by_role(p
->remote_role
));
13160 vty_out(vty
, " Local Role: %s\n",
13161 bgp_get_name_by_role(p
->local_role
));
13162 vty_out(vty
, " Remote Role: %s\n",
13163 bgp_get_name_by_role(p
->remote_role
));
13170 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13172 vty_out(vty
, " Description: %s\n", p
->desc
);
13177 json_object_string_add(json_neigh
, "hostname",
13181 json_object_string_add(json_neigh
, "domainname",
13184 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13185 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13188 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13192 json_object_string_add(json_neigh
, "hostname",
13199 json_object_string_add(json_neigh
, "peerGroup",
13203 struct prefix prefix
, *range
= NULL
;
13205 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13206 range
= peer_group_lookup_dynamic_neighbor_range(
13207 p
->group
, &prefix
);
13210 json_object_string_addf(
13212 "peerSubnetRangeGroup", "%pFX",
13218 " Member of peer-group %s for session parameters\n",
13222 struct prefix prefix
, *range
= NULL
;
13224 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13225 range
= peer_group_lookup_dynamic_neighbor_range(
13226 p
->group
, &prefix
);
13230 " Belongs to the subnet range group: %pFX\n",
13238 /* Administrative shutdown. */
13239 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13240 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13241 json_object_boolean_true_add(json_neigh
,
13245 json_object_int_add(json_neigh
, "bgpVersion", 4);
13246 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13248 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13251 /* Confederation */
13252 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13253 && bgp_confederation_peers_check(bgp
, p
->as
))
13254 json_object_boolean_true_add(json_neigh
,
13258 json_object_string_add(
13259 json_neigh
, "bgpState",
13260 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13262 if (peer_established(p
)) {
13265 uptime
= monotime(NULL
);
13266 uptime
-= p
->uptime
;
13267 epoch_tbuf
= time(NULL
) - uptime
;
13269 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13271 json_object_string_add(json_neigh
, "bgpTimerUpString",
13272 peer_uptime(p
->uptime
, timebuf
,
13275 json_object_int_add(json_neigh
,
13276 "bgpTimerUpEstablishedEpoch",
13280 else if (p
->status
== Active
) {
13281 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13282 json_object_string_add(json_neigh
, "bgpStateIs",
13284 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13285 json_object_string_add(json_neigh
, "bgpStateIs",
13293 uptime
= monotime(NULL
);
13294 uptime
-= p
->readtime
;
13295 gmtime_r(&uptime
, &tm
);
13297 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13298 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13299 + (tm
.tm_hour
* 3600000));
13301 uptime
= monotime(NULL
);
13302 uptime
-= p
->last_write
;
13303 gmtime_r(&uptime
, &tm
);
13305 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13306 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13307 + (tm
.tm_hour
* 3600000));
13309 uptime
= monotime(NULL
);
13310 uptime
-= p
->update_time
;
13311 gmtime_r(&uptime
, &tm
);
13313 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13314 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13315 + (tm
.tm_hour
* 3600000));
13317 /* Configured timer values. */
13318 json_object_int_add(json_neigh
,
13319 "bgpTimerConfiguredHoldTimeMsecs",
13320 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13321 ? p
->holdtime
* 1000
13322 : bgp
->default_holdtime
* 1000);
13323 json_object_int_add(json_neigh
,
13324 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13325 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13326 ? p
->keepalive
* 1000
13327 : bgp
->default_keepalive
* 1000);
13328 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13329 p
->v_holdtime
* 1000);
13330 json_object_int_add(json_neigh
,
13331 "bgpTimerKeepAliveIntervalMsecs",
13332 p
->v_keepalive
* 1000);
13333 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13334 json_object_int_add(json_neigh
,
13335 "bgpTimerDelayOpenTimeMsecs",
13336 p
->v_delayopen
* 1000);
13339 /* Configured and Synced tcp-mss value for peer */
13340 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13341 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13342 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13344 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13348 /* Extended Optional Parameters Length for BGP OPEN Message */
13349 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13350 json_object_boolean_true_add(
13351 json_neigh
, "extendedOptionalParametersLength");
13353 json_object_boolean_false_add(
13354 json_neigh
, "extendedOptionalParametersLength");
13356 /* Conditional advertisements */
13357 json_object_int_add(
13359 "bgpTimerConfiguredConditionalAdvertisementsSec",
13360 bgp
->condition_check_period
);
13361 if (thread_is_scheduled(bgp
->t_condition_check
))
13362 json_object_int_add(
13364 "bgpTimerUntilConditionalAdvertisementsSec",
13365 thread_timer_remain_second(
13366 bgp
->t_condition_check
));
13368 /* Administrative shutdown. */
13369 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13370 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13371 vty_out(vty
, " Administratively shut down\n");
13374 vty_out(vty
, " BGP version 4");
13375 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13376 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13378 /* Confederation */
13379 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13380 && bgp_confederation_peers_check(bgp
, p
->as
))
13382 " Neighbor under common administration\n");
13385 vty_out(vty
, " BGP state = %s",
13386 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13388 if (peer_established(p
))
13389 vty_out(vty
, ", up for %8s",
13390 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13393 else if (p
->status
== Active
) {
13394 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13395 vty_out(vty
, " (passive)");
13396 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13397 vty_out(vty
, " (NSF passive)");
13399 vty_out(vty
, "\n");
13402 vty_out(vty
, " Last read %s",
13403 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13405 vty_out(vty
, ", Last write %s\n",
13406 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13409 /* Configured timer values. */
13411 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13412 p
->v_holdtime
, p
->v_keepalive
);
13413 vty_out(vty
, " Configured hold time is %d seconds",
13414 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13416 : bgp
->default_holdtime
);
13417 vty_out(vty
, ", keepalive interval is %d seconds\n",
13418 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13420 : bgp
->default_keepalive
);
13421 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13423 " Configured DelayOpenTime is %d seconds\n",
13426 /* Configured and synced tcp-mss value for peer */
13427 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13428 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13429 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13430 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13433 /* Extended Optional Parameters Length for BGP OPEN Message */
13434 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13436 " Extended Optional Parameters Length is enabled\n");
13438 /* Conditional advertisements */
13440 " Configured conditional advertisements interval is %d seconds\n",
13441 bgp
->condition_check_period
);
13442 if (thread_is_scheduled(bgp
->t_condition_check
))
13444 " Time until conditional advertisements begin is %lu seconds\n",
13445 thread_timer_remain_second(
13446 bgp
->t_condition_check
));
13449 if (peer_established(p
) &&
13450 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13452 json_object
*json_cap
= NULL
;
13454 json_cap
= json_object_new_object();
13457 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13458 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13459 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13460 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13461 json_object_string_add(
13462 json_cap
, "4byteAs",
13463 "advertisedAndReceived");
13464 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13465 json_object_string_add(json_cap
,
13468 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13469 json_object_string_add(json_cap
,
13474 /* Extended Message Support */
13475 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13476 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13477 json_object_string_add(json_cap
,
13479 "advertisedAndReceived");
13480 else if (CHECK_FLAG(p
->cap
,
13481 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13482 json_object_string_add(json_cap
,
13485 else if (CHECK_FLAG(p
->cap
,
13486 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13487 json_object_string_add(json_cap
,
13492 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13493 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13494 json_object
*json_add
= NULL
;
13495 const char *print_store
;
13497 json_add
= json_object_new_object();
13499 FOREACH_AFI_SAFI (afi
, safi
) {
13500 json_object
*json_sub
= NULL
;
13501 json_sub
= json_object_new_object();
13502 print_store
= get_afi_safi_str(
13506 p
->af_cap
[afi
][safi
],
13507 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13509 p
->af_cap
[afi
][safi
],
13510 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13514 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13518 PEER_CAP_ADDPATH_AF_TX_RCV
))
13519 json_object_boolean_true_add(
13521 "txAdvertisedAndReceived");
13526 PEER_CAP_ADDPATH_AF_TX_ADV
))
13527 json_object_boolean_true_add(
13534 PEER_CAP_ADDPATH_AF_TX_RCV
))
13535 json_object_boolean_true_add(
13541 p
->af_cap
[afi
][safi
],
13542 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13544 p
->af_cap
[afi
][safi
],
13545 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13549 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13553 PEER_CAP_ADDPATH_AF_RX_RCV
))
13554 json_object_boolean_true_add(
13556 "rxAdvertisedAndReceived");
13561 PEER_CAP_ADDPATH_AF_RX_ADV
))
13562 json_object_boolean_true_add(
13569 PEER_CAP_ADDPATH_AF_RX_RCV
))
13570 json_object_boolean_true_add(
13576 p
->af_cap
[afi
][safi
],
13577 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13579 p
->af_cap
[afi
][safi
],
13580 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13582 p
->af_cap
[afi
][safi
],
13583 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13585 p
->af_cap
[afi
][safi
],
13586 PEER_CAP_ADDPATH_AF_RX_RCV
))
13587 json_object_object_add(
13588 json_add
, print_store
,
13591 json_object_free(json_sub
);
13594 json_object_object_add(json_cap
, "addPath",
13599 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13600 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13601 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13602 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13603 json_object_string_add(
13604 json_cap
, "dynamic",
13605 "advertisedAndReceived");
13606 else if (CHECK_FLAG(p
->cap
,
13607 PEER_CAP_DYNAMIC_ADV
))
13608 json_object_string_add(json_cap
,
13611 else if (CHECK_FLAG(p
->cap
,
13612 PEER_CAP_DYNAMIC_RCV
))
13613 json_object_string_add(json_cap
,
13619 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13620 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13622 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13623 json_object_string_add(
13625 "advertisedAndReceived");
13626 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13627 json_object_string_add(json_cap
, "role",
13629 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13630 json_object_string_add(json_cap
, "role",
13634 /* Extended nexthop */
13635 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13636 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13637 json_object
*json_nxt
= NULL
;
13638 const char *print_store
;
13641 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13642 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13643 json_object_string_add(
13644 json_cap
, "extendedNexthop",
13645 "advertisedAndReceived");
13646 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13647 json_object_string_add(
13648 json_cap
, "extendedNexthop",
13650 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13651 json_object_string_add(
13652 json_cap
, "extendedNexthop",
13655 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13656 json_nxt
= json_object_new_object();
13658 for (safi
= SAFI_UNICAST
;
13659 safi
< SAFI_MAX
; safi
++) {
13663 PEER_CAP_ENHE_AF_RCV
)) {
13669 json_object_string_add(
13672 "recieved"); /* misspelled for compatibility */
13675 json_object_object_add(
13677 "extendedNexthopFamililesByPeer",
13682 /* Long-lived Graceful Restart */
13683 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13684 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13685 json_object
*json_llgr
= NULL
;
13686 const char *afi_safi_str
;
13688 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13689 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13690 json_object_string_add(
13692 "longLivedGracefulRestart",
13693 "advertisedAndReceived");
13694 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13695 json_object_string_add(
13697 "longLivedGracefulRestart",
13699 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13700 json_object_string_add(
13702 "longLivedGracefulRestart",
13705 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13706 json_llgr
= json_object_new_object();
13708 FOREACH_AFI_SAFI (afi
, safi
) {
13712 PEER_CAP_ENHE_AF_RCV
)) {
13718 json_object_string_add(
13724 json_object_object_add(
13726 "longLivedGracefulRestartByPeer",
13731 /* Route Refresh */
13732 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13733 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13734 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13735 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13736 (CHECK_FLAG(p
->cap
,
13737 PEER_CAP_REFRESH_NEW_RCV
) ||
13739 PEER_CAP_REFRESH_OLD_RCV
))) {
13742 PEER_CAP_REFRESH_OLD_RCV
) &&
13745 PEER_CAP_REFRESH_NEW_RCV
))
13746 json_object_string_add(
13749 "advertisedAndReceivedOldNew");
13753 PEER_CAP_REFRESH_OLD_RCV
))
13754 json_object_string_add(
13757 "advertisedAndReceivedOld");
13759 json_object_string_add(
13762 "advertisedAndReceivedNew");
13764 } else if (CHECK_FLAG(p
->cap
,
13765 PEER_CAP_REFRESH_ADV
))
13766 json_object_string_add(json_cap
,
13769 else if (CHECK_FLAG(p
->cap
,
13770 PEER_CAP_REFRESH_NEW_RCV
) ||
13772 PEER_CAP_REFRESH_OLD_RCV
))
13773 json_object_string_add(json_cap
,
13778 /* Enhanced Route Refresh */
13779 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13780 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13781 if (CHECK_FLAG(p
->cap
,
13782 PEER_CAP_ENHANCED_RR_ADV
) &&
13784 PEER_CAP_ENHANCED_RR_RCV
))
13785 json_object_string_add(
13787 "enhancedRouteRefresh",
13788 "advertisedAndReceived");
13789 else if (CHECK_FLAG(p
->cap
,
13790 PEER_CAP_ENHANCED_RR_ADV
))
13791 json_object_string_add(
13793 "enhancedRouteRefresh",
13795 else if (CHECK_FLAG(p
->cap
,
13796 PEER_CAP_ENHANCED_RR_RCV
))
13797 json_object_string_add(
13799 "enhancedRouteRefresh",
13803 /* Multiprotocol Extensions */
13804 json_object
*json_multi
= NULL
;
13806 json_multi
= json_object_new_object();
13808 FOREACH_AFI_SAFI (afi
, safi
) {
13809 if (p
->afc_adv
[afi
][safi
] ||
13810 p
->afc_recv
[afi
][safi
]) {
13811 json_object
*json_exten
= NULL
;
13812 json_exten
= json_object_new_object();
13814 if (p
->afc_adv
[afi
][safi
] &&
13815 p
->afc_recv
[afi
][safi
])
13816 json_object_boolean_true_add(
13818 "advertisedAndReceived");
13819 else if (p
->afc_adv
[afi
][safi
])
13820 json_object_boolean_true_add(
13823 else if (p
->afc_recv
[afi
][safi
])
13824 json_object_boolean_true_add(
13825 json_exten
, "received");
13827 json_object_object_add(
13829 get_afi_safi_str(afi
, safi
,
13834 json_object_object_add(json_cap
,
13835 "multiprotocolExtensions",
13838 /* Hostname capabilities */
13839 json_object
*json_hname
= NULL
;
13841 json_hname
= json_object_new_object();
13843 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13844 json_object_string_add(
13845 json_hname
, "advHostName",
13846 bgp
->peer_self
->hostname
13847 ? bgp
->peer_self
->hostname
13849 json_object_string_add(
13850 json_hname
, "advDomainName",
13851 bgp
->peer_self
->domainname
13852 ? bgp
->peer_self
->domainname
13857 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13858 json_object_string_add(
13859 json_hname
, "rcvHostName",
13860 p
->hostname
? p
->hostname
: "n/a");
13861 json_object_string_add(
13862 json_hname
, "rcvDomainName",
13863 p
->domainname
? p
->domainname
: "n/a");
13866 json_object_object_add(json_cap
, "hostName",
13869 /* Software Version capability */
13870 json_object
*json_soft_version
= NULL
;
13872 json_soft_version
= json_object_new_object();
13874 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_ADV
))
13875 json_object_string_add(
13877 "advertisedSoftwareVersion",
13878 cmd_software_version_get());
13880 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_RCV
))
13881 json_object_string_add(
13883 "receivedSoftwareVersion",
13884 p
->soft_version
? p
->soft_version
13887 json_object_object_add(json_cap
, "softwareVersion",
13888 json_soft_version
);
13890 /* Graceful Restart */
13891 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13892 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13893 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13894 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13895 json_object_string_add(
13896 json_cap
, "gracefulRestart",
13897 "advertisedAndReceived");
13898 else if (CHECK_FLAG(p
->cap
,
13899 PEER_CAP_RESTART_ADV
))
13900 json_object_string_add(
13902 "gracefulRestartCapability",
13904 else if (CHECK_FLAG(p
->cap
,
13905 PEER_CAP_RESTART_RCV
))
13906 json_object_string_add(
13908 "gracefulRestartCapability",
13911 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13912 int restart_af_count
= 0;
13913 json_object
*json_restart
= NULL
;
13914 json_restart
= json_object_new_object();
13916 json_object_int_add(
13918 "gracefulRestartRemoteTimerMsecs",
13919 p
->v_gr_restart
* 1000);
13921 FOREACH_AFI_SAFI (afi
, safi
) {
13925 PEER_CAP_RESTART_AF_RCV
)) {
13926 json_object
*json_sub
=
13929 json_object_new_object();
13935 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13936 json_object_boolean_true_add(
13939 restart_af_count
++;
13940 json_object_object_add(
13949 if (!restart_af_count
) {
13950 json_object_string_add(
13952 "addressFamiliesByPeer",
13954 json_object_free(json_restart
);
13956 json_object_object_add(
13958 "addressFamiliesByPeer",
13962 json_object_object_add(
13963 json_neigh
, "neighborCapabilities", json_cap
);
13965 vty_out(vty
, " Neighbor capabilities:\n");
13968 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13969 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13970 vty_out(vty
, " 4 Byte AS:");
13971 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13972 vty_out(vty
, " advertised");
13973 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13974 vty_out(vty
, " %sreceived",
13979 vty_out(vty
, "\n");
13982 /* Extended Message Support */
13983 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13984 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13985 vty_out(vty
, " Extended Message:");
13986 if (CHECK_FLAG(p
->cap
,
13987 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13988 vty_out(vty
, " advertised");
13989 if (CHECK_FLAG(p
->cap
,
13990 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13991 vty_out(vty
, " %sreceived",
13994 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13997 vty_out(vty
, "\n");
14001 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
14002 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
14003 vty_out(vty
, " AddPath:\n");
14005 FOREACH_AFI_SAFI (afi
, safi
) {
14007 p
->af_cap
[afi
][safi
],
14008 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
14010 p
->af_cap
[afi
][safi
],
14011 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
14012 vty_out(vty
, " %s: TX ",
14020 PEER_CAP_ADDPATH_AF_TX_ADV
))
14027 PEER_CAP_ADDPATH_AF_TX_RCV
))
14034 PEER_CAP_ADDPATH_AF_TX_ADV
)
14038 vty_out(vty
, "\n");
14042 p
->af_cap
[afi
][safi
],
14043 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
14045 p
->af_cap
[afi
][safi
],
14046 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14047 vty_out(vty
, " %s: RX ",
14055 PEER_CAP_ADDPATH_AF_RX_ADV
))
14062 PEER_CAP_ADDPATH_AF_RX_RCV
))
14069 PEER_CAP_ADDPATH_AF_RX_ADV
)
14073 vty_out(vty
, "\n");
14079 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
14080 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
14081 vty_out(vty
, " Dynamic:");
14082 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
14083 vty_out(vty
, " advertised");
14084 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
14085 vty_out(vty
, " %sreceived",
14087 PEER_CAP_DYNAMIC_ADV
)
14090 vty_out(vty
, "\n");
14094 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
14095 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
14096 vty_out(vty
, " Role:");
14097 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
14098 vty_out(vty
, " advertised");
14099 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
14100 vty_out(vty
, " %sreceived",
14105 vty_out(vty
, "\n");
14108 /* Extended nexthop */
14109 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14110 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14111 vty_out(vty
, " Extended nexthop:");
14112 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14113 vty_out(vty
, " advertised");
14114 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14115 vty_out(vty
, " %sreceived",
14120 vty_out(vty
, "\n");
14122 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14124 " Address families by peer:\n ");
14125 for (safi
= SAFI_UNICAST
;
14126 safi
< SAFI_MAX
; safi
++)
14130 PEER_CAP_ENHE_AF_RCV
))
14140 /* Long-lived Graceful Restart */
14141 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14142 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14144 " Long-lived Graceful Restart:");
14145 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14146 vty_out(vty
, " advertised");
14147 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14148 vty_out(vty
, " %sreceived",
14153 vty_out(vty
, "\n");
14155 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14157 " Address families by peer:\n");
14158 FOREACH_AFI_SAFI (afi
, safi
)
14162 PEER_CAP_LLGR_AF_RCV
))
14172 /* Route Refresh */
14173 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14174 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14175 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14176 vty_out(vty
, " Route refresh:");
14177 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14178 vty_out(vty
, " advertised");
14179 if (CHECK_FLAG(p
->cap
,
14180 PEER_CAP_REFRESH_NEW_RCV
) ||
14182 PEER_CAP_REFRESH_OLD_RCV
))
14183 vty_out(vty
, " %sreceived(%s)",
14185 PEER_CAP_REFRESH_ADV
)
14190 PEER_CAP_REFRESH_OLD_RCV
) &&
14193 PEER_CAP_REFRESH_NEW_RCV
))
14197 PEER_CAP_REFRESH_OLD_RCV
)
14201 vty_out(vty
, "\n");
14204 /* Enhanced Route Refresh */
14205 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14206 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14207 vty_out(vty
, " Enhanced Route Refresh:");
14208 if (CHECK_FLAG(p
->cap
,
14209 PEER_CAP_ENHANCED_RR_ADV
))
14210 vty_out(vty
, " advertised");
14211 if (CHECK_FLAG(p
->cap
,
14212 PEER_CAP_ENHANCED_RR_RCV
))
14213 vty_out(vty
, " %sreceived",
14215 PEER_CAP_REFRESH_ADV
)
14218 vty_out(vty
, "\n");
14221 /* Multiprotocol Extensions */
14222 FOREACH_AFI_SAFI (afi
, safi
)
14223 if (p
->afc_adv
[afi
][safi
] ||
14224 p
->afc_recv
[afi
][safi
]) {
14225 vty_out(vty
, " Address Family %s:",
14226 get_afi_safi_str(afi
, safi
,
14228 if (p
->afc_adv
[afi
][safi
])
14229 vty_out(vty
, " advertised");
14230 if (p
->afc_recv
[afi
][safi
])
14231 vty_out(vty
, " %sreceived",
14232 p
->afc_adv
[afi
][safi
]
14235 vty_out(vty
, "\n");
14238 /* Hostname capability */
14239 vty_out(vty
, " Hostname Capability:");
14241 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14243 " advertised (name: %s,domain name: %s)",
14244 bgp
->peer_self
->hostname
14245 ? bgp
->peer_self
->hostname
14247 bgp
->peer_self
->domainname
14248 ? bgp
->peer_self
->domainname
14251 vty_out(vty
, " not advertised");
14254 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14256 " received (name: %s,domain name: %s)",
14257 p
->hostname
? p
->hostname
: "n/a",
14258 p
->domainname
? p
->domainname
: "n/a");
14260 vty_out(vty
, " not received");
14263 vty_out(vty
, "\n");
14265 /* Software Version capability */
14266 vty_out(vty
, " Version Capability:");
14268 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_ADV
)) {
14270 " advertised software version (%s)",
14271 cmd_software_version_get());
14273 vty_out(vty
, " not advertised");
14275 if (CHECK_FLAG(p
->cap
, PEER_CAP_SOFT_VERSION_RCV
)) {
14276 vty_out(vty
, " received software version (%s)",
14277 p
->soft_version
? p
->soft_version
14280 vty_out(vty
, " not received");
14282 vty_out(vty
, "\n");
14284 /* Graceful Restart */
14285 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14286 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14288 " Graceful Restart Capability:");
14289 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14290 vty_out(vty
, " advertised");
14291 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14292 vty_out(vty
, " %sreceived",
14294 PEER_CAP_RESTART_ADV
)
14297 vty_out(vty
, "\n");
14299 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14300 int restart_af_count
= 0;
14303 " Remote Restart timer is %d seconds\n",
14306 " Address families by peer:\n ");
14308 FOREACH_AFI_SAFI (afi
, safi
)
14312 PEER_CAP_RESTART_AF_RCV
)) {
14313 vty_out(vty
, "%s%s(%s)",
14325 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14327 : "not preserved");
14328 restart_af_count
++;
14330 if (!restart_af_count
)
14331 vty_out(vty
, "none");
14332 vty_out(vty
, "\n");
14334 } /* Graceful Restart */
14338 /* graceful restart information */
14339 json_object
*json_grace
= NULL
;
14340 json_object
*json_grace_send
= NULL
;
14341 json_object
*json_grace_recv
= NULL
;
14342 int eor_send_af_count
= 0;
14343 int eor_receive_af_count
= 0;
14346 json_grace
= json_object_new_object();
14347 json_grace_send
= json_object_new_object();
14348 json_grace_recv
= json_object_new_object();
14350 if ((peer_established(p
)) &&
14351 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14352 FOREACH_AFI_SAFI (afi
, safi
) {
14353 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14354 PEER_STATUS_EOR_SEND
)) {
14355 json_object_boolean_true_add(
14357 get_afi_safi_str(afi
, safi
,
14359 eor_send_af_count
++;
14362 FOREACH_AFI_SAFI (afi
, safi
) {
14363 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14364 PEER_STATUS_EOR_RECEIVED
)) {
14365 json_object_boolean_true_add(
14367 get_afi_safi_str(afi
, safi
,
14369 eor_receive_af_count
++;
14373 json_object_object_add(json_grace
, "endOfRibSend",
14375 json_object_object_add(json_grace
, "endOfRibRecv",
14379 if (p
->t_gr_restart
)
14380 json_object_int_add(
14381 json_grace
, "gracefulRestartTimerMsecs",
14382 thread_timer_remain_second(p
->t_gr_restart
) *
14386 json_object_int_add(
14387 json_grace
, "gracefulStalepathTimerMsecs",
14388 thread_timer_remain_second(p
->t_gr_stale
) *
14390 /* more gr info in new format */
14391 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14392 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14395 vty_out(vty
, " Graceful restart information:\n");
14396 if ((peer_established(p
)) &&
14397 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14399 vty_out(vty
, " End-of-RIB send: ");
14400 FOREACH_AFI_SAFI (afi
, safi
) {
14401 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14402 PEER_STATUS_EOR_SEND
)) {
14403 vty_out(vty
, "%s%s",
14404 eor_send_af_count
? ", " : "",
14405 get_afi_safi_str(afi
, safi
,
14407 eor_send_af_count
++;
14410 vty_out(vty
, "\n");
14411 vty_out(vty
, " End-of-RIB received: ");
14412 FOREACH_AFI_SAFI (afi
, safi
) {
14413 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14414 PEER_STATUS_EOR_RECEIVED
)) {
14415 vty_out(vty
, "%s%s",
14416 eor_receive_af_count
? ", "
14418 get_afi_safi_str(afi
, safi
,
14420 eor_receive_af_count
++;
14423 vty_out(vty
, "\n");
14426 if (p
->t_gr_restart
)
14428 " The remaining time of restart timer is %ld\n",
14429 thread_timer_remain_second(p
->t_gr_restart
));
14433 " The remaining time of stalepath timer is %ld\n",
14434 thread_timer_remain_second(p
->t_gr_stale
));
14436 /* more gr info in new format */
14437 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14441 json_object
*json_stat
= NULL
;
14442 json_stat
= json_object_new_object();
14443 /* Packet counts. */
14445 atomic_size_t outq_count
, inq_count
;
14446 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14447 memory_order_relaxed
);
14448 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14449 memory_order_relaxed
);
14451 json_object_int_add(json_stat
, "depthInq",
14452 (unsigned long)inq_count
);
14453 json_object_int_add(json_stat
, "depthOutq",
14454 (unsigned long)outq_count
);
14455 json_object_int_add(json_stat
, "opensSent",
14456 atomic_load_explicit(&p
->open_out
,
14457 memory_order_relaxed
));
14458 json_object_int_add(json_stat
, "opensRecv",
14459 atomic_load_explicit(&p
->open_in
,
14460 memory_order_relaxed
));
14461 json_object_int_add(json_stat
, "notificationsSent",
14462 atomic_load_explicit(&p
->notify_out
,
14463 memory_order_relaxed
));
14464 json_object_int_add(json_stat
, "notificationsRecv",
14465 atomic_load_explicit(&p
->notify_in
,
14466 memory_order_relaxed
));
14467 json_object_int_add(json_stat
, "updatesSent",
14468 atomic_load_explicit(&p
->update_out
,
14469 memory_order_relaxed
));
14470 json_object_int_add(json_stat
, "updatesRecv",
14471 atomic_load_explicit(&p
->update_in
,
14472 memory_order_relaxed
));
14473 json_object_int_add(json_stat
, "keepalivesSent",
14474 atomic_load_explicit(&p
->keepalive_out
,
14475 memory_order_relaxed
));
14476 json_object_int_add(json_stat
, "keepalivesRecv",
14477 atomic_load_explicit(&p
->keepalive_in
,
14478 memory_order_relaxed
));
14479 json_object_int_add(json_stat
, "routeRefreshSent",
14480 atomic_load_explicit(&p
->refresh_out
,
14481 memory_order_relaxed
));
14482 json_object_int_add(json_stat
, "routeRefreshRecv",
14483 atomic_load_explicit(&p
->refresh_in
,
14484 memory_order_relaxed
));
14485 json_object_int_add(json_stat
, "capabilitySent",
14486 atomic_load_explicit(&p
->dynamic_cap_out
,
14487 memory_order_relaxed
));
14488 json_object_int_add(json_stat
, "capabilityRecv",
14489 atomic_load_explicit(&p
->dynamic_cap_in
,
14490 memory_order_relaxed
));
14491 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14492 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14493 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14495 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14496 notify_out
, notify_in
, update_out
, update_in
,
14497 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14498 dynamic_cap_out
, dynamic_cap_in
;
14499 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14500 memory_order_relaxed
);
14501 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14502 memory_order_relaxed
);
14503 open_out
= atomic_load_explicit(&p
->open_out
,
14504 memory_order_relaxed
);
14506 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14507 notify_out
= atomic_load_explicit(&p
->notify_out
,
14508 memory_order_relaxed
);
14509 notify_in
= atomic_load_explicit(&p
->notify_in
,
14510 memory_order_relaxed
);
14511 update_out
= atomic_load_explicit(&p
->update_out
,
14512 memory_order_relaxed
);
14513 update_in
= atomic_load_explicit(&p
->update_in
,
14514 memory_order_relaxed
);
14515 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14516 memory_order_relaxed
);
14517 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14518 memory_order_relaxed
);
14519 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14520 memory_order_relaxed
);
14521 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14522 memory_order_relaxed
);
14523 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14524 memory_order_relaxed
);
14525 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14526 memory_order_relaxed
);
14528 /* Packet counts. */
14529 vty_out(vty
, " Message statistics:\n");
14530 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14531 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14532 vty_out(vty
, " Sent Rcvd\n");
14533 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14535 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14537 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14539 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14541 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14543 vty_out(vty
, " Capability: %10zu %10zu\n",
14544 dynamic_cap_out
, dynamic_cap_in
);
14545 vty_out(vty
, " Total: %10u %10u\n",
14546 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14550 /* advertisement-interval */
14551 json_object_int_add(json_neigh
,
14552 "minBtwnAdvertisementRunsTimerMsecs",
14553 p
->v_routeadv
* 1000);
14555 /* Update-source. */
14556 if (p
->update_if
|| p
->update_source
) {
14558 json_object_string_add(json_neigh
,
14561 else if (p
->update_source
)
14562 json_object_string_addf(json_neigh
,
14563 "updateSource", "%pSU",
14567 /* advertisement-interval */
14569 " Minimum time between advertisement runs is %d seconds\n",
14572 /* Update-source. */
14573 if (p
->update_if
|| p
->update_source
) {
14574 vty_out(vty
, " Update source is ");
14576 vty_out(vty
, "%s", p
->update_if
);
14577 else if (p
->update_source
)
14578 vty_out(vty
, "%pSU", p
->update_source
);
14579 vty_out(vty
, "\n");
14582 vty_out(vty
, "\n");
14585 /* Address Family Information */
14586 json_object
*json_hold
= NULL
;
14589 json_hold
= json_object_new_object();
14591 FOREACH_AFI_SAFI (afi
, safi
)
14592 if (p
->afc
[afi
][safi
])
14593 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14597 json_object_object_add(json_neigh
, "addressFamilyInfo",
14599 json_object_int_add(json_neigh
, "connectionsEstablished",
14601 json_object_int_add(json_neigh
, "connectionsDropped",
14604 vty_out(vty
, " Connections established %d; dropped %d\n",
14605 p
->established
, p
->dropped
);
14607 if (!p
->last_reset
) {
14609 json_object_string_add(json_neigh
, "lastReset",
14612 vty_out(vty
, " Last reset never\n");
14618 uptime
= monotime(NULL
);
14619 uptime
-= p
->resettime
;
14620 gmtime_r(&uptime
, &tm
);
14622 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14624 + (tm
.tm_min
* 60000)
14625 + (tm
.tm_hour
* 3600000));
14626 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14628 vty_out(vty
, " Last reset %s, ",
14629 peer_uptime(p
->resettime
, timebuf
,
14630 BGP_UPTIME_LEN
, 0, NULL
));
14632 bgp_show_peer_reset(vty
, p
, NULL
, false);
14633 if (p
->last_reset_cause_size
) {
14634 msg
= p
->last_reset_cause
;
14636 " Message received that caused BGP to send a NOTIFICATION:\n ");
14637 for (i
= 1; i
<= p
->last_reset_cause_size
;
14639 vty_out(vty
, "%02X", *msg
++);
14641 if (i
!= p
->last_reset_cause_size
) {
14643 vty_out(vty
, "\n ");
14644 } else if (i
% 4 == 0) {
14649 vty_out(vty
, "\n");
14654 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14656 json_object_boolean_true_add(json_neigh
,
14657 "prefixesConfigExceedMax");
14660 " Peer had exceeded the max. no. of prefixes configured.\n");
14662 if (p
->t_pmax_restart
) {
14664 json_object_boolean_true_add(
14665 json_neigh
, "reducePrefixNumFrom");
14666 json_object_int_add(json_neigh
,
14667 "restartInTimerMsec",
14668 thread_timer_remain_second(
14673 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14674 p
->host
, thread_timer_remain_second(
14675 p
->t_pmax_restart
));
14678 json_object_boolean_true_add(
14680 "reducePrefixNumAndClearIpBgp");
14683 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14688 /* EBGP Multihop and GTSM */
14689 if (p
->sort
!= BGP_PEER_IBGP
) {
14691 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14692 json_object_int_add(json_neigh
,
14693 "externalBgpNbrMaxHopsAway",
14696 json_object_int_add(json_neigh
,
14697 "externalBgpNbrMaxHopsAway",
14700 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14702 " External BGP neighbor may be up to %d hops away.\n",
14706 " External BGP neighbor may be up to %d hops away.\n",
14711 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14712 json_object_int_add(json_neigh
,
14713 "internalBgpNbrMaxHopsAway",
14716 json_object_int_add(json_neigh
,
14717 "internalBgpNbrMaxHopsAway",
14720 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14722 " Internal BGP neighbor may be up to %d hops away.\n",
14726 " Internal BGP neighbor may be up to %d hops away.\n",
14731 /* Local address. */
14734 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14736 json_object_int_add(json_neigh
, "portLocal",
14737 ntohs(p
->su_local
->sin
.sin_port
));
14739 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14740 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14743 json_object_string_add(json_neigh
, "hostLocal",
14745 json_object_int_add(json_neigh
, "portLocal", -1);
14749 /* Remote address. */
14750 if (p
->su_remote
) {
14752 json_object_string_addf(json_neigh
, "hostForeign",
14753 "%pSU", p
->su_remote
);
14754 json_object_int_add(json_neigh
, "portForeign",
14755 ntohs(p
->su_remote
->sin
.sin_port
));
14757 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14759 ntohs(p
->su_remote
->sin
.sin_port
));
14762 json_object_string_add(json_neigh
, "hostForeign",
14764 json_object_int_add(json_neigh
, "portForeign", -1);
14768 /* Nexthop display. */
14771 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14773 json_object_string_addf(json_neigh
, "nexthopGlobal",
14774 "%pI6", &p
->nexthop
.v6_global
);
14775 json_object_string_addf(json_neigh
, "nexthopLocal",
14776 "%pI6", &p
->nexthop
.v6_local
);
14777 if (p
->shared_network
)
14778 json_object_string_add(json_neigh
,
14782 json_object_string_add(json_neigh
,
14784 "nonSharedNetwork");
14786 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14787 vty_out(vty
, "Nexthop global: %pI6\n",
14788 &p
->nexthop
.v6_global
);
14789 vty_out(vty
, "Nexthop local: %pI6\n",
14790 &p
->nexthop
.v6_local
);
14791 vty_out(vty
, "BGP connection: %s\n",
14792 p
->shared_network
? "shared network"
14793 : "non shared network");
14797 json_object_string_add(json_neigh
, "nexthop",
14799 json_object_string_add(json_neigh
, "nexthopGlobal",
14801 json_object_string_add(json_neigh
, "nexthopLocal",
14803 json_object_string_add(json_neigh
, "bgpConnection",
14808 /* Timer information. */
14810 json_object_int_add(json_neigh
, "connectRetryTimer",
14812 if (peer_established(p
)) {
14813 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14815 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14816 json_object_int_add(json_neigh
,
14817 "shutdownRttInMsecs",
14819 json_object_int_add(json_neigh
,
14820 "shutdownRttAfterCount",
14821 p
->rtt_keepalive_rcv
);
14825 json_object_int_add(
14826 json_neigh
, "nextStartTimerDueInMsecs",
14827 thread_timer_remain_second(p
->t_start
) * 1000);
14829 json_object_int_add(
14830 json_neigh
, "nextConnectTimerDueInMsecs",
14831 thread_timer_remain_second(p
->t_connect
)
14833 if (p
->t_routeadv
) {
14834 json_object_int_add(json_neigh
, "mraiInterval",
14836 json_object_int_add(
14837 json_neigh
, "mraiTimerExpireInMsecs",
14838 thread_timer_remain_second(p
->t_routeadv
)
14842 json_object_int_add(json_neigh
, "authenticationEnabled",
14846 json_object_string_add(json_neigh
, "readThread", "on");
14848 json_object_string_add(json_neigh
, "readThread", "off");
14850 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14851 json_object_string_add(json_neigh
, "writeThread", "on");
14853 json_object_string_add(json_neigh
, "writeThread",
14856 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14858 if (peer_established(p
)) {
14859 vty_out(vty
, "Estimated round trip time: %d ms\n",
14861 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14863 "Shutdown when RTT > %dms, count > %u\n",
14864 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14867 vty_out(vty
, "Next start timer due in %ld seconds\n",
14868 thread_timer_remain_second(p
->t_start
));
14870 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14871 thread_timer_remain_second(p
->t_connect
));
14874 "MRAI (interval %u) timer expires in %ld seconds\n",
14876 thread_timer_remain_second(p
->t_routeadv
));
14878 vty_out(vty
, "Peer Authentication Enabled\n");
14880 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14881 p
->t_read
? "on" : "off",
14882 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14887 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14888 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14889 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14892 vty_out(vty
, "\n");
14894 /* BFD information. */
14896 bgp_bfd_show_info(vty
, p
, json_neigh
);
14899 if (p
->conf_if
) /* Configured interface name. */
14900 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14901 else /* Configured IP address. */
14902 json_object_object_add(json
, p
->host
, json_neigh
);
14906 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14907 enum show_type type
,
14908 union sockunion
*su
,
14909 const char *conf_if
, afi_t afi
,
14912 struct listnode
*node
, *nnode
;
14914 bool found
= false;
14915 safi_t safi
= SAFI_UNICAST
;
14916 json_object
*json_neighbor
= NULL
;
14918 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14920 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14923 if ((peer
->afc
[afi
][safi
]) == 0)
14927 json_neighbor
= json_object_new_object();
14929 if (type
== show_all
) {
14930 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14933 json_object_object_add(json
, peer
->host
,
14936 } else if (type
== show_peer
) {
14939 && !strcmp(peer
->conf_if
, conf_if
))
14941 && !strcmp(peer
->hostname
, conf_if
))) {
14943 bgp_show_peer_gr_status(vty
, peer
,
14947 if (sockunion_same(&peer
->su
, su
)) {
14949 bgp_show_peer_gr_status(vty
, peer
,
14955 json_object_object_add(json
, peer
->host
,
14958 json_object_free(json_neighbor
);
14966 if (type
== show_peer
&& !found
) {
14968 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14970 vty_out(vty
, "%% No such neighbor\n");
14974 vty_out(vty
, "\n");
14976 return CMD_SUCCESS
;
14979 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14980 enum show_type type
, union sockunion
*su
,
14981 const char *conf_if
, bool use_json
,
14984 struct listnode
*node
, *nnode
;
14987 bool nbr_output
= false;
14988 afi_t afi
= AFI_MAX
;
14989 safi_t safi
= SAFI_MAX
;
14991 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14993 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14997 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14998 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15003 bgp_show_peer(vty
, peer
, use_json
, json
);
15009 && !strcmp(peer
->conf_if
, conf_if
))
15011 && !strcmp(peer
->hostname
, conf_if
))) {
15013 bgp_show_peer(vty
, peer
, use_json
,
15017 if (sockunion_same(&peer
->su
, su
)) {
15019 bgp_show_peer(vty
, peer
, use_json
,
15024 case show_ipv4_peer
:
15025 case show_ipv6_peer
:
15026 FOREACH_SAFI (safi
) {
15027 if (peer
->afc
[afi
][safi
]) {
15030 && !strcmp(peer
->conf_if
, conf_if
))
15032 && !strcmp(peer
->hostname
, conf_if
))) {
15034 bgp_show_peer(vty
, peer
, use_json
,
15039 if (sockunion_same(&peer
->su
, su
)) {
15041 bgp_show_peer(vty
, peer
, use_json
,
15049 case show_ipv4_all
:
15050 case show_ipv6_all
:
15051 FOREACH_SAFI (safi
) {
15052 if (peer
->afc
[afi
][safi
]) {
15053 bgp_show_peer(vty
, peer
, use_json
, json
);
15062 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15063 type
== show_ipv6_peer
) && !find
) {
15065 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15067 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15070 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15071 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15072 vty_out(vty
, "%% No BGP neighbors found\n");
15075 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15076 json
, JSON_C_TO_STRING_PRETTY
));
15078 vty_out(vty
, "\n");
15081 return CMD_SUCCESS
;
15084 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15085 enum show_type type
,
15086 const char *ip_str
,
15087 afi_t afi
, json_object
*json
)
15092 union sockunion su
;
15094 bgp
= bgp_get_default();
15100 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
15103 ret
= str2sockunion(ip_str
, &su
);
15105 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
15106 ip_str
, afi
, json
);
15108 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15111 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15115 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15116 enum show_type type
,
15117 const char *ip_str
,
15120 struct listnode
*node
, *nnode
;
15122 union sockunion su
;
15123 json_object
*json
= NULL
;
15124 int ret
, is_first
= 1;
15125 bool nbr_output
= false;
15128 vty_out(vty
, "{\n");
15130 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15133 if (!(json
= json_object_new_object())) {
15135 EC_BGP_JSON_MEM_ERROR
,
15136 "Unable to allocate memory for JSON object");
15138 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15142 json_object_int_add(json
, "vrfId",
15143 (bgp
->vrf_id
== VRF_UNKNOWN
)
15145 : (int64_t)bgp
->vrf_id
);
15146 json_object_string_add(
15148 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15153 vty_out(vty
, ",\n");
15157 vty_out(vty
, "\"%s\":",
15158 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15162 vty_out(vty
, "\nInstance %s:\n",
15163 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15168 if (type
== show_peer
|| type
== show_ipv4_peer
||
15169 type
== show_ipv6_peer
) {
15170 ret
= str2sockunion(ip_str
, &su
);
15172 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15175 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15178 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15181 json_object_free(json
);
15186 vty_out(vty
, "}\n");
15187 else if (!nbr_output
)
15188 vty_out(vty
, "%% BGP instance not found\n");
15191 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15192 enum show_type type
, const char *ip_str
,
15197 union sockunion su
;
15198 json_object
*json
= NULL
;
15201 if (strmatch(name
, "all")) {
15202 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15204 return CMD_SUCCESS
;
15206 bgp
= bgp_lookup_by_name(name
);
15209 json
= json_object_new_object();
15210 vty_json(vty
, json
);
15213 "%% BGP instance not found\n");
15215 return CMD_WARNING
;
15219 bgp
= bgp_get_default();
15223 json
= json_object_new_object();
15225 ret
= str2sockunion(ip_str
, &su
);
15227 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15230 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15233 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15236 json_object_free(json
);
15239 vty_out(vty
, "{}\n");
15241 vty_out(vty
, "%% BGP instance not found\n");
15244 return CMD_SUCCESS
;
15249 /* "show [ip] bgp neighbors graceful-restart" commands. */
15250 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15251 show_ip_bgp_neighbors_graceful_restart_cmd
,
15252 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15258 "Neighbor to display information about\n"
15259 "Neighbor to display information about\n"
15260 "Neighbor on BGP configured interface\n"
15264 char *sh_arg
= NULL
;
15265 enum show_type sh_type
;
15267 afi_t afi
= AFI_MAX
;
15268 bool uj
= use_json(argc
, argv
);
15270 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15275 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15276 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15277 || argv_find(argv
, argc
, "WORD", &idx
)) {
15278 sh_type
= show_peer
;
15279 sh_arg
= argv
[idx
]->arg
;
15281 sh_type
= show_all
;
15283 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15284 return CMD_SUCCESS
;
15287 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15291 /* "show [ip] bgp neighbors" commands. */
15292 DEFUN (show_ip_bgp_neighbors
,
15293 show_ip_bgp_neighbors_cmd
,
15294 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15298 BGP_INSTANCE_HELP_STR
15301 "Detailed information on TCP and BGP neighbor connections\n"
15302 "Neighbor to display information about\n"
15303 "Neighbor to display information about\n"
15304 "Neighbor on BGP configured interface\n"
15308 char *sh_arg
= NULL
;
15309 enum show_type sh_type
;
15310 afi_t afi
= AFI_MAX
;
15312 bool uj
= use_json(argc
, argv
);
15316 /* [<vrf> VIEWVRFNAME] */
15317 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15318 vrf
= argv
[idx
+ 1]->arg
;
15319 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15321 } else if (argv_find(argv
, argc
, "view", &idx
))
15322 /* [<view> VIEWVRFNAME] */
15323 vrf
= argv
[idx
+ 1]->arg
;
15327 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15328 sh_type
= show_ipv4_all
;
15330 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15331 sh_type
= show_ipv6_all
;
15334 sh_type
= show_all
;
15337 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15338 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15339 || argv_find(argv
, argc
, "WORD", &idx
)) {
15340 sh_type
= show_peer
;
15341 sh_arg
= argv
[idx
]->arg
;
15344 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15345 sh_type
= show_ipv4_peer
;
15346 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15347 sh_type
= show_ipv6_peer
;
15350 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15353 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15354 paths' and `show ip mbgp paths'. Those functions results are the
15356 DEFUN (show_ip_bgp_paths
,
15357 show_ip_bgp_paths_cmd
,
15358 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15363 "Path information\n")
15365 vty_out(vty
, "Address Refcnt Path\n");
15366 aspath_print_all_vty(vty
);
15367 return CMD_SUCCESS
;
15372 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15375 struct community
*com
;
15377 com
= (struct community
*)bucket
->data
;
15378 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15379 community_str(com
, false, false));
15382 /* Show BGP's community internal data. */
15383 DEFUN (show_ip_bgp_community_info
,
15384 show_ip_bgp_community_info_cmd
,
15385 "show [ip] bgp community-info",
15389 "List all bgp community information\n")
15391 vty_out(vty
, "Address Refcnt Community\n");
15393 hash_iterate(community_hash(),
15394 (void (*)(struct hash_bucket
*,
15395 void *))community_show_all_iterator
,
15398 return CMD_SUCCESS
;
15401 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15404 struct lcommunity
*lcom
;
15406 lcom
= (struct lcommunity
*)bucket
->data
;
15407 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15408 lcommunity_str(lcom
, false, false));
15411 /* Show BGP's community internal data. */
15412 DEFUN (show_ip_bgp_lcommunity_info
,
15413 show_ip_bgp_lcommunity_info_cmd
,
15414 "show ip bgp large-community-info",
15418 "List all bgp large-community information\n")
15420 vty_out(vty
, "Address Refcnt Large-community\n");
15422 hash_iterate(lcommunity_hash(),
15423 (void (*)(struct hash_bucket
*,
15424 void *))lcommunity_show_all_iterator
,
15427 return CMD_SUCCESS
;
15429 /* Graceful Restart */
15431 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15436 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15438 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15440 switch (bgp_global_gr_mode
) {
15442 case GLOBAL_HELPER
:
15443 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15447 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15450 case GLOBAL_DISABLE
:
15451 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15454 case GLOBAL_INVALID
:
15456 "Global BGP GR Mode Invalid\n");
15459 vty_out(vty
, "\n");
15462 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15463 enum show_type type
,
15464 const char *ip_str
,
15465 afi_t afi
, bool use_json
)
15467 json_object
*json
= NULL
;
15470 json
= json_object_new_object();
15472 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15475 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15477 bgp_show_neighbor_graceful_restart_vty(
15478 vty
, type
, ip_str
, afi
, json
);
15481 } else if (afi
!= AFI_MAX
) {
15482 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15486 json_object_free(json
);
15487 return CMD_ERR_INCOMPLETE
;
15491 vty_json(vty
, json
);
15493 return CMD_SUCCESS
;
15495 /* Graceful Restart */
15497 DEFUN (show_ip_bgp_attr_info
,
15498 show_ip_bgp_attr_info_cmd
,
15499 "show [ip] bgp attribute-info",
15503 "List all bgp attribute information\n")
15505 attr_show_all(vty
);
15506 return CMD_SUCCESS
;
15509 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15510 afi_t afi
, safi_t safi
,
15511 bool use_json
, json_object
*json
)
15514 struct listnode
*node
;
15517 enum vpn_policy_direction dir
;
15520 json_object
*json_import_vrfs
= NULL
;
15521 json_object
*json_export_vrfs
= NULL
;
15523 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15526 vty_json(vty
, json
);
15528 return CMD_WARNING
;
15531 /* Provide context for the block */
15532 json_object_string_add(json
, "vrf", name
? name
: "default");
15533 json_object_string_add(json
, "afiSafi",
15534 get_afi_safi_str(afi
, safi
, true));
15536 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15537 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15538 json_object_string_add(json
, "importFromVrfs", "none");
15539 json_object_string_add(json
, "importRts", "none");
15541 json_import_vrfs
= json_object_new_array();
15543 for (ALL_LIST_ELEMENTS_RO(
15544 bgp
->vpn_policy
[afi
].import_vrf
,
15546 json_object_array_add(json_import_vrfs
,
15547 json_object_new_string(vname
));
15549 json_object_object_add(json
, "importFromVrfs",
15551 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15552 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15553 ecom_str
= ecommunity_ecom2str(
15554 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15555 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15556 json_object_string_add(json
, "importRts",
15558 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15560 json_object_string_add(json
, "importRts",
15564 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15565 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15566 json_object_string_add(json
, "exportToVrfs", "none");
15567 json_object_string_add(json
, "routeDistinguisher",
15569 json_object_string_add(json
, "exportRts", "none");
15571 json_export_vrfs
= json_object_new_array();
15573 for (ALL_LIST_ELEMENTS_RO(
15574 bgp
->vpn_policy
[afi
].export_vrf
,
15576 json_object_array_add(json_export_vrfs
,
15577 json_object_new_string(vname
));
15578 json_object_object_add(json
, "exportToVrfs",
15580 json_object_string_addf(json
, "routeDistinguisher",
15582 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15584 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15585 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15586 ecom_str
= ecommunity_ecom2str(
15587 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15588 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15589 json_object_string_add(json
, "exportRts",
15591 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15593 json_object_string_add(json
, "exportRts",
15598 vty_json(vty
, json
);
15601 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15604 vty_out(vty
, "%% No such BGP instance exist\n");
15605 return CMD_WARNING
;
15608 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15609 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15611 "This VRF is not importing %s routes from any other VRF\n",
15612 get_afi_safi_str(afi
, safi
, false));
15615 "This VRF is importing %s routes from the following VRFs:\n",
15616 get_afi_safi_str(afi
, safi
, false));
15618 for (ALL_LIST_ELEMENTS_RO(
15619 bgp
->vpn_policy
[afi
].import_vrf
,
15621 vty_out(vty
, " %s\n", vname
);
15623 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15625 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15626 ecom_str
= ecommunity_ecom2str(
15627 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15628 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15629 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15631 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15633 vty_out(vty
, "Import RT(s):\n");
15636 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15637 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15639 "This VRF is not exporting %s routes to any other VRF\n",
15640 get_afi_safi_str(afi
, safi
, false));
15643 "This VRF is exporting %s routes to the following VRFs:\n",
15644 get_afi_safi_str(afi
, safi
, false));
15646 for (ALL_LIST_ELEMENTS_RO(
15647 bgp
->vpn_policy
[afi
].export_vrf
,
15649 vty_out(vty
, " %s\n", vname
);
15651 vty_out(vty
, "RD: %pRD\n",
15652 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15654 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15655 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15656 ecom_str
= ecommunity_ecom2str(
15657 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15658 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15659 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15660 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15662 vty_out(vty
, "Import RT(s):\n");
15666 return CMD_SUCCESS
;
15669 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15670 safi_t safi
, bool use_json
)
15672 struct listnode
*node
, *nnode
;
15674 char *vrf_name
= NULL
;
15675 json_object
*json
= NULL
;
15676 json_object
*json_vrf
= NULL
;
15677 json_object
*json_vrfs
= NULL
;
15680 json
= json_object_new_object();
15681 json_vrfs
= json_object_new_object();
15684 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15686 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15687 vrf_name
= bgp
->name
;
15690 json_vrf
= json_object_new_object();
15692 vty_out(vty
, "\nInstance %s:\n",
15693 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15694 ? VRF_DEFAULT_NAME
: bgp
->name
);
15696 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15698 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15699 json_object_object_add(json_vrfs
,
15700 VRF_DEFAULT_NAME
, json_vrf
);
15702 json_object_object_add(json_vrfs
, vrf_name
,
15708 json_object_object_add(json
, "vrfs", json_vrfs
);
15709 vty_json(vty
, json
);
15712 return CMD_SUCCESS
;
15715 /* "show [ip] bgp route-leak" command. */
15716 DEFUN (show_ip_bgp_route_leak
,
15717 show_ip_bgp_route_leak_cmd
,
15718 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15722 BGP_INSTANCE_HELP_STR
15725 "Route leaking information\n"
15729 afi_t afi
= AFI_MAX
;
15730 safi_t safi
= SAFI_MAX
;
15732 bool uj
= use_json(argc
, argv
);
15734 json_object
*json
= NULL
;
15736 /* show [ip] bgp */
15737 if (argv_find(argv
, argc
, "ip", &idx
)) {
15739 safi
= SAFI_UNICAST
;
15741 /* [vrf VIEWVRFNAME] */
15742 if (argv_find(argv
, argc
, "view", &idx
)) {
15744 "%% This command is not applicable to BGP views\n");
15745 return CMD_WARNING
;
15748 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15749 vrf
= argv
[idx
+ 1]->arg
;
15750 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15753 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15754 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15755 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15757 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15759 "%% This command is applicable only for unicast ipv4|ipv6\n");
15760 return CMD_WARNING
;
15763 if (vrf
&& strmatch(vrf
, "all"))
15764 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15767 json
= json_object_new_object();
15769 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15772 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15773 safi_t safi
, bool uj
)
15775 struct listnode
*node
, *nnode
;
15778 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15780 vty_out(vty
, "\nInstance %s:\n",
15781 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15785 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15789 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15790 int safi
, uint64_t subgrp_id
, bool uj
)
15795 if (strmatch(name
, "all")) {
15796 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15797 return CMD_SUCCESS
;
15799 bgp
= bgp_lookup_by_name(name
);
15802 bgp
= bgp_get_default();
15806 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15807 return CMD_SUCCESS
;
15810 DEFUN (show_ip_bgp_updgrps
,
15811 show_ip_bgp_updgrps_cmd
,
15812 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15816 BGP_INSTANCE_HELP_STR
15818 BGP_SAFI_WITH_LABEL_HELP_STR
15819 "Detailed info about dynamic update groups\n"
15820 "Specific subgroup to display detailed info for\n"
15824 afi_t afi
= AFI_IP6
;
15825 safi_t safi
= SAFI_UNICAST
;
15826 uint64_t subgrp_id
= 0;
15830 bool uj
= use_json(argc
, argv
);
15832 /* show [ip] bgp */
15833 if (argv_find(argv
, argc
, "ip", &idx
))
15835 /* [<vrf> VIEWVRFNAME] */
15836 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15837 vrf
= argv
[idx
+ 1]->arg
;
15838 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15840 } else if (argv_find(argv
, argc
, "view", &idx
))
15841 /* [<view> VIEWVRFNAME] */
15842 vrf
= argv
[idx
+ 1]->arg
;
15843 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15844 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15845 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15848 /* get subgroup id, if provided */
15850 if (argv
[idx
]->type
== VARIABLE_TKN
)
15851 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15853 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15856 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15857 show_bgp_instance_all_ipv6_updgrps_cmd
,
15858 "show [ip] bgp <view|vrf> all update-groups [json]",
15862 BGP_INSTANCE_ALL_HELP_STR
15863 "Detailed info about dynamic update groups\n"
15866 bool uj
= use_json(argc
, argv
);
15868 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15869 return CMD_SUCCESS
;
15872 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15873 show_bgp_l2vpn_evpn_updgrps_cmd
,
15874 "show [ip] bgp l2vpn evpn update-groups",
15878 "l2vpn address family\n"
15879 "evpn sub-address family\n"
15880 "Detailed info about dynamic update groups\n")
15883 uint64_t subgrp_id
= 0;
15885 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15886 return CMD_SUCCESS
;
15889 DEFUN (show_bgp_updgrps_stats
,
15890 show_bgp_updgrps_stats_cmd
,
15891 "show [ip] bgp update-groups statistics",
15895 "Detailed info about dynamic update groups\n"
15900 bgp
= bgp_get_default();
15902 update_group_show_stats(bgp
, vty
);
15904 return CMD_SUCCESS
;
15907 DEFUN (show_bgp_instance_updgrps_stats
,
15908 show_bgp_instance_updgrps_stats_cmd
,
15909 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15913 BGP_INSTANCE_HELP_STR
15914 "Detailed info about dynamic update groups\n"
15920 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15922 update_group_show_stats(bgp
, vty
);
15924 return CMD_SUCCESS
;
15927 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15928 afi_t afi
, safi_t safi
,
15929 const char *what
, uint64_t subgrp_id
)
15934 bgp
= bgp_lookup_by_name(name
);
15936 bgp
= bgp_get_default();
15939 if (!strcmp(what
, "advertise-queue"))
15940 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15942 else if (!strcmp(what
, "advertised-routes"))
15943 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15945 else if (!strcmp(what
, "packet-queue"))
15946 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15951 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15952 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15953 "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",
15954 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15956 "Detailed info about dynamic update groups\n"
15957 "Specific subgroup to display info for\n"
15958 "Advertisement queue\n"
15959 "Announced routes\n"
15962 uint64_t subgrp_id
= 0;
15966 subgrp_id
= strtoull(sgid
, NULL
, 10);
15971 afiz
= bgp_vty_afi_from_str(afi
);
15975 afiz
= bgp_vty_afi_from_str(afi
);
15976 if (afiz
!= AFI_IP
)
15978 "%% Cannot specify both 'ip' and 'ipv6'\n");
15979 return CMD_WARNING
;
15982 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15984 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15985 return CMD_SUCCESS
;
15988 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15991 struct listnode
*node
, *nnode
;
15992 struct prefix
*range
;
15997 const char *peer_status
;
16001 json_object
*json_peer_group
= NULL
;
16002 json_object
*json_peer_group_afc
= NULL
;
16003 json_object
*json_peer_group_members
= NULL
;
16004 json_object
*json_peer_group_dynamic
= NULL
;
16005 json_object
*json_peer_group_dynamic_af
= NULL
;
16006 json_object
*json_peer_group_ranges
= NULL
;
16008 conf
= group
->conf
;
16011 json_peer_group
= json_object_new_object();
16012 json_peer_group_afc
= json_object_new_array();
16015 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
16017 json_object_int_add(json_peer_group
, "remoteAs",
16020 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
16021 group
->name
, conf
->as
);
16022 } else if (conf
->as_type
== AS_INTERNAL
) {
16024 json_object_int_add(json_peer_group
, "remoteAs",
16027 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
16028 group
->name
, group
->bgp
->as
);
16031 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
16034 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
16036 json_object_string_add(json_peer_group
, "type",
16039 vty_out(vty
, " Peer-group type is internal\n");
16042 json_object_string_add(json_peer_group
, "type",
16045 vty_out(vty
, " Peer-group type is external\n");
16048 /* Display AFs configured. */
16050 vty_out(vty
, " Configured address-families:");
16052 FOREACH_AFI_SAFI (afi
, safi
) {
16053 if (conf
->afc
[afi
][safi
]) {
16056 json_object_array_add(
16057 json_peer_group_afc
,
16058 json_object_new_string(get_afi_safi_str(
16059 afi
, safi
, false)));
16061 vty_out(vty
, " %s;",
16062 get_afi_safi_str(afi
, safi
, false));
16067 json_object_object_add(json_peer_group
,
16068 "addressFamiliesConfigured",
16069 json_peer_group_afc
);
16072 vty_out(vty
, " none\n");
16074 vty_out(vty
, "\n");
16077 /* Display listen ranges (for dynamic neighbors), if any */
16078 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16079 lr_count
= listcount(group
->listen_range
[afi
]);
16082 if (!json_peer_group_dynamic
)
16083 json_peer_group_dynamic
=
16084 json_object_new_object();
16086 json_peer_group_dynamic_af
=
16087 json_object_new_object();
16088 json_peer_group_ranges
=
16089 json_object_new_array();
16090 json_object_int_add(json_peer_group_dynamic_af
,
16091 "count", lr_count
);
16093 vty_out(vty
, " %d %s listen range(s)\n",
16094 lr_count
, afi2str(afi
));
16097 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16102 snprintfrr(buf
, sizeof(buf
), "%pFX",
16105 json_object_array_add(
16106 json_peer_group_ranges
,
16107 json_object_new_string(buf
));
16109 vty_out(vty
, " %pFX\n", range
);
16114 json_object_object_add(
16115 json_peer_group_dynamic_af
, "ranges",
16116 json_peer_group_ranges
);
16118 json_object_object_add(
16119 json_peer_group_dynamic
, afi2str(afi
),
16120 json_peer_group_dynamic_af
);
16125 if (json_peer_group_dynamic
)
16126 json_object_object_add(json_peer_group
, "dynamicRanges",
16127 json_peer_group_dynamic
);
16129 /* Display group members and their status */
16130 if (listcount(group
->peer
)) {
16132 json_peer_group_members
= json_object_new_object();
16134 vty_out(vty
, " Peer-group members:\n");
16135 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16136 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16137 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16138 peer_status
= "Idle (Admin)";
16139 else if (CHECK_FLAG(peer
->sflags
,
16140 PEER_STATUS_PREFIX_OVERFLOW
))
16141 peer_status
= "Idle (PfxCt)";
16143 peer_status
= lookup_msg(bgp_status_msg
,
16144 peer
->status
, NULL
);
16146 dynamic
= peer_dynamic_neighbor(peer
);
16149 json_object
*json_peer_group_member
=
16150 json_object_new_object();
16152 json_object_string_add(json_peer_group_member
,
16153 "status", peer_status
);
16156 json_object_boolean_true_add(
16157 json_peer_group_member
,
16160 json_object_object_add(json_peer_group_members
,
16162 json_peer_group_member
);
16164 vty_out(vty
, " %s %s %s \n", peer
->host
,
16165 dynamic
? "(dynamic)" : "",
16170 json_object_object_add(json_peer_group
, "members",
16171 json_peer_group_members
);
16175 json_object_object_add(json
, group
->name
, json_peer_group
);
16177 return CMD_SUCCESS
;
16180 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16181 const char *group_name
, bool uj
)
16184 struct listnode
*node
, *nnode
;
16185 struct peer_group
*group
;
16186 bool found
= false;
16187 json_object
*json
= NULL
;
16190 json
= json_object_new_object();
16192 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16196 vty_json(vty
, json
);
16198 vty_out(vty
, "%% BGP instance not found\n");
16200 return CMD_WARNING
;
16203 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16205 if (strmatch(group
->name
, group_name
)) {
16206 bgp_show_one_peer_group(vty
, group
, json
);
16211 bgp_show_one_peer_group(vty
, group
, json
);
16215 if (group_name
&& !found
&& !uj
)
16216 vty_out(vty
, "%% No such peer-group\n");
16219 vty_json(vty
, json
);
16221 return CMD_SUCCESS
;
16224 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16225 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16226 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16227 "Detailed information on BGP peer groups\n"
16228 "Peer group name\n" JSON_STR
)
16232 bool uj
= use_json(argc
, argv
);
16234 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16236 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16238 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16242 /* Redistribute VTY commands. */
16244 DEFUN (bgp_redistribute_ipv4
,
16245 bgp_redistribute_ipv4_cmd
,
16246 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16247 "Redistribute information from another routing protocol\n"
16248 FRR_IP_REDIST_HELP_STR_BGPD
)
16250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16251 int idx_protocol
= 1;
16254 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16256 vty_out(vty
, "%% Invalid route type\n");
16257 return CMD_WARNING_CONFIG_FAILED
;
16260 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16261 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16265 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16266 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16267 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16269 DEFUN (bgp_redistribute_ipv4_rmap
,
16270 bgp_redistribute_ipv4_rmap_cmd
,
16271 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16272 "Redistribute information from another routing protocol\n"
16273 FRR_IP_REDIST_HELP_STR_BGPD
16274 "Route map reference\n"
16275 "Pointer to route-map entries\n")
16277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16278 int idx_protocol
= 1;
16281 struct bgp_redist
*red
;
16283 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16284 vty
, argv
[idx_word
]->arg
);
16286 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16288 vty_out(vty
, "%% Invalid route type\n");
16289 return CMD_WARNING_CONFIG_FAILED
;
16292 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16294 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16295 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16299 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16300 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16301 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16302 "Route map reference\n"
16303 "Pointer to route-map entries\n")
16305 DEFUN (bgp_redistribute_ipv4_metric
,
16306 bgp_redistribute_ipv4_metric_cmd
,
16307 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16308 "Redistribute information from another routing protocol\n"
16309 FRR_IP_REDIST_HELP_STR_BGPD
16310 "Metric for redistributed routes\n"
16311 "Default metric\n")
16313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16314 int idx_protocol
= 1;
16315 int idx_number
= 3;
16318 struct bgp_redist
*red
;
16321 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16323 vty_out(vty
, "%% Invalid route type\n");
16324 return CMD_WARNING_CONFIG_FAILED
;
16326 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16328 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16329 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16330 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16334 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16335 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16336 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16337 "Metric for redistributed routes\n"
16338 "Default metric\n")
16340 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16341 bgp_redistribute_ipv4_rmap_metric_cmd
,
16342 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16343 "Redistribute information from another routing protocol\n"
16344 FRR_IP_REDIST_HELP_STR_BGPD
16345 "Route map reference\n"
16346 "Pointer to route-map entries\n"
16347 "Metric for redistributed routes\n"
16348 "Default metric\n")
16350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16351 int idx_protocol
= 1;
16353 int idx_number
= 5;
16356 struct bgp_redist
*red
;
16358 struct route_map
*route_map
=
16359 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16361 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16363 vty_out(vty
, "%% Invalid route type\n");
16364 return CMD_WARNING_CONFIG_FAILED
;
16366 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16368 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16370 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16371 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16372 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16376 bgp_redistribute_ipv4_rmap_metric
,
16377 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16378 "redistribute " FRR_IP_REDIST_STR_BGPD
16379 " route-map RMAP_NAME metric (0-4294967295)",
16380 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16381 "Route map reference\n"
16382 "Pointer to route-map entries\n"
16383 "Metric for redistributed routes\n"
16384 "Default metric\n")
16386 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16387 bgp_redistribute_ipv4_metric_rmap_cmd
,
16388 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16389 "Redistribute information from another routing protocol\n"
16390 FRR_IP_REDIST_HELP_STR_BGPD
16391 "Metric for redistributed routes\n"
16393 "Route map reference\n"
16394 "Pointer to route-map entries\n")
16396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16397 int idx_protocol
= 1;
16398 int idx_number
= 3;
16402 struct bgp_redist
*red
;
16404 struct route_map
*route_map
=
16405 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16407 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16409 vty_out(vty
, "%% Invalid route type\n");
16410 return CMD_WARNING_CONFIG_FAILED
;
16412 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16414 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16415 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16417 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16418 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16422 bgp_redistribute_ipv4_metric_rmap
,
16423 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16424 "redistribute " FRR_IP_REDIST_STR_BGPD
16425 " metric (0-4294967295) route-map RMAP_NAME",
16426 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16427 "Metric for redistributed routes\n"
16429 "Route map reference\n"
16430 "Pointer to route-map entries\n")
16432 DEFUN (bgp_redistribute_ipv4_ospf
,
16433 bgp_redistribute_ipv4_ospf_cmd
,
16434 "redistribute <ospf|table> (1-65535)",
16435 "Redistribute information from another routing protocol\n"
16436 "Open Shortest Path First (OSPFv2)\n"
16437 "Non-main Kernel Routing Table\n"
16438 "Instance ID/Table ID\n")
16440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16441 int idx_ospf_table
= 1;
16442 int idx_number
= 2;
16443 unsigned short instance
;
16444 unsigned short protocol
;
16446 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16448 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16449 protocol
= ZEBRA_ROUTE_OSPF
;
16451 protocol
= ZEBRA_ROUTE_TABLE
;
16453 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16454 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16457 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16458 "redistribute <ospf|table> (1-65535)",
16459 "Redistribute information from another routing protocol\n"
16460 "Open Shortest Path First (OSPFv2)\n"
16461 "Non-main Kernel Routing Table\n"
16462 "Instance ID/Table ID\n")
16464 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16465 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16466 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16467 "Redistribute information from another routing protocol\n"
16468 "Open Shortest Path First (OSPFv2)\n"
16469 "Non-main Kernel Routing Table\n"
16470 "Instance ID/Table ID\n"
16471 "Route map reference\n"
16472 "Pointer to route-map entries\n")
16474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16475 int idx_ospf_table
= 1;
16476 int idx_number
= 2;
16478 struct bgp_redist
*red
;
16479 unsigned short instance
;
16482 struct route_map
*route_map
=
16483 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16485 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16486 protocol
= ZEBRA_ROUTE_OSPF
;
16488 protocol
= ZEBRA_ROUTE_TABLE
;
16490 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16491 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16493 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16494 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16497 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16498 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16499 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16500 "Redistribute information from another routing protocol\n"
16501 "Open Shortest Path First (OSPFv2)\n"
16502 "Non-main Kernel Routing Table\n"
16503 "Instance ID/Table ID\n"
16504 "Route map reference\n"
16505 "Pointer to route-map entries\n")
16507 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16508 bgp_redistribute_ipv4_ospf_metric_cmd
,
16509 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16510 "Redistribute information from another routing protocol\n"
16511 "Open Shortest Path First (OSPFv2)\n"
16512 "Non-main Kernel Routing Table\n"
16513 "Instance ID/Table ID\n"
16514 "Metric for redistributed routes\n"
16515 "Default metric\n")
16517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16518 int idx_ospf_table
= 1;
16519 int idx_number
= 2;
16520 int idx_number_2
= 4;
16522 struct bgp_redist
*red
;
16523 unsigned short instance
;
16527 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16528 protocol
= ZEBRA_ROUTE_OSPF
;
16530 protocol
= ZEBRA_ROUTE_TABLE
;
16532 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16533 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16535 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16536 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16538 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16541 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16542 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16543 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16544 "Redistribute information from another routing protocol\n"
16545 "Open Shortest Path First (OSPFv2)\n"
16546 "Non-main Kernel Routing Table\n"
16547 "Instance ID/Table ID\n"
16548 "Metric for redistributed routes\n"
16549 "Default metric\n")
16551 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16552 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16553 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16554 "Redistribute information from another routing protocol\n"
16555 "Open Shortest Path First (OSPFv2)\n"
16556 "Non-main Kernel Routing Table\n"
16557 "Instance ID/Table ID\n"
16558 "Route map reference\n"
16559 "Pointer to route-map entries\n"
16560 "Metric for redistributed routes\n"
16561 "Default metric\n")
16563 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16564 int idx_ospf_table
= 1;
16565 int idx_number
= 2;
16567 int idx_number_2
= 6;
16569 struct bgp_redist
*red
;
16570 unsigned short instance
;
16573 struct route_map
*route_map
=
16574 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16576 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16577 protocol
= ZEBRA_ROUTE_OSPF
;
16579 protocol
= ZEBRA_ROUTE_TABLE
;
16581 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16582 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16584 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16586 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16587 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16589 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16593 bgp_redistribute_ipv4_ospf_rmap_metric
,
16594 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16595 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16596 "Redistribute information from another routing protocol\n"
16597 "Open Shortest Path First (OSPFv2)\n"
16598 "Non-main Kernel Routing Table\n"
16599 "Instance ID/Table ID\n"
16600 "Route map reference\n"
16601 "Pointer to route-map entries\n"
16602 "Metric for redistributed routes\n"
16603 "Default metric\n")
16605 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16606 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16607 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16608 "Redistribute information from another routing protocol\n"
16609 "Open Shortest Path First (OSPFv2)\n"
16610 "Non-main Kernel Routing Table\n"
16611 "Instance ID/Table ID\n"
16612 "Metric for redistributed routes\n"
16614 "Route map reference\n"
16615 "Pointer to route-map entries\n")
16617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16618 int idx_ospf_table
= 1;
16619 int idx_number
= 2;
16620 int idx_number_2
= 4;
16623 struct bgp_redist
*red
;
16624 unsigned short instance
;
16627 struct route_map
*route_map
=
16628 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16630 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16631 protocol
= ZEBRA_ROUTE_OSPF
;
16633 protocol
= ZEBRA_ROUTE_TABLE
;
16635 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16636 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16638 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16639 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16642 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16643 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16647 bgp_redistribute_ipv4_ospf_metric_rmap
,
16648 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16649 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16650 "Redistribute information from another routing protocol\n"
16651 "Open Shortest Path First (OSPFv2)\n"
16652 "Non-main Kernel Routing Table\n"
16653 "Instance ID/Table ID\n"
16654 "Metric for redistributed routes\n"
16656 "Route map reference\n"
16657 "Pointer to route-map entries\n")
16659 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16660 no_bgp_redistribute_ipv4_ospf_cmd
,
16661 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16663 "Redistribute information from another routing protocol\n"
16664 "Open Shortest Path First (OSPFv2)\n"
16665 "Non-main Kernel Routing Table\n"
16666 "Instance ID/Table ID\n"
16667 "Metric for redistributed routes\n"
16669 "Route map reference\n"
16670 "Pointer to route-map entries\n")
16672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16673 int idx_ospf_table
= 2;
16674 int idx_number
= 3;
16675 unsigned short instance
;
16678 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16679 protocol
= ZEBRA_ROUTE_OSPF
;
16681 protocol
= ZEBRA_ROUTE_TABLE
;
16683 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16684 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16688 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16689 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16691 "Redistribute information from another routing protocol\n"
16692 "Open Shortest Path First (OSPFv2)\n"
16693 "Non-main Kernel Routing Table\n"
16694 "Instance ID/Table ID\n"
16695 "Metric for redistributed routes\n"
16697 "Route map reference\n"
16698 "Pointer to route-map entries\n")
16700 DEFUN (no_bgp_redistribute_ipv4
,
16701 no_bgp_redistribute_ipv4_cmd
,
16702 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16704 "Redistribute information from another routing protocol\n"
16705 FRR_IP_REDIST_HELP_STR_BGPD
16706 "Metric for redistributed routes\n"
16708 "Route map reference\n"
16709 "Pointer to route-map entries\n")
16711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16712 int idx_protocol
= 2;
16715 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16717 vty_out(vty
, "%% Invalid route type\n");
16718 return CMD_WARNING_CONFIG_FAILED
;
16720 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16724 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16725 "no redistribute " FRR_IP_REDIST_STR_BGPD
16726 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16728 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16729 "Metric for redistributed routes\n"
16731 "Route map reference\n"
16732 "Pointer to route-map entries\n")
16734 DEFUN (bgp_redistribute_ipv6
,
16735 bgp_redistribute_ipv6_cmd
,
16736 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16737 "Redistribute information from another routing protocol\n"
16738 FRR_IP6_REDIST_HELP_STR_BGPD
)
16740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16741 int idx_protocol
= 1;
16744 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16746 vty_out(vty
, "%% Invalid route type\n");
16747 return CMD_WARNING_CONFIG_FAILED
;
16750 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16751 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16754 DEFUN (bgp_redistribute_ipv6_rmap
,
16755 bgp_redistribute_ipv6_rmap_cmd
,
16756 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16757 "Redistribute information from another routing protocol\n"
16758 FRR_IP6_REDIST_HELP_STR_BGPD
16759 "Route map reference\n"
16760 "Pointer to route-map entries\n")
16762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16763 int idx_protocol
= 1;
16766 struct bgp_redist
*red
;
16768 struct route_map
*route_map
=
16769 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16771 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16773 vty_out(vty
, "%% Invalid route type\n");
16774 return CMD_WARNING_CONFIG_FAILED
;
16777 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16779 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16780 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16783 DEFUN (bgp_redistribute_ipv6_metric
,
16784 bgp_redistribute_ipv6_metric_cmd
,
16785 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16786 "Redistribute information from another routing protocol\n"
16787 FRR_IP6_REDIST_HELP_STR_BGPD
16788 "Metric for redistributed routes\n"
16789 "Default metric\n")
16791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16792 int idx_protocol
= 1;
16793 int idx_number
= 3;
16796 struct bgp_redist
*red
;
16799 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16801 vty_out(vty
, "%% Invalid route type\n");
16802 return CMD_WARNING_CONFIG_FAILED
;
16804 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16806 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16807 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16808 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16811 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16812 bgp_redistribute_ipv6_rmap_metric_cmd
,
16813 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16814 "Redistribute information from another routing protocol\n"
16815 FRR_IP6_REDIST_HELP_STR_BGPD
16816 "Route map reference\n"
16817 "Pointer to route-map entries\n"
16818 "Metric for redistributed routes\n"
16819 "Default metric\n")
16821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16822 int idx_protocol
= 1;
16824 int idx_number
= 5;
16827 struct bgp_redist
*red
;
16829 struct route_map
*route_map
=
16830 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16832 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16834 vty_out(vty
, "%% Invalid route type\n");
16835 return CMD_WARNING_CONFIG_FAILED
;
16837 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16839 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16841 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16842 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16844 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16847 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16848 bgp_redistribute_ipv6_metric_rmap_cmd
,
16849 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16850 "Redistribute information from another routing protocol\n"
16851 FRR_IP6_REDIST_HELP_STR_BGPD
16852 "Metric for redistributed routes\n"
16854 "Route map reference\n"
16855 "Pointer to route-map entries\n")
16857 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16858 int idx_protocol
= 1;
16859 int idx_number
= 3;
16863 struct bgp_redist
*red
;
16865 struct route_map
*route_map
=
16866 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16868 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16870 vty_out(vty
, "%% Invalid route type\n");
16871 return CMD_WARNING_CONFIG_FAILED
;
16873 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16875 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16876 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16879 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16880 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16883 DEFUN (no_bgp_redistribute_ipv6
,
16884 no_bgp_redistribute_ipv6_cmd
,
16885 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16887 "Redistribute information from another routing protocol\n"
16888 FRR_IP6_REDIST_HELP_STR_BGPD
16889 "Metric for redistributed routes\n"
16891 "Route map reference\n"
16892 "Pointer to route-map entries\n")
16894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16895 int idx_protocol
= 2;
16898 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16900 vty_out(vty
, "%% Invalid route type\n");
16901 return CMD_WARNING_CONFIG_FAILED
;
16904 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16907 /* Neighbor update tcp-mss. */
16908 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16909 const char *tcp_mss_str
)
16912 uint32_t tcp_mss_val
= 0;
16914 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16916 return CMD_WARNING_CONFIG_FAILED
;
16919 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16920 peer_tcp_mss_set(peer
, tcp_mss_val
);
16922 peer_tcp_mss_unset(peer
);
16925 return CMD_SUCCESS
;
16928 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16929 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16931 "TCP max segment size\n"
16934 int peer_index
= 1;
16938 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16939 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16940 argv
[mss_index
]->arg
);
16943 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16944 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16946 "TCP max segment size\n"
16949 int peer_index
= 2;
16952 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16953 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16956 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16957 "[no$no] bgp retain route-target all",
16959 "Retain BGP updates\n"
16960 "Retain BGP updates based on route-target values\n"
16961 "Retain all BGP updates\n")
16964 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16966 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16967 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16968 if (check
!= !no
) {
16970 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16971 [bgp_node_safi(vty
)],
16972 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16974 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16975 [bgp_node_safi(vty
)],
16976 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16977 /* trigger a flush to re-sync with ADJ-RIB-in */
16978 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16979 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16981 return CMD_SUCCESS
;
16984 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16985 afi_t afi
, safi_t safi
)
16989 /* Unicast redistribution only. */
16990 if (safi
!= SAFI_UNICAST
)
16993 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16994 /* Redistribute BGP does not make sense. */
16995 if (i
!= ZEBRA_ROUTE_BGP
) {
16996 struct list
*red_list
;
16997 struct listnode
*node
;
16998 struct bgp_redist
*red
;
17000 red_list
= bgp
->redist
[afi
][i
];
17004 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
17005 /* "redistribute" configuration. */
17006 vty_out(vty
, " redistribute %s",
17007 zebra_route_string(i
));
17009 vty_out(vty
, " %d", red
->instance
);
17010 if (red
->redist_metric_flag
)
17011 vty_out(vty
, " metric %u",
17012 red
->redist_metric
);
17013 if (red
->rmap
.name
)
17014 vty_out(vty
, " route-map %s",
17016 vty_out(vty
, "\n");
17022 /* peer-group helpers for config-write */
17024 bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
17026 if (!peer_group_active(peer
)) {
17027 if (CHECK_FLAG(peer
->flags_invert
, flag
))
17028 return !CHECK_FLAG(peer
->flags
, flag
);
17030 return !!CHECK_FLAG(peer
->flags
, flag
);
17033 return !!CHECK_FLAG(peer
->flags_override
, flag
);
17036 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
17039 if (!peer_group_active(peer
)) {
17040 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
17041 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
17043 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
17046 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
17049 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
17050 uint8_t type
, int direct
)
17052 struct bgp_filter
*filter
;
17054 if (peer_group_active(peer
))
17055 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
17058 filter
= &peer
->filter
[afi
][safi
];
17060 case PEER_FT_DISTRIBUTE_LIST
:
17061 return !!(filter
->dlist
[direct
].name
);
17062 case PEER_FT_FILTER_LIST
:
17063 return !!(filter
->aslist
[direct
].name
);
17064 case PEER_FT_PREFIX_LIST
:
17065 return !!(filter
->plist
[direct
].name
);
17066 case PEER_FT_ROUTE_MAP
:
17067 return !!(filter
->map
[direct
].name
);
17068 case PEER_FT_UNSUPPRESS_MAP
:
17069 return !!(filter
->usmap
.name
);
17070 case PEER_FT_ADVERTISE_MAP
:
17071 return !!(filter
->advmap
.aname
17072 && ((filter
->advmap
.condition
== direct
)
17073 && filter
->advmap
.cname
));
17079 /* Return true if the addpath type is set for peer and different from
17082 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
17085 enum bgp_addpath_strat type
, g_type
;
17087 type
= peer
->addpath_type
[afi
][safi
];
17089 if (type
!= BGP_ADDPATH_NONE
) {
17090 if (peer_group_active(peer
)) {
17091 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
17093 if (type
!= g_type
)
17105 /* This is part of the address-family block (unicast only) */
17106 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17110 uint32_t tovpn_sid_index
= 0;
17112 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17113 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17114 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17115 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17116 bgp
->vpn_policy
[afi
]
17117 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17119 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17120 bgp
->vpn_policy
[afi
]
17121 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17123 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17124 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17125 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17126 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17129 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17130 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17132 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17135 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17136 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17137 bgp
->vpn_policy
[afi
].tovpn_label
);
17141 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17142 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17143 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17144 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17145 } else if (tovpn_sid_index
!= 0) {
17146 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17150 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17151 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
17152 &bgp
->vpn_policy
[afi
].tovpn_rd
);
17154 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17155 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17157 char buf
[PREFIX_STRLEN
];
17158 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17159 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17162 vty_out(vty
, "%*snexthop vpn export %s\n",
17166 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17167 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17169 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17170 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17172 char *b
= ecommunity_ecom2str(
17173 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17174 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17175 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17176 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17178 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17179 char *b
= ecommunity_ecom2str(
17180 bgp
->vpn_policy
[afi
]
17181 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17182 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17183 ECOMMUNITY_ROUTE_TARGET
);
17184 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17185 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17187 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17188 char *b
= ecommunity_ecom2str(
17189 bgp
->vpn_policy
[afi
]
17190 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17191 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17192 ECOMMUNITY_ROUTE_TARGET
);
17193 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17194 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17198 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17199 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17200 bgp
->vpn_policy
[afi
]
17201 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17203 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17204 char *b
= ecommunity_ecom2str(
17205 bgp
->vpn_policy
[afi
]
17206 .import_redirect_rtlist
,
17207 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17208 ECOMMUNITY_ROUTE_TARGET
);
17210 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17211 != ECOMMUNITY_SIZE
)
17212 vty_out(vty
, "%*srt6 redirect import %s\n",
17215 vty_out(vty
, "%*srt redirect import %s\n",
17217 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17221 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17222 afi_t afi
, safi_t safi
)
17224 struct bgp_filter
*filter
;
17228 filter
= &peer
->filter
[afi
][safi
];
17230 /* distribute-list. */
17231 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17233 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17234 filter
->dlist
[FILTER_IN
].name
);
17236 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17238 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17239 filter
->dlist
[FILTER_OUT
].name
);
17242 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17244 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17245 filter
->plist
[FILTER_IN
].name
);
17247 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17249 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17250 filter
->plist
[FILTER_OUT
].name
);
17253 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17254 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17255 filter
->map
[RMAP_IN
].name
);
17257 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17259 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17260 filter
->map
[RMAP_OUT
].name
);
17262 /* unsuppress-map */
17263 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17264 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17265 filter
->usmap
.name
);
17267 /* advertise-map : always applied in OUT direction*/
17268 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17269 CONDITION_NON_EXIST
))
17271 " neighbor %s advertise-map %s non-exist-map %s\n",
17272 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17274 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17276 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17277 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17280 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17282 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17283 filter
->aslist
[FILTER_IN
].name
);
17285 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17287 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17288 filter
->aslist
[FILTER_OUT
].name
);
17291 /* BGP peer configuration display function. */
17292 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17295 struct peer
*g_peer
= NULL
;
17297 int if_pg_printed
= false;
17298 int if_ras_printed
= false;
17300 /* Skip dynamic neighbors. */
17301 if (peer_dynamic_neighbor(peer
))
17305 addr
= peer
->conf_if
;
17309 /************************************
17310 ****** Global to the neighbor ******
17311 ************************************/
17312 if (peer
->conf_if
) {
17313 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17314 vty_out(vty
, " neighbor %s interface v6only", addr
);
17316 vty_out(vty
, " neighbor %s interface", addr
);
17318 if (peer_group_active(peer
)) {
17319 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17320 if_pg_printed
= true;
17321 } else if (peer
->as_type
== AS_SPECIFIED
) {
17322 vty_out(vty
, " remote-as %u", peer
->as
);
17323 if_ras_printed
= true;
17324 } else if (peer
->as_type
== AS_INTERNAL
) {
17325 vty_out(vty
, " remote-as internal");
17326 if_ras_printed
= true;
17327 } else if (peer
->as_type
== AS_EXTERNAL
) {
17328 vty_out(vty
, " remote-as external");
17329 if_ras_printed
= true;
17332 vty_out(vty
, "\n");
17335 /* remote-as and peer-group */
17336 /* peer is a member of a peer-group */
17337 if (peer_group_active(peer
)) {
17338 g_peer
= peer
->group
->conf
;
17340 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17341 if (peer
->as_type
== AS_SPECIFIED
) {
17342 vty_out(vty
, " neighbor %s remote-as %u\n",
17344 } else if (peer
->as_type
== AS_INTERNAL
) {
17346 " neighbor %s remote-as internal\n",
17348 } else if (peer
->as_type
== AS_EXTERNAL
) {
17350 " neighbor %s remote-as external\n",
17355 /* For swpX peers we displayed the peer-group
17356 * via 'neighbor swpX interface peer-group PGNAME' */
17357 if (!if_pg_printed
)
17358 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17359 peer
->group
->name
);
17362 /* peer is NOT a member of a peer-group */
17364 /* peer is a peer-group, declare the peer-group */
17365 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17366 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17369 if (!if_ras_printed
) {
17370 if (peer
->as_type
== AS_SPECIFIED
) {
17371 vty_out(vty
, " neighbor %s remote-as %u\n",
17373 } else if (peer
->as_type
== AS_INTERNAL
) {
17375 " neighbor %s remote-as internal\n",
17377 } else if (peer
->as_type
== AS_EXTERNAL
) {
17379 " neighbor %s remote-as external\n",
17386 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17387 vty_out(vty
, " neighbor %s local-as %u", addr
,
17388 peer
->change_local_as
);
17389 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17390 vty_out(vty
, " no-prepend");
17391 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17392 vty_out(vty
, " replace-as");
17393 vty_out(vty
, "\n");
17398 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17402 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17403 if (peer
->tx_shutdown_message
)
17404 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17405 peer
->tx_shutdown_message
);
17407 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17410 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17411 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17412 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17415 if (peer
->bfd_config
)
17416 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17419 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17420 vty_out(vty
, " neighbor %s password %s\n", addr
,
17423 /* neighbor solo */
17424 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17425 if (!peer_group_active(peer
)) {
17426 vty_out(vty
, " neighbor %s solo\n", addr
);
17431 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17432 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17435 /* Local interface name */
17436 if (peer
->ifname
) {
17437 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17440 /* TCP max segment size */
17441 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17442 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17445 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17446 vty_out(vty
, " neighbor %s passive\n", addr
);
17448 /* ebgp-multihop */
17449 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17450 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17451 && peer
->ttl
== MAXTTL
)) {
17452 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17453 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17459 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17460 vty_out(vty
, " neighbor %s aigp\n", addr
);
17462 /* graceful-shutdown */
17463 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17464 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17467 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17468 peer
->local_role
!= ROLE_UNDEFINED
)
17469 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17470 bgp_get_name_by_role(peer
->local_role
),
17471 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17475 /* ttl-security hops */
17476 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17477 if (!peer_group_active(peer
)
17478 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17479 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17480 addr
, peer
->gtsm_hops
);
17484 /* disable-connected-check */
17485 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17486 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17488 /* link-bw-encoding-ieee */
17489 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17490 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17493 /* extended-optional-parameters */
17494 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17495 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17498 /* enforce-first-as */
17499 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17500 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17502 /* update-source */
17503 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17504 if (peer
->update_source
)
17505 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17506 peer
->update_source
);
17507 else if (peer
->update_if
)
17508 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17512 /* advertisement-interval */
17513 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17514 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17518 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17519 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17520 peer
->keepalive
, peer
->holdtime
);
17522 /* timers connect */
17523 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17524 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17526 /* need special-case handling for changed default values due to
17527 * config profile / version (because there is no "timers bgp connect"
17528 * command, we need to save this per-peer :/)
17530 else if (!peer_group_active(peer
) && !peer
->connect
&&
17531 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17532 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17533 peer
->bgp
->default_connect_retry
);
17535 /* timers delayopen */
17536 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17537 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17539 /* Save config even though flag is not set if default values have been
17542 else if (!peer_group_active(peer
) && !peer
->delayopen
17543 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17544 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17545 peer
->bgp
->default_delayopen
);
17547 /* capability dynamic */
17548 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17549 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17551 /* capability extended-nexthop */
17552 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17553 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17556 " no neighbor %s capability extended-nexthop\n",
17558 else if (!peer
->conf_if
)
17560 " neighbor %s capability extended-nexthop\n",
17564 /* capability software-version */
17565 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_SOFT_VERSION
))
17566 vty_out(vty
, " neighbor %s capability software-version\n",
17569 /* dont-capability-negotiation */
17570 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17571 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17573 /* override-capability */
17574 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17575 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17577 /* strict-capability-match */
17578 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17579 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17581 /* Sender side AS path loop detection. */
17582 if (peer
->as_path_loop_detection
)
17583 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17586 /* path-attribute discard */
17587 char discard_attrs_str
[BUFSIZ
] = {0};
17588 bool discard_attrs
= bgp_path_attribute_discard(
17589 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17592 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17593 discard_attrs_str
);
17595 /* path-attribute treat-as-withdraw */
17596 char withdraw_attrs_str
[BUFSIZ
] = {0};
17597 bool withdraw_attrs
= bgp_path_attribute_treat_as_withdraw(
17598 peer
, withdraw_attrs_str
, sizeof(withdraw_attrs_str
));
17600 if (withdraw_attrs
)
17602 " neighbor %s path-attribute treat-as-withdraw %s\n",
17603 addr
, withdraw_attrs_str
);
17605 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17606 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17608 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17609 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17611 " neighbor %s graceful-restart-helper\n", addr
);
17612 } else if (CHECK_FLAG(
17613 peer
->peer_gr_new_status_flag
,
17614 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17616 " neighbor %s graceful-restart\n", addr
);
17618 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17619 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17621 peer
->peer_gr_new_status_flag
,
17622 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17623 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17629 /* BGP peer configuration display function. */
17630 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17631 struct peer
*peer
, afi_t afi
, safi_t safi
)
17633 struct peer
*g_peer
= NULL
;
17635 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17637 /* Skip dynamic neighbors. */
17638 if (peer_dynamic_neighbor(peer
))
17642 addr
= peer
->conf_if
;
17646 /************************************
17647 ****** Per AF to the neighbor ******
17648 ************************************/
17649 if (peer_group_active(peer
)) {
17650 g_peer
= peer
->group
->conf
;
17652 /* If the peer-group is active but peer is not, print a 'no
17654 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17655 vty_out(vty
, " no neighbor %s activate\n", addr
);
17658 /* If the peer-group is not active but peer is, print an
17660 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17661 vty_out(vty
, " neighbor %s activate\n", addr
);
17664 if (peer
->afc
[afi
][safi
]) {
17665 if (safi
== SAFI_ENCAP
)
17666 vty_out(vty
, " neighbor %s activate\n", addr
);
17667 else if (!bgp
->default_af
[afi
][safi
])
17668 vty_out(vty
, " neighbor %s activate\n", addr
);
17670 if (bgp
->default_af
[afi
][safi
])
17671 vty_out(vty
, " no neighbor %s activate\n",
17676 /* addpath TX knobs */
17677 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17678 switch (peer
->addpath_type
[afi
][safi
]) {
17679 case BGP_ADDPATH_ALL
:
17680 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17683 case BGP_ADDPATH_BEST_PER_AS
:
17685 " neighbor %s addpath-tx-bestpath-per-AS\n",
17688 case BGP_ADDPATH_MAX
:
17689 case BGP_ADDPATH_NONE
:
17694 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17695 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17697 /* ORF capability. */
17698 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17699 || peergroup_af_flag_check(peer
, afi
, safi
,
17700 PEER_FLAG_ORF_PREFIX_RM
)) {
17701 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17703 if (peergroup_af_flag_check(peer
, afi
, safi
,
17704 PEER_FLAG_ORF_PREFIX_SM
)
17705 && peergroup_af_flag_check(peer
, afi
, safi
,
17706 PEER_FLAG_ORF_PREFIX_RM
))
17707 vty_out(vty
, " both");
17708 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17709 PEER_FLAG_ORF_PREFIX_SM
))
17710 vty_out(vty
, " send");
17712 vty_out(vty
, " receive");
17713 vty_out(vty
, "\n");
17716 /* Route reflector client. */
17717 if (peergroup_af_flag_check(peer
, afi
, safi
,
17718 PEER_FLAG_REFLECTOR_CLIENT
)) {
17719 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17722 /* next-hop-self force */
17723 if (peergroup_af_flag_check(peer
, afi
, safi
,
17724 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17725 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17728 /* next-hop-self */
17729 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17730 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17733 /* remove-private-AS */
17734 if (peergroup_af_flag_check(peer
, afi
, safi
,
17735 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17736 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17740 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17741 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17742 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17746 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17747 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17748 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17751 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17752 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17753 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17757 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17758 vty_out(vty
, " neighbor %s as-override\n", addr
);
17761 /* send-community print. */
17762 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17763 PEER_FLAG_SEND_COMMUNITY
);
17764 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17765 PEER_FLAG_SEND_EXT_COMMUNITY
);
17766 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17767 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17769 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17770 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17773 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17776 " no neighbor %s send-community extended\n",
17780 vty_out(vty
, " no neighbor %s send-community large\n",
17784 /* Default information */
17785 if (peergroup_af_flag_check(peer
, afi
, safi
,
17786 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17787 vty_out(vty
, " neighbor %s default-originate", addr
);
17789 if (peer
->default_rmap
[afi
][safi
].name
)
17790 vty_out(vty
, " route-map %s",
17791 peer
->default_rmap
[afi
][safi
].name
);
17793 vty_out(vty
, "\n");
17796 /* Soft reconfiguration inbound. */
17797 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17798 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17802 /* maximum-prefix. */
17803 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17804 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17805 peer
->pmax
[afi
][safi
]);
17807 if (peer
->pmax_threshold
[afi
][safi
]
17808 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17809 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17810 if (peer_af_flag_check(peer
, afi
, safi
,
17811 PEER_FLAG_MAX_PREFIX_WARNING
))
17812 vty_out(vty
, " warning-only");
17813 if (peer
->pmax_restart
[afi
][safi
])
17814 vty_out(vty
, " restart %u",
17815 peer
->pmax_restart
[afi
][safi
]);
17816 if (peer_af_flag_check(peer
, afi
, safi
,
17817 PEER_FLAG_MAX_PREFIX_FORCE
))
17818 vty_out(vty
, " force");
17820 vty_out(vty
, "\n");
17823 /* maximum-prefix-out */
17824 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17825 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17826 addr
, peer
->pmax_out
[afi
][safi
]);
17828 /* Route server client. */
17829 if (peergroup_af_flag_check(peer
, afi
, safi
,
17830 PEER_FLAG_RSERVER_CLIENT
)) {
17831 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17834 /* Nexthop-local unchanged. */
17835 if (peergroup_af_flag_check(peer
, afi
, safi
,
17836 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17837 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17840 /* allowas-in <1-10> */
17841 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17842 if (peer_af_flag_check(peer
, afi
, safi
,
17843 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17844 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17845 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17846 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17848 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17849 peer
->allowas_in
[afi
][safi
]);
17854 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17855 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17858 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17859 char *soo_str
= ecommunity_ecom2str(
17860 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17862 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17863 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17867 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17868 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17869 peer
->weight
[afi
][safi
]);
17872 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17874 /* atribute-unchanged. */
17875 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17876 || (safi
!= SAFI_EVPN
17877 && peer_af_flag_check(peer
, afi
, safi
,
17878 PEER_FLAG_NEXTHOP_UNCHANGED
))
17879 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17881 if (!peer_group_active(peer
)
17882 || peergroup_af_flag_check(peer
, afi
, safi
,
17883 PEER_FLAG_AS_PATH_UNCHANGED
)
17884 || peergroup_af_flag_check(peer
, afi
, safi
,
17885 PEER_FLAG_NEXTHOP_UNCHANGED
)
17886 || peergroup_af_flag_check(peer
, afi
, safi
,
17887 PEER_FLAG_MED_UNCHANGED
)) {
17890 " neighbor %s attribute-unchanged%s%s%s\n",
17892 peer_af_flag_check(peer
, afi
, safi
,
17893 PEER_FLAG_AS_PATH_UNCHANGED
)
17896 peer_af_flag_check(peer
, afi
, safi
,
17897 PEER_FLAG_NEXTHOP_UNCHANGED
)
17900 peer_af_flag_check(peer
, afi
, safi
,
17901 PEER_FLAG_MED_UNCHANGED
)
17908 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17911 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17912 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17913 vty_out(vty
, " no bgp retain route-target all\n");
17916 /* Address family based peer configuration display. */
17917 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17921 struct peer_group
*group
;
17922 struct listnode
*node
, *nnode
;
17925 vty_frame(vty
, " !\n address-family ");
17926 if (afi
== AFI_IP
) {
17927 if (safi
== SAFI_UNICAST
)
17928 vty_frame(vty
, "ipv4 unicast");
17929 else if (safi
== SAFI_LABELED_UNICAST
)
17930 vty_frame(vty
, "ipv4 labeled-unicast");
17931 else if (safi
== SAFI_MULTICAST
)
17932 vty_frame(vty
, "ipv4 multicast");
17933 else if (safi
== SAFI_MPLS_VPN
)
17934 vty_frame(vty
, "ipv4 vpn");
17935 else if (safi
== SAFI_ENCAP
)
17936 vty_frame(vty
, "ipv4 encap");
17937 else if (safi
== SAFI_FLOWSPEC
)
17938 vty_frame(vty
, "ipv4 flowspec");
17939 } else if (afi
== AFI_IP6
) {
17940 if (safi
== SAFI_UNICAST
)
17941 vty_frame(vty
, "ipv6 unicast");
17942 else if (safi
== SAFI_LABELED_UNICAST
)
17943 vty_frame(vty
, "ipv6 labeled-unicast");
17944 else if (safi
== SAFI_MULTICAST
)
17945 vty_frame(vty
, "ipv6 multicast");
17946 else if (safi
== SAFI_MPLS_VPN
)
17947 vty_frame(vty
, "ipv6 vpn");
17948 else if (safi
== SAFI_ENCAP
)
17949 vty_frame(vty
, "ipv6 encap");
17950 else if (safi
== SAFI_FLOWSPEC
)
17951 vty_frame(vty
, "ipv6 flowspec");
17952 } else if (afi
== AFI_L2VPN
) {
17953 if (safi
== SAFI_EVPN
)
17954 vty_frame(vty
, "l2vpn evpn");
17956 vty_frame(vty
, "\n");
17958 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17960 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17962 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17964 /* BGP flag dampening. */
17965 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17966 bgp_config_write_damp(vty
, afi
, safi
);
17968 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17969 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17971 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17972 /* Do not display doppelganger peers */
17973 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17974 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17977 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17978 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17980 if (safi
== SAFI_EVPN
)
17981 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17983 if (safi
== SAFI_FLOWSPEC
)
17984 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17986 if (safi
== SAFI_MPLS_VPN
)
17987 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17989 if (safi
== SAFI_UNICAST
) {
17990 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17991 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17992 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17994 vty_out(vty
, " export vpn\n");
17996 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17997 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17999 vty_out(vty
, " import vpn\n");
18001 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
18002 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
18005 for (ALL_LIST_ELEMENTS_RO(
18006 bgp
->vpn_policy
[afi
].import_vrf
, node
,
18008 vty_out(vty
, " import vrf %s\n", name
);
18012 vty_endframe(vty
, " exit-address-family\n");
18015 int bgp_config_write(struct vty
*vty
)
18018 struct peer_group
*group
;
18020 struct listnode
*node
, *nnode
;
18021 struct listnode
*mnode
, *mnnode
;
18024 uint32_t tovpn_sid_index
= 0;
18026 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
18027 vty_out(vty
, "bgp route-map delay-timer %u\n",
18028 bm
->rmap_update_timer
);
18030 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
18031 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
18032 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
18033 vty_out(vty
, " %d", bm
->v_establish_wait
);
18034 vty_out(vty
, "\n");
18037 if (bm
->wait_for_fib
)
18038 vty_out(vty
, "bgp suppress-fib-pending\n");
18040 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18041 vty_out(vty
, "bgp graceful-shutdown\n");
18043 /* No-RIB (Zebra) option flag configuration */
18044 if (bgp_option_check(BGP_OPT_NO_FIB
))
18045 vty_out(vty
, "bgp no-rib\n");
18047 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
18048 vty_out(vty
, "bgp send-extra-data zebra\n");
18050 /* BGP session DSCP value */
18051 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
18052 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
18054 /* BGP InQ limit */
18055 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
18056 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
18058 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
18059 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
18061 /* BGP configuration. */
18062 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
18064 /* skip all auto created vrf as they dont have user config */
18065 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
18068 /* Router bgp ASN */
18069 vty_out(vty
, "router bgp %u", bgp
->as
);
18072 vty_out(vty
, " %s %s",
18073 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
18074 ? "view" : "vrf", bgp
->name
);
18075 vty_out(vty
, "\n");
18077 /* BGP fast-external-failover. */
18078 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
18079 vty_out(vty
, " no bgp fast-external-failover\n");
18081 /* BGP router ID. */
18082 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
18083 vty_out(vty
, " bgp router-id %pI4\n",
18084 &bgp
->router_id_static
);
18086 /* Suppress fib pending */
18087 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
18088 vty_out(vty
, " bgp suppress-fib-pending\n");
18090 /* BGP log-neighbor-changes. */
18091 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18092 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
18093 vty_out(vty
, " %sbgp log-neighbor-changes\n",
18094 CHECK_FLAG(bgp
->flags
,
18095 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18099 /* BGP configuration. */
18100 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
18101 vty_out(vty
, " bgp always-compare-med\n");
18103 /* RFC8212 default eBGP policy. */
18104 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
18105 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
18106 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
18107 CHECK_FLAG(bgp
->flags
,
18108 BGP_FLAG_EBGP_REQUIRES_POLICY
)
18112 /* draft-ietf-idr-deprecate-as-set-confed-set */
18113 if (bgp
->reject_as_sets
)
18114 vty_out(vty
, " bgp reject-as-sets\n");
18116 /* Suppress duplicate updates if the route actually not changed
18118 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
18119 != SAVE_BGP_SUPPRESS_DUPLICATES
)
18120 vty_out(vty
, " %sbgp suppress-duplicates\n",
18121 CHECK_FLAG(bgp
->flags
,
18122 BGP_FLAG_SUPPRESS_DUPLICATES
)
18126 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
18128 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
18129 SAVE_BGP_HARD_ADMIN_RESET
)
18130 vty_out(vty
, " %sbgp hard-administrative-reset\n",
18131 CHECK_FLAG(bgp
->flags
,
18132 BGP_FLAG_HARD_ADMIN_RESET
)
18136 /* BGP default <afi>-<safi> */
18137 FOREACH_AFI_SAFI (afi
, safi
) {
18138 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
18139 if (!bgp
->default_af
[afi
][safi
])
18140 vty_out(vty
, " no bgp default %s\n",
18141 get_bgp_default_af_flag(afi
,
18143 } else if (bgp
->default_af
[afi
][safi
])
18144 vty_out(vty
, " bgp default %s\n",
18145 get_bgp_default_af_flag(afi
, safi
));
18148 /* BGP default local-preference. */
18149 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18150 vty_out(vty
, " bgp default local-preference %u\n",
18151 bgp
->default_local_pref
);
18153 /* BGP default show-hostname */
18154 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18155 != SAVE_BGP_SHOW_HOSTNAME
)
18156 vty_out(vty
, " %sbgp default show-hostname\n",
18157 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18161 /* BGP default show-nexthop-hostname */
18162 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18163 != SAVE_BGP_SHOW_HOSTNAME
)
18164 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18165 CHECK_FLAG(bgp
->flags
,
18166 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18170 /* BGP default subgroup-pkt-queue-max. */
18171 if (bgp
->default_subgroup_pkt_queue_max
18172 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18173 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18174 bgp
->default_subgroup_pkt_queue_max
);
18176 /* BGP client-to-client reflection. */
18177 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18178 vty_out(vty
, " no bgp client-to-client reflection\n");
18180 /* BGP cluster ID. */
18181 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18182 vty_out(vty
, " bgp cluster-id %pI4\n",
18185 /* Disable ebgp connected nexthop check */
18186 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18188 " bgp disable-ebgp-connected-route-check\n");
18190 /* Confederation identifier*/
18191 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18192 vty_out(vty
, " bgp confederation identifier %u\n",
18195 /* Confederation peer */
18196 if (bgp
->confed_peers_cnt
> 0) {
18199 vty_out(vty
, " bgp confederation peers");
18201 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18202 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18204 vty_out(vty
, "\n");
18207 /* BGP deterministic-med. */
18208 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18209 != SAVE_BGP_DETERMINISTIC_MED
)
18210 vty_out(vty
, " %sbgp deterministic-med\n",
18211 CHECK_FLAG(bgp
->flags
,
18212 BGP_FLAG_DETERMINISTIC_MED
)
18216 /* BGP update-delay. */
18217 bgp_config_write_update_delay(vty
, bgp
);
18219 if (bgp
->v_maxmed_onstartup
18220 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18221 vty_out(vty
, " bgp max-med on-startup %u",
18222 bgp
->v_maxmed_onstartup
);
18223 if (bgp
->maxmed_onstartup_value
18224 != BGP_MAXMED_VALUE_DEFAULT
)
18225 vty_out(vty
, " %u",
18226 bgp
->maxmed_onstartup_value
);
18227 vty_out(vty
, "\n");
18229 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18230 vty_out(vty
, " bgp max-med administrative");
18231 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18232 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18233 vty_out(vty
, "\n");
18237 bgp_config_write_wpkt_quanta(vty
, bgp
);
18239 bgp_config_write_rpkt_quanta(vty
, bgp
);
18241 /* coalesce time */
18242 bgp_config_write_coalesce_time(vty
, bgp
);
18244 /* BGP per-instance graceful-shutdown */
18245 /* BGP-wide settings and per-instance settings are mutually
18248 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18249 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18250 vty_out(vty
, " bgp graceful-shutdown\n");
18252 /* Long-lived Graceful Restart */
18253 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18255 " bgp long-lived-graceful-restart stale-time %u\n",
18256 bgp
->llgr_stale_time
);
18258 /* BGP graceful-restart. */
18259 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18261 " bgp graceful-restart stalepath-time %u\n",
18262 bgp
->stalepath_time
);
18264 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18265 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18266 bgp
->restart_time
);
18268 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18269 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18270 vty_out(vty
, " %sbgp graceful-restart notification\n",
18271 CHECK_FLAG(bgp
->flags
,
18272 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18276 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18278 " bgp graceful-restart select-defer-time %u\n",
18279 bgp
->select_defer_time
);
18281 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18282 vty_out(vty
, " bgp graceful-restart\n");
18284 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18285 vty_out(vty
, " bgp graceful-restart-disable\n");
18287 /* BGP graceful-restart Preserve State F bit. */
18288 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18290 " bgp graceful-restart preserve-fw-state\n");
18292 /* BGP TCP keepalive */
18293 bgp_config_tcp_keepalive(vty
, bgp
);
18295 /* Stale timer for RIB */
18296 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18298 " bgp graceful-restart rib-stale-time %u\n",
18299 bgp
->rib_stale_time
);
18301 /* BGP bestpath method. */
18302 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18303 vty_out(vty
, " bgp bestpath as-path ignore\n");
18304 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18305 vty_out(vty
, " bgp bestpath as-path confed\n");
18307 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18308 if (CHECK_FLAG(bgp
->flags
,
18309 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18311 " bgp bestpath as-path multipath-relax as-set\n");
18314 " bgp bestpath as-path multipath-relax\n");
18318 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18320 " bgp route-reflector allow-outbound-policy\n");
18322 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18323 vty_out(vty
, " bgp bestpath compare-routerid\n");
18324 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18325 vty_out(vty
, " bgp bestpath aigp\n");
18326 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18327 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18328 vty_out(vty
, " bgp bestpath med");
18329 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18330 vty_out(vty
, " confed");
18331 if (CHECK_FLAG(bgp
->flags
,
18332 BGP_FLAG_MED_MISSING_AS_WORST
))
18333 vty_out(vty
, " missing-as-worst");
18334 vty_out(vty
, "\n");
18337 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18339 " bgp bestpath peer-type multipath-relax\n");
18341 /* Link bandwidth handling. */
18342 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18343 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18344 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18345 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18346 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18347 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18349 /* BGP network import check. */
18350 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18351 != SAVE_BGP_IMPORT_CHECK
)
18352 vty_out(vty
, " %sbgp network import-check\n",
18353 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18357 /* BGP timers configuration. */
18358 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18359 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18360 vty_out(vty
, " timers bgp %u %u\n",
18361 bgp
->default_keepalive
, bgp
->default_holdtime
);
18363 /* BGP minimum holdtime configuration. */
18364 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18365 && bgp
->default_min_holdtime
!= 0)
18366 vty_out(vty
, " bgp minimum-holdtime %u\n",
18367 bgp
->default_min_holdtime
);
18369 /* Conditional advertisement timer configuration */
18370 if (bgp
->condition_check_period
18371 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18373 " bgp conditional-advertisement timer %u\n",
18374 bgp
->condition_check_period
);
18377 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18378 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18381 /* Normal neighbor configuration. */
18382 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18383 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18384 bgp_config_write_peer_global(vty
, bgp
, peer
);
18387 /* listen range and limit for dynamic BGP neighbors */
18388 bgp_config_write_listen(vty
, bgp
);
18391 * BGP default autoshutdown neighbors
18393 * This must be placed after any peer and peer-group
18394 * configuration, to avoid setting all peers to shutdown after
18395 * a daemon restart, which is undesired behavior. (see #2286)
18397 if (bgp
->autoshutdown
)
18398 vty_out(vty
, " bgp default shutdown\n");
18400 /* BGP instance administrative shutdown */
18401 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18402 vty_out(vty
, " bgp shutdown\n");
18404 if (bgp
->allow_martian
)
18405 vty_out(vty
, " bgp allow-martian-nexthop\n");
18407 if (bgp
->fast_convergence
)
18408 vty_out(vty
, " bgp fast-convergence\n");
18410 if (bgp
->srv6_enabled
) {
18411 vty_frame(vty
, " !\n segment-routing srv6\n");
18412 if (strlen(bgp
->srv6_locator_name
))
18413 vty_out(vty
, " locator %s\n",
18414 bgp
->srv6_locator_name
);
18415 vty_endframe(vty
, " exit\n");
18418 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18419 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18420 vty_out(vty
, " sid vpn per-vrf export auto\n");
18421 } else if (tovpn_sid_index
!= 0) {
18422 vty_out(vty
, " sid vpn per-vrf export %d\n",
18426 /* IPv4 unicast configuration. */
18427 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18429 /* IPv4 multicast configuration. */
18430 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18432 /* IPv4 labeled-unicast configuration. */
18433 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18435 /* IPv4 VPN configuration. */
18436 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18438 /* ENCAPv4 configuration. */
18439 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18441 /* FLOWSPEC v4 configuration. */
18442 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18444 /* IPv6 unicast configuration. */
18445 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18447 /* IPv6 multicast configuration. */
18448 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18450 /* IPv6 labeled-unicast configuration. */
18451 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18452 SAFI_LABELED_UNICAST
);
18454 /* IPv6 VPN configuration. */
18455 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18457 /* ENCAPv6 configuration. */
18458 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18460 /* FLOWSPEC v6 configuration. */
18461 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18463 /* EVPN configuration. */
18464 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18466 hook_call(bgp_inst_config_write
, bgp
, vty
);
18468 #ifdef ENABLE_BGP_VNC
18469 bgp_rfapi_cfg_write(vty
, bgp
);
18472 vty_out(vty
, "exit\n");
18473 vty_out(vty
, "!\n");
18479 /* BGP node structure. */
18480 static struct cmd_node bgp_node
= {
18483 .parent_node
= CONFIG_NODE
,
18484 .prompt
= "%s(config-router)# ",
18485 .config_write
= bgp_config_write
,
18488 static struct cmd_node bgp_ipv4_unicast_node
= {
18489 .name
= "bgp ipv4 unicast",
18490 .node
= BGP_IPV4_NODE
,
18491 .parent_node
= BGP_NODE
,
18492 .prompt
= "%s(config-router-af)# ",
18496 static struct cmd_node bgp_ipv4_multicast_node
= {
18497 .name
= "bgp ipv4 multicast",
18498 .node
= BGP_IPV4M_NODE
,
18499 .parent_node
= BGP_NODE
,
18500 .prompt
= "%s(config-router-af)# ",
18504 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18505 .name
= "bgp ipv4 labeled unicast",
18506 .node
= BGP_IPV4L_NODE
,
18507 .parent_node
= BGP_NODE
,
18508 .prompt
= "%s(config-router-af)# ",
18512 static struct cmd_node bgp_ipv6_unicast_node
= {
18513 .name
= "bgp ipv6 unicast",
18514 .node
= BGP_IPV6_NODE
,
18515 .parent_node
= BGP_NODE
,
18516 .prompt
= "%s(config-router-af)# ",
18520 static struct cmd_node bgp_ipv6_multicast_node
= {
18521 .name
= "bgp ipv6 multicast",
18522 .node
= BGP_IPV6M_NODE
,
18523 .parent_node
= BGP_NODE
,
18524 .prompt
= "%s(config-router-af)# ",
18528 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18529 .name
= "bgp ipv6 labeled unicast",
18530 .node
= BGP_IPV6L_NODE
,
18531 .parent_node
= BGP_NODE
,
18532 .prompt
= "%s(config-router-af)# ",
18536 static struct cmd_node bgp_vpnv4_node
= {
18537 .name
= "bgp vpnv4",
18538 .node
= BGP_VPNV4_NODE
,
18539 .parent_node
= BGP_NODE
,
18540 .prompt
= "%s(config-router-af)# ",
18544 static struct cmd_node bgp_vpnv6_node
= {
18545 .name
= "bgp vpnv6",
18546 .node
= BGP_VPNV6_NODE
,
18547 .parent_node
= BGP_NODE
,
18548 .prompt
= "%s(config-router-af-vpnv6)# ",
18552 static struct cmd_node bgp_evpn_node
= {
18553 .name
= "bgp evpn",
18554 .node
= BGP_EVPN_NODE
,
18555 .parent_node
= BGP_NODE
,
18556 .prompt
= "%s(config-router-evpn)# ",
18560 static struct cmd_node bgp_evpn_vni_node
= {
18561 .name
= "bgp evpn vni",
18562 .node
= BGP_EVPN_VNI_NODE
,
18563 .parent_node
= BGP_EVPN_NODE
,
18564 .prompt
= "%s(config-router-af-vni)# ",
18567 static struct cmd_node bgp_flowspecv4_node
= {
18568 .name
= "bgp ipv4 flowspec",
18569 .node
= BGP_FLOWSPECV4_NODE
,
18570 .parent_node
= BGP_NODE
,
18571 .prompt
= "%s(config-router-af)# ",
18575 static struct cmd_node bgp_flowspecv6_node
= {
18576 .name
= "bgp ipv6 flowspec",
18577 .node
= BGP_FLOWSPECV6_NODE
,
18578 .parent_node
= BGP_NODE
,
18579 .prompt
= "%s(config-router-af-vpnv6)# ",
18583 static struct cmd_node bgp_srv6_node
= {
18584 .name
= "bgp srv6",
18585 .node
= BGP_SRV6_NODE
,
18586 .parent_node
= BGP_NODE
,
18587 .prompt
= "%s(config-router-srv6)# ",
18590 static void community_list_vty(void);
18592 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18595 struct peer_group
*group
;
18596 struct listnode
*lnbgp
, *lnpeer
;
18598 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18599 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18601 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18605 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18609 struct listnode
*lnbgp
, *lnpeer
;
18611 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18612 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18613 /* only provide suggestions on the appropriate input
18615 * they'll otherwise show up multiple times */
18616 enum cmd_token_type match_type
;
18617 char *name
= peer
->host
;
18619 if (peer
->conf_if
) {
18620 match_type
= VARIABLE_TKN
;
18621 name
= peer
->conf_if
;
18622 } else if (strchr(peer
->host
, ':'))
18623 match_type
= IPV6_TKN
;
18625 match_type
= IPV4_TKN
;
18627 if (token
->type
!= match_type
)
18630 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18635 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18637 bgp_ac_peer(comps
, token
);
18639 if (token
->type
== VARIABLE_TKN
)
18640 bgp_ac_peergroup(comps
, token
);
18643 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18644 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18645 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18646 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18647 {.completions
= NULL
}};
18649 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18650 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18651 {.completions
= NULL
} };
18653 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18655 static struct thread
*t_bgp_cfg
;
18657 bool bgp_config_inprocess(void)
18659 return thread_is_scheduled(t_bgp_cfg
);
18662 static void bgp_config_finish(struct thread
*t
)
18664 struct listnode
*node
;
18667 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18668 hook_call(bgp_config_end
, bgp
);
18671 static void bgp_config_start(void)
18673 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18674 THREAD_OFF(t_bgp_cfg
);
18675 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18676 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18679 /* When we receive a hook the configuration is read,
18680 * we start a timer to make sure we postpone sending
18681 * EoR before route-maps are processed.
18682 * This is especially valid if using `bgp route-map delay-timer`.
18684 static void bgp_config_end(void)
18686 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18687 uint32_t bgp_post_config_delay
=
18688 thread_is_scheduled(bm
->t_rmap_update
)
18689 ? thread_timer_remain_second(bm
->t_rmap_update
)
18690 : BGP_POST_CONFIG_DELAY_SECONDS
;
18692 /* If BGP config processing thread isn't running, then
18693 * we can return and rely it's properly handled.
18695 if (!bgp_config_inprocess())
18698 THREAD_OFF(t_bgp_cfg
);
18700 /* Start a new timer to make sure we don't send EoR
18701 * before route-maps are processed.
18703 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18704 bgp_post_config_delay
, &t_bgp_cfg
);
18707 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18710 struct interface
*ifp
;
18711 struct bgp_interface
*iifp
;
18713 FOR_ALL_INTERFACES (vrf
, ifp
) {
18718 if_vty_config_start(vty
, ifp
);
18720 if (CHECK_FLAG(iifp
->flags
,
18721 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18722 vty_out(vty
, " mpls bgp forwarding\n");
18726 if_vty_config_end(vty
);
18732 /* Configuration write function for bgpd. */
18733 static int config_write_interface(struct vty
*vty
)
18736 struct vrf
*vrf
= NULL
;
18738 /* Display all VRF aware OSPF interface configuration */
18739 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18740 write
+= config_write_interface_one(vty
, vrf
);
18746 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18747 "[no$no] mpls bgp forwarding",
18748 NO_STR MPLS_STR BGP_STR
18749 "Enable MPLS forwarding for eBGP directly connected peers\n")
18752 struct bgp_interface
*iifp
;
18754 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18757 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18758 return CMD_WARNING_CONFIG_FAILED
;
18760 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18761 if (check
!= !no
) {
18763 UNSET_FLAG(iifp
->flags
,
18764 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18766 SET_FLAG(iifp
->flags
,
18767 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18768 /* trigger a nht update on eBGP sessions */
18769 if (if_is_operative(ifp
))
18770 bgp_nht_ifp_up(ifp
);
18772 return CMD_SUCCESS
;
18775 DEFPY (bgp_inq_limit
,
18777 "bgp input-queue-limit (1-4294967295)$limit",
18779 "Set the BGP Input Queue limit for all peers when message parsing\n"
18780 "Input-Queue limit\n")
18782 bm
->inq_limit
= limit
;
18784 return CMD_SUCCESS
;
18787 DEFPY (no_bgp_inq_limit
,
18788 no_bgp_inq_limit_cmd
,
18789 "no bgp input-queue-limit [(1-4294967295)$limit]",
18792 "Set the BGP Input Queue limit for all peers when message parsing\n"
18793 "Input-Queue limit\n")
18795 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18797 return CMD_SUCCESS
;
18800 DEFPY (bgp_outq_limit
,
18801 bgp_outq_limit_cmd
,
18802 "bgp output-queue-limit (1-4294967295)$limit",
18804 "Set the BGP Output Queue limit for all peers when message parsing\n"
18805 "Output-Queue limit\n")
18807 bm
->outq_limit
= limit
;
18809 return CMD_SUCCESS
;
18812 DEFPY (no_bgp_outq_limit
,
18813 no_bgp_outq_limit_cmd
,
18814 "no bgp output-queue-limit [(1-4294967295)$limit]",
18817 "Set the BGP Output Queue limit for all peers when message parsing\n"
18818 "Output-Queue limit\n")
18820 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18822 return CMD_SUCCESS
;
18826 /* Initialization of BGP interface. */
18827 static void bgp_vty_if_init(void)
18829 /* Install interface node. */
18830 if_cmd_init(config_write_interface
);
18832 /* "mpls bgp forwarding" commands. */
18833 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18836 void bgp_vty_init(void)
18838 cmd_variable_handler_register(bgp_var_neighbor
);
18839 cmd_variable_handler_register(bgp_var_peergroup
);
18841 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18843 /* Install bgp top node. */
18844 install_node(&bgp_node
);
18845 install_node(&bgp_ipv4_unicast_node
);
18846 install_node(&bgp_ipv4_multicast_node
);
18847 install_node(&bgp_ipv4_labeled_unicast_node
);
18848 install_node(&bgp_ipv6_unicast_node
);
18849 install_node(&bgp_ipv6_multicast_node
);
18850 install_node(&bgp_ipv6_labeled_unicast_node
);
18851 install_node(&bgp_vpnv4_node
);
18852 install_node(&bgp_vpnv6_node
);
18853 install_node(&bgp_evpn_node
);
18854 install_node(&bgp_evpn_vni_node
);
18855 install_node(&bgp_flowspecv4_node
);
18856 install_node(&bgp_flowspecv6_node
);
18857 install_node(&bgp_srv6_node
);
18859 /* Install default VTY commands to new nodes. */
18860 install_default(BGP_NODE
);
18861 install_default(BGP_IPV4_NODE
);
18862 install_default(BGP_IPV4M_NODE
);
18863 install_default(BGP_IPV4L_NODE
);
18864 install_default(BGP_IPV6_NODE
);
18865 install_default(BGP_IPV6M_NODE
);
18866 install_default(BGP_IPV6L_NODE
);
18867 install_default(BGP_VPNV4_NODE
);
18868 install_default(BGP_VPNV6_NODE
);
18869 install_default(BGP_FLOWSPECV4_NODE
);
18870 install_default(BGP_FLOWSPECV6_NODE
);
18871 install_default(BGP_EVPN_NODE
);
18872 install_default(BGP_EVPN_VNI_NODE
);
18873 install_default(BGP_SRV6_NODE
);
18875 /* "global bgp inq-limit command */
18876 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18877 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18878 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18879 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18881 /* "bgp local-mac" hidden commands. */
18882 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18883 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18885 /* "bgp suppress-fib-pending" global */
18886 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18888 /* bgp route-map delay-timer commands. */
18889 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18890 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18892 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18894 /* bgp fast-convergence command */
18895 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18896 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18898 /* global bgp update-delay command */
18899 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18900 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18902 /* global bgp graceful-shutdown command */
18903 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18904 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18906 /* Dummy commands (Currently not supported) */
18907 install_element(BGP_NODE
, &no_synchronization_cmd
);
18908 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18910 /* "router bgp" commands. */
18911 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18913 /* "no router bgp" commands. */
18914 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18916 /* "bgp session-dscp command */
18917 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18918 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18920 /* "bgp router-id" commands. */
18921 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18922 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18924 /* "bgp suppress-fib-pending" command */
18925 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18927 /* "bgp cluster-id" commands. */
18928 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18929 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18931 /* "bgp no-rib" commands. */
18932 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18933 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18935 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18937 /* "bgp confederation" commands. */
18938 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18939 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18941 /* "bgp confederation peers" commands. */
18942 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18943 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18945 /* bgp max-med command */
18946 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18947 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18948 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18949 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18950 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18952 /* "neighbor role" commands. */
18953 install_element(BGP_NODE
, &neighbor_role_cmd
);
18954 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18955 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18957 /* "neighbor aigp" commands. */
18958 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18960 /* "neighbor graceful-shutdown" command */
18961 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18963 /* bgp disable-ebgp-connected-nh-check */
18964 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18965 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18967 /* bgp update-delay command */
18968 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18969 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18971 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18972 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18974 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18975 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18977 /* "maximum-paths" commands. */
18978 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18979 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18980 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18981 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18982 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18983 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18984 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18985 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18986 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18987 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18988 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18989 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18990 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18991 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18992 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18994 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18995 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18996 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18997 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18998 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18999 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
19000 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
19001 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
19002 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
19003 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
19005 /* "timers bgp" commands. */
19006 install_element(BGP_NODE
, &bgp_timers_cmd
);
19007 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
19009 /* "minimum-holdtime" commands. */
19010 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
19011 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
19013 /* route-map delay-timer commands - per instance for backwards compat.
19015 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
19016 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
19018 /* "bgp client-to-client reflection" commands */
19019 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
19020 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
19022 /* "bgp always-compare-med" commands */
19023 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
19024 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
19026 /* bgp ebgp-requires-policy */
19027 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
19028 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
19030 /* bgp suppress-duplicates */
19031 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
19032 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
19034 /* bgp reject-as-sets */
19035 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
19036 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
19038 /* "bgp deterministic-med" commands */
19039 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
19040 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
19042 /* "bgp graceful-restart" command */
19043 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
19044 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
19046 /* "bgp graceful-restart-disable" command */
19047 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
19048 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
19050 /* "neighbor a:b:c:d graceful-restart" command */
19051 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
19052 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
19054 /* "neighbor a:b:c:d graceful-restart-disable" command */
19055 install_element(BGP_NODE
,
19056 &bgp_neighbor_graceful_restart_disable_set_cmd
);
19057 install_element(BGP_NODE
,
19058 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
19060 /* "neighbor a:b:c:d graceful-restart-helper" command */
19061 install_element(BGP_NODE
,
19062 &bgp_neighbor_graceful_restart_helper_set_cmd
);
19063 install_element(BGP_NODE
,
19064 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
19066 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
19067 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
19068 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
19069 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
19070 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
19071 install_element(BGP_NODE
,
19072 &no_bgp_graceful_restart_select_defer_time_cmd
);
19073 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
19074 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
19075 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
19077 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
19078 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
19079 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
19080 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
19082 /* "bgp graceful-shutdown" commands */
19083 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
19084 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
19086 /* "bgp hard-administrative-reset" commands */
19087 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
19089 /* "bgp long-lived-graceful-restart" commands */
19090 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
19091 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
19093 /* "bgp fast-external-failover" commands */
19094 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
19095 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
19097 /* "bgp bestpath aigp" commands */
19098 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
19100 /* "bgp bestpath compare-routerid" commands */
19101 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
19102 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
19104 /* "bgp bestpath as-path ignore" commands */
19105 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
19106 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
19108 /* "bgp bestpath as-path confed" commands */
19109 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
19110 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
19112 /* "bgp bestpath as-path multipath-relax" commands */
19113 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
19114 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
19116 /* "bgp bestpath peer-type multipath-relax" commands */
19117 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
19118 install_element(BGP_NODE
,
19119 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
19121 /* "bgp log-neighbor-changes" commands */
19122 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
19123 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
19125 /* "bgp bestpath med" commands */
19126 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
19127 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
19129 /* "bgp bestpath bandwidth" commands */
19130 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
19131 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
19133 /* "no bgp default <afi>-<safi>" commands. */
19134 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
19136 /* "bgp network import-check" commands. */
19137 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
19138 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
19139 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
19141 /* "bgp default local-preference" commands. */
19142 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19143 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19145 /* bgp default show-hostname */
19146 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19147 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19149 /* bgp default show-nexthop-hostname */
19150 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19151 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19153 /* "bgp default subgroup-pkt-queue-max" commands. */
19154 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19155 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19157 /* bgp ibgp-allow-policy-mods command */
19158 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19159 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19161 /* "bgp listen limit" commands. */
19162 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19163 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19165 /* "bgp listen range" commands. */
19166 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19167 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19169 /* "bgp default shutdown" command */
19170 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19172 /* "bgp shutdown" commands */
19173 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19174 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19175 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19176 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19178 /* "neighbor remote-as" commands. */
19179 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19180 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19181 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19182 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19183 install_element(BGP_NODE
,
19184 &neighbor_interface_v6only_config_remote_as_cmd
);
19185 install_element(BGP_NODE
, &no_neighbor_cmd
);
19186 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19188 /* "neighbor peer-group" commands. */
19189 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19190 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19191 install_element(BGP_NODE
,
19192 &no_neighbor_interface_peer_group_remote_as_cmd
);
19194 /* "neighbor local-as" commands. */
19195 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19196 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19197 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19198 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19200 /* "neighbor solo" commands. */
19201 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19202 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19204 /* "neighbor password" commands. */
19205 install_element(BGP_NODE
, &neighbor_password_cmd
);
19206 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19208 /* "neighbor activate" commands. */
19209 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19210 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19211 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19212 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19213 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19214 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19215 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19216 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19217 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19218 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19219 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19220 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19222 /* "no neighbor activate" commands. */
19223 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19224 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19225 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19226 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19227 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19228 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19229 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19230 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19231 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19232 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19233 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19234 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19236 /* "neighbor peer-group" set commands. */
19237 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19238 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19239 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19240 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19241 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19242 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19243 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19244 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19245 install_element(BGP_FLOWSPECV4_NODE
,
19246 &neighbor_set_peer_group_hidden_cmd
);
19247 install_element(BGP_FLOWSPECV6_NODE
,
19248 &neighbor_set_peer_group_hidden_cmd
);
19250 /* "no neighbor peer-group unset" commands. */
19251 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19252 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19253 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19254 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19255 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19256 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19257 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19258 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19259 install_element(BGP_FLOWSPECV4_NODE
,
19260 &no_neighbor_set_peer_group_hidden_cmd
);
19261 install_element(BGP_FLOWSPECV6_NODE
,
19262 &no_neighbor_set_peer_group_hidden_cmd
);
19264 /* "neighbor softreconfiguration inbound" commands.*/
19265 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19266 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19267 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19268 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19269 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19270 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19271 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19272 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19273 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19274 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19275 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19276 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19277 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19278 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19279 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19280 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19281 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19282 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19283 install_element(BGP_FLOWSPECV4_NODE
,
19284 &neighbor_soft_reconfiguration_cmd
);
19285 install_element(BGP_FLOWSPECV4_NODE
,
19286 &no_neighbor_soft_reconfiguration_cmd
);
19287 install_element(BGP_FLOWSPECV6_NODE
,
19288 &neighbor_soft_reconfiguration_cmd
);
19289 install_element(BGP_FLOWSPECV6_NODE
,
19290 &no_neighbor_soft_reconfiguration_cmd
);
19291 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19292 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19294 /* "neighbor attribute-unchanged" commands. */
19295 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19296 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19297 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19298 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19299 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19300 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19301 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19302 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19303 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19304 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19305 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19306 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19307 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19308 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19309 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19310 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19311 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19312 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19314 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19315 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19317 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19318 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19319 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19320 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19322 /* "nexthop-local unchanged" commands */
19323 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19324 install_element(BGP_IPV6_NODE
,
19325 &no_neighbor_nexthop_local_unchanged_cmd
);
19327 /* "neighbor next-hop-self" commands. */
19328 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19329 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19330 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19331 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19332 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19333 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19334 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19335 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19336 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19337 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19338 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19339 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19340 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19341 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19342 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19343 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19344 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19345 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19346 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19347 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19349 /* "neighbor next-hop-self force" commands. */
19350 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19351 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19352 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19353 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19354 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19355 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19356 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19357 install_element(BGP_IPV4_NODE
,
19358 &no_neighbor_nexthop_self_all_hidden_cmd
);
19359 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19360 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19361 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19362 install_element(BGP_IPV4M_NODE
,
19363 &no_neighbor_nexthop_self_all_hidden_cmd
);
19364 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19365 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19366 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19367 install_element(BGP_IPV4L_NODE
,
19368 &no_neighbor_nexthop_self_all_hidden_cmd
);
19369 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19370 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19371 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19372 install_element(BGP_IPV6_NODE
,
19373 &no_neighbor_nexthop_self_all_hidden_cmd
);
19374 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19375 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19376 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19377 install_element(BGP_IPV6M_NODE
,
19378 &no_neighbor_nexthop_self_all_hidden_cmd
);
19379 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19380 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19381 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19382 install_element(BGP_IPV6L_NODE
,
19383 &no_neighbor_nexthop_self_all_hidden_cmd
);
19384 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19385 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19386 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19387 install_element(BGP_VPNV4_NODE
,
19388 &no_neighbor_nexthop_self_all_hidden_cmd
);
19389 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19390 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19391 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19392 install_element(BGP_VPNV6_NODE
,
19393 &no_neighbor_nexthop_self_all_hidden_cmd
);
19394 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19395 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19397 /* "neighbor as-override" commands. */
19398 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19399 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19400 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19401 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19402 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19403 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19404 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19405 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19406 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19407 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19408 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19409 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19410 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19411 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19412 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19413 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19414 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19415 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19417 /* "neighbor remove-private-AS" commands. */
19418 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19419 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19420 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19421 install_element(BGP_NODE
,
19422 &no_neighbor_remove_private_as_all_hidden_cmd
);
19423 install_element(BGP_NODE
,
19424 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19425 install_element(BGP_NODE
,
19426 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19427 install_element(BGP_NODE
,
19428 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19431 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19432 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19433 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19434 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19435 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19436 install_element(BGP_IPV4_NODE
,
19437 &neighbor_remove_private_as_replace_as_cmd
);
19438 install_element(BGP_IPV4_NODE
,
19439 &no_neighbor_remove_private_as_replace_as_cmd
);
19440 install_element(BGP_IPV4_NODE
,
19441 &neighbor_remove_private_as_all_replace_as_cmd
);
19442 install_element(BGP_IPV4_NODE
,
19443 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19444 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19445 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19446 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19447 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19448 install_element(BGP_IPV4M_NODE
,
19449 &neighbor_remove_private_as_replace_as_cmd
);
19450 install_element(BGP_IPV4M_NODE
,
19451 &no_neighbor_remove_private_as_replace_as_cmd
);
19452 install_element(BGP_IPV4M_NODE
,
19453 &neighbor_remove_private_as_all_replace_as_cmd
);
19454 install_element(BGP_IPV4M_NODE
,
19455 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19456 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19457 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19458 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19459 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19460 install_element(BGP_IPV4L_NODE
,
19461 &neighbor_remove_private_as_replace_as_cmd
);
19462 install_element(BGP_IPV4L_NODE
,
19463 &no_neighbor_remove_private_as_replace_as_cmd
);
19464 install_element(BGP_IPV4L_NODE
,
19465 &neighbor_remove_private_as_all_replace_as_cmd
);
19466 install_element(BGP_IPV4L_NODE
,
19467 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19468 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19469 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19470 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19471 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19472 install_element(BGP_IPV6_NODE
,
19473 &neighbor_remove_private_as_replace_as_cmd
);
19474 install_element(BGP_IPV6_NODE
,
19475 &no_neighbor_remove_private_as_replace_as_cmd
);
19476 install_element(BGP_IPV6_NODE
,
19477 &neighbor_remove_private_as_all_replace_as_cmd
);
19478 install_element(BGP_IPV6_NODE
,
19479 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19480 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19481 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19482 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19483 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19484 install_element(BGP_IPV6M_NODE
,
19485 &neighbor_remove_private_as_replace_as_cmd
);
19486 install_element(BGP_IPV6M_NODE
,
19487 &no_neighbor_remove_private_as_replace_as_cmd
);
19488 install_element(BGP_IPV6M_NODE
,
19489 &neighbor_remove_private_as_all_replace_as_cmd
);
19490 install_element(BGP_IPV6M_NODE
,
19491 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19492 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19493 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19494 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19495 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19496 install_element(BGP_IPV6L_NODE
,
19497 &neighbor_remove_private_as_replace_as_cmd
);
19498 install_element(BGP_IPV6L_NODE
,
19499 &no_neighbor_remove_private_as_replace_as_cmd
);
19500 install_element(BGP_IPV6L_NODE
,
19501 &neighbor_remove_private_as_all_replace_as_cmd
);
19502 install_element(BGP_IPV6L_NODE
,
19503 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19504 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19505 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19506 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19507 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19508 install_element(BGP_VPNV4_NODE
,
19509 &neighbor_remove_private_as_replace_as_cmd
);
19510 install_element(BGP_VPNV4_NODE
,
19511 &no_neighbor_remove_private_as_replace_as_cmd
);
19512 install_element(BGP_VPNV4_NODE
,
19513 &neighbor_remove_private_as_all_replace_as_cmd
);
19514 install_element(BGP_VPNV4_NODE
,
19515 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19516 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19517 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19518 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19519 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19520 install_element(BGP_VPNV6_NODE
,
19521 &neighbor_remove_private_as_replace_as_cmd
);
19522 install_element(BGP_VPNV6_NODE
,
19523 &no_neighbor_remove_private_as_replace_as_cmd
);
19524 install_element(BGP_VPNV6_NODE
,
19525 &neighbor_remove_private_as_all_replace_as_cmd
);
19526 install_element(BGP_VPNV6_NODE
,
19527 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19529 /* "neighbor send-community" commands.*/
19530 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19531 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19532 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19533 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19534 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19535 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19536 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19537 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19538 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19539 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19540 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19541 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19542 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19543 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19544 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19545 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19546 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19547 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19548 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19549 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19550 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19551 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19552 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19553 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19554 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19555 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19556 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19557 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19558 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19559 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19560 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19561 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19562 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19563 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19564 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19565 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19567 /* "neighbor route-reflector" commands.*/
19568 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19569 install_element(BGP_NODE
,
19570 &no_neighbor_route_reflector_client_hidden_cmd
);
19571 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19572 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19573 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19574 install_element(BGP_IPV4M_NODE
,
19575 &no_neighbor_route_reflector_client_cmd
);
19576 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19577 install_element(BGP_IPV4L_NODE
,
19578 &no_neighbor_route_reflector_client_cmd
);
19579 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19580 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19581 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19582 install_element(BGP_IPV6M_NODE
,
19583 &no_neighbor_route_reflector_client_cmd
);
19584 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19585 install_element(BGP_IPV6L_NODE
,
19586 &no_neighbor_route_reflector_client_cmd
);
19587 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19588 install_element(BGP_VPNV4_NODE
,
19589 &no_neighbor_route_reflector_client_cmd
);
19590 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19591 install_element(BGP_VPNV6_NODE
,
19592 &no_neighbor_route_reflector_client_cmd
);
19593 install_element(BGP_FLOWSPECV4_NODE
,
19594 &neighbor_route_reflector_client_cmd
);
19595 install_element(BGP_FLOWSPECV4_NODE
,
19596 &no_neighbor_route_reflector_client_cmd
);
19597 install_element(BGP_FLOWSPECV6_NODE
,
19598 &neighbor_route_reflector_client_cmd
);
19599 install_element(BGP_FLOWSPECV6_NODE
,
19600 &no_neighbor_route_reflector_client_cmd
);
19601 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19602 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19604 /* "neighbor route-server" commands.*/
19605 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19606 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19607 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19608 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19609 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19610 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19611 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19612 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19613 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19614 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19615 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19616 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19617 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19618 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19619 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19620 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19621 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19622 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19623 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19624 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19625 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19626 install_element(BGP_FLOWSPECV4_NODE
,
19627 &no_neighbor_route_server_client_cmd
);
19628 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19629 install_element(BGP_FLOWSPECV6_NODE
,
19630 &no_neighbor_route_server_client_cmd
);
19632 /* "neighbor disable-addpath-rx" commands. */
19633 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19634 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19635 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19636 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19637 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19638 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19639 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19640 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19641 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19642 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19643 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19644 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19645 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19646 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19647 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19648 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19650 /* "neighbor addpath-tx-all-paths" commands.*/
19651 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19652 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19653 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19654 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19655 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19656 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19657 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19658 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19659 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19660 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19661 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19662 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19663 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19664 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19665 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19666 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19667 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19668 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19670 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19671 install_element(BGP_NODE
,
19672 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19673 install_element(BGP_NODE
,
19674 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19675 install_element(BGP_IPV4_NODE
,
19676 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19677 install_element(BGP_IPV4_NODE
,
19678 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19679 install_element(BGP_IPV4M_NODE
,
19680 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19681 install_element(BGP_IPV4M_NODE
,
19682 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19683 install_element(BGP_IPV4L_NODE
,
19684 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19685 install_element(BGP_IPV4L_NODE
,
19686 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19687 install_element(BGP_IPV6_NODE
,
19688 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19689 install_element(BGP_IPV6_NODE
,
19690 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19691 install_element(BGP_IPV6M_NODE
,
19692 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19693 install_element(BGP_IPV6M_NODE
,
19694 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19695 install_element(BGP_IPV6L_NODE
,
19696 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19697 install_element(BGP_IPV6L_NODE
,
19698 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19699 install_element(BGP_VPNV4_NODE
,
19700 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19701 install_element(BGP_VPNV4_NODE
,
19702 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19703 install_element(BGP_VPNV6_NODE
,
19704 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19705 install_element(BGP_VPNV6_NODE
,
19706 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19708 /* "neighbor sender-as-path-loop-detection" commands. */
19709 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19710 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19712 /* "neighbor path-attribute discard" commands. */
19713 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19714 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19716 /* "neighbor path-attribute treat-as-withdraw" commands. */
19717 install_element(BGP_NODE
,
19718 &neighbor_path_attribute_treat_as_withdraw_cmd
);
19719 install_element(BGP_NODE
,
19720 &no_neighbor_path_attribute_treat_as_withdraw_cmd
);
19722 /* "neighbor passive" commands. */
19723 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19724 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19727 /* "neighbor shutdown" commands. */
19728 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19729 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19730 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19731 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19732 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19733 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19735 /* "neighbor capability extended-nexthop" commands.*/
19736 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19737 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19739 /* "neighbor capability software-version" commands.*/
19740 install_element(BGP_NODE
, &neighbor_capability_software_version_cmd
);
19742 /* "neighbor capability orf prefix-list" commands.*/
19743 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19744 install_element(BGP_NODE
,
19745 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19746 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19747 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19748 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19749 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19750 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19751 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19752 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19753 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19754 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19755 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19756 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19757 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19759 /* "neighbor capability dynamic" commands.*/
19760 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19761 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19763 /* "neighbor dont-capability-negotiate" commands. */
19764 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19765 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19767 /* "neighbor ebgp-multihop" commands. */
19768 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19769 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19770 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19772 /* "neighbor disable-connected-check" commands. */
19773 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19774 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19776 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19777 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19778 install_element(BGP_NODE
,
19779 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19781 /* "neighbor extended-optional-parameters" commands. */
19782 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19783 install_element(BGP_NODE
,
19784 &no_neighbor_extended_optional_parameters_cmd
);
19786 /* "neighbor enforce-first-as" commands. */
19787 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19788 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19790 /* "neighbor description" commands. */
19791 install_element(BGP_NODE
, &neighbor_description_cmd
);
19792 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19793 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19795 /* "neighbor update-source" commands. "*/
19796 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19797 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19799 /* "neighbor default-originate" commands. */
19800 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19801 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19802 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19803 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19804 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19805 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19806 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19807 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19808 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19809 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19810 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19811 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19812 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19813 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19814 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19815 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19816 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19817 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19818 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19819 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19820 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19822 /* "neighbor port" commands. */
19823 install_element(BGP_NODE
, &neighbor_port_cmd
);
19824 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19826 /* "neighbor weight" commands. */
19827 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19828 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19830 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19831 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19832 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19833 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19834 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19835 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19836 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19837 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19838 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19839 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19840 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19841 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19842 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19843 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19844 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19845 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19847 /* "neighbor override-capability" commands. */
19848 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19849 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19851 /* "neighbor strict-capability-match" commands. */
19852 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19853 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19855 /* "neighbor timers" commands. */
19856 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19857 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19859 /* "neighbor timers connect" commands. */
19860 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19861 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19863 /* "neighbor timers delayopen" commands. */
19864 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19865 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19867 /* "neighbor advertisement-interval" commands. */
19868 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19869 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19871 /* "neighbor interface" commands. */
19872 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19873 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19875 /* "neighbor distribute" commands. */
19876 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19877 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19878 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19879 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19880 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19881 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19882 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19883 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19884 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19885 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19886 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19887 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19888 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19889 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19890 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19891 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19892 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19893 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19895 /* "neighbor prefix-list" commands. */
19896 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19897 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19898 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19899 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19900 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19901 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19902 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19903 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19904 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19905 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19906 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19907 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19908 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19909 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19910 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19911 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19912 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19913 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19914 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19915 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19916 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19917 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19919 /* "neighbor filter-list" commands. */
19920 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19921 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19922 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19923 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19924 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19925 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19926 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19927 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19928 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19929 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19930 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19931 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19932 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19933 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19934 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19935 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19936 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19937 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19938 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19939 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19940 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19941 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19943 /* "neighbor route-map" commands. */
19944 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19945 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19946 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19947 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19948 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19949 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19950 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19951 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19952 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19953 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19954 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19955 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19956 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19957 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19958 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19959 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19960 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19961 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19962 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19963 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19964 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19965 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19966 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19967 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19969 /* "neighbor unsuppress-map" commands. */
19970 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19971 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19972 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19973 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19974 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19975 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19976 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19977 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19978 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19979 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19980 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19981 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19982 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19983 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19984 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19985 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19986 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19987 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19989 /* "neighbor advertise-map" commands. */
19990 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19991 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19992 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19993 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19994 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19995 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19996 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19997 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19998 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19999 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
20001 /* neighbor maximum-prefix-out commands. */
20002 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
20003 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20004 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
20005 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20006 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
20007 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20008 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
20009 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20010 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
20011 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20012 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
20013 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20014 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
20015 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20016 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
20017 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20018 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
20019 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
20021 /* "neighbor maximum-prefix" commands. */
20022 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
20023 install_element(BGP_NODE
,
20024 &neighbor_maximum_prefix_threshold_hidden_cmd
);
20025 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
20026 install_element(BGP_NODE
,
20027 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
20028 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
20029 install_element(BGP_NODE
,
20030 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
20031 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
20032 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
20033 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20034 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20035 install_element(BGP_IPV4_NODE
,
20036 &neighbor_maximum_prefix_threshold_warning_cmd
);
20037 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20038 install_element(BGP_IPV4_NODE
,
20039 &neighbor_maximum_prefix_threshold_restart_cmd
);
20040 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20041 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
20042 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20043 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20044 install_element(BGP_IPV4M_NODE
,
20045 &neighbor_maximum_prefix_threshold_warning_cmd
);
20046 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20047 install_element(BGP_IPV4M_NODE
,
20048 &neighbor_maximum_prefix_threshold_restart_cmd
);
20049 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
20050 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
20051 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20052 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20053 install_element(BGP_IPV4L_NODE
,
20054 &neighbor_maximum_prefix_threshold_warning_cmd
);
20055 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20056 install_element(BGP_IPV4L_NODE
,
20057 &neighbor_maximum_prefix_threshold_restart_cmd
);
20058 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20059 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
20060 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20061 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20062 install_element(BGP_IPV6_NODE
,
20063 &neighbor_maximum_prefix_threshold_warning_cmd
);
20064 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20065 install_element(BGP_IPV6_NODE
,
20066 &neighbor_maximum_prefix_threshold_restart_cmd
);
20067 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20068 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
20069 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20070 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20071 install_element(BGP_IPV6M_NODE
,
20072 &neighbor_maximum_prefix_threshold_warning_cmd
);
20073 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20074 install_element(BGP_IPV6M_NODE
,
20075 &neighbor_maximum_prefix_threshold_restart_cmd
);
20076 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
20077 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
20078 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20079 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20080 install_element(BGP_IPV6L_NODE
,
20081 &neighbor_maximum_prefix_threshold_warning_cmd
);
20082 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20083 install_element(BGP_IPV6L_NODE
,
20084 &neighbor_maximum_prefix_threshold_restart_cmd
);
20085 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20086 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
20087 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20088 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20089 install_element(BGP_VPNV4_NODE
,
20090 &neighbor_maximum_prefix_threshold_warning_cmd
);
20091 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20092 install_element(BGP_VPNV4_NODE
,
20093 &neighbor_maximum_prefix_threshold_restart_cmd
);
20094 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20095 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
20096 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20097 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20098 install_element(BGP_VPNV6_NODE
,
20099 &neighbor_maximum_prefix_threshold_warning_cmd
);
20100 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20101 install_element(BGP_VPNV6_NODE
,
20102 &neighbor_maximum_prefix_threshold_restart_cmd
);
20103 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20105 /* "neighbor allowas-in" */
20106 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
20107 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
20108 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
20109 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
20110 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
20111 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
20112 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
20113 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
20114 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
20115 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
20116 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
20117 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
20118 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
20119 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
20120 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
20121 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
20122 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
20123 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
20124 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
20125 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
20127 /* neighbor accept-own */
20128 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
20129 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
20131 /* "neighbor soo" */
20132 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
20133 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
20134 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
20135 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
20136 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
20137 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
20138 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
20139 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
20140 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
20141 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
20142 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
20143 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
20144 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
20145 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
20146 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
20147 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
20148 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
20149 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
20151 /* address-family commands. */
20152 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20153 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20154 #ifdef KEEP_OLD_VPN_COMMANDS
20155 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20156 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20157 #endif /* KEEP_OLD_VPN_COMMANDS */
20159 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20161 /* "exit-address-family" command. */
20162 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20163 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20164 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20165 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20166 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20167 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20168 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20169 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20170 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20171 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20172 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20174 /* BGP retain all route-target */
20175 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20176 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20178 /* "clear ip bgp commands" */
20179 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20181 /* clear ip bgp prefix */
20182 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20183 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20184 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20186 /* "show [ip] bgp summary" commands. */
20187 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20188 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20189 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20190 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20191 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20192 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20193 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20195 /* "show [ip] bgp neighbors" commands. */
20196 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20198 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20200 /* "show [ip] bgp peer-group" commands. */
20201 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20203 /* "show [ip] bgp paths" commands. */
20204 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20206 /* "show [ip] bgp community" commands. */
20207 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20209 /* "show ip bgp large-community" commands. */
20210 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20211 /* "show [ip] bgp attribute-info" commands. */
20212 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20213 /* "show [ip] bgp route-leak" command */
20214 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20216 /* "redistribute" commands. */
20217 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20218 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20219 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20220 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20221 install_element(BGP_NODE
,
20222 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20223 install_element(BGP_NODE
,
20224 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20225 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20226 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20227 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20228 install_element(BGP_NODE
,
20229 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20230 install_element(BGP_NODE
,
20231 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20232 install_element(BGP_NODE
,
20233 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20234 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20235 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20236 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20237 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20238 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20239 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20240 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20241 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20242 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20243 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20244 install_element(BGP_IPV4_NODE
,
20245 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20246 install_element(BGP_IPV4_NODE
,
20247 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20248 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20249 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20250 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20251 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20252 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20253 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20255 /* import|export vpn [route-map RMAP_NAME] */
20256 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20257 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20259 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20260 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20262 /* ttl_security commands */
20263 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20264 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20266 /* "bgp tcp-keepalive" commands */
20267 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20268 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20270 /* "show [ip] bgp memory" commands. */
20271 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20273 /* "show bgp martian next-hop" */
20274 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20276 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20278 /* "show [ip] bgp views" commands. */
20279 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20281 /* "show [ip] bgp vrfs" commands. */
20282 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20284 /* Community-list. */
20285 community_list_vty();
20287 community_alias_vty();
20289 /* vpn-policy commands */
20290 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20291 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20292 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20293 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20294 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20295 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20296 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20297 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20298 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20299 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20300 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20301 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20303 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20304 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20306 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20307 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20308 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20309 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20310 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20311 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20312 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20313 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20314 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20315 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20317 /* tcp-mss command */
20318 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20319 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20321 /* srv6 commands */
20322 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20323 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20324 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20325 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20326 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20327 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20328 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20329 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20330 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20335 #include "memory.h"
20336 #include "bgp_regex.h"
20337 #include "bgp_clist.h"
20338 #include "bgp_ecommunity.h"
20340 /* VTY functions. */
20342 /* Direction value to string conversion. */
20343 static const char *community_direct_str(int direct
)
20346 case COMMUNITY_DENY
:
20348 case COMMUNITY_PERMIT
:
20355 /* Display error string. */
20356 static void community_list_perror(struct vty
*vty
, int ret
)
20359 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20360 vty_out(vty
, "%% Can't find community-list\n");
20362 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20363 vty_out(vty
, "%% Malformed community-list value\n");
20365 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20367 "%% Community name conflict, previously defined as standard community\n");
20369 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20371 "%% Community name conflict, previously defined as expanded community\n");
20376 /* "community-list" keyword help string. */
20377 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20379 /*community-list standard */
20380 DEFUN (community_list_standard
,
20381 bgp_community_list_standard_cmd
,
20382 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20385 "Community list number (standard)\n"
20386 "Add an standard community-list entry\n"
20387 "Community list name\n"
20388 "Sequence number of an entry\n"
20389 "Sequence number\n"
20390 "Specify community to reject\n"
20391 "Specify community to accept\n"
20394 char *cl_name_or_number
= NULL
;
20397 int style
= COMMUNITY_LIST_STANDARD
;
20400 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20401 seq
= argv
[idx
]->arg
;
20404 argv_find(argv
, argc
, "(1-99)", &idx
);
20405 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20406 cl_name_or_number
= argv
[idx
]->arg
;
20407 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20409 argv_find(argv
, argc
, "AA:NN", &idx
);
20410 char *str
= argv_concat(argv
, argc
, idx
);
20412 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20415 XFREE(MTYPE_TMP
, str
);
20418 /* Display error string. */
20419 community_list_perror(vty
, ret
);
20420 return CMD_WARNING_CONFIG_FAILED
;
20423 return CMD_SUCCESS
;
20426 DEFUN (no_community_list_standard_all
,
20427 no_bgp_community_list_standard_all_cmd
,
20428 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20432 "Community list number (standard)\n"
20433 "Add an standard community-list entry\n"
20434 "Community list name\n"
20435 "Sequence number of an entry\n"
20436 "Sequence number\n"
20437 "Specify community to reject\n"
20438 "Specify community to accept\n"
20441 char *cl_name_or_number
= NULL
;
20444 int style
= COMMUNITY_LIST_STANDARD
;
20448 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20449 seq
= argv
[idx
]->arg
;
20452 argv_find(argv
, argc
, "permit", &idx
);
20453 argv_find(argv
, argc
, "deny", &idx
);
20456 direct
= argv_find(argv
, argc
, "permit", &idx
)
20461 argv_find(argv
, argc
, "AA:NN", &idx
);
20462 str
= argv_concat(argv
, argc
, idx
);
20466 argv_find(argv
, argc
, "(1-99)", &idx
);
20467 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20468 cl_name_or_number
= argv
[idx
]->arg
;
20470 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20473 XFREE(MTYPE_TMP
, str
);
20476 community_list_perror(vty
, ret
);
20477 return CMD_WARNING_CONFIG_FAILED
;
20480 return CMD_SUCCESS
;
20483 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20484 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20485 NO_STR BGP_STR COMMUNITY_LIST_STR
20486 "Community list number (standard)\n"
20487 "Add an standard community-list entry\n"
20488 "Community list name\n")
20490 /*community-list expanded */
20491 DEFUN (community_list_expanded_all
,
20492 bgp_community_list_expanded_all_cmd
,
20493 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20496 "Community list number (expanded)\n"
20497 "Add an expanded community-list entry\n"
20498 "Community list name\n"
20499 "Sequence number of an entry\n"
20500 "Sequence number\n"
20501 "Specify community to reject\n"
20502 "Specify community to accept\n"
20505 char *cl_name_or_number
= NULL
;
20508 int style
= COMMUNITY_LIST_EXPANDED
;
20511 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20512 seq
= argv
[idx
]->arg
;
20516 argv_find(argv
, argc
, "(100-500)", &idx
);
20517 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20518 cl_name_or_number
= argv
[idx
]->arg
;
20519 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20521 argv_find(argv
, argc
, "AA:NN", &idx
);
20522 char *str
= argv_concat(argv
, argc
, idx
);
20524 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20527 XFREE(MTYPE_TMP
, str
);
20530 /* Display error string. */
20531 community_list_perror(vty
, ret
);
20532 return CMD_WARNING_CONFIG_FAILED
;
20535 return CMD_SUCCESS
;
20538 DEFUN (no_community_list_expanded_all
,
20539 no_bgp_community_list_expanded_all_cmd
,
20540 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20544 "Community list number (expanded)\n"
20545 "Add an expanded community-list entry\n"
20546 "Community list name\n"
20547 "Sequence number of an entry\n"
20548 "Sequence number\n"
20549 "Specify community to reject\n"
20550 "Specify community to accept\n"
20553 char *cl_name_or_number
= NULL
;
20557 int style
= COMMUNITY_LIST_EXPANDED
;
20560 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20561 seq
= argv
[idx
]->arg
;
20564 argv_find(argv
, argc
, "permit", &idx
);
20565 argv_find(argv
, argc
, "deny", &idx
);
20568 direct
= argv_find(argv
, argc
, "permit", &idx
)
20573 argv_find(argv
, argc
, "AA:NN", &idx
);
20574 str
= argv_concat(argv
, argc
, idx
);
20578 argv_find(argv
, argc
, "(100-500)", &idx
);
20579 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20580 cl_name_or_number
= argv
[idx
]->arg
;
20582 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20585 XFREE(MTYPE_TMP
, str
);
20588 community_list_perror(vty
, ret
);
20589 return CMD_WARNING_CONFIG_FAILED
;
20592 return CMD_SUCCESS
;
20595 ALIAS(no_community_list_expanded_all
,
20596 no_bgp_community_list_expanded_all_list_cmd
,
20597 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20598 NO_STR BGP_STR COMMUNITY_LIST_STR
20599 "Community list number (expanded)\n"
20600 "Add an expanded community-list entry\n"
20601 "Community list name\n")
20603 /* Return configuration string of community-list entry. */
20604 static const char *community_list_config_str(struct community_entry
*entry
)
20611 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20612 str
= community_str(entry
->u
.com
, false, false);
20613 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20614 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20616 str
= entry
->config
;
20621 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20623 struct community_entry
*entry
;
20625 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20626 if (entry
== list
->head
) {
20627 if (all_digit(list
->name
))
20628 vty_out(vty
, "Community %s list %s\n",
20629 entry
->style
== COMMUNITY_LIST_STANDARD
20631 : "(expanded) access",
20634 vty_out(vty
, "Named Community %s list %s\n",
20635 entry
->style
== COMMUNITY_LIST_STANDARD
20641 vty_out(vty
, " %s\n",
20642 community_direct_str(entry
->direct
));
20644 vty_out(vty
, " %s %s\n",
20645 community_direct_str(entry
->direct
),
20646 community_list_config_str(entry
));
20650 DEFUN (show_community_list
,
20651 show_bgp_community_list_cmd
,
20652 "show bgp community-list",
20655 "List community-list\n")
20657 struct community_list
*list
;
20658 struct community_list_master
*cm
;
20660 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20662 return CMD_SUCCESS
;
20664 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20665 community_list_show(vty
, list
);
20667 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20668 community_list_show(vty
, list
);
20670 return CMD_SUCCESS
;
20673 DEFUN (show_community_list_arg
,
20674 show_bgp_community_list_arg_cmd
,
20675 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20678 "List community-list\n"
20679 "Community-list number\n"
20680 "Community-list name\n"
20681 "Detailed information on community-list\n")
20683 int idx_comm_list
= 3;
20684 struct community_list
*list
;
20686 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20687 COMMUNITY_LIST_MASTER
);
20689 vty_out(vty
, "%% Can't find community-list\n");
20690 return CMD_WARNING
;
20693 community_list_show(vty
, list
);
20695 return CMD_SUCCESS
;
20699 * Large Community code.
20701 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20702 struct cmd_token
**argv
, int style
,
20703 int reject_all_digit_name
)
20712 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20713 seq
= argv
[idx
]->arg
;
20716 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20719 /* All digit name check. */
20721 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20722 argv_find(argv
, argc
, "(1-99)", &idx
);
20723 argv_find(argv
, argc
, "(100-500)", &idx
);
20724 cl_name
= argv
[idx
]->arg
;
20725 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20726 vty_out(vty
, "%% Community name cannot have all digits\n");
20727 return CMD_WARNING_CONFIG_FAILED
;
20731 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20732 argv_find(argv
, argc
, "LINE", &idx
);
20733 /* Concat community string argument. */
20735 str
= argv_concat(argv
, argc
, idx
);
20739 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20741 /* Free temporary community list string allocated by
20743 XFREE(MTYPE_TMP
, str
);
20746 community_list_perror(vty
, ret
);
20747 return CMD_WARNING_CONFIG_FAILED
;
20749 return CMD_SUCCESS
;
20752 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20753 struct cmd_token
**argv
, int style
)
20761 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20762 seq
= argv
[idx
]->arg
;
20765 argv_find(argv
, argc
, "permit", &idx
);
20766 argv_find(argv
, argc
, "deny", &idx
);
20769 /* Check the list direct. */
20770 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20771 direct
= COMMUNITY_PERMIT
;
20773 direct
= COMMUNITY_DENY
;
20776 argv_find(argv
, argc
, "LINE", &idx
);
20777 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20778 /* Concat community string argument. */
20779 str
= argv_concat(argv
, argc
, idx
);
20783 argv_find(argv
, argc
, "(1-99)", &idx
);
20784 argv_find(argv
, argc
, "(100-500)", &idx
);
20785 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20787 /* Unset community list. */
20788 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20791 /* Free temporary community list string allocated by
20793 XFREE(MTYPE_TMP
, str
);
20796 community_list_perror(vty
, ret
);
20797 return CMD_WARNING_CONFIG_FAILED
;
20800 return CMD_SUCCESS
;
20803 /* "large-community-list" keyword help string. */
20804 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20805 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20807 DEFUN (lcommunity_list_standard
,
20808 bgp_lcommunity_list_standard_cmd
,
20809 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20811 LCOMMUNITY_LIST_STR
20812 "Large Community list number (standard)\n"
20813 "Sequence number of an entry\n"
20814 "Sequence number\n"
20815 "Specify large community to reject\n"
20816 "Specify large community to accept\n"
20817 LCOMMUNITY_VAL_STR
)
20819 return lcommunity_list_set_vty(vty
, argc
, argv
,
20820 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20823 DEFUN (lcommunity_list_expanded
,
20824 bgp_lcommunity_list_expanded_cmd
,
20825 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20827 LCOMMUNITY_LIST_STR
20828 "Large Community list number (expanded)\n"
20829 "Sequence number of an entry\n"
20830 "Sequence number\n"
20831 "Specify large community to reject\n"
20832 "Specify large community to accept\n"
20833 "An ordered list as a regular-expression\n")
20835 return lcommunity_list_set_vty(vty
, argc
, argv
,
20836 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20839 DEFUN (lcommunity_list_name_standard
,
20840 bgp_lcommunity_list_name_standard_cmd
,
20841 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20843 LCOMMUNITY_LIST_STR
20844 "Specify standard large-community-list\n"
20845 "Large Community list name\n"
20846 "Sequence number of an entry\n"
20847 "Sequence number\n"
20848 "Specify large community to reject\n"
20849 "Specify large community to accept\n"
20850 LCOMMUNITY_VAL_STR
)
20852 return lcommunity_list_set_vty(vty
, argc
, argv
,
20853 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20856 DEFUN (lcommunity_list_name_expanded
,
20857 bgp_lcommunity_list_name_expanded_cmd
,
20858 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20860 LCOMMUNITY_LIST_STR
20861 "Specify expanded large-community-list\n"
20862 "Large Community list name\n"
20863 "Sequence number of an entry\n"
20864 "Sequence number\n"
20865 "Specify large community to reject\n"
20866 "Specify large community to accept\n"
20867 "An ordered list as a regular-expression\n")
20869 return lcommunity_list_set_vty(vty
, argc
, argv
,
20870 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20873 DEFUN (no_lcommunity_list_all
,
20874 no_bgp_lcommunity_list_all_cmd
,
20875 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20878 LCOMMUNITY_LIST_STR
20879 "Large Community list number (standard)\n"
20880 "Large Community list number (expanded)\n"
20881 "Large Community list name\n")
20883 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20884 LARGE_COMMUNITY_LIST_STANDARD
);
20887 DEFUN (no_lcommunity_list_name_standard_all
,
20888 no_bgp_lcommunity_list_name_standard_all_cmd
,
20889 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20892 LCOMMUNITY_LIST_STR
20893 "Specify standard large-community-list\n"
20894 "Large Community list name\n")
20896 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20897 LARGE_COMMUNITY_LIST_STANDARD
);
20900 DEFUN (no_lcommunity_list_name_expanded_all
,
20901 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20902 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20905 LCOMMUNITY_LIST_STR
20906 "Specify expanded large-community-list\n"
20907 "Large Community list name\n")
20909 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20910 LARGE_COMMUNITY_LIST_EXPANDED
);
20913 DEFUN (no_lcommunity_list_standard
,
20914 no_bgp_lcommunity_list_standard_cmd
,
20915 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20918 LCOMMUNITY_LIST_STR
20919 "Large Community list number (standard)\n"
20920 "Sequence number of an entry\n"
20921 "Sequence number\n"
20922 "Specify large community to reject\n"
20923 "Specify large community to accept\n"
20924 LCOMMUNITY_VAL_STR
)
20926 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20927 LARGE_COMMUNITY_LIST_STANDARD
);
20930 DEFUN (no_lcommunity_list_expanded
,
20931 no_bgp_lcommunity_list_expanded_cmd
,
20932 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20935 LCOMMUNITY_LIST_STR
20936 "Large Community list number (expanded)\n"
20937 "Sequence number of an entry\n"
20938 "Sequence number\n"
20939 "Specify large community to reject\n"
20940 "Specify large community to accept\n"
20941 "An ordered list as a regular-expression\n")
20943 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20944 LARGE_COMMUNITY_LIST_EXPANDED
);
20947 DEFUN (no_lcommunity_list_name_standard
,
20948 no_bgp_lcommunity_list_name_standard_cmd
,
20949 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20952 LCOMMUNITY_LIST_STR
20953 "Specify standard large-community-list\n"
20954 "Large Community list name\n"
20955 "Sequence number of an entry\n"
20956 "Sequence number\n"
20957 "Specify large community to reject\n"
20958 "Specify large community to accept\n"
20959 LCOMMUNITY_VAL_STR
)
20961 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20962 LARGE_COMMUNITY_LIST_STANDARD
);
20965 DEFUN (no_lcommunity_list_name_expanded
,
20966 no_bgp_lcommunity_list_name_expanded_cmd
,
20967 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20970 LCOMMUNITY_LIST_STR
20971 "Specify expanded large-community-list\n"
20972 "Large community list name\n"
20973 "Sequence number of an entry\n"
20974 "Sequence number\n"
20975 "Specify large community to reject\n"
20976 "Specify large community to accept\n"
20977 "An ordered list as a regular-expression\n")
20979 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20980 LARGE_COMMUNITY_LIST_EXPANDED
);
20983 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20985 struct community_entry
*entry
;
20987 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20988 if (entry
== list
->head
) {
20989 if (all_digit(list
->name
))
20990 vty_out(vty
, "Large community %s list %s\n",
20992 LARGE_COMMUNITY_LIST_STANDARD
20994 : "(expanded) access",
20998 "Named large community %s list %s\n",
21000 LARGE_COMMUNITY_LIST_STANDARD
21006 vty_out(vty
, " %s\n",
21007 community_direct_str(entry
->direct
));
21009 vty_out(vty
, " %s %s\n",
21010 community_direct_str(entry
->direct
),
21011 community_list_config_str(entry
));
21015 DEFUN (show_lcommunity_list
,
21016 show_bgp_lcommunity_list_cmd
,
21017 "show bgp large-community-list",
21020 "List large-community list\n")
21022 struct community_list
*list
;
21023 struct community_list_master
*cm
;
21025 cm
= community_list_master_lookup(bgp_clist
,
21026 LARGE_COMMUNITY_LIST_MASTER
);
21028 return CMD_SUCCESS
;
21030 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21031 lcommunity_list_show(vty
, list
);
21033 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21034 lcommunity_list_show(vty
, list
);
21036 return CMD_SUCCESS
;
21039 DEFUN (show_lcommunity_list_arg
,
21040 show_bgp_lcommunity_list_arg_cmd
,
21041 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
21044 "List large-community list\n"
21045 "Large-community-list number\n"
21046 "Large-community-list name\n"
21047 "Detailed information on large-community-list\n")
21049 struct community_list
*list
;
21051 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
21052 LARGE_COMMUNITY_LIST_MASTER
);
21054 vty_out(vty
, "%% Can't find large-community-list\n");
21055 return CMD_WARNING
;
21058 lcommunity_list_show(vty
, list
);
21060 return CMD_SUCCESS
;
21063 /* "extcommunity-list" keyword help string. */
21064 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
21065 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
21067 DEFUN (extcommunity_list_standard
,
21068 bgp_extcommunity_list_standard_cmd
,
21069 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21071 EXTCOMMUNITY_LIST_STR
21072 "Extended Community list number (standard)\n"
21073 "Specify standard extcommunity-list\n"
21074 "Community list name\n"
21075 "Sequence number of an entry\n"
21076 "Sequence number\n"
21077 "Specify community to reject\n"
21078 "Specify community to accept\n"
21079 EXTCOMMUNITY_VAL_STR
)
21081 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21083 char *cl_number_or_name
= NULL
;
21088 argv_find(argv
, argc
, "(1-99)", &idx
);
21089 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21090 cl_number_or_name
= argv
[idx
]->arg
;
21092 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21093 seq
= argv
[idx
]->arg
;
21095 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21097 argv_find(argv
, argc
, "AA:NN", &idx
);
21098 char *str
= argv_concat(argv
, argc
, idx
);
21100 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21103 XFREE(MTYPE_TMP
, str
);
21106 community_list_perror(vty
, ret
);
21107 return CMD_WARNING_CONFIG_FAILED
;
21110 return CMD_SUCCESS
;
21113 DEFUN (extcommunity_list_name_expanded
,
21114 bgp_extcommunity_list_name_expanded_cmd
,
21115 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21117 EXTCOMMUNITY_LIST_STR
21118 "Extended Community list number (expanded)\n"
21119 "Specify expanded extcommunity-list\n"
21120 "Extended Community list name\n"
21121 "Sequence number of an entry\n"
21122 "Sequence number\n"
21123 "Specify community to reject\n"
21124 "Specify community to accept\n"
21125 "An ordered list as a regular-expression\n")
21127 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21129 char *cl_number_or_name
= NULL
;
21133 argv_find(argv
, argc
, "(100-500)", &idx
);
21134 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21135 cl_number_or_name
= argv
[idx
]->arg
;
21137 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21138 seq
= argv
[idx
]->arg
;
21140 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21142 argv_find(argv
, argc
, "LINE", &idx
);
21143 char *str
= argv_concat(argv
, argc
, idx
);
21145 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21148 XFREE(MTYPE_TMP
, str
);
21151 community_list_perror(vty
, ret
);
21152 return CMD_WARNING_CONFIG_FAILED
;
21155 return CMD_SUCCESS
;
21158 DEFUN (no_extcommunity_list_standard_all
,
21159 no_bgp_extcommunity_list_standard_all_cmd
,
21160 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21163 EXTCOMMUNITY_LIST_STR
21164 "Extended Community list number (standard)\n"
21165 "Specify standard extcommunity-list\n"
21166 "Community list name\n"
21167 "Sequence number of an entry\n"
21168 "Sequence number\n"
21169 "Specify community to reject\n"
21170 "Specify community to accept\n"
21171 EXTCOMMUNITY_VAL_STR
)
21173 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21175 char *cl_number_or_name
= NULL
;
21180 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21181 seq
= argv
[idx
]->arg
;
21184 argv_find(argv
, argc
, "permit", &idx
);
21185 argv_find(argv
, argc
, "deny", &idx
);
21187 direct
= argv_find(argv
, argc
, "permit", &idx
)
21192 argv_find(argv
, argc
, "AA:NN", &idx
);
21193 str
= argv_concat(argv
, argc
, idx
);
21197 argv_find(argv
, argc
, "(1-99)", &idx
);
21198 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21199 cl_number_or_name
= argv
[idx
]->arg
;
21201 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21202 seq
, direct
, style
);
21204 XFREE(MTYPE_TMP
, str
);
21207 community_list_perror(vty
, ret
);
21208 return CMD_WARNING_CONFIG_FAILED
;
21211 return CMD_SUCCESS
;
21214 ALIAS(no_extcommunity_list_standard_all
,
21215 no_bgp_extcommunity_list_standard_all_list_cmd
,
21216 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21217 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21218 "Extended Community list number (standard)\n"
21219 "Specify standard extcommunity-list\n"
21220 "Community list name\n")
21222 DEFUN (no_extcommunity_list_expanded_all
,
21223 no_bgp_extcommunity_list_expanded_all_cmd
,
21224 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21227 EXTCOMMUNITY_LIST_STR
21228 "Extended Community list number (expanded)\n"
21229 "Specify expanded extcommunity-list\n"
21230 "Extended Community list name\n"
21231 "Sequence number of an entry\n"
21232 "Sequence number\n"
21233 "Specify community to reject\n"
21234 "Specify community to accept\n"
21235 "An ordered list as a regular-expression\n")
21237 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21239 char *cl_number_or_name
= NULL
;
21244 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21245 seq
= argv
[idx
]->arg
;
21248 argv_find(argv
, argc
, "permit", &idx
);
21249 argv_find(argv
, argc
, "deny", &idx
);
21252 direct
= argv_find(argv
, argc
, "permit", &idx
)
21257 argv_find(argv
, argc
, "LINE", &idx
);
21258 str
= argv_concat(argv
, argc
, idx
);
21262 argv_find(argv
, argc
, "(100-500)", &idx
);
21263 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21264 cl_number_or_name
= argv
[idx
]->arg
;
21266 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21267 seq
, direct
, style
);
21269 XFREE(MTYPE_TMP
, str
);
21272 community_list_perror(vty
, ret
);
21273 return CMD_WARNING_CONFIG_FAILED
;
21276 return CMD_SUCCESS
;
21279 ALIAS(no_extcommunity_list_expanded_all
,
21280 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21281 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21282 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21283 "Extended Community list number (expanded)\n"
21284 "Specify expanded extcommunity-list\n"
21285 "Extended Community list name\n")
21287 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21289 struct community_entry
*entry
;
21291 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21292 if (entry
== list
->head
) {
21293 if (all_digit(list
->name
))
21294 vty_out(vty
, "Extended community %s list %s\n",
21295 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21297 : "(expanded) access",
21301 "Named extended community %s list %s\n",
21302 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21308 vty_out(vty
, " %s\n",
21309 community_direct_str(entry
->direct
));
21311 vty_out(vty
, " %s %s\n",
21312 community_direct_str(entry
->direct
),
21313 community_list_config_str(entry
));
21317 DEFUN (show_extcommunity_list
,
21318 show_bgp_extcommunity_list_cmd
,
21319 "show bgp extcommunity-list",
21322 "List extended-community list\n")
21324 struct community_list
*list
;
21325 struct community_list_master
*cm
;
21327 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21329 return CMD_SUCCESS
;
21331 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21332 extcommunity_list_show(vty
, list
);
21334 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21335 extcommunity_list_show(vty
, list
);
21337 return CMD_SUCCESS
;
21340 DEFUN (show_extcommunity_list_arg
,
21341 show_bgp_extcommunity_list_arg_cmd
,
21342 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21345 "List extended-community list\n"
21346 "Extcommunity-list number\n"
21347 "Extcommunity-list name\n"
21348 "Detailed information on extcommunity-list\n")
21350 int idx_comm_list
= 3;
21351 struct community_list
*list
;
21353 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21354 EXTCOMMUNITY_LIST_MASTER
);
21356 vty_out(vty
, "%% Can't find extcommunity-list\n");
21357 return CMD_WARNING
;
21360 extcommunity_list_show(vty
, list
);
21362 return CMD_SUCCESS
;
21365 /* Display community-list and extcommunity-list configuration. */
21366 static int community_list_config_write(struct vty
*vty
)
21368 struct community_list
*list
;
21369 struct community_entry
*entry
;
21370 struct community_list_master
*cm
;
21373 /* Community-list. */
21374 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21376 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21377 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21379 "bgp community-list %s seq %" PRId64
" %s %s\n",
21380 list
->name
, entry
->seq
,
21381 community_direct_str(entry
->direct
),
21382 community_list_config_str(entry
));
21385 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21386 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21388 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21389 entry
->style
== COMMUNITY_LIST_STANDARD
21392 list
->name
, entry
->seq
,
21393 community_direct_str(entry
->direct
),
21394 community_list_config_str(entry
));
21398 /* Extcommunity-list. */
21399 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21401 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21402 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21404 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21405 list
->name
, entry
->seq
,
21406 community_direct_str(entry
->direct
),
21407 community_list_config_str(entry
));
21410 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21411 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21413 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21414 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21417 list
->name
, entry
->seq
,
21418 community_direct_str(entry
->direct
),
21419 community_list_config_str(entry
));
21424 /* lcommunity-list. */
21425 cm
= community_list_master_lookup(bgp_clist
,
21426 LARGE_COMMUNITY_LIST_MASTER
);
21428 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21429 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21431 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21432 list
->name
, entry
->seq
,
21433 community_direct_str(entry
->direct
),
21434 community_list_config_str(entry
));
21437 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21438 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21440 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21442 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21445 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21446 community_list_config_str(entry
));
21453 static int community_list_config_write(struct vty
*vty
);
21454 static struct cmd_node community_list_node
= {
21455 .name
= "community list",
21456 .node
= COMMUNITY_LIST_NODE
,
21458 .config_write
= community_list_config_write
,
21461 static void community_list_vty(void)
21463 install_node(&community_list_node
);
21465 /* Community-list. */
21466 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21467 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21468 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21469 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21470 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21471 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21472 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21473 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21475 /* Extcommunity-list. */
21476 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21477 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21478 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21479 install_element(CONFIG_NODE
,
21480 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21481 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21482 install_element(CONFIG_NODE
,
21483 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21484 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21485 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21487 /* Large Community List */
21488 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21489 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21490 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21491 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21492 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21493 install_element(CONFIG_NODE
,
21494 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21495 install_element(CONFIG_NODE
,
21496 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21497 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21498 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21499 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21500 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21501 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21502 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21504 bgp_community_list_command_completion_setup();
21507 static struct cmd_node community_alias_node
= {
21508 .name
= "community alias",
21509 .node
= COMMUNITY_ALIAS_NODE
,
21511 .config_write
= bgp_community_alias_write
,
21514 void community_alias_vty(void)
21516 install_node(&community_alias_node
);
21518 /* Community-list. */
21519 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21521 bgp_community_alias_command_completion_setup();