2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nexthop.h"
57 #include "bgpd/bgp_open.h"
58 #include "bgpd/bgp_regex.h"
59 #include "bgpd/bgp_route.h"
60 #include "bgpd/bgp_mplsvpn.h"
61 #include "bgpd/bgp_zebra.h"
62 #include "bgpd/bgp_table.h"
63 #include "bgpd/bgp_vty.h"
64 #include "bgpd/bgp_mpath.h"
65 #include "bgpd/bgp_packet.h"
66 #include "bgpd/bgp_updgrp.h"
67 #include "bgpd/bgp_bfd.h"
68 #include "bgpd/bgp_io.h"
69 #include "bgpd/bgp_evpn.h"
70 #include "bgpd/bgp_evpn_vty.h"
71 #include "bgpd/bgp_evpn_mh.h"
72 #include "bgpd/bgp_addpath.h"
73 #include "bgpd/bgp_mac.h"
74 #include "bgpd/bgp_flowspec.h"
75 #include "bgpd/bgp_conditional_adv.h"
77 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
80 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
83 .match_profile
= "traditional",
84 .match_version
= "< 7.4",
88 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
89 { .val_bool
= true, .match_profile
= "datacenter", },
90 { .val_bool
= false },
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
105 { .val_ulong
= 10, .match_profile
= "datacenter", },
106 { .val_ulong
= 120 },
108 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
109 { .val_ulong
= 9, .match_profile
= "datacenter", },
110 { .val_ulong
= 180 },
112 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
113 { .val_ulong
= 3, .match_profile
= "datacenter", },
116 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
117 { .val_bool
= false, .match_profile
= "datacenter", },
118 { .val_bool
= false, .match_version
= "< 7.4", },
119 { .val_bool
= true },
121 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
122 { .val_bool
= false, .match_version
= "< 7.6", },
123 { .val_bool
= true },
126 DEFINE_HOOK(bgp_inst_config_write
,
127 (struct bgp
*bgp
, struct vty
*vty
),
129 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
130 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
132 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
133 struct prefix
*range
, int exact
);
135 /* Show BGP peer's information. */
145 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
146 struct prefix
*range
, int exact
);
148 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
153 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
156 afi_t afi
, bool use_json
);
158 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
164 return BGP_IPV4_NODE
;
166 return BGP_IPV4M_NODE
;
167 case SAFI_LABELED_UNICAST
:
168 return BGP_IPV4L_NODE
;
170 return BGP_VPNV4_NODE
;
172 return BGP_FLOWSPECV4_NODE
;
175 return BGP_IPV4_NODE
;
181 return BGP_IPV6_NODE
;
183 return BGP_IPV6M_NODE
;
184 case SAFI_LABELED_UNICAST
:
185 return BGP_IPV6L_NODE
;
187 return BGP_VPNV6_NODE
;
189 return BGP_FLOWSPECV6_NODE
;
192 return BGP_IPV4_NODE
;
196 return BGP_EVPN_NODE
;
199 // We should never be here but to clarify the switch statement..
200 return BGP_IPV4_NODE
;
203 // Impossible to happen
204 return BGP_IPV4_NODE
;
207 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
210 if (safi
== SAFI_UNICAST
)
211 return "IPv4 Unicast";
212 if (safi
== SAFI_MULTICAST
)
213 return "IPv4 Multicast";
214 if (safi
== SAFI_LABELED_UNICAST
)
215 return "IPv4 Labeled Unicast";
216 if (safi
== SAFI_MPLS_VPN
)
218 if (safi
== SAFI_ENCAP
)
220 if (safi
== SAFI_FLOWSPEC
)
221 return "IPv4 Flowspec";
222 } else if (afi
== AFI_IP6
) {
223 if (safi
== SAFI_UNICAST
)
224 return "IPv6 Unicast";
225 if (safi
== SAFI_MULTICAST
)
226 return "IPv6 Multicast";
227 if (safi
== SAFI_LABELED_UNICAST
)
228 return "IPv6 Labeled Unicast";
229 if (safi
== SAFI_MPLS_VPN
)
231 if (safi
== SAFI_ENCAP
)
233 if (safi
== SAFI_FLOWSPEC
)
234 return "IPv6 Flowspec";
235 } else if (afi
== AFI_L2VPN
) {
236 if (safi
== SAFI_EVPN
)
244 * Please note that we have intentionally camelCased
245 * the return strings here. So if you want
246 * to use this function, please ensure you
247 * are doing this within json output
249 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
252 if (safi
== SAFI_UNICAST
)
253 return "ipv4Unicast";
254 if (safi
== SAFI_MULTICAST
)
255 return "ipv4Multicast";
256 if (safi
== SAFI_LABELED_UNICAST
)
257 return "ipv4LabeledUnicast";
258 if (safi
== SAFI_MPLS_VPN
)
260 if (safi
== SAFI_ENCAP
)
262 if (safi
== SAFI_FLOWSPEC
)
263 return "ipv4Flowspec";
264 } else if (afi
== AFI_IP6
) {
265 if (safi
== SAFI_UNICAST
)
266 return "ipv6Unicast";
267 if (safi
== SAFI_MULTICAST
)
268 return "ipv6Multicast";
269 if (safi
== SAFI_LABELED_UNICAST
)
270 return "ipv6LabeledUnicast";
271 if (safi
== SAFI_MPLS_VPN
)
273 if (safi
== SAFI_ENCAP
)
275 if (safi
== SAFI_FLOWSPEC
)
276 return "ipv6Flowspec";
277 } else if (afi
== AFI_L2VPN
) {
278 if (safi
== SAFI_EVPN
)
285 /* unset srv6 locator */
286 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
289 struct listnode
*node
, *nnode
;
290 struct prefix_ipv6
*chunk
;
291 struct bgp_srv6_function
*func
;
293 struct in6_addr
*tovpn_sid
;
295 /* release chunk notification via ZAPI */
296 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
297 bgp
->srv6_locator_name
);
302 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
))
303 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
305 /* refresh functions */
306 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
))
307 listnode_delete(bgp
->srv6_functions
, func
);
309 /* refresh tovpn_sid */
310 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
311 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
314 /* refresh vpnv4 tovpn_sid */
315 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
;
317 XFREE(MTYPE_BGP_SRV6_SID
,
318 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
320 /* refresh vpnv6 tovpn_sid */
321 tovpn_sid
= bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
;
323 XFREE(MTYPE_BGP_SRV6_SID
,
324 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
327 /* update vpn bgp processes */
328 vpn_leak_postchange_all();
330 /* clear locator name */
331 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
336 /* Utility function to get address family from current node. */
337 afi_t
bgp_node_afi(struct vty
*vty
)
345 case BGP_FLOWSPECV6_NODE
:
358 /* Utility function to get subsequent address family from current
360 safi_t
bgp_node_safi(struct vty
*vty
)
366 safi
= SAFI_MPLS_VPN
;
370 safi
= SAFI_MULTICAST
;
377 safi
= SAFI_LABELED_UNICAST
;
379 case BGP_FLOWSPECV4_NODE
:
380 case BGP_FLOWSPECV6_NODE
:
381 safi
= SAFI_FLOWSPEC
;
391 * Converts an AFI in string form to afi_t
393 * @param afi string, one of
397 * @return the corresponding afi_t
399 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
401 afi_t afi
= AFI_MAX
; /* unknown */
402 if (strmatch(afi_str
, "ipv4"))
404 else if (strmatch(afi_str
, "ipv6"))
406 else if (strmatch(afi_str
, "l2vpn"))
411 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
415 if (argv_find(argv
, argc
, "ipv4", index
)) {
419 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
423 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
431 /* supports <unicast|multicast|vpn|labeled-unicast> */
432 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
434 safi_t safi
= SAFI_MAX
; /* unknown */
435 if (strmatch(safi_str
, "multicast"))
436 safi
= SAFI_MULTICAST
;
437 else if (strmatch(safi_str
, "unicast"))
439 else if (strmatch(safi_str
, "vpn"))
440 safi
= SAFI_MPLS_VPN
;
441 else if (strmatch(safi_str
, "evpn"))
443 else if (strmatch(safi_str
, "labeled-unicast"))
444 safi
= SAFI_LABELED_UNICAST
;
445 else if (strmatch(safi_str
, "flowspec"))
446 safi
= SAFI_FLOWSPEC
;
450 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
454 if (argv_find(argv
, argc
, "unicast", index
)) {
457 *safi
= SAFI_UNICAST
;
458 } else if (argv_find(argv
, argc
, "multicast", index
)) {
461 *safi
= SAFI_MULTICAST
;
462 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
465 *safi
= SAFI_LABELED_UNICAST
;
466 } else if (argv_find(argv
, argc
, "vpn", index
)) {
469 *safi
= SAFI_MPLS_VPN
;
470 } else if (argv_find(argv
, argc
, "evpn", index
)) {
474 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
477 *safi
= SAFI_FLOWSPEC
;
483 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
486 * address-family identifier
489 * subsequent address-family identifier
492 * default_af string corresponding to the supplied afi/safi pair.
493 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
496 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
502 return "ipv4-unicast";
504 return "ipv4-multicast";
509 case SAFI_LABELED_UNICAST
:
510 return "ipv4-labeled-unicast";
512 return "ipv4-flowspec";
514 return "unknown-afi/safi";
520 return "ipv6-unicast";
522 return "ipv6-multicast";
527 case SAFI_LABELED_UNICAST
:
528 return "ipv6-labeled-unicast";
530 return "ipv6-flowspec";
532 return "unknown-afi/safi";
540 return "unknown-afi/safi";
544 return "unknown-afi/safi";
546 /* all AFIs are accounted for above, so this shouldn't happen */
547 return "unknown-afi/safi";
550 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
551 enum bgp_instance_type inst_type
)
553 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
555 if (ret
== BGP_CREATED
) {
556 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
557 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
559 if (DFLT_BGP_IMPORT_CHECK
)
560 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
561 if (DFLT_BGP_SHOW_HOSTNAME
)
562 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
563 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
564 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
565 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
566 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
567 if (DFLT_BGP_DETERMINISTIC_MED
)
568 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
569 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
570 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
571 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
572 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
580 * bgp_vty_find_and_parse_afi_safi_bgp
582 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
583 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
584 * to appropriate values for the calling function. This is to allow the
585 * calling function to make decisions appropriate for the show command
586 * that is being parsed.
588 * The show commands are generally of the form:
589 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
590 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
592 * Since we use argv_find if the show command in particular doesn't have:
594 * [<view|vrf> VIEWVRFNAME]
595 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
596 * The command parsing should still be ok.
598 * vty -> The vty for the command so we can output some useful data in
599 * the event of a parse error in the vrf.
600 * argv -> The command tokens
601 * argc -> How many command tokens we have
602 * idx -> The current place in the command, generally should be 0 for this
604 * afi -> The parsed afi if it was included in the show command, returned here
605 * safi -> The parsed safi if it was included in the show command, returned here
606 * bgp -> Pointer to the bgp data structure we need to fill in.
607 * use_json -> json is configured or not
609 * The function returns the correct location in the parse tree for the
612 * Returns 0 for failure to parse correctly, else the idx position of where
613 * it found the last token.
615 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
616 struct cmd_token
**argv
, int argc
,
617 int *idx
, afi_t
*afi
, safi_t
*safi
,
618 struct bgp
**bgp
, bool use_json
)
620 char *vrf_name
= NULL
;
626 if (argv_find(argv
, argc
, "ip", idx
))
629 if (argv_find(argv
, argc
, "view", idx
))
630 vrf_name
= argv
[*idx
+ 1]->arg
;
631 else if (argv_find(argv
, argc
, "vrf", idx
)) {
632 vrf_name
= argv
[*idx
+ 1]->arg
;
633 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
637 if (strmatch(vrf_name
, "all"))
640 *bgp
= bgp_lookup_by_name(vrf_name
);
643 json_object
*json
= NULL
;
644 json
= json_object_new_object();
645 json_object_string_add(
647 "View/Vrf is unknown");
651 vty_out(vty
, "View/Vrf %s is unknown\n",
658 *bgp
= bgp_get_default();
661 json_object
*json
= NULL
;
662 json
= json_object_new_object();
663 json_object_string_add(
665 "Default BGP instance not found");
670 "Default BGP instance not found\n");
676 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
677 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
683 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
685 struct interface
*ifp
= NULL
;
687 if (su
->sa
.sa_family
== AF_INET
)
688 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
689 else if (su
->sa
.sa_family
== AF_INET6
)
690 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
691 su
->sin6
.sin6_scope_id
,
700 /* Utility function for looking up peer from VTY. */
701 /* This is used only for configuration, so disallow if attempted on
702 * a dynamic neighbor.
704 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
706 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
715 ret
= str2sockunion(ip_str
, &su
);
717 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
719 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
722 "%% Malformed address or name: %s\n",
728 peer
= peer_lookup(bgp
, &su
);
731 "%% Specify remote-as or peer-group commands first\n");
734 if (peer_dynamic_neighbor(peer
)) {
736 "%% Operation not allowed on a dynamic neighbor\n");
743 /* Utility function for looking up peer or peer group. */
744 /* This is used only for configuration, so disallow if attempted on
745 * a dynamic neighbor.
747 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
749 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
752 struct peer
*peer
= NULL
;
753 struct peer_group
*group
= NULL
;
759 ret
= str2sockunion(peer_str
, &su
);
761 /* IP address, locate peer. */
762 peer
= peer_lookup(bgp
, &su
);
764 /* Not IP, could match either peer configured on interface or a
766 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
768 group
= peer_group_lookup(bgp
, peer_str
);
772 if (peer_dynamic_neighbor(peer
)) {
774 "%% Operation not allowed on a dynamic neighbor\n");
784 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
789 int bgp_vty_return(struct vty
*vty
, int ret
)
791 const char *str
= NULL
;
794 case BGP_ERR_INVALID_VALUE
:
795 str
= "Invalid value";
797 case BGP_ERR_INVALID_FLAG
:
798 str
= "Invalid flag";
800 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
801 str
= "Peer-group has been shutdown. Activate the peer-group first";
803 case BGP_ERR_PEER_FLAG_CONFLICT
:
804 str
= "Can't set override-capability and strict-capability-match at the same time";
806 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
807 str
= "Specify remote-as or peer-group remote AS first";
809 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
810 str
= "Cannot change the peer-group. Deconfigure first";
812 case BGP_ERR_PEER_GROUP_MISMATCH
:
813 str
= "Peer is not a member of this peer-group";
815 case BGP_ERR_PEER_FILTER_CONFLICT
:
816 str
= "Prefix/distribute list can not co-exist";
818 case BGP_ERR_NOT_INTERNAL_PEER
:
819 str
= "Invalid command. Not an internal neighbor";
821 case BGP_ERR_REMOVE_PRIVATE_AS
:
822 str
= "remove-private-AS cannot be configured for IBGP peers";
824 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
825 str
= "Local-AS allowed only for EBGP peers";
827 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
828 str
= "Cannot have local-as same as BGP AS number";
830 case BGP_ERR_TCPSIG_FAILED
:
831 str
= "Error while applying TCP-Sig to session(s)";
833 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
834 str
= "ebgp-multihop and ttl-security cannot be configured together";
836 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
837 str
= "ttl-security only allowed for EBGP peers";
839 case BGP_ERR_AS_OVERRIDE
:
840 str
= "as-override cannot be configured for IBGP peers";
842 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
843 str
= "Invalid limit for number of dynamic neighbors";
845 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
846 str
= "Dynamic neighbor listen range already exists";
848 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
849 str
= "Operation not allowed on a dynamic neighbor";
851 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
852 str
= "Operation not allowed on a directly connected neighbor";
854 case BGP_ERR_PEER_SAFI_CONFLICT
:
855 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
857 case BGP_ERR_GR_INVALID_CMD
:
858 str
= "The Graceful Restart command used is not valid at this moment.";
860 case BGP_ERR_GR_OPERATION_FAILED
:
861 str
= "The Graceful Restart Operation failed due to an err.";
865 vty_out(vty
, "%% %s\n", str
);
866 return CMD_WARNING_CONFIG_FAILED
;
871 /* BGP clear sort. */
880 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
881 safi_t safi
, int error
)
884 case BGP_ERR_AF_UNCONFIGURED
:
886 "%%BGP: Enable %s address family for the neighbor %s\n",
887 get_afi_safi_str(afi
, safi
, false), peer
->host
);
889 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
891 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
899 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
900 struct listnode
**nnode
, enum bgp_clear_type stype
)
905 /* if afi/.safi not specified, spin thru all of them */
906 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
909 enum bgp_af_index index
;
911 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
912 paf
= peer
->peer_af_array
[index
];
916 if (paf
&& paf
->subgroup
)
917 SET_FLAG(paf
->subgroup
->sflags
,
918 SUBGRP_STATUS_FORCE_UPDATES
);
921 tmp_safi
= paf
->safi
;
922 if (!peer
->afc
[tmp_afi
][tmp_safi
])
925 if (stype
== BGP_CLEAR_SOFT_NONE
)
926 ret
= peer_clear(peer
, nnode
);
928 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
931 /* if afi specified and safi not, spin thru safis on this afi */
932 } else if (safi
== SAFI_UNSPEC
) {
935 for (tmp_safi
= SAFI_UNICAST
;
936 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
937 if (!peer
->afc
[afi
][tmp_safi
])
940 paf
= peer_af_find(peer
, afi
, tmp_safi
);
941 if (paf
&& paf
->subgroup
)
942 SET_FLAG(paf
->subgroup
->sflags
,
943 SUBGRP_STATUS_FORCE_UPDATES
);
945 if (stype
== BGP_CLEAR_SOFT_NONE
)
946 ret
= peer_clear(peer
, nnode
);
948 ret
= peer_clear_soft(peer
, afi
,
951 /* both afi/safi specified, let the caller know if not defined */
953 if (!peer
->afc
[afi
][safi
])
956 paf
= peer_af_find(peer
, afi
, safi
);
957 if (paf
&& paf
->subgroup
)
958 SET_FLAG(paf
->subgroup
->sflags
,
959 SUBGRP_STATUS_FORCE_UPDATES
);
961 if (stype
== BGP_CLEAR_SOFT_NONE
)
962 ret
= peer_clear(peer
, nnode
);
964 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
970 /* `clear ip bgp' functions. */
971 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
972 enum clear_sort sort
, enum bgp_clear_type stype
,
979 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
981 /* Clear all neighbors. */
983 * Pass along pointer to next node to peer_clear() when walking all
984 * nodes on the BGP instance as that may get freed if it is a
987 if (sort
== clear_all
) {
988 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
990 bgp_peer_gr_flags_update(peer
);
992 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
993 gr_router_detected
= true;
995 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
999 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1002 if (gr_router_detected
1003 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1004 bgp_zebra_send_capabilities(bgp
, false);
1005 } else if (!gr_router_detected
1006 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1007 bgp_zebra_send_capabilities(bgp
, true);
1010 /* This is to apply read-only mode on this clear. */
1011 if (stype
== BGP_CLEAR_SOFT_NONE
)
1012 bgp
->update_delay_over
= 0;
1017 /* Clear specified neighbor. */
1018 if (sort
== clear_peer
) {
1021 /* Make sockunion for lookup. */
1022 ret
= str2sockunion(arg
, &su
);
1024 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1026 peer
= peer_lookup_by_hostname(bgp
, arg
);
1029 "Malformed address or name: %s\n",
1035 peer
= peer_lookup(bgp
, &su
);
1038 "%%BGP: Unknown neighbor - \"%s\"\n",
1044 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1045 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1047 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1049 /* if afi/safi not defined for this peer, let caller know */
1051 ret
= BGP_ERR_AF_UNCONFIGURED
;
1054 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1059 /* Clear all neighbors belonging to a specific peer-group. */
1060 if (sort
== clear_group
) {
1061 struct peer_group
*group
;
1063 group
= peer_group_lookup(bgp
, arg
);
1065 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
1069 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1070 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1073 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1080 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
1081 get_afi_safi_str(afi
, safi
, false), arg
);
1086 /* Clear all external (eBGP) neighbors. */
1087 if (sort
== clear_external
) {
1088 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1089 if (peer
->sort
== BGP_PEER_IBGP
)
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
, stype
);
1100 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1105 if (gr_router_detected
1106 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1107 bgp_zebra_send_capabilities(bgp
, false);
1108 } else if (!gr_router_detected
1109 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1110 bgp_zebra_send_capabilities(bgp
, true);
1115 "%%BGP: No external %s peer is configured\n",
1116 get_afi_safi_str(afi
, safi
, false));
1121 /* Clear all neighbors belonging to a specific AS. */
1122 if (sort
== clear_as
) {
1123 as_t as
= strtoul(arg
, NULL
, 10);
1125 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1129 bgp_peer_gr_flags_update(peer
);
1131 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1132 gr_router_detected
= true;
1134 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1137 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1142 if (gr_router_detected
1143 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1144 bgp_zebra_send_capabilities(bgp
, false);
1145 } else if (!gr_router_detected
1146 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1147 bgp_zebra_send_capabilities(bgp
, true);
1152 "%%BGP: No %s peer is configured with AS %s\n",
1153 get_afi_safi_str(afi
, safi
, false), arg
);
1161 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1162 safi_t safi
, enum clear_sort sort
,
1163 enum bgp_clear_type stype
, const char *arg
)
1167 /* BGP structure lookup. */
1169 bgp
= bgp_lookup_by_name(name
);
1171 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1175 bgp
= bgp_get_default();
1177 vty_out(vty
, "No BGP process is configured\n");
1182 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1185 /* clear soft inbound */
1186 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1191 FOREACH_AFI_SAFI (afi
, safi
)
1192 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1193 BGP_CLEAR_SOFT_IN
, NULL
);
1196 /* clear soft outbound */
1197 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1202 FOREACH_AFI_SAFI (afi
, safi
)
1203 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1204 BGP_CLEAR_SOFT_OUT
, NULL
);
1208 #ifndef VTYSH_EXTRACT_PL
1209 #include "bgpd/bgp_vty_clippy.c"
1212 DEFUN_HIDDEN (bgp_local_mac
,
1214 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1216 "Local MAC config\n"
1217 "VxLAN Network Identifier\n"
1221 "mac-mobility sequence\n"
1231 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1232 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1233 vty_out(vty
, "%% Malformed MAC address\n");
1236 memset(&ip
, 0, sizeof(ip
));
1237 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1239 bgp
= bgp_get_default();
1241 vty_out(vty
, "Default BGP instance is not there\n");
1245 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1248 vty_out(vty
, "Internal error\n");
1255 DEFUN_HIDDEN (no_bgp_local_mac
,
1256 no_bgp_local_mac_cmd
,
1257 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1260 "Local MAC config\n"
1261 "VxLAN Network Identifier\n"
1272 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1273 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1274 vty_out(vty
, "%% Malformed MAC address\n");
1277 memset(&ip
, 0, sizeof(ip
));
1279 bgp
= bgp_get_default();
1281 vty_out(vty
, "Default BGP instance is not there\n");
1285 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1287 vty_out(vty
, "Internal error\n");
1294 DEFUN (no_synchronization
,
1295 no_synchronization_cmd
,
1296 "no synchronization",
1298 "Perform IGP synchronization\n")
1303 DEFUN (no_auto_summary
,
1304 no_auto_summary_cmd
,
1307 "Enable automatic network number summarization\n")
1312 /* "router bgp" commands. */
1313 DEFUN_NOSH (router_bgp
,
1315 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1319 BGP_INSTANCE_HELP_STR
)
1322 int idx_view_vrf
= 3;
1328 const char *name
= NULL
;
1329 enum bgp_instance_type inst_type
;
1331 // "router bgp" without an ASN
1333 // Pending: Make VRF option available for ASN less config
1334 bgp
= bgp_get_default();
1337 vty_out(vty
, "%% No BGP process is configured\n");
1338 return CMD_WARNING_CONFIG_FAILED
;
1341 if (listcount(bm
->bgp
) > 1) {
1342 vty_out(vty
, "%% Please specify ASN and VRF\n");
1343 return CMD_WARNING_CONFIG_FAILED
;
1349 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1351 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1352 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1353 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1355 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1357 name
= argv
[idx_vrf
]->arg
;
1359 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1360 if (strmatch(name
, VRF_DEFAULT_NAME
))
1363 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1364 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1365 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1368 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1369 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1371 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1373 case BGP_ERR_AS_MISMATCH
:
1374 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1375 return CMD_WARNING_CONFIG_FAILED
;
1376 case BGP_ERR_INSTANCE_MISMATCH
:
1378 "BGP instance name and AS number mismatch\n");
1380 "BGP instance is already running; AS is %u\n",
1382 return CMD_WARNING_CONFIG_FAILED
;
1386 * If we just instantiated the default instance, complete
1387 * any pending VRF-VPN leaking that was configured via
1388 * earlier "router bgp X vrf FOO" blocks.
1390 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1391 vpn_leak_postchange_all();
1393 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1394 bgp_vpn_leak_export(bgp
);
1395 /* Pending: handle when user tries to change a view to vrf n vv.
1399 /* unset the auto created flag as the user config is now present */
1400 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1401 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1406 /* "no router bgp" commands. */
1407 DEFUN (no_router_bgp
,
1409 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1414 BGP_INSTANCE_HELP_STR
)
1420 const char *name
= NULL
;
1422 // "no router bgp" without an ASN
1424 // Pending: Make VRF option available for ASN less config
1425 bgp
= bgp_get_default();
1428 vty_out(vty
, "%% No BGP process is configured\n");
1429 return CMD_WARNING_CONFIG_FAILED
;
1432 if (listcount(bm
->bgp
) > 1) {
1433 vty_out(vty
, "%% Please specify ASN and VRF\n");
1434 return CMD_WARNING_CONFIG_FAILED
;
1438 vty_out(vty
, "%% Please unconfigure l3vni %u",
1440 return CMD_WARNING_CONFIG_FAILED
;
1443 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1446 name
= argv
[idx_vrf
]->arg
;
1447 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1448 && strmatch(name
, VRF_DEFAULT_NAME
))
1452 /* Lookup bgp structure. */
1453 bgp
= bgp_lookup(as
, name
);
1455 vty_out(vty
, "%% Can't find BGP instance\n");
1456 return CMD_WARNING_CONFIG_FAILED
;
1460 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1462 return CMD_WARNING_CONFIG_FAILED
;
1465 /* Cannot delete default instance if vrf instances exist */
1466 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1467 struct listnode
*node
;
1468 struct bgp
*tmp_bgp
;
1470 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1471 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1473 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1474 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1475 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1476 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1477 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1478 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1479 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1480 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1481 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1482 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1483 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1484 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1485 (bgp
== bgp_get_evpn() &&
1486 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1487 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1488 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1489 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1490 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1491 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1492 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1493 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1494 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1496 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1497 return CMD_WARNING_CONFIG_FAILED
;
1509 /* BGP router-id. */
1511 DEFPY (bgp_router_id
,
1513 "bgp router-id A.B.C.D",
1515 "Override configured router identifier\n"
1516 "Manually configured router identifier\n")
1518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1519 bgp_router_id_static_set(bgp
, router_id
);
1523 DEFPY (no_bgp_router_id
,
1524 no_bgp_router_id_cmd
,
1525 "no bgp router-id [A.B.C.D]",
1528 "Override configured router identifier\n"
1529 "Manually configured router identifier\n")
1531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1533 if (router_id_str
) {
1534 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1535 vty_out(vty
, "%% BGP router-id doesn't match\n");
1536 return CMD_WARNING_CONFIG_FAILED
;
1540 router_id
.s_addr
= 0;
1541 bgp_router_id_static_set(bgp
, router_id
);
1546 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1547 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1549 "Add community specific parameters\n"
1550 "Create an alias for a community\n"
1551 "Community (AA:BB or AA:BB:CC)\n"
1554 struct community_alias ca1
;
1555 struct community_alias ca2
;
1556 struct community_alias
*lookup_community
;
1557 struct community_alias
*lookup_alias
;
1559 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1560 vty_out(vty
, "Invalid community format\n");
1564 memset(&ca1
, 0, sizeof(ca1
));
1565 memset(&ca2
, 0, sizeof(ca2
));
1566 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1567 strlcpy(ca1
.alias
, alias_name
, sizeof(ca1
.alias
));
1569 lookup_community
= bgp_ca_community_lookup(&ca1
);
1570 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1573 bgp_ca_alias_delete(&ca1
);
1574 bgp_ca_community_delete(&ca1
);
1577 /* Lookup if community hash table has an item
1578 * with the same alias name.
1580 strlcpy(ca2
.community
, lookup_alias
->community
,
1581 sizeof(ca2
.community
));
1582 if (bgp_ca_community_lookup(&ca2
)) {
1584 "community (%s) already has this alias (%s)\n",
1585 lookup_alias
->community
,
1586 lookup_alias
->alias
);
1589 bgp_ca_alias_delete(&ca1
);
1592 if (lookup_community
)
1593 bgp_ca_community_delete(&ca1
);
1595 bgp_ca_alias_insert(&ca1
);
1596 bgp_ca_community_insert(&ca1
);
1602 DEFPY (bgp_global_suppress_fib_pending
,
1603 bgp_global_suppress_fib_pending_cmd
,
1604 "[no] bgp suppress-fib-pending",
1607 "Advertise only routes that are programmed in kernel to peers globally\n")
1609 bm_wait_for_fib_set(!no
);
1614 DEFPY (bgp_suppress_fib_pending
,
1615 bgp_suppress_fib_pending_cmd
,
1616 "[no] bgp suppress-fib-pending",
1619 "Advertise only routes that are programmed in kernel to peers\n")
1621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1623 bgp_suppress_fib_pending_set(bgp
, !no
);
1628 /* BGP Cluster ID. */
1629 DEFUN (bgp_cluster_id
,
1631 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1633 "Configure Route-Reflector Cluster-id\n"
1634 "Route-Reflector Cluster-id in IP address format\n"
1635 "Route-Reflector Cluster-id as 32 bit quantity\n")
1637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1640 struct in_addr cluster
;
1642 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1644 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1645 return CMD_WARNING_CONFIG_FAILED
;
1648 bgp_cluster_id_set(bgp
, &cluster
);
1649 bgp_clear_star_soft_out(vty
, bgp
->name
);
1654 DEFUN (no_bgp_cluster_id
,
1655 no_bgp_cluster_id_cmd
,
1656 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1659 "Configure Route-Reflector Cluster-id\n"
1660 "Route-Reflector Cluster-id in IP address format\n"
1661 "Route-Reflector Cluster-id as 32 bit quantity\n")
1663 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1664 bgp_cluster_id_unset(bgp
);
1665 bgp_clear_star_soft_out(vty
, bgp
->name
);
1674 "Disable BGP route installation to RIB (Zebra)\n")
1676 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1678 "%% No-RIB option is already set, nothing to do here.\n");
1682 bgp_option_norib_set_runtime();
1687 DEFPY (no_bgp_norib
,
1692 "Disable BGP route installation to RIB (Zebra)\n")
1694 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1696 "%% No-RIB option is not set, nothing to do here.\n");
1700 bgp_option_norib_unset_runtime();
1705 DEFPY (no_bgp_send_extra_data
,
1706 no_bgp_send_extra_data_cmd
,
1707 "[no] bgp send-extra-data zebra",
1710 "Extra data to Zebra for display/use\n"
1714 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1716 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1721 DEFUN (bgp_confederation_identifier
,
1722 bgp_confederation_identifier_cmd
,
1723 "bgp confederation identifier (1-4294967295)",
1725 "AS confederation parameters\n"
1727 "Set routing domain confederation AS\n")
1729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1733 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1735 bgp_confederation_id_set(bgp
, as
);
1740 DEFUN (no_bgp_confederation_identifier
,
1741 no_bgp_confederation_identifier_cmd
,
1742 "no bgp confederation identifier [(1-4294967295)]",
1745 "AS confederation parameters\n"
1747 "Set routing domain confederation AS\n")
1749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1750 bgp_confederation_id_unset(bgp
);
1755 DEFUN (bgp_confederation_peers
,
1756 bgp_confederation_peers_cmd
,
1757 "bgp confederation peers (1-4294967295)...",
1759 "AS confederation parameters\n"
1760 "Peer ASs in BGP confederation\n"
1763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1768 for (i
= idx_asn
; i
< argc
; i
++) {
1769 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1771 if (bgp
->as
== as
) {
1773 "%% Local member-AS not allowed in confed peer list\n");
1777 bgp_confederation_peers_add(bgp
, as
);
1782 DEFUN (no_bgp_confederation_peers
,
1783 no_bgp_confederation_peers_cmd
,
1784 "no bgp confederation peers (1-4294967295)...",
1787 "AS confederation parameters\n"
1788 "Peer ASs in BGP confederation\n"
1791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1796 for (i
= idx_asn
; i
< argc
; i
++) {
1797 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1799 bgp_confederation_peers_remove(bgp
, as
);
1805 * Central routine for maximum-paths configuration.
1806 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1807 * @set: 1 for setting values, 0 for removing the max-paths config.
1809 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1810 const char *mpaths
, uint16_t options
,
1813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1814 uint16_t maxpaths
= 0;
1819 afi
= bgp_node_afi(vty
);
1820 safi
= bgp_node_safi(vty
);
1823 maxpaths
= strtol(mpaths
, NULL
, 10);
1824 if (maxpaths
> multipath_num
) {
1826 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1827 maxpaths
, multipath_num
);
1828 return CMD_WARNING_CONFIG_FAILED
;
1830 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1833 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1837 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1838 (set
== 1) ? "" : "un",
1839 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1840 maxpaths
, afi
, safi
);
1841 return CMD_WARNING_CONFIG_FAILED
;
1844 bgp_recalculate_all_bestpaths(bgp
);
1849 DEFUN (bgp_maxmed_admin
,
1850 bgp_maxmed_admin_cmd
,
1851 "bgp max-med administrative ",
1853 "Advertise routes with max-med\n"
1854 "Administratively applied, for an indefinite period\n")
1856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1858 bgp
->v_maxmed_admin
= 1;
1859 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1861 bgp_maxmed_update(bgp
);
1866 DEFUN (bgp_maxmed_admin_medv
,
1867 bgp_maxmed_admin_medv_cmd
,
1868 "bgp max-med administrative (0-4294967295)",
1870 "Advertise routes with max-med\n"
1871 "Administratively applied, for an indefinite period\n"
1872 "Max MED value to be used\n")
1874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1877 bgp
->v_maxmed_admin
= 1;
1878 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1880 bgp_maxmed_update(bgp
);
1885 DEFUN (no_bgp_maxmed_admin
,
1886 no_bgp_maxmed_admin_cmd
,
1887 "no bgp max-med administrative [(0-4294967295)]",
1890 "Advertise routes with max-med\n"
1891 "Administratively applied, for an indefinite period\n"
1892 "Max MED value to be used\n")
1894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1895 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1896 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1897 bgp_maxmed_update(bgp
);
1902 DEFUN (bgp_maxmed_onstartup
,
1903 bgp_maxmed_onstartup_cmd
,
1904 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1906 "Advertise routes with max-med\n"
1907 "Effective on a startup\n"
1908 "Time (seconds) period for max-med\n"
1909 "Max MED value to be used\n")
1911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1914 argv_find(argv
, argc
, "(5-86400)", &idx
);
1915 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1916 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1917 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1919 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1921 bgp_maxmed_update(bgp
);
1926 DEFUN (no_bgp_maxmed_onstartup
,
1927 no_bgp_maxmed_onstartup_cmd
,
1928 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1931 "Advertise routes with max-med\n"
1932 "Effective on a startup\n"
1933 "Time (seconds) period for max-med\n"
1934 "Max MED value to be used\n")
1936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1938 /* Cancel max-med onstartup if its on */
1939 if (bgp
->t_maxmed_onstartup
) {
1940 thread_cancel(&bgp
->t_maxmed_onstartup
);
1941 bgp
->maxmed_onstartup_over
= 1;
1944 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1945 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1947 bgp_maxmed_update(bgp
);
1952 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1953 uint16_t update_delay
,
1954 uint16_t establish_wait
)
1956 struct listnode
*node
, *nnode
;
1958 bool vrf_cfg
= false;
1961 * See if update-delay is set per-vrf and warn user to delete it
1962 * Note that we only need to check this if this is the first time
1963 * setting the global config.
1965 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1966 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1967 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1969 "%% update-delay configuration found in vrf %s\n",
1970 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1980 "%%Failed: global update-delay config not permitted\n");
1984 if (!establish_wait
) { /* update-delay <delay> */
1985 bm
->v_update_delay
= update_delay
;
1986 bm
->v_establish_wait
= bm
->v_update_delay
;
1988 /* update-delay <delay> <establish-wait> */
1989 if (update_delay
< establish_wait
) {
1991 "%%Failed: update-delay less than the establish-wait!\n");
1992 return CMD_WARNING_CONFIG_FAILED
;
1995 bm
->v_update_delay
= update_delay
;
1996 bm
->v_establish_wait
= establish_wait
;
1999 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2000 bgp
->v_update_delay
= bm
->v_update_delay
;
2001 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2007 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2009 struct listnode
*node
, *nnode
;
2012 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2013 bm
->v_establish_wait
= bm
->v_update_delay
;
2015 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2016 bgp
->v_update_delay
= bm
->v_update_delay
;
2017 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2023 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2024 uint16_t establish_wait
)
2026 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2028 /* if configured globally, per-instance config is not allowed */
2029 if (bm
->v_update_delay
) {
2031 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2032 return CMD_WARNING_CONFIG_FAILED
;
2036 if (!establish_wait
) /* update-delay <delay> */
2038 bgp
->v_update_delay
= update_delay
;
2039 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2043 /* update-delay <delay> <establish-wait> */
2044 if (update_delay
< establish_wait
) {
2046 "%%Failed: update-delay less than the establish-wait!\n");
2047 return CMD_WARNING_CONFIG_FAILED
;
2050 bgp
->v_update_delay
= update_delay
;
2051 bgp
->v_establish_wait
= establish_wait
;
2056 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2058 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 /* If configured globally, cannot remove from one bgp instance */
2061 if (bm
->v_update_delay
) {
2063 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2064 return CMD_WARNING_CONFIG_FAILED
;
2066 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2067 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2072 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2074 /* If configured globally, no need to display per-instance value */
2075 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2076 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2077 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2078 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2083 /* Global update-delay configuration */
2084 DEFPY (bgp_global_update_delay
,
2085 bgp_global_update_delay_cmd
,
2086 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2088 "Force initial delay for best-path and updates for all bgp instances\n"
2089 "Max delay in seconds\n"
2090 "Establish wait in seconds\n")
2092 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2095 /* Global update-delay deconfiguration */
2096 DEFPY (no_bgp_global_update_delay
,
2097 no_bgp_global_update_delay_cmd
,
2098 "no bgp update-delay [(0-3600) [(1-3600)]]",
2101 "Force initial delay for best-path and updates\n"
2102 "Max delay in seconds\n"
2103 "Establish wait in seconds\n")
2105 return bgp_global_update_delay_deconfig_vty(vty
);
2108 /* Update-delay configuration */
2110 DEFPY (bgp_update_delay
,
2111 bgp_update_delay_cmd
,
2112 "update-delay (0-3600)$delay [(1-3600)$wait]",
2113 "Force initial delay for best-path and updates\n"
2114 "Max delay in seconds\n"
2115 "Establish wait in seconds\n")
2117 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2120 /* Update-delay deconfiguration */
2121 DEFPY (no_bgp_update_delay
,
2122 no_bgp_update_delay_cmd
,
2123 "no update-delay [(0-3600) [(1-3600)]]",
2125 "Force initial delay for best-path and updates\n"
2126 "Max delay in seconds\n"
2127 "Establish wait in seconds\n")
2129 return bgp_update_delay_deconfig_vty(vty
);
2133 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2138 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2139 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2144 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2149 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2150 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2155 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2158 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2159 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2160 vty_out(vty
, " write-quanta %d\n", quanta
);
2163 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2166 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2167 if (quanta
!= BGP_READ_PACKET_MAX
)
2168 vty_out(vty
, " read-quanta %d\n", quanta
);
2171 /* Packet quanta configuration
2173 * XXX: The value set here controls the size of a stack buffer in the IO
2174 * thread. When changing these limits be careful to prevent stack overflow.
2176 * Furthermore, the maximums used here should correspond to
2177 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2179 DEFPY (bgp_wpkt_quanta
,
2180 bgp_wpkt_quanta_cmd
,
2181 "[no] write-quanta (1-64)$quanta",
2183 "How many packets to write to peer socket per run\n"
2184 "Number of packets\n")
2186 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2189 DEFPY (bgp_rpkt_quanta
,
2190 bgp_rpkt_quanta_cmd
,
2191 "[no] read-quanta (1-10)$quanta",
2193 "How many packets to read from peer socket per I/O cycle\n"
2194 "Number of packets\n")
2196 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2199 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2201 if (!bgp
->heuristic_coalesce
)
2202 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2206 DEFUN (bgp_coalesce_time
,
2207 bgp_coalesce_time_cmd
,
2208 "coalesce-time (0-4294967295)",
2209 "Subgroup coalesce timer\n"
2210 "Subgroup coalesce timer value (in ms)\n")
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2215 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2216 bgp
->heuristic_coalesce
= false;
2217 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2221 DEFUN (no_bgp_coalesce_time
,
2222 no_bgp_coalesce_time_cmd
,
2223 "no coalesce-time (0-4294967295)",
2225 "Subgroup coalesce timer\n"
2226 "Subgroup coalesce timer value (in ms)\n")
2228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2230 bgp
->heuristic_coalesce
= true;
2231 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2235 /* Maximum-paths configuration */
2236 DEFUN (bgp_maxpaths
,
2238 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2239 "Forward packets over multiple paths\n"
2240 "Number of paths\n")
2243 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2244 argv
[idx_number
]->arg
, 0, 1);
2247 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2248 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2249 "Forward packets over multiple paths\n"
2250 "Number of paths\n")
2252 DEFUN (bgp_maxpaths_ibgp
,
2253 bgp_maxpaths_ibgp_cmd
,
2254 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2255 "Forward packets over multiple paths\n"
2257 "Number of paths\n")
2260 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2261 argv
[idx_number
]->arg
, 0, 1);
2264 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2265 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2266 "Forward packets over multiple paths\n"
2268 "Number of paths\n")
2270 DEFUN (bgp_maxpaths_ibgp_cluster
,
2271 bgp_maxpaths_ibgp_cluster_cmd
,
2272 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2273 "Forward packets over multiple paths\n"
2276 "Match the cluster length\n")
2279 return bgp_maxpaths_config_vty(
2280 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
2281 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
2284 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2285 "maximum-paths ibgp " CMD_RANGE_STR(
2286 1, MULTIPATH_NUM
) " equal-cluster-length",
2287 "Forward packets over multiple paths\n"
2290 "Match the cluster length\n")
2292 DEFUN (no_bgp_maxpaths
,
2293 no_bgp_maxpaths_cmd
,
2294 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2296 "Forward packets over multiple paths\n"
2297 "Number of paths\n")
2299 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2302 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2303 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2304 "Forward packets over multiple paths\n"
2305 "Number of paths\n")
2307 DEFUN (no_bgp_maxpaths_ibgp
,
2308 no_bgp_maxpaths_ibgp_cmd
,
2309 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2311 "Forward packets over multiple paths\n"
2314 "Match the cluster length\n")
2316 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2319 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2320 "no maximum-paths ibgp [" CMD_RANGE_STR(
2321 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2323 "Forward packets over multiple paths\n"
2326 "Match the cluster length\n")
2328 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2329 afi_t afi
, safi_t safi
)
2331 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2332 vty_out(vty
, " maximum-paths %d\n",
2333 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2336 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2337 vty_out(vty
, " maximum-paths ibgp %d",
2338 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2339 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2340 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2341 vty_out(vty
, " equal-cluster-length");
2350 "timers bgp (0-65535) (0-65535)",
2351 "Adjust routing timers\n"
2353 "Keepalive interval\n"
2356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2358 int idx_number_2
= 3;
2359 unsigned long keepalive
= 0;
2360 unsigned long holdtime
= 0;
2362 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2363 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2365 /* Holdtime value check. */
2366 if (holdtime
< 3 && holdtime
!= 0) {
2368 "%% hold time value must be either 0 or greater than 3\n");
2369 return CMD_WARNING_CONFIG_FAILED
;
2372 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2373 BGP_DEFAULT_DELAYOPEN
);
2378 DEFUN (no_bgp_timers
,
2380 "no timers bgp [(0-65535) (0-65535)]",
2382 "Adjust routing timers\n"
2384 "Keepalive interval\n"
2387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2388 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2389 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2394 /* BGP minimum holdtime. */
2396 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2397 "bgp minimum-holdtime (1-65535)",
2398 "BGP specific commands\n"
2399 "BGP minimum holdtime\n"
2402 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2404 unsigned long min_holdtime
;
2406 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2408 bgp
->default_min_holdtime
= min_holdtime
;
2413 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2414 "no bgp minimum-holdtime [(1-65535)]",
2416 "BGP specific commands\n"
2417 "BGP minimum holdtime\n"
2420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2422 bgp
->default_min_holdtime
= 0;
2427 DEFUN (bgp_client_to_client_reflection
,
2428 bgp_client_to_client_reflection_cmd
,
2429 "bgp client-to-client reflection",
2431 "Configure client to client route reflection\n"
2432 "reflection of routes allowed\n")
2434 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2435 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2436 bgp_clear_star_soft_out(vty
, bgp
->name
);
2441 DEFUN (no_bgp_client_to_client_reflection
,
2442 no_bgp_client_to_client_reflection_cmd
,
2443 "no bgp client-to-client reflection",
2446 "Configure client to client route reflection\n"
2447 "reflection of routes allowed\n")
2449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2450 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2451 bgp_clear_star_soft_out(vty
, bgp
->name
);
2456 /* "bgp always-compare-med" configuration. */
2457 DEFUN (bgp_always_compare_med
,
2458 bgp_always_compare_med_cmd
,
2459 "bgp always-compare-med",
2461 "Allow comparing MED from different neighbors\n")
2463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2464 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2465 bgp_recalculate_all_bestpaths(bgp
);
2470 DEFUN (no_bgp_always_compare_med
,
2471 no_bgp_always_compare_med_cmd
,
2472 "no bgp always-compare-med",
2475 "Allow comparing MED from different neighbors\n")
2477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2478 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2479 bgp_recalculate_all_bestpaths(bgp
);
2485 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2486 "bgp ebgp-requires-policy",
2488 "Require in and out policy for eBGP peers (RFC8212)\n")
2490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2491 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2495 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2496 "no bgp ebgp-requires-policy",
2499 "Require in and out policy for eBGP peers (RFC8212)\n")
2501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2502 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2506 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2507 "bgp suppress-duplicates",
2509 "Suppress duplicate updates if the route actually not changed\n")
2511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2512 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2516 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2517 "no bgp suppress-duplicates",
2520 "Suppress duplicate updates if the route actually not changed\n")
2522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2523 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2527 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2528 "bgp reject-as-sets",
2530 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2533 struct listnode
*node
, *nnode
;
2536 bgp
->reject_as_sets
= true;
2538 /* Reset existing BGP sessions to reject routes
2539 * with aspath containing AS_SET or AS_CONFED_SET.
2541 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2542 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2543 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2544 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2545 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2552 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2553 "no bgp reject-as-sets",
2556 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2559 struct listnode
*node
, *nnode
;
2562 bgp
->reject_as_sets
= false;
2564 /* Reset existing BGP sessions to reject routes
2565 * with aspath containing AS_SET or AS_CONFED_SET.
2567 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2568 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2569 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2570 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2571 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2578 /* "bgp deterministic-med" configuration. */
2579 DEFUN (bgp_deterministic_med
,
2580 bgp_deterministic_med_cmd
,
2581 "bgp deterministic-med",
2583 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2585 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2587 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2588 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2589 bgp_recalculate_all_bestpaths(bgp
);
2595 DEFUN (no_bgp_deterministic_med
,
2596 no_bgp_deterministic_med_cmd
,
2597 "no bgp deterministic-med",
2600 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2603 int bestpath_per_as_used
;
2607 struct listnode
*node
, *nnode
;
2609 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2610 bestpath_per_as_used
= 0;
2612 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2613 FOREACH_AFI_SAFI (afi
, safi
)
2614 if (bgp_addpath_dmed_required(
2615 peer
->addpath_type
[afi
][safi
])) {
2616 bestpath_per_as_used
= 1;
2620 if (bestpath_per_as_used
)
2624 if (bestpath_per_as_used
) {
2626 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2627 return CMD_WARNING_CONFIG_FAILED
;
2629 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2630 bgp_recalculate_all_bestpaths(bgp
);
2637 /* "bgp graceful-restart mode" configuration. */
2638 DEFUN (bgp_graceful_restart
,
2639 bgp_graceful_restart_cmd
,
2640 "bgp graceful-restart",
2645 int ret
= BGP_GR_FAILURE
;
2647 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2648 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2654 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2657 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2658 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2660 "Graceful restart configuration changed, reset all peers to take effect\n");
2661 return bgp_vty_return(vty
, ret
);
2664 DEFUN (no_bgp_graceful_restart
,
2665 no_bgp_graceful_restart_cmd
,
2666 "no bgp graceful-restart",
2672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2674 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2675 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2677 int ret
= BGP_GR_FAILURE
;
2679 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2681 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2684 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2685 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2687 "Graceful restart configuration changed, reset all peers to take effect\n");
2689 return bgp_vty_return(vty
, ret
);
2692 DEFUN (bgp_graceful_restart_stalepath_time
,
2693 bgp_graceful_restart_stalepath_time_cmd
,
2694 "bgp graceful-restart stalepath-time (1-4095)",
2696 "Graceful restart capability parameters\n"
2697 "Set the max time to hold onto restarting peer's stale paths\n"
2698 "Delay value (seconds)\n")
2700 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2705 bgp
->stalepath_time
= stalepath
;
2709 DEFUN (bgp_graceful_restart_restart_time
,
2710 bgp_graceful_restart_restart_time_cmd
,
2711 "bgp graceful-restart restart-time (0-4095)",
2713 "Graceful restart capability parameters\n"
2714 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2715 "Delay value (seconds)\n")
2717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2721 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2722 bgp
->restart_time
= restart
;
2726 DEFUN (bgp_graceful_restart_select_defer_time
,
2727 bgp_graceful_restart_select_defer_time_cmd
,
2728 "bgp graceful-restart select-defer-time (0-3600)",
2730 "Graceful restart capability parameters\n"
2731 "Set the time to defer the BGP route selection after restart\n"
2732 "Delay value (seconds, 0 - disable)\n")
2734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2736 uint32_t defer_time
;
2738 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2739 bgp
->select_defer_time
= defer_time
;
2740 if (defer_time
== 0)
2741 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2743 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2748 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2749 no_bgp_graceful_restart_stalepath_time_cmd
,
2750 "no bgp graceful-restart stalepath-time [(1-4095)]",
2753 "Graceful restart capability parameters\n"
2754 "Set the max time to hold onto restarting peer's stale paths\n"
2755 "Delay value (seconds)\n")
2757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2759 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2763 DEFUN (no_bgp_graceful_restart_restart_time
,
2764 no_bgp_graceful_restart_restart_time_cmd
,
2765 "no bgp graceful-restart restart-time [(0-4095)]",
2768 "Graceful restart capability parameters\n"
2769 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2770 "Delay value (seconds)\n")
2772 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2774 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2778 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2779 no_bgp_graceful_restart_select_defer_time_cmd
,
2780 "no bgp graceful-restart select-defer-time [(0-3600)]",
2783 "Graceful restart capability parameters\n"
2784 "Set the time to defer the BGP route selection after restart\n"
2785 "Delay value (seconds)\n")
2787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2789 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2790 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2795 DEFUN (bgp_graceful_restart_preserve_fw
,
2796 bgp_graceful_restart_preserve_fw_cmd
,
2797 "bgp graceful-restart preserve-fw-state",
2799 "Graceful restart capability parameters\n"
2800 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2807 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2808 no_bgp_graceful_restart_preserve_fw_cmd
,
2809 "no bgp graceful-restart preserve-fw-state",
2812 "Graceful restart capability parameters\n"
2813 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2816 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2820 DEFUN (bgp_graceful_restart_disable
,
2821 bgp_graceful_restart_disable_cmd
,
2822 "bgp graceful-restart-disable",
2826 int ret
= BGP_GR_FAILURE
;
2828 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2830 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2834 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2836 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2839 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2841 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2843 "Graceful restart configuration changed, reset all peers to take effect\n");
2845 return bgp_vty_return(vty
, ret
);
2848 DEFUN (no_bgp_graceful_restart_disable
,
2849 no_bgp_graceful_restart_disable_cmd
,
2850 "no bgp graceful-restart-disable",
2856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2858 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2860 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2862 int ret
= BGP_GR_FAILURE
;
2864 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2866 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2869 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2871 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2873 "Graceful restart configuration changed, reset all peers to take effect\n");
2875 return bgp_vty_return(vty
, ret
);
2878 DEFUN (bgp_neighbor_graceful_restart_set
,
2879 bgp_neighbor_graceful_restart_set_cmd
,
2880 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2888 int ret
= BGP_GR_FAILURE
;
2890 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2892 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2894 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2896 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2898 return CMD_WARNING_CONFIG_FAILED
;
2900 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2902 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2903 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2905 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2907 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2909 "Graceful restart configuration changed, reset this peer to take effect\n");
2911 return bgp_vty_return(vty
, ret
);
2914 DEFUN (no_bgp_neighbor_graceful_restart
,
2915 no_bgp_neighbor_graceful_restart_set_cmd
,
2916 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2924 int ret
= BGP_GR_FAILURE
;
2927 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2929 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2931 return CMD_WARNING_CONFIG_FAILED
;
2933 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2935 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2937 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2939 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2940 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2942 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2944 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2946 "Graceful restart configuration changed, reset this peer to take effect\n");
2948 return bgp_vty_return(vty
, ret
);
2951 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2952 bgp_neighbor_graceful_restart_helper_set_cmd
,
2953 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2956 GR_NEIGHBOR_HELPER_CMD
2961 int ret
= BGP_GR_FAILURE
;
2963 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2965 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2967 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2969 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2972 return CMD_WARNING_CONFIG_FAILED
;
2975 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2977 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2978 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2980 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2982 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2984 "Graceful restart configuration changed, reset this peer to take effect\n");
2986 return bgp_vty_return(vty
, ret
);
2989 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2990 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2991 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2995 NO_GR_NEIGHBOR_HELPER_CMD
2999 int ret
= BGP_GR_FAILURE
;
3002 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3004 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3006 return CMD_WARNING_CONFIG_FAILED
;
3008 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3010 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3012 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3014 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3015 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3017 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3019 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3021 "Graceful restart configuration changed, reset this peer to take effect\n");
3023 return bgp_vty_return(vty
, ret
);
3026 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3027 bgp_neighbor_graceful_restart_disable_set_cmd
,
3028 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3031 GR_NEIGHBOR_DISABLE_CMD
3036 int ret
= BGP_GR_FAILURE
;
3038 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3040 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3042 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3044 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3046 return CMD_WARNING_CONFIG_FAILED
;
3048 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3050 if (peer
->bgp
->t_startup
)
3051 bgp_peer_gr_flags_update(peer
);
3053 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3054 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3056 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3058 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3060 "Graceful restart configuration changed, reset this peer to take effect\n");
3062 return bgp_vty_return(vty
, ret
);
3065 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3066 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3067 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3071 NO_GR_NEIGHBOR_DISABLE_CMD
3075 int ret
= BGP_GR_FAILURE
;
3078 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3080 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3082 return CMD_WARNING_CONFIG_FAILED
;
3084 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3086 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3088 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3090 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3091 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3093 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3095 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3097 "Graceful restart configuration changed, reset this peer to take effect\n");
3099 return bgp_vty_return(vty
, ret
);
3102 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3103 bgp_graceful_restart_disable_eor_cmd
,
3104 "bgp graceful-restart disable-eor",
3106 "Graceful restart configuration parameters\n"
3107 "Disable EOR Check\n")
3109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3110 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3115 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3116 no_bgp_graceful_restart_disable_eor_cmd
,
3117 "no bgp graceful-restart disable-eor",
3120 "Graceful restart configuration parameters\n"
3121 "Disable EOR Check\n")
3123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3124 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3129 DEFUN (bgp_graceful_restart_rib_stale_time
,
3130 bgp_graceful_restart_rib_stale_time_cmd
,
3131 "bgp graceful-restart rib-stale-time (1-3600)",
3133 "Graceful restart configuration parameters\n"
3134 "Specify the stale route removal timer in rib\n"
3135 "Delay value (seconds)\n")
3137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3139 uint32_t stale_time
;
3141 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3142 bgp
->rib_stale_time
= stale_time
;
3143 /* Send the stale timer update message to RIB */
3144 if (bgp_zebra_stale_timer_update(bgp
))
3150 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3151 no_bgp_graceful_restart_rib_stale_time_cmd
,
3152 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3155 "Graceful restart configuration parameters\n"
3156 "Specify the stale route removal timer in rib\n"
3157 "Delay value (seconds)\n")
3159 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3161 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3162 /* Send the stale timer update message to RIB */
3163 if (bgp_zebra_stale_timer_update(bgp
))
3169 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3170 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3172 "Enable Long-lived Graceful Restart\n"
3173 "Specifies maximum time to wait before purging long-lived stale routes\n"
3174 "Stale time value (seconds)\n")
3176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3178 uint32_t llgr_stale_time
;
3180 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3181 bgp
->llgr_stale_time
= llgr_stale_time
;
3186 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3187 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3189 "Enable Long-lived Graceful Restart\n"
3190 "Specifies maximum time to wait before purging long-lived stale routes\n"
3191 "Stale time value (seconds)\n")
3193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3195 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3200 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3203 bgp_static_redo_import_check(bgp
);
3204 bgp_redistribute_redo(bgp
);
3205 bgp_clear_star_soft_out(vty
, bgp
->name
);
3206 bgp_clear_star_soft_in(vty
, bgp
->name
);
3209 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3211 struct listnode
*node
, *nnode
;
3213 bool vrf_cfg
= false;
3215 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3218 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3219 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3220 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3222 "%% graceful-shutdown configuration found in vrf %s\n",
3223 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3224 VRF_DEFAULT_NAME
: bgp
->name
);
3231 "%%Failed: global graceful-shutdown not permitted\n");
3235 /* Set flag globally */
3236 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3238 /* Initiate processing for all BGP instances. */
3239 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3240 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3245 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3247 struct listnode
*node
, *nnode
;
3250 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3253 /* Unset flag globally */
3254 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3256 /* Initiate processing for all BGP instances. */
3257 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3258 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3263 /* "bgp graceful-shutdown" configuration */
3264 DEFUN (bgp_graceful_shutdown
,
3265 bgp_graceful_shutdown_cmd
,
3266 "bgp graceful-shutdown",
3268 "Graceful shutdown parameters\n")
3270 if (vty
->node
== CONFIG_NODE
)
3271 return bgp_global_graceful_shutdown_config_vty(vty
);
3273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3275 /* if configured globally, per-instance config is not allowed */
3276 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3278 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3279 return CMD_WARNING_CONFIG_FAILED
;
3282 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3283 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3284 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3290 DEFUN (no_bgp_graceful_shutdown
,
3291 no_bgp_graceful_shutdown_cmd
,
3292 "no bgp graceful-shutdown",
3295 "Graceful shutdown parameters\n")
3297 if (vty
->node
== CONFIG_NODE
)
3298 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3302 /* If configured globally, cannot remove from one bgp instance */
3303 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3305 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3306 return CMD_WARNING_CONFIG_FAILED
;
3309 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3310 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3311 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3317 /* "bgp fast-external-failover" configuration. */
3318 DEFUN (bgp_fast_external_failover
,
3319 bgp_fast_external_failover_cmd
,
3320 "bgp fast-external-failover",
3322 "Immediately reset session if a link to a directly connected external peer goes down\n")
3324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3325 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3329 DEFUN (no_bgp_fast_external_failover
,
3330 no_bgp_fast_external_failover_cmd
,
3331 "no bgp fast-external-failover",
3334 "Immediately reset session if a link to a directly connected external peer goes down\n")
3336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3337 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3341 /* "bgp bestpath compare-routerid" configuration. */
3342 DEFUN (bgp_bestpath_compare_router_id
,
3343 bgp_bestpath_compare_router_id_cmd
,
3344 "bgp bestpath compare-routerid",
3346 "Change the default bestpath selection\n"
3347 "Compare router-id for identical EBGP paths\n")
3349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3350 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3351 bgp_recalculate_all_bestpaths(bgp
);
3356 DEFUN (no_bgp_bestpath_compare_router_id
,
3357 no_bgp_bestpath_compare_router_id_cmd
,
3358 "no bgp bestpath compare-routerid",
3361 "Change the default bestpath selection\n"
3362 "Compare router-id for identical EBGP paths\n")
3364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3365 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3366 bgp_recalculate_all_bestpaths(bgp
);
3371 /* "bgp bestpath as-path ignore" configuration. */
3372 DEFUN (bgp_bestpath_aspath_ignore
,
3373 bgp_bestpath_aspath_ignore_cmd
,
3374 "bgp bestpath as-path ignore",
3376 "Change the default bestpath selection\n"
3377 "AS-path attribute\n"
3378 "Ignore as-path length in selecting a route\n")
3380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3381 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3382 bgp_recalculate_all_bestpaths(bgp
);
3387 DEFUN (no_bgp_bestpath_aspath_ignore
,
3388 no_bgp_bestpath_aspath_ignore_cmd
,
3389 "no bgp bestpath as-path ignore",
3392 "Change the default bestpath selection\n"
3393 "AS-path attribute\n"
3394 "Ignore as-path length in selecting a route\n")
3396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3397 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3398 bgp_recalculate_all_bestpaths(bgp
);
3403 /* "bgp bestpath as-path confed" configuration. */
3404 DEFUN (bgp_bestpath_aspath_confed
,
3405 bgp_bestpath_aspath_confed_cmd
,
3406 "bgp bestpath as-path confed",
3408 "Change the default bestpath selection\n"
3409 "AS-path attribute\n"
3410 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3413 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3414 bgp_recalculate_all_bestpaths(bgp
);
3419 DEFUN (no_bgp_bestpath_aspath_confed
,
3420 no_bgp_bestpath_aspath_confed_cmd
,
3421 "no bgp bestpath as-path confed",
3424 "Change the default bestpath selection\n"
3425 "AS-path attribute\n"
3426 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3428 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3429 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3430 bgp_recalculate_all_bestpaths(bgp
);
3435 /* "bgp bestpath as-path multipath-relax" configuration. */
3436 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3437 bgp_bestpath_aspath_multipath_relax_cmd
,
3438 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3440 "Change the default bestpath selection\n"
3441 "AS-path attribute\n"
3442 "Allow load sharing across routes that have different AS paths (but same length)\n"
3443 "Generate an AS_SET\n"
3444 "Do not generate an AS_SET\n")
3446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3448 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3450 /* no-as-set is now the default behavior so we can silently
3452 if (argv_find(argv
, argc
, "as-set", &idx
))
3453 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3455 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3457 bgp_recalculate_all_bestpaths(bgp
);
3462 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3463 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3464 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3467 "Change the default bestpath selection\n"
3468 "AS-path attribute\n"
3469 "Allow load sharing across routes that have different AS paths (but same length)\n"
3470 "Generate an AS_SET\n"
3471 "Do not generate an AS_SET\n")
3473 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3474 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3475 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3476 bgp_recalculate_all_bestpaths(bgp
);
3481 /* "bgp bestpath peer-type multipath-relax" configuration. */
3482 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3483 bgp_bestpath_peer_type_multipath_relax_cmd
,
3484 "bgp bestpath peer-type multipath-relax",
3486 "Change the default bestpath selection\n"
3488 "Allow load sharing across routes learned from different peer types\n")
3490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3491 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3492 bgp_recalculate_all_bestpaths(bgp
);
3497 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3498 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3499 "no bgp bestpath peer-type multipath-relax",
3501 "Change the default bestpath selection\n"
3503 "Allow load sharing across routes learned from different peer types\n")
3505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3506 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3507 bgp_recalculate_all_bestpaths(bgp
);
3512 /* "bgp log-neighbor-changes" configuration. */
3513 DEFUN (bgp_log_neighbor_changes
,
3514 bgp_log_neighbor_changes_cmd
,
3515 "bgp log-neighbor-changes",
3517 "Log neighbor up/down and reset reason\n")
3519 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3520 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3524 DEFUN (no_bgp_log_neighbor_changes
,
3525 no_bgp_log_neighbor_changes_cmd
,
3526 "no bgp log-neighbor-changes",
3529 "Log neighbor up/down and reset reason\n")
3531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3532 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3536 /* "bgp bestpath med" configuration. */
3537 DEFUN (bgp_bestpath_med
,
3538 bgp_bestpath_med_cmd
,
3539 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3541 "Change the default bestpath selection\n"
3543 "Compare MED among confederation paths\n"
3544 "Treat missing MED as the least preferred one\n"
3545 "Treat missing MED as the least preferred one\n"
3546 "Compare MED among confederation paths\n")
3548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3551 if (argv_find(argv
, argc
, "confed", &idx
))
3552 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3554 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3555 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3557 bgp_recalculate_all_bestpaths(bgp
);
3562 DEFUN (no_bgp_bestpath_med
,
3563 no_bgp_bestpath_med_cmd
,
3564 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3567 "Change the default bestpath selection\n"
3569 "Compare MED among confederation paths\n"
3570 "Treat missing MED as the least preferred one\n"
3571 "Treat missing MED as the least preferred one\n"
3572 "Compare MED among confederation paths\n")
3574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3577 if (argv_find(argv
, argc
, "confed", &idx
))
3578 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3580 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3581 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3583 bgp_recalculate_all_bestpaths(bgp
);
3588 /* "bgp bestpath bandwidth" configuration. */
3589 DEFPY (bgp_bestpath_bw
,
3590 bgp_bestpath_bw_cmd
,
3591 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3593 "Change the default bestpath selection\n"
3594 "Link Bandwidth attribute\n"
3595 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3596 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3597 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3604 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3605 return CMD_ERR_INCOMPLETE
;
3607 if (!strcmp(bw_cfg
, "ignore"))
3608 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3609 else if (!strcmp(bw_cfg
, "skip-missing"))
3610 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3611 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3612 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3614 return CMD_ERR_NO_MATCH
;
3616 /* This config is used in route install, so redo that. */
3617 FOREACH_AFI_SAFI (afi
, safi
) {
3618 if (!bgp_fibupd_safi(safi
))
3620 bgp_zebra_announce_table(bgp
, afi
, safi
);
3626 DEFPY (no_bgp_bestpath_bw
,
3627 no_bgp_bestpath_bw_cmd
,
3628 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3631 "Change the default bestpath selection\n"
3632 "Link Bandwidth attribute\n"
3633 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3634 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3635 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3641 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3643 /* This config is used in route install, so redo that. */
3644 FOREACH_AFI_SAFI (afi
, safi
) {
3645 if (!bgp_fibupd_safi(safi
))
3647 bgp_zebra_announce_table(bgp
, afi
, safi
);
3652 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3653 "[no] bgp default <ipv4-unicast|"
3656 "ipv4-labeled-unicast|"
3661 "ipv6-labeled-unicast|"
3663 "l2vpn-evpn>$afi_safi",
3666 "Configure BGP defaults\n"
3667 "Activate ipv4-unicast for a peer by default\n"
3668 "Activate ipv4-multicast for a peer by default\n"
3669 "Activate ipv4-vpn for a peer by default\n"
3670 "Activate ipv4-labeled-unicast for a peer by default\n"
3671 "Activate ipv4-flowspec for a peer by default\n"
3672 "Activate ipv6-unicast for a peer by default\n"
3673 "Activate ipv6-multicast for a peer by default\n"
3674 "Activate ipv6-vpn for a peer by default\n"
3675 "Activate ipv6-labeled-unicast for a peer by default\n"
3676 "Activate ipv6-flowspec for a peer by default\n"
3677 "Activate l2vpn-evpn for a peer by default\n")
3679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3680 char afi_safi_str
[strlen(afi_safi
) + 1];
3681 char *afi_safi_str_tok
;
3683 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3684 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3685 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3686 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3689 if (strmatch(safi_str
, "labeled"))
3690 safi
= bgp_vty_safi_from_str("labeled-unicast");
3692 safi
= bgp_vty_safi_from_str(safi_str
);
3695 bgp
->default_af
[afi
][safi
] = false;
3697 if ((safi
== SAFI_LABELED_UNICAST
3698 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3699 || (safi
== SAFI_UNICAST
3700 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3701 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3703 bgp
->default_af
[afi
][safi
] = true;
3709 /* Display hostname in certain command outputs */
3710 DEFUN (bgp_default_show_hostname
,
3711 bgp_default_show_hostname_cmd
,
3712 "bgp default show-hostname",
3714 "Configure BGP defaults\n"
3715 "Show hostname in certain command outputs\n")
3717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3718 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3722 DEFUN (no_bgp_default_show_hostname
,
3723 no_bgp_default_show_hostname_cmd
,
3724 "no bgp default show-hostname",
3727 "Configure BGP defaults\n"
3728 "Show hostname in certain command outputs\n")
3730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3731 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3735 /* Display hostname in certain command outputs */
3736 DEFUN (bgp_default_show_nexthop_hostname
,
3737 bgp_default_show_nexthop_hostname_cmd
,
3738 "bgp default show-nexthop-hostname",
3740 "Configure BGP defaults\n"
3741 "Show hostname for nexthop in certain command outputs\n")
3743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3744 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3748 DEFUN (no_bgp_default_show_nexthop_hostname
,
3749 no_bgp_default_show_nexthop_hostname_cmd
,
3750 "no bgp default show-nexthop-hostname",
3753 "Configure BGP defaults\n"
3754 "Show hostname for nexthop in certain command outputs\n")
3756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3757 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3761 /* "bgp network import-check" configuration. */
3762 DEFUN (bgp_network_import_check
,
3763 bgp_network_import_check_cmd
,
3764 "bgp network import-check",
3766 "BGP network command\n"
3767 "Check BGP network route exists in IGP\n")
3769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3770 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3771 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3772 bgp_static_redo_import_check(bgp
);
3778 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3779 "bgp network import-check exact",
3781 "BGP network command\n"
3782 "Check BGP network route exists in IGP\n"
3783 "Match route precisely\n")
3785 DEFUN (no_bgp_network_import_check
,
3786 no_bgp_network_import_check_cmd
,
3787 "no bgp network import-check",
3790 "BGP network command\n"
3791 "Check BGP network route exists in IGP\n")
3793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3794 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3795 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3796 bgp_static_redo_import_check(bgp
);
3802 DEFUN (bgp_default_local_preference
,
3803 bgp_default_local_preference_cmd
,
3804 "bgp default local-preference (0-4294967295)",
3806 "Configure BGP defaults\n"
3807 "local preference (higher=more preferred)\n"
3808 "Configure default local preference value\n")
3810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3812 uint32_t local_pref
;
3814 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3816 bgp_default_local_preference_set(bgp
, local_pref
);
3817 bgp_clear_star_soft_in(vty
, bgp
->name
);
3822 DEFUN (no_bgp_default_local_preference
,
3823 no_bgp_default_local_preference_cmd
,
3824 "no bgp default local-preference [(0-4294967295)]",
3827 "Configure BGP defaults\n"
3828 "local preference (higher=more preferred)\n"
3829 "Configure default local preference value\n")
3831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3832 bgp_default_local_preference_unset(bgp
);
3833 bgp_clear_star_soft_in(vty
, bgp
->name
);
3839 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3840 bgp_default_subgroup_pkt_queue_max_cmd
,
3841 "bgp default subgroup-pkt-queue-max (20-100)",
3843 "Configure BGP defaults\n"
3844 "subgroup-pkt-queue-max\n"
3845 "Configure subgroup packet queue max\n")
3847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3851 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3853 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3858 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3859 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3860 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3863 "Configure BGP defaults\n"
3864 "subgroup-pkt-queue-max\n"
3865 "Configure subgroup packet queue max\n")
3867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3868 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3873 DEFUN (bgp_rr_allow_outbound_policy
,
3874 bgp_rr_allow_outbound_policy_cmd
,
3875 "bgp route-reflector allow-outbound-policy",
3877 "Allow modifications made by out route-map\n"
3878 "on ibgp neighbors\n")
3880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3882 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3883 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3884 update_group_announce_rrclients(bgp
);
3885 bgp_clear_star_soft_out(vty
, bgp
->name
);
3891 DEFUN (no_bgp_rr_allow_outbound_policy
,
3892 no_bgp_rr_allow_outbound_policy_cmd
,
3893 "no bgp route-reflector allow-outbound-policy",
3896 "Allow modifications made by out route-map\n"
3897 "on ibgp neighbors\n")
3899 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3901 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3902 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3903 update_group_announce_rrclients(bgp
);
3904 bgp_clear_star_soft_out(vty
, bgp
->name
);
3910 DEFUN (bgp_listen_limit
,
3911 bgp_listen_limit_cmd
,
3912 "bgp listen limit (1-65535)",
3914 "BGP Dynamic Neighbors listen commands\n"
3915 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3916 "Configure Dynamic Neighbors listen limit value\n")
3918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3922 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3924 bgp_listen_limit_set(bgp
, listen_limit
);
3929 DEFUN (no_bgp_listen_limit
,
3930 no_bgp_listen_limit_cmd
,
3931 "no bgp listen limit [(1-65535)]",
3934 "BGP Dynamic Neighbors listen commands\n"
3935 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3936 "Configure Dynamic Neighbors listen limit value\n")
3938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3939 bgp_listen_limit_unset(bgp
);
3945 * Check if this listen range is already configured. Check for exact
3946 * match or overlap based on input.
3948 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3949 struct prefix
*range
, int exact
)
3951 struct listnode
*node
, *nnode
;
3952 struct listnode
*node1
, *nnode1
;
3953 struct peer_group
*group
;
3958 afi
= family2afi(range
->family
);
3959 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3960 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3963 match
= prefix_same(range
, lr
);
3965 match
= (prefix_match(range
, lr
)
3966 || prefix_match(lr
, range
));
3975 DEFUN (bgp_listen_range
,
3976 bgp_listen_range_cmd
,
3977 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3979 "Configure BGP dynamic neighbors listen range\n"
3980 "Configure BGP dynamic neighbors listen range\n"
3982 "Member of the peer-group\n"
3983 "Peer-group name\n")
3985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3986 struct prefix range
;
3987 struct peer_group
*group
, *existing_group
;
3992 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3993 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3994 char *prefix
= argv
[idx
]->arg
;
3995 argv_find(argv
, argc
, "PGNAME", &idx
);
3996 char *peergroup
= argv
[idx
]->arg
;
3998 /* Convert IP prefix string to struct prefix. */
3999 ret
= str2prefix(prefix
, &range
);
4001 vty_out(vty
, "%% Malformed listen range\n");
4002 return CMD_WARNING_CONFIG_FAILED
;
4005 afi
= family2afi(range
.family
);
4007 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4009 "%% Malformed listen range (link-local address)\n");
4010 return CMD_WARNING_CONFIG_FAILED
;
4015 /* Check if same listen range is already configured. */
4016 existing_group
= listen_range_exists(bgp
, &range
, 1);
4017 if (existing_group
) {
4018 if (strcmp(existing_group
->name
, peergroup
) == 0)
4022 "%% Same listen range is attached to peer-group %s\n",
4023 existing_group
->name
);
4024 return CMD_WARNING_CONFIG_FAILED
;
4028 /* Check if an overlapping listen range exists. */
4029 if (listen_range_exists(bgp
, &range
, 0)) {
4031 "%% Listen range overlaps with existing listen range\n");
4032 return CMD_WARNING_CONFIG_FAILED
;
4035 group
= peer_group_lookup(bgp
, peergroup
);
4037 vty_out(vty
, "%% Configure the peer-group first\n");
4038 return CMD_WARNING_CONFIG_FAILED
;
4041 ret
= peer_group_listen_range_add(group
, &range
);
4042 return bgp_vty_return(vty
, ret
);
4045 DEFUN (no_bgp_listen_range
,
4046 no_bgp_listen_range_cmd
,
4047 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4050 "Unconfigure BGP dynamic neighbors listen range\n"
4051 "Unconfigure BGP dynamic neighbors listen range\n"
4053 "Member of the peer-group\n"
4054 "Peer-group name\n")
4056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4057 struct prefix range
;
4058 struct peer_group
*group
;
4063 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4064 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4065 char *prefix
= argv
[idx
]->arg
;
4066 argv_find(argv
, argc
, "PGNAME", &idx
);
4067 char *peergroup
= argv
[idx
]->arg
;
4069 /* Convert IP prefix string to struct prefix. */
4070 ret
= str2prefix(prefix
, &range
);
4072 vty_out(vty
, "%% Malformed listen range\n");
4073 return CMD_WARNING_CONFIG_FAILED
;
4076 afi
= family2afi(range
.family
);
4078 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4080 "%% Malformed listen range (link-local address)\n");
4081 return CMD_WARNING_CONFIG_FAILED
;
4086 group
= peer_group_lookup(bgp
, peergroup
);
4088 vty_out(vty
, "%% Peer-group does not exist\n");
4089 return CMD_WARNING_CONFIG_FAILED
;
4092 ret
= peer_group_listen_range_del(group
, &range
);
4093 return bgp_vty_return(vty
, ret
);
4096 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4098 struct peer_group
*group
;
4099 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4100 struct prefix
*range
;
4103 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4104 vty_out(vty
, " bgp listen limit %d\n",
4105 bgp
->dynamic_neighbors_limit
);
4107 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4108 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4109 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4112 " bgp listen range %pFX peer-group %s\n",
4113 range
, group
->name
);
4120 DEFUN (bgp_disable_connected_route_check
,
4121 bgp_disable_connected_route_check_cmd
,
4122 "bgp disable-ebgp-connected-route-check",
4124 "Disable checking if nexthop is connected on ebgp sessions\n")
4126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4127 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4128 bgp_clear_star_soft_in(vty
, bgp
->name
);
4133 DEFUN (no_bgp_disable_connected_route_check
,
4134 no_bgp_disable_connected_route_check_cmd
,
4135 "no bgp disable-ebgp-connected-route-check",
4138 "Disable checking if nexthop is connected on ebgp sessions\n")
4140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4141 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4142 bgp_clear_star_soft_in(vty
, bgp
->name
);
4148 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4154 int as_type
= AS_SPECIFIED
;
4157 if (as_str
[0] == 'i') {
4159 as_type
= AS_INTERNAL
;
4160 } else if (as_str
[0] == 'e') {
4162 as_type
= AS_EXTERNAL
;
4164 /* Get AS number. */
4165 as
= strtoul(as_str
, NULL
, 10);
4168 /* If peer is peer group or interface peer, call proper function. */
4169 ret
= str2sockunion(peer_str
, &su
);
4173 /* Check if existing interface peer */
4174 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4176 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4178 /* if not interface peer, check peer-group settings */
4179 if (ret
< 0 && !peer
) {
4180 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4183 "%% Create the peer-group or interface first\n");
4184 return CMD_WARNING_CONFIG_FAILED
;
4189 if (peer_address_self_check(bgp
, &su
)) {
4191 "%% Can not configure the local system as neighbor\n");
4192 return CMD_WARNING_CONFIG_FAILED
;
4194 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4197 /* This peer belongs to peer group. */
4199 case BGP_ERR_PEER_GROUP_MEMBER
:
4201 "%% Peer-group member cannot override remote-as of peer-group\n");
4202 return CMD_WARNING_CONFIG_FAILED
;
4203 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
4205 "%% Peer-group members must be all internal or all external\n");
4206 return CMD_WARNING_CONFIG_FAILED
;
4208 return bgp_vty_return(vty
, ret
);
4211 DEFUN (bgp_default_shutdown
,
4212 bgp_default_shutdown_cmd
,
4213 "[no] bgp default shutdown",
4216 "Configure BGP defaults\n"
4217 "Apply administrative shutdown to newly configured peers\n")
4219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4220 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4224 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4226 "Administrative shutdown of the BGP instance\n"
4227 "Add a shutdown message (RFC 8203)\n"
4228 "Shutdown message\n")
4230 char *msgstr
= NULL
;
4232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4235 msgstr
= argv_concat(argv
, argc
, 3);
4237 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4238 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4239 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4240 return CMD_WARNING_CONFIG_FAILED
;
4243 bgp_shutdown_enable(bgp
, msgstr
);
4244 XFREE(MTYPE_TMP
, msgstr
);
4249 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4250 BGP_STR
"Administrative shutdown of the BGP instance\n")
4252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4254 bgp_shutdown_enable(bgp
, NULL
);
4259 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4260 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4264 bgp_shutdown_disable(bgp
);
4269 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4270 "no bgp shutdown message MSG...", NO_STR BGP_STR
4271 "Administrative shutdown of the BGP instance\n"
4272 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4274 DEFUN (neighbor_remote_as
,
4275 neighbor_remote_as_cmd
,
4276 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4279 "Specify a BGP neighbor\n"
4281 "Internal BGP peer\n"
4282 "External BGP peer\n")
4285 int idx_remote_as
= 3;
4286 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4287 argv
[idx_remote_as
]->arg
);
4289 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4290 * sessions do not wait for hold timer expiry to bring down the sessions
4291 * when nexthop becomes unreachable
4293 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4294 BGP_STR
"Fast convergence for bgp sessions\n")
4296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4297 bgp
->fast_convergence
= true;
4302 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4303 "no bgp fast-convergence",
4304 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4307 bgp
->fast_convergence
= false;
4312 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4314 const char *peer_group_name
,
4317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4319 int as_type
= AS_UNSPECIFIED
;
4321 struct peer_group
*group
;
4324 group
= peer_group_lookup(bgp
, conf_if
);
4327 vty_out(vty
, "%% Name conflict with peer-group \n");
4328 return CMD_WARNING_CONFIG_FAILED
;
4332 if (as_str
[0] == 'i') {
4333 as_type
= AS_INTERNAL
;
4334 } else if (as_str
[0] == 'e') {
4335 as_type
= AS_EXTERNAL
;
4337 /* Get AS number. */
4338 as
= strtoul(as_str
, NULL
, 10);
4339 as_type
= AS_SPECIFIED
;
4343 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4346 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4348 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4352 vty_out(vty
, "%% BGP failed to create peer\n");
4353 return CMD_WARNING_CONFIG_FAILED
;
4357 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4359 /* Request zebra to initiate IPv6 RAs on this interface. We do
4361 * any unnumbered peer in order to not worry about run-time
4363 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4365 * gets deleted later etc.)
4368 bgp_zebra_initiate_radv(bgp
, peer
);
4371 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4372 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4374 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4376 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4378 /* v6only flag changed. Reset bgp seesion */
4379 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4380 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4381 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4382 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4384 bgp_session_reset(peer
);
4387 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4388 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4389 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4390 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4393 if (peer_group_name
) {
4394 group
= peer_group_lookup(bgp
, peer_group_name
);
4396 vty_out(vty
, "%% Configure the peer-group first\n");
4397 return CMD_WARNING_CONFIG_FAILED
;
4400 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4403 return bgp_vty_return(vty
, ret
);
4406 DEFUN (neighbor_interface_config
,
4407 neighbor_interface_config_cmd
,
4408 "neighbor WORD interface [peer-group PGNAME]",
4410 "Interface name or neighbor tag\n"
4411 "Enable BGP on interface\n"
4412 "Member of the peer-group\n"
4413 "Peer-group name\n")
4416 int idx_peer_group_word
= 4;
4418 if (argc
> idx_peer_group_word
)
4419 return peer_conf_interface_get(
4420 vty
, argv
[idx_word
]->arg
, 0,
4421 argv
[idx_peer_group_word
]->arg
, NULL
);
4423 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4427 DEFUN (neighbor_interface_config_v6only
,
4428 neighbor_interface_config_v6only_cmd
,
4429 "neighbor WORD interface v6only [peer-group PGNAME]",
4431 "Interface name or neighbor tag\n"
4432 "Enable BGP on interface\n"
4433 "Enable BGP with v6 link-local only\n"
4434 "Member of the peer-group\n"
4435 "Peer-group name\n")
4438 int idx_peer_group_word
= 5;
4440 if (argc
> idx_peer_group_word
)
4441 return peer_conf_interface_get(
4442 vty
, argv
[idx_word
]->arg
, 1,
4443 argv
[idx_peer_group_word
]->arg
, NULL
);
4445 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4449 DEFUN (neighbor_interface_config_remote_as
,
4450 neighbor_interface_config_remote_as_cmd
,
4451 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4453 "Interface name or neighbor tag\n"
4454 "Enable BGP on interface\n"
4455 "Specify a BGP neighbor\n"
4457 "Internal BGP peer\n"
4458 "External BGP peer\n")
4461 int idx_remote_as
= 4;
4462 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4463 argv
[idx_remote_as
]->arg
);
4466 DEFUN (neighbor_interface_v6only_config_remote_as
,
4467 neighbor_interface_v6only_config_remote_as_cmd
,
4468 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4470 "Interface name or neighbor tag\n"
4471 "Enable BGP with v6 link-local only\n"
4472 "Enable BGP on interface\n"
4473 "Specify a BGP neighbor\n"
4475 "Internal BGP peer\n"
4476 "External BGP peer\n")
4479 int idx_remote_as
= 5;
4480 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4481 argv
[idx_remote_as
]->arg
);
4484 DEFUN (neighbor_peer_group
,
4485 neighbor_peer_group_cmd
,
4486 "neighbor WORD peer-group",
4488 "Interface name or neighbor tag\n"
4489 "Configure peer-group\n")
4491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4494 struct peer_group
*group
;
4496 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4498 vty_out(vty
, "%% Name conflict with interface: \n");
4499 return CMD_WARNING_CONFIG_FAILED
;
4502 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4504 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4505 return CMD_WARNING_CONFIG_FAILED
;
4513 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4517 "Specify a BGP neighbor\n"
4519 "Internal BGP peer\n"
4520 "External BGP peer\n")
4522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4526 struct peer_group
*group
;
4530 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4532 /* look up for neighbor by interface name config. */
4533 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4535 /* Request zebra to terminate IPv6 RAs on this
4538 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4539 peer_notify_unconfig(peer
);
4544 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4546 peer_group_notify_unconfig(group
);
4547 peer_group_delete(group
);
4549 vty_out(vty
, "%% Create the peer-group first\n");
4550 return CMD_WARNING_CONFIG_FAILED
;
4553 peer
= peer_lookup(bgp
, &su
);
4555 if (peer_dynamic_neighbor(peer
)) {
4557 "%% Operation not allowed on a dynamic neighbor\n");
4558 return CMD_WARNING_CONFIG_FAILED
;
4561 other
= peer
->doppelganger
;
4563 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4564 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4566 peer_notify_unconfig(peer
);
4568 if (other
&& other
->status
!= Deleted
) {
4569 peer_notify_unconfig(other
);
4578 DEFUN (no_neighbor_interface_config
,
4579 no_neighbor_interface_config_cmd
,
4580 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4584 "Configure BGP on interface\n"
4585 "Enable BGP with v6 link-local only\n"
4586 "Member of the peer-group\n"
4588 "Specify a BGP neighbor\n"
4590 "Internal BGP peer\n"
4591 "External BGP peer\n")
4593 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4597 /* look up for neighbor by interface name config. */
4598 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4600 /* Request zebra to terminate IPv6 RAs on this interface. */
4602 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4603 peer_notify_unconfig(peer
);
4606 vty_out(vty
, "%% Create the bgp interface first\n");
4607 return CMD_WARNING_CONFIG_FAILED
;
4612 DEFUN (no_neighbor_peer_group
,
4613 no_neighbor_peer_group_cmd
,
4614 "no neighbor WORD peer-group",
4618 "Configure peer-group\n")
4620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4622 struct peer_group
*group
;
4624 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4626 peer_group_notify_unconfig(group
);
4627 peer_group_delete(group
);
4629 vty_out(vty
, "%% Create the peer-group first\n");
4630 return CMD_WARNING_CONFIG_FAILED
;
4635 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4636 no_neighbor_interface_peer_group_remote_as_cmd
,
4637 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4640 "Interface name or neighbor tag\n"
4641 "Specify a BGP neighbor\n"
4643 "Internal BGP peer\n"
4644 "External BGP peer\n")
4646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4648 struct peer_group
*group
;
4651 /* look up for neighbor by interface name config. */
4652 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4654 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4658 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4660 peer_group_remote_as_delete(group
);
4662 vty_out(vty
, "%% Create the peer-group or interface first\n");
4663 return CMD_WARNING_CONFIG_FAILED
;
4668 DEFUN (neighbor_local_as
,
4669 neighbor_local_as_cmd
,
4670 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4673 "Specify a local-as number\n"
4674 "AS number used as local AS\n")
4682 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4684 return CMD_WARNING_CONFIG_FAILED
;
4686 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4687 ret
= peer_local_as_set(peer
, as
, 0, 0);
4688 return bgp_vty_return(vty
, ret
);
4691 DEFUN (neighbor_local_as_no_prepend
,
4692 neighbor_local_as_no_prepend_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4696 "Specify a local-as number\n"
4697 "AS number used as local AS\n"
4698 "Do not prepend local-as to updates from ebgp peers\n")
4706 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4708 return CMD_WARNING_CONFIG_FAILED
;
4710 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4711 ret
= peer_local_as_set(peer
, as
, 1, 0);
4712 return bgp_vty_return(vty
, ret
);
4715 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4716 neighbor_local_as_no_prepend_replace_as_cmd
,
4717 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4720 "Specify a local-as number\n"
4721 "AS number used as local AS\n"
4722 "Do not prepend local-as to updates from ebgp peers\n"
4723 "Do not prepend local-as to updates from ibgp peers\n")
4731 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4733 return CMD_WARNING_CONFIG_FAILED
;
4735 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4736 ret
= peer_local_as_set(peer
, as
, 1, 1);
4737 return bgp_vty_return(vty
, ret
);
4740 DEFUN (no_neighbor_local_as
,
4741 no_neighbor_local_as_cmd
,
4742 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4746 "Specify a local-as number\n"
4747 "AS number used as local AS\n"
4748 "Do not prepend local-as to updates from ebgp peers\n"
4749 "Do not prepend local-as to updates from ibgp peers\n")
4755 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4757 return CMD_WARNING_CONFIG_FAILED
;
4759 ret
= peer_local_as_unset(peer
);
4760 return bgp_vty_return(vty
, ret
);
4764 DEFUN (neighbor_solo
,
4766 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4769 "Solo peer - part of its own update group\n")
4775 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4777 return CMD_WARNING_CONFIG_FAILED
;
4779 ret
= update_group_adjust_soloness(peer
, 1);
4780 return bgp_vty_return(vty
, ret
);
4783 DEFUN (no_neighbor_solo
,
4784 no_neighbor_solo_cmd
,
4785 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4789 "Solo peer - part of its own update group\n")
4795 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4797 return CMD_WARNING_CONFIG_FAILED
;
4799 ret
= update_group_adjust_soloness(peer
, 0);
4800 return bgp_vty_return(vty
, ret
);
4803 DEFUN (neighbor_password
,
4804 neighbor_password_cmd
,
4805 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4816 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4818 return CMD_WARNING_CONFIG_FAILED
;
4820 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4821 return bgp_vty_return(vty
, ret
);
4824 DEFUN (no_neighbor_password
,
4825 no_neighbor_password_cmd
,
4826 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4837 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4839 return CMD_WARNING_CONFIG_FAILED
;
4841 ret
= peer_password_unset(peer
);
4842 return bgp_vty_return(vty
, ret
);
4845 DEFUN (neighbor_activate
,
4846 neighbor_activate_cmd
,
4847 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4850 "Enable the Address Family for this Neighbor\n")
4856 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4858 return CMD_WARNING_CONFIG_FAILED
;
4860 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4861 return bgp_vty_return(vty
, ret
);
4864 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4865 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4866 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4867 "Enable the Address Family for this Neighbor\n")
4869 DEFUN (no_neighbor_activate
,
4870 no_neighbor_activate_cmd
,
4871 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4875 "Enable the Address Family for this Neighbor\n")
4882 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4884 return CMD_WARNING_CONFIG_FAILED
;
4886 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4887 return bgp_vty_return(vty
, ret
);
4890 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4891 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4892 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4893 "Enable the Address Family for this Neighbor\n")
4895 DEFUN (neighbor_set_peer_group
,
4896 neighbor_set_peer_group_cmd
,
4897 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4900 "Member of the peer-group\n"
4901 "Peer-group name\n")
4903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4910 struct peer_group
*group
;
4912 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4914 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4916 vty_out(vty
, "%% Malformed address or name: %s\n",
4917 argv
[idx_peer
]->arg
);
4918 return CMD_WARNING_CONFIG_FAILED
;
4921 if (peer_address_self_check(bgp
, &su
)) {
4923 "%% Can not configure the local system as neighbor\n");
4924 return CMD_WARNING_CONFIG_FAILED
;
4927 /* Disallow for dynamic neighbor. */
4928 peer
= peer_lookup(bgp
, &su
);
4929 if (peer
&& peer_dynamic_neighbor(peer
)) {
4931 "%% Operation not allowed on a dynamic neighbor\n");
4932 return CMD_WARNING_CONFIG_FAILED
;
4936 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4938 vty_out(vty
, "%% Configure the peer-group first\n");
4939 return CMD_WARNING_CONFIG_FAILED
;
4942 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4944 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4946 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4948 return CMD_WARNING_CONFIG_FAILED
;
4951 return bgp_vty_return(vty
, ret
);
4954 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4955 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4956 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4957 "Member of the peer-group\n"
4958 "Peer-group name\n")
4960 DEFUN (no_neighbor_set_peer_group
,
4961 no_neighbor_set_peer_group_cmd
,
4962 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4966 "Member of the peer-group\n"
4967 "Peer-group name\n")
4969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4974 struct peer_group
*group
;
4976 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4978 return CMD_WARNING_CONFIG_FAILED
;
4980 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4982 vty_out(vty
, "%% Configure the peer-group first\n");
4983 return CMD_WARNING_CONFIG_FAILED
;
4986 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4987 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4989 peer_notify_unconfig(peer
);
4990 ret
= peer_delete(peer
);
4992 return bgp_vty_return(vty
, ret
);
4995 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4996 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4997 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4998 "Member of the peer-group\n"
4999 "Peer-group name\n")
5001 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5002 uint32_t flag
, int set
)
5007 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5009 return CMD_WARNING_CONFIG_FAILED
;
5012 * If 'neighbor <interface>', then this is for directly connected peers,
5013 * we should not accept disable-connected-check.
5015 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5017 "%s is directly connected peer, cannot accept disable-connected-check\n",
5019 return CMD_WARNING_CONFIG_FAILED
;
5022 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5023 peer_tx_shutdown_message_unset(peer
);
5026 ret
= peer_flag_set(peer
, flag
);
5028 ret
= peer_flag_unset(peer
, flag
);
5030 return bgp_vty_return(vty
, ret
);
5033 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5035 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5038 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5041 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5044 /* neighbor passive. */
5045 DEFUN (neighbor_passive
,
5046 neighbor_passive_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5050 "Don't send open messages to this neighbor\n")
5053 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5056 DEFUN (no_neighbor_passive
,
5057 no_neighbor_passive_cmd
,
5058 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5062 "Don't send open messages to this neighbor\n")
5065 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5068 /* neighbor shutdown. */
5069 DEFUN (neighbor_shutdown_msg
,
5070 neighbor_shutdown_msg_cmd
,
5071 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5074 "Administratively shut down this neighbor\n"
5075 "Add a shutdown message (RFC 8203)\n"
5076 "Shutdown message\n")
5082 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5086 return CMD_WARNING_CONFIG_FAILED
;
5087 message
= argv_concat(argv
, argc
, 4);
5088 peer_tx_shutdown_message_set(peer
, message
);
5089 XFREE(MTYPE_TMP
, message
);
5092 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5095 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5096 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5097 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5098 "Administratively shut down this neighbor\n")
5100 DEFUN (no_neighbor_shutdown_msg
,
5101 no_neighbor_shutdown_msg_cmd
,
5102 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5106 "Administratively shut down this neighbor\n"
5107 "Remove a shutdown message (RFC 8203)\n"
5108 "Shutdown message\n")
5112 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5113 PEER_FLAG_SHUTDOWN
);
5116 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5117 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5118 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5119 "Administratively shut down this neighbor\n")
5121 DEFUN(neighbor_shutdown_rtt
,
5122 neighbor_shutdown_rtt_cmd
,
5123 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5126 "Administratively shut down this neighbor\n"
5127 "Shutdown if round-trip-time is higher than expected\n"
5128 "Round-trip-time in milliseconds\n"
5129 "Specify the number of keepalives before shutdown\n"
5130 "The number of keepalives with higher RTT to shutdown\n")
5137 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5140 return CMD_WARNING_CONFIG_FAILED
;
5142 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5144 if (argv_find(argv
, argc
, "count", &idx_count
))
5145 peer
->rtt_keepalive_conf
=
5146 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5148 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5149 PEER_FLAG_RTT_SHUTDOWN
);
5152 DEFUN(no_neighbor_shutdown_rtt
,
5153 no_neighbor_shutdown_rtt_cmd
,
5154 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5158 "Administratively shut down this neighbor\n"
5159 "Shutdown if round-trip-time is higher than expected\n"
5160 "Round-trip-time in milliseconds\n"
5161 "Specify the number of keepalives before shutdown\n"
5162 "The number of keepalives with higher RTT to shutdown\n")
5167 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5170 return CMD_WARNING_CONFIG_FAILED
;
5172 peer
->rtt_expected
= 0;
5173 peer
->rtt_keepalive_conf
= 1;
5175 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5176 PEER_FLAG_RTT_SHUTDOWN
);
5179 /* neighbor capability dynamic. */
5180 DEFUN (neighbor_capability_dynamic
,
5181 neighbor_capability_dynamic_cmd
,
5182 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5185 "Advertise capability to the peer\n"
5186 "Advertise dynamic capability to this neighbor\n")
5189 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5190 PEER_FLAG_DYNAMIC_CAPABILITY
);
5193 DEFUN (no_neighbor_capability_dynamic
,
5194 no_neighbor_capability_dynamic_cmd
,
5195 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5199 "Advertise capability to the peer\n"
5200 "Advertise dynamic capability to this neighbor\n")
5203 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5204 PEER_FLAG_DYNAMIC_CAPABILITY
);
5207 /* neighbor dont-capability-negotiate */
5208 DEFUN (neighbor_dont_capability_negotiate
,
5209 neighbor_dont_capability_negotiate_cmd
,
5210 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5213 "Do not perform capability negotiation\n")
5216 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5217 PEER_FLAG_DONT_CAPABILITY
);
5220 DEFUN (no_neighbor_dont_capability_negotiate
,
5221 no_neighbor_dont_capability_negotiate_cmd
,
5222 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5226 "Do not perform capability negotiation\n")
5229 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5230 PEER_FLAG_DONT_CAPABILITY
);
5233 /* neighbor capability extended next hop encoding */
5234 DEFUN (neighbor_capability_enhe
,
5235 neighbor_capability_enhe_cmd
,
5236 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5239 "Advertise capability to the peer\n"
5240 "Advertise extended next-hop capability to the peer\n")
5243 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5244 PEER_FLAG_CAPABILITY_ENHE
);
5247 DEFUN (no_neighbor_capability_enhe
,
5248 no_neighbor_capability_enhe_cmd
,
5249 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5253 "Advertise capability to the peer\n"
5254 "Advertise extended next-hop capability to the peer\n")
5257 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5258 PEER_FLAG_CAPABILITY_ENHE
);
5261 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5262 afi_t afi
, safi_t safi
, uint32_t flag
,
5268 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5270 return CMD_WARNING_CONFIG_FAILED
;
5273 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5275 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5277 return bgp_vty_return(vty
, ret
);
5280 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5281 afi_t afi
, safi_t safi
, uint32_t flag
)
5283 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5286 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5287 afi_t afi
, safi_t safi
, uint32_t flag
)
5289 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5292 /* neighbor capability orf prefix-list. */
5293 DEFUN (neighbor_capability_orf_prefix
,
5294 neighbor_capability_orf_prefix_cmd
,
5295 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5298 "Advertise capability to the peer\n"
5299 "Advertise ORF capability to the peer\n"
5300 "Advertise prefixlist ORF capability to this neighbor\n"
5301 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5302 "Capability to RECEIVE the ORF from this neighbor\n"
5303 "Capability to SEND the ORF to this neighbor\n")
5305 int idx_send_recv
= 5;
5306 char *peer_str
= argv
[1]->arg
;
5308 afi_t afi
= bgp_node_afi(vty
);
5309 safi_t safi
= bgp_node_safi(vty
);
5311 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5313 return CMD_WARNING_CONFIG_FAILED
;
5315 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5316 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5317 PEER_FLAG_ORF_PREFIX_SM
);
5319 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5320 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5321 PEER_FLAG_ORF_PREFIX_RM
);
5323 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5324 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5325 PEER_FLAG_ORF_PREFIX_SM
)
5326 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5327 PEER_FLAG_ORF_PREFIX_RM
);
5329 return CMD_WARNING_CONFIG_FAILED
;
5333 neighbor_capability_orf_prefix
,
5334 neighbor_capability_orf_prefix_hidden_cmd
,
5335 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5336 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5337 "Advertise capability to the peer\n"
5338 "Advertise ORF capability to the peer\n"
5339 "Advertise prefixlist ORF capability to this neighbor\n"
5340 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5341 "Capability to RECEIVE the ORF from this neighbor\n"
5342 "Capability to SEND the ORF to this neighbor\n")
5344 DEFUN (no_neighbor_capability_orf_prefix
,
5345 no_neighbor_capability_orf_prefix_cmd
,
5346 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5350 "Advertise capability to the peer\n"
5351 "Advertise ORF capability to the peer\n"
5352 "Advertise prefixlist ORF capability to this neighbor\n"
5353 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5354 "Capability to RECEIVE the ORF from this neighbor\n"
5355 "Capability to SEND the ORF to this neighbor\n")
5357 int idx_send_recv
= 6;
5358 char *peer_str
= argv
[2]->arg
;
5360 afi_t afi
= bgp_node_afi(vty
);
5361 safi_t safi
= bgp_node_safi(vty
);
5363 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5365 return CMD_WARNING_CONFIG_FAILED
;
5367 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5368 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5369 PEER_FLAG_ORF_PREFIX_SM
);
5371 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5372 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5373 PEER_FLAG_ORF_PREFIX_RM
);
5375 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5376 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5377 PEER_FLAG_ORF_PREFIX_SM
)
5378 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5379 PEER_FLAG_ORF_PREFIX_RM
);
5381 return CMD_WARNING_CONFIG_FAILED
;
5385 no_neighbor_capability_orf_prefix
,
5386 no_neighbor_capability_orf_prefix_hidden_cmd
,
5387 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5388 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5389 "Advertise capability to the peer\n"
5390 "Advertise ORF capability to the peer\n"
5391 "Advertise prefixlist ORF capability to this neighbor\n"
5392 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5393 "Capability to RECEIVE the ORF from this neighbor\n"
5394 "Capability to SEND the ORF to this neighbor\n")
5396 /* neighbor next-hop-self. */
5397 DEFUN (neighbor_nexthop_self
,
5398 neighbor_nexthop_self_cmd
,
5399 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5402 "Disable the next hop calculation for this neighbor\n")
5405 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5406 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5409 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5410 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5411 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5412 "Disable the next hop calculation for this neighbor\n")
5414 /* neighbor next-hop-self. */
5415 DEFUN (neighbor_nexthop_self_force
,
5416 neighbor_nexthop_self_force_cmd
,
5417 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5420 "Disable the next hop calculation for this neighbor\n"
5421 "Set the next hop to self for reflected routes\n")
5424 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5426 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5429 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5430 neighbor_nexthop_self_force_hidden_cmd
,
5431 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5432 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5433 "Disable the next hop calculation for this neighbor\n"
5434 "Set the next hop to self for reflected routes\n")
5436 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5437 neighbor_nexthop_self_all_hidden_cmd
,
5438 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5439 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5440 "Disable the next hop calculation for this neighbor\n"
5441 "Set the next hop to self for reflected routes\n")
5443 DEFUN (no_neighbor_nexthop_self
,
5444 no_neighbor_nexthop_self_cmd
,
5445 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5449 "Disable the next hop calculation for this neighbor\n")
5452 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5453 bgp_node_afi(vty
), bgp_node_safi(vty
),
5454 PEER_FLAG_NEXTHOP_SELF
);
5457 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5458 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5459 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5460 "Disable the next hop calculation for this neighbor\n")
5462 DEFUN (no_neighbor_nexthop_self_force
,
5463 no_neighbor_nexthop_self_force_cmd
,
5464 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5468 "Disable the next hop calculation for this neighbor\n"
5469 "Set the next hop to self for reflected routes\n")
5472 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5473 bgp_node_afi(vty
), bgp_node_safi(vty
),
5474 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5477 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5478 no_neighbor_nexthop_self_force_hidden_cmd
,
5479 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5480 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5481 "Disable the next hop calculation for this neighbor\n"
5482 "Set the next hop to self for reflected routes\n")
5484 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5485 no_neighbor_nexthop_self_all_hidden_cmd
,
5486 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5487 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5488 "Disable the next hop calculation for this neighbor\n"
5489 "Set the next hop to self for reflected routes\n")
5491 /* neighbor as-override */
5492 DEFUN (neighbor_as_override
,
5493 neighbor_as_override_cmd
,
5494 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5497 "Override ASNs in outbound updates if aspath equals remote-as\n")
5500 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5501 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5504 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5505 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5506 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5507 "Override ASNs in outbound updates if aspath equals remote-as\n")
5509 DEFUN (no_neighbor_as_override
,
5510 no_neighbor_as_override_cmd
,
5511 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5515 "Override ASNs in outbound updates if aspath equals remote-as\n")
5518 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5519 bgp_node_afi(vty
), bgp_node_safi(vty
),
5520 PEER_FLAG_AS_OVERRIDE
);
5523 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5524 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5525 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5526 "Override ASNs in outbound updates if aspath equals remote-as\n")
5528 /* neighbor remove-private-AS. */
5529 DEFUN (neighbor_remove_private_as
,
5530 neighbor_remove_private_as_cmd
,
5531 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5534 "Remove private ASNs in outbound updates\n")
5537 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5539 PEER_FLAG_REMOVE_PRIVATE_AS
);
5542 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5543 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5544 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5545 "Remove private ASNs in outbound updates\n")
5547 DEFUN (neighbor_remove_private_as_all
,
5548 neighbor_remove_private_as_all_cmd
,
5549 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5552 "Remove private ASNs in outbound updates\n"
5553 "Apply to all AS numbers\n")
5556 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5558 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5561 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5562 neighbor_remove_private_as_all_hidden_cmd
,
5563 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5564 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5565 "Remove private ASNs in outbound updates\n"
5566 "Apply to all AS numbers")
5568 DEFUN (neighbor_remove_private_as_replace_as
,
5569 neighbor_remove_private_as_replace_as_cmd
,
5570 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5573 "Remove private ASNs in outbound updates\n"
5574 "Replace private ASNs with our ASN in outbound updates\n")
5577 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5579 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5582 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5583 neighbor_remove_private_as_replace_as_hidden_cmd
,
5584 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5585 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5586 "Remove private ASNs in outbound updates\n"
5587 "Replace private ASNs with our ASN in outbound updates\n")
5589 DEFUN (neighbor_remove_private_as_all_replace_as
,
5590 neighbor_remove_private_as_all_replace_as_cmd
,
5591 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5594 "Remove private ASNs in outbound updates\n"
5595 "Apply to all AS numbers\n"
5596 "Replace private ASNs with our ASN in outbound updates\n")
5599 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5601 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5605 neighbor_remove_private_as_all_replace_as
,
5606 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5607 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5608 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5609 "Remove private ASNs in outbound updates\n"
5610 "Apply to all AS numbers\n"
5611 "Replace private ASNs with our ASN in outbound updates\n")
5613 DEFUN (no_neighbor_remove_private_as
,
5614 no_neighbor_remove_private_as_cmd
,
5615 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5619 "Remove private ASNs in outbound updates\n")
5622 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5623 bgp_node_afi(vty
), bgp_node_safi(vty
),
5624 PEER_FLAG_REMOVE_PRIVATE_AS
);
5627 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5628 no_neighbor_remove_private_as_hidden_cmd
,
5629 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5630 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Remove private ASNs in outbound updates\n")
5633 DEFUN (no_neighbor_remove_private_as_all
,
5634 no_neighbor_remove_private_as_all_cmd
,
5635 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5639 "Remove private ASNs in outbound updates\n"
5640 "Apply to all AS numbers\n")
5643 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5644 bgp_node_afi(vty
), bgp_node_safi(vty
),
5645 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5648 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5649 no_neighbor_remove_private_as_all_hidden_cmd
,
5650 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5651 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5652 "Remove private ASNs in outbound updates\n"
5653 "Apply to all AS numbers\n")
5655 DEFUN (no_neighbor_remove_private_as_replace_as
,
5656 no_neighbor_remove_private_as_replace_as_cmd
,
5657 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5661 "Remove private ASNs in outbound updates\n"
5662 "Replace private ASNs with our ASN in outbound updates\n")
5665 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5666 bgp_node_afi(vty
), bgp_node_safi(vty
),
5667 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5670 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5671 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5672 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5673 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5674 "Remove private ASNs in outbound updates\n"
5675 "Replace private ASNs with our ASN in outbound updates\n")
5677 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5678 no_neighbor_remove_private_as_all_replace_as_cmd
,
5679 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5683 "Remove private ASNs in outbound updates\n"
5684 "Apply to all AS numbers\n"
5685 "Replace private ASNs with our ASN in outbound updates\n")
5688 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5689 bgp_node_afi(vty
), bgp_node_safi(vty
),
5690 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5694 no_neighbor_remove_private_as_all_replace_as
,
5695 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5696 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5697 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5698 "Remove private ASNs in outbound updates\n"
5699 "Apply to all AS numbers\n"
5700 "Replace private ASNs with our ASN in outbound updates\n")
5703 /* neighbor send-community. */
5704 DEFUN (neighbor_send_community
,
5705 neighbor_send_community_cmd
,
5706 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5709 "Send Community attribute to this neighbor\n")
5713 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5715 PEER_FLAG_SEND_COMMUNITY
);
5718 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5719 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5720 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5721 "Send Community attribute to this neighbor\n")
5723 DEFUN (no_neighbor_send_community
,
5724 no_neighbor_send_community_cmd
,
5725 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5729 "Send Community attribute to this neighbor\n")
5733 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5734 bgp_node_afi(vty
), bgp_node_safi(vty
),
5735 PEER_FLAG_SEND_COMMUNITY
);
5738 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5741 "Send Community attribute to this neighbor\n")
5743 /* neighbor send-community extended. */
5744 DEFUN (neighbor_send_community_type
,
5745 neighbor_send_community_type_cmd
,
5746 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5749 "Send Community attribute to this neighbor\n"
5750 "Send Standard and Extended Community attributes\n"
5751 "Send Standard, Large and Extended Community attributes\n"
5752 "Send Extended Community attributes\n"
5753 "Send Standard Community attributes\n"
5754 "Send Large Community attributes\n")
5756 const char *type
= argv
[argc
- 1]->text
;
5757 char *peer_str
= argv
[1]->arg
;
5759 afi_t afi
= bgp_node_afi(vty
);
5760 safi_t safi
= bgp_node_safi(vty
);
5762 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5764 return CMD_WARNING_CONFIG_FAILED
;
5766 if (strmatch(type
, "standard"))
5767 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5768 PEER_FLAG_SEND_COMMUNITY
);
5770 if (strmatch(type
, "extended"))
5771 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5772 PEER_FLAG_SEND_EXT_COMMUNITY
);
5774 if (strmatch(type
, "large"))
5775 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5776 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5778 if (strmatch(type
, "both")) {
5779 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5780 PEER_FLAG_SEND_COMMUNITY
)
5781 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5782 PEER_FLAG_SEND_EXT_COMMUNITY
);
5784 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5785 PEER_FLAG_SEND_COMMUNITY
)
5786 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5787 PEER_FLAG_SEND_EXT_COMMUNITY
)
5788 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5789 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5793 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5795 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5796 "Send Community attribute to this neighbor\n"
5797 "Send Standard and Extended Community attributes\n"
5798 "Send Standard, Large and Extended Community attributes\n"
5799 "Send Extended Community attributes\n"
5800 "Send Standard Community attributes\n"
5801 "Send Large Community attributes\n")
5803 DEFUN (no_neighbor_send_community_type
,
5804 no_neighbor_send_community_type_cmd
,
5805 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5809 "Send Community attribute to this neighbor\n"
5810 "Send Standard and Extended Community attributes\n"
5811 "Send Standard, Large and Extended Community attributes\n"
5812 "Send Extended Community attributes\n"
5813 "Send Standard Community attributes\n"
5814 "Send Large Community attributes\n")
5816 const char *type
= argv
[argc
- 1]->text
;
5817 char *peer_str
= argv
[2]->arg
;
5819 afi_t afi
= bgp_node_afi(vty
);
5820 safi_t safi
= bgp_node_safi(vty
);
5822 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5824 return CMD_WARNING_CONFIG_FAILED
;
5826 if (strmatch(type
, "standard"))
5827 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5828 PEER_FLAG_SEND_COMMUNITY
);
5830 if (strmatch(type
, "extended"))
5831 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5832 PEER_FLAG_SEND_EXT_COMMUNITY
);
5834 if (strmatch(type
, "large"))
5835 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5836 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5838 if (strmatch(type
, "both")) {
5840 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5841 PEER_FLAG_SEND_COMMUNITY
)
5842 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5843 PEER_FLAG_SEND_EXT_COMMUNITY
);
5846 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5847 PEER_FLAG_SEND_COMMUNITY
)
5848 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5849 PEER_FLAG_SEND_EXT_COMMUNITY
)
5850 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5851 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5855 no_neighbor_send_community_type
,
5856 no_neighbor_send_community_type_hidden_cmd
,
5857 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5858 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5859 "Send Community attribute to this neighbor\n"
5860 "Send Standard and Extended Community attributes\n"
5861 "Send Standard, Large and Extended Community attributes\n"
5862 "Send Extended Community attributes\n"
5863 "Send Standard Community attributes\n"
5864 "Send Large Community attributes\n")
5866 /* neighbor soft-reconfig. */
5867 DEFUN (neighbor_soft_reconfiguration
,
5868 neighbor_soft_reconfiguration_cmd
,
5869 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5872 "Per neighbor soft reconfiguration\n"
5873 "Allow inbound soft reconfiguration for this neighbor\n")
5876 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5878 PEER_FLAG_SOFT_RECONFIG
);
5881 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
5882 neighbor_soft_reconfiguration_hidden_cmd
,
5883 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5884 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5885 "Per neighbor soft reconfiguration\n"
5886 "Allow inbound soft reconfiguration for this neighbor\n")
5888 DEFUN (no_neighbor_soft_reconfiguration
,
5889 no_neighbor_soft_reconfiguration_cmd
,
5890 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5894 "Per neighbor soft reconfiguration\n"
5895 "Allow inbound soft reconfiguration for this neighbor\n")
5898 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5899 bgp_node_afi(vty
), bgp_node_safi(vty
),
5900 PEER_FLAG_SOFT_RECONFIG
);
5903 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5904 no_neighbor_soft_reconfiguration_hidden_cmd
,
5905 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5906 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5907 "Per neighbor soft reconfiguration\n"
5908 "Allow inbound soft reconfiguration for this neighbor\n")
5910 DEFUN (neighbor_route_reflector_client
,
5911 neighbor_route_reflector_client_cmd
,
5912 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5915 "Configure a neighbor as Route Reflector client\n")
5921 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5923 return CMD_WARNING_CONFIG_FAILED
;
5925 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5927 PEER_FLAG_REFLECTOR_CLIENT
);
5930 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5931 neighbor_route_reflector_client_hidden_cmd
,
5932 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5933 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5934 "Configure a neighbor as Route Reflector client\n")
5936 DEFUN (no_neighbor_route_reflector_client
,
5937 no_neighbor_route_reflector_client_cmd
,
5938 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5942 "Configure a neighbor as Route Reflector client\n")
5945 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5946 bgp_node_afi(vty
), bgp_node_safi(vty
),
5947 PEER_FLAG_REFLECTOR_CLIENT
);
5950 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5951 no_neighbor_route_reflector_client_hidden_cmd
,
5952 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5953 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5954 "Configure a neighbor as Route Reflector client\n")
5956 /* neighbor route-server-client. */
5957 DEFUN (neighbor_route_server_client
,
5958 neighbor_route_server_client_cmd
,
5959 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5962 "Configure a neighbor as Route Server client\n")
5967 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5969 return CMD_WARNING_CONFIG_FAILED
;
5970 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5972 PEER_FLAG_RSERVER_CLIENT
);
5975 ALIAS_HIDDEN(neighbor_route_server_client
,
5976 neighbor_route_server_client_hidden_cmd
,
5977 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5978 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5979 "Configure a neighbor as Route Server client\n")
5981 DEFUN (no_neighbor_route_server_client
,
5982 no_neighbor_route_server_client_cmd
,
5983 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5987 "Configure a neighbor as Route Server client\n")
5990 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5991 bgp_node_afi(vty
), bgp_node_safi(vty
),
5992 PEER_FLAG_RSERVER_CLIENT
);
5995 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5996 no_neighbor_route_server_client_hidden_cmd
,
5997 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5998 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5999 "Configure a neighbor as Route Server client\n")
6001 DEFUN (neighbor_nexthop_local_unchanged
,
6002 neighbor_nexthop_local_unchanged_cmd
,
6003 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6006 "Configure treatment of outgoing link-local nexthop attribute\n"
6007 "Leave link-local nexthop unchanged for this peer\n")
6010 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6012 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6015 DEFUN (no_neighbor_nexthop_local_unchanged
,
6016 no_neighbor_nexthop_local_unchanged_cmd
,
6017 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6021 "Configure treatment of outgoing link-local-nexthop attribute\n"
6022 "Leave link-local nexthop unchanged for this peer\n")
6025 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6026 bgp_node_afi(vty
), bgp_node_safi(vty
),
6027 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6030 DEFUN (neighbor_attr_unchanged
,
6031 neighbor_attr_unchanged_cmd
,
6032 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6035 "BGP attribute is propagated unchanged to this neighbor\n"
6036 "As-path attribute\n"
6037 "Nexthop attribute\n"
6041 char *peer_str
= argv
[1]->arg
;
6043 bool aspath
= false;
6044 bool nexthop
= false;
6046 afi_t afi
= bgp_node_afi(vty
);
6047 safi_t safi
= bgp_node_safi(vty
);
6050 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6052 return CMD_WARNING_CONFIG_FAILED
;
6054 if (argv_find(argv
, argc
, "as-path", &idx
))
6058 if (argv_find(argv
, argc
, "next-hop", &idx
))
6062 if (argv_find(argv
, argc
, "med", &idx
))
6065 /* no flags means all of them! */
6066 if (!aspath
&& !nexthop
&& !med
) {
6067 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6068 PEER_FLAG_AS_PATH_UNCHANGED
);
6069 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6070 PEER_FLAG_NEXTHOP_UNCHANGED
);
6071 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6072 PEER_FLAG_MED_UNCHANGED
);
6075 if (peer_af_flag_check(peer
, afi
, safi
,
6076 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6077 ret
|= peer_af_flag_unset_vty(
6078 vty
, peer_str
, afi
, safi
,
6079 PEER_FLAG_AS_PATH_UNCHANGED
);
6082 ret
|= peer_af_flag_set_vty(
6083 vty
, peer_str
, afi
, safi
,
6084 PEER_FLAG_AS_PATH_UNCHANGED
);
6087 if (peer_af_flag_check(peer
, afi
, safi
,
6088 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6089 ret
|= peer_af_flag_unset_vty(
6090 vty
, peer_str
, afi
, safi
,
6091 PEER_FLAG_NEXTHOP_UNCHANGED
);
6094 ret
|= peer_af_flag_set_vty(
6095 vty
, peer_str
, afi
, safi
,
6096 PEER_FLAG_NEXTHOP_UNCHANGED
);
6099 if (peer_af_flag_check(peer
, afi
, safi
,
6100 PEER_FLAG_MED_UNCHANGED
)) {
6101 ret
|= peer_af_flag_unset_vty(
6102 vty
, peer_str
, afi
, safi
,
6103 PEER_FLAG_MED_UNCHANGED
);
6106 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6107 PEER_FLAG_MED_UNCHANGED
);
6114 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6115 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6116 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6117 "BGP attribute is propagated unchanged to this neighbor\n"
6118 "As-path attribute\n"
6119 "Nexthop attribute\n"
6122 DEFUN (no_neighbor_attr_unchanged
,
6123 no_neighbor_attr_unchanged_cmd
,
6124 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6128 "BGP attribute is propagated unchanged to this neighbor\n"
6129 "As-path attribute\n"
6130 "Nexthop attribute\n"
6134 char *peer_str
= argv
[2]->arg
;
6136 bool aspath
= false;
6137 bool nexthop
= false;
6139 afi_t afi
= bgp_node_afi(vty
);
6140 safi_t safi
= bgp_node_safi(vty
);
6143 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6145 return CMD_WARNING_CONFIG_FAILED
;
6147 if (argv_find(argv
, argc
, "as-path", &idx
))
6151 if (argv_find(argv
, argc
, "next-hop", &idx
))
6155 if (argv_find(argv
, argc
, "med", &idx
))
6158 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6159 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6160 PEER_FLAG_AS_PATH_UNCHANGED
)
6161 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6162 PEER_FLAG_NEXTHOP_UNCHANGED
)
6163 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6164 PEER_FLAG_MED_UNCHANGED
);
6167 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6168 PEER_FLAG_AS_PATH_UNCHANGED
);
6171 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6172 PEER_FLAG_NEXTHOP_UNCHANGED
);
6175 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6176 PEER_FLAG_MED_UNCHANGED
);
6182 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6185 "BGP attribute is propagated unchanged to this neighbor\n"
6186 "As-path attribute\n"
6187 "Nexthop attribute\n"
6190 /* EBGP multihop configuration. */
6191 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6192 const char *ttl_str
)
6197 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6199 return CMD_WARNING_CONFIG_FAILED
;
6202 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6207 ttl
= strtoul(ttl_str
, NULL
, 10);
6209 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6212 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6216 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6218 return CMD_WARNING_CONFIG_FAILED
;
6220 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6223 /* neighbor ebgp-multihop. */
6224 DEFUN (neighbor_ebgp_multihop
,
6225 neighbor_ebgp_multihop_cmd
,
6226 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6229 "Allow EBGP neighbors not on directly connected networks\n")
6232 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6235 DEFUN (neighbor_ebgp_multihop_ttl
,
6236 neighbor_ebgp_multihop_ttl_cmd
,
6237 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6240 "Allow EBGP neighbors not on directly connected networks\n"
6241 "maximum hop count\n")
6245 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6246 argv
[idx_number
]->arg
);
6249 DEFUN (no_neighbor_ebgp_multihop
,
6250 no_neighbor_ebgp_multihop_cmd
,
6251 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6255 "Allow EBGP neighbors not on directly connected networks\n"
6256 "maximum hop count\n")
6259 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6263 /* disable-connected-check */
6264 DEFUN (neighbor_disable_connected_check
,
6265 neighbor_disable_connected_check_cmd
,
6266 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6269 "one-hop away EBGP peer using loopback address\n"
6270 "Enforce EBGP neighbors perform multihop\n")
6273 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6274 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6277 DEFUN (no_neighbor_disable_connected_check
,
6278 no_neighbor_disable_connected_check_cmd
,
6279 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6283 "one-hop away EBGP peer using loopback address\n"
6284 "Enforce EBGP neighbors perform multihop\n")
6287 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6288 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6291 /* disable-link-bw-encoding-ieee */
6292 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6293 neighbor_disable_link_bw_encoding_ieee_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6295 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6296 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6300 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6301 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6304 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6305 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6306 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6312 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6313 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6316 /* extended-optional-parameters */
6317 DEFUN(neighbor_extended_optional_parameters
,
6318 neighbor_extended_optional_parameters_cmd
,
6319 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6320 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6321 "Force the extended optional parameters format for OPEN messages\n")
6325 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6326 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6329 DEFUN(no_neighbor_extended_optional_parameters
,
6330 no_neighbor_extended_optional_parameters_cmd
,
6331 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6332 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6333 "Force the extended optional parameters format for OPEN messages\n")
6337 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6338 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6341 /* enforce-first-as */
6342 DEFUN (neighbor_enforce_first_as
,
6343 neighbor_enforce_first_as_cmd
,
6344 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6347 "Enforce the first AS for EBGP routes\n")
6351 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6352 PEER_FLAG_ENFORCE_FIRST_AS
);
6355 DEFUN (no_neighbor_enforce_first_as
,
6356 no_neighbor_enforce_first_as_cmd
,
6357 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6361 "Enforce the first AS for EBGP routes\n")
6365 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6366 PEER_FLAG_ENFORCE_FIRST_AS
);
6370 DEFUN (neighbor_description
,
6371 neighbor_description_cmd
,
6372 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6375 "Neighbor specific description\n"
6376 "Up to 80 characters describing this neighbor\n")
6383 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6385 return CMD_WARNING_CONFIG_FAILED
;
6387 str
= argv_concat(argv
, argc
, idx_line
);
6389 peer_description_set(peer
, str
);
6391 XFREE(MTYPE_TMP
, str
);
6396 DEFUN (no_neighbor_description
,
6397 no_neighbor_description_cmd
,
6398 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6402 "Neighbor specific description\n")
6407 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6409 return CMD_WARNING_CONFIG_FAILED
;
6411 peer_description_unset(peer
);
6416 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6417 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6418 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6419 "Neighbor specific description\n"
6420 "Up to 80 characters describing this neighbor\n")
6422 /* Neighbor update-source. */
6423 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6424 const char *source_str
)
6430 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6432 return CMD_WARNING_CONFIG_FAILED
;
6438 if (str2sockunion(source_str
, &su
) == 0)
6439 peer_update_source_addr_set(peer
, &su
);
6441 if (str2prefix(source_str
, &p
)) {
6443 "%% Invalid update-source, remove prefix length \n");
6444 return CMD_WARNING_CONFIG_FAILED
;
6446 peer_update_source_if_set(peer
, source_str
);
6449 peer_update_source_unset(peer
);
6454 #define BGP_UPDATE_SOURCE_HELP_STR \
6457 "Interface name (requires zebra to be running)\n"
6459 DEFUN (neighbor_update_source
,
6460 neighbor_update_source_cmd
,
6461 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6464 "Source of routing updates\n"
6465 BGP_UPDATE_SOURCE_HELP_STR
)
6469 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6470 argv
[idx_peer_2
]->arg
);
6473 DEFUN (no_neighbor_update_source
,
6474 no_neighbor_update_source_cmd
,
6475 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6479 "Source of routing updates\n"
6480 BGP_UPDATE_SOURCE_HELP_STR
)
6483 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6486 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6487 afi_t afi
, safi_t safi
,
6488 const char *rmap
, int set
)
6492 struct route_map
*route_map
= NULL
;
6494 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6496 return CMD_WARNING_CONFIG_FAILED
;
6500 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6501 ret
= peer_default_originate_set(peer
, afi
, safi
,
6504 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6506 return bgp_vty_return(vty
, ret
);
6509 /* neighbor default-originate. */
6510 DEFUN (neighbor_default_originate
,
6511 neighbor_default_originate_cmd
,
6512 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6515 "Originate default route to this neighbor\n")
6518 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6520 bgp_node_safi(vty
), NULL
, 1);
6523 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6524 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6525 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6526 "Originate default route to this neighbor\n")
6528 DEFUN (neighbor_default_originate_rmap
,
6529 neighbor_default_originate_rmap_cmd
,
6530 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6533 "Originate default route to this neighbor\n"
6534 "Route-map to specify criteria to originate default\n"
6539 return peer_default_originate_set_vty(
6540 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6541 argv
[idx_word
]->arg
, 1);
6545 neighbor_default_originate_rmap
,
6546 neighbor_default_originate_rmap_hidden_cmd
,
6547 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6548 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6549 "Originate default route to this neighbor\n"
6550 "Route-map to specify criteria to originate default\n"
6553 DEFUN (no_neighbor_default_originate
,
6554 no_neighbor_default_originate_cmd
,
6555 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6559 "Originate default route to this neighbor\n"
6560 "Route-map to specify criteria to originate default\n"
6564 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6566 bgp_node_safi(vty
), NULL
, 0);
6570 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6571 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6572 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6573 "Originate default route to this neighbor\n"
6574 "Route-map to specify criteria to originate default\n"
6578 /* Set neighbor's BGP port. */
6579 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6580 const char *port_str
)
6586 peer
= peer_lookup_vty(vty
, ip_str
);
6588 return CMD_WARNING_CONFIG_FAILED
;
6591 sp
= getservbyname("bgp", "tcp");
6592 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6594 port
= strtoul(port_str
, NULL
, 10);
6597 peer_port_set(peer
, port
);
6602 /* Set specified peer's BGP port. */
6603 DEFUN (neighbor_port
,
6605 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6608 "Neighbor's BGP port\n"
6609 "TCP port number\n")
6613 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6614 argv
[idx_number
]->arg
);
6617 DEFUN (no_neighbor_port
,
6618 no_neighbor_port_cmd
,
6619 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6623 "Neighbor's BGP port\n"
6624 "TCP port number\n")
6627 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6631 /* neighbor weight. */
6632 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6633 safi_t safi
, const char *weight_str
)
6637 unsigned long weight
;
6639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6641 return CMD_WARNING_CONFIG_FAILED
;
6643 weight
= strtoul(weight_str
, NULL
, 10);
6645 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6646 return bgp_vty_return(vty
, ret
);
6649 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6657 return CMD_WARNING_CONFIG_FAILED
;
6659 ret
= peer_weight_unset(peer
, afi
, safi
);
6660 return bgp_vty_return(vty
, ret
);
6663 DEFUN (neighbor_weight
,
6664 neighbor_weight_cmd
,
6665 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6668 "Set default weight for routes from this neighbor\n"
6673 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6674 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6677 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6678 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6679 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6680 "Set default weight for routes from this neighbor\n"
6683 DEFUN (no_neighbor_weight
,
6684 no_neighbor_weight_cmd
,
6685 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6689 "Set default weight for routes from this neighbor\n"
6693 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6694 bgp_node_afi(vty
), bgp_node_safi(vty
));
6697 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6698 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6699 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6700 "Set default weight for routes from this neighbor\n"
6704 /* Override capability negotiation. */
6705 DEFUN (neighbor_override_capability
,
6706 neighbor_override_capability_cmd
,
6707 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6710 "Override capability negotiation result\n")
6713 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6714 PEER_FLAG_OVERRIDE_CAPABILITY
);
6717 DEFUN (no_neighbor_override_capability
,
6718 no_neighbor_override_capability_cmd
,
6719 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6723 "Override capability negotiation result\n")
6726 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6727 PEER_FLAG_OVERRIDE_CAPABILITY
);
6730 DEFUN (neighbor_strict_capability
,
6731 neighbor_strict_capability_cmd
,
6732 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6735 "Strict capability negotiation match\n")
6739 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6740 PEER_FLAG_STRICT_CAP_MATCH
);
6743 DEFUN (no_neighbor_strict_capability
,
6744 no_neighbor_strict_capability_cmd
,
6745 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6749 "Strict capability negotiation match\n")
6753 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6754 PEER_FLAG_STRICT_CAP_MATCH
);
6757 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6758 const char *keep_str
, const char *hold_str
)
6765 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6767 return CMD_WARNING_CONFIG_FAILED
;
6769 keepalive
= strtoul(keep_str
, NULL
, 10);
6770 holdtime
= strtoul(hold_str
, NULL
, 10);
6772 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6774 return bgp_vty_return(vty
, ret
);
6777 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6782 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6784 return CMD_WARNING_CONFIG_FAILED
;
6786 ret
= peer_timers_unset(peer
);
6788 return bgp_vty_return(vty
, ret
);
6791 DEFUN (neighbor_timers
,
6792 neighbor_timers_cmd
,
6793 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6796 "BGP per neighbor timers\n"
6797 "Keepalive interval\n"
6802 int idx_number_2
= 4;
6803 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6804 argv
[idx_number
]->arg
,
6805 argv
[idx_number_2
]->arg
);
6808 DEFUN (no_neighbor_timers
,
6809 no_neighbor_timers_cmd
,
6810 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6814 "BGP per neighbor timers\n"
6815 "Keepalive interval\n"
6819 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6823 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6824 const char *time_str
)
6830 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6832 return CMD_WARNING_CONFIG_FAILED
;
6834 connect
= strtoul(time_str
, NULL
, 10);
6836 ret
= peer_timers_connect_set(peer
, connect
);
6838 return bgp_vty_return(vty
, ret
);
6841 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6846 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6848 return CMD_WARNING_CONFIG_FAILED
;
6850 ret
= peer_timers_connect_unset(peer
);
6852 return bgp_vty_return(vty
, ret
);
6855 DEFUN (neighbor_timers_connect
,
6856 neighbor_timers_connect_cmd
,
6857 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6860 "BGP per neighbor timers\n"
6861 "BGP connect timer\n"
6866 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6867 argv
[idx_number
]->arg
);
6870 DEFUN (no_neighbor_timers_connect
,
6871 no_neighbor_timers_connect_cmd
,
6872 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6876 "BGP per neighbor timers\n"
6877 "BGP connect timer\n"
6881 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
6884 DEFPY (neighbor_timers_delayopen
,
6885 neighbor_timers_delayopen_cmd
,
6886 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
6889 "BGP per neighbor timers\n"
6890 "RFC 4271 DelayOpenTimer\n"
6891 "DelayOpenTime timer interval\n")
6895 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6897 return CMD_WARNING_CONFIG_FAILED
;
6900 if (peer_timers_delayopen_unset(peer
))
6901 return CMD_WARNING_CONFIG_FAILED
;
6903 if (peer_timers_delayopen_set(peer
, interval
))
6904 return CMD_WARNING_CONFIG_FAILED
;
6910 DEFPY (no_neighbor_timers_delayopen
,
6911 no_neighbor_timers_delayopen_cmd
,
6912 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
6916 "BGP per neighbor timers\n"
6917 "RFC 4271 DelayOpenTimer\n"
6918 "DelayOpenTime timer interval\n")
6922 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6924 return CMD_WARNING_CONFIG_FAILED
;
6926 if (peer_timers_delayopen_unset(peer
))
6927 return CMD_WARNING_CONFIG_FAILED
;
6932 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
6933 const char *time_str
, int set
)
6937 uint32_t routeadv
= 0;
6939 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6941 return CMD_WARNING_CONFIG_FAILED
;
6944 routeadv
= strtoul(time_str
, NULL
, 10);
6947 ret
= peer_advertise_interval_set(peer
, routeadv
);
6949 ret
= peer_advertise_interval_unset(peer
);
6951 return bgp_vty_return(vty
, ret
);
6954 DEFUN (neighbor_advertise_interval
,
6955 neighbor_advertise_interval_cmd
,
6956 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
6959 "Minimum interval between sending BGP routing updates\n"
6960 "time in seconds\n")
6964 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
6965 argv
[idx_number
]->arg
, 1);
6968 DEFUN (no_neighbor_advertise_interval
,
6969 no_neighbor_advertise_interval_cmd
,
6970 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
6974 "Minimum interval between sending BGP routing updates\n"
6975 "time in seconds\n")
6978 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
6982 /* Time to wait before processing route-map updates */
6983 DEFUN (bgp_set_route_map_delay_timer
,
6984 bgp_set_route_map_delay_timer_cmd
,
6985 "bgp route-map delay-timer (0-600)",
6987 "BGP route-map delay timer\n"
6988 "Time in secs to wait before processing route-map changes\n"
6989 "0 disables the timer, no route updates happen when route-maps change\n")
6992 uint32_t rmap_delay_timer
;
6994 if (argv
[idx_number
]->arg
) {
6995 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6996 bm
->rmap_update_timer
= rmap_delay_timer
;
6998 /* if the dynamic update handling is being disabled, and a timer
7000 * running, stop the timer and act as if the timer has already
7003 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7004 BGP_TIMER_OFF(bm
->t_rmap_update
);
7005 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7010 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7011 return CMD_WARNING_CONFIG_FAILED
;
7015 DEFUN (no_bgp_set_route_map_delay_timer
,
7016 no_bgp_set_route_map_delay_timer_cmd
,
7017 "no bgp route-map delay-timer [(0-600)]",
7020 "Default BGP route-map delay timer\n"
7021 "Reset to default time to wait for processing route-map changes\n"
7022 "0 disables the timer, no route updates happen when route-maps change\n")
7025 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7030 /* neighbor interface */
7031 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7036 peer
= peer_lookup_vty(vty
, ip_str
);
7037 if (!peer
|| peer
->conf_if
) {
7038 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7039 return CMD_WARNING_CONFIG_FAILED
;
7043 peer_interface_set(peer
, str
);
7045 peer_interface_unset(peer
);
7050 DEFUN (neighbor_interface
,
7051 neighbor_interface_cmd
,
7052 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7061 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7064 DEFUN (no_neighbor_interface
,
7065 no_neighbor_interface_cmd
,
7066 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7075 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7078 DEFUN (neighbor_distribute_list
,
7079 neighbor_distribute_list_cmd
,
7080 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7083 "Filter updates to/from this neighbor\n"
7084 "IP Access-list name\n"
7085 "Filter incoming updates\n"
7086 "Filter outgoing updates\n")
7093 const char *pstr
= argv
[idx_peer
]->arg
;
7094 const char *acl
= argv
[idx_acl
]->arg
;
7095 const char *inout
= argv
[argc
- 1]->text
;
7097 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7099 return CMD_WARNING_CONFIG_FAILED
;
7101 /* Check filter direction. */
7102 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7103 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7106 return bgp_vty_return(vty
, ret
);
7110 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7111 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7112 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7113 "Filter updates to/from this neighbor\n"
7114 "IP Access-list name\n"
7115 "Filter incoming updates\n"
7116 "Filter outgoing updates\n")
7118 DEFUN (no_neighbor_distribute_list
,
7119 no_neighbor_distribute_list_cmd
,
7120 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7124 "Filter updates to/from this neighbor\n"
7125 "IP Access-list name\n"
7126 "Filter incoming updates\n"
7127 "Filter outgoing updates\n")
7133 const char *pstr
= argv
[idx_peer
]->arg
;
7134 const char *inout
= argv
[argc
- 1]->text
;
7136 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7138 return CMD_WARNING_CONFIG_FAILED
;
7140 /* Check filter direction. */
7141 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7142 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7145 return bgp_vty_return(vty
, ret
);
7149 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7150 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7152 "Filter updates to/from this neighbor\n"
7153 "IP Access-list name\n"
7154 "Filter incoming updates\n"
7155 "Filter outgoing updates\n")
7157 /* Set prefix list to the peer. */
7158 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7159 afi_t afi
, safi_t safi
,
7160 const char *name_str
,
7161 const char *direct_str
)
7164 int direct
= FILTER_IN
;
7167 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7169 return CMD_WARNING_CONFIG_FAILED
;
7171 /* Check filter direction. */
7172 if (strncmp(direct_str
, "i", 1) == 0)
7174 else if (strncmp(direct_str
, "o", 1) == 0)
7175 direct
= FILTER_OUT
;
7177 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7179 return bgp_vty_return(vty
, ret
);
7182 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7183 afi_t afi
, safi_t safi
,
7184 const char *direct_str
)
7188 int direct
= FILTER_IN
;
7190 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7192 return CMD_WARNING_CONFIG_FAILED
;
7194 /* Check filter direction. */
7195 if (strncmp(direct_str
, "i", 1) == 0)
7197 else if (strncmp(direct_str
, "o", 1) == 0)
7198 direct
= FILTER_OUT
;
7200 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7202 return bgp_vty_return(vty
, ret
);
7205 DEFUN (neighbor_prefix_list
,
7206 neighbor_prefix_list_cmd
,
7207 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7210 "Filter updates to/from this neighbor\n"
7211 "Name of a prefix list\n"
7212 "Filter incoming updates\n"
7213 "Filter outgoing updates\n")
7218 return peer_prefix_list_set_vty(
7219 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7220 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7223 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7224 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7225 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7226 "Filter updates to/from this neighbor\n"
7227 "Name of a prefix list\n"
7228 "Filter incoming updates\n"
7229 "Filter outgoing updates\n")
7231 DEFUN (no_neighbor_prefix_list
,
7232 no_neighbor_prefix_list_cmd
,
7233 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7237 "Filter updates to/from this neighbor\n"
7238 "Name of a prefix list\n"
7239 "Filter incoming updates\n"
7240 "Filter outgoing updates\n")
7244 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7245 bgp_node_afi(vty
), bgp_node_safi(vty
),
7246 argv
[idx_in_out
]->arg
);
7249 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7250 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7252 "Filter updates to/from this neighbor\n"
7253 "Name of a prefix list\n"
7254 "Filter incoming updates\n"
7255 "Filter outgoing updates\n")
7257 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7258 safi_t safi
, const char *name_str
,
7259 const char *direct_str
)
7263 int direct
= FILTER_IN
;
7265 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7267 return CMD_WARNING_CONFIG_FAILED
;
7269 /* Check filter direction. */
7270 if (strncmp(direct_str
, "i", 1) == 0)
7272 else if (strncmp(direct_str
, "o", 1) == 0)
7273 direct
= FILTER_OUT
;
7275 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7277 return bgp_vty_return(vty
, ret
);
7280 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7281 safi_t safi
, const char *direct_str
)
7285 int direct
= FILTER_IN
;
7287 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7289 return CMD_WARNING_CONFIG_FAILED
;
7291 /* Check filter direction. */
7292 if (strncmp(direct_str
, "i", 1) == 0)
7294 else if (strncmp(direct_str
, "o", 1) == 0)
7295 direct
= FILTER_OUT
;
7297 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7299 return bgp_vty_return(vty
, ret
);
7302 DEFUN (neighbor_filter_list
,
7303 neighbor_filter_list_cmd
,
7304 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7307 "Establish BGP filters\n"
7308 "AS path access-list name\n"
7309 "Filter incoming routes\n"
7310 "Filter outgoing routes\n")
7315 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7316 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7317 argv
[idx_in_out
]->arg
);
7320 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7321 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7322 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7323 "Establish BGP filters\n"
7324 "AS path access-list name\n"
7325 "Filter incoming routes\n"
7326 "Filter outgoing routes\n")
7328 DEFUN (no_neighbor_filter_list
,
7329 no_neighbor_filter_list_cmd
,
7330 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7334 "Establish BGP filters\n"
7335 "AS path access-list name\n"
7336 "Filter incoming routes\n"
7337 "Filter outgoing routes\n")
7341 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7342 bgp_node_afi(vty
), bgp_node_safi(vty
),
7343 argv
[idx_in_out
]->arg
);
7346 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7347 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7348 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7349 "Establish BGP filters\n"
7350 "AS path access-list name\n"
7351 "Filter incoming routes\n"
7352 "Filter outgoing routes\n")
7354 /* Set advertise-map to the peer. */
7355 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7356 afi_t afi
, safi_t safi
,
7357 const char *advertise_str
,
7358 const char *condition_str
, bool condition
,
7361 int ret
= CMD_WARNING_CONFIG_FAILED
;
7363 struct route_map
*advertise_map
;
7364 struct route_map
*condition_map
;
7366 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7370 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7371 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7374 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7375 advertise_map
, condition_str
,
7376 condition_map
, condition
);
7378 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7379 advertise_map
, condition_str
,
7380 condition_map
, condition
);
7382 return bgp_vty_return(vty
, ret
);
7385 DEFPY (bgp_condadv_period
,
7386 bgp_condadv_period_cmd
,
7387 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7390 "Conditional advertisement settings\n"
7391 "Set period to rescan BGP table to check if condition is met\n"
7392 "Period between BGP table scans, in seconds; default 60\n")
7394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7396 bgp
->condition_check_period
=
7397 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7402 DEFPY (neighbor_advertise_map
,
7403 neighbor_advertise_map_cmd
,
7404 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7408 "Route-map to conditionally advertise routes\n"
7409 "Name of advertise map\n"
7410 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7411 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7412 "Name of the exist or non exist map\n")
7414 bool condition
= CONDITION_EXIST
;
7416 if (!strcmp(exist
, "non-exist-map"))
7417 condition
= CONDITION_NON_EXIST
;
7419 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7420 bgp_node_safi(vty
), advertise_str
,
7421 condition_str
, condition
, !no
);
7424 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7425 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7426 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7427 "Route-map to conditionally advertise routes\n"
7428 "Name of advertise map\n"
7429 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7430 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7431 "Name of the exist or non exist map\n")
7433 /* Set route-map to the peer. */
7434 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7435 afi_t afi
, safi_t safi
, const char *name_str
,
7436 const char *direct_str
)
7440 int direct
= RMAP_IN
;
7441 struct route_map
*route_map
;
7443 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7445 return CMD_WARNING_CONFIG_FAILED
;
7447 /* Check filter direction. */
7448 if (strncmp(direct_str
, "in", 2) == 0)
7450 else if (strncmp(direct_str
, "o", 1) == 0)
7453 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7454 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7456 return bgp_vty_return(vty
, ret
);
7459 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7460 afi_t afi
, safi_t safi
,
7461 const char *direct_str
)
7465 int direct
= RMAP_IN
;
7467 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7469 return CMD_WARNING_CONFIG_FAILED
;
7471 /* Check filter direction. */
7472 if (strncmp(direct_str
, "in", 2) == 0)
7474 else if (strncmp(direct_str
, "o", 1) == 0)
7477 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7479 return bgp_vty_return(vty
, ret
);
7482 DEFUN (neighbor_route_map
,
7483 neighbor_route_map_cmd
,
7484 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7487 "Apply route map to neighbor\n"
7488 "Name of route map\n"
7489 "Apply map to incoming routes\n"
7490 "Apply map to outbound routes\n")
7495 return peer_route_map_set_vty(
7496 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7497 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7500 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7501 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7502 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7503 "Apply route map to neighbor\n"
7504 "Name of route map\n"
7505 "Apply map to incoming routes\n"
7506 "Apply map to outbound routes\n")
7508 DEFUN (no_neighbor_route_map
,
7509 no_neighbor_route_map_cmd
,
7510 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7514 "Apply route map to neighbor\n"
7515 "Name of route map\n"
7516 "Apply map to incoming routes\n"
7517 "Apply map to outbound routes\n")
7521 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7522 bgp_node_afi(vty
), bgp_node_safi(vty
),
7523 argv
[idx_in_out
]->arg
);
7526 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7527 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7528 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7529 "Apply route map to neighbor\n"
7530 "Name of route map\n"
7531 "Apply map to incoming routes\n"
7532 "Apply map to outbound routes\n")
7534 /* Set unsuppress-map to the peer. */
7535 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7536 afi_t afi
, safi_t safi
,
7537 const char *name_str
)
7541 struct route_map
*route_map
;
7543 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7545 return CMD_WARNING_CONFIG_FAILED
;
7547 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7548 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7550 return bgp_vty_return(vty
, ret
);
7553 /* Unset route-map from the peer. */
7554 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7555 afi_t afi
, safi_t safi
)
7560 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7562 return CMD_WARNING_CONFIG_FAILED
;
7564 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7566 return bgp_vty_return(vty
, ret
);
7569 DEFUN (neighbor_unsuppress_map
,
7570 neighbor_unsuppress_map_cmd
,
7571 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7574 "Route-map to selectively unsuppress suppressed routes\n"
7575 "Name of route map\n")
7579 return peer_unsuppress_map_set_vty(
7580 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7581 argv
[idx_word
]->arg
);
7584 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7585 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7586 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7587 "Route-map to selectively unsuppress suppressed routes\n"
7588 "Name of route map\n")
7590 DEFUN (no_neighbor_unsuppress_map
,
7591 no_neighbor_unsuppress_map_cmd
,
7592 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7596 "Route-map to selectively unsuppress suppressed routes\n"
7597 "Name of route map\n")
7600 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7602 bgp_node_safi(vty
));
7605 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7606 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7607 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7608 "Route-map to selectively unsuppress suppressed routes\n"
7609 "Name of route map\n")
7611 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7612 afi_t afi
, safi_t safi
,
7613 const char *num_str
,
7614 const char *threshold_str
, int warning
,
7615 const char *restart_str
,
7616 const char *force_str
)
7624 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7626 return CMD_WARNING_CONFIG_FAILED
;
7628 max
= strtoul(num_str
, NULL
, 10);
7630 threshold
= atoi(threshold_str
);
7632 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7635 restart
= atoi(restart_str
);
7639 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7640 restart
, force_str
? true : false);
7642 return bgp_vty_return(vty
, ret
);
7645 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7646 afi_t afi
, safi_t safi
)
7651 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7653 return CMD_WARNING_CONFIG_FAILED
;
7655 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7657 return bgp_vty_return(vty
, ret
);
7660 /* Maximum number of prefix to be sent to the neighbor. */
7661 DEFUN(neighbor_maximum_prefix_out
,
7662 neighbor_maximum_prefix_out_cmd
,
7663 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7666 "Maximum number of prefixes to be sent to this peer\n"
7667 "Maximum no. of prefix limit\n")
7673 afi_t afi
= bgp_node_afi(vty
);
7674 safi_t safi
= bgp_node_safi(vty
);
7676 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7678 return CMD_WARNING_CONFIG_FAILED
;
7680 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7682 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7683 peer
->pmax_out
[afi
][safi
] = max
;
7688 DEFUN(no_neighbor_maximum_prefix_out
,
7689 no_neighbor_maximum_prefix_out_cmd
,
7690 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
7694 "Maximum number of prefixes to be sent to this peer\n")
7698 afi_t afi
= bgp_node_afi(vty
);
7699 safi_t safi
= bgp_node_safi(vty
);
7701 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7703 return CMD_WARNING_CONFIG_FAILED
;
7705 UNSET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7706 peer
->pmax_out
[afi
][safi
] = 0;
7711 /* Maximum number of prefix configuration. Prefix count is different
7712 for each peer configuration. So this configuration can be set for
7713 each peer configuration. */
7714 DEFUN (neighbor_maximum_prefix
,
7715 neighbor_maximum_prefix_cmd
,
7716 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7719 "Maximum number of prefix accept from this peer\n"
7720 "maximum no. of prefix limit\n"
7721 "Force checking all received routes not only accepted\n")
7728 if (argv_find(argv
, argc
, "force", &idx_force
))
7729 force
= argv
[idx_force
]->arg
;
7731 return peer_maximum_prefix_set_vty(
7732 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7733 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7736 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7737 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7738 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7739 "Maximum number of prefix accept from this peer\n"
7740 "maximum no. of prefix limit\n"
7741 "Force checking all received routes not only accepted\n")
7743 DEFUN (neighbor_maximum_prefix_threshold
,
7744 neighbor_maximum_prefix_threshold_cmd
,
7745 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7748 "Maximum number of prefix accept from this peer\n"
7749 "maximum no. of prefix limit\n"
7750 "Threshold value (%) at which to generate a warning msg\n"
7751 "Force checking all received routes not only accepted\n")
7755 int idx_number_2
= 4;
7759 if (argv_find(argv
, argc
, "force", &idx_force
))
7760 force
= argv
[idx_force
]->arg
;
7762 return peer_maximum_prefix_set_vty(
7763 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7764 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
7768 neighbor_maximum_prefix_threshold
,
7769 neighbor_maximum_prefix_threshold_hidden_cmd
,
7770 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7771 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7772 "Maximum number of prefix accept from this peer\n"
7773 "maximum no. of prefix limit\n"
7774 "Threshold value (%) at which to generate a warning msg\n"
7775 "Force checking all received routes not only accepted\n")
7777 DEFUN (neighbor_maximum_prefix_warning
,
7778 neighbor_maximum_prefix_warning_cmd
,
7779 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7782 "Maximum number of prefix accept from this peer\n"
7783 "maximum no. of prefix limit\n"
7784 "Only give warning message when limit is exceeded\n"
7785 "Force checking all received routes not only accepted\n")
7792 if (argv_find(argv
, argc
, "force", &idx_force
))
7793 force
= argv
[idx_force
]->arg
;
7795 return peer_maximum_prefix_set_vty(
7796 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7797 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
7801 neighbor_maximum_prefix_warning
,
7802 neighbor_maximum_prefix_warning_hidden_cmd
,
7803 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7804 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7805 "Maximum number of prefix accept from this peer\n"
7806 "maximum no. of prefix limit\n"
7807 "Only give warning message when limit is exceeded\n"
7808 "Force checking all received routes not only accepted\n")
7810 DEFUN (neighbor_maximum_prefix_threshold_warning
,
7811 neighbor_maximum_prefix_threshold_warning_cmd
,
7812 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7815 "Maximum number of prefix accept from this peer\n"
7816 "maximum no. of prefix limit\n"
7817 "Threshold value (%) at which to generate a warning msg\n"
7818 "Only give warning message when limit is exceeded\n"
7819 "Force checking all received routes not only accepted\n")
7823 int idx_number_2
= 4;
7827 if (argv_find(argv
, argc
, "force", &idx_force
))
7828 force
= argv
[idx_force
]->arg
;
7830 return peer_maximum_prefix_set_vty(
7831 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7832 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
7836 neighbor_maximum_prefix_threshold_warning
,
7837 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
7838 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7839 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7840 "Maximum number of prefix accept from this peer\n"
7841 "maximum no. of prefix limit\n"
7842 "Threshold value (%) at which to generate a warning msg\n"
7843 "Only give warning message when limit is exceeded\n"
7844 "Force checking all received routes not only accepted\n")
7846 DEFUN (neighbor_maximum_prefix_restart
,
7847 neighbor_maximum_prefix_restart_cmd
,
7848 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7851 "Maximum number of prefix accept from this peer\n"
7852 "maximum no. of prefix limit\n"
7853 "Restart bgp connection after limit is exceeded\n"
7854 "Restart interval in minutes\n"
7855 "Force checking all received routes not only accepted\n")
7859 int idx_number_2
= 5;
7863 if (argv_find(argv
, argc
, "force", &idx_force
))
7864 force
= argv
[idx_force
]->arg
;
7866 return peer_maximum_prefix_set_vty(
7867 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7868 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7872 neighbor_maximum_prefix_restart
,
7873 neighbor_maximum_prefix_restart_hidden_cmd
,
7874 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7875 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7876 "Maximum number of prefix accept from this peer\n"
7877 "maximum no. of prefix limit\n"
7878 "Restart bgp connection after limit is exceeded\n"
7879 "Restart interval in minutes\n"
7880 "Force checking all received routes not only accepted\n")
7882 DEFUN (neighbor_maximum_prefix_threshold_restart
,
7883 neighbor_maximum_prefix_threshold_restart_cmd
,
7884 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7887 "Maximum number of prefixes to accept from this peer\n"
7888 "maximum no. of prefix limit\n"
7889 "Threshold value (%) at which to generate a warning msg\n"
7890 "Restart bgp connection after limit is exceeded\n"
7891 "Restart interval in minutes\n"
7892 "Force checking all received routes not only accepted\n")
7896 int idx_number_2
= 4;
7897 int idx_number_3
= 6;
7901 if (argv_find(argv
, argc
, "force", &idx_force
))
7902 force
= argv
[idx_force
]->arg
;
7904 return peer_maximum_prefix_set_vty(
7905 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7906 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
7907 argv
[idx_number_3
]->arg
, force
);
7911 neighbor_maximum_prefix_threshold_restart
,
7912 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
7913 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7914 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7915 "Maximum number of prefixes to accept from this peer\n"
7916 "maximum no. of prefix limit\n"
7917 "Threshold value (%) at which to generate a warning msg\n"
7918 "Restart bgp connection after limit is exceeded\n"
7919 "Restart interval in minutes\n"
7920 "Force checking all received routes not only accepted\n")
7922 DEFUN (no_neighbor_maximum_prefix
,
7923 no_neighbor_maximum_prefix_cmd
,
7924 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7928 "Maximum number of prefixes to accept from this peer\n"
7929 "maximum no. of prefix limit\n"
7930 "Threshold value (%) at which to generate a warning msg\n"
7931 "Restart bgp connection after limit is exceeded\n"
7932 "Restart interval in minutes\n"
7933 "Only give warning message when limit is exceeded\n"
7934 "Force checking all received routes not only accepted\n")
7937 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
7939 bgp_node_safi(vty
));
7943 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
7944 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7946 "Maximum number of prefixes to accept from this peer\n"
7947 "maximum no. of prefix limit\n"
7948 "Threshold value (%) at which to generate a warning msg\n"
7949 "Restart bgp connection after limit is exceeded\n"
7950 "Restart interval in minutes\n"
7951 "Only give warning message when limit is exceeded\n"
7952 "Force checking all received routes not only accepted\n")
7955 /* "neighbor allowas-in" */
7956 DEFUN (neighbor_allowas_in
,
7957 neighbor_allowas_in_cmd
,
7958 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7961 "Accept as-path with my AS present in it\n"
7962 "Number of occurrences of AS number\n"
7963 "Only accept my AS in the as-path if the route was originated in my AS\n")
7966 int idx_number_origin
= 3;
7972 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7974 return CMD_WARNING_CONFIG_FAILED
;
7976 if (argc
<= idx_number_origin
)
7979 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
7982 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
7985 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7988 return bgp_vty_return(vty
, ret
);
7992 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
7993 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7994 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7995 "Accept as-path with my AS present in it\n"
7996 "Number of occurrences of AS number\n"
7997 "Only accept my AS in the as-path if the route was originated in my AS\n")
7999 DEFUN (no_neighbor_allowas_in
,
8000 no_neighbor_allowas_in_cmd
,
8001 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8005 "allow local ASN appears in aspath attribute\n"
8006 "Number of occurrences of AS number\n"
8007 "Only accept my AS in the as-path if the route was originated in my AS\n")
8013 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8015 return CMD_WARNING_CONFIG_FAILED
;
8017 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8018 bgp_node_safi(vty
));
8020 return bgp_vty_return(vty
, ret
);
8024 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8025 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8026 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8027 "allow local ASN appears in aspath attribute\n"
8028 "Number of occurrences of AS number\n"
8029 "Only accept my AS in the as-path if the route was originated in my AS\n")
8031 DEFUN (neighbor_ttl_security
,
8032 neighbor_ttl_security_cmd
,
8033 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8036 "BGP ttl-security parameters\n"
8037 "Specify the maximum number of hops to the BGP peer\n"
8038 "Number of hops to BGP peer\n")
8045 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8047 return CMD_WARNING_CONFIG_FAILED
;
8049 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8052 * If 'neighbor swpX', then this is for directly connected peers,
8053 * we should not accept a ttl-security hops value greater than 1.
8055 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8057 "%s is directly connected peer, hops cannot exceed 1\n",
8058 argv
[idx_peer
]->arg
);
8059 return CMD_WARNING_CONFIG_FAILED
;
8062 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8065 DEFUN (no_neighbor_ttl_security
,
8066 no_neighbor_ttl_security_cmd
,
8067 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8071 "BGP ttl-security parameters\n"
8072 "Specify the maximum number of hops to the BGP peer\n"
8073 "Number of hops to BGP peer\n")
8078 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8080 return CMD_WARNING_CONFIG_FAILED
;
8082 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8085 /* disable-addpath-rx */
8086 DEFUN(neighbor_disable_addpath_rx
,
8087 neighbor_disable_addpath_rx_cmd
,
8088 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8091 "Do not accept additional paths\n")
8093 char *peer_str
= argv
[1]->arg
;
8095 afi_t afi
= bgp_node_afi(vty
);
8096 safi_t safi
= bgp_node_safi(vty
);
8098 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8100 return CMD_WARNING_CONFIG_FAILED
;
8102 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8103 PEER_FLAG_DISABLE_ADDPATH_RX
);
8106 DEFUN(no_neighbor_disable_addpath_rx
,
8107 no_neighbor_disable_addpath_rx_cmd
,
8108 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8112 "Do not accept additional paths\n")
8114 char *peer_str
= argv
[2]->arg
;
8116 afi_t afi
= bgp_node_afi(vty
);
8117 safi_t safi
= bgp_node_safi(vty
);
8119 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8121 return CMD_WARNING_CONFIG_FAILED
;
8123 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8124 PEER_FLAG_DISABLE_ADDPATH_RX
);
8127 DEFUN (neighbor_addpath_tx_all_paths
,
8128 neighbor_addpath_tx_all_paths_cmd
,
8129 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8132 "Use addpath to advertise all paths to a neighbor\n")
8137 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8139 return CMD_WARNING_CONFIG_FAILED
;
8141 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8146 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8147 neighbor_addpath_tx_all_paths_hidden_cmd
,
8148 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8150 "Use addpath to advertise all paths to a neighbor\n")
8152 DEFUN (no_neighbor_addpath_tx_all_paths
,
8153 no_neighbor_addpath_tx_all_paths_cmd
,
8154 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8158 "Use addpath to advertise all paths to a neighbor\n")
8163 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8165 return CMD_WARNING_CONFIG_FAILED
;
8167 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8168 != BGP_ADDPATH_ALL
) {
8170 "%% Peer not currently configured to transmit all paths.");
8171 return CMD_WARNING_CONFIG_FAILED
;
8174 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8180 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8181 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8182 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8183 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8184 "Use addpath to advertise all paths to a neighbor\n")
8186 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8187 neighbor_addpath_tx_bestpath_per_as_cmd
,
8188 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8191 "Use addpath to advertise the bestpath per each neighboring AS\n")
8196 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8198 return CMD_WARNING_CONFIG_FAILED
;
8200 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8201 BGP_ADDPATH_BEST_PER_AS
);
8206 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8207 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8208 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8209 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8210 "Use addpath to advertise the bestpath per each neighboring AS\n")
8212 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8213 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8214 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8218 "Use addpath to advertise the bestpath per each neighboring AS\n")
8223 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8225 return CMD_WARNING_CONFIG_FAILED
;
8227 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8228 != BGP_ADDPATH_BEST_PER_AS
) {
8230 "%% Peer not currently configured to transmit all best path per as.");
8231 return CMD_WARNING_CONFIG_FAILED
;
8234 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8240 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8241 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8242 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8243 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8244 "Use addpath to advertise the bestpath per each neighboring AS\n")
8247 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8248 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8251 "Detect AS loops before sending to neighbor\n")
8255 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8257 return CMD_WARNING_CONFIG_FAILED
;
8259 peer
->as_path_loop_detection
= true;
8265 no_neighbor_aspath_loop_detection
,
8266 no_neighbor_aspath_loop_detection_cmd
,
8267 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8271 "Detect AS loops before sending to neighbor\n")
8275 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8277 return CMD_WARNING_CONFIG_FAILED
;
8279 peer
->as_path_loop_detection
= false;
8284 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8285 struct ecommunity
**list
, bool is_rt6
)
8287 struct ecommunity
*ecom
= NULL
;
8288 struct ecommunity
*ecomadd
;
8290 for (; argc
; --argc
, ++argv
) {
8292 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8293 ECOMMUNITY_ROUTE_TARGET
,
8296 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8297 ECOMMUNITY_ROUTE_TARGET
,
8300 vty_out(vty
, "Malformed community-list value\n");
8302 ecommunity_free(&ecom
);
8303 return CMD_WARNING_CONFIG_FAILED
;
8307 ecommunity_merge(ecom
, ecomadd
);
8308 ecommunity_free(&ecomadd
);
8315 ecommunity_free(&*list
);
8323 * v2vimport is true if we are handling a `import vrf ...` command
8325 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8329 switch (vty
->node
) {
8338 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8343 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8344 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8345 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8346 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8348 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8352 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8353 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8354 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8355 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8357 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8364 DEFPY (af_rd_vpn_export
,
8365 af_rd_vpn_export_cmd
,
8366 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8368 "Specify route distinguisher\n"
8369 "Between current address-family and vpn\n"
8370 "For routes leaked from current address-family to vpn\n"
8371 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8374 struct prefix_rd prd
;
8380 if (argv_find(argv
, argc
, "no", &idx
))
8384 ret
= str2prefix_rd(rd_str
, &prd
);
8386 vty_out(vty
, "%% Malformed rd\n");
8387 return CMD_WARNING_CONFIG_FAILED
;
8391 afi
= vpn_policy_getafi(vty
, bgp
, false);
8393 return CMD_WARNING_CONFIG_FAILED
;
8396 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8398 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8399 bgp_get_default(), bgp
);
8402 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8403 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8404 BGP_VPN_POLICY_TOVPN_RD_SET
);
8406 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8407 BGP_VPN_POLICY_TOVPN_RD_SET
);
8410 /* post-change: re-export vpn routes */
8411 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8412 bgp_get_default(), bgp
);
8417 ALIAS (af_rd_vpn_export
,
8418 af_no_rd_vpn_export_cmd
,
8421 "Specify route distinguisher\n"
8422 "Between current address-family and vpn\n"
8423 "For routes leaked from current address-family to vpn\n")
8425 DEFPY (af_label_vpn_export
,
8426 af_label_vpn_export_cmd
,
8427 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8429 "label value for VRF\n"
8430 "Between current address-family and vpn\n"
8431 "For routes leaked from current address-family to vpn\n"
8432 "Label Value <0-1048575>\n"
8433 "Automatically assign a label\n")
8435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8436 mpls_label_t label
= MPLS_LABEL_NONE
;
8441 if (argv_find(argv
, argc
, "no", &idx
))
8444 /* If "no ...", squash trailing parameter */
8450 label
= label_val
; /* parser should force unsigned */
8453 afi
= vpn_policy_getafi(vty
, bgp
, false);
8455 return CMD_WARNING_CONFIG_FAILED
;
8458 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8459 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8464 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8466 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8467 bgp_get_default(), bgp
);
8469 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8470 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8472 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8475 * label has previously been automatically
8476 * assigned by labelpool: release it
8478 * NB if tovpn_label == MPLS_LABEL_NONE it
8479 * means the automatic assignment is in flight
8480 * and therefore the labelpool callback must
8481 * detect that the auto label is not needed.
8484 bgp_lp_release(LP_TYPE_VRF
,
8485 &bgp
->vpn_policy
[afi
],
8486 bgp
->vpn_policy
[afi
].tovpn_label
);
8488 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8489 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8492 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8494 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8495 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8496 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8497 vpn_leak_label_callback
);
8500 /* post-change: re-export vpn routes */
8501 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8502 bgp_get_default(), bgp
);
8504 hook_call(bgp_snmp_update_last_changed
, bgp
);
8508 DEFPY (af_sid_vpn_export
,
8509 af_sid_vpn_export_cmd
,
8510 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8512 "sid value for VRF\n"
8513 "Between current address-family and vpn\n"
8514 "For routes leaked from current address-family to vpn\n"
8515 "Sid allocation index\n"
8516 "Automatically assign a label\n")
8518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8524 if (argv_find(argv
, argc
, "no", &idx
))
8526 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8527 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8529 afi
= vpn_policy_getafi(vty
, bgp
, false);
8531 return CMD_WARNING_CONFIG_FAILED
;
8535 vty_out(vty
, "It's not implemented");
8536 return CMD_WARNING_CONFIG_FAILED
;
8539 /* skip when it's already configured */
8540 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8541 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8542 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8546 * mode change between sid_idx and sid_auto isn't supported.
8547 * user must negate sid vpn export when they want to change the mode
8549 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8550 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8551 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8552 vty_out(vty
, "it's already configured as %s.\n",
8553 sid_auto
? "auto-mode" : "idx-mode");
8554 return CMD_WARNING_CONFIG_FAILED
;
8558 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8559 bgp_get_default(), bgp
);
8562 /* SID allocation auto-mode */
8564 zlog_debug("%s: auto sid alloc.", __func__
);
8565 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8566 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8568 /* SID allocation index-mode */
8570 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8571 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8575 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8576 bgp_get_default(), bgp
);
8580 ALIAS (af_label_vpn_export
,
8581 af_no_label_vpn_export_cmd
,
8582 "no label vpn export",
8584 "label value for VRF\n"
8585 "Between current address-family and vpn\n"
8586 "For routes leaked from current address-family to vpn\n")
8588 DEFPY (af_nexthop_vpn_export
,
8589 af_nexthop_vpn_export_cmd
,
8590 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8592 "Specify next hop to use for VRF advertised prefixes\n"
8593 "Between current address-family and vpn\n"
8594 "For routes leaked from current address-family to vpn\n"
8598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8604 vty_out(vty
, "%% Nexthop required\n");
8605 return CMD_WARNING_CONFIG_FAILED
;
8607 if (!sockunion2hostprefix(nexthop_su
, &p
))
8608 return CMD_WARNING_CONFIG_FAILED
;
8611 afi
= vpn_policy_getafi(vty
, bgp
, false);
8613 return CMD_WARNING_CONFIG_FAILED
;
8616 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8618 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8619 bgp_get_default(), bgp
);
8622 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8623 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8624 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8626 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8627 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8630 /* post-change: re-export vpn routes */
8631 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8632 bgp_get_default(), bgp
);
8637 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8639 if (!strcmp(dstr
, "import")) {
8640 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8641 } else if (!strcmp(dstr
, "export")) {
8642 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8643 } else if (!strcmp(dstr
, "both")) {
8644 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8645 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8647 vty_out(vty
, "%% direction parse error\n");
8648 return CMD_WARNING_CONFIG_FAILED
;
8653 DEFPY (af_rt_vpn_imexport
,
8654 af_rt_vpn_imexport_cmd
,
8655 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8657 "Specify route target list\n"
8658 "Specify route target list\n"
8659 "Between current address-family and vpn\n"
8660 "For routes leaked from vpn to current address-family: match any\n"
8661 "For routes leaked from current address-family to vpn: set\n"
8662 "both import: match any and export: set\n"
8663 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8667 struct ecommunity
*ecom
= NULL
;
8668 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8669 vpn_policy_direction_t dir
;
8674 if (argv_find(argv
, argc
, "no", &idx
))
8677 afi
= vpn_policy_getafi(vty
, bgp
, false);
8679 return CMD_WARNING_CONFIG_FAILED
;
8681 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8682 if (ret
!= CMD_SUCCESS
)
8686 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8687 vty_out(vty
, "%% Missing RTLIST\n");
8688 return CMD_WARNING_CONFIG_FAILED
;
8690 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8691 if (ret
!= CMD_SUCCESS
) {
8696 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8700 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8703 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8705 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8706 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8707 ecommunity_dup(ecom
);
8709 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8711 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8712 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8715 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8719 ecommunity_free(&ecom
);
8724 ALIAS (af_rt_vpn_imexport
,
8725 af_no_rt_vpn_imexport_cmd
,
8726 "no <rt|route-target> vpn <import|export|both>$direction_str",
8728 "Specify route target list\n"
8729 "Specify route target list\n"
8730 "Between current address-family and vpn\n"
8731 "For routes leaked from vpn to current address-family\n"
8732 "For routes leaked from current address-family to vpn\n"
8733 "both import and export\n")
8735 DEFPY (af_route_map_vpn_imexport
,
8736 af_route_map_vpn_imexport_cmd
,
8737 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8738 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8740 "Specify route map\n"
8741 "Between current address-family and vpn\n"
8742 "For routes leaked from vpn to current address-family\n"
8743 "For routes leaked from current address-family to vpn\n"
8744 "name of route-map\n")
8746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8748 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8749 vpn_policy_direction_t dir
;
8754 if (argv_find(argv
, argc
, "no", &idx
))
8757 afi
= vpn_policy_getafi(vty
, bgp
, false);
8759 return CMD_WARNING_CONFIG_FAILED
;
8761 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8762 if (ret
!= CMD_SUCCESS
)
8765 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8769 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8772 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8773 XFREE(MTYPE_ROUTE_MAP_NAME
,
8774 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8775 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
8776 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8777 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8778 route_map_lookup_warn_noexist(vty
, rmap_str
);
8779 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8782 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8783 XFREE(MTYPE_ROUTE_MAP_NAME
,
8784 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8785 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8786 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8789 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8795 ALIAS (af_route_map_vpn_imexport
,
8796 af_no_route_map_vpn_imexport_cmd
,
8797 "no route-map vpn <import|export>$direction_str",
8799 "Specify route map\n"
8800 "Between current address-family and vpn\n"
8801 "For routes leaked from vpn to current address-family\n"
8802 "For routes leaked from current address-family to vpn\n")
8804 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
8805 "import vrf route-map RMAP$rmap_str",
8806 "Import routes from another VRF\n"
8807 "Vrf routes being filtered\n"
8808 "Specify route map\n"
8809 "name of route-map\n")
8811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8812 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8814 struct bgp
*bgp_default
;
8816 afi
= vpn_policy_getafi(vty
, bgp
, true);
8818 return CMD_WARNING_CONFIG_FAILED
;
8820 bgp_default
= bgp_get_default();
8825 /* Auto-create assuming the same AS */
8826 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8827 BGP_INSTANCE_TYPE_DEFAULT
);
8831 "VRF default is not configured as a bgp instance\n");
8836 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8838 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8839 XFREE(MTYPE_ROUTE_MAP_NAME
,
8840 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8841 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
8842 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8843 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8844 route_map_lookup_warn_noexist(vty
, rmap_str
);
8845 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8848 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8849 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8851 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8856 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
8857 "no import vrf route-map [RMAP$rmap_str]",
8859 "Import routes from another VRF\n"
8860 "Vrf routes being filtered\n"
8861 "Specify route map\n"
8862 "name of route-map\n")
8864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8865 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8868 afi
= vpn_policy_getafi(vty
, bgp
, true);
8870 return CMD_WARNING_CONFIG_FAILED
;
8872 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8874 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8875 XFREE(MTYPE_ROUTE_MAP_NAME
,
8876 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8877 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8878 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8880 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
8881 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8882 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8884 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8889 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
8890 "[no] import vrf VIEWVRFNAME$import_name",
8892 "Import routes from another VRF\n"
8893 "VRF to import from\n"
8894 "The name of the VRF\n")
8896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8897 struct listnode
*node
;
8898 struct bgp
*vrf_bgp
, *bgp_default
;
8901 bool remove
= false;
8904 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
8908 if (import_name
== NULL
) {
8909 vty_out(vty
, "%% Missing import name\n");
8913 if (strcmp(import_name
, "route-map") == 0) {
8914 vty_out(vty
, "%% Must include route-map name\n");
8918 if (argv_find(argv
, argc
, "no", &idx
))
8921 afi
= vpn_policy_getafi(vty
, bgp
, true);
8923 return CMD_WARNING_CONFIG_FAILED
;
8925 safi
= bgp_node_safi(vty
);
8927 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
8928 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
8929 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
8930 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
8931 remove
? "unimport" : "import", import_name
);
8935 bgp_default
= bgp_get_default();
8937 /* Auto-create assuming the same AS */
8938 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8939 BGP_INSTANCE_TYPE_DEFAULT
);
8943 "VRF default is not configured as a bgp instance\n");
8948 vrf_bgp
= bgp_lookup_by_name(import_name
);
8950 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
8951 vrf_bgp
= bgp_default
;
8953 /* Auto-create assuming the same AS */
8954 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
8958 "VRF %s is not configured as a bgp instance\n",
8965 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8967 /* Already importing from "import_vrf"? */
8968 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
8970 if (strcmp(vname
, import_name
) == 0)
8974 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8980 /* This command is valid only in a bgp vrf instance or the default instance */
8981 DEFPY (bgp_imexport_vpn
,
8982 bgp_imexport_vpn_cmd
,
8983 "[no] <import|export>$direction_str vpn",
8985 "Import routes to this address-family\n"
8986 "Export routes from this address-family\n"
8987 "to/from default instance VPN RIB\n")
8989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8996 vpn_policy_direction_t dir
;
8998 if (argv_find(argv
, argc
, "no", &idx
))
9001 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9002 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9004 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9005 return CMD_WARNING_CONFIG_FAILED
;
9008 afi
= bgp_node_afi(vty
);
9009 safi
= bgp_node_safi(vty
);
9010 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9011 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9012 return CMD_WARNING_CONFIG_FAILED
;
9015 if (!strcmp(direction_str
, "import")) {
9016 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9017 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9018 } else if (!strcmp(direction_str
, "export")) {
9019 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9020 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9022 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9023 return CMD_WARNING_CONFIG_FAILED
;
9026 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9029 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9030 if (!previous_state
) {
9031 /* trigger export current vrf */
9032 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9035 if (previous_state
) {
9036 /* trigger un-export current vrf */
9037 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9039 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9042 hook_call(bgp_snmp_init_stats
, bgp
);
9047 DEFPY (af_routetarget_import
,
9048 af_routetarget_import_cmd
,
9049 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9051 "Specify route target list\n"
9052 "Specify route target list\n"
9053 "Specify route target list\n"
9054 "Specify route target list\n"
9055 "Flow-spec redirect type route target\n"
9056 "Import routes to this address-family\n"
9057 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9061 struct ecommunity
*ecom
= NULL
;
9063 int idx
= 0, idx_unused
= 0;
9067 if (argv_find(argv
, argc
, "no", &idx
))
9070 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9071 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9074 afi
= vpn_policy_getafi(vty
, bgp
, false);
9076 return CMD_WARNING_CONFIG_FAILED
;
9078 if (rt6
&& afi
!= AFI_IP6
)
9079 return CMD_WARNING_CONFIG_FAILED
;
9082 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9083 vty_out(vty
, "%% Missing RTLIST\n");
9084 return CMD_WARNING_CONFIG_FAILED
;
9086 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9087 if (ret
!= CMD_SUCCESS
)
9092 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9093 ecommunity_free(&bgp
->vpn_policy
[afi
]
9094 .import_redirect_rtlist
);
9095 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9096 ecommunity_dup(ecom
);
9098 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9099 ecommunity_free(&bgp
->vpn_policy
[afi
]
9100 .import_redirect_rtlist
);
9101 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9105 ecommunity_free(&ecom
);
9110 DEFUN_NOSH (address_family_ipv4_safi
,
9111 address_family_ipv4_safi_cmd
,
9112 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9113 "Enter Address Family command mode\n"
9115 BGP_SAFI_WITH_LABEL_HELP_STR
)
9119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9120 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9121 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9122 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9123 && safi
!= SAFI_EVPN
) {
9125 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9126 return CMD_WARNING_CONFIG_FAILED
;
9128 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9130 vty
->node
= BGP_IPV4_NODE
;
9135 DEFUN_NOSH (address_family_ipv6_safi
,
9136 address_family_ipv6_safi_cmd
,
9137 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9138 "Enter Address Family command mode\n"
9140 BGP_SAFI_WITH_LABEL_HELP_STR
)
9143 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9144 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9145 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9146 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9147 && safi
!= SAFI_EVPN
) {
9149 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9150 return CMD_WARNING_CONFIG_FAILED
;
9152 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9154 vty
->node
= BGP_IPV6_NODE
;
9159 #ifdef KEEP_OLD_VPN_COMMANDS
9160 DEFUN_NOSH (address_family_vpnv4
,
9161 address_family_vpnv4_cmd
,
9162 "address-family vpnv4 [unicast]",
9163 "Enter Address Family command mode\n"
9165 "Address Family modifier\n")
9167 vty
->node
= BGP_VPNV4_NODE
;
9171 DEFUN_NOSH (address_family_vpnv6
,
9172 address_family_vpnv6_cmd
,
9173 "address-family vpnv6 [unicast]",
9174 "Enter Address Family command mode\n"
9176 "Address Family modifier\n")
9178 vty
->node
= BGP_VPNV6_NODE
;
9181 #endif /* KEEP_OLD_VPN_COMMANDS */
9183 DEFUN_NOSH (address_family_evpn
,
9184 address_family_evpn_cmd
,
9185 "address-family l2vpn evpn",
9186 "Enter Address Family command mode\n"
9188 "Address Family modifier\n")
9190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9191 vty
->node
= BGP_EVPN_NODE
;
9195 DEFUN_NOSH (bgp_segment_routing_srv6
,
9196 bgp_segment_routing_srv6_cmd
,
9197 "segment-routing srv6",
9198 "Segment-Routing configuration\n"
9199 "Segment-Routing SRv6 configuration\n")
9201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9202 bgp
->srv6_enabled
= true;
9203 vty
->node
= BGP_SRV6_NODE
;
9207 DEFUN (no_bgp_segment_routing_srv6
,
9208 no_bgp_segment_routing_srv6_cmd
,
9209 "no segment-routing srv6",
9211 "Segment-Routing configuration\n"
9212 "Segment-Routing SRv6 configuration\n")
9214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9216 if (strlen(bgp
->srv6_locator_name
) > 0)
9217 if (bgp_srv6_locator_unset(bgp
) < 0)
9218 return CMD_WARNING_CONFIG_FAILED
;
9220 bgp
->srv6_enabled
= false;
9224 DEFPY (bgp_srv6_locator
,
9225 bgp_srv6_locator_cmd
,
9226 "locator NAME$name",
9227 "Specify SRv6 locator\n"
9228 "Specify SRv6 locator\n")
9230 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9233 if (strlen(bgp
->srv6_locator_name
) > 0
9234 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9235 vty_out(vty
, "srv6 locator is already configured\n");
9236 return CMD_WARNING_CONFIG_FAILED
;
9239 snprintf(bgp
->srv6_locator_name
,
9240 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9242 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9244 return CMD_WARNING_CONFIG_FAILED
;
9249 DEFPY (no_bgp_srv6_locator
,
9250 no_bgp_srv6_locator_cmd
,
9251 "no locator NAME$name",
9253 "Specify SRv6 locator\n"
9254 "Specify SRv6 locator\n")
9256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9258 /* when locator isn't configured, do nothing */
9259 if (strlen(bgp
->srv6_locator_name
) < 1)
9262 /* name validation */
9263 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9264 vty_out(vty
, "%% No srv6 locator is configured\n");
9265 return CMD_WARNING_CONFIG_FAILED
;
9269 if (bgp_srv6_locator_unset(bgp
) < 0)
9270 return CMD_WARNING_CONFIG_FAILED
;
9275 DEFPY (show_bgp_srv6
,
9277 "show bgp segment-routing srv6",
9280 "BGP Segment Routing\n"
9281 "BGP Segment Routing SRv6\n")
9284 struct listnode
*node
;
9285 struct prefix_ipv6
*chunk
;
9286 struct bgp_srv6_function
*func
;
9287 struct in6_addr
*tovpn4_sid
;
9288 struct in6_addr
*tovpn6_sid
;
9290 char buf_tovpn4_sid
[256];
9291 char buf_tovpn6_sid
[256];
9293 bgp
= bgp_get_default();
9297 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9298 vty_out(vty
, "locator_chunks:\n");
9299 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9300 prefix2str(chunk
, buf
, sizeof(buf
));
9301 vty_out(vty
, "- %s\n", buf
);
9304 vty_out(vty
, "functions:\n");
9305 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9306 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9307 vty_out(vty
, "- sid: %s\n", buf
);
9308 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9311 vty_out(vty
, "bgps:\n");
9312 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9313 vty_out(vty
, "- name: %s\n",
9314 bgp
->name
? bgp
->name
: "default");
9316 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9317 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9319 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9320 sizeof(buf_tovpn4_sid
));
9322 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9323 sizeof(buf_tovpn6_sid
));
9325 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9326 tovpn4_sid
? buf_tovpn4_sid
: "none");
9327 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9328 tovpn6_sid
? buf_tovpn6_sid
: "none");
9334 DEFUN_NOSH (exit_address_family
,
9335 exit_address_family_cmd
,
9336 "exit-address-family",
9337 "Exit from Address Family configuration mode\n")
9339 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9340 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9341 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9342 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9343 || vty
->node
== BGP_EVPN_NODE
9344 || vty
->node
== BGP_FLOWSPECV4_NODE
9345 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9346 vty
->node
= BGP_NODE
;
9350 /* Recalculate bestpath and re-advertise a prefix */
9351 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9352 const char *ip_str
, afi_t afi
, safi_t safi
,
9353 struct prefix_rd
*prd
)
9356 struct prefix match
;
9357 struct bgp_dest
*dest
;
9358 struct bgp_dest
*rm
;
9360 struct bgp_table
*table
;
9361 struct bgp_table
*rib
;
9363 /* BGP structure lookup. */
9365 bgp
= bgp_lookup_by_name(view_name
);
9367 vty_out(vty
, "%% Can't find BGP instance %s\n",
9372 bgp
= bgp_get_default();
9374 vty_out(vty
, "%% No BGP process is configured\n");
9379 /* Check IP address argument. */
9380 ret
= str2prefix(ip_str
, &match
);
9382 vty_out(vty
, "%% address is malformed\n");
9386 match
.family
= afi2family(afi
);
9387 rib
= bgp
->rib
[afi
][safi
];
9389 if (safi
== SAFI_MPLS_VPN
) {
9390 for (dest
= bgp_table_top(rib
); dest
;
9391 dest
= bgp_route_next(dest
)) {
9392 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9394 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9397 table
= bgp_dest_get_bgp_table_info(dest
);
9401 rm
= bgp_node_match(table
, &match
);
9403 const struct prefix
*rm_p
=
9404 bgp_dest_get_prefix(rm
);
9406 if (rm_p
->prefixlen
== match
.prefixlen
) {
9408 BGP_NODE_USER_CLEAR
);
9409 bgp_process(bgp
, rm
, afi
, safi
);
9411 bgp_dest_unlock_node(rm
);
9415 dest
= bgp_node_match(rib
, &match
);
9417 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9419 if (dest_p
->prefixlen
== match
.prefixlen
) {
9420 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9421 bgp_process(bgp
, dest
, afi
, safi
);
9423 bgp_dest_unlock_node(dest
);
9430 /* one clear bgp command to rule them all */
9431 DEFUN (clear_ip_bgp_all
,
9432 clear_ip_bgp_all_cmd
,
9433 "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>]",
9437 BGP_INSTANCE_HELP_STR
9440 BGP_SAFI_WITH_LABEL_HELP_STR
9441 "Address Family modifier\n"
9443 "BGP IPv4 neighbor to clear\n"
9444 "BGP IPv6 neighbor to clear\n"
9445 "BGP neighbor on interface to clear\n"
9446 "Clear peers with the AS number\n"
9447 "Clear all external peers\n"
9448 "Clear all members of peer-group\n"
9449 "BGP peer-group name\n"
9454 "Push out prefix-list ORF and do inbound soft reconfig\n"
9459 afi_t afi
= AFI_UNSPEC
;
9460 safi_t safi
= SAFI_UNSPEC
;
9461 enum clear_sort clr_sort
= clear_peer
;
9462 enum bgp_clear_type clr_type
;
9463 char *clr_arg
= NULL
;
9467 /* clear [ip] bgp */
9468 if (argv_find(argv
, argc
, "ip", &idx
))
9471 /* [<vrf> VIEWVRFNAME] */
9472 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9473 vrf
= argv
[idx
+ 1]->arg
;
9475 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9477 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9478 /* [<view> VIEWVRFNAME] */
9479 vrf
= argv
[idx
+ 1]->arg
;
9482 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9483 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9484 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9486 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9487 if (argv_find(argv
, argc
, "*", &idx
)) {
9488 clr_sort
= clear_all
;
9489 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9490 clr_sort
= clear_peer
;
9491 clr_arg
= argv
[idx
]->arg
;
9492 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9493 clr_sort
= clear_peer
;
9494 clr_arg
= argv
[idx
]->arg
;
9495 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9496 clr_sort
= clear_group
;
9498 clr_arg
= argv
[idx
]->arg
;
9499 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9500 clr_sort
= clear_peer
;
9501 clr_arg
= argv
[idx
]->arg
;
9502 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9503 clr_sort
= clear_peer
;
9504 clr_arg
= argv
[idx
]->arg
;
9505 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9506 clr_sort
= clear_as
;
9507 clr_arg
= argv
[idx
]->arg
;
9508 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9509 clr_sort
= clear_external
;
9512 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9513 if (argv_find(argv
, argc
, "soft", &idx
)) {
9514 if (argv_find(argv
, argc
, "in", &idx
)
9515 || argv_find(argv
, argc
, "out", &idx
))
9516 clr_type
= strmatch(argv
[idx
]->text
, "in")
9518 : BGP_CLEAR_SOFT_OUT
;
9520 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9521 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9522 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9523 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9524 : BGP_CLEAR_SOFT_IN
;
9525 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9526 clr_type
= BGP_CLEAR_SOFT_OUT
;
9528 clr_type
= BGP_CLEAR_SOFT_NONE
;
9530 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9533 DEFUN (clear_ip_bgp_prefix
,
9534 clear_ip_bgp_prefix_cmd
,
9535 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9539 BGP_INSTANCE_HELP_STR
9540 "Clear bestpath and re-advertise\n"
9544 char *prefix
= NULL
;
9548 /* [<view|vrf> VIEWVRFNAME] */
9549 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9550 vrf
= argv
[idx
+ 1]->arg
;
9552 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9554 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9555 /* [<view> VIEWVRFNAME] */
9556 vrf
= argv
[idx
+ 1]->arg
;
9560 prefix
= argv
[argc
- 1]->arg
;
9562 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9565 DEFUN (clear_bgp_ipv6_safi_prefix
,
9566 clear_bgp_ipv6_safi_prefix_cmd
,
9567 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9573 "Clear bestpath and re-advertise\n"
9577 int idx_ipv6_prefix
= 0;
9578 safi_t safi
= SAFI_UNICAST
;
9579 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9580 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9582 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9583 return bgp_clear_prefix(
9584 vty
, NULL
, prefix
, AFI_IP6
,
9588 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9589 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9590 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9594 BGP_INSTANCE_HELP_STR
9597 "Clear bestpath and re-advertise\n"
9601 int idx_vrfview
= 0;
9602 int idx_ipv6_prefix
= 0;
9603 safi_t safi
= SAFI_UNICAST
;
9604 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9605 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9606 char *vrfview
= NULL
;
9608 /* [<view|vrf> VIEWVRFNAME] */
9609 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9610 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9611 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9613 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9614 /* [<view> VIEWVRFNAME] */
9615 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9617 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9619 return bgp_clear_prefix(
9620 vty
, vrfview
, prefix
,
9621 AFI_IP6
, safi
, NULL
);
9624 DEFUN (show_bgp_views
,
9626 "show [ip] bgp views",
9630 "Show the defined BGP views\n")
9632 struct list
*inst
= bm
->bgp
;
9633 struct listnode
*node
;
9636 vty_out(vty
, "Defined BGP views:\n");
9637 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9639 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9641 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9648 DEFUN (show_bgp_vrfs
,
9650 "show [ip] bgp vrfs [json]",
9657 char buf
[ETHER_ADDR_STRLEN
];
9658 struct list
*inst
= bm
->bgp
;
9659 struct listnode
*node
;
9661 bool uj
= use_json(argc
, argv
);
9662 json_object
*json
= NULL
;
9663 json_object
*json_vrfs
= NULL
;
9667 json
= json_object_new_object();
9668 json_vrfs
= json_object_new_object();
9671 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9672 const char *name
, *type
;
9674 struct listnode
*node2
, *nnode2
;
9675 int peers_cfg
, peers_estb
;
9676 json_object
*json_vrf
= NULL
;
9679 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9683 if (!uj
&& count
== 1) {
9685 "%4s %-5s %-16s %9s %10s %-37s\n",
9686 "Type", "Id", "routerId", "#PeersCfg",
9687 "#PeersEstb", "Name");
9688 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9689 "L3-VNI", "RouterMAC", "Interface");
9692 peers_cfg
= peers_estb
= 0;
9694 json_vrf
= json_object_new_object();
9697 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9698 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9701 if (peer_established(peer
))
9705 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9706 name
= VRF_DEFAULT_NAME
;
9715 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9717 : (int64_t)bgp
->vrf_id
;
9718 char buf
[BUFSIZ
] = {0};
9720 json_object_string_add(json_vrf
, "type", type
);
9721 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9722 json_object_string_addf(json_vrf
, "routerId", "%pI4",
9724 json_object_int_add(json_vrf
, "numConfiguredPeers",
9726 json_object_int_add(json_vrf
, "numEstablishedPeers",
9729 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9730 json_object_string_add(
9732 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9733 json_object_string_add(json_vrf
, "interface",
9734 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9736 json_object_object_add(json_vrfs
, name
, json_vrf
);
9738 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
9740 bgp
->vrf_id
== VRF_UNKNOWN
? -1
9742 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
9743 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
9745 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
9746 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9752 json_object_object_add(json
, "vrfs", json_vrfs
);
9754 json_object_int_add(json
, "totalVrfs", count
);
9756 vty_json(vty
, json
);
9760 "\nTotal number of VRFs (including default): %d\n",
9767 DEFUN (show_bgp_mac_hash
,
9768 show_bgp_mac_hash_cmd
,
9769 "show bgp mac hash",
9773 "Mac Address database\n")
9775 bgp_mac_dump_table(vty
);
9780 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
9782 struct vty
*vty
= (struct vty
*)args
;
9783 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
9785 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
9788 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
9790 vty_out(vty
, "self nexthop database:\n");
9791 bgp_nexthop_show_address_hash(vty
, bgp
);
9793 vty_out(vty
, "Tunnel-ip database:\n");
9794 hash_iterate(bgp
->tip_hash
,
9795 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
9799 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
9800 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
9801 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
9802 "martian next-hops\n"
9803 "martian next-hop database\n")
9805 struct bgp
*bgp
= NULL
;
9809 /* [<vrf> VIEWVRFNAME] */
9810 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9811 name
= argv
[idx
+ 1]->arg
;
9812 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
9814 } else if (argv_find(argv
, argc
, "view", &idx
))
9815 /* [<view> VIEWVRFNAME] */
9816 name
= argv
[idx
+ 1]->arg
;
9818 bgp
= bgp_lookup_by_name(name
);
9820 bgp
= bgp_get_default();
9823 vty_out(vty
, "%% No BGP process is configured\n");
9826 bgp_show_martian_nexthops(vty
, bgp
);
9831 DEFUN (show_bgp_memory
,
9832 show_bgp_memory_cmd
,
9833 "show [ip] bgp memory",
9837 "Global BGP memory statistics\n")
9839 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9840 unsigned long count
;
9842 /* RIB related usage stats */
9843 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
9844 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
9845 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9846 count
* sizeof(struct bgp_dest
)));
9848 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
9849 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
9850 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9851 count
* sizeof(struct bgp_path_info
)));
9852 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
9853 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
9856 memstrbuf
, sizeof(memstrbuf
),
9857 count
* sizeof(struct bgp_path_info_extra
)));
9859 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
9860 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
9861 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9862 count
* sizeof(struct bgp_static
)));
9864 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
9865 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
9866 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9867 count
* sizeof(struct bpacket
)));
9870 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
9871 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
9872 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9873 count
* sizeof(struct bgp_adj_in
)));
9874 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
9875 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
9876 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9877 count
* sizeof(struct bgp_adj_out
)));
9879 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
9880 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
9882 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9883 count
* sizeof(struct bgp_nexthop_cache
)));
9885 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
9886 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
9888 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9889 count
* sizeof(struct bgp_damp_info
)));
9892 count
= attr_count();
9893 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
9894 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9895 count
* sizeof(struct attr
)));
9897 if ((count
= attr_unknown_count()))
9898 vty_out(vty
, "%ld unknown attributes\n", count
);
9900 /* AS_PATH attributes */
9901 count
= aspath_count();
9902 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
9903 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9904 count
* sizeof(struct aspath
)));
9906 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
9907 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
9908 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9909 count
* sizeof(struct assegment
)));
9911 /* Other attributes */
9912 if ((count
= community_count()))
9913 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9914 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9915 count
* sizeof(struct community
)));
9916 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
9917 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9918 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9919 count
* sizeof(struct ecommunity
)));
9920 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
9922 "%ld BGP large-community entries, using %s of memory\n",
9923 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9924 count
* sizeof(struct lcommunity
)));
9926 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
9927 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
9928 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9929 count
* sizeof(struct cluster_list
)));
9931 /* Peer related usage */
9932 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
9933 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
9934 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9935 count
* sizeof(struct peer
)));
9937 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
9938 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
9939 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9940 count
* sizeof(struct peer_group
)));
9943 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
9944 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
9945 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9946 count
* sizeof(regex_t
)));
9950 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
9952 json_object
*bestpath
= json_object_new_object();
9954 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
9955 json_object_string_add(bestpath
, "asPath", "ignore");
9957 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
9958 json_object_string_add(bestpath
, "asPath", "confed");
9960 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
9961 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
9962 json_object_string_add(bestpath
, "multiPathRelax",
9965 json_object_string_add(bestpath
, "multiPathRelax",
9968 json_object_string_add(bestpath
, "multiPathRelax", "false");
9970 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
9971 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
9973 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
9974 json_object_string_add(bestpath
, "compareRouterId", "true");
9975 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
9976 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
9977 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
9978 json_object_string_add(bestpath
, "med", "confed");
9979 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
9980 json_object_string_add(bestpath
, "med",
9981 "missing-as-worst");
9983 json_object_string_add(bestpath
, "med", "true");
9986 json_object_object_add(json
, "bestPath", bestpath
);
9989 /* Print the error code/subcode for why the peer is down */
9990 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
9991 json_object
*json_peer
, bool use_json
)
9993 const char *code_str
;
9994 const char *subcode_str
;
9997 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9998 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9999 char errorcodesubcode_hexstr
[5];
10000 char errorcodesubcode_str
[256];
10002 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10003 subcode_str
= bgp_notify_subcode_str(
10005 peer
->notify
.subcode
);
10007 snprintf(errorcodesubcode_hexstr
,
10008 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10009 peer
->notify
.code
, peer
->notify
.subcode
);
10010 json_object_string_add(json_peer
,
10011 "lastErrorCodeSubcode",
10012 errorcodesubcode_hexstr
);
10013 snprintf(errorcodesubcode_str
, 255, "%s%s",
10014 code_str
, subcode_str
);
10015 json_object_string_add(json_peer
,
10016 "lastNotificationReason",
10017 errorcodesubcode_str
);
10018 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10019 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10020 && (peer
->notify
.subcode
10021 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10022 || peer
->notify
.subcode
10023 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10024 && peer
->notify
.length
) {
10026 const char *msg_str
;
10028 msg_str
= bgp_notify_admin_message(
10029 msgbuf
, sizeof(msgbuf
),
10030 (uint8_t *)peer
->notify
.data
,
10031 peer
->notify
.length
);
10033 json_object_string_add(
10035 "lastShutdownDescription",
10040 json_object_string_add(json_peer
, "lastResetDueTo",
10041 peer_down_str
[(int)peer
->last_reset
]);
10042 json_object_int_add(json_peer
, "lastResetCode",
10045 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10046 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10047 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10049 bgp_notify_subcode_str(peer
->notify
.code
,
10050 peer
->notify
.subcode
);
10051 vty_out(vty
, " Notification %s (%s%s)\n",
10052 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10055 code_str
, subcode_str
);
10057 vty_out(vty
, " %s\n",
10058 peer_down_str
[(int)peer
->last_reset
]);
10063 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10066 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10069 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10070 struct peer
*peer
, json_object
*json_peer
,
10071 int max_neighbor_width
, bool use_json
)
10073 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10077 if (peer_dynamic_neighbor(peer
))
10078 json_object_boolean_true_add(json_peer
,
10080 if (peer
->hostname
)
10081 json_object_string_add(json_peer
, "hostname",
10084 if (peer
->domainname
)
10085 json_object_string_add(json_peer
, "domainname",
10087 json_object_int_add(json_peer
, "connectionsEstablished",
10088 peer
->established
);
10089 json_object_int_add(json_peer
, "connectionsDropped",
10091 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10092 use_json
, json_peer
);
10093 if (peer_established(peer
))
10094 json_object_string_add(json_peer
, "lastResetDueTo",
10095 "AFI/SAFI Not Negotiated");
10097 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10100 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10102 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10103 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10104 peer
->hostname
, peer
->host
);
10106 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10108 /* pad the neighbor column with spaces */
10109 if (len
< max_neighbor_width
)
10110 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10112 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10114 peer_uptime(peer
->uptime
, timebuf
,
10115 BGP_UPTIME_LEN
, 0, NULL
));
10116 if (peer_established(peer
))
10117 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10119 bgp_show_peer_reset(vty
, peer
, NULL
,
10124 /* Strip peer's description to the given size. */
10125 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10127 static char stripped
[BUFSIZ
];
10128 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10130 strlcpy(stripped
, desc
, len
+ 1);
10135 /* Determine whether var peer should be filtered out of the summary. */
10136 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10137 struct peer
*fpeer
, int as_type
,
10141 /* filter neighbor XXXX */
10142 if (fpeer
&& fpeer
!= peer
)
10145 /* filter remote-as (internal|external) */
10146 if (as_type
!= AS_UNSPECIFIED
) {
10147 if (peer
->as_type
== AS_SPECIFIED
) {
10148 if (as_type
== AS_INTERNAL
) {
10149 if (peer
->as
!= peer
->local_as
)
10151 } else if (peer
->as
== peer
->local_as
)
10153 } else if (as_type
!= peer
->as_type
)
10155 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10161 /* Show BGP peer's summary information.
10163 * Peer's description is stripped according to if `wide` option is given
10166 * When adding new columns to `show bgp summary` output, please make
10167 * sure `Desc` is the lastest column to show because it can contain
10168 * whitespaces and the whole output will be tricky.
10170 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10171 struct peer
*fpeer
, int as_type
, as_t as
,
10172 uint16_t show_flags
)
10175 struct listnode
*node
, *nnode
;
10176 unsigned int count
= 0, dn_count
= 0;
10177 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10178 char neighbor_buf
[VTY_BUFSIZ
];
10179 int neighbor_col_default_width
= 16;
10180 int len
, failed_count
= 0;
10181 unsigned int filtered_count
= 0;
10182 int max_neighbor_width
= 0;
10184 json_object
*json
= NULL
;
10185 json_object
*json_peer
= NULL
;
10186 json_object
*json_peers
= NULL
;
10187 struct peer_af
*paf
;
10188 struct bgp_filter
*filter
;
10189 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10190 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10191 bool show_established
=
10192 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10193 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10194 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10196 /* labeled-unicast routes are installed in the unicast table so in order
10198 * display the correct PfxRcd value we must look at SAFI_UNICAST
10201 if (safi
== SAFI_LABELED_UNICAST
)
10202 pfx_rcd_safi
= SAFI_UNICAST
;
10204 pfx_rcd_safi
= safi
;
10207 json
= json_object_new_object();
10208 json_peers
= json_object_new_object();
10209 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10210 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10217 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10220 if (peer
->afc
[afi
][safi
]) {
10221 /* See if we have at least a single failed peer */
10222 if (bgp_has_peer_failed(peer
, afi
, safi
))
10226 if (peer_dynamic_neighbor(peer
))
10231 /* Loop over all neighbors that will be displayed to determine
10233 * characters are needed for the Neighbor column
10235 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10236 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10243 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10246 if (peer
->afc
[afi
][safi
]) {
10247 memset(dn_flag
, '\0', sizeof(dn_flag
));
10248 if (peer_dynamic_neighbor(peer
))
10252 && CHECK_FLAG(bgp
->flags
,
10253 BGP_FLAG_SHOW_HOSTNAME
))
10254 snprintf(neighbor_buf
,
10255 sizeof(neighbor_buf
),
10256 "%s%s(%s) ", dn_flag
,
10257 peer
->hostname
, peer
->host
);
10259 snprintf(neighbor_buf
,
10260 sizeof(neighbor_buf
), "%s%s ",
10261 dn_flag
, peer
->host
);
10263 len
= strlen(neighbor_buf
);
10265 if (len
> max_neighbor_width
)
10266 max_neighbor_width
= len
;
10268 /* See if we have at least a single failed peer */
10269 if (bgp_has_peer_failed(peer
, afi
, safi
))
10275 /* Originally we displayed the Neighbor column as 16
10276 * characters wide so make that the default
10278 if (max_neighbor_width
< neighbor_col_default_width
)
10279 max_neighbor_width
= neighbor_col_default_width
;
10282 if (show_failed
&& !failed_count
) {
10284 json_object_int_add(json
, "failedPeersCount", 0);
10285 json_object_int_add(json
, "dynamicPeers", dn_count
);
10286 json_object_int_add(json
, "totalPeers", count
);
10288 vty_json(vty
, json
);
10290 vty_out(vty
, "%% No failed BGP neighbors found\n");
10292 return CMD_SUCCESS
;
10295 count
= 0; /* Reset the value as its used again */
10296 filtered_count
= 0;
10298 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10299 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10302 if (!peer
->afc
[afi
][safi
])
10306 unsigned long ents
;
10307 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10310 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10312 : (int64_t)bgp
->vrf_id
;
10314 /* Usage summary and header */
10316 json_object_string_addf(json
, "routerId",
10319 json_object_int_add(json
, "as", bgp
->as
);
10320 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10321 json_object_string_add(
10324 == BGP_INSTANCE_TYPE_DEFAULT
)
10329 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10330 &bgp
->router_id
, bgp
->as
,
10331 bgp
->vrf_id
== VRF_UNKNOWN
10333 : (int)bgp
->vrf_id
);
10334 vty_out(vty
, "\n");
10337 if (bgp_update_delay_configured(bgp
)) {
10339 json_object_int_add(
10340 json
, "updateDelayLimit",
10341 bgp
->v_update_delay
);
10343 if (bgp
->v_update_delay
10344 != bgp
->v_establish_wait
)
10345 json_object_int_add(
10347 "updateDelayEstablishWait",
10348 bgp
->v_establish_wait
);
10350 if (bgp_update_delay_active(bgp
)) {
10351 json_object_string_add(
10353 "updateDelayFirstNeighbor",
10354 bgp
->update_delay_begin_time
);
10355 json_object_boolean_true_add(
10357 "updateDelayInProgress");
10359 if (bgp
->update_delay_over
) {
10360 json_object_string_add(
10362 "updateDelayFirstNeighbor",
10363 bgp
->update_delay_begin_time
);
10364 json_object_string_add(
10366 "updateDelayBestpathResumed",
10367 bgp
->update_delay_end_time
);
10368 json_object_string_add(
10370 "updateDelayZebraUpdateResume",
10371 bgp
->update_delay_zebra_resume_time
);
10372 json_object_string_add(
10374 "updateDelayPeerUpdateResume",
10375 bgp
->update_delay_peers_resume_time
);
10380 "Read-only mode update-delay limit: %d seconds\n",
10381 bgp
->v_update_delay
);
10382 if (bgp
->v_update_delay
10383 != bgp
->v_establish_wait
)
10385 " Establish wait: %d seconds\n",
10386 bgp
->v_establish_wait
);
10388 if (bgp_update_delay_active(bgp
)) {
10390 " First neighbor established: %s\n",
10391 bgp
->update_delay_begin_time
);
10393 " Delay in progress\n");
10395 if (bgp
->update_delay_over
) {
10397 " First neighbor established: %s\n",
10398 bgp
->update_delay_begin_time
);
10400 " Best-paths resumed: %s\n",
10401 bgp
->update_delay_end_time
);
10403 " zebra update resumed: %s\n",
10404 bgp
->update_delay_zebra_resume_time
);
10406 " peers update resumed: %s\n",
10407 bgp
->update_delay_peers_resume_time
);
10414 if (bgp_maxmed_onstartup_configured(bgp
)
10415 && bgp
->maxmed_active
)
10416 json_object_boolean_true_add(
10417 json
, "maxMedOnStartup");
10418 if (bgp
->v_maxmed_admin
)
10419 json_object_boolean_true_add(
10420 json
, "maxMedAdministrative");
10422 json_object_int_add(
10423 json
, "tableVersion",
10424 bgp_table_version(bgp
->rib
[afi
][safi
]));
10426 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10427 json_object_int_add(json
, "ribCount", ents
);
10428 json_object_int_add(
10430 ents
* sizeof(struct bgp_dest
));
10432 ents
= bgp
->af_peer_count
[afi
][safi
];
10433 json_object_int_add(json
, "peerCount", ents
);
10434 json_object_int_add(json
, "peerMemory",
10435 ents
* sizeof(struct peer
));
10437 if ((ents
= listcount(bgp
->group
))) {
10438 json_object_int_add(
10439 json
, "peerGroupCount", ents
);
10440 json_object_int_add(
10441 json
, "peerGroupMemory",
10442 ents
* sizeof(struct
10446 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10447 BGP_CONFIG_DAMPENING
))
10448 json_object_boolean_true_add(
10449 json
, "dampeningEnabled");
10452 if (bgp_maxmed_onstartup_configured(bgp
)
10453 && bgp
->maxmed_active
)
10455 "Max-med on-startup active\n");
10456 if (bgp
->v_maxmed_admin
)
10458 "Max-med administrative active\n");
10461 "BGP table version %" PRIu64
10464 bgp
->rib
[afi
][safi
]));
10466 ents
= bgp_table_count(
10467 bgp
->rib
[afi
][safi
]);
10469 "RIB entries %ld, using %s of memory\n",
10479 /* Peer related usage */
10480 ents
= bgp
->af_peer_count
[afi
][safi
];
10482 "Peers %ld, using %s of memory\n",
10492 if ((ents
= listcount(bgp
->group
)))
10494 "Peer groups %ld, using %s of memory\n",
10504 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10505 BGP_CONFIG_DAMPENING
))
10507 "Dampening enabled.\n");
10510 vty_out(vty
, "\n");
10512 /* Subtract 8 here because 'Neighbor' is
10514 vty_out(vty
, "Neighbor");
10515 vty_out(vty
, "%*s",
10516 max_neighbor_width
- 8, " ");
10518 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10523 paf
= peer_af_find(peer
, afi
, safi
);
10524 filter
= &peer
->filter
[afi
][safi
];
10527 /* Works for both failed & successful cases */
10528 if (peer_dynamic_neighbor(peer
))
10533 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10539 bgp_has_peer_failed(peer
, afi
, safi
)) {
10540 json_peer
= json_object_new_object();
10541 bgp_show_failed_summary(vty
, bgp
, peer
,
10542 json_peer
, 0, use_json
);
10543 } else if (!show_failed
) {
10544 if (show_established
10545 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10550 json_peer
= json_object_new_object();
10551 if (peer_dynamic_neighbor(peer
)) {
10552 json_object_boolean_true_add(json_peer
,
10556 if (peer
->hostname
)
10557 json_object_string_add(json_peer
, "hostname",
10560 if (peer
->domainname
)
10561 json_object_string_add(json_peer
, "domainname",
10564 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10565 json_object_int_add(
10566 json_peer
, "localAs",
10567 peer
->change_local_as
10568 ? peer
->change_local_as
10570 json_object_int_add(json_peer
, "version", 4);
10571 json_object_int_add(json_peer
, "msgRcvd",
10572 PEER_TOTAL_RX(peer
));
10573 json_object_int_add(json_peer
, "msgSent",
10574 PEER_TOTAL_TX(peer
));
10576 atomic_size_t outq_count
, inq_count
;
10577 outq_count
= atomic_load_explicit(
10578 &peer
->obuf
->count
,
10579 memory_order_relaxed
);
10580 inq_count
= atomic_load_explicit(
10581 &peer
->ibuf
->count
,
10582 memory_order_relaxed
);
10584 json_object_int_add(json_peer
, "tableVersion",
10585 peer
->version
[afi
][safi
]);
10586 json_object_int_add(json_peer
, "outq",
10588 json_object_int_add(json_peer
, "inq",
10590 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10591 use_json
, json_peer
);
10593 json_object_int_add(json_peer
, "pfxRcd",
10594 peer
->pcount
[afi
][pfx_rcd_safi
]);
10596 if (paf
&& PAF_SUBGRP(paf
))
10597 json_object_int_add(
10598 json_peer
, "pfxSnt",
10599 (PAF_SUBGRP(paf
))->scount
);
10601 json_object_int_add(json_peer
, "pfxSnt",
10604 /* BGP FSM state */
10605 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10606 || CHECK_FLAG(peer
->bgp
->flags
,
10607 BGP_FLAG_SHUTDOWN
))
10608 json_object_string_add(json_peer
,
10611 else if (peer
->afc_recv
[afi
][safi
])
10612 json_object_string_add(
10613 json_peer
, "state",
10614 lookup_msg(bgp_status_msg
,
10615 peer
->status
, NULL
));
10616 else if (CHECK_FLAG(
10618 PEER_STATUS_PREFIX_OVERFLOW
))
10619 json_object_string_add(json_peer
,
10623 json_object_string_add(
10624 json_peer
, "state",
10625 lookup_msg(bgp_status_msg
,
10626 peer
->status
, NULL
));
10628 /* BGP peer state */
10629 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10630 || CHECK_FLAG(peer
->bgp
->flags
,
10631 BGP_FLAG_SHUTDOWN
))
10632 json_object_string_add(json_peer
,
10635 else if (CHECK_FLAG(
10637 PEER_STATUS_PREFIX_OVERFLOW
))
10638 json_object_string_add(json_peer
,
10641 else if (CHECK_FLAG(peer
->flags
,
10642 PEER_FLAG_PASSIVE
))
10643 json_object_string_add(json_peer
,
10646 else if (CHECK_FLAG(peer
->sflags
,
10647 PEER_STATUS_NSF_WAIT
))
10648 json_object_string_add(json_peer
,
10651 else if (CHECK_FLAG(
10653 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10654 && (!bgp_inbound_policy_exists(peer
,
10656 || !bgp_outbound_policy_exists(
10658 json_object_string_add(json_peer
,
10662 json_object_string_add(
10663 json_peer
, "peerState", "OK");
10665 json_object_int_add(json_peer
, "connectionsEstablished",
10666 peer
->established
);
10667 json_object_int_add(json_peer
, "connectionsDropped",
10670 json_object_string_add(
10671 json_peer
, "desc", peer
->desc
);
10673 /* Avoid creating empty peer dicts in JSON */
10674 if (json_peer
== NULL
)
10678 json_object_string_add(json_peer
, "idType",
10680 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10681 json_object_string_add(json_peer
, "idType",
10683 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10684 json_object_string_add(json_peer
, "idType",
10686 json_object_object_add(json_peers
, peer
->host
,
10689 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10695 bgp_has_peer_failed(peer
, afi
, safi
)) {
10696 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10697 max_neighbor_width
,
10699 } else if (!show_failed
) {
10700 if (show_established
10701 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10706 if ((count
- filtered_count
) == 1) {
10707 /* display headline before the first
10709 vty_out(vty
, "\n");
10711 /* Subtract 8 here because 'Neighbor' is
10713 vty_out(vty
, "Neighbor");
10714 vty_out(vty
, "%*s",
10715 max_neighbor_width
- 8, " ");
10718 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10719 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10722 memset(dn_flag
, '\0', sizeof(dn_flag
));
10723 if (peer_dynamic_neighbor(peer
)) {
10728 && CHECK_FLAG(bgp
->flags
,
10729 BGP_FLAG_SHOW_HOSTNAME
))
10730 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10734 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10736 /* pad the neighbor column with spaces */
10737 if (len
< max_neighbor_width
)
10738 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10741 atomic_size_t outq_count
, inq_count
;
10742 outq_count
= atomic_load_explicit(
10743 &peer
->obuf
->count
,
10744 memory_order_relaxed
);
10745 inq_count
= atomic_load_explicit(
10746 &peer
->ibuf
->count
,
10747 memory_order_relaxed
);
10751 "4 %10u %10u %9u %9u %8" PRIu64
10754 peer
->change_local_as
10755 ? peer
->change_local_as
10757 PEER_TOTAL_RX(peer
),
10758 PEER_TOTAL_TX(peer
),
10759 peer
->version
[afi
][safi
],
10760 inq_count
, outq_count
,
10761 peer_uptime(peer
->uptime
,
10766 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
10768 peer
->as
, PEER_TOTAL_RX(peer
),
10769 PEER_TOTAL_TX(peer
),
10770 peer
->version
[afi
][safi
],
10771 inq_count
, outq_count
,
10772 peer_uptime(peer
->uptime
,
10777 if (peer_established(peer
)) {
10778 if (peer
->afc_recv
[afi
][safi
]) {
10781 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10782 && !bgp_inbound_policy_exists(
10784 vty_out(vty
, " %12s",
10793 vty_out(vty
, " NoNeg");
10796 if (paf
&& PAF_SUBGRP(paf
)) {
10799 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10800 && !bgp_outbound_policy_exists(
10802 vty_out(vty
, " %8s",
10811 vty_out(vty
, " NoNeg");
10814 if (CHECK_FLAG(peer
->flags
,
10815 PEER_FLAG_SHUTDOWN
)
10816 || CHECK_FLAG(peer
->bgp
->flags
,
10817 BGP_FLAG_SHUTDOWN
))
10818 vty_out(vty
, " Idle (Admin)");
10819 else if (CHECK_FLAG(
10821 PEER_STATUS_PREFIX_OVERFLOW
))
10822 vty_out(vty
, " Idle (PfxCt)");
10824 vty_out(vty
, " %12s",
10825 lookup_msg(bgp_status_msg
,
10826 peer
->status
, NULL
));
10828 vty_out(vty
, " %8u", 0);
10830 /* Make sure `Desc` column is the lastest in
10834 vty_out(vty
, " %s",
10835 bgp_peer_description_stripped(
10837 show_wide
? 64 : 20));
10839 vty_out(vty
, " N/A");
10840 vty_out(vty
, "\n");
10847 json_object_object_add(json
, "peers", json_peers
);
10848 json_object_int_add(json
, "failedPeers", failed_count
);
10849 json_object_int_add(json
, "displayedPeers",
10850 count
- filtered_count
);
10851 json_object_int_add(json
, "totalPeers", count
);
10852 json_object_int_add(json
, "dynamicPeers", dn_count
);
10855 bgp_show_bestpath_json(bgp
, json
);
10857 vty_json(vty
, json
);
10860 if (filtered_count
== count
)
10861 vty_out(vty
, "\n%% No matching neighbor\n");
10864 vty_out(vty
, "\nDisplayed neighbors %d",
10866 else if (as_type
!= AS_UNSPECIFIED
|| as
10867 || fpeer
|| show_established
)
10868 vty_out(vty
, "\nDisplayed neighbors %d",
10869 count
- filtered_count
);
10871 vty_out(vty
, "\nTotal number of neighbors %d\n",
10875 vty_out(vty
, "No %s neighbor is configured\n",
10876 get_afi_safi_str(afi
, safi
, false));
10880 vty_out(vty
, "* - dynamic neighbor\n");
10881 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
10882 dn_count
, bgp
->dynamic_neighbors_limit
);
10886 return CMD_SUCCESS
;
10889 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
10890 int safi
, struct peer
*fpeer
, int as_type
,
10891 as_t as
, uint16_t show_flags
)
10894 int afi_wildcard
= (afi
== AFI_MAX
);
10895 int safi_wildcard
= (safi
== SAFI_MAX
);
10896 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
10897 bool nbr_output
= false;
10898 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10900 if (use_json
&& is_wildcard
)
10901 vty_out(vty
, "{\n");
10903 afi
= 1; /* AFI_IP */
10904 while (afi
< AFI_MAX
) {
10906 safi
= 1; /* SAFI_UNICAST */
10907 while (safi
< SAFI_MAX
) {
10908 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
10913 * So limit output to those afi/safi
10915 * actualy have something interesting in
10920 vty_out(vty
, ",\n");
10924 vty_out(vty
, "\"%s\":",
10925 get_afi_safi_str(afi
,
10930 "\n%s Summary (%s):\n",
10931 get_afi_safi_str(afi
,
10937 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
10938 as_type
, as
, show_flags
);
10941 if (!safi_wildcard
)
10949 if (use_json
&& is_wildcard
)
10950 vty_out(vty
, "}\n");
10951 else if (!nbr_output
) {
10953 vty_out(vty
, "{}\n");
10955 vty_out(vty
, "%% No BGP neighbors found in %s\n",
10960 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
10962 const char *neighbor
,
10963 int as_type
, as_t as
,
10964 uint16_t show_flags
)
10966 struct listnode
*node
, *nnode
;
10968 struct peer
*fpeer
= NULL
;
10970 bool nbr_output
= false;
10971 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10974 vty_out(vty
, "{\n");
10976 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10980 vty_out(vty
, ",\n");
10984 vty_out(vty
, "\"%s\":",
10985 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10990 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
10995 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11000 vty_out(vty
, "}\n");
11001 else if (!nbr_output
)
11002 vty_out(vty
, "%% BGP instance not found\n");
11005 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11006 safi_t safi
, const char *neighbor
, int as_type
,
11007 as_t as
, uint16_t show_flags
)
11010 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11011 struct peer
*fpeer
= NULL
;
11014 if (strmatch(name
, "all")) {
11015 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11018 return CMD_SUCCESS
;
11020 bgp
= bgp_lookup_by_name(name
);
11024 vty_out(vty
, "{}\n");
11027 "%% BGP instance not found\n");
11028 return CMD_WARNING
;
11032 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11035 return CMD_WARNING
;
11037 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11038 as_type
, as
, show_flags
);
11039 return CMD_SUCCESS
;
11043 bgp
= bgp_get_default();
11047 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11050 return CMD_WARNING
;
11052 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11056 vty_out(vty
, "{}\n");
11058 vty_out(vty
, "%% BGP instance not found\n");
11059 return CMD_WARNING
;
11062 return CMD_SUCCESS
;
11065 /* `show [ip] bgp summary' commands. */
11066 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11067 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11068 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11069 "]] [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]",
11070 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11071 BGP_SAFI_WITH_LABEL_HELP_STR
11072 "Display the entries for all address families\n"
11073 "Summary of BGP neighbor status\n"
11074 "Show only sessions in Established state\n"
11075 "Show only sessions not in Established state\n"
11076 "Show only the specified neighbor session\n"
11077 "Neighbor to display information about\n"
11078 "Neighbor to display information about\n"
11079 "Neighbor on BGP configured interface\n"
11080 "Show only the specified remote AS sessions\n"
11082 "Internal (iBGP) AS sessions\n"
11083 "External (eBGP) AS sessions\n"
11084 "Shorten the information on BGP instances\n"
11085 "Increase table width for longer output\n" JSON_STR
)
11088 afi_t afi
= AFI_MAX
;
11089 safi_t safi
= SAFI_MAX
;
11090 as_t as
= 0; /* 0 means AS filter not set */
11091 int as_type
= AS_UNSPECIFIED
;
11092 uint16_t show_flags
= 0;
11096 /* show [ip] bgp */
11097 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11099 /* [<vrf> VIEWVRFNAME] */
11100 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11101 vrf
= argv
[idx
+ 1]->arg
;
11102 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11104 } else if (argv_find(argv
, argc
, "view", &idx
))
11105 /* [<view> VIEWVRFNAME] */
11106 vrf
= argv
[idx
+ 1]->arg
;
11107 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11108 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11109 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11112 if (argv_find(argv
, argc
, "failed", &idx
))
11113 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11115 if (argv_find(argv
, argc
, "established", &idx
))
11116 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11118 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11119 if (argv
[idx
+ 1]->arg
[0] == 'i')
11120 as_type
= AS_INTERNAL
;
11121 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11122 as_type
= AS_EXTERNAL
;
11124 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11127 if (argv_find(argv
, argc
, "terse", &idx
))
11128 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11130 if (argv_find(argv
, argc
, "wide", &idx
))
11131 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11133 if (argv_find(argv
, argc
, "json", &idx
))
11134 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11136 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11140 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11143 return get_afi_safi_json_str(afi
, safi
);
11145 return get_afi_safi_vty_str(afi
, safi
);
11149 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11150 afi_t afi
, safi_t safi
,
11151 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11152 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11153 bool use_json
, json_object
*json_pref
)
11156 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11157 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11159 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11160 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11161 json_object_string_add(json_pref
, "sendMode",
11162 "advertisedAndReceived");
11163 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11164 json_object_string_add(json_pref
, "sendMode",
11166 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11167 json_object_string_add(json_pref
, "sendMode",
11170 vty_out(vty
, " Send-mode: ");
11171 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11172 vty_out(vty
, "advertised");
11173 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11174 vty_out(vty
, "%sreceived",
11175 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11179 vty_out(vty
, "\n");
11184 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11185 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11187 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11188 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11189 json_object_string_add(json_pref
, "recvMode",
11190 "advertisedAndReceived");
11191 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11192 json_object_string_add(json_pref
, "recvMode",
11194 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11195 json_object_string_add(json_pref
, "recvMode",
11198 vty_out(vty
, " Receive-mode: ");
11199 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11200 vty_out(vty
, "advertised");
11201 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11202 vty_out(vty
, "%sreceived",
11203 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11207 vty_out(vty
, "\n");
11212 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11217 bool rbit_status
= false;
11220 vty_out(vty
, "\n R bit: ");
11222 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11223 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11224 && (peer_established(p
))) {
11226 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11227 rbit_status
= true;
11229 rbit_status
= false;
11234 json_object_boolean_true_add(json
, "rBit");
11236 vty_out(vty
, "True\n");
11239 json_object_boolean_false_add(json
, "rBit");
11241 vty_out(vty
, "False\n");
11245 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11250 const char *mode
= "NotApplicable";
11253 vty_out(vty
, "\n Remote GR Mode: ");
11255 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11256 && (peer_established(peer
))) {
11258 if ((peer
->nsf_af_count
== 0)
11259 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11263 } else if (peer
->nsf_af_count
== 0
11264 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11268 } else if (peer
->nsf_af_count
!= 0
11269 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11276 json_object_string_add(json
, "remoteGrMode", mode
);
11278 vty_out(vty
, mode
, "\n");
11281 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11286 const char *mode
= "Invalid";
11289 vty_out(vty
, " Local GR Mode: ");
11291 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11293 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11295 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11297 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11298 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11300 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11302 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11309 json_object_string_add(json
, "localGrMode", mode
);
11311 vty_out(vty
, mode
, "\n");
11315 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11316 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11320 json_object
*json_afi_safi
= NULL
;
11321 json_object
*json_timer
= NULL
;
11322 json_object
*json_endofrib_status
= NULL
;
11323 bool eor_flag
= false;
11325 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11326 if (!peer
->afc
[afi
][safi
])
11329 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11330 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11334 json_afi_safi
= json_object_new_object();
11335 json_endofrib_status
= json_object_new_object();
11336 json_timer
= json_object_new_object();
11339 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11345 vty_out(vty
, " %s:\n",
11346 get_afi_safi_str(afi
, safi
, false));
11348 vty_out(vty
, " F bit: ");
11351 if (peer
->nsf
[afi
][safi
] &&
11352 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11353 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11356 json_object_boolean_true_add(json_afi_safi
,
11359 vty_out(vty
, "True\n");
11362 json_object_boolean_false_add(json_afi_safi
,
11365 vty_out(vty
, "False\n");
11369 vty_out(vty
, " End-of-RIB sent: ");
11371 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11372 PEER_STATUS_EOR_SEND
)) {
11374 json_object_boolean_true_add(
11375 json_endofrib_status
, "endOfRibSend");
11377 PRINT_EOR_JSON(eor_flag
);
11379 vty_out(vty
, "Yes\n");
11381 " End-of-RIB sent after update: ");
11383 PRINT_EOR(eor_flag
);
11387 json_object_boolean_false_add(
11388 json_endofrib_status
, "endOfRibSend");
11389 json_object_boolean_false_add(
11390 json_endofrib_status
,
11391 "endOfRibSentAfterUpdate");
11393 vty_out(vty
, "No\n");
11395 " End-of-RIB sent after update: ");
11396 vty_out(vty
, "No\n");
11401 vty_out(vty
, " End-of-RIB received: ");
11403 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11404 PEER_STATUS_EOR_RECEIVED
)) {
11406 json_object_boolean_true_add(
11407 json_endofrib_status
, "endOfRibRecv");
11409 vty_out(vty
, "Yes\n");
11412 json_object_boolean_false_add(
11413 json_endofrib_status
, "endOfRibRecv");
11415 vty_out(vty
, "No\n");
11419 json_object_int_add(json_timer
, "stalePathTimer",
11420 peer
->bgp
->stalepath_time
);
11422 if (peer
->t_gr_stale
!= NULL
) {
11423 json_object_int_add(json_timer
,
11424 "stalePathTimerRemaining",
11425 thread_timer_remain_second(
11426 peer
->t_gr_stale
));
11429 /* Display Configured Selection
11430 * Deferral only when when
11431 * Gr mode is enabled.
11433 if (CHECK_FLAG(peer
->flags
,
11434 PEER_FLAG_GRACEFUL_RESTART
)) {
11435 json_object_int_add(json_timer
,
11436 "selectionDeferralTimer",
11437 peer
->bgp
->stalepath_time
);
11440 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11443 json_object_int_add(
11445 "selectionDeferralTimerRemaining",
11446 thread_timer_remain_second(
11447 peer
->bgp
->gr_info
[afi
][safi
]
11448 .t_select_deferral
));
11451 vty_out(vty
, " Timers:\n");
11453 " Configured Stale Path Time(sec): %u\n",
11454 peer
->bgp
->stalepath_time
);
11456 if (peer
->t_gr_stale
!= NULL
)
11458 " Stale Path Remaining(sec): %ld\n",
11459 thread_timer_remain_second(
11460 peer
->t_gr_stale
));
11461 /* Display Configured Selection
11462 * Deferral only when when
11463 * Gr mode is enabled.
11465 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11467 " Configured Selection Deferral Time(sec): %u\n",
11468 peer
->bgp
->select_defer_time
);
11470 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11473 " Selection Deferral Time Remaining(sec): %ld\n",
11474 thread_timer_remain_second(
11475 peer
->bgp
->gr_info
[afi
][safi
]
11476 .t_select_deferral
));
11479 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11480 json_endofrib_status
);
11481 json_object_object_add(json_afi_safi
, "timers",
11483 json_object_object_add(
11484 json
, get_afi_safi_str(afi
, safi
, true),
11490 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11496 json_object
*json_timer
= NULL
;
11498 json_timer
= json_object_new_object();
11500 json_object_int_add(json_timer
, "configuredRestartTimer",
11501 p
->bgp
->restart_time
);
11503 json_object_int_add(json_timer
, "receivedRestartTimer",
11506 if (p
->t_gr_restart
!= NULL
)
11507 json_object_int_add(
11508 json_timer
, "restartTimerRemaining",
11509 thread_timer_remain_second(p
->t_gr_restart
));
11511 json_object_object_add(json
, "timers", json_timer
);
11514 vty_out(vty
, " Timers:\n");
11515 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11516 p
->bgp
->restart_time
);
11518 vty_out(vty
, " Received Restart Time(sec): %u\n",
11520 if (p
->t_gr_restart
!= NULL
)
11521 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11522 thread_timer_remain_second(p
->t_gr_restart
));
11523 if (p
->t_gr_restart
!= NULL
) {
11524 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11525 thread_timer_remain_second(p
->t_gr_restart
));
11530 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11531 bool use_json
, json_object
*json
)
11533 char buf
[SU_ADDRSTRLEN
] = {0};
11534 char dn_flag
[2] = {0};
11535 /* '*' + v6 address of neighbor */
11536 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11538 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11543 json_object_string_add(
11544 json
, "neighborAddr",
11545 BGP_PEER_SU_UNSPEC(p
)
11547 : sockunion2str(&p
->su
, buf
,
11550 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11551 BGP_PEER_SU_UNSPEC(p
)
11553 : sockunion2str(&p
->su
, buf
,
11556 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11560 json_object_string_add(json
, "neighborAddr",
11563 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11566 /* more gr info in new format */
11567 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11570 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11571 safi_t safi
, bool use_json
,
11572 json_object
*json_neigh
)
11574 struct bgp_filter
*filter
;
11575 struct peer_af
*paf
;
11576 char orf_pfx_name
[BUFSIZ
];
11578 json_object
*json_af
= NULL
;
11579 json_object
*json_prefA
= NULL
;
11580 json_object
*json_prefB
= NULL
;
11581 json_object
*json_addr
= NULL
;
11582 json_object
*json_advmap
= NULL
;
11585 json_addr
= json_object_new_object();
11586 json_af
= json_object_new_object();
11587 filter
= &p
->filter
[afi
][safi
];
11589 if (peer_group_active(p
))
11590 json_object_string_add(json_addr
, "peerGroupMember",
11593 paf
= peer_af_find(p
, afi
, safi
);
11594 if (paf
&& PAF_SUBGRP(paf
)) {
11595 json_object_int_add(json_addr
, "updateGroupId",
11596 PAF_UPDGRP(paf
)->id
);
11597 json_object_int_add(json_addr
, "subGroupId",
11598 PAF_SUBGRP(paf
)->id
);
11599 json_object_int_add(json_addr
, "packetQueueLength",
11600 bpacket_queue_virtual_length(paf
));
11603 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11604 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11605 PEER_CAP_ORF_PREFIX_SM_RCV
)
11606 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11607 PEER_CAP_ORF_PREFIX_RM_ADV
)
11608 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11609 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11610 json_object_int_add(json_af
, "orfType",
11612 json_prefA
= json_object_new_object();
11613 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11614 PEER_CAP_ORF_PREFIX_SM_ADV
,
11615 PEER_CAP_ORF_PREFIX_RM_ADV
,
11616 PEER_CAP_ORF_PREFIX_SM_RCV
,
11617 PEER_CAP_ORF_PREFIX_RM_RCV
,
11618 use_json
, json_prefA
);
11619 json_object_object_add(json_af
, "orfPrefixList",
11623 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11624 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11625 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11626 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11627 PEER_CAP_ORF_PREFIX_RM_ADV
)
11628 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11629 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11630 json_object_int_add(json_af
, "orfOldType",
11631 ORF_TYPE_PREFIX_OLD
);
11632 json_prefB
= json_object_new_object();
11633 bgp_show_peer_afi_orf_cap(
11634 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11635 PEER_CAP_ORF_PREFIX_RM_ADV
,
11636 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11637 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11639 json_object_object_add(json_af
, "orfOldPrefixList",
11643 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11644 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11645 PEER_CAP_ORF_PREFIX_SM_RCV
)
11646 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11647 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11648 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11649 PEER_CAP_ORF_PREFIX_RM_ADV
)
11650 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11651 PEER_CAP_ORF_PREFIX_RM_RCV
)
11652 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11653 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11654 json_object_object_add(json_addr
, "afDependentCap",
11657 json_object_free(json_af
);
11659 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11660 p
->host
, afi
, safi
);
11661 orf_pfx_count
= prefix_bgp_show_prefix_list(
11662 NULL
, afi
, orf_pfx_name
, use_json
);
11664 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11665 PEER_STATUS_ORF_PREFIX_SEND
)
11666 || orf_pfx_count
) {
11667 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11668 PEER_STATUS_ORF_PREFIX_SEND
))
11669 json_object_boolean_true_add(json_neigh
,
11672 json_object_int_add(json_addr
, "orfRecvCounter",
11675 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11676 PEER_STATUS_ORF_WAIT_REFRESH
))
11677 json_object_string_add(
11678 json_addr
, "orfFirstUpdate",
11679 "deferredUntilORFOrRouteRefreshRecvd");
11681 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11682 PEER_FLAG_REFLECTOR_CLIENT
))
11683 json_object_boolean_true_add(json_addr
,
11684 "routeReflectorClient");
11685 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11686 PEER_FLAG_RSERVER_CLIENT
))
11687 json_object_boolean_true_add(json_addr
,
11688 "routeServerClient");
11689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11690 json_object_boolean_true_add(json_addr
,
11691 "inboundSoftConfigPermit");
11693 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11694 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11695 json_object_boolean_true_add(
11697 "privateAsNumsAllReplacedInUpdatesToNbr");
11698 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11699 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11700 json_object_boolean_true_add(
11702 "privateAsNumsReplacedInUpdatesToNbr");
11703 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11704 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11705 json_object_boolean_true_add(
11707 "privateAsNumsAllRemovedInUpdatesToNbr");
11708 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11709 PEER_FLAG_REMOVE_PRIVATE_AS
))
11710 json_object_boolean_true_add(
11712 "privateAsNumsRemovedInUpdatesToNbr");
11714 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11715 json_object_boolean_true_add(
11717 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11720 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11721 json_object_string_add(json_addr
,
11722 "overrideASNsInOutboundUpdates",
11723 "ifAspathEqualRemoteAs");
11725 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11726 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11727 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11728 json_object_boolean_true_add(json_addr
,
11729 "routerAlwaysNextHop");
11730 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11731 PEER_FLAG_AS_PATH_UNCHANGED
))
11732 json_object_boolean_true_add(
11733 json_addr
, "unchangedAsPathPropogatedToNbr");
11734 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11735 PEER_FLAG_NEXTHOP_UNCHANGED
))
11736 json_object_boolean_true_add(
11737 json_addr
, "unchangedNextHopPropogatedToNbr");
11738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11739 json_object_boolean_true_add(
11740 json_addr
, "unchangedMedPropogatedToNbr");
11741 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11742 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11743 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11744 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11745 PEER_FLAG_SEND_COMMUNITY
)
11746 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11747 PEER_FLAG_SEND_EXT_COMMUNITY
))
11748 json_object_string_add(json_addr
,
11749 "commAttriSentToNbr",
11750 "extendedAndStandard");
11751 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11752 PEER_FLAG_SEND_EXT_COMMUNITY
))
11753 json_object_string_add(json_addr
,
11754 "commAttriSentToNbr",
11757 json_object_string_add(json_addr
,
11758 "commAttriSentToNbr",
11761 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11762 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11763 if (p
->default_rmap
[afi
][safi
].name
)
11764 json_object_string_add(
11765 json_addr
, "defaultRouteMap",
11766 p
->default_rmap
[afi
][safi
].name
);
11768 if (paf
&& PAF_SUBGRP(paf
)
11769 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11770 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11771 json_object_boolean_true_add(json_addr
,
11774 json_object_boolean_true_add(json_addr
,
11778 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11779 if (is_evpn_enabled())
11780 json_object_boolean_true_add(
11781 json_addr
, "advertiseAllVnis");
11784 if (filter
->plist
[FILTER_IN
].name
11785 || filter
->dlist
[FILTER_IN
].name
11786 || filter
->aslist
[FILTER_IN
].name
11787 || filter
->map
[RMAP_IN
].name
)
11788 json_object_boolean_true_add(json_addr
,
11789 "inboundPathPolicyConfig");
11790 if (filter
->plist
[FILTER_OUT
].name
11791 || filter
->dlist
[FILTER_OUT
].name
11792 || filter
->aslist
[FILTER_OUT
].name
11793 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11794 json_object_boolean_true_add(
11795 json_addr
, "outboundPathPolicyConfig");
11798 if (filter
->plist
[FILTER_IN
].name
)
11799 json_object_string_add(json_addr
,
11800 "incomingUpdatePrefixFilterList",
11801 filter
->plist
[FILTER_IN
].name
);
11802 if (filter
->plist
[FILTER_OUT
].name
)
11803 json_object_string_add(json_addr
,
11804 "outgoingUpdatePrefixFilterList",
11805 filter
->plist
[FILTER_OUT
].name
);
11807 /* distribute-list */
11808 if (filter
->dlist
[FILTER_IN
].name
)
11809 json_object_string_add(
11810 json_addr
, "incomingUpdateNetworkFilterList",
11811 filter
->dlist
[FILTER_IN
].name
);
11812 if (filter
->dlist
[FILTER_OUT
].name
)
11813 json_object_string_add(
11814 json_addr
, "outgoingUpdateNetworkFilterList",
11815 filter
->dlist
[FILTER_OUT
].name
);
11818 if (filter
->aslist
[FILTER_IN
].name
)
11819 json_object_string_add(json_addr
,
11820 "incomingUpdateAsPathFilterList",
11821 filter
->aslist
[FILTER_IN
].name
);
11822 if (filter
->aslist
[FILTER_OUT
].name
)
11823 json_object_string_add(json_addr
,
11824 "outgoingUpdateAsPathFilterList",
11825 filter
->aslist
[FILTER_OUT
].name
);
11828 if (filter
->map
[RMAP_IN
].name
)
11829 json_object_string_add(
11830 json_addr
, "routeMapForIncomingAdvertisements",
11831 filter
->map
[RMAP_IN
].name
);
11832 if (filter
->map
[RMAP_OUT
].name
)
11833 json_object_string_add(
11834 json_addr
, "routeMapForOutgoingAdvertisements",
11835 filter
->map
[RMAP_OUT
].name
);
11837 /* ebgp-requires-policy (inbound) */
11838 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11839 && !bgp_inbound_policy_exists(p
, filter
))
11840 json_object_string_add(
11841 json_addr
, "inboundEbgpRequiresPolicy",
11842 "Inbound updates discarded due to missing policy");
11844 /* ebgp-requires-policy (outbound) */
11845 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11846 && (!bgp_outbound_policy_exists(p
, filter
)))
11847 json_object_string_add(
11848 json_addr
, "outboundEbgpRequiresPolicy",
11849 "Outbound updates discarded due to missing policy");
11851 /* unsuppress-map */
11852 if (filter
->usmap
.name
)
11853 json_object_string_add(json_addr
,
11854 "selectiveUnsuppressRouteMap",
11855 filter
->usmap
.name
);
11857 /* advertise-map */
11858 if (filter
->advmap
.aname
) {
11859 json_advmap
= json_object_new_object();
11860 json_object_string_add(json_advmap
, "condition",
11861 filter
->advmap
.condition
11864 json_object_string_add(json_advmap
, "conditionMap",
11865 filter
->advmap
.cname
);
11866 json_object_string_add(json_advmap
, "advertiseMap",
11867 filter
->advmap
.aname
);
11868 json_object_string_add(json_advmap
, "advertiseStatus",
11869 filter
->advmap
.update_type
11873 json_object_object_add(json_addr
, "advertiseMap",
11877 /* Receive prefix count */
11878 json_object_int_add(json_addr
, "acceptedPrefixCounter",
11879 p
->pcount
[afi
][safi
]);
11880 if (paf
&& PAF_SUBGRP(paf
))
11881 json_object_int_add(json_addr
, "sentPrefixCounter",
11882 (PAF_SUBGRP(paf
))->scount
);
11884 /* Maximum prefix */
11885 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
11886 json_object_int_add(json_addr
, "prefixOutAllowedMax",
11887 p
->pmax_out
[afi
][safi
]);
11889 /* Maximum prefix */
11890 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11891 json_object_int_add(json_addr
, "prefixAllowedMax",
11892 p
->pmax
[afi
][safi
]);
11893 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11894 PEER_FLAG_MAX_PREFIX_WARNING
))
11895 json_object_boolean_true_add(
11896 json_addr
, "prefixAllowedMaxWarning");
11897 json_object_int_add(json_addr
,
11898 "prefixAllowedWarningThresh",
11899 p
->pmax_threshold
[afi
][safi
]);
11900 if (p
->pmax_restart
[afi
][safi
])
11901 json_object_int_add(
11903 "prefixAllowedRestartIntervalMsecs",
11904 p
->pmax_restart
[afi
][safi
] * 60000);
11906 json_object_object_add(json_neigh
,
11907 get_afi_safi_str(afi
, safi
, true),
11911 filter
= &p
->filter
[afi
][safi
];
11913 vty_out(vty
, " For address family: %s\n",
11914 get_afi_safi_str(afi
, safi
, false));
11916 if (peer_group_active(p
))
11917 vty_out(vty
, " %s peer-group member\n",
11920 paf
= peer_af_find(p
, afi
, safi
);
11921 if (paf
&& PAF_SUBGRP(paf
)) {
11922 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
11923 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
11924 vty_out(vty
, " Packet Queue length %d\n",
11925 bpacket_queue_virtual_length(paf
));
11927 vty_out(vty
, " Not part of any update group\n");
11929 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11930 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11931 PEER_CAP_ORF_PREFIX_SM_RCV
)
11932 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11933 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11935 PEER_CAP_ORF_PREFIX_RM_ADV
)
11936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11937 PEER_CAP_ORF_PREFIX_RM_RCV
)
11938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11939 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11940 vty_out(vty
, " AF-dependant capabilities:\n");
11942 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11943 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11944 PEER_CAP_ORF_PREFIX_SM_RCV
)
11945 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11946 PEER_CAP_ORF_PREFIX_RM_ADV
)
11947 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11948 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11950 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11952 bgp_show_peer_afi_orf_cap(
11953 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11954 PEER_CAP_ORF_PREFIX_RM_ADV
,
11955 PEER_CAP_ORF_PREFIX_SM_RCV
,
11956 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
11958 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11959 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11960 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11961 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11962 PEER_CAP_ORF_PREFIX_RM_ADV
)
11963 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11964 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11966 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11967 ORF_TYPE_PREFIX_OLD
);
11968 bgp_show_peer_afi_orf_cap(
11969 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11970 PEER_CAP_ORF_PREFIX_RM_ADV
,
11971 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11972 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
11975 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11976 p
->host
, afi
, safi
);
11977 orf_pfx_count
= prefix_bgp_show_prefix_list(
11978 NULL
, afi
, orf_pfx_name
, use_json
);
11980 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11981 PEER_STATUS_ORF_PREFIX_SEND
)
11982 || orf_pfx_count
) {
11983 vty_out(vty
, " Outbound Route Filter (ORF):");
11984 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11985 PEER_STATUS_ORF_PREFIX_SEND
))
11986 vty_out(vty
, " sent;");
11988 vty_out(vty
, " received (%d entries)",
11990 vty_out(vty
, "\n");
11992 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11993 PEER_STATUS_ORF_WAIT_REFRESH
))
11995 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
11997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11998 PEER_FLAG_REFLECTOR_CLIENT
))
11999 vty_out(vty
, " Route-Reflector Client\n");
12000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12001 PEER_FLAG_RSERVER_CLIENT
))
12002 vty_out(vty
, " Route-Server Client\n");
12003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12005 " Inbound soft reconfiguration allowed\n");
12007 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12008 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12010 " Private AS numbers (all) replaced in updates to this neighbor\n");
12011 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12012 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12014 " Private AS numbers replaced in updates to this neighbor\n");
12015 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12016 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12018 " Private AS numbers (all) removed in updates to this neighbor\n");
12019 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12020 PEER_FLAG_REMOVE_PRIVATE_AS
))
12022 " Private AS numbers removed in updates to this neighbor\n");
12024 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12025 vty_out(vty
, " %s\n",
12026 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12027 ->human_description
);
12029 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12031 " Override ASNs in outbound updates if aspath equals remote-as\n");
12033 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12034 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12035 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12036 vty_out(vty
, " NEXT_HOP is always this router\n");
12037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12038 PEER_FLAG_AS_PATH_UNCHANGED
))
12040 " AS_PATH is propagated unchanged to this neighbor\n");
12041 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12042 PEER_FLAG_NEXTHOP_UNCHANGED
))
12044 " NEXT_HOP is propagated unchanged to this neighbor\n");
12045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12047 " MED is propagated unchanged to this neighbor\n");
12048 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12049 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12050 PEER_FLAG_SEND_EXT_COMMUNITY
)
12051 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12052 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12054 " Community attribute sent to this neighbor");
12055 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12056 PEER_FLAG_SEND_COMMUNITY
)
12057 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12058 PEER_FLAG_SEND_EXT_COMMUNITY
)
12059 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12060 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12061 vty_out(vty
, "(all)\n");
12062 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12063 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12064 vty_out(vty
, "(large)\n");
12065 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12066 PEER_FLAG_SEND_EXT_COMMUNITY
))
12067 vty_out(vty
, "(extended)\n");
12069 vty_out(vty
, "(standard)\n");
12071 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12072 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12073 vty_out(vty
, " Default information originate,");
12075 if (p
->default_rmap
[afi
][safi
].name
)
12076 vty_out(vty
, " default route-map %s%s,",
12077 p
->default_rmap
[afi
][safi
].map
? "*"
12079 p
->default_rmap
[afi
][safi
].name
);
12080 if (paf
&& PAF_SUBGRP(paf
)
12081 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12082 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12083 vty_out(vty
, " default sent\n");
12085 vty_out(vty
, " default not sent\n");
12088 /* advertise-vni-all */
12089 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12090 if (is_evpn_enabled())
12091 vty_out(vty
, " advertise-all-vni\n");
12094 if (filter
->plist
[FILTER_IN
].name
12095 || filter
->dlist
[FILTER_IN
].name
12096 || filter
->aslist
[FILTER_IN
].name
12097 || filter
->map
[RMAP_IN
].name
)
12098 vty_out(vty
, " Inbound path policy configured\n");
12099 if (filter
->plist
[FILTER_OUT
].name
12100 || filter
->dlist
[FILTER_OUT
].name
12101 || filter
->aslist
[FILTER_OUT
].name
12102 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12103 vty_out(vty
, " Outbound path policy configured\n");
12106 if (filter
->plist
[FILTER_IN
].name
)
12108 " Incoming update prefix filter list is %s%s\n",
12109 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12110 filter
->plist
[FILTER_IN
].name
);
12111 if (filter
->plist
[FILTER_OUT
].name
)
12113 " Outgoing update prefix filter list is %s%s\n",
12114 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12115 filter
->plist
[FILTER_OUT
].name
);
12117 /* distribute-list */
12118 if (filter
->dlist
[FILTER_IN
].name
)
12120 " Incoming update network filter list is %s%s\n",
12121 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12122 filter
->dlist
[FILTER_IN
].name
);
12123 if (filter
->dlist
[FILTER_OUT
].name
)
12125 " Outgoing update network filter list is %s%s\n",
12126 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12127 filter
->dlist
[FILTER_OUT
].name
);
12130 if (filter
->aslist
[FILTER_IN
].name
)
12132 " Incoming update AS path filter list is %s%s\n",
12133 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12134 filter
->aslist
[FILTER_IN
].name
);
12135 if (filter
->aslist
[FILTER_OUT
].name
)
12137 " Outgoing update AS path filter list is %s%s\n",
12138 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12139 filter
->aslist
[FILTER_OUT
].name
);
12142 if (filter
->map
[RMAP_IN
].name
)
12144 " Route map for incoming advertisements is %s%s\n",
12145 filter
->map
[RMAP_IN
].map
? "*" : "",
12146 filter
->map
[RMAP_IN
].name
);
12147 if (filter
->map
[RMAP_OUT
].name
)
12149 " Route map for outgoing advertisements is %s%s\n",
12150 filter
->map
[RMAP_OUT
].map
? "*" : "",
12151 filter
->map
[RMAP_OUT
].name
);
12153 /* ebgp-requires-policy (inbound) */
12154 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12155 && !bgp_inbound_policy_exists(p
, filter
))
12157 " Inbound updates discarded due to missing policy\n");
12159 /* ebgp-requires-policy (outbound) */
12160 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12161 && !bgp_outbound_policy_exists(p
, filter
))
12163 " Outbound updates discarded due to missing policy\n");
12165 /* unsuppress-map */
12166 if (filter
->usmap
.name
)
12168 " Route map for selective unsuppress is %s%s\n",
12169 filter
->usmap
.map
? "*" : "",
12170 filter
->usmap
.name
);
12172 /* advertise-map */
12173 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12175 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12176 filter
->advmap
.condition
? "EXIST"
12178 filter
->advmap
.cmap
? "*" : "",
12179 filter
->advmap
.cname
,
12180 filter
->advmap
.amap
? "*" : "",
12181 filter
->advmap
.aname
,
12182 filter
->advmap
.update_type
== ADVERTISE
12186 /* Receive prefix count */
12187 vty_out(vty
, " %u accepted prefixes\n",
12188 p
->pcount
[afi
][safi
]);
12190 /* maximum-prefix-out */
12191 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12192 PEER_FLAG_MAX_PREFIX_OUT
))
12194 " Maximum allowed prefixes sent %u\n",
12195 p
->pmax_out
[afi
][safi
]);
12197 /* Maximum prefix */
12198 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12200 " Maximum prefixes allowed %u%s\n",
12201 p
->pmax
[afi
][safi
],
12202 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12203 PEER_FLAG_MAX_PREFIX_WARNING
)
12204 ? " (warning-only)"
12206 vty_out(vty
, " Threshold for warning message %d%%",
12207 p
->pmax_threshold
[afi
][safi
]);
12208 if (p
->pmax_restart
[afi
][safi
])
12209 vty_out(vty
, ", restart interval %d min",
12210 p
->pmax_restart
[afi
][safi
]);
12211 vty_out(vty
, "\n");
12214 vty_out(vty
, "\n");
12218 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12222 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12223 char timebuf
[BGP_UPTIME_LEN
];
12229 json_object
*json_neigh
= NULL
;
12231 uint32_t sync_tcp_mss
;
12236 json_neigh
= json_object_new_object();
12238 memset(dn_flag
, '\0', sizeof(dn_flag
));
12239 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12243 if (p
->conf_if
) /* Configured interface name. */
12244 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12245 BGP_PEER_SU_UNSPEC(p
)
12247 : sockunion2str(&p
->su
, buf
,
12249 else /* Configured IP address. */
12250 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12255 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12256 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12258 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12259 json_object_string_add(
12260 json_neigh
, "bgpNeighborAddr",
12261 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12263 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12265 if (p
->change_local_as
)
12266 json_object_int_add(json_neigh
, "localAs",
12267 p
->change_local_as
);
12269 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12271 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12272 json_object_boolean_true_add(json_neigh
,
12273 "localAsNoPrepend");
12275 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12276 json_object_boolean_true_add(json_neigh
,
12277 "localAsReplaceAs");
12279 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12280 || (p
->as_type
== AS_INTERNAL
))
12281 vty_out(vty
, "remote AS %u, ", p
->as
);
12283 vty_out(vty
, "remote AS Unspecified, ");
12284 vty_out(vty
, "local AS %u%s%s, ",
12285 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12286 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12289 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12293 /* peer type internal or confed-internal */
12294 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12296 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12297 json_object_boolean_true_add(
12298 json_neigh
, "nbrConfedInternalLink");
12300 json_object_boolean_true_add(json_neigh
,
12301 "nbrInternalLink");
12303 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12304 vty_out(vty
, "confed-internal link\n");
12306 vty_out(vty
, "internal link\n");
12308 /* peer type external or confed-external */
12309 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12311 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12312 json_object_boolean_true_add(
12313 json_neigh
, "nbrConfedExternalLink");
12315 json_object_boolean_true_add(json_neigh
,
12316 "nbrExternalLink");
12318 if (bgp_confederation_peers_check(bgp
, p
->as
))
12319 vty_out(vty
, "confed-external link\n");
12321 vty_out(vty
, "external link\n");
12325 json_object_boolean_true_add(json_neigh
,
12326 "nbrUnspecifiedLink");
12328 vty_out(vty
, "unspecified link\n");
12334 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12336 vty_out(vty
, " Description: %s\n", p
->desc
);
12342 json_object_string_add(json_neigh
, "hostname",
12346 json_object_string_add(json_neigh
, "domainname",
12349 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12350 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12353 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12360 json_object_string_add(json_neigh
, "peerGroup",
12364 struct prefix prefix
, *range
= NULL
;
12366 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12367 range
= peer_group_lookup_dynamic_neighbor_range(
12368 p
->group
, &prefix
);
12371 json_object_string_addf(
12373 "peerSubnetRangeGroup", "%pFX",
12379 " Member of peer-group %s for session parameters\n",
12383 struct prefix prefix
, *range
= NULL
;
12385 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12386 range
= peer_group_lookup_dynamic_neighbor_range(
12387 p
->group
, &prefix
);
12391 " Belongs to the subnet range group: %pFX\n",
12399 /* Administrative shutdown. */
12400 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12401 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12402 json_object_boolean_true_add(json_neigh
,
12406 json_object_int_add(json_neigh
, "bgpVersion", 4);
12407 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12409 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12412 /* Confederation */
12413 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12414 && bgp_confederation_peers_check(bgp
, p
->as
))
12415 json_object_boolean_true_add(json_neigh
,
12419 json_object_string_add(
12420 json_neigh
, "bgpState",
12421 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12423 if (peer_established(p
)) {
12426 uptime
= bgp_clock();
12427 uptime
-= p
->uptime
;
12428 epoch_tbuf
= time(NULL
) - uptime
;
12430 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12432 json_object_string_add(json_neigh
, "bgpTimerUpString",
12433 peer_uptime(p
->uptime
, timebuf
,
12436 json_object_int_add(json_neigh
,
12437 "bgpTimerUpEstablishedEpoch",
12441 else if (p
->status
== Active
) {
12442 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12443 json_object_string_add(json_neigh
, "bgpStateIs",
12445 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12446 json_object_string_add(json_neigh
, "bgpStateIs",
12454 uptime
= bgp_clock();
12455 uptime
-= p
->readtime
;
12456 gmtime_r(&uptime
, &tm
);
12458 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12459 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12460 + (tm
.tm_hour
* 3600000));
12462 uptime
= bgp_clock();
12463 uptime
-= p
->last_write
;
12464 gmtime_r(&uptime
, &tm
);
12466 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12467 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12468 + (tm
.tm_hour
* 3600000));
12470 uptime
= bgp_clock();
12471 uptime
-= p
->update_time
;
12472 gmtime_r(&uptime
, &tm
);
12474 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12475 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12476 + (tm
.tm_hour
* 3600000));
12478 /* Configured timer values. */
12479 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12480 p
->v_holdtime
* 1000);
12481 json_object_int_add(json_neigh
,
12482 "bgpTimerKeepAliveIntervalMsecs",
12483 p
->v_keepalive
* 1000);
12484 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12485 json_object_int_add(json_neigh
,
12486 "bgpTimerDelayOpenTimeMsecs",
12487 p
->v_delayopen
* 1000);
12490 /* Configured and Synced tcp-mss value for peer */
12491 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12492 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12493 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12495 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12499 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12500 json_object_int_add(json_neigh
,
12501 "bgpTimerConfiguredHoldTimeMsecs",
12502 p
->holdtime
* 1000);
12503 json_object_int_add(
12505 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12506 p
->keepalive
* 1000);
12507 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12508 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12509 json_object_int_add(json_neigh
,
12510 "bgpTimerConfiguredHoldTimeMsecs",
12511 bgp
->default_holdtime
);
12512 json_object_int_add(
12514 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12515 bgp
->default_keepalive
);
12518 /* Extended Optional Parameters Length for BGP OPEN Message */
12519 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12520 json_object_boolean_true_add(
12521 json_neigh
, "extendedOptionalParametersLength");
12523 json_object_boolean_false_add(
12524 json_neigh
, "extendedOptionalParametersLength");
12526 /* Administrative shutdown. */
12527 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12528 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12529 vty_out(vty
, " Administratively shut down\n");
12532 vty_out(vty
, " BGP version 4");
12533 vty_out(vty
, ", remote router ID %s",
12534 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12535 vty_out(vty
, ", local router ID %s\n",
12536 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12539 /* Confederation */
12540 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12541 && bgp_confederation_peers_check(bgp
, p
->as
))
12543 " Neighbor under common administration\n");
12546 vty_out(vty
, " BGP state = %s",
12547 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12549 if (peer_established(p
))
12550 vty_out(vty
, ", up for %8s",
12551 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12554 else if (p
->status
== Active
) {
12555 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12556 vty_out(vty
, " (passive)");
12557 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12558 vty_out(vty
, " (NSF passive)");
12560 vty_out(vty
, "\n");
12563 vty_out(vty
, " Last read %s",
12564 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12566 vty_out(vty
, ", Last write %s\n",
12567 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12570 /* Configured timer values. */
12572 " Hold time is %d, keepalive interval is %d seconds\n",
12573 p
->v_holdtime
, p
->v_keepalive
);
12574 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12575 vty_out(vty
, " Configured hold time is %d",
12577 vty_out(vty
, ", keepalive interval is %d seconds\n",
12579 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12580 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12581 vty_out(vty
, " Configured hold time is %d",
12582 bgp
->default_holdtime
);
12583 vty_out(vty
, ", keepalive interval is %d seconds\n",
12584 bgp
->default_keepalive
);
12586 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12588 " Configured DelayOpenTime is %d seconds\n",
12591 /* Configured and synced tcp-mss value for peer */
12592 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12593 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12594 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12595 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12598 /* Extended Optional Parameters Length for BGP OPEN Message */
12599 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12601 " Extended Optional Parameters Length is enabled\n");
12604 if (peer_established(p
) &&
12605 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
12607 json_object
*json_cap
= NULL
;
12609 json_cap
= json_object_new_object();
12612 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
12613 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12614 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
12615 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12616 json_object_string_add(
12617 json_cap
, "4byteAs",
12618 "advertisedAndReceived");
12619 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
12620 json_object_string_add(json_cap
,
12623 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
12624 json_object_string_add(json_cap
,
12629 /* Extended Message Support */
12630 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
12631 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
12632 json_object_string_add(json_cap
,
12634 "advertisedAndReceived");
12635 else if (CHECK_FLAG(p
->cap
,
12636 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12637 json_object_string_add(json_cap
,
12640 else if (CHECK_FLAG(p
->cap
,
12641 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12642 json_object_string_add(json_cap
,
12647 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
12648 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
12649 json_object
*json_add
= NULL
;
12650 const char *print_store
;
12652 json_add
= json_object_new_object();
12654 FOREACH_AFI_SAFI (afi
, safi
) {
12655 json_object
*json_sub
= NULL
;
12656 json_sub
= json_object_new_object();
12657 print_store
= get_afi_safi_str(
12661 p
->af_cap
[afi
][safi
],
12662 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12664 p
->af_cap
[afi
][safi
],
12665 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12669 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
12673 PEER_CAP_ADDPATH_AF_TX_RCV
))
12674 json_object_boolean_true_add(
12676 "txAdvertisedAndReceived");
12681 PEER_CAP_ADDPATH_AF_TX_ADV
))
12682 json_object_boolean_true_add(
12689 PEER_CAP_ADDPATH_AF_TX_RCV
))
12690 json_object_boolean_true_add(
12696 p
->af_cap
[afi
][safi
],
12697 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12699 p
->af_cap
[afi
][safi
],
12700 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12704 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
12708 PEER_CAP_ADDPATH_AF_RX_RCV
))
12709 json_object_boolean_true_add(
12711 "rxAdvertisedAndReceived");
12716 PEER_CAP_ADDPATH_AF_RX_ADV
))
12717 json_object_boolean_true_add(
12724 PEER_CAP_ADDPATH_AF_RX_RCV
))
12725 json_object_boolean_true_add(
12731 p
->af_cap
[afi
][safi
],
12732 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
12734 p
->af_cap
[afi
][safi
],
12735 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
12737 p
->af_cap
[afi
][safi
],
12738 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
12740 p
->af_cap
[afi
][safi
],
12741 PEER_CAP_ADDPATH_AF_RX_RCV
))
12742 json_object_object_add(
12743 json_add
, print_store
,
12746 json_object_free(json_sub
);
12749 json_object_object_add(json_cap
, "addPath",
12754 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
12755 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
12756 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
12757 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
12758 json_object_string_add(
12759 json_cap
, "dynamic",
12760 "advertisedAndReceived");
12761 else if (CHECK_FLAG(p
->cap
,
12762 PEER_CAP_DYNAMIC_ADV
))
12763 json_object_string_add(json_cap
,
12766 else if (CHECK_FLAG(p
->cap
,
12767 PEER_CAP_DYNAMIC_RCV
))
12768 json_object_string_add(json_cap
,
12773 /* Extended nexthop */
12774 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
12775 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12776 json_object
*json_nxt
= NULL
;
12777 const char *print_store
;
12780 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
12781 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12782 json_object_string_add(
12783 json_cap
, "extendedNexthop",
12784 "advertisedAndReceived");
12785 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
12786 json_object_string_add(
12787 json_cap
, "extendedNexthop",
12789 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
12790 json_object_string_add(
12791 json_cap
, "extendedNexthop",
12794 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
12795 json_nxt
= json_object_new_object();
12797 for (safi
= SAFI_UNICAST
;
12798 safi
< SAFI_MAX
; safi
++) {
12802 PEER_CAP_ENHE_AF_RCV
)) {
12808 json_object_string_add(
12811 "recieved"); /* misspelled for compatibility */
12814 json_object_object_add(
12816 "extendedNexthopFamililesByPeer",
12821 /* Long-lived Graceful Restart */
12822 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
12823 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
12824 json_object
*json_llgr
= NULL
;
12825 const char *afi_safi_str
;
12827 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
12828 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12829 json_object_string_add(
12831 "longLivedGracefulRestart",
12832 "advertisedAndReceived");
12833 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
12834 json_object_string_add(
12836 "longLivedGracefulRestart",
12838 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
12839 json_object_string_add(
12841 "longLivedGracefulRestart",
12844 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
12845 json_llgr
= json_object_new_object();
12847 FOREACH_AFI_SAFI (afi
, safi
) {
12851 PEER_CAP_ENHE_AF_RCV
)) {
12857 json_object_string_add(
12863 json_object_object_add(
12865 "longLivedGracefulRestartByPeer",
12870 /* Route Refresh */
12871 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
12872 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
12873 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
12874 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
12875 (CHECK_FLAG(p
->cap
,
12876 PEER_CAP_REFRESH_NEW_RCV
) ||
12878 PEER_CAP_REFRESH_OLD_RCV
))) {
12881 PEER_CAP_REFRESH_OLD_RCV
) &&
12884 PEER_CAP_REFRESH_NEW_RCV
))
12885 json_object_string_add(
12888 "advertisedAndReceivedOldNew");
12892 PEER_CAP_REFRESH_OLD_RCV
))
12893 json_object_string_add(
12896 "advertisedAndReceivedOld");
12898 json_object_string_add(
12901 "advertisedAndReceivedNew");
12903 } else if (CHECK_FLAG(p
->cap
,
12904 PEER_CAP_REFRESH_ADV
))
12905 json_object_string_add(json_cap
,
12908 else if (CHECK_FLAG(p
->cap
,
12909 PEER_CAP_REFRESH_NEW_RCV
) ||
12911 PEER_CAP_REFRESH_OLD_RCV
))
12912 json_object_string_add(json_cap
,
12917 /* Enhanced Route Refresh */
12918 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
12919 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
12920 if (CHECK_FLAG(p
->cap
,
12921 PEER_CAP_ENHANCED_RR_ADV
) &&
12923 PEER_CAP_ENHANCED_RR_RCV
))
12924 json_object_string_add(
12926 "enhancedRouteRefresh",
12927 "advertisedAndReceived");
12928 else if (CHECK_FLAG(p
->cap
,
12929 PEER_CAP_ENHANCED_RR_ADV
))
12930 json_object_string_add(
12932 "enhancedRouteRefresh",
12934 else if (CHECK_FLAG(p
->cap
,
12935 PEER_CAP_ENHANCED_RR_RCV
))
12936 json_object_string_add(
12938 "enhancedRouteRefresh",
12942 /* Multiprotocol Extensions */
12943 json_object
*json_multi
= NULL
;
12945 json_multi
= json_object_new_object();
12947 FOREACH_AFI_SAFI (afi
, safi
) {
12948 if (p
->afc_adv
[afi
][safi
] ||
12949 p
->afc_recv
[afi
][safi
]) {
12950 json_object
*json_exten
= NULL
;
12951 json_exten
= json_object_new_object();
12953 if (p
->afc_adv
[afi
][safi
] &&
12954 p
->afc_recv
[afi
][safi
])
12955 json_object_boolean_true_add(
12957 "advertisedAndReceived");
12958 else if (p
->afc_adv
[afi
][safi
])
12959 json_object_boolean_true_add(
12962 else if (p
->afc_recv
[afi
][safi
])
12963 json_object_boolean_true_add(
12964 json_exten
, "received");
12966 json_object_object_add(
12968 get_afi_safi_str(afi
, safi
,
12973 json_object_object_add(json_cap
,
12974 "multiprotocolExtensions",
12977 /* Hostname capabilities */
12978 json_object
*json_hname
= NULL
;
12980 json_hname
= json_object_new_object();
12982 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
12983 json_object_string_add(
12984 json_hname
, "advHostName",
12985 bgp
->peer_self
->hostname
12986 ? bgp
->peer_self
->hostname
12988 json_object_string_add(
12989 json_hname
, "advDomainName",
12990 bgp
->peer_self
->domainname
12991 ? bgp
->peer_self
->domainname
12996 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
12997 json_object_string_add(
12998 json_hname
, "rcvHostName",
12999 p
->hostname
? p
->hostname
: "n/a");
13000 json_object_string_add(
13001 json_hname
, "rcvDomainName",
13002 p
->domainname
? p
->domainname
: "n/a");
13005 json_object_object_add(json_cap
, "hostName",
13008 /* Gracefull Restart */
13009 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13010 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13011 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13012 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13013 json_object_string_add(
13014 json_cap
, "gracefulRestart",
13015 "advertisedAndReceived");
13016 else if (CHECK_FLAG(p
->cap
,
13017 PEER_CAP_RESTART_ADV
))
13018 json_object_string_add(
13020 "gracefulRestartCapability",
13022 else if (CHECK_FLAG(p
->cap
,
13023 PEER_CAP_RESTART_RCV
))
13024 json_object_string_add(
13026 "gracefulRestartCapability",
13029 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13030 int restart_af_count
= 0;
13031 json_object
*json_restart
= NULL
;
13032 json_restart
= json_object_new_object();
13034 json_object_int_add(
13036 "gracefulRestartRemoteTimerMsecs",
13037 p
->v_gr_restart
* 1000);
13039 FOREACH_AFI_SAFI (afi
, safi
) {
13043 PEER_CAP_RESTART_AF_RCV
)) {
13044 json_object
*json_sub
=
13047 json_object_new_object();
13053 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13054 json_object_boolean_true_add(
13057 restart_af_count
++;
13058 json_object_object_add(
13067 if (!restart_af_count
) {
13068 json_object_string_add(
13070 "addressFamiliesByPeer",
13072 json_object_free(json_restart
);
13074 json_object_object_add(
13076 "addressFamiliesByPeer",
13080 json_object_object_add(
13081 json_neigh
, "neighborCapabilities", json_cap
);
13083 vty_out(vty
, " Neighbor capabilities:\n");
13086 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13087 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13088 vty_out(vty
, " 4 Byte AS:");
13089 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13090 vty_out(vty
, " advertised");
13091 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13092 vty_out(vty
, " %sreceived",
13097 vty_out(vty
, "\n");
13100 /* Extended Message Support */
13101 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13102 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13103 vty_out(vty
, " Extended Message:");
13104 if (CHECK_FLAG(p
->cap
,
13105 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13106 vty_out(vty
, " advertised");
13107 if (CHECK_FLAG(p
->cap
,
13108 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13109 vty_out(vty
, " %sreceived",
13112 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13115 vty_out(vty
, "\n");
13119 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13120 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13121 vty_out(vty
, " AddPath:\n");
13123 FOREACH_AFI_SAFI (afi
, safi
) {
13125 p
->af_cap
[afi
][safi
],
13126 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13128 p
->af_cap
[afi
][safi
],
13129 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13130 vty_out(vty
, " %s: TX ",
13138 PEER_CAP_ADDPATH_AF_TX_ADV
))
13145 PEER_CAP_ADDPATH_AF_TX_RCV
))
13152 PEER_CAP_ADDPATH_AF_TX_ADV
)
13156 vty_out(vty
, "\n");
13160 p
->af_cap
[afi
][safi
],
13161 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13163 p
->af_cap
[afi
][safi
],
13164 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13165 vty_out(vty
, " %s: RX ",
13173 PEER_CAP_ADDPATH_AF_RX_ADV
))
13180 PEER_CAP_ADDPATH_AF_RX_RCV
))
13187 PEER_CAP_ADDPATH_AF_RX_ADV
)
13191 vty_out(vty
, "\n");
13197 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13198 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13199 vty_out(vty
, " Dynamic:");
13200 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13201 vty_out(vty
, " advertised");
13202 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13203 vty_out(vty
, " %sreceived",
13205 PEER_CAP_DYNAMIC_ADV
)
13208 vty_out(vty
, "\n");
13211 /* Extended nexthop */
13212 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13213 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13214 vty_out(vty
, " Extended nexthop:");
13215 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13216 vty_out(vty
, " advertised");
13217 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13218 vty_out(vty
, " %sreceived",
13223 vty_out(vty
, "\n");
13225 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13227 " Address families by peer:\n ");
13228 for (safi
= SAFI_UNICAST
;
13229 safi
< SAFI_MAX
; safi
++)
13233 PEER_CAP_ENHE_AF_RCV
))
13243 /* Long-lived Graceful Restart */
13244 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13245 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13247 " Long-lived Graceful Restart:");
13248 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13249 vty_out(vty
, " advertised");
13250 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13251 vty_out(vty
, " %sreceived",
13256 vty_out(vty
, "\n");
13258 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13260 " Address families by peer:\n");
13261 FOREACH_AFI_SAFI (afi
, safi
)
13265 PEER_CAP_LLGR_AF_RCV
))
13275 /* Route Refresh */
13276 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13277 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13278 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13279 vty_out(vty
, " Route refresh:");
13280 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13281 vty_out(vty
, " advertised");
13282 if (CHECK_FLAG(p
->cap
,
13283 PEER_CAP_REFRESH_NEW_RCV
) ||
13285 PEER_CAP_REFRESH_OLD_RCV
))
13286 vty_out(vty
, " %sreceived(%s)",
13288 PEER_CAP_REFRESH_ADV
)
13293 PEER_CAP_REFRESH_OLD_RCV
) &&
13296 PEER_CAP_REFRESH_NEW_RCV
))
13300 PEER_CAP_REFRESH_OLD_RCV
)
13304 vty_out(vty
, "\n");
13307 /* Enhanced Route Refresh */
13308 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13309 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13310 vty_out(vty
, " Enhanced Route Refresh:");
13311 if (CHECK_FLAG(p
->cap
,
13312 PEER_CAP_ENHANCED_RR_ADV
))
13313 vty_out(vty
, " advertised");
13314 if (CHECK_FLAG(p
->cap
,
13315 PEER_CAP_ENHANCED_RR_RCV
))
13316 vty_out(vty
, " %sreceived",
13318 PEER_CAP_REFRESH_ADV
)
13321 vty_out(vty
, "\n");
13324 /* Multiprotocol Extensions */
13325 FOREACH_AFI_SAFI (afi
, safi
)
13326 if (p
->afc_adv
[afi
][safi
] ||
13327 p
->afc_recv
[afi
][safi
]) {
13328 vty_out(vty
, " Address Family %s:",
13329 get_afi_safi_str(afi
, safi
,
13331 if (p
->afc_adv
[afi
][safi
])
13332 vty_out(vty
, " advertised");
13333 if (p
->afc_recv
[afi
][safi
])
13334 vty_out(vty
, " %sreceived",
13335 p
->afc_adv
[afi
][safi
]
13338 vty_out(vty
, "\n");
13341 /* Hostname capability */
13342 vty_out(vty
, " Hostname Capability:");
13344 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13346 " advertised (name: %s,domain name: %s)",
13347 bgp
->peer_self
->hostname
13348 ? bgp
->peer_self
->hostname
13350 bgp
->peer_self
->domainname
13351 ? bgp
->peer_self
->domainname
13354 vty_out(vty
, " not advertised");
13357 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13359 " received (name: %s,domain name: %s)",
13360 p
->hostname
? p
->hostname
: "n/a",
13361 p
->domainname
? p
->domainname
: "n/a");
13363 vty_out(vty
, " not received");
13366 vty_out(vty
, "\n");
13368 /* Graceful Restart */
13369 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13370 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13372 " Graceful Restart Capability:");
13373 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13374 vty_out(vty
, " advertised");
13375 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13376 vty_out(vty
, " %sreceived",
13378 PEER_CAP_RESTART_ADV
)
13381 vty_out(vty
, "\n");
13383 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13384 int restart_af_count
= 0;
13387 " Remote Restart timer is %d seconds\n",
13390 " Address families by peer:\n ");
13392 FOREACH_AFI_SAFI (afi
, safi
)
13396 PEER_CAP_RESTART_AF_RCV
)) {
13397 vty_out(vty
, "%s%s(%s)",
13409 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13411 : "not preserved");
13412 restart_af_count
++;
13414 if (!restart_af_count
)
13415 vty_out(vty
, "none");
13416 vty_out(vty
, "\n");
13418 } /* Gracefull Restart */
13422 /* graceful restart information */
13423 json_object
*json_grace
= NULL
;
13424 json_object
*json_grace_send
= NULL
;
13425 json_object
*json_grace_recv
= NULL
;
13426 int eor_send_af_count
= 0;
13427 int eor_receive_af_count
= 0;
13430 json_grace
= json_object_new_object();
13431 json_grace_send
= json_object_new_object();
13432 json_grace_recv
= json_object_new_object();
13434 if ((peer_established(p
)) &&
13435 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13436 FOREACH_AFI_SAFI (afi
, safi
) {
13437 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13438 PEER_STATUS_EOR_SEND
)) {
13439 json_object_boolean_true_add(
13441 get_afi_safi_str(afi
, safi
,
13443 eor_send_af_count
++;
13446 FOREACH_AFI_SAFI (afi
, safi
) {
13447 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13448 PEER_STATUS_EOR_RECEIVED
)) {
13449 json_object_boolean_true_add(
13451 get_afi_safi_str(afi
, safi
,
13453 eor_receive_af_count
++;
13457 json_object_object_add(json_grace
, "endOfRibSend",
13459 json_object_object_add(json_grace
, "endOfRibRecv",
13463 if (p
->t_gr_restart
)
13464 json_object_int_add(
13465 json_grace
, "gracefulRestartTimerMsecs",
13466 thread_timer_remain_second(p
->t_gr_restart
) *
13470 json_object_int_add(
13471 json_grace
, "gracefulStalepathTimerMsecs",
13472 thread_timer_remain_second(p
->t_gr_stale
) *
13474 /* more gr info in new format */
13475 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13476 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13479 vty_out(vty
, " Graceful restart information:\n");
13480 if ((peer_established(p
)) &&
13481 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13483 vty_out(vty
, " End-of-RIB send: ");
13484 FOREACH_AFI_SAFI (afi
, safi
) {
13485 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13486 PEER_STATUS_EOR_SEND
)) {
13487 vty_out(vty
, "%s%s",
13488 eor_send_af_count
? ", " : "",
13489 get_afi_safi_str(afi
, safi
,
13491 eor_send_af_count
++;
13494 vty_out(vty
, "\n");
13495 vty_out(vty
, " End-of-RIB received: ");
13496 FOREACH_AFI_SAFI (afi
, safi
) {
13497 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13498 PEER_STATUS_EOR_RECEIVED
)) {
13499 vty_out(vty
, "%s%s",
13500 eor_receive_af_count
? ", "
13502 get_afi_safi_str(afi
, safi
,
13504 eor_receive_af_count
++;
13507 vty_out(vty
, "\n");
13510 if (p
->t_gr_restart
)
13512 " The remaining time of restart timer is %ld\n",
13513 thread_timer_remain_second(p
->t_gr_restart
));
13517 " The remaining time of stalepath timer is %ld\n",
13518 thread_timer_remain_second(p
->t_gr_stale
));
13520 /* more gr info in new format */
13521 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13525 json_object
*json_stat
= NULL
;
13526 json_stat
= json_object_new_object();
13527 /* Packet counts. */
13529 atomic_size_t outq_count
, inq_count
;
13530 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13531 memory_order_relaxed
);
13532 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13533 memory_order_relaxed
);
13535 json_object_int_add(json_stat
, "depthInq",
13536 (unsigned long)inq_count
);
13537 json_object_int_add(json_stat
, "depthOutq",
13538 (unsigned long)outq_count
);
13539 json_object_int_add(json_stat
, "opensSent",
13540 atomic_load_explicit(&p
->open_out
,
13541 memory_order_relaxed
));
13542 json_object_int_add(json_stat
, "opensRecv",
13543 atomic_load_explicit(&p
->open_in
,
13544 memory_order_relaxed
));
13545 json_object_int_add(json_stat
, "notificationsSent",
13546 atomic_load_explicit(&p
->notify_out
,
13547 memory_order_relaxed
));
13548 json_object_int_add(json_stat
, "notificationsRecv",
13549 atomic_load_explicit(&p
->notify_in
,
13550 memory_order_relaxed
));
13551 json_object_int_add(json_stat
, "updatesSent",
13552 atomic_load_explicit(&p
->update_out
,
13553 memory_order_relaxed
));
13554 json_object_int_add(json_stat
, "updatesRecv",
13555 atomic_load_explicit(&p
->update_in
,
13556 memory_order_relaxed
));
13557 json_object_int_add(json_stat
, "keepalivesSent",
13558 atomic_load_explicit(&p
->keepalive_out
,
13559 memory_order_relaxed
));
13560 json_object_int_add(json_stat
, "keepalivesRecv",
13561 atomic_load_explicit(&p
->keepalive_in
,
13562 memory_order_relaxed
));
13563 json_object_int_add(json_stat
, "routeRefreshSent",
13564 atomic_load_explicit(&p
->refresh_out
,
13565 memory_order_relaxed
));
13566 json_object_int_add(json_stat
, "routeRefreshRecv",
13567 atomic_load_explicit(&p
->refresh_in
,
13568 memory_order_relaxed
));
13569 json_object_int_add(json_stat
, "capabilitySent",
13570 atomic_load_explicit(&p
->dynamic_cap_out
,
13571 memory_order_relaxed
));
13572 json_object_int_add(json_stat
, "capabilityRecv",
13573 atomic_load_explicit(&p
->dynamic_cap_in
,
13574 memory_order_relaxed
));
13575 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13576 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13577 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13579 atomic_size_t outq_count
, inq_count
;
13580 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13581 memory_order_relaxed
);
13582 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13583 memory_order_relaxed
);
13585 /* Packet counts. */
13586 vty_out(vty
, " Message statistics:\n");
13587 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13588 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13589 vty_out(vty
, " Sent Rcvd\n");
13590 vty_out(vty
, " Opens: %10d %10d\n",
13591 atomic_load_explicit(&p
->open_out
,
13592 memory_order_relaxed
),
13593 atomic_load_explicit(&p
->open_in
,
13594 memory_order_relaxed
));
13595 vty_out(vty
, " Notifications: %10d %10d\n",
13596 atomic_load_explicit(&p
->notify_out
,
13597 memory_order_relaxed
),
13598 atomic_load_explicit(&p
->notify_in
,
13599 memory_order_relaxed
));
13600 vty_out(vty
, " Updates: %10d %10d\n",
13601 atomic_load_explicit(&p
->update_out
,
13602 memory_order_relaxed
),
13603 atomic_load_explicit(&p
->update_in
,
13604 memory_order_relaxed
));
13605 vty_out(vty
, " Keepalives: %10d %10d\n",
13606 atomic_load_explicit(&p
->keepalive_out
,
13607 memory_order_relaxed
),
13608 atomic_load_explicit(&p
->keepalive_in
,
13609 memory_order_relaxed
));
13610 vty_out(vty
, " Route Refresh: %10d %10d\n",
13611 atomic_load_explicit(&p
->refresh_out
,
13612 memory_order_relaxed
),
13613 atomic_load_explicit(&p
->refresh_in
,
13614 memory_order_relaxed
));
13615 vty_out(vty
, " Capability: %10d %10d\n",
13616 atomic_load_explicit(&p
->dynamic_cap_out
,
13617 memory_order_relaxed
),
13618 atomic_load_explicit(&p
->dynamic_cap_in
,
13619 memory_order_relaxed
));
13620 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13625 /* advertisement-interval */
13626 json_object_int_add(json_neigh
,
13627 "minBtwnAdvertisementRunsTimerMsecs",
13628 p
->v_routeadv
* 1000);
13630 /* Update-source. */
13631 if (p
->update_if
|| p
->update_source
) {
13633 json_object_string_add(json_neigh
,
13636 else if (p
->update_source
)
13637 json_object_string_add(
13638 json_neigh
, "updateSource",
13639 sockunion2str(p
->update_source
, buf1
,
13643 /* advertisement-interval */
13645 " Minimum time between advertisement runs is %d seconds\n",
13648 /* Update-source. */
13649 if (p
->update_if
|| p
->update_source
) {
13650 vty_out(vty
, " Update source is ");
13652 vty_out(vty
, "%s", p
->update_if
);
13653 else if (p
->update_source
)
13655 sockunion2str(p
->update_source
, buf1
,
13657 vty_out(vty
, "\n");
13660 vty_out(vty
, "\n");
13663 /* Address Family Information */
13664 json_object
*json_hold
= NULL
;
13667 json_hold
= json_object_new_object();
13669 FOREACH_AFI_SAFI (afi
, safi
)
13670 if (p
->afc
[afi
][safi
])
13671 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13675 json_object_object_add(json_neigh
, "addressFamilyInfo",
13677 json_object_int_add(json_neigh
, "connectionsEstablished",
13679 json_object_int_add(json_neigh
, "connectionsDropped",
13682 vty_out(vty
, " Connections established %d; dropped %d\n",
13683 p
->established
, p
->dropped
);
13685 if (!p
->last_reset
) {
13687 json_object_string_add(json_neigh
, "lastReset",
13690 vty_out(vty
, " Last reset never\n");
13696 uptime
= bgp_clock();
13697 uptime
-= p
->resettime
;
13698 gmtime_r(&uptime
, &tm
);
13700 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13702 + (tm
.tm_min
* 60000)
13703 + (tm
.tm_hour
* 3600000));
13704 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13706 vty_out(vty
, " Last reset %s, ",
13707 peer_uptime(p
->resettime
, timebuf
,
13708 BGP_UPTIME_LEN
, 0, NULL
));
13710 bgp_show_peer_reset(vty
, p
, NULL
, false);
13711 if (p
->last_reset_cause_size
) {
13712 msg
= p
->last_reset_cause
;
13714 " Message received that caused BGP to send a NOTIFICATION:\n ");
13715 for (i
= 1; i
<= p
->last_reset_cause_size
;
13717 vty_out(vty
, "%02X", *msg
++);
13719 if (i
!= p
->last_reset_cause_size
) {
13721 vty_out(vty
, "\n ");
13722 } else if (i
% 4 == 0) {
13727 vty_out(vty
, "\n");
13732 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13734 json_object_boolean_true_add(json_neigh
,
13735 "prefixesConfigExceedMax");
13738 " Peer had exceeded the max. no. of prefixes configured.\n");
13740 if (p
->t_pmax_restart
) {
13742 json_object_boolean_true_add(
13743 json_neigh
, "reducePrefixNumFrom");
13744 json_object_int_add(json_neigh
,
13745 "restartInTimerMsec",
13746 thread_timer_remain_second(
13751 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13752 p
->host
, thread_timer_remain_second(
13753 p
->t_pmax_restart
));
13756 json_object_boolean_true_add(
13758 "reducePrefixNumAndClearIpBgp");
13761 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13766 /* EBGP Multihop and GTSM */
13767 if (p
->sort
!= BGP_PEER_IBGP
) {
13769 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13770 json_object_int_add(json_neigh
,
13771 "externalBgpNbrMaxHopsAway",
13773 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13774 json_object_int_add(json_neigh
,
13775 "externalBgpNbrMaxHopsAway",
13778 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13780 " External BGP neighbor may be up to %d hops away.\n",
13782 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13784 " External BGP neighbor may be up to %d hops away.\n",
13788 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13790 json_object_int_add(json_neigh
,
13791 "internalBgpNbrMaxHopsAway",
13795 " Internal BGP neighbor may be up to %d hops away.\n",
13800 /* Local address. */
13803 json_object_string_add(json_neigh
, "hostLocal",
13804 sockunion2str(p
->su_local
, buf1
,
13806 json_object_int_add(json_neigh
, "portLocal",
13807 ntohs(p
->su_local
->sin
.sin_port
));
13809 vty_out(vty
, "Local host: %s, Local port: %d\n",
13810 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13811 ntohs(p
->su_local
->sin
.sin_port
));
13814 /* Remote address. */
13815 if (p
->su_remote
) {
13817 json_object_string_add(json_neigh
, "hostForeign",
13818 sockunion2str(p
->su_remote
, buf1
,
13820 json_object_int_add(json_neigh
, "portForeign",
13821 ntohs(p
->su_remote
->sin
.sin_port
));
13823 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13824 sockunion2str(p
->su_remote
, buf1
,
13826 ntohs(p
->su_remote
->sin
.sin_port
));
13829 /* Nexthop display. */
13832 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
13834 json_object_string_addf(json_neigh
, "nexthopGlobal",
13835 "%pI6", &p
->nexthop
.v6_global
);
13836 json_object_string_addf(json_neigh
, "nexthopLocal",
13837 "%pI6", &p
->nexthop
.v6_local
);
13838 if (p
->shared_network
)
13839 json_object_string_add(json_neigh
,
13843 json_object_string_add(json_neigh
,
13845 "nonSharedNetwork");
13847 vty_out(vty
, "Nexthop: %s\n",
13848 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13850 vty_out(vty
, "Nexthop global: %s\n",
13851 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
13853 vty_out(vty
, "Nexthop local: %s\n",
13854 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
13856 vty_out(vty
, "BGP connection: %s\n",
13857 p
->shared_network
? "shared network"
13858 : "non shared network");
13862 /* Timer information. */
13864 json_object_int_add(json_neigh
, "connectRetryTimer",
13866 if (peer_established(p
) && p
->rtt
)
13867 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
13870 json_object_int_add(
13871 json_neigh
, "nextStartTimerDueInMsecs",
13872 thread_timer_remain_second(p
->t_start
) * 1000);
13874 json_object_int_add(
13875 json_neigh
, "nextConnectTimerDueInMsecs",
13876 thread_timer_remain_second(p
->t_connect
)
13878 if (p
->t_routeadv
) {
13879 json_object_int_add(json_neigh
, "mraiInterval",
13881 json_object_int_add(
13882 json_neigh
, "mraiTimerExpireInMsecs",
13883 thread_timer_remain_second(p
->t_routeadv
)
13887 json_object_int_add(json_neigh
, "authenticationEnabled",
13891 json_object_string_add(json_neigh
, "readThread", "on");
13893 json_object_string_add(json_neigh
, "readThread", "off");
13895 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
13896 json_object_string_add(json_neigh
, "writeThread", "on");
13898 json_object_string_add(json_neigh
, "writeThread",
13901 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
13903 if (peer_established(p
) && p
->rtt
)
13904 vty_out(vty
, "Estimated round trip time: %d ms\n",
13907 vty_out(vty
, "Next start timer due in %ld seconds\n",
13908 thread_timer_remain_second(p
->t_start
));
13910 vty_out(vty
, "Next connect timer due in %ld seconds\n",
13911 thread_timer_remain_second(p
->t_connect
));
13914 "MRAI (interval %u) timer expires in %ld seconds\n",
13916 thread_timer_remain_second(p
->t_routeadv
));
13918 vty_out(vty
, "Peer Authentication Enabled\n");
13920 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
13921 p
->t_read
? "on" : "off",
13922 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
13927 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
13928 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
13929 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
13932 vty_out(vty
, "\n");
13934 /* BFD information. */
13936 bgp_bfd_show_info(vty
, p
, json_neigh
);
13939 if (p
->conf_if
) /* Configured interface name. */
13940 json_object_object_add(json
, p
->conf_if
, json_neigh
);
13941 else /* Configured IP address. */
13942 json_object_object_add(json
, p
->host
, json_neigh
);
13946 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
13947 enum show_type type
,
13948 union sockunion
*su
,
13949 const char *conf_if
, afi_t afi
,
13952 struct listnode
*node
, *nnode
;
13955 safi_t safi
= SAFI_UNICAST
;
13956 json_object
*json
= NULL
;
13957 json_object
*json_neighbor
= NULL
;
13960 json
= json_object_new_object();
13961 json_neighbor
= json_object_new_object();
13964 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13966 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13969 if ((peer
->afc
[afi
][safi
]) == 0)
13972 if (type
== show_all
) {
13973 bgp_show_peer_gr_status(vty
, peer
, use_json
,
13977 json_object_object_add(json
, peer
->host
,
13979 json_neighbor
= NULL
;
13982 } else if (type
== show_peer
) {
13985 && !strcmp(peer
->conf_if
, conf_if
))
13987 && !strcmp(peer
->hostname
, conf_if
))) {
13989 bgp_show_peer_gr_status(vty
, peer
,
13994 if (sockunion_same(&peer
->su
, su
)) {
13996 bgp_show_peer_gr_status(vty
, peer
,
14001 if (use_json
&& find
)
14002 json_object_object_add(json
, peer
->host
,
14007 json_neighbor
= NULL
;
14012 if (type
== show_peer
&& !find
) {
14014 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14016 vty_out(vty
, "%% No such neighbor\n");
14020 json_object_free(json_neighbor
);
14021 vty_json(vty
, json
);
14023 vty_out(vty
, "\n");
14026 return CMD_SUCCESS
;
14029 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14030 enum show_type type
, union sockunion
*su
,
14031 const char *conf_if
, bool use_json
,
14034 struct listnode
*node
, *nnode
;
14037 bool nbr_output
= false;
14038 afi_t afi
= AFI_MAX
;
14039 safi_t safi
= SAFI_MAX
;
14041 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14043 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14047 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14048 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14053 bgp_show_peer(vty
, peer
, use_json
, json
);
14059 && !strcmp(peer
->conf_if
, conf_if
))
14061 && !strcmp(peer
->hostname
, conf_if
))) {
14063 bgp_show_peer(vty
, peer
, use_json
,
14067 if (sockunion_same(&peer
->su
, su
)) {
14069 bgp_show_peer(vty
, peer
, use_json
,
14074 case show_ipv4_peer
:
14075 case show_ipv6_peer
:
14076 FOREACH_SAFI (safi
) {
14077 if (peer
->afc
[afi
][safi
]) {
14080 && !strcmp(peer
->conf_if
, conf_if
))
14082 && !strcmp(peer
->hostname
, conf_if
))) {
14084 bgp_show_peer(vty
, peer
, use_json
,
14089 if (sockunion_same(&peer
->su
, su
)) {
14091 bgp_show_peer(vty
, peer
, use_json
,
14099 case show_ipv4_all
:
14100 case show_ipv6_all
:
14101 FOREACH_SAFI (safi
) {
14102 if (peer
->afc
[afi
][safi
]) {
14103 bgp_show_peer(vty
, peer
, use_json
, json
);
14112 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14113 type
== show_ipv6_peer
) && !find
) {
14115 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14117 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14120 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14121 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14122 vty_out(vty
, "%% No BGP neighbors found\n");
14125 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14126 json
, JSON_C_TO_STRING_PRETTY
));
14128 vty_out(vty
, "\n");
14131 return CMD_SUCCESS
;
14134 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14135 enum show_type type
,
14136 const char *ip_str
,
14137 afi_t afi
, bool use_json
)
14142 union sockunion su
;
14144 bgp
= bgp_get_default();
14150 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14154 ret
= str2sockunion(ip_str
, &su
);
14156 bgp_show_neighbor_graceful_restart(
14157 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14159 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14160 NULL
, afi
, use_json
);
14162 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14166 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14167 enum show_type type
,
14168 const char *ip_str
,
14171 struct listnode
*node
, *nnode
;
14173 union sockunion su
;
14174 json_object
*json
= NULL
;
14175 int ret
, is_first
= 1;
14176 bool nbr_output
= false;
14179 vty_out(vty
, "{\n");
14181 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14184 if (!(json
= json_object_new_object())) {
14186 EC_BGP_JSON_MEM_ERROR
,
14187 "Unable to allocate memory for JSON object");
14189 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14193 json_object_int_add(json
, "vrfId",
14194 (bgp
->vrf_id
== VRF_UNKNOWN
)
14196 : (int64_t)bgp
->vrf_id
);
14197 json_object_string_add(
14199 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14204 vty_out(vty
, ",\n");
14208 vty_out(vty
, "\"%s\":",
14209 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14213 vty_out(vty
, "\nInstance %s:\n",
14214 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14219 if (type
== show_peer
|| type
== show_ipv4_peer
||
14220 type
== show_ipv6_peer
) {
14221 ret
= str2sockunion(ip_str
, &su
);
14223 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14226 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14229 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14232 json_object_free(json
);
14237 vty_out(vty
, "}\n");
14238 else if (!nbr_output
)
14239 vty_out(vty
, "%% BGP instance not found\n");
14242 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14243 enum show_type type
, const char *ip_str
,
14248 union sockunion su
;
14249 json_object
*json
= NULL
;
14252 if (strmatch(name
, "all")) {
14253 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14255 return CMD_SUCCESS
;
14257 bgp
= bgp_lookup_by_name(name
);
14260 json
= json_object_new_object();
14261 vty_json(vty
, json
);
14264 "%% BGP instance not found\n");
14266 return CMD_WARNING
;
14270 bgp
= bgp_get_default();
14274 json
= json_object_new_object();
14276 ret
= str2sockunion(ip_str
, &su
);
14278 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14281 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14284 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14287 json_object_free(json
);
14290 vty_out(vty
, "{}\n");
14292 vty_out(vty
, "%% BGP instance not found\n");
14295 return CMD_SUCCESS
;
14300 /* "show [ip] bgp neighbors graceful-restart" commands. */
14301 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14302 show_ip_bgp_neighbors_graceful_restart_cmd
,
14303 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14309 "Neighbor to display information about\n"
14310 "Neighbor to display information about\n"
14311 "Neighbor on BGP configured interface\n"
14315 char *sh_arg
= NULL
;
14316 enum show_type sh_type
;
14318 afi_t afi
= AFI_MAX
;
14319 bool uj
= use_json(argc
, argv
);
14321 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14326 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14327 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14328 || argv_find(argv
, argc
, "WORD", &idx
)) {
14329 sh_type
= show_peer
;
14330 sh_arg
= argv
[idx
]->arg
;
14332 sh_type
= show_all
;
14334 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14335 return CMD_SUCCESS
;
14338 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14342 /* "show [ip] bgp neighbors" commands. */
14343 DEFUN (show_ip_bgp_neighbors
,
14344 show_ip_bgp_neighbors_cmd
,
14345 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14349 BGP_INSTANCE_HELP_STR
14352 "Detailed information on TCP and BGP neighbor connections\n"
14353 "Neighbor to display information about\n"
14354 "Neighbor to display information about\n"
14355 "Neighbor on BGP configured interface\n"
14359 char *sh_arg
= NULL
;
14360 enum show_type sh_type
;
14361 afi_t afi
= AFI_MAX
;
14363 bool uj
= use_json(argc
, argv
);
14367 /* [<vrf> VIEWVRFNAME] */
14368 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14369 vrf
= argv
[idx
+ 1]->arg
;
14370 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14372 } else if (argv_find(argv
, argc
, "view", &idx
))
14373 /* [<view> VIEWVRFNAME] */
14374 vrf
= argv
[idx
+ 1]->arg
;
14378 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14379 sh_type
= show_ipv4_all
;
14381 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14382 sh_type
= show_ipv6_all
;
14385 sh_type
= show_all
;
14388 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14389 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14390 || argv_find(argv
, argc
, "WORD", &idx
)) {
14391 sh_type
= show_peer
;
14392 sh_arg
= argv
[idx
]->arg
;
14395 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14396 sh_type
= show_ipv4_peer
;
14397 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14398 sh_type
= show_ipv6_peer
;
14401 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14404 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14405 paths' and `show ip mbgp paths'. Those functions results are the
14407 DEFUN (show_ip_bgp_paths
,
14408 show_ip_bgp_paths_cmd
,
14409 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14414 "Path information\n")
14416 vty_out(vty
, "Address Refcnt Path\n");
14417 aspath_print_all_vty(vty
);
14418 return CMD_SUCCESS
;
14423 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14426 struct community
*com
;
14428 com
= (struct community
*)bucket
->data
;
14429 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14430 community_str(com
, false));
14433 /* Show BGP's community internal data. */
14434 DEFUN (show_ip_bgp_community_info
,
14435 show_ip_bgp_community_info_cmd
,
14436 "show [ip] bgp community-info",
14440 "List all bgp community information\n")
14442 vty_out(vty
, "Address Refcnt Community\n");
14444 hash_iterate(community_hash(),
14445 (void (*)(struct hash_bucket
*,
14446 void *))community_show_all_iterator
,
14449 return CMD_SUCCESS
;
14452 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14455 struct lcommunity
*lcom
;
14457 lcom
= (struct lcommunity
*)bucket
->data
;
14458 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14459 lcommunity_str(lcom
, false));
14462 /* Show BGP's community internal data. */
14463 DEFUN (show_ip_bgp_lcommunity_info
,
14464 show_ip_bgp_lcommunity_info_cmd
,
14465 "show ip bgp large-community-info",
14469 "List all bgp large-community information\n")
14471 vty_out(vty
, "Address Refcnt Large-community\n");
14473 hash_iterate(lcommunity_hash(),
14474 (void (*)(struct hash_bucket
*,
14475 void *))lcommunity_show_all_iterator
,
14478 return CMD_SUCCESS
;
14480 /* Graceful Restart */
14482 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14489 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14491 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14493 switch (bgp_global_gr_mode
) {
14495 case GLOBAL_HELPER
:
14496 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14500 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14503 case GLOBAL_DISABLE
:
14504 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14507 case GLOBAL_INVALID
:
14509 "Global BGP GR Mode Invalid\n");
14512 vty_out(vty
, "\n");
14515 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14516 enum show_type type
,
14517 const char *ip_str
,
14518 afi_t afi
, bool use_json
)
14520 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14523 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14525 bgp_show_neighbor_graceful_restart_vty(
14526 vty
, type
, ip_str
, afi
, use_json
);
14529 } else if (afi
!= AFI_MAX
) {
14530 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14533 return CMD_ERR_INCOMPLETE
;
14536 return CMD_SUCCESS
;
14538 /* Graceful Restart */
14540 DEFUN (show_ip_bgp_attr_info
,
14541 show_ip_bgp_attr_info_cmd
,
14542 "show [ip] bgp attribute-info",
14546 "List all bgp attribute information\n")
14548 attr_show_all(vty
);
14549 return CMD_SUCCESS
;
14552 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14553 afi_t afi
, safi_t safi
,
14554 bool use_json
, json_object
*json
)
14557 struct listnode
*node
;
14559 char buf1
[INET6_ADDRSTRLEN
];
14561 vpn_policy_direction_t dir
;
14564 json_object
*json_import_vrfs
= NULL
;
14565 json_object
*json_export_vrfs
= NULL
;
14567 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14570 vty_json(vty
, json
);
14572 return CMD_WARNING
;
14575 /* Provide context for the block */
14576 json_object_string_add(json
, "vrf", name
? name
: "default");
14577 json_object_string_add(json
, "afiSafi",
14578 get_afi_safi_str(afi
, safi
, true));
14580 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14581 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14582 json_object_string_add(json
, "importFromVrfs", "none");
14583 json_object_string_add(json
, "importRts", "none");
14585 json_import_vrfs
= json_object_new_array();
14587 for (ALL_LIST_ELEMENTS_RO(
14588 bgp
->vpn_policy
[afi
].import_vrf
,
14590 json_object_array_add(json_import_vrfs
,
14591 json_object_new_string(vname
));
14593 json_object_object_add(json
, "importFromVrfs",
14595 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14596 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14597 ecom_str
= ecommunity_ecom2str(
14598 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14599 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14600 json_object_string_add(json
, "importRts",
14602 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14604 json_object_string_add(json
, "importRts",
14608 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14609 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14610 json_object_string_add(json
, "exportToVrfs", "none");
14611 json_object_string_add(json
, "routeDistinguisher",
14613 json_object_string_add(json
, "exportRts", "none");
14615 json_export_vrfs
= json_object_new_array();
14617 for (ALL_LIST_ELEMENTS_RO(
14618 bgp
->vpn_policy
[afi
].export_vrf
,
14620 json_object_array_add(json_export_vrfs
,
14621 json_object_new_string(vname
));
14622 json_object_object_add(json
, "exportToVrfs",
14624 json_object_string_add(json
, "routeDistinguisher",
14625 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14626 buf1
, RD_ADDRSTRLEN
));
14628 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14629 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14630 ecom_str
= ecommunity_ecom2str(
14631 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14632 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14633 json_object_string_add(json
, "exportRts",
14635 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14637 json_object_string_add(json
, "exportRts",
14642 vty_json(vty
, json
);
14645 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14648 vty_out(vty
, "%% No such BGP instance exist\n");
14649 return CMD_WARNING
;
14652 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14653 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14655 "This VRF is not importing %s routes from any other VRF\n",
14656 get_afi_safi_str(afi
, safi
, false));
14659 "This VRF is importing %s routes from the following VRFs:\n",
14660 get_afi_safi_str(afi
, safi
, false));
14662 for (ALL_LIST_ELEMENTS_RO(
14663 bgp
->vpn_policy
[afi
].import_vrf
,
14665 vty_out(vty
, " %s\n", vname
);
14667 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14669 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14670 ecom_str
= ecommunity_ecom2str(
14671 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14672 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14673 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14675 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14677 vty_out(vty
, "Import RT(s):\n");
14680 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14681 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14683 "This VRF is not exporting %s routes to any other VRF\n",
14684 get_afi_safi_str(afi
, safi
, false));
14687 "This VRF is exporting %s routes to the following VRFs:\n",
14688 get_afi_safi_str(afi
, safi
, false));
14690 for (ALL_LIST_ELEMENTS_RO(
14691 bgp
->vpn_policy
[afi
].export_vrf
,
14693 vty_out(vty
, " %s\n", vname
);
14695 vty_out(vty
, "RD: %s\n",
14696 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14697 buf1
, RD_ADDRSTRLEN
));
14699 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14700 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14701 ecom_str
= ecommunity_ecom2str(
14702 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14703 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14704 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14705 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14707 vty_out(vty
, "Import RT(s):\n");
14711 return CMD_SUCCESS
;
14714 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14715 safi_t safi
, bool use_json
)
14717 struct listnode
*node
, *nnode
;
14719 char *vrf_name
= NULL
;
14720 json_object
*json
= NULL
;
14721 json_object
*json_vrf
= NULL
;
14722 json_object
*json_vrfs
= NULL
;
14725 json
= json_object_new_object();
14726 json_vrfs
= json_object_new_object();
14729 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14731 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14732 vrf_name
= bgp
->name
;
14735 json_vrf
= json_object_new_object();
14737 vty_out(vty
, "\nInstance %s:\n",
14738 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14739 ? VRF_DEFAULT_NAME
: bgp
->name
);
14741 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14743 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14744 json_object_object_add(json_vrfs
,
14745 VRF_DEFAULT_NAME
, json_vrf
);
14747 json_object_object_add(json_vrfs
, vrf_name
,
14753 json_object_object_add(json
, "vrfs", json_vrfs
);
14754 vty_json(vty
, json
);
14757 return CMD_SUCCESS
;
14760 /* "show [ip] bgp route-leak" command. */
14761 DEFUN (show_ip_bgp_route_leak
,
14762 show_ip_bgp_route_leak_cmd
,
14763 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14767 BGP_INSTANCE_HELP_STR
14770 "Route leaking information\n"
14774 afi_t afi
= AFI_MAX
;
14775 safi_t safi
= SAFI_MAX
;
14777 bool uj
= use_json(argc
, argv
);
14779 json_object
*json
= NULL
;
14781 /* show [ip] bgp */
14782 if (argv_find(argv
, argc
, "ip", &idx
)) {
14784 safi
= SAFI_UNICAST
;
14786 /* [vrf VIEWVRFNAME] */
14787 if (argv_find(argv
, argc
, "view", &idx
)) {
14789 "%% This command is not applicable to BGP views\n");
14790 return CMD_WARNING
;
14793 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14794 vrf
= argv
[idx
+ 1]->arg
;
14795 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14798 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14799 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14800 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14802 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14804 "%% This command is applicable only for unicast ipv4|ipv6\n");
14805 return CMD_WARNING
;
14808 if (vrf
&& strmatch(vrf
, "all"))
14809 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14812 json
= json_object_new_object();
14814 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14817 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14820 struct listnode
*node
, *nnode
;
14823 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14824 vty_out(vty
, "\nInstance %s:\n",
14825 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14828 update_group_show(bgp
, afi
, safi
, vty
, 0);
14832 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14833 int safi
, uint64_t subgrp_id
)
14838 if (strmatch(name
, "all")) {
14839 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14840 return CMD_SUCCESS
;
14842 bgp
= bgp_lookup_by_name(name
);
14845 bgp
= bgp_get_default();
14849 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
14850 return CMD_SUCCESS
;
14853 DEFUN (show_ip_bgp_updgrps
,
14854 show_ip_bgp_updgrps_cmd
,
14855 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
14859 BGP_INSTANCE_HELP_STR
14861 BGP_SAFI_WITH_LABEL_HELP_STR
14862 "Detailed info about dynamic update groups\n"
14863 "Specific subgroup to display detailed info for\n")
14866 afi_t afi
= AFI_IP6
;
14867 safi_t safi
= SAFI_UNICAST
;
14868 uint64_t subgrp_id
= 0;
14872 /* show [ip] bgp */
14873 if (argv_find(argv
, argc
, "ip", &idx
))
14875 /* [<vrf> VIEWVRFNAME] */
14876 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14877 vrf
= argv
[idx
+ 1]->arg
;
14878 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14880 } else if (argv_find(argv
, argc
, "view", &idx
))
14881 /* [<view> VIEWVRFNAME] */
14882 vrf
= argv
[idx
+ 1]->arg
;
14883 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14884 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14885 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14888 /* get subgroup id, if provided */
14890 if (argv
[idx
]->type
== VARIABLE_TKN
)
14891 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
14893 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
14896 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
14897 show_bgp_instance_all_ipv6_updgrps_cmd
,
14898 "show [ip] bgp <view|vrf> all update-groups",
14902 BGP_INSTANCE_ALL_HELP_STR
14903 "Detailed info about dynamic update groups\n")
14905 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
14906 return CMD_SUCCESS
;
14909 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
14910 show_bgp_l2vpn_evpn_updgrps_cmd
,
14911 "show [ip] bgp l2vpn evpn update-groups",
14915 "l2vpn address family\n"
14916 "evpn sub-address family\n"
14917 "Detailed info about dynamic update groups\n")
14920 uint64_t subgrp_id
= 0;
14922 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
14923 return CMD_SUCCESS
;
14926 DEFUN (show_bgp_updgrps_stats
,
14927 show_bgp_updgrps_stats_cmd
,
14928 "show [ip] bgp update-groups statistics",
14932 "Detailed info about dynamic update groups\n"
14937 bgp
= bgp_get_default();
14939 update_group_show_stats(bgp
, vty
);
14941 return CMD_SUCCESS
;
14944 DEFUN (show_bgp_instance_updgrps_stats
,
14945 show_bgp_instance_updgrps_stats_cmd
,
14946 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
14950 BGP_INSTANCE_HELP_STR
14951 "Detailed info about dynamic update groups\n"
14957 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
14959 update_group_show_stats(bgp
, vty
);
14961 return CMD_SUCCESS
;
14964 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
14965 afi_t afi
, safi_t safi
,
14966 const char *what
, uint64_t subgrp_id
)
14971 bgp
= bgp_lookup_by_name(name
);
14973 bgp
= bgp_get_default();
14976 if (!strcmp(what
, "advertise-queue"))
14977 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
14979 else if (!strcmp(what
, "advertised-routes"))
14980 update_group_show_advertised(bgp
, afi
, safi
, vty
,
14982 else if (!strcmp(what
, "packet-queue"))
14983 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
14988 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
14989 show_ip_bgp_instance_updgrps_adj_s_cmd
,
14990 "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",
14991 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
14993 "Detailed info about dynamic update groups\n"
14994 "Specific subgroup to display info for\n"
14995 "Advertisement queue\n"
14996 "Announced routes\n"
14999 uint64_t subgrp_id
= 0;
15003 subgrp_id
= strtoull(sgid
, NULL
, 10);
15008 afiz
= bgp_vty_afi_from_str(afi
);
15012 afiz
= bgp_vty_afi_from_str(afi
);
15013 if (afiz
!= AFI_IP
)
15015 "%% Cannot specify both 'ip' and 'ipv6'\n");
15016 return CMD_WARNING
;
15019 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15021 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15022 return CMD_SUCCESS
;
15025 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15028 struct listnode
*node
, *nnode
;
15029 struct prefix
*range
;
15034 const char *peer_status
;
15038 json_object
*json_peer_group
= NULL
;
15039 json_object
*json_peer_group_afc
= NULL
;
15040 json_object
*json_peer_group_members
= NULL
;
15041 json_object
*json_peer_group_dynamic
= NULL
;
15042 json_object
*json_peer_group_dynamic_af
= NULL
;
15043 json_object
*json_peer_group_ranges
= NULL
;
15045 conf
= group
->conf
;
15048 json_peer_group
= json_object_new_object();
15049 json_peer_group_afc
= json_object_new_array();
15052 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15054 json_object_int_add(json_peer_group
, "remoteAs",
15057 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15058 group
->name
, conf
->as
);
15059 } else if (conf
->as_type
== AS_INTERNAL
) {
15061 json_object_int_add(json_peer_group
, "remoteAs",
15064 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15065 group
->name
, group
->bgp
->as
);
15068 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15071 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15073 json_object_string_add(json_peer_group
, "type",
15076 vty_out(vty
, " Peer-group type is internal\n");
15079 json_object_string_add(json_peer_group
, "type",
15082 vty_out(vty
, " Peer-group type is external\n");
15085 /* Display AFs configured. */
15087 vty_out(vty
, " Configured address-families:");
15089 FOREACH_AFI_SAFI (afi
, safi
) {
15090 if (conf
->afc
[afi
][safi
]) {
15093 json_object_array_add(
15094 json_peer_group_afc
,
15095 json_object_new_string(get_afi_safi_str(
15096 afi
, safi
, false)));
15098 vty_out(vty
, " %s;",
15099 get_afi_safi_str(afi
, safi
, false));
15104 json_object_object_add(json_peer_group
,
15105 "addressFamiliesConfigured",
15106 json_peer_group_afc
);
15109 vty_out(vty
, " none\n");
15111 vty_out(vty
, "\n");
15114 /* Display listen ranges (for dynamic neighbors), if any */
15115 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15116 lr_count
= listcount(group
->listen_range
[afi
]);
15119 if (!json_peer_group_dynamic
)
15120 json_peer_group_dynamic
=
15121 json_object_new_object();
15123 json_peer_group_dynamic_af
=
15124 json_object_new_object();
15125 json_peer_group_ranges
=
15126 json_object_new_array();
15127 json_object_int_add(json_peer_group_dynamic_af
,
15128 "count", lr_count
);
15130 vty_out(vty
, " %d %s listen range(s)\n",
15131 lr_count
, afi2str(afi
));
15134 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15139 snprintfrr(buf
, sizeof(buf
), "%pFX",
15142 json_object_array_add(
15143 json_peer_group_ranges
,
15144 json_object_new_string(buf
));
15146 vty_out(vty
, " %pFX\n", range
);
15151 json_object_object_add(
15152 json_peer_group_dynamic_af
, "ranges",
15153 json_peer_group_ranges
);
15155 json_object_object_add(
15156 json_peer_group_dynamic
, afi2str(afi
),
15157 json_peer_group_dynamic_af
);
15162 if (json_peer_group_dynamic
)
15163 json_object_object_add(json_peer_group
, "dynamicRanges",
15164 json_peer_group_dynamic
);
15166 /* Display group members and their status */
15167 if (listcount(group
->peer
)) {
15169 json_peer_group_members
= json_object_new_object();
15171 vty_out(vty
, " Peer-group members:\n");
15172 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15173 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15174 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15175 peer_status
= "Idle (Admin)";
15176 else if (CHECK_FLAG(peer
->sflags
,
15177 PEER_STATUS_PREFIX_OVERFLOW
))
15178 peer_status
= "Idle (PfxCt)";
15180 peer_status
= lookup_msg(bgp_status_msg
,
15181 peer
->status
, NULL
);
15183 dynamic
= peer_dynamic_neighbor(peer
);
15186 json_object
*json_peer_group_member
=
15187 json_object_new_object();
15189 json_object_string_add(json_peer_group_member
,
15190 "status", peer_status
);
15193 json_object_boolean_true_add(
15194 json_peer_group_member
,
15197 json_object_object_add(json_peer_group_members
,
15199 json_peer_group_member
);
15201 vty_out(vty
, " %s %s %s \n", peer
->host
,
15202 dynamic
? "(dynamic)" : "",
15207 json_object_object_add(json_peer_group
, "members",
15208 json_peer_group_members
);
15212 json_object_object_add(json
, group
->name
, json_peer_group
);
15214 return CMD_SUCCESS
;
15217 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15218 const char *group_name
, bool uj
)
15221 struct listnode
*node
, *nnode
;
15222 struct peer_group
*group
;
15223 bool found
= false;
15224 json_object
*json
= NULL
;
15227 json
= json_object_new_object();
15229 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15233 vty_json(vty
, json
);
15235 vty_out(vty
, "%% BGP instance not found\n");
15237 return CMD_WARNING
;
15240 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15242 if (strmatch(group
->name
, group_name
)) {
15243 bgp_show_one_peer_group(vty
, group
, json
);
15248 bgp_show_one_peer_group(vty
, group
, json
);
15252 if (group_name
&& !found
&& !uj
)
15253 vty_out(vty
, "%% No such peer-group\n");
15256 vty_json(vty
, json
);
15258 return CMD_SUCCESS
;
15261 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15262 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15263 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15264 "Detailed information on BGP peer groups\n"
15265 "Peer group name\n" JSON_STR
)
15269 bool uj
= use_json(argc
, argv
);
15271 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15273 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15275 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15279 /* Redistribute VTY commands. */
15281 DEFUN (bgp_redistribute_ipv4
,
15282 bgp_redistribute_ipv4_cmd
,
15283 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15284 "Redistribute information from another routing protocol\n"
15285 FRR_IP_REDIST_HELP_STR_BGPD
)
15287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15288 int idx_protocol
= 1;
15291 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15293 vty_out(vty
, "%% Invalid route type\n");
15294 return CMD_WARNING_CONFIG_FAILED
;
15297 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15298 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15302 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15303 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15304 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15306 DEFUN (bgp_redistribute_ipv4_rmap
,
15307 bgp_redistribute_ipv4_rmap_cmd
,
15308 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15309 "Redistribute information from another routing protocol\n"
15310 FRR_IP_REDIST_HELP_STR_BGPD
15311 "Route map reference\n"
15312 "Pointer to route-map entries\n")
15314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15315 int idx_protocol
= 1;
15318 struct bgp_redist
*red
;
15320 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15321 vty
, argv
[idx_word
]->arg
);
15323 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15325 vty_out(vty
, "%% Invalid route type\n");
15326 return CMD_WARNING_CONFIG_FAILED
;
15329 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15331 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15332 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15336 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15337 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15338 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15339 "Route map reference\n"
15340 "Pointer to route-map entries\n")
15342 DEFUN (bgp_redistribute_ipv4_metric
,
15343 bgp_redistribute_ipv4_metric_cmd
,
15344 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15345 "Redistribute information from another routing protocol\n"
15346 FRR_IP_REDIST_HELP_STR_BGPD
15347 "Metric for redistributed routes\n"
15348 "Default metric\n")
15350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15351 int idx_protocol
= 1;
15352 int idx_number
= 3;
15355 struct bgp_redist
*red
;
15358 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15360 vty_out(vty
, "%% Invalid route type\n");
15361 return CMD_WARNING_CONFIG_FAILED
;
15363 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15365 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15366 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15367 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15371 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15372 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15373 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15374 "Metric for redistributed routes\n"
15375 "Default metric\n")
15377 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15378 bgp_redistribute_ipv4_rmap_metric_cmd
,
15379 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15380 "Redistribute information from another routing protocol\n"
15381 FRR_IP_REDIST_HELP_STR_BGPD
15382 "Route map reference\n"
15383 "Pointer to route-map entries\n"
15384 "Metric for redistributed routes\n"
15385 "Default metric\n")
15387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15388 int idx_protocol
= 1;
15390 int idx_number
= 5;
15393 struct bgp_redist
*red
;
15395 struct route_map
*route_map
=
15396 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15398 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15400 vty_out(vty
, "%% Invalid route type\n");
15401 return CMD_WARNING_CONFIG_FAILED
;
15403 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15405 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15407 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15408 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15409 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15413 bgp_redistribute_ipv4_rmap_metric
,
15414 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15415 "redistribute " FRR_IP_REDIST_STR_BGPD
15416 " route-map WORD metric (0-4294967295)",
15417 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15418 "Route map reference\n"
15419 "Pointer to route-map entries\n"
15420 "Metric for redistributed routes\n"
15421 "Default metric\n")
15423 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15424 bgp_redistribute_ipv4_metric_rmap_cmd
,
15425 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15426 "Redistribute information from another routing protocol\n"
15427 FRR_IP_REDIST_HELP_STR_BGPD
15428 "Metric for redistributed routes\n"
15430 "Route map reference\n"
15431 "Pointer to route-map entries\n")
15433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15434 int idx_protocol
= 1;
15435 int idx_number
= 3;
15439 struct bgp_redist
*red
;
15441 struct route_map
*route_map
=
15442 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15444 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15446 vty_out(vty
, "%% Invalid route type\n");
15447 return CMD_WARNING_CONFIG_FAILED
;
15449 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15451 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15452 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15454 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15455 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15459 bgp_redistribute_ipv4_metric_rmap
,
15460 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15461 "redistribute " FRR_IP_REDIST_STR_BGPD
15462 " metric (0-4294967295) route-map WORD",
15463 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15464 "Metric for redistributed routes\n"
15466 "Route map reference\n"
15467 "Pointer to route-map entries\n")
15469 DEFUN (bgp_redistribute_ipv4_ospf
,
15470 bgp_redistribute_ipv4_ospf_cmd
,
15471 "redistribute <ospf|table> (1-65535)",
15472 "Redistribute information from another routing protocol\n"
15473 "Open Shortest Path First (OSPFv2)\n"
15474 "Non-main Kernel Routing Table\n"
15475 "Instance ID/Table ID\n")
15477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15478 int idx_ospf_table
= 1;
15479 int idx_number
= 2;
15480 unsigned short instance
;
15481 unsigned short protocol
;
15483 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15485 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15486 protocol
= ZEBRA_ROUTE_OSPF
;
15488 protocol
= ZEBRA_ROUTE_TABLE
;
15490 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15491 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15494 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15495 "redistribute <ospf|table> (1-65535)",
15496 "Redistribute information from another routing protocol\n"
15497 "Open Shortest Path First (OSPFv2)\n"
15498 "Non-main Kernel Routing Table\n"
15499 "Instance ID/Table ID\n")
15501 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15502 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15503 "redistribute <ospf|table> (1-65535) route-map WORD",
15504 "Redistribute information from another routing protocol\n"
15505 "Open Shortest Path First (OSPFv2)\n"
15506 "Non-main Kernel Routing Table\n"
15507 "Instance ID/Table ID\n"
15508 "Route map reference\n"
15509 "Pointer to route-map entries\n")
15511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15512 int idx_ospf_table
= 1;
15513 int idx_number
= 2;
15515 struct bgp_redist
*red
;
15516 unsigned short instance
;
15519 struct route_map
*route_map
=
15520 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15522 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15523 protocol
= ZEBRA_ROUTE_OSPF
;
15525 protocol
= ZEBRA_ROUTE_TABLE
;
15527 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15528 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15530 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15531 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15534 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15535 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15536 "redistribute <ospf|table> (1-65535) route-map WORD",
15537 "Redistribute information from another routing protocol\n"
15538 "Open Shortest Path First (OSPFv2)\n"
15539 "Non-main Kernel Routing Table\n"
15540 "Instance ID/Table ID\n"
15541 "Route map reference\n"
15542 "Pointer to route-map entries\n")
15544 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15545 bgp_redistribute_ipv4_ospf_metric_cmd
,
15546 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15547 "Redistribute information from another routing protocol\n"
15548 "Open Shortest Path First (OSPFv2)\n"
15549 "Non-main Kernel Routing Table\n"
15550 "Instance ID/Table ID\n"
15551 "Metric for redistributed routes\n"
15552 "Default metric\n")
15554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15555 int idx_ospf_table
= 1;
15556 int idx_number
= 2;
15557 int idx_number_2
= 4;
15559 struct bgp_redist
*red
;
15560 unsigned short instance
;
15564 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15565 protocol
= ZEBRA_ROUTE_OSPF
;
15567 protocol
= ZEBRA_ROUTE_TABLE
;
15569 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15570 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15572 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15573 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15575 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15578 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15579 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15580 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15581 "Redistribute information from another routing protocol\n"
15582 "Open Shortest Path First (OSPFv2)\n"
15583 "Non-main Kernel Routing Table\n"
15584 "Instance ID/Table ID\n"
15585 "Metric for redistributed routes\n"
15586 "Default metric\n")
15588 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15589 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15590 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15591 "Redistribute information from another routing protocol\n"
15592 "Open Shortest Path First (OSPFv2)\n"
15593 "Non-main Kernel Routing Table\n"
15594 "Instance ID/Table ID\n"
15595 "Route map reference\n"
15596 "Pointer to route-map entries\n"
15597 "Metric for redistributed routes\n"
15598 "Default metric\n")
15600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15601 int idx_ospf_table
= 1;
15602 int idx_number
= 2;
15604 int idx_number_2
= 6;
15606 struct bgp_redist
*red
;
15607 unsigned short instance
;
15610 struct route_map
*route_map
=
15611 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15613 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15614 protocol
= ZEBRA_ROUTE_OSPF
;
15616 protocol
= ZEBRA_ROUTE_TABLE
;
15618 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15619 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15621 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15623 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15624 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15626 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15630 bgp_redistribute_ipv4_ospf_rmap_metric
,
15631 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15632 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15633 "Redistribute information from another routing protocol\n"
15634 "Open Shortest Path First (OSPFv2)\n"
15635 "Non-main Kernel Routing Table\n"
15636 "Instance ID/Table ID\n"
15637 "Route map reference\n"
15638 "Pointer to route-map entries\n"
15639 "Metric for redistributed routes\n"
15640 "Default metric\n")
15642 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15643 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15644 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15645 "Redistribute information from another routing protocol\n"
15646 "Open Shortest Path First (OSPFv2)\n"
15647 "Non-main Kernel Routing Table\n"
15648 "Instance ID/Table ID\n"
15649 "Metric for redistributed routes\n"
15651 "Route map reference\n"
15652 "Pointer to route-map entries\n")
15654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15655 int idx_ospf_table
= 1;
15656 int idx_number
= 2;
15657 int idx_number_2
= 4;
15660 struct bgp_redist
*red
;
15661 unsigned short instance
;
15664 struct route_map
*route_map
=
15665 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15667 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15668 protocol
= ZEBRA_ROUTE_OSPF
;
15670 protocol
= ZEBRA_ROUTE_TABLE
;
15672 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15673 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15675 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15676 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15679 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15680 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15684 bgp_redistribute_ipv4_ospf_metric_rmap
,
15685 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15686 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15687 "Redistribute information from another routing protocol\n"
15688 "Open Shortest Path First (OSPFv2)\n"
15689 "Non-main Kernel Routing Table\n"
15690 "Instance ID/Table ID\n"
15691 "Metric for redistributed routes\n"
15693 "Route map reference\n"
15694 "Pointer to route-map entries\n")
15696 DEFUN (no_bgp_redistribute_ipv4_ospf
,
15697 no_bgp_redistribute_ipv4_ospf_cmd
,
15698 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15700 "Redistribute information from another routing protocol\n"
15701 "Open Shortest Path First (OSPFv2)\n"
15702 "Non-main Kernel Routing Table\n"
15703 "Instance ID/Table ID\n"
15704 "Metric for redistributed routes\n"
15706 "Route map reference\n"
15707 "Pointer to route-map entries\n")
15709 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15710 int idx_ospf_table
= 2;
15711 int idx_number
= 3;
15712 unsigned short instance
;
15715 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15716 protocol
= ZEBRA_ROUTE_OSPF
;
15718 protocol
= ZEBRA_ROUTE_TABLE
;
15720 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15721 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
15725 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15726 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15728 "Redistribute information from another routing protocol\n"
15729 "Open Shortest Path First (OSPFv2)\n"
15730 "Non-main Kernel Routing Table\n"
15731 "Instance ID/Table ID\n"
15732 "Metric for redistributed routes\n"
15734 "Route map reference\n"
15735 "Pointer to route-map entries\n")
15737 DEFUN (no_bgp_redistribute_ipv4
,
15738 no_bgp_redistribute_ipv4_cmd
,
15739 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15741 "Redistribute information from another routing protocol\n"
15742 FRR_IP_REDIST_HELP_STR_BGPD
15743 "Metric for redistributed routes\n"
15745 "Route map reference\n"
15746 "Pointer to route-map entries\n")
15748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15749 int idx_protocol
= 2;
15752 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15754 vty_out(vty
, "%% Invalid route type\n");
15755 return CMD_WARNING_CONFIG_FAILED
;
15757 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
15761 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15762 "no redistribute " FRR_IP_REDIST_STR_BGPD
15763 " [{metric (0-4294967295)|route-map WORD}]",
15765 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15766 "Metric for redistributed routes\n"
15768 "Route map reference\n"
15769 "Pointer to route-map entries\n")
15771 DEFUN (bgp_redistribute_ipv6
,
15772 bgp_redistribute_ipv6_cmd
,
15773 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15774 "Redistribute information from another routing protocol\n"
15775 FRR_IP6_REDIST_HELP_STR_BGPD
)
15777 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15778 int idx_protocol
= 1;
15781 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15783 vty_out(vty
, "%% Invalid route type\n");
15784 return CMD_WARNING_CONFIG_FAILED
;
15787 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15788 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
15791 DEFUN (bgp_redistribute_ipv6_rmap
,
15792 bgp_redistribute_ipv6_rmap_cmd
,
15793 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15794 "Redistribute information from another routing protocol\n"
15795 FRR_IP6_REDIST_HELP_STR_BGPD
15796 "Route map reference\n"
15797 "Pointer to route-map entries\n")
15799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15800 int idx_protocol
= 1;
15803 struct bgp_redist
*red
;
15805 struct route_map
*route_map
=
15806 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15808 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15810 vty_out(vty
, "%% Invalid route type\n");
15811 return CMD_WARNING_CONFIG_FAILED
;
15814 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15816 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15817 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15820 DEFUN (bgp_redistribute_ipv6_metric
,
15821 bgp_redistribute_ipv6_metric_cmd
,
15822 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15823 "Redistribute information from another routing protocol\n"
15824 FRR_IP6_REDIST_HELP_STR_BGPD
15825 "Metric for redistributed routes\n"
15826 "Default metric\n")
15828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15829 int idx_protocol
= 1;
15830 int idx_number
= 3;
15833 struct bgp_redist
*red
;
15836 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15838 vty_out(vty
, "%% Invalid route type\n");
15839 return CMD_WARNING_CONFIG_FAILED
;
15841 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15843 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15844 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
15845 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15848 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
15849 bgp_redistribute_ipv6_rmap_metric_cmd
,
15850 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15851 "Redistribute information from another routing protocol\n"
15852 FRR_IP6_REDIST_HELP_STR_BGPD
15853 "Route map reference\n"
15854 "Pointer to route-map entries\n"
15855 "Metric for redistributed routes\n"
15856 "Default metric\n")
15858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15859 int idx_protocol
= 1;
15861 int idx_number
= 5;
15864 struct bgp_redist
*red
;
15866 struct route_map
*route_map
=
15867 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15869 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15871 vty_out(vty
, "%% Invalid route type\n");
15872 return CMD_WARNING_CONFIG_FAILED
;
15874 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15876 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15878 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15879 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
15881 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15884 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
15885 bgp_redistribute_ipv6_metric_rmap_cmd
,
15886 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15887 "Redistribute information from another routing protocol\n"
15888 FRR_IP6_REDIST_HELP_STR_BGPD
15889 "Metric for redistributed routes\n"
15891 "Route map reference\n"
15892 "Pointer to route-map entries\n")
15894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15895 int idx_protocol
= 1;
15896 int idx_number
= 3;
15900 struct bgp_redist
*red
;
15902 struct route_map
*route_map
=
15903 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15905 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15907 vty_out(vty
, "%% Invalid route type\n");
15908 return CMD_WARNING_CONFIG_FAILED
;
15910 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15912 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15913 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
15916 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15917 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15920 DEFUN (no_bgp_redistribute_ipv6
,
15921 no_bgp_redistribute_ipv6_cmd
,
15922 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15924 "Redistribute information from another routing protocol\n"
15925 FRR_IP6_REDIST_HELP_STR_BGPD
15926 "Metric for redistributed routes\n"
15928 "Route map reference\n"
15929 "Pointer to route-map entries\n")
15931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15932 int idx_protocol
= 2;
15935 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15937 vty_out(vty
, "%% Invalid route type\n");
15938 return CMD_WARNING_CONFIG_FAILED
;
15941 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
15944 /* Neighbor update tcp-mss. */
15945 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
15946 const char *tcp_mss_str
)
15949 uint32_t tcp_mss_val
= 0;
15951 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
15953 return CMD_WARNING_CONFIG_FAILED
;
15956 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
15957 peer_tcp_mss_set(peer
, tcp_mss_val
);
15959 peer_tcp_mss_unset(peer
);
15962 return CMD_SUCCESS
;
15965 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
15966 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
15967 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
15968 "TCP max segment size\n"
15971 int peer_index
= 1;
15975 " Warning: Reset BGP session for tcp-mss value to take effect\n");
15976 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
15977 argv
[mss_index
]->arg
);
15980 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
15981 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
15982 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
15983 "TCP max segment size\n"
15986 int peer_index
= 2;
15989 " Warning: Reset BGP session for tcp-mss value to take effect\n");
15990 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
15993 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
15994 afi_t afi
, safi_t safi
)
15998 /* Unicast redistribution only. */
15999 if (safi
!= SAFI_UNICAST
)
16002 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16003 /* Redistribute BGP does not make sense. */
16004 if (i
!= ZEBRA_ROUTE_BGP
) {
16005 struct list
*red_list
;
16006 struct listnode
*node
;
16007 struct bgp_redist
*red
;
16009 red_list
= bgp
->redist
[afi
][i
];
16013 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16014 /* "redistribute" configuration. */
16015 vty_out(vty
, " redistribute %s",
16016 zebra_route_string(i
));
16018 vty_out(vty
, " %d", red
->instance
);
16019 if (red
->redist_metric_flag
)
16020 vty_out(vty
, " metric %u",
16021 red
->redist_metric
);
16022 if (red
->rmap
.name
)
16023 vty_out(vty
, " route-map %s",
16025 vty_out(vty
, "\n");
16031 /* peer-group helpers for config-write */
16033 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16035 if (!peer_group_active(peer
)) {
16036 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16037 return !CHECK_FLAG(peer
->flags
, flag
);
16039 return !!CHECK_FLAG(peer
->flags
, flag
);
16042 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16045 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16048 if (!peer_group_active(peer
)) {
16049 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16050 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16052 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16055 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16058 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16059 uint8_t type
, int direct
)
16061 struct bgp_filter
*filter
;
16063 if (peer_group_active(peer
))
16064 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16067 filter
= &peer
->filter
[afi
][safi
];
16069 case PEER_FT_DISTRIBUTE_LIST
:
16070 return !!(filter
->dlist
[direct
].name
);
16071 case PEER_FT_FILTER_LIST
:
16072 return !!(filter
->aslist
[direct
].name
);
16073 case PEER_FT_PREFIX_LIST
:
16074 return !!(filter
->plist
[direct
].name
);
16075 case PEER_FT_ROUTE_MAP
:
16076 return !!(filter
->map
[direct
].name
);
16077 case PEER_FT_UNSUPPRESS_MAP
:
16078 return !!(filter
->usmap
.name
);
16079 case PEER_FT_ADVERTISE_MAP
:
16080 return !!(filter
->advmap
.aname
16081 && ((filter
->advmap
.condition
== direct
)
16082 && filter
->advmap
.cname
));
16088 /* Return true if the addpath type is set for peer and different from
16091 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16094 enum bgp_addpath_strat type
, g_type
;
16096 type
= peer
->addpath_type
[afi
][safi
];
16098 if (type
!= BGP_ADDPATH_NONE
) {
16099 if (peer_group_active(peer
)) {
16100 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16102 if (type
!= g_type
)
16114 /* This is part of the address-family block (unicast only) */
16115 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16119 uint32_t tovpn_sid_index
= 0;
16121 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16122 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16123 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16124 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16125 bgp
->vpn_policy
[afi
]
16126 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16128 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16129 bgp
->vpn_policy
[afi
]
16130 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16132 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16133 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16134 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16135 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16138 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16139 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16141 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16144 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16145 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16146 bgp
->vpn_policy
[afi
].tovpn_label
);
16150 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16151 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16152 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16153 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16154 } else if (tovpn_sid_index
!= 0) {
16155 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16159 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16160 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16161 char buf
[RD_ADDRSTRLEN
];
16162 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16163 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16166 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16167 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16169 char buf
[PREFIX_STRLEN
];
16170 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16171 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16174 vty_out(vty
, "%*snexthop vpn export %s\n",
16178 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16179 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16181 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16182 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16184 char *b
= ecommunity_ecom2str(
16185 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16186 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16187 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16188 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16190 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16191 char *b
= ecommunity_ecom2str(
16192 bgp
->vpn_policy
[afi
]
16193 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16194 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16195 ECOMMUNITY_ROUTE_TARGET
);
16196 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16197 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16199 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16200 char *b
= ecommunity_ecom2str(
16201 bgp
->vpn_policy
[afi
]
16202 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16203 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16204 ECOMMUNITY_ROUTE_TARGET
);
16205 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16206 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16210 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16211 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16212 bgp
->vpn_policy
[afi
]
16213 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16215 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16216 char *b
= ecommunity_ecom2str(
16217 bgp
->vpn_policy
[afi
]
16218 .import_redirect_rtlist
,
16219 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16220 ECOMMUNITY_ROUTE_TARGET
);
16222 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16223 != ECOMMUNITY_SIZE
)
16224 vty_out(vty
, "%*srt6 redirect import %s\n",
16227 vty_out(vty
, "%*srt redirect import %s\n",
16229 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16233 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16234 afi_t afi
, safi_t safi
)
16236 struct bgp_filter
*filter
;
16240 filter
= &peer
->filter
[afi
][safi
];
16242 /* distribute-list. */
16243 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16245 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16246 filter
->dlist
[FILTER_IN
].name
);
16248 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16250 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16251 filter
->dlist
[FILTER_OUT
].name
);
16254 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16256 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16257 filter
->plist
[FILTER_IN
].name
);
16259 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16261 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16262 filter
->plist
[FILTER_OUT
].name
);
16265 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16266 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16267 filter
->map
[RMAP_IN
].name
);
16269 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16271 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16272 filter
->map
[RMAP_OUT
].name
);
16274 /* unsuppress-map */
16275 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16276 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16277 filter
->usmap
.name
);
16279 /* advertise-map : always applied in OUT direction*/
16280 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16281 CONDITION_NON_EXIST
))
16283 " neighbor %s advertise-map %s non-exist-map %s\n",
16284 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16286 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16288 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16289 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16292 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16294 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16295 filter
->aslist
[FILTER_IN
].name
);
16297 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16299 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16300 filter
->aslist
[FILTER_OUT
].name
);
16303 /* BGP peer configuration display function. */
16304 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16307 struct peer
*g_peer
= NULL
;
16308 char buf
[SU_ADDRSTRLEN
];
16310 int if_pg_printed
= false;
16311 int if_ras_printed
= false;
16313 /* Skip dynamic neighbors. */
16314 if (peer_dynamic_neighbor(peer
))
16318 addr
= peer
->conf_if
;
16322 /************************************
16323 ****** Global to the neighbor ******
16324 ************************************/
16325 if (peer
->conf_if
) {
16326 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16327 vty_out(vty
, " neighbor %s interface v6only", addr
);
16329 vty_out(vty
, " neighbor %s interface", addr
);
16331 if (peer_group_active(peer
)) {
16332 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16333 if_pg_printed
= true;
16334 } else if (peer
->as_type
== AS_SPECIFIED
) {
16335 vty_out(vty
, " remote-as %u", peer
->as
);
16336 if_ras_printed
= true;
16337 } else if (peer
->as_type
== AS_INTERNAL
) {
16338 vty_out(vty
, " remote-as internal");
16339 if_ras_printed
= true;
16340 } else if (peer
->as_type
== AS_EXTERNAL
) {
16341 vty_out(vty
, " remote-as external");
16342 if_ras_printed
= true;
16345 vty_out(vty
, "\n");
16348 /* remote-as and peer-group */
16349 /* peer is a member of a peer-group */
16350 if (peer_group_active(peer
)) {
16351 g_peer
= peer
->group
->conf
;
16353 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16354 if (peer
->as_type
== AS_SPECIFIED
) {
16355 vty_out(vty
, " neighbor %s remote-as %u\n",
16357 } else if (peer
->as_type
== AS_INTERNAL
) {
16359 " neighbor %s remote-as internal\n",
16361 } else if (peer
->as_type
== AS_EXTERNAL
) {
16363 " neighbor %s remote-as external\n",
16368 /* For swpX peers we displayed the peer-group
16369 * via 'neighbor swpX interface peer-group PGNAME' */
16370 if (!if_pg_printed
)
16371 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16372 peer
->group
->name
);
16375 /* peer is NOT a member of a peer-group */
16377 /* peer is a peer-group, declare the peer-group */
16378 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16379 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16382 if (!if_ras_printed
) {
16383 if (peer
->as_type
== AS_SPECIFIED
) {
16384 vty_out(vty
, " neighbor %s remote-as %u\n",
16386 } else if (peer
->as_type
== AS_INTERNAL
) {
16388 " neighbor %s remote-as internal\n",
16390 } else if (peer
->as_type
== AS_EXTERNAL
) {
16392 " neighbor %s remote-as external\n",
16399 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16400 vty_out(vty
, " neighbor %s local-as %u", addr
,
16401 peer
->change_local_as
);
16402 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16403 vty_out(vty
, " no-prepend");
16404 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16405 vty_out(vty
, " replace-as");
16406 vty_out(vty
, "\n");
16411 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16415 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16416 if (peer
->tx_shutdown_message
)
16417 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16418 peer
->tx_shutdown_message
);
16420 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16423 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16424 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16425 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16428 if (peer
->bfd_config
)
16429 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16432 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16433 vty_out(vty
, " neighbor %s password %s\n", addr
,
16436 /* neighbor solo */
16437 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16438 if (!peer_group_active(peer
)) {
16439 vty_out(vty
, " neighbor %s solo\n", addr
);
16444 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16445 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16448 /* Local interface name */
16449 if (peer
->ifname
) {
16450 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16453 /* TCP max segment size */
16454 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16455 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16458 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16459 vty_out(vty
, " neighbor %s passive\n", addr
);
16461 /* ebgp-multihop */
16462 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16463 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16464 && peer
->ttl
== MAXTTL
)) {
16465 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16466 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16471 /* ttl-security hops */
16472 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16473 if (!peer_group_active(peer
)
16474 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16475 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16476 addr
, peer
->gtsm_hops
);
16480 /* disable-connected-check */
16481 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16482 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16484 /* link-bw-encoding-ieee */
16485 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
16486 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
16489 /* extended-optional-parameters */
16490 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
16491 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
16494 /* enforce-first-as */
16495 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16496 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16498 /* update-source */
16499 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16500 if (peer
->update_source
)
16501 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16502 sockunion2str(peer
->update_source
, buf
,
16504 else if (peer
->update_if
)
16505 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16509 /* advertisement-interval */
16510 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16511 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16515 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16516 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16517 peer
->keepalive
, peer
->holdtime
);
16519 /* timers connect */
16520 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16521 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16523 /* need special-case handling for changed default values due to
16524 * config profile / version (because there is no "timers bgp connect"
16525 * command, we need to save this per-peer :/)
16527 else if (!peer_group_active(peer
) && !peer
->connect
&&
16528 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16529 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16530 peer
->bgp
->default_connect_retry
);
16532 /* timers delayopen */
16533 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16534 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16536 /* Save config even though flag is not set if default values have been
16539 else if (!peer_group_active(peer
) && !peer
->delayopen
16540 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16541 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16542 peer
->bgp
->default_delayopen
);
16544 /* capability dynamic */
16545 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16546 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16548 /* capability extended-nexthop */
16549 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16550 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
))
16552 " no neighbor %s capability extended-nexthop\n",
16554 else if (!peer
->conf_if
)
16556 " neighbor %s capability extended-nexthop\n",
16560 /* dont-capability-negotiation */
16561 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16562 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16564 /* override-capability */
16565 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16566 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16568 /* strict-capability-match */
16569 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16570 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16572 /* Sender side AS path loop detection. */
16573 if (peer
->as_path_loop_detection
)
16574 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16577 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16578 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16580 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16581 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16583 " neighbor %s graceful-restart-helper\n", addr
);
16584 } else if (CHECK_FLAG(
16585 peer
->peer_gr_new_status_flag
,
16586 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16588 " neighbor %s graceful-restart\n", addr
);
16590 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16591 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16593 peer
->peer_gr_new_status_flag
,
16594 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16595 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16601 /* BGP peer configuration display function. */
16602 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16603 struct peer
*peer
, afi_t afi
, safi_t safi
)
16605 struct peer
*g_peer
= NULL
;
16607 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16609 /* Skip dynamic neighbors. */
16610 if (peer_dynamic_neighbor(peer
))
16614 addr
= peer
->conf_if
;
16618 /************************************
16619 ****** Per AF to the neighbor ******
16620 ************************************/
16621 if (peer_group_active(peer
)) {
16622 g_peer
= peer
->group
->conf
;
16624 /* If the peer-group is active but peer is not, print a 'no
16626 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16627 vty_out(vty
, " no neighbor %s activate\n", addr
);
16630 /* If the peer-group is not active but peer is, print an
16632 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16633 vty_out(vty
, " neighbor %s activate\n", addr
);
16636 if (peer
->afc
[afi
][safi
]) {
16637 if (safi
== SAFI_ENCAP
)
16638 vty_out(vty
, " neighbor %s activate\n", addr
);
16639 else if (!bgp
->default_af
[afi
][safi
])
16640 vty_out(vty
, " neighbor %s activate\n", addr
);
16642 if (bgp
->default_af
[afi
][safi
])
16643 vty_out(vty
, " no neighbor %s activate\n",
16648 /* addpath TX knobs */
16649 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16650 switch (peer
->addpath_type
[afi
][safi
]) {
16651 case BGP_ADDPATH_ALL
:
16652 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16655 case BGP_ADDPATH_BEST_PER_AS
:
16657 " neighbor %s addpath-tx-bestpath-per-AS\n",
16660 case BGP_ADDPATH_MAX
:
16661 case BGP_ADDPATH_NONE
:
16666 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
16667 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
16669 /* ORF capability. */
16670 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16671 || peergroup_af_flag_check(peer
, afi
, safi
,
16672 PEER_FLAG_ORF_PREFIX_RM
)) {
16673 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16675 if (peergroup_af_flag_check(peer
, afi
, safi
,
16676 PEER_FLAG_ORF_PREFIX_SM
)
16677 && peergroup_af_flag_check(peer
, afi
, safi
,
16678 PEER_FLAG_ORF_PREFIX_RM
))
16679 vty_out(vty
, " both");
16680 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16681 PEER_FLAG_ORF_PREFIX_SM
))
16682 vty_out(vty
, " send");
16684 vty_out(vty
, " receive");
16685 vty_out(vty
, "\n");
16688 /* Route reflector client. */
16689 if (peergroup_af_flag_check(peer
, afi
, safi
,
16690 PEER_FLAG_REFLECTOR_CLIENT
)) {
16691 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16694 /* next-hop-self force */
16695 if (peergroup_af_flag_check(peer
, afi
, safi
,
16696 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16697 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16700 /* next-hop-self */
16701 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16702 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16705 /* remove-private-AS */
16706 if (peergroup_af_flag_check(peer
, afi
, safi
,
16707 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16708 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16712 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16713 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16714 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16718 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16719 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16720 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16723 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16724 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16725 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16729 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16730 vty_out(vty
, " neighbor %s as-override\n", addr
);
16733 /* send-community print. */
16734 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16735 PEER_FLAG_SEND_COMMUNITY
);
16736 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16737 PEER_FLAG_SEND_EXT_COMMUNITY
);
16738 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16739 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16741 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16742 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16745 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16748 " no neighbor %s send-community extended\n",
16752 vty_out(vty
, " no neighbor %s send-community large\n",
16756 /* Default information */
16757 if (peergroup_af_flag_check(peer
, afi
, safi
,
16758 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16759 vty_out(vty
, " neighbor %s default-originate", addr
);
16761 if (peer
->default_rmap
[afi
][safi
].name
)
16762 vty_out(vty
, " route-map %s",
16763 peer
->default_rmap
[afi
][safi
].name
);
16765 vty_out(vty
, "\n");
16768 /* Soft reconfiguration inbound. */
16769 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16770 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16774 /* maximum-prefix. */
16775 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16776 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16777 peer
->pmax
[afi
][safi
]);
16779 if (peer
->pmax_threshold
[afi
][safi
]
16780 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16781 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16782 if (peer_af_flag_check(peer
, afi
, safi
,
16783 PEER_FLAG_MAX_PREFIX_WARNING
))
16784 vty_out(vty
, " warning-only");
16785 if (peer
->pmax_restart
[afi
][safi
])
16786 vty_out(vty
, " restart %u",
16787 peer
->pmax_restart
[afi
][safi
]);
16788 if (peer_af_flag_check(peer
, afi
, safi
,
16789 PEER_FLAG_MAX_PREFIX_FORCE
))
16790 vty_out(vty
, " force");
16792 vty_out(vty
, "\n");
16795 /* maximum-prefix-out */
16796 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16797 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16798 addr
, peer
->pmax_out
[afi
][safi
]);
16800 /* Route server client. */
16801 if (peergroup_af_flag_check(peer
, afi
, safi
,
16802 PEER_FLAG_RSERVER_CLIENT
)) {
16803 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16806 /* Nexthop-local unchanged. */
16807 if (peergroup_af_flag_check(peer
, afi
, safi
,
16808 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16809 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16812 /* allowas-in <1-10> */
16813 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16814 if (peer_af_flag_check(peer
, afi
, safi
,
16815 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16816 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16817 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16818 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16820 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16821 peer
->allowas_in
[afi
][safi
]);
16826 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16827 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16828 peer
->weight
[afi
][safi
]);
16831 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16833 /* atribute-unchanged. */
16834 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16835 || (safi
!= SAFI_EVPN
16836 && peer_af_flag_check(peer
, afi
, safi
,
16837 PEER_FLAG_NEXTHOP_UNCHANGED
))
16838 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16840 if (!peer_group_active(peer
)
16841 || peergroup_af_flag_check(peer
, afi
, safi
,
16842 PEER_FLAG_AS_PATH_UNCHANGED
)
16843 || peergroup_af_flag_check(peer
, afi
, safi
,
16844 PEER_FLAG_NEXTHOP_UNCHANGED
)
16845 || peergroup_af_flag_check(peer
, afi
, safi
,
16846 PEER_FLAG_MED_UNCHANGED
)) {
16849 " neighbor %s attribute-unchanged%s%s%s\n",
16851 peer_af_flag_check(peer
, afi
, safi
,
16852 PEER_FLAG_AS_PATH_UNCHANGED
)
16855 peer_af_flag_check(peer
, afi
, safi
,
16856 PEER_FLAG_NEXTHOP_UNCHANGED
)
16859 peer_af_flag_check(peer
, afi
, safi
,
16860 PEER_FLAG_MED_UNCHANGED
)
16867 /* Address family based peer configuration display. */
16868 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16872 struct peer_group
*group
;
16873 struct listnode
*node
, *nnode
;
16876 vty_frame(vty
, " !\n address-family ");
16877 if (afi
== AFI_IP
) {
16878 if (safi
== SAFI_UNICAST
)
16879 vty_frame(vty
, "ipv4 unicast");
16880 else if (safi
== SAFI_LABELED_UNICAST
)
16881 vty_frame(vty
, "ipv4 labeled-unicast");
16882 else if (safi
== SAFI_MULTICAST
)
16883 vty_frame(vty
, "ipv4 multicast");
16884 else if (safi
== SAFI_MPLS_VPN
)
16885 vty_frame(vty
, "ipv4 vpn");
16886 else if (safi
== SAFI_ENCAP
)
16887 vty_frame(vty
, "ipv4 encap");
16888 else if (safi
== SAFI_FLOWSPEC
)
16889 vty_frame(vty
, "ipv4 flowspec");
16890 } else if (afi
== AFI_IP6
) {
16891 if (safi
== SAFI_UNICAST
)
16892 vty_frame(vty
, "ipv6 unicast");
16893 else if (safi
== SAFI_LABELED_UNICAST
)
16894 vty_frame(vty
, "ipv6 labeled-unicast");
16895 else if (safi
== SAFI_MULTICAST
)
16896 vty_frame(vty
, "ipv6 multicast");
16897 else if (safi
== SAFI_MPLS_VPN
)
16898 vty_frame(vty
, "ipv6 vpn");
16899 else if (safi
== SAFI_ENCAP
)
16900 vty_frame(vty
, "ipv6 encap");
16901 else if (safi
== SAFI_FLOWSPEC
)
16902 vty_frame(vty
, "ipv6 flowspec");
16903 } else if (afi
== AFI_L2VPN
) {
16904 if (safi
== SAFI_EVPN
)
16905 vty_frame(vty
, "l2vpn evpn");
16907 vty_frame(vty
, "\n");
16909 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16911 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16913 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16915 /* BGP flag dampening. */
16916 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16917 bgp_config_write_damp(vty
, afi
, safi
);
16919 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16920 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16922 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16923 /* Do not display doppelganger peers */
16924 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16925 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16928 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16929 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16931 if (safi
== SAFI_EVPN
)
16932 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16934 if (safi
== SAFI_FLOWSPEC
)
16935 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16937 if (safi
== SAFI_UNICAST
) {
16938 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16939 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16940 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16942 vty_out(vty
, " export vpn\n");
16944 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16945 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16947 vty_out(vty
, " import vpn\n");
16949 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16950 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16953 for (ALL_LIST_ELEMENTS_RO(
16954 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16956 vty_out(vty
, " import vrf %s\n", name
);
16960 vty_endframe(vty
, " exit-address-family\n");
16963 int bgp_config_write(struct vty
*vty
)
16966 struct peer_group
*group
;
16968 struct listnode
*node
, *nnode
;
16969 struct listnode
*mnode
, *mnnode
;
16973 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
16974 vty_out(vty
, "bgp route-map delay-timer %u\n",
16975 bm
->rmap_update_timer
);
16977 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
16978 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
16979 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
16980 vty_out(vty
, " %d", bm
->v_establish_wait
);
16981 vty_out(vty
, "\n");
16984 if (bm
->wait_for_fib
)
16985 vty_out(vty
, "bgp suppress-fib-pending\n");
16987 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16988 vty_out(vty
, "bgp graceful-shutdown\n");
16990 /* No-RIB (Zebra) option flag configuration */
16991 if (bgp_option_check(BGP_OPT_NO_FIB
))
16992 vty_out(vty
, "bgp no-rib\n");
16994 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
16995 vty_out(vty
, "no bgp send-extra-data zebra\n");
16997 /* BGP configuration. */
16998 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17000 /* skip all auto created vrf as they dont have user config */
17001 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17004 /* Router bgp ASN */
17005 vty_out(vty
, "router bgp %u", bgp
->as
);
17008 vty_out(vty
, " %s %s",
17009 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17010 ? "view" : "vrf", bgp
->name
);
17011 vty_out(vty
, "\n");
17013 /* BGP fast-external-failover. */
17014 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17015 vty_out(vty
, " no bgp fast-external-failover\n");
17017 /* BGP router ID. */
17018 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17019 vty_out(vty
, " bgp router-id %pI4\n",
17020 &bgp
->router_id_static
);
17022 /* Suppress fib pending */
17023 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17024 vty_out(vty
, " bgp suppress-fib-pending\n");
17026 /* BGP log-neighbor-changes. */
17027 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17028 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17029 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17030 CHECK_FLAG(bgp
->flags
,
17031 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17035 /* BGP configuration. */
17036 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17037 vty_out(vty
, " bgp always-compare-med\n");
17039 /* RFC8212 default eBGP policy. */
17040 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17041 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17042 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17043 CHECK_FLAG(bgp
->flags
,
17044 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17048 /* draft-ietf-idr-deprecate-as-set-confed-set */
17049 if (bgp
->reject_as_sets
)
17050 vty_out(vty
, " bgp reject-as-sets\n");
17052 /* Suppress duplicate updates if the route actually not changed
17054 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17055 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17056 vty_out(vty
, " %sbgp suppress-duplicates\n",
17057 CHECK_FLAG(bgp
->flags
,
17058 BGP_FLAG_SUPPRESS_DUPLICATES
)
17062 /* BGP default <afi>-<safi> */
17063 FOREACH_AFI_SAFI (afi
, safi
) {
17064 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17065 if (!bgp
->default_af
[afi
][safi
])
17066 vty_out(vty
, " no bgp default %s\n",
17067 get_bgp_default_af_flag(afi
,
17069 } else if (bgp
->default_af
[afi
][safi
])
17070 vty_out(vty
, " bgp default %s\n",
17071 get_bgp_default_af_flag(afi
, safi
));
17074 /* BGP default local-preference. */
17075 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17076 vty_out(vty
, " bgp default local-preference %u\n",
17077 bgp
->default_local_pref
);
17079 /* BGP default show-hostname */
17080 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17081 != SAVE_BGP_SHOW_HOSTNAME
)
17082 vty_out(vty
, " %sbgp default show-hostname\n",
17083 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17087 /* BGP default show-nexthop-hostname */
17088 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17089 != SAVE_BGP_SHOW_HOSTNAME
)
17090 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17091 CHECK_FLAG(bgp
->flags
,
17092 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17096 /* BGP default subgroup-pkt-queue-max. */
17097 if (bgp
->default_subgroup_pkt_queue_max
17098 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17099 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17100 bgp
->default_subgroup_pkt_queue_max
);
17102 /* BGP client-to-client reflection. */
17103 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17104 vty_out(vty
, " no bgp client-to-client reflection\n");
17106 /* BGP cluster ID. */
17107 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17108 vty_out(vty
, " bgp cluster-id %pI4\n",
17111 /* Disable ebgp connected nexthop check */
17112 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17114 " bgp disable-ebgp-connected-route-check\n");
17116 /* Confederation identifier*/
17117 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17118 vty_out(vty
, " bgp confederation identifier %u\n",
17121 /* Confederation peer */
17122 if (bgp
->confed_peers_cnt
> 0) {
17125 vty_out(vty
, " bgp confederation peers");
17127 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17128 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17130 vty_out(vty
, "\n");
17133 /* BGP deterministic-med. */
17134 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17135 != SAVE_BGP_DETERMINISTIC_MED
)
17136 vty_out(vty
, " %sbgp deterministic-med\n",
17137 CHECK_FLAG(bgp
->flags
,
17138 BGP_FLAG_DETERMINISTIC_MED
)
17142 /* BGP update-delay. */
17143 bgp_config_write_update_delay(vty
, bgp
);
17145 if (bgp
->v_maxmed_onstartup
17146 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17147 vty_out(vty
, " bgp max-med on-startup %u",
17148 bgp
->v_maxmed_onstartup
);
17149 if (bgp
->maxmed_onstartup_value
17150 != BGP_MAXMED_VALUE_DEFAULT
)
17151 vty_out(vty
, " %u",
17152 bgp
->maxmed_onstartup_value
);
17153 vty_out(vty
, "\n");
17155 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17156 vty_out(vty
, " bgp max-med administrative");
17157 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17158 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17159 vty_out(vty
, "\n");
17163 bgp_config_write_wpkt_quanta(vty
, bgp
);
17165 bgp_config_write_rpkt_quanta(vty
, bgp
);
17167 /* coalesce time */
17168 bgp_config_write_coalesce_time(vty
, bgp
);
17170 /* BGP per-instance graceful-shutdown */
17171 /* BGP-wide settings and per-instance settings are mutually
17174 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17175 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17176 vty_out(vty
, " bgp graceful-shutdown\n");
17178 /* Long-lived Graceful Restart */
17179 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17181 " bgp long-lived-graceful-restart stale-time %u\n",
17182 bgp
->llgr_stale_time
);
17184 /* BGP graceful-restart. */
17185 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17187 " bgp graceful-restart stalepath-time %u\n",
17188 bgp
->stalepath_time
);
17190 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17191 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17192 bgp
->restart_time
);
17194 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17196 " bgp graceful-restart select-defer-time %u\n",
17197 bgp
->select_defer_time
);
17199 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17200 vty_out(vty
, " bgp graceful-restart\n");
17202 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17203 vty_out(vty
, " bgp graceful-restart-disable\n");
17205 /* BGP graceful-restart Preserve State F bit. */
17206 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17208 " bgp graceful-restart preserve-fw-state\n");
17210 /* Stale timer for RIB */
17211 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17213 " bgp graceful-restart rib-stale-time %u\n",
17214 bgp
->rib_stale_time
);
17216 /* BGP bestpath method. */
17217 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17218 vty_out(vty
, " bgp bestpath as-path ignore\n");
17219 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17220 vty_out(vty
, " bgp bestpath as-path confed\n");
17222 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17223 if (CHECK_FLAG(bgp
->flags
,
17224 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17226 " bgp bestpath as-path multipath-relax as-set\n");
17229 " bgp bestpath as-path multipath-relax\n");
17233 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17235 " bgp route-reflector allow-outbound-policy\n");
17237 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17238 vty_out(vty
, " bgp bestpath compare-routerid\n");
17239 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17240 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17241 vty_out(vty
, " bgp bestpath med");
17242 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17243 vty_out(vty
, " confed");
17244 if (CHECK_FLAG(bgp
->flags
,
17245 BGP_FLAG_MED_MISSING_AS_WORST
))
17246 vty_out(vty
, " missing-as-worst");
17247 vty_out(vty
, "\n");
17250 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17252 " bgp bestpath peer-type multipath-relax\n");
17254 /* Link bandwidth handling. */
17255 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17256 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17257 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17258 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17259 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17260 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17262 /* BGP network import check. */
17263 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17264 != SAVE_BGP_IMPORT_CHECK
)
17265 vty_out(vty
, " %sbgp network import-check\n",
17266 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17270 /* BGP timers configuration. */
17271 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17272 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17273 vty_out(vty
, " timers bgp %u %u\n",
17274 bgp
->default_keepalive
, bgp
->default_holdtime
);
17276 /* BGP minimum holdtime configuration. */
17277 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17278 && bgp
->default_min_holdtime
!= 0)
17279 vty_out(vty
, " bgp minimum-holdtime %u\n",
17280 bgp
->default_min_holdtime
);
17282 /* Conditional advertisement timer configuration */
17283 if (bgp
->condition_check_period
17284 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17286 " bgp conditional-advertisement timer %u\n",
17287 bgp
->condition_check_period
);
17290 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17291 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17294 /* Normal neighbor configuration. */
17295 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17296 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17297 bgp_config_write_peer_global(vty
, bgp
, peer
);
17300 /* listen range and limit for dynamic BGP neighbors */
17301 bgp_config_write_listen(vty
, bgp
);
17304 * BGP default autoshutdown neighbors
17306 * This must be placed after any peer and peer-group
17307 * configuration, to avoid setting all peers to shutdown after
17308 * a daemon restart, which is undesired behavior. (see #2286)
17310 if (bgp
->autoshutdown
)
17311 vty_out(vty
, " bgp default shutdown\n");
17313 /* BGP instance administrative shutdown */
17314 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17315 vty_out(vty
, " bgp shutdown\n");
17317 if (bgp
->fast_convergence
)
17318 vty_out(vty
, " bgp fast-convergence\n");
17320 if (bgp
->srv6_enabled
) {
17321 vty_frame(vty
, " !\n segment-routing srv6\n");
17322 if (strlen(bgp
->srv6_locator_name
))
17323 vty_out(vty
, " locator %s\n",
17324 bgp
->srv6_locator_name
);
17325 vty_endframe(vty
, " exit\n");
17329 /* IPv4 unicast configuration. */
17330 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17332 /* IPv4 multicast configuration. */
17333 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17335 /* IPv4 labeled-unicast configuration. */
17336 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17338 /* IPv4 VPN configuration. */
17339 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17341 /* ENCAPv4 configuration. */
17342 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17344 /* FLOWSPEC v4 configuration. */
17345 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17347 /* IPv6 unicast configuration. */
17348 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17350 /* IPv6 multicast configuration. */
17351 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17353 /* IPv6 labeled-unicast configuration. */
17354 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17355 SAFI_LABELED_UNICAST
);
17357 /* IPv6 VPN configuration. */
17358 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17360 /* ENCAPv6 configuration. */
17361 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17363 /* FLOWSPEC v6 configuration. */
17364 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17366 /* EVPN configuration. */
17367 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17369 hook_call(bgp_inst_config_write
, bgp
, vty
);
17371 #ifdef ENABLE_BGP_VNC
17372 bgp_rfapi_cfg_write(vty
, bgp
);
17375 vty_out(vty
, "exit\n");
17376 vty_out(vty
, "!\n");
17382 /* BGP node structure. */
17383 static struct cmd_node bgp_node
= {
17386 .parent_node
= CONFIG_NODE
,
17387 .prompt
= "%s(config-router)# ",
17388 .config_write
= bgp_config_write
,
17391 static struct cmd_node bgp_ipv4_unicast_node
= {
17392 .name
= "bgp ipv4 unicast",
17393 .node
= BGP_IPV4_NODE
,
17394 .parent_node
= BGP_NODE
,
17395 .prompt
= "%s(config-router-af)# ",
17399 static struct cmd_node bgp_ipv4_multicast_node
= {
17400 .name
= "bgp ipv4 multicast",
17401 .node
= BGP_IPV4M_NODE
,
17402 .parent_node
= BGP_NODE
,
17403 .prompt
= "%s(config-router-af)# ",
17407 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17408 .name
= "bgp ipv4 labeled unicast",
17409 .node
= BGP_IPV4L_NODE
,
17410 .parent_node
= BGP_NODE
,
17411 .prompt
= "%s(config-router-af)# ",
17415 static struct cmd_node bgp_ipv6_unicast_node
= {
17416 .name
= "bgp ipv6 unicast",
17417 .node
= BGP_IPV6_NODE
,
17418 .parent_node
= BGP_NODE
,
17419 .prompt
= "%s(config-router-af)# ",
17423 static struct cmd_node bgp_ipv6_multicast_node
= {
17424 .name
= "bgp ipv6 multicast",
17425 .node
= BGP_IPV6M_NODE
,
17426 .parent_node
= BGP_NODE
,
17427 .prompt
= "%s(config-router-af)# ",
17431 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17432 .name
= "bgp ipv6 labeled unicast",
17433 .node
= BGP_IPV6L_NODE
,
17434 .parent_node
= BGP_NODE
,
17435 .prompt
= "%s(config-router-af)# ",
17439 static struct cmd_node bgp_vpnv4_node
= {
17440 .name
= "bgp vpnv4",
17441 .node
= BGP_VPNV4_NODE
,
17442 .parent_node
= BGP_NODE
,
17443 .prompt
= "%s(config-router-af)# ",
17447 static struct cmd_node bgp_vpnv6_node
= {
17448 .name
= "bgp vpnv6",
17449 .node
= BGP_VPNV6_NODE
,
17450 .parent_node
= BGP_NODE
,
17451 .prompt
= "%s(config-router-af-vpnv6)# ",
17455 static struct cmd_node bgp_evpn_node
= {
17456 .name
= "bgp evpn",
17457 .node
= BGP_EVPN_NODE
,
17458 .parent_node
= BGP_NODE
,
17459 .prompt
= "%s(config-router-evpn)# ",
17463 static struct cmd_node bgp_evpn_vni_node
= {
17464 .name
= "bgp evpn vni",
17465 .node
= BGP_EVPN_VNI_NODE
,
17466 .parent_node
= BGP_EVPN_NODE
,
17467 .prompt
= "%s(config-router-af-vni)# ",
17470 static struct cmd_node bgp_flowspecv4_node
= {
17471 .name
= "bgp ipv4 flowspec",
17472 .node
= BGP_FLOWSPECV4_NODE
,
17473 .parent_node
= BGP_NODE
,
17474 .prompt
= "%s(config-router-af)# ",
17478 static struct cmd_node bgp_flowspecv6_node
= {
17479 .name
= "bgp ipv6 flowspec",
17480 .node
= BGP_FLOWSPECV6_NODE
,
17481 .parent_node
= BGP_NODE
,
17482 .prompt
= "%s(config-router-af-vpnv6)# ",
17486 static struct cmd_node bgp_srv6_node
= {
17487 .name
= "bgp srv6",
17488 .node
= BGP_SRV6_NODE
,
17489 .parent_node
= BGP_NODE
,
17490 .prompt
= "%s(config-router-srv6)# ",
17493 static void community_list_vty(void);
17495 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17498 struct peer_group
*group
;
17499 struct listnode
*lnbgp
, *lnpeer
;
17501 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17502 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17504 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
17508 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
17512 struct listnode
*lnbgp
, *lnpeer
;
17514 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17515 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17516 /* only provide suggestions on the appropriate input
17518 * they'll otherwise show up multiple times */
17519 enum cmd_token_type match_type
;
17520 char *name
= peer
->host
;
17522 if (peer
->conf_if
) {
17523 match_type
= VARIABLE_TKN
;
17524 name
= peer
->conf_if
;
17525 } else if (strchr(peer
->host
, ':'))
17526 match_type
= IPV6_TKN
;
17528 match_type
= IPV4_TKN
;
17530 if (token
->type
!= match_type
)
17533 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17538 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17540 bgp_ac_peer(comps
, token
);
17542 if (token
->type
== VARIABLE_TKN
)
17543 bgp_ac_peergroup(comps
, token
);
17546 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17547 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17548 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17549 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17550 {.completions
= NULL
}};
17552 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17553 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17554 {.completions
= NULL
} };
17556 void bgp_vty_init(void)
17558 cmd_variable_handler_register(bgp_var_neighbor
);
17559 cmd_variable_handler_register(bgp_var_peergroup
);
17561 /* Install bgp top node. */
17562 install_node(&bgp_node
);
17563 install_node(&bgp_ipv4_unicast_node
);
17564 install_node(&bgp_ipv4_multicast_node
);
17565 install_node(&bgp_ipv4_labeled_unicast_node
);
17566 install_node(&bgp_ipv6_unicast_node
);
17567 install_node(&bgp_ipv6_multicast_node
);
17568 install_node(&bgp_ipv6_labeled_unicast_node
);
17569 install_node(&bgp_vpnv4_node
);
17570 install_node(&bgp_vpnv6_node
);
17571 install_node(&bgp_evpn_node
);
17572 install_node(&bgp_evpn_vni_node
);
17573 install_node(&bgp_flowspecv4_node
);
17574 install_node(&bgp_flowspecv6_node
);
17575 install_node(&bgp_srv6_node
);
17577 /* Install default VTY commands to new nodes. */
17578 install_default(BGP_NODE
);
17579 install_default(BGP_IPV4_NODE
);
17580 install_default(BGP_IPV4M_NODE
);
17581 install_default(BGP_IPV4L_NODE
);
17582 install_default(BGP_IPV6_NODE
);
17583 install_default(BGP_IPV6M_NODE
);
17584 install_default(BGP_IPV6L_NODE
);
17585 install_default(BGP_VPNV4_NODE
);
17586 install_default(BGP_VPNV6_NODE
);
17587 install_default(BGP_FLOWSPECV4_NODE
);
17588 install_default(BGP_FLOWSPECV6_NODE
);
17589 install_default(BGP_EVPN_NODE
);
17590 install_default(BGP_EVPN_VNI_NODE
);
17591 install_default(BGP_SRV6_NODE
);
17593 /* "bgp local-mac" hidden commands. */
17594 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17595 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17597 /* "bgp suppress-fib-pending" global */
17598 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17600 /* bgp route-map delay-timer commands. */
17601 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17602 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17604 /* bgp fast-convergence command */
17605 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
17606 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
17608 /* global bgp update-delay command */
17609 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17610 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17612 /* global bgp graceful-shutdown command */
17613 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17614 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17616 /* Dummy commands (Currently not supported) */
17617 install_element(BGP_NODE
, &no_synchronization_cmd
);
17618 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17620 /* "router bgp" commands. */
17621 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17623 /* "no router bgp" commands. */
17624 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17626 /* "bgp router-id" commands. */
17627 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17628 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17630 /* "bgp suppress-fib-pending" command */
17631 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17633 /* "bgp cluster-id" commands. */
17634 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17635 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17637 /* "bgp no-rib" commands. */
17638 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17639 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17641 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17643 /* "bgp confederation" commands. */
17644 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17645 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17647 /* "bgp confederation peers" commands. */
17648 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17649 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17651 /* bgp max-med command */
17652 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17653 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17654 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17655 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17656 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17658 /* bgp disable-ebgp-connected-nh-check */
17659 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17660 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17662 /* bgp update-delay command */
17663 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17664 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17666 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17667 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17669 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17670 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17672 /* "maximum-paths" commands. */
17673 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17674 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17675 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17676 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17677 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17678 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17679 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17680 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17681 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17682 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17683 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17684 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17685 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17686 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17687 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17689 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17690 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17691 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17692 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17693 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17694 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17695 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17696 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17697 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17698 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17700 /* "timers bgp" commands. */
17701 install_element(BGP_NODE
, &bgp_timers_cmd
);
17702 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17704 /* "minimum-holdtime" commands. */
17705 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
17706 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
17708 /* route-map delay-timer commands - per instance for backwards compat.
17710 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17711 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17713 /* "bgp client-to-client reflection" commands */
17714 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17715 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17717 /* "bgp always-compare-med" commands */
17718 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17719 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17721 /* bgp ebgp-requires-policy */
17722 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17723 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17725 /* bgp suppress-duplicates */
17726 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17727 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17729 /* bgp reject-as-sets */
17730 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17731 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17733 /* "bgp deterministic-med" commands */
17734 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17735 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17737 /* "bgp graceful-restart" command */
17738 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17739 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17741 /* "bgp graceful-restart-disable" command */
17742 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17743 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17745 /* "neighbor a:b:c:d graceful-restart" command */
17746 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17747 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17749 /* "neighbor a:b:c:d graceful-restart-disable" command */
17750 install_element(BGP_NODE
,
17751 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17752 install_element(BGP_NODE
,
17753 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17755 /* "neighbor a:b:c:d graceful-restart-helper" command */
17756 install_element(BGP_NODE
,
17757 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17758 install_element(BGP_NODE
,
17759 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17761 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17762 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17763 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17764 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17765 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17766 install_element(BGP_NODE
,
17767 &no_bgp_graceful_restart_select_defer_time_cmd
);
17768 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17769 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17771 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17772 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17773 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17774 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17776 /* "bgp graceful-shutdown" commands */
17777 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17778 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17780 /* "bgp long-lived-graceful-restart" commands */
17781 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
17782 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
17784 /* "bgp fast-external-failover" commands */
17785 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17786 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17788 /* "bgp bestpath compare-routerid" commands */
17789 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17790 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17792 /* "bgp bestpath as-path ignore" commands */
17793 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17794 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17796 /* "bgp bestpath as-path confed" commands */
17797 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17798 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17800 /* "bgp bestpath as-path multipath-relax" commands */
17801 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17802 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17804 /* "bgp bestpath peer-type multipath-relax" commands */
17805 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
17806 install_element(BGP_NODE
,
17807 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
17809 /* "bgp log-neighbor-changes" commands */
17810 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17811 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17813 /* "bgp bestpath med" commands */
17814 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17815 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17817 /* "bgp bestpath bandwidth" commands */
17818 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17819 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17821 /* "no bgp default <afi>-<safi>" commands. */
17822 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
17824 /* "bgp network import-check" commands. */
17825 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17826 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17827 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17829 /* "bgp default local-preference" commands. */
17830 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17831 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17833 /* bgp default show-hostname */
17834 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17835 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17837 /* bgp default show-nexthop-hostname */
17838 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17839 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17841 /* "bgp default subgroup-pkt-queue-max" commands. */
17842 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17843 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17845 /* bgp ibgp-allow-policy-mods command */
17846 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17847 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17849 /* "bgp listen limit" commands. */
17850 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17851 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17853 /* "bgp listen range" commands. */
17854 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17855 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17857 /* "bgp default shutdown" command */
17858 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17860 /* "bgp shutdown" commands */
17861 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17862 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17863 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17864 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17866 /* "neighbor remote-as" commands. */
17867 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17868 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17869 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17870 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17871 install_element(BGP_NODE
,
17872 &neighbor_interface_v6only_config_remote_as_cmd
);
17873 install_element(BGP_NODE
, &no_neighbor_cmd
);
17874 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17876 /* "neighbor peer-group" commands. */
17877 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17878 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17879 install_element(BGP_NODE
,
17880 &no_neighbor_interface_peer_group_remote_as_cmd
);
17882 /* "neighbor local-as" commands. */
17883 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17884 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17885 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17886 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17888 /* "neighbor solo" commands. */
17889 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17890 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17892 /* "neighbor password" commands. */
17893 install_element(BGP_NODE
, &neighbor_password_cmd
);
17894 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17896 /* "neighbor activate" commands. */
17897 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17898 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17899 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17900 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17901 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17902 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17903 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17904 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17905 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17906 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17907 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17908 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17910 /* "no neighbor activate" commands. */
17911 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17912 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17913 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17914 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17915 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17916 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17917 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17918 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17919 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17920 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17921 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17922 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17924 /* "neighbor peer-group" set commands. */
17925 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17926 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17927 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17928 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17929 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17930 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17931 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17932 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17933 install_element(BGP_FLOWSPECV4_NODE
,
17934 &neighbor_set_peer_group_hidden_cmd
);
17935 install_element(BGP_FLOWSPECV6_NODE
,
17936 &neighbor_set_peer_group_hidden_cmd
);
17938 /* "no neighbor peer-group unset" commands. */
17939 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17940 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17941 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17942 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17943 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17944 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17945 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17946 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17947 install_element(BGP_FLOWSPECV4_NODE
,
17948 &no_neighbor_set_peer_group_hidden_cmd
);
17949 install_element(BGP_FLOWSPECV6_NODE
,
17950 &no_neighbor_set_peer_group_hidden_cmd
);
17952 /* "neighbor softreconfiguration inbound" commands.*/
17953 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17954 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17955 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17956 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17957 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17958 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17959 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17960 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17961 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17962 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17963 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17964 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17965 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17966 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17967 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17968 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17969 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17970 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17971 install_element(BGP_FLOWSPECV4_NODE
,
17972 &neighbor_soft_reconfiguration_cmd
);
17973 install_element(BGP_FLOWSPECV4_NODE
,
17974 &no_neighbor_soft_reconfiguration_cmd
);
17975 install_element(BGP_FLOWSPECV6_NODE
,
17976 &neighbor_soft_reconfiguration_cmd
);
17977 install_element(BGP_FLOWSPECV6_NODE
,
17978 &no_neighbor_soft_reconfiguration_cmd
);
17979 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17980 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17982 /* "neighbor attribute-unchanged" commands. */
17983 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17984 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17985 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17986 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17987 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17988 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17989 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17990 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17991 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17992 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17993 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17994 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17995 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17996 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17997 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17998 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17999 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18000 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18002 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18003 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18005 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18006 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18007 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18008 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18010 /* "nexthop-local unchanged" commands */
18011 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18012 install_element(BGP_IPV6_NODE
,
18013 &no_neighbor_nexthop_local_unchanged_cmd
);
18015 /* "neighbor next-hop-self" commands. */
18016 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18017 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18018 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18019 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18020 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18021 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18022 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18023 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18024 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18025 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18026 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18027 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18028 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18029 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18030 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18031 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18032 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18033 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18034 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18035 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18037 /* "neighbor next-hop-self force" commands. */
18038 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18039 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18040 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18041 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18042 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18043 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18044 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18045 install_element(BGP_IPV4_NODE
,
18046 &no_neighbor_nexthop_self_all_hidden_cmd
);
18047 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18048 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18049 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18050 install_element(BGP_IPV4M_NODE
,
18051 &no_neighbor_nexthop_self_all_hidden_cmd
);
18052 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18053 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18054 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18055 install_element(BGP_IPV4L_NODE
,
18056 &no_neighbor_nexthop_self_all_hidden_cmd
);
18057 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18058 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18059 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18060 install_element(BGP_IPV6_NODE
,
18061 &no_neighbor_nexthop_self_all_hidden_cmd
);
18062 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18063 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18064 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18065 install_element(BGP_IPV6M_NODE
,
18066 &no_neighbor_nexthop_self_all_hidden_cmd
);
18067 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18068 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18069 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18070 install_element(BGP_IPV6L_NODE
,
18071 &no_neighbor_nexthop_self_all_hidden_cmd
);
18072 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18073 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18074 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18075 install_element(BGP_VPNV4_NODE
,
18076 &no_neighbor_nexthop_self_all_hidden_cmd
);
18077 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18078 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18079 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18080 install_element(BGP_VPNV6_NODE
,
18081 &no_neighbor_nexthop_self_all_hidden_cmd
);
18082 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18083 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18085 /* "neighbor as-override" commands. */
18086 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18087 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18088 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18089 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18090 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18091 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18092 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18093 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18094 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18095 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18096 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18097 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18098 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18099 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18100 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18101 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18102 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18103 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18105 /* "neighbor remove-private-AS" commands. */
18106 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18107 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18108 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18109 install_element(BGP_NODE
,
18110 &no_neighbor_remove_private_as_all_hidden_cmd
);
18111 install_element(BGP_NODE
,
18112 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18113 install_element(BGP_NODE
,
18114 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18115 install_element(BGP_NODE
,
18116 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18119 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18120 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18121 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18122 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18123 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18124 install_element(BGP_IPV4_NODE
,
18125 &neighbor_remove_private_as_replace_as_cmd
);
18126 install_element(BGP_IPV4_NODE
,
18127 &no_neighbor_remove_private_as_replace_as_cmd
);
18128 install_element(BGP_IPV4_NODE
,
18129 &neighbor_remove_private_as_all_replace_as_cmd
);
18130 install_element(BGP_IPV4_NODE
,
18131 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18132 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18133 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18134 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18135 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18136 install_element(BGP_IPV4M_NODE
,
18137 &neighbor_remove_private_as_replace_as_cmd
);
18138 install_element(BGP_IPV4M_NODE
,
18139 &no_neighbor_remove_private_as_replace_as_cmd
);
18140 install_element(BGP_IPV4M_NODE
,
18141 &neighbor_remove_private_as_all_replace_as_cmd
);
18142 install_element(BGP_IPV4M_NODE
,
18143 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18144 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18145 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18146 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18147 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18148 install_element(BGP_IPV4L_NODE
,
18149 &neighbor_remove_private_as_replace_as_cmd
);
18150 install_element(BGP_IPV4L_NODE
,
18151 &no_neighbor_remove_private_as_replace_as_cmd
);
18152 install_element(BGP_IPV4L_NODE
,
18153 &neighbor_remove_private_as_all_replace_as_cmd
);
18154 install_element(BGP_IPV4L_NODE
,
18155 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18156 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18157 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18158 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18159 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18160 install_element(BGP_IPV6_NODE
,
18161 &neighbor_remove_private_as_replace_as_cmd
);
18162 install_element(BGP_IPV6_NODE
,
18163 &no_neighbor_remove_private_as_replace_as_cmd
);
18164 install_element(BGP_IPV6_NODE
,
18165 &neighbor_remove_private_as_all_replace_as_cmd
);
18166 install_element(BGP_IPV6_NODE
,
18167 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18168 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18169 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18170 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18171 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18172 install_element(BGP_IPV6M_NODE
,
18173 &neighbor_remove_private_as_replace_as_cmd
);
18174 install_element(BGP_IPV6M_NODE
,
18175 &no_neighbor_remove_private_as_replace_as_cmd
);
18176 install_element(BGP_IPV6M_NODE
,
18177 &neighbor_remove_private_as_all_replace_as_cmd
);
18178 install_element(BGP_IPV6M_NODE
,
18179 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18180 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18181 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18182 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18183 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18184 install_element(BGP_IPV6L_NODE
,
18185 &neighbor_remove_private_as_replace_as_cmd
);
18186 install_element(BGP_IPV6L_NODE
,
18187 &no_neighbor_remove_private_as_replace_as_cmd
);
18188 install_element(BGP_IPV6L_NODE
,
18189 &neighbor_remove_private_as_all_replace_as_cmd
);
18190 install_element(BGP_IPV6L_NODE
,
18191 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18192 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18193 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18194 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18195 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18196 install_element(BGP_VPNV4_NODE
,
18197 &neighbor_remove_private_as_replace_as_cmd
);
18198 install_element(BGP_VPNV4_NODE
,
18199 &no_neighbor_remove_private_as_replace_as_cmd
);
18200 install_element(BGP_VPNV4_NODE
,
18201 &neighbor_remove_private_as_all_replace_as_cmd
);
18202 install_element(BGP_VPNV4_NODE
,
18203 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18204 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18205 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18206 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18207 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18208 install_element(BGP_VPNV6_NODE
,
18209 &neighbor_remove_private_as_replace_as_cmd
);
18210 install_element(BGP_VPNV6_NODE
,
18211 &no_neighbor_remove_private_as_replace_as_cmd
);
18212 install_element(BGP_VPNV6_NODE
,
18213 &neighbor_remove_private_as_all_replace_as_cmd
);
18214 install_element(BGP_VPNV6_NODE
,
18215 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18217 /* "neighbor send-community" commands.*/
18218 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18219 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18220 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18221 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18222 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18223 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18224 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18225 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18226 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18227 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18228 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18229 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18230 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18231 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18232 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18233 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18234 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18235 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18236 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18237 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18238 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18239 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18240 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18241 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18242 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18243 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18244 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18245 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18246 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18247 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18248 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18249 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18250 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18251 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18252 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18253 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18255 /* "neighbor route-reflector" commands.*/
18256 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18257 install_element(BGP_NODE
,
18258 &no_neighbor_route_reflector_client_hidden_cmd
);
18259 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18260 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18261 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18262 install_element(BGP_IPV4M_NODE
,
18263 &no_neighbor_route_reflector_client_cmd
);
18264 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18265 install_element(BGP_IPV4L_NODE
,
18266 &no_neighbor_route_reflector_client_cmd
);
18267 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18268 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18269 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18270 install_element(BGP_IPV6M_NODE
,
18271 &no_neighbor_route_reflector_client_cmd
);
18272 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18273 install_element(BGP_IPV6L_NODE
,
18274 &no_neighbor_route_reflector_client_cmd
);
18275 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18276 install_element(BGP_VPNV4_NODE
,
18277 &no_neighbor_route_reflector_client_cmd
);
18278 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18279 install_element(BGP_VPNV6_NODE
,
18280 &no_neighbor_route_reflector_client_cmd
);
18281 install_element(BGP_FLOWSPECV4_NODE
,
18282 &neighbor_route_reflector_client_cmd
);
18283 install_element(BGP_FLOWSPECV4_NODE
,
18284 &no_neighbor_route_reflector_client_cmd
);
18285 install_element(BGP_FLOWSPECV6_NODE
,
18286 &neighbor_route_reflector_client_cmd
);
18287 install_element(BGP_FLOWSPECV6_NODE
,
18288 &no_neighbor_route_reflector_client_cmd
);
18289 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18290 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18292 /* "neighbor route-server" commands.*/
18293 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18294 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18295 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18296 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18297 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18298 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18299 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18300 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18301 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18302 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18303 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18304 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18305 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18306 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18307 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18308 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18309 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18310 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18311 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18312 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18313 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18314 install_element(BGP_FLOWSPECV4_NODE
,
18315 &no_neighbor_route_server_client_cmd
);
18316 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18317 install_element(BGP_FLOWSPECV6_NODE
,
18318 &no_neighbor_route_server_client_cmd
);
18320 /* "neighbor disable-addpath-rx" commands. */
18321 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18322 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18323 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18324 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18325 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18326 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18327 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18328 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18329 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
18330 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18331 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
18332 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18333 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
18334 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18335 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
18336 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
18338 /* "neighbor addpath-tx-all-paths" commands.*/
18339 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18340 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18341 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18342 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18343 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18344 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18345 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18346 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18347 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18348 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18349 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18350 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18351 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18352 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18353 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18354 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18355 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18356 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18358 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18359 install_element(BGP_NODE
,
18360 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18361 install_element(BGP_NODE
,
18362 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18363 install_element(BGP_IPV4_NODE
,
18364 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18365 install_element(BGP_IPV4_NODE
,
18366 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18367 install_element(BGP_IPV4M_NODE
,
18368 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18369 install_element(BGP_IPV4M_NODE
,
18370 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18371 install_element(BGP_IPV4L_NODE
,
18372 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18373 install_element(BGP_IPV4L_NODE
,
18374 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18375 install_element(BGP_IPV6_NODE
,
18376 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18377 install_element(BGP_IPV6_NODE
,
18378 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18379 install_element(BGP_IPV6M_NODE
,
18380 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18381 install_element(BGP_IPV6M_NODE
,
18382 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18383 install_element(BGP_IPV6L_NODE
,
18384 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18385 install_element(BGP_IPV6L_NODE
,
18386 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18387 install_element(BGP_VPNV4_NODE
,
18388 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18389 install_element(BGP_VPNV4_NODE
,
18390 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18391 install_element(BGP_VPNV6_NODE
,
18392 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18393 install_element(BGP_VPNV6_NODE
,
18394 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18396 /* "neighbor sender-as-path-loop-detection" commands. */
18397 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18398 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18400 /* "neighbor passive" commands. */
18401 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18402 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18405 /* "neighbor shutdown" commands. */
18406 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18407 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18408 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18409 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18410 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18411 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18413 /* "neighbor capability extended-nexthop" commands.*/
18414 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18415 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18417 /* "neighbor capability orf prefix-list" commands.*/
18418 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18419 install_element(BGP_NODE
,
18420 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18421 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18422 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18423 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18424 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18425 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18426 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18427 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18428 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18429 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18430 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18431 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18432 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18434 /* "neighbor capability dynamic" commands.*/
18435 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18436 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18438 /* "neighbor dont-capability-negotiate" commands. */
18439 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18440 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18442 /* "neighbor ebgp-multihop" commands. */
18443 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18444 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18445 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18447 /* "neighbor disable-connected-check" commands. */
18448 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18449 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18451 /* "neighbor disable-link-bw-encoding-ieee" commands. */
18452 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
18453 install_element(BGP_NODE
,
18454 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
18456 /* "neighbor extended-optional-parameters" commands. */
18457 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
18458 install_element(BGP_NODE
,
18459 &no_neighbor_extended_optional_parameters_cmd
);
18461 /* "neighbor enforce-first-as" commands. */
18462 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18463 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18465 /* "neighbor description" commands. */
18466 install_element(BGP_NODE
, &neighbor_description_cmd
);
18467 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18468 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18470 /* "neighbor update-source" commands. "*/
18471 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18472 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18474 /* "neighbor default-originate" commands. */
18475 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18476 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18477 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18478 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18479 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18480 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18481 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18482 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18483 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18484 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18485 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18486 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18487 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18488 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18489 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18490 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18491 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18492 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18493 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18494 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18495 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18497 /* "neighbor port" commands. */
18498 install_element(BGP_NODE
, &neighbor_port_cmd
);
18499 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18501 /* "neighbor weight" commands. */
18502 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18503 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18505 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18506 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18507 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18508 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18509 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18510 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18511 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18512 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18513 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18514 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18515 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18516 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18517 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18518 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18519 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18520 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18522 /* "neighbor override-capability" commands. */
18523 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18524 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18526 /* "neighbor strict-capability-match" commands. */
18527 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18528 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18530 /* "neighbor timers" commands. */
18531 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18532 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18534 /* "neighbor timers connect" commands. */
18535 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18536 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18538 /* "neighbor timers delayopen" commands. */
18539 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18540 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18542 /* "neighbor advertisement-interval" commands. */
18543 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18544 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18546 /* "neighbor interface" commands. */
18547 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18548 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18550 /* "neighbor distribute" commands. */
18551 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18552 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18553 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18554 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18555 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18556 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18557 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18558 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18559 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18560 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18561 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18562 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18563 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18564 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18565 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18566 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18567 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18568 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18570 /* "neighbor prefix-list" commands. */
18571 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18572 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18573 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18574 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18575 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18576 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18577 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18578 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18579 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18580 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18581 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18582 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18583 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18584 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18585 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18586 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18587 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18588 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18589 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18590 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18591 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18592 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18594 /* "neighbor filter-list" commands. */
18595 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18596 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18597 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18598 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18599 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18600 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18601 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18602 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18603 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18604 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18605 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18606 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18607 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18608 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18609 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18610 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18611 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18612 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18613 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18614 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18615 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18616 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18618 /* "neighbor route-map" commands. */
18619 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18620 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18621 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18622 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18623 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18624 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18625 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18626 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18627 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18628 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18629 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18630 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18631 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18632 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18633 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18634 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18635 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18636 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18637 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18638 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18639 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18640 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18641 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18642 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18644 /* "neighbor unsuppress-map" commands. */
18645 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18646 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18647 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18648 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18649 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18650 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18651 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18652 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18653 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18654 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18655 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18656 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18657 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18658 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18659 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18660 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18661 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18662 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18664 /* "neighbor advertise-map" commands. */
18665 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
18666 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18667 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18668 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18669 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18670 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18671 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18672 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18673 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18674 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18676 /* neighbor maximum-prefix-out commands. */
18677 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18678 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18679 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18680 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18681 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18682 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18683 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18684 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18685 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18686 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18687 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18688 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18689 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18690 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18691 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18692 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18693 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18694 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18696 /* "neighbor maximum-prefix" commands. */
18697 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18698 install_element(BGP_NODE
,
18699 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18700 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18701 install_element(BGP_NODE
,
18702 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18703 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18704 install_element(BGP_NODE
,
18705 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18706 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18707 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18708 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18709 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18710 install_element(BGP_IPV4_NODE
,
18711 &neighbor_maximum_prefix_threshold_warning_cmd
);
18712 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18713 install_element(BGP_IPV4_NODE
,
18714 &neighbor_maximum_prefix_threshold_restart_cmd
);
18715 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18716 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18717 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18718 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18719 install_element(BGP_IPV4M_NODE
,
18720 &neighbor_maximum_prefix_threshold_warning_cmd
);
18721 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18722 install_element(BGP_IPV4M_NODE
,
18723 &neighbor_maximum_prefix_threshold_restart_cmd
);
18724 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18725 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18726 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18727 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18728 install_element(BGP_IPV4L_NODE
,
18729 &neighbor_maximum_prefix_threshold_warning_cmd
);
18730 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18731 install_element(BGP_IPV4L_NODE
,
18732 &neighbor_maximum_prefix_threshold_restart_cmd
);
18733 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18734 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18735 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18736 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18737 install_element(BGP_IPV6_NODE
,
18738 &neighbor_maximum_prefix_threshold_warning_cmd
);
18739 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18740 install_element(BGP_IPV6_NODE
,
18741 &neighbor_maximum_prefix_threshold_restart_cmd
);
18742 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18743 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18744 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18745 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18746 install_element(BGP_IPV6M_NODE
,
18747 &neighbor_maximum_prefix_threshold_warning_cmd
);
18748 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18749 install_element(BGP_IPV6M_NODE
,
18750 &neighbor_maximum_prefix_threshold_restart_cmd
);
18751 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18752 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18753 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18754 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18755 install_element(BGP_IPV6L_NODE
,
18756 &neighbor_maximum_prefix_threshold_warning_cmd
);
18757 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18758 install_element(BGP_IPV6L_NODE
,
18759 &neighbor_maximum_prefix_threshold_restart_cmd
);
18760 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18761 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18762 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18763 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18764 install_element(BGP_VPNV4_NODE
,
18765 &neighbor_maximum_prefix_threshold_warning_cmd
);
18766 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18767 install_element(BGP_VPNV4_NODE
,
18768 &neighbor_maximum_prefix_threshold_restart_cmd
);
18769 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18770 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18771 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18772 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18773 install_element(BGP_VPNV6_NODE
,
18774 &neighbor_maximum_prefix_threshold_warning_cmd
);
18775 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18776 install_element(BGP_VPNV6_NODE
,
18777 &neighbor_maximum_prefix_threshold_restart_cmd
);
18778 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18780 /* "neighbor allowas-in" */
18781 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18782 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18783 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18784 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18785 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18786 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18787 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18788 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18789 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18790 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18791 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18792 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18793 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18794 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18795 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18796 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18797 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18798 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18799 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18800 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18802 /* address-family commands. */
18803 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18804 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18805 #ifdef KEEP_OLD_VPN_COMMANDS
18806 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18807 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18808 #endif /* KEEP_OLD_VPN_COMMANDS */
18810 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18812 /* "exit-address-family" command. */
18813 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18814 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18815 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18816 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18817 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18818 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18819 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18820 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18821 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18822 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18823 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18825 /* "clear ip bgp commands" */
18826 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18828 /* clear ip bgp prefix */
18829 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18830 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18831 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18833 /* "show [ip] bgp summary" commands. */
18834 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18835 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18836 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18837 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18838 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18839 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18840 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18842 /* "show [ip] bgp neighbors" commands. */
18843 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18845 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18847 /* "show [ip] bgp peer-group" commands. */
18848 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18850 /* "show [ip] bgp paths" commands. */
18851 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18853 /* "show [ip] bgp community" commands. */
18854 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18856 /* "show ip bgp large-community" commands. */
18857 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18858 /* "show [ip] bgp attribute-info" commands. */
18859 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18860 /* "show [ip] bgp route-leak" command */
18861 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18863 /* "redistribute" commands. */
18864 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18865 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18866 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18867 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18868 install_element(BGP_NODE
,
18869 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18870 install_element(BGP_NODE
,
18871 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18872 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18873 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18874 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18875 install_element(BGP_NODE
,
18876 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18877 install_element(BGP_NODE
,
18878 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18879 install_element(BGP_NODE
,
18880 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18881 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18882 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18883 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18884 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18885 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18886 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18887 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18888 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18889 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18890 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18891 install_element(BGP_IPV4_NODE
,
18892 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18893 install_element(BGP_IPV4_NODE
,
18894 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18895 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18896 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18897 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18898 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18899 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18900 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18902 /* import|export vpn [route-map WORD] */
18903 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18904 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18906 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18907 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18909 /* ttl_security commands */
18910 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18911 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18913 /* "show [ip] bgp memory" commands. */
18914 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18916 /* "show bgp martian next-hop" */
18917 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18919 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18921 /* "show [ip] bgp views" commands. */
18922 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18924 /* "show [ip] bgp vrfs" commands. */
18925 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18927 /* Community-list. */
18928 community_list_vty();
18930 community_alias_vty();
18932 /* vpn-policy commands */
18933 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18934 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18935 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18936 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18937 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18938 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18939 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18940 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18941 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18942 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18943 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18944 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18946 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18947 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18949 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18950 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18951 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18952 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18953 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18954 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18955 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18956 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18957 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18958 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18960 /* tcp-mss command */
18961 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
18962 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
18964 /* srv6 commands */
18965 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
18966 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
18967 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
18968 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
18969 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
18970 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
18971 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
18974 #include "memory.h"
18975 #include "bgp_regex.h"
18976 #include "bgp_clist.h"
18977 #include "bgp_ecommunity.h"
18979 /* VTY functions. */
18981 /* Direction value to string conversion. */
18982 static const char *community_direct_str(int direct
)
18985 case COMMUNITY_DENY
:
18987 case COMMUNITY_PERMIT
:
18994 /* Display error string. */
18995 static void community_list_perror(struct vty
*vty
, int ret
)
18998 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18999 vty_out(vty
, "%% Can't find community-list\n");
19001 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19002 vty_out(vty
, "%% Malformed community-list value\n");
19004 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19006 "%% Community name conflict, previously defined as standard community\n");
19008 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19010 "%% Community name conflict, previously defined as expanded community\n");
19015 /* "community-list" keyword help string. */
19016 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19018 /*community-list standard */
19019 DEFUN (community_list_standard
,
19020 bgp_community_list_standard_cmd
,
19021 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19024 "Community list number (standard)\n"
19025 "Add an standard community-list entry\n"
19026 "Community list name\n"
19027 "Sequence number of an entry\n"
19028 "Sequence number\n"
19029 "Specify community to reject\n"
19030 "Specify community to accept\n"
19033 char *cl_name_or_number
= NULL
;
19036 int style
= COMMUNITY_LIST_STANDARD
;
19039 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19041 seq
= argv
[idx
]->arg
;
19044 argv_find(argv
, argc
, "(1-99)", &idx
);
19045 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19046 cl_name_or_number
= argv
[idx
]->arg
;
19047 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19049 argv_find(argv
, argc
, "AA:NN", &idx
);
19050 char *str
= argv_concat(argv
, argc
, idx
);
19052 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19055 XFREE(MTYPE_TMP
, str
);
19058 /* Display error string. */
19059 community_list_perror(vty
, ret
);
19060 return CMD_WARNING_CONFIG_FAILED
;
19063 return CMD_SUCCESS
;
19066 DEFUN (no_community_list_standard_all
,
19067 no_bgp_community_list_standard_all_cmd
,
19068 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19072 "Community list number (standard)\n"
19073 "Add an standard community-list entry\n"
19074 "Community list name\n"
19075 "Sequence number of an entry\n"
19076 "Sequence number\n"
19077 "Specify community to reject\n"
19078 "Specify community to accept\n"
19081 char *cl_name_or_number
= NULL
;
19084 int style
= COMMUNITY_LIST_STANDARD
;
19088 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19090 seq
= argv
[idx
]->arg
;
19093 argv_find(argv
, argc
, "permit", &idx
);
19094 argv_find(argv
, argc
, "deny", &idx
);
19097 direct
= argv_find(argv
, argc
, "permit", &idx
)
19102 argv_find(argv
, argc
, "AA:NN", &idx
);
19103 str
= argv_concat(argv
, argc
, idx
);
19107 argv_find(argv
, argc
, "(1-99)", &idx
);
19108 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19109 cl_name_or_number
= argv
[idx
]->arg
;
19111 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19114 XFREE(MTYPE_TMP
, str
);
19117 community_list_perror(vty
, ret
);
19118 return CMD_WARNING_CONFIG_FAILED
;
19121 return CMD_SUCCESS
;
19124 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19125 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19126 NO_STR BGP_STR COMMUNITY_LIST_STR
19127 "Community list number (standard)\n"
19128 "Add an standard community-list entry\n"
19129 "Community list name\n")
19131 /*community-list expanded */
19132 DEFUN (community_list_expanded_all
,
19133 bgp_community_list_expanded_all_cmd
,
19134 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19137 "Community list number (expanded)\n"
19138 "Add an expanded community-list entry\n"
19139 "Community list name\n"
19140 "Sequence number of an entry\n"
19141 "Sequence number\n"
19142 "Specify community to reject\n"
19143 "Specify community to accept\n"
19146 char *cl_name_or_number
= NULL
;
19149 int style
= COMMUNITY_LIST_EXPANDED
;
19152 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19154 seq
= argv
[idx
]->arg
;
19158 argv_find(argv
, argc
, "(100-500)", &idx
);
19159 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19160 cl_name_or_number
= argv
[idx
]->arg
;
19161 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19163 argv_find(argv
, argc
, "AA:NN", &idx
);
19164 char *str
= argv_concat(argv
, argc
, idx
);
19166 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19169 XFREE(MTYPE_TMP
, str
);
19172 /* Display error string. */
19173 community_list_perror(vty
, ret
);
19174 return CMD_WARNING_CONFIG_FAILED
;
19177 return CMD_SUCCESS
;
19180 DEFUN (no_community_list_expanded_all
,
19181 no_bgp_community_list_expanded_all_cmd
,
19182 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19186 "Community list number (expanded)\n"
19187 "Add an expanded community-list entry\n"
19188 "Community list name\n"
19189 "Sequence number of an entry\n"
19190 "Sequence number\n"
19191 "Specify community to reject\n"
19192 "Specify community to accept\n"
19195 char *cl_name_or_number
= NULL
;
19199 int style
= COMMUNITY_LIST_EXPANDED
;
19202 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19204 seq
= argv
[idx
]->arg
;
19207 argv_find(argv
, argc
, "permit", &idx
);
19208 argv_find(argv
, argc
, "deny", &idx
);
19211 direct
= argv_find(argv
, argc
, "permit", &idx
)
19216 argv_find(argv
, argc
, "AA:NN", &idx
);
19217 str
= argv_concat(argv
, argc
, idx
);
19221 argv_find(argv
, argc
, "(100-500)", &idx
);
19222 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19223 cl_name_or_number
= argv
[idx
]->arg
;
19225 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19228 XFREE(MTYPE_TMP
, str
);
19231 community_list_perror(vty
, ret
);
19232 return CMD_WARNING_CONFIG_FAILED
;
19235 return CMD_SUCCESS
;
19238 ALIAS(no_community_list_expanded_all
,
19239 no_bgp_community_list_expanded_all_list_cmd
,
19240 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
19241 NO_STR BGP_STR COMMUNITY_LIST_STR
19242 "Community list number (expanded)\n"
19243 "Add an expanded community-list entry\n"
19244 "Community list name\n")
19246 /* Return configuration string of community-list entry. */
19247 static const char *community_list_config_str(struct community_entry
*entry
)
19254 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19255 str
= community_str(entry
->u
.com
, false);
19256 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19257 str
= lcommunity_str(entry
->u
.lcom
, false);
19259 str
= entry
->config
;
19264 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19266 struct community_entry
*entry
;
19268 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19269 if (entry
== list
->head
) {
19270 if (all_digit(list
->name
))
19271 vty_out(vty
, "Community %s list %s\n",
19272 entry
->style
== COMMUNITY_LIST_STANDARD
19274 : "(expanded) access",
19277 vty_out(vty
, "Named Community %s list %s\n",
19278 entry
->style
== COMMUNITY_LIST_STANDARD
19284 vty_out(vty
, " %s\n",
19285 community_direct_str(entry
->direct
));
19287 vty_out(vty
, " %s %s\n",
19288 community_direct_str(entry
->direct
),
19289 community_list_config_str(entry
));
19293 DEFUN (show_community_list
,
19294 show_bgp_community_list_cmd
,
19295 "show bgp community-list",
19298 "List community-list\n")
19300 struct community_list
*list
;
19301 struct community_list_master
*cm
;
19303 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19305 return CMD_SUCCESS
;
19307 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19308 community_list_show(vty
, list
);
19310 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19311 community_list_show(vty
, list
);
19313 return CMD_SUCCESS
;
19316 DEFUN (show_community_list_arg
,
19317 show_bgp_community_list_arg_cmd
,
19318 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
19321 "List community-list\n"
19322 "Community-list number\n"
19323 "Community-list name\n"
19324 "Detailed information on community-list\n")
19326 int idx_comm_list
= 3;
19327 struct community_list
*list
;
19329 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19330 COMMUNITY_LIST_MASTER
);
19332 vty_out(vty
, "%% Can't find community-list\n");
19333 return CMD_WARNING
;
19336 community_list_show(vty
, list
);
19338 return CMD_SUCCESS
;
19342 * Large Community code.
19344 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19345 struct cmd_token
**argv
, int style
,
19346 int reject_all_digit_name
)
19355 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19356 seq
= argv
[idx
]->arg
;
19359 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19362 /* All digit name check. */
19364 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19365 argv_find(argv
, argc
, "(1-99)", &idx
);
19366 argv_find(argv
, argc
, "(100-500)", &idx
);
19367 cl_name
= argv
[idx
]->arg
;
19368 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19369 vty_out(vty
, "%% Community name cannot have all digits\n");
19370 return CMD_WARNING_CONFIG_FAILED
;
19374 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19375 argv_find(argv
, argc
, "LINE", &idx
);
19376 /* Concat community string argument. */
19378 str
= argv_concat(argv
, argc
, idx
);
19382 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19384 /* Free temporary community list string allocated by
19386 XFREE(MTYPE_TMP
, str
);
19389 community_list_perror(vty
, ret
);
19390 return CMD_WARNING_CONFIG_FAILED
;
19392 return CMD_SUCCESS
;
19395 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19396 struct cmd_token
**argv
, int style
)
19404 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19405 seq
= argv
[idx
]->arg
;
19408 argv_find(argv
, argc
, "permit", &idx
);
19409 argv_find(argv
, argc
, "deny", &idx
);
19412 /* Check the list direct. */
19413 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19414 direct
= COMMUNITY_PERMIT
;
19416 direct
= COMMUNITY_DENY
;
19419 argv_find(argv
, argc
, "LINE", &idx
);
19420 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19421 /* Concat community string argument. */
19422 str
= argv_concat(argv
, argc
, idx
);
19426 argv_find(argv
, argc
, "(1-99)", &idx
);
19427 argv_find(argv
, argc
, "(100-500)", &idx
);
19428 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
19430 /* Unset community list. */
19431 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19434 /* Free temporary community list string allocated by
19436 XFREE(MTYPE_TMP
, str
);
19439 community_list_perror(vty
, ret
);
19440 return CMD_WARNING_CONFIG_FAILED
;
19443 return CMD_SUCCESS
;
19446 /* "large-community-list" keyword help string. */
19447 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19448 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19450 DEFUN (lcommunity_list_standard
,
19451 bgp_lcommunity_list_standard_cmd
,
19452 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19454 LCOMMUNITY_LIST_STR
19455 "Large Community list number (standard)\n"
19456 "Sequence number of an entry\n"
19457 "Sequence number\n"
19458 "Specify large community to reject\n"
19459 "Specify large community to accept\n"
19460 LCOMMUNITY_VAL_STR
)
19462 return lcommunity_list_set_vty(vty
, argc
, argv
,
19463 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19466 DEFUN (lcommunity_list_expanded
,
19467 bgp_lcommunity_list_expanded_cmd
,
19468 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19470 LCOMMUNITY_LIST_STR
19471 "Large Community list number (expanded)\n"
19472 "Sequence number of an entry\n"
19473 "Sequence number\n"
19474 "Specify large community to reject\n"
19475 "Specify large community to accept\n"
19476 "An ordered list as a regular-expression\n")
19478 return lcommunity_list_set_vty(vty
, argc
, argv
,
19479 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19482 DEFUN (lcommunity_list_name_standard
,
19483 bgp_lcommunity_list_name_standard_cmd
,
19484 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19486 LCOMMUNITY_LIST_STR
19487 "Specify standard large-community-list\n"
19488 "Large Community list name\n"
19489 "Sequence number of an entry\n"
19490 "Sequence number\n"
19491 "Specify large community to reject\n"
19492 "Specify large community to accept\n"
19493 LCOMMUNITY_VAL_STR
)
19495 return lcommunity_list_set_vty(vty
, argc
, argv
,
19496 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19499 DEFUN (lcommunity_list_name_expanded
,
19500 bgp_lcommunity_list_name_expanded_cmd
,
19501 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19503 LCOMMUNITY_LIST_STR
19504 "Specify expanded large-community-list\n"
19505 "Large Community list name\n"
19506 "Sequence number of an entry\n"
19507 "Sequence number\n"
19508 "Specify large community to reject\n"
19509 "Specify large community to accept\n"
19510 "An ordered list as a regular-expression\n")
19512 return lcommunity_list_set_vty(vty
, argc
, argv
,
19513 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19516 DEFUN (no_lcommunity_list_all
,
19517 no_bgp_lcommunity_list_all_cmd
,
19518 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
19521 LCOMMUNITY_LIST_STR
19522 "Large Community list number (standard)\n"
19523 "Large Community list number (expanded)\n"
19524 "Large Community list name\n")
19526 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19527 LARGE_COMMUNITY_LIST_STANDARD
);
19530 DEFUN (no_lcommunity_list_name_standard_all
,
19531 no_bgp_lcommunity_list_name_standard_all_cmd
,
19532 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
19535 LCOMMUNITY_LIST_STR
19536 "Specify standard large-community-list\n"
19537 "Large Community list name\n")
19539 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19540 LARGE_COMMUNITY_LIST_STANDARD
);
19543 DEFUN (no_lcommunity_list_name_expanded_all
,
19544 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19545 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
19548 LCOMMUNITY_LIST_STR
19549 "Specify expanded large-community-list\n"
19550 "Large Community list name\n")
19552 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19553 LARGE_COMMUNITY_LIST_EXPANDED
);
19556 DEFUN (no_lcommunity_list_standard
,
19557 no_bgp_lcommunity_list_standard_cmd
,
19558 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19561 LCOMMUNITY_LIST_STR
19562 "Large Community list number (standard)\n"
19563 "Sequence number of an entry\n"
19564 "Sequence number\n"
19565 "Specify large community to reject\n"
19566 "Specify large community to accept\n"
19567 LCOMMUNITY_VAL_STR
)
19569 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19570 LARGE_COMMUNITY_LIST_STANDARD
);
19573 DEFUN (no_lcommunity_list_expanded
,
19574 no_bgp_lcommunity_list_expanded_cmd
,
19575 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19578 LCOMMUNITY_LIST_STR
19579 "Large Community list number (expanded)\n"
19580 "Sequence number of an entry\n"
19581 "Sequence number\n"
19582 "Specify large community to reject\n"
19583 "Specify large community to accept\n"
19584 "An ordered list as a regular-expression\n")
19586 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19587 LARGE_COMMUNITY_LIST_EXPANDED
);
19590 DEFUN (no_lcommunity_list_name_standard
,
19591 no_bgp_lcommunity_list_name_standard_cmd
,
19592 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19595 LCOMMUNITY_LIST_STR
19596 "Specify standard large-community-list\n"
19597 "Large Community list name\n"
19598 "Sequence number of an entry\n"
19599 "Sequence number\n"
19600 "Specify large community to reject\n"
19601 "Specify large community to accept\n"
19602 LCOMMUNITY_VAL_STR
)
19604 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19605 LARGE_COMMUNITY_LIST_STANDARD
);
19608 DEFUN (no_lcommunity_list_name_expanded
,
19609 no_bgp_lcommunity_list_name_expanded_cmd
,
19610 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
19613 LCOMMUNITY_LIST_STR
19614 "Specify expanded large-community-list\n"
19615 "Large community list name\n"
19616 "Sequence number of an entry\n"
19617 "Sequence number\n"
19618 "Specify large community to reject\n"
19619 "Specify large community to accept\n"
19620 "An ordered list as a regular-expression\n")
19622 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19623 LARGE_COMMUNITY_LIST_EXPANDED
);
19626 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19628 struct community_entry
*entry
;
19630 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19631 if (entry
== list
->head
) {
19632 if (all_digit(list
->name
))
19633 vty_out(vty
, "Large community %s list %s\n",
19635 LARGE_COMMUNITY_LIST_STANDARD
19637 : "(expanded) access",
19641 "Named large community %s list %s\n",
19643 LARGE_COMMUNITY_LIST_STANDARD
19649 vty_out(vty
, " %s\n",
19650 community_direct_str(entry
->direct
));
19652 vty_out(vty
, " %s %s\n",
19653 community_direct_str(entry
->direct
),
19654 community_list_config_str(entry
));
19658 DEFUN (show_lcommunity_list
,
19659 show_bgp_lcommunity_list_cmd
,
19660 "show bgp large-community-list",
19663 "List large-community list\n")
19665 struct community_list
*list
;
19666 struct community_list_master
*cm
;
19668 cm
= community_list_master_lookup(bgp_clist
,
19669 LARGE_COMMUNITY_LIST_MASTER
);
19671 return CMD_SUCCESS
;
19673 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19674 lcommunity_list_show(vty
, list
);
19676 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19677 lcommunity_list_show(vty
, list
);
19679 return CMD_SUCCESS
;
19682 DEFUN (show_lcommunity_list_arg
,
19683 show_bgp_lcommunity_list_arg_cmd
,
19684 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
19687 "List large-community list\n"
19688 "Large-community-list number\n"
19689 "Large-community-list name\n"
19690 "Detailed information on large-community-list\n")
19692 struct community_list
*list
;
19694 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19695 LARGE_COMMUNITY_LIST_MASTER
);
19697 vty_out(vty
, "%% Can't find large-community-list\n");
19698 return CMD_WARNING
;
19701 lcommunity_list_show(vty
, list
);
19703 return CMD_SUCCESS
;
19706 /* "extcommunity-list" keyword help string. */
19707 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19708 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19710 DEFUN (extcommunity_list_standard
,
19711 bgp_extcommunity_list_standard_cmd
,
19712 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19714 EXTCOMMUNITY_LIST_STR
19715 "Extended Community list number (standard)\n"
19716 "Specify standard extcommunity-list\n"
19717 "Community list name\n"
19718 "Sequence number of an entry\n"
19719 "Sequence number\n"
19720 "Specify community to reject\n"
19721 "Specify community to accept\n"
19722 EXTCOMMUNITY_VAL_STR
)
19724 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19726 char *cl_number_or_name
= NULL
;
19731 argv_find(argv
, argc
, "(1-99)", &idx
);
19732 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19733 cl_number_or_name
= argv
[idx
]->arg
;
19735 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19736 seq
= argv
[idx
]->arg
;
19738 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19740 argv_find(argv
, argc
, "AA:NN", &idx
);
19741 char *str
= argv_concat(argv
, argc
, idx
);
19743 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19746 XFREE(MTYPE_TMP
, str
);
19749 community_list_perror(vty
, ret
);
19750 return CMD_WARNING_CONFIG_FAILED
;
19753 return CMD_SUCCESS
;
19756 DEFUN (extcommunity_list_name_expanded
,
19757 bgp_extcommunity_list_name_expanded_cmd
,
19758 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19760 EXTCOMMUNITY_LIST_STR
19761 "Extended Community list number (expanded)\n"
19762 "Specify expanded extcommunity-list\n"
19763 "Extended Community list name\n"
19764 "Sequence number of an entry\n"
19765 "Sequence number\n"
19766 "Specify community to reject\n"
19767 "Specify community to accept\n"
19768 "An ordered list as a regular-expression\n")
19770 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19772 char *cl_number_or_name
= NULL
;
19776 argv_find(argv
, argc
, "(100-500)", &idx
);
19777 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19778 cl_number_or_name
= argv
[idx
]->arg
;
19780 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19781 seq
= argv
[idx
]->arg
;
19783 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19785 argv_find(argv
, argc
, "LINE", &idx
);
19786 char *str
= argv_concat(argv
, argc
, idx
);
19788 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19791 XFREE(MTYPE_TMP
, str
);
19794 community_list_perror(vty
, ret
);
19795 return CMD_WARNING_CONFIG_FAILED
;
19798 return CMD_SUCCESS
;
19801 DEFUN (no_extcommunity_list_standard_all
,
19802 no_bgp_extcommunity_list_standard_all_cmd
,
19803 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19806 EXTCOMMUNITY_LIST_STR
19807 "Extended Community list number (standard)\n"
19808 "Specify standard extcommunity-list\n"
19809 "Community list name\n"
19810 "Sequence number of an entry\n"
19811 "Sequence number\n"
19812 "Specify community to reject\n"
19813 "Specify community to accept\n"
19814 EXTCOMMUNITY_VAL_STR
)
19816 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19818 char *cl_number_or_name
= NULL
;
19823 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19824 seq
= argv
[idx
]->arg
;
19827 argv_find(argv
, argc
, "permit", &idx
);
19828 argv_find(argv
, argc
, "deny", &idx
);
19830 direct
= argv_find(argv
, argc
, "permit", &idx
)
19835 argv_find(argv
, argc
, "AA:NN", &idx
);
19836 str
= argv_concat(argv
, argc
, idx
);
19840 argv_find(argv
, argc
, "(1-99)", &idx
);
19841 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19842 cl_number_or_name
= argv
[idx
]->arg
;
19844 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19845 seq
, direct
, style
);
19847 XFREE(MTYPE_TMP
, str
);
19850 community_list_perror(vty
, ret
);
19851 return CMD_WARNING_CONFIG_FAILED
;
19854 return CMD_SUCCESS
;
19857 ALIAS(no_extcommunity_list_standard_all
,
19858 no_bgp_extcommunity_list_standard_all_list_cmd
,
19859 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
19860 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19861 "Extended Community list number (standard)\n"
19862 "Specify standard extcommunity-list\n"
19863 "Community list name\n")
19865 DEFUN (no_extcommunity_list_expanded_all
,
19866 no_bgp_extcommunity_list_expanded_all_cmd
,
19867 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
19870 EXTCOMMUNITY_LIST_STR
19871 "Extended Community list number (expanded)\n"
19872 "Specify expanded extcommunity-list\n"
19873 "Extended Community list name\n"
19874 "Sequence number of an entry\n"
19875 "Sequence number\n"
19876 "Specify community to reject\n"
19877 "Specify community to accept\n"
19878 "An ordered list as a regular-expression\n")
19880 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19882 char *cl_number_or_name
= NULL
;
19887 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19888 seq
= argv
[idx
]->arg
;
19891 argv_find(argv
, argc
, "permit", &idx
);
19892 argv_find(argv
, argc
, "deny", &idx
);
19895 direct
= argv_find(argv
, argc
, "permit", &idx
)
19900 argv_find(argv
, argc
, "LINE", &idx
);
19901 str
= argv_concat(argv
, argc
, idx
);
19905 argv_find(argv
, argc
, "(100-500)", &idx
);
19906 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
19907 cl_number_or_name
= argv
[idx
]->arg
;
19909 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19910 seq
, direct
, style
);
19912 XFREE(MTYPE_TMP
, str
);
19915 community_list_perror(vty
, ret
);
19916 return CMD_WARNING_CONFIG_FAILED
;
19919 return CMD_SUCCESS
;
19922 ALIAS(no_extcommunity_list_expanded_all
,
19923 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19924 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
19925 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19926 "Extended Community list number (expanded)\n"
19927 "Specify expanded extcommunity-list\n"
19928 "Extended Community list name\n")
19930 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19932 struct community_entry
*entry
;
19934 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19935 if (entry
== list
->head
) {
19936 if (all_digit(list
->name
))
19937 vty_out(vty
, "Extended community %s list %s\n",
19938 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19940 : "(expanded) access",
19944 "Named extended community %s list %s\n",
19945 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19951 vty_out(vty
, " %s\n",
19952 community_direct_str(entry
->direct
));
19954 vty_out(vty
, " %s %s\n",
19955 community_direct_str(entry
->direct
),
19956 community_list_config_str(entry
));
19960 DEFUN (show_extcommunity_list
,
19961 show_bgp_extcommunity_list_cmd
,
19962 "show bgp extcommunity-list",
19965 "List extended-community list\n")
19967 struct community_list
*list
;
19968 struct community_list_master
*cm
;
19970 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19972 return CMD_SUCCESS
;
19974 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19975 extcommunity_list_show(vty
, list
);
19977 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19978 extcommunity_list_show(vty
, list
);
19980 return CMD_SUCCESS
;
19983 DEFUN (show_extcommunity_list_arg
,
19984 show_bgp_extcommunity_list_arg_cmd
,
19985 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
19988 "List extended-community list\n"
19989 "Extcommunity-list number\n"
19990 "Extcommunity-list name\n"
19991 "Detailed information on extcommunity-list\n")
19993 int idx_comm_list
= 3;
19994 struct community_list
*list
;
19996 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19997 EXTCOMMUNITY_LIST_MASTER
);
19999 vty_out(vty
, "%% Can't find extcommunity-list\n");
20000 return CMD_WARNING
;
20003 extcommunity_list_show(vty
, list
);
20005 return CMD_SUCCESS
;
20008 /* Display community-list and extcommunity-list configuration. */
20009 static int community_list_config_write(struct vty
*vty
)
20011 struct community_list
*list
;
20012 struct community_entry
*entry
;
20013 struct community_list_master
*cm
;
20016 /* Community-list. */
20017 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20019 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20020 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20022 "bgp community-list %s seq %" PRId64
" %s %s\n",
20023 list
->name
, entry
->seq
,
20024 community_direct_str(entry
->direct
),
20025 community_list_config_str(entry
));
20028 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20029 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20031 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20032 entry
->style
== COMMUNITY_LIST_STANDARD
20035 list
->name
, entry
->seq
,
20036 community_direct_str(entry
->direct
),
20037 community_list_config_str(entry
));
20041 /* Extcommunity-list. */
20042 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20044 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20045 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20047 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20048 list
->name
, entry
->seq
,
20049 community_direct_str(entry
->direct
),
20050 community_list_config_str(entry
));
20053 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20054 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20056 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20057 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20060 list
->name
, entry
->seq
,
20061 community_direct_str(entry
->direct
),
20062 community_list_config_str(entry
));
20067 /* lcommunity-list. */
20068 cm
= community_list_master_lookup(bgp_clist
,
20069 LARGE_COMMUNITY_LIST_MASTER
);
20071 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20072 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20074 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20075 list
->name
, entry
->seq
,
20076 community_direct_str(entry
->direct
),
20077 community_list_config_str(entry
));
20080 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20081 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20083 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20085 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20088 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20089 community_list_config_str(entry
));
20096 static int community_list_config_write(struct vty
*vty
);
20097 static struct cmd_node community_list_node
= {
20098 .name
= "community list",
20099 .node
= COMMUNITY_LIST_NODE
,
20101 .config_write
= community_list_config_write
,
20104 static void community_list_vty(void)
20106 install_node(&community_list_node
);
20108 /* Community-list. */
20109 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20110 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20111 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20112 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20113 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20114 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20115 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20116 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20118 /* Extcommunity-list. */
20119 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20120 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20121 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20122 install_element(CONFIG_NODE
,
20123 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20124 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20125 install_element(CONFIG_NODE
,
20126 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20127 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20128 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20130 /* Large Community List */
20131 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20132 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20133 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20134 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20135 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20136 install_element(CONFIG_NODE
,
20137 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20138 install_element(CONFIG_NODE
,
20139 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20140 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20141 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20142 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20143 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20144 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20145 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20147 bgp_community_list_command_completion_setup();
20150 static struct cmd_node community_alias_node
= {
20151 .name
= "community alias",
20152 .node
= COMMUNITY_ALIAS_NODE
,
20154 .config_write
= bgp_community_alias_write
,
20157 void community_alias_vty(void)
20159 install_node(&community_alias_node
);
20161 /* Community-list. */
20162 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20164 bgp_community_alias_command_completion_setup();