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 #include "northbound.h"
81 #include "northbound_cli.h"
82 #include "bgpd/bgp_nb.h"
85 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
88 .match_profile
= "traditional",
89 .match_version
= "< 7.4",
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
106 { .val_bool
= true, .match_profile
= "datacenter", },
107 { .val_bool
= false },
109 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
110 { .val_ulong
= 10, .match_profile
= "datacenter", },
111 { .val_ulong
= 120 },
113 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
114 { .val_ulong
= 9, .match_profile
= "datacenter", },
115 { .val_ulong
= 180 },
117 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
118 { .val_ulong
= 3, .match_profile
= "datacenter", },
121 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
122 { .val_bool
= false, .match_profile
= "datacenter", },
123 { .val_bool
= false, .match_version
= "< 7.4", },
124 { .val_bool
= true },
126 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
127 { .val_bool
= false, .match_version
= "< 7.6", },
128 { .val_bool
= true },
131 DEFINE_HOOK(bgp_inst_config_write
,
132 (struct bgp
*bgp
, struct vty
*vty
),
134 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
136 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
137 struct prefix
*range
, int exact
);
139 /* Show BGP peer's information. */
149 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
150 struct prefix
*range
, int exact
);
152 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
157 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
160 afi_t afi
, bool use_json
);
162 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
163 char *base_xpath
, int xpath_len
,
166 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
172 return BGP_IPV4_NODE
;
174 return BGP_IPV4M_NODE
;
175 case SAFI_LABELED_UNICAST
:
176 return BGP_IPV4L_NODE
;
178 return BGP_VPNV4_NODE
;
180 return BGP_FLOWSPECV4_NODE
;
183 return BGP_IPV4_NODE
;
189 return BGP_IPV6_NODE
;
191 return BGP_IPV6M_NODE
;
192 case SAFI_LABELED_UNICAST
:
193 return BGP_IPV6L_NODE
;
195 return BGP_VPNV6_NODE
;
197 return BGP_FLOWSPECV6_NODE
;
200 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* return string maps to afi-safi specific container names
294 * defined in bgp yang file.
296 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
299 if (safi
== SAFI_UNICAST
)
300 return "ipv4-unicast";
301 if (safi
== SAFI_MULTICAST
)
302 return "ipv4-multicast";
303 if (safi
== SAFI_LABELED_UNICAST
)
304 return "ipv4-labeled-unicast";
305 if (safi
== SAFI_MPLS_VPN
)
306 return "l3vpn-ipv4-unicast";
307 if (safi
== SAFI_FLOWSPEC
)
308 return "ipv4-flowspec";
309 } else if (afi
== AFI_IP6
) {
310 if (safi
== SAFI_UNICAST
)
311 return "ipv6-unicast";
312 if (safi
== SAFI_MULTICAST
)
313 return "ipv6-multicast";
314 if (safi
== SAFI_LABELED_UNICAST
)
315 return "ipv6-labeled-unicast";
316 if (safi
== SAFI_MPLS_VPN
)
317 return "l3vpn-ipv6-unicast";
318 if (safi
== SAFI_FLOWSPEC
)
319 return "ipv6-flowspec";
320 } else if (afi
== AFI_L2VPN
) {
321 if (safi
== SAFI_EVPN
)
328 /* Utility function to get address family from current node. */
329 afi_t
bgp_node_afi(struct vty
*vty
)
337 case BGP_FLOWSPECV6_NODE
:
350 /* Utility function to get subsequent address family from current
352 safi_t
bgp_node_safi(struct vty
*vty
)
358 safi
= SAFI_MPLS_VPN
;
362 safi
= SAFI_MULTICAST
;
369 safi
= SAFI_LABELED_UNICAST
;
371 case BGP_FLOWSPECV4_NODE
:
372 case BGP_FLOWSPECV6_NODE
:
373 safi
= SAFI_FLOWSPEC
;
383 * Converts an AFI in string form to afi_t
385 * @param afi string, one of
389 * @return the corresponding afi_t
391 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
393 afi_t afi
= AFI_MAX
; /* unknown */
394 if (strmatch(afi_str
, "ipv4"))
396 else if (strmatch(afi_str
, "ipv6"))
398 else if (strmatch(afi_str
, "l2vpn"))
403 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
407 if (argv_find(argv
, argc
, "ipv4", index
)) {
411 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
415 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
423 /* supports <unicast|multicast|vpn|labeled-unicast> */
424 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
426 safi_t safi
= SAFI_MAX
; /* unknown */
427 if (strmatch(safi_str
, "multicast"))
428 safi
= SAFI_MULTICAST
;
429 else if (strmatch(safi_str
, "unicast"))
431 else if (strmatch(safi_str
, "vpn"))
432 safi
= SAFI_MPLS_VPN
;
433 else if (strmatch(safi_str
, "evpn"))
435 else if (strmatch(safi_str
, "labeled-unicast"))
436 safi
= SAFI_LABELED_UNICAST
;
437 else if (strmatch(safi_str
, "flowspec"))
438 safi
= SAFI_FLOWSPEC
;
442 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
446 if (argv_find(argv
, argc
, "unicast", index
)) {
449 *safi
= SAFI_UNICAST
;
450 } else if (argv_find(argv
, argc
, "multicast", index
)) {
453 *safi
= SAFI_MULTICAST
;
454 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
457 *safi
= SAFI_LABELED_UNICAST
;
458 } else if (argv_find(argv
, argc
, "vpn", index
)) {
461 *safi
= SAFI_MPLS_VPN
;
462 } else if (argv_find(argv
, argc
, "evpn", index
)) {
466 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
469 *safi
= SAFI_FLOWSPEC
;
475 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
478 * address-family identifier
481 * subsequent address-family identifier
484 * default_af string corresponding to the supplied afi/safi pair.
485 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
488 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
494 return "ipv4-unicast";
496 return "ipv4-multicast";
501 case SAFI_LABELED_UNICAST
:
502 return "ipv4-labeled-unicast";
504 return "ipv4-flowspec";
506 return "unknown-afi/safi";
512 return "ipv6-unicast";
514 return "ipv6-multicast";
519 case SAFI_LABELED_UNICAST
:
520 return "ipv6-labeled-unicast";
522 return "ipv6-flowspec";
524 return "unknown-afi/safi";
532 return "unknown-afi/safi";
536 return "unknown-afi/safi";
538 /* all AFIs are accounted for above, so this shouldn't happen */
539 return "unknown-afi/safi";
542 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
543 enum bgp_instance_type inst_type
)
545 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
547 if (ret
== BGP_CREATED
) {
548 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
549 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
551 if (DFLT_BGP_IMPORT_CHECK
)
552 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
553 if (DFLT_BGP_SHOW_HOSTNAME
)
554 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
555 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
556 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
557 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
558 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
559 if (DFLT_BGP_DETERMINISTIC_MED
)
560 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
561 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
562 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
563 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
564 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
572 * bgp_vty_find_and_parse_afi_safi_bgp
574 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
575 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
576 * to appropriate values for the calling function. This is to allow the
577 * calling function to make decisions appropriate for the show command
578 * that is being parsed.
580 * The show commands are generally of the form:
581 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
582 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
584 * Since we use argv_find if the show command in particular doesn't have:
586 * [<view|vrf> VIEWVRFNAME]
587 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
588 * The command parsing should still be ok.
590 * vty -> The vty for the command so we can output some useful data in
591 * the event of a parse error in the vrf.
592 * argv -> The command tokens
593 * argc -> How many command tokens we have
594 * idx -> The current place in the command, generally should be 0 for this
596 * afi -> The parsed afi if it was included in the show command, returned here
597 * safi -> The parsed safi if it was included in the show command, returned here
598 * bgp -> Pointer to the bgp data structure we need to fill in.
599 * use_json -> json is configured or not
601 * The function returns the correct location in the parse tree for the
604 * Returns 0 for failure to parse correctly, else the idx position of where
605 * it found the last token.
607 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
608 struct cmd_token
**argv
, int argc
,
609 int *idx
, afi_t
*afi
, safi_t
*safi
,
610 struct bgp
**bgp
, bool use_json
)
612 char *vrf_name
= NULL
;
618 if (argv_find(argv
, argc
, "ip", idx
))
621 if (argv_find(argv
, argc
, "view", idx
))
622 vrf_name
= argv
[*idx
+ 1]->arg
;
623 else if (argv_find(argv
, argc
, "vrf", idx
)) {
624 vrf_name
= argv
[*idx
+ 1]->arg
;
625 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
629 if (strmatch(vrf_name
, "all"))
632 *bgp
= bgp_lookup_by_name(vrf_name
);
635 json_object
*json
= NULL
;
636 json
= json_object_new_object();
637 json_object_string_add(
639 "View/Vrf is unknown");
641 json_object_to_json_string_ext(json
,
642 JSON_C_TO_STRING_PRETTY
));
643 json_object_free(json
);
646 vty_out(vty
, "View/Vrf %s is unknown\n",
653 *bgp
= bgp_get_default();
656 json_object
*json
= NULL
;
657 json
= json_object_new_object();
658 json_object_string_add(
660 "Default BGP instance not found");
662 json_object_to_json_string_ext(json
,
663 JSON_C_TO_STRING_PRETTY
));
664 json_object_free(json
);
668 "Default BGP instance not found\n");
674 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
675 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
681 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
683 struct interface
*ifp
= NULL
;
685 if (su
->sa
.sa_family
== AF_INET
)
686 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
687 else if (su
->sa
.sa_family
== AF_INET6
)
688 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
689 su
->sin6
.sin6_scope_id
,
698 /* Utility function for looking up peer or peer group. */
699 /* This is used only for configuration, so disallow if attempted on
700 * a dynamic neighbor.
702 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
704 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
707 struct peer
*peer
= NULL
;
708 struct peer_group
*group
= NULL
;
714 ret
= str2sockunion(peer_str
, &su
);
716 /* IP address, locate peer. */
717 peer
= peer_lookup(bgp
, &su
);
719 /* Not IP, could match either peer configured on interface or a
721 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
723 group
= peer_group_lookup(bgp
, peer_str
);
727 if (peer_dynamic_neighbor(peer
)) {
729 "%% Operation not allowed on a dynamic neighbor\n");
739 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
744 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
746 const char *str
= NULL
;
749 case BGP_ERR_INVALID_VALUE
:
750 str
= "Invalid value";
752 case BGP_ERR_INVALID_FLAG
:
753 str
= "Invalid flag";
755 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
756 str
= "Peer-group has been shutdown. Activate the peer-group first";
758 case BGP_ERR_PEER_FLAG_CONFLICT
:
759 str
= "Can't set override-capability and strict-capability-match at the same time";
761 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
762 str
= "Specify remote-as or peer-group remote AS first";
764 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
765 str
= "Cannot change the peer-group. Deconfigure first";
767 case BGP_ERR_PEER_GROUP_MISMATCH
:
768 str
= "Peer is not a member of this peer-group";
770 case BGP_ERR_PEER_FILTER_CONFLICT
:
771 str
= "Prefix/distribute list can not co-exist";
773 case BGP_ERR_NOT_INTERNAL_PEER
:
774 str
= "Invalid command. Not an internal neighbor";
776 case BGP_ERR_REMOVE_PRIVATE_AS
:
777 str
= "remove-private-AS cannot be configured for IBGP peers";
779 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
780 str
= "Local-AS allowed only for EBGP peers";
782 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
783 str
= "Cannot have local-as same as BGP AS number";
785 case BGP_ERR_TCPSIG_FAILED
:
786 str
= "Error while applying TCP-Sig to session(s)";
788 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
789 str
= "ebgp-multihop and ttl-security cannot be configured together";
791 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
792 str
= "ttl-security only allowed for EBGP peers";
794 case BGP_ERR_AS_OVERRIDE
:
795 str
= "as-override cannot be configured for IBGP peers";
797 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
798 str
= "Invalid limit for number of dynamic neighbors";
800 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
801 str
= "Dynamic neighbor listen range already exists";
803 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
804 str
= "Operation not allowed on a dynamic neighbor";
806 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
807 str
= "Operation not allowed on a directly connected neighbor";
809 case BGP_ERR_PEER_SAFI_CONFLICT
:
810 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
812 case BGP_ERR_GR_INVALID_CMD
:
813 str
= "The Graceful Restart command used is not valid at this moment.";
815 case BGP_ERR_GR_OPERATION_FAILED
:
816 str
= "The Graceful Restart Operation failed due to an err.";
818 case BGP_ERR_PEER_GROUP_MEMBER
:
819 str
= "Peer-group member cannot override remote-as of peer-group";
821 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
822 str
= "Peer-group members must be all internal or all external";
826 snprintf(errmsg
, errmsg_len
, "%s", str
);
833 int bgp_vty_return(struct vty
*vty
, int ret
)
835 const char *str
= NULL
;
838 case BGP_ERR_INVALID_VALUE
:
839 str
= "Invalid value";
841 case BGP_ERR_INVALID_FLAG
:
842 str
= "Invalid flag";
844 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
845 str
= "Peer-group has been shutdown. Activate the peer-group first";
847 case BGP_ERR_PEER_FLAG_CONFLICT
:
848 str
= "Can't set override-capability and strict-capability-match at the same time";
850 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
851 str
= "Specify remote-as or peer-group remote AS first";
853 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
854 str
= "Cannot change the peer-group. Deconfigure first";
856 case BGP_ERR_PEER_GROUP_MISMATCH
:
857 str
= "Peer is not a member of this peer-group";
859 case BGP_ERR_PEER_FILTER_CONFLICT
:
860 str
= "Prefix/distribute list can not co-exist";
862 case BGP_ERR_NOT_INTERNAL_PEER
:
863 str
= "Invalid command. Not an internal neighbor";
865 case BGP_ERR_REMOVE_PRIVATE_AS
:
866 str
= "remove-private-AS cannot be configured for IBGP peers";
868 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
869 str
= "Local-AS allowed only for EBGP peers";
871 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
872 str
= "Cannot have local-as same as BGP AS number";
874 case BGP_ERR_TCPSIG_FAILED
:
875 str
= "Error while applying TCP-Sig to session(s)";
877 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
878 str
= "ebgp-multihop and ttl-security cannot be configured together";
880 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
881 str
= "ttl-security only allowed for EBGP peers";
883 case BGP_ERR_AS_OVERRIDE
:
884 str
= "as-override cannot be configured for IBGP peers";
886 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
887 str
= "Invalid limit for number of dynamic neighbors";
889 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
890 str
= "Dynamic neighbor listen range already exists";
892 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
893 str
= "Operation not allowed on a dynamic neighbor";
895 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
896 str
= "Operation not allowed on a directly connected neighbor";
898 case BGP_ERR_PEER_SAFI_CONFLICT
:
899 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
901 case BGP_ERR_GR_INVALID_CMD
:
902 str
= "The Graceful Restart command used is not valid at this moment.";
904 case BGP_ERR_GR_OPERATION_FAILED
:
905 str
= "The Graceful Restart Operation failed due to an err.";
909 vty_out(vty
, "%% %s\n", str
);
910 return CMD_WARNING_CONFIG_FAILED
;
915 /* BGP clear sort. */
924 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
925 int error
, char *errmsg
, size_t errmsg_len
)
928 case BGP_ERR_AF_UNCONFIGURED
:
929 snprintf(errmsg
, errmsg_len
,
930 "%%BGP: Enable %s address family for the neighbor %s",
931 get_afi_safi_str(afi
, safi
, false), peer
->host
);
933 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
936 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
944 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
945 struct listnode
**nnode
, enum bgp_clear_type stype
)
950 /* if afi/.safi not specified, spin thru all of them */
951 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
955 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
956 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
957 if (paf
&& paf
->subgroup
)
958 SET_FLAG(paf
->subgroup
->sflags
,
959 SUBGRP_STATUS_FORCE_UPDATES
);
961 if (!peer
->afc
[tmp_afi
][tmp_safi
])
964 if (stype
== BGP_CLEAR_SOFT_NONE
)
965 ret
= peer_clear(peer
, nnode
);
967 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
970 /* if afi specified and safi not, spin thru safis on this afi */
971 } else if (safi
== SAFI_UNSPEC
) {
974 for (tmp_safi
= SAFI_UNICAST
;
975 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
976 if (!peer
->afc
[afi
][tmp_safi
])
979 paf
= peer_af_find(peer
, afi
, tmp_safi
);
980 if (paf
&& paf
->subgroup
)
981 SET_FLAG(paf
->subgroup
->sflags
,
982 SUBGRP_STATUS_FORCE_UPDATES
);
984 if (stype
== BGP_CLEAR_SOFT_NONE
)
985 ret
= peer_clear(peer
, nnode
);
987 ret
= peer_clear_soft(peer
, afi
,
990 /* both afi/safi specified, let the caller know if not defined */
992 if (!peer
->afc
[afi
][safi
])
995 paf
= peer_af_find(peer
, afi
, safi
);
996 if (paf
&& paf
->subgroup
)
997 SET_FLAG(paf
->subgroup
->sflags
,
998 SUBGRP_STATUS_FORCE_UPDATES
);
1000 if (stype
== BGP_CLEAR_SOFT_NONE
)
1001 ret
= peer_clear(peer
, nnode
);
1003 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1009 /* `clear ip bgp' functions. */
1010 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1011 enum clear_sort sort
, enum bgp_clear_type stype
,
1012 const char *arg
, char *errmsg
, size_t errmsg_len
)
1018 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1020 /* Clear all neighbors. */
1022 * Pass along pointer to next node to peer_clear() when walking all
1023 * nodes on the BGP instance as that may get freed if it is a
1026 if (sort
== clear_all
) {
1027 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1029 bgp_peer_gr_flags_update(peer
);
1031 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1032 gr_router_detected
= true;
1034 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1038 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1039 errmsg
, errmsg_len
);
1042 if (gr_router_detected
1043 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1044 bgp_zebra_send_capabilities(bgp
, false);
1045 } else if (!gr_router_detected
1046 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1047 bgp_zebra_send_capabilities(bgp
, true);
1050 /* This is to apply read-only mode on this clear. */
1051 if (stype
== BGP_CLEAR_SOFT_NONE
)
1052 bgp
->update_delay_over
= 0;
1057 /* Clear specified neighbor. */
1058 if (sort
== clear_peer
) {
1061 /* Make sockunion for lookup. */
1062 ret
= str2sockunion(arg
, &su
);
1064 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1066 peer
= peer_lookup_by_hostname(bgp
, arg
);
1070 "Malformed address or name: %s",
1076 peer
= peer_lookup(bgp
, &su
);
1078 snprintf(errmsg
, errmsg_len
,
1079 "%%BGP: Unknown neighbor - \"%s\"",
1085 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1086 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1088 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1090 /* if afi/safi not defined for this peer, let caller know */
1092 ret
= BGP_ERR_AF_UNCONFIGURED
;
1095 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1101 /* Clear all neighbors belonging to a specific peer-group. */
1102 if (sort
== clear_group
) {
1103 struct peer_group
*group
;
1105 group
= peer_group_lookup(bgp
, arg
);
1107 snprintf(errmsg
, errmsg_len
,
1108 "%%BGP: No such peer-group %s", arg
);
1112 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1113 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1116 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1117 errmsg
, errmsg_len
);
1125 "%%BGP: No %s peer belonging to peer-group %s is configured",
1126 get_afi_safi_str(afi
, safi
, false), arg
);
1131 /* Clear all external (eBGP) neighbors. */
1132 if (sort
== clear_external
) {
1133 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1134 if (peer
->sort
== BGP_PEER_IBGP
)
1137 bgp_peer_gr_flags_update(peer
);
1139 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1140 gr_router_detected
= true;
1142 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1145 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1146 errmsg
, errmsg_len
);
1151 if (gr_router_detected
1152 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1153 bgp_zebra_send_capabilities(bgp
, false);
1154 } else if (!gr_router_detected
1155 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1156 bgp_zebra_send_capabilities(bgp
, true);
1160 snprintf(errmsg
, errmsg_len
,
1161 "%%BGP: No external %s peer is configured",
1162 get_afi_safi_str(afi
, safi
, false));
1167 /* Clear all neighbors belonging to a specific AS. */
1168 if (sort
== clear_as
) {
1169 as_t as
= strtoul(arg
, NULL
, 10);
1171 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1175 bgp_peer_gr_flags_update(peer
);
1177 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1178 gr_router_detected
= true;
1180 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1183 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1184 errmsg
, errmsg_len
);
1189 if (gr_router_detected
1190 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1191 bgp_zebra_send_capabilities(bgp
, false);
1192 } else if (!gr_router_detected
1193 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1194 bgp_zebra_send_capabilities(bgp
, true);
1198 snprintf(errmsg
, errmsg_len
,
1199 "%%BGP: No %s peer is configured with AS %s",
1200 get_afi_safi_str(afi
, safi
, false), arg
);
1208 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1209 enum clear_sort sort
, enum bgp_clear_type stype
,
1210 const char *arg
, char *errmsg
, size_t errmsg_len
)
1214 /* BGP structure lookup. */
1216 bgp
= bgp_lookup_by_name(name
);
1218 snprintf(errmsg
, errmsg_len
,
1219 "Can't find BGP instance %s", name
);
1223 bgp
= bgp_get_default();
1225 snprintf(errmsg
, errmsg_len
,
1226 "No BGP process is configured");
1231 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1234 /* clear soft inbound */
1235 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1241 FOREACH_AFI_SAFI (afi
, safi
) {
1242 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1243 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1245 if (ret
!= CMD_SUCCESS
)
1252 /* clear soft outbound */
1253 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1259 FOREACH_AFI_SAFI (afi
, safi
) {
1260 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1261 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1263 if (ret
!= CMD_SUCCESS
)
1271 #ifndef VTYSH_EXTRACT_PL
1272 #include "bgpd/bgp_vty_clippy.c"
1275 DEFUN_HIDDEN (bgp_local_mac
,
1277 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1279 "Local MAC config\n"
1280 "VxLAN Network Identifier\n"
1284 "mac-mobility sequence\n"
1294 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1295 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1296 vty_out(vty
, "%% Malformed MAC address\n");
1299 memset(&ip
, 0, sizeof(ip
));
1300 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1302 bgp
= bgp_get_default();
1304 vty_out(vty
, "Default BGP instance is not there\n");
1308 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1311 vty_out(vty
, "Internal error\n");
1318 DEFUN_HIDDEN (no_bgp_local_mac
,
1319 no_bgp_local_mac_cmd
,
1320 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1323 "Local MAC config\n"
1324 "VxLAN Network Identifier\n"
1335 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1336 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1337 vty_out(vty
, "%% Malformed MAC address\n");
1340 memset(&ip
, 0, sizeof(ip
));
1342 bgp
= bgp_get_default();
1344 vty_out(vty
, "Default BGP instance is not there\n");
1348 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1350 vty_out(vty
, "Internal error\n");
1357 DEFUN (no_synchronization
,
1358 no_synchronization_cmd
,
1359 "no synchronization",
1361 "Perform IGP synchronization\n")
1366 DEFUN (no_auto_summary
,
1367 no_auto_summary_cmd
,
1370 "Enable automatic network number summarization\n")
1375 /* "router bgp" commands. */
1376 DEFUN_YANG_NOSH(router_bgp
,
1378 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1379 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1382 int idx_view_vrf
= 3;
1384 int ret
= CMD_SUCCESS
;
1387 const char *name
= NULL
;
1388 enum bgp_instance_type inst_type
;
1389 char base_xpath
[XPATH_MAXLEN
];
1390 const struct lyd_node
*bgp_glb_dnode
;
1392 // "router bgp" without an ASN
1394 // Pending: Make VRF option available for ASN less config
1395 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1396 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1398 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1400 if (!bgp_glb_dnode
) {
1401 vty_out(vty
, "%% No BGP process is configured\n");
1402 return CMD_WARNING_CONFIG_FAILED
;
1405 if (listcount(bm
->bgp
) > 1) {
1406 vty_out(vty
, "%% Please specify ASN and VRF\n");
1407 return CMD_WARNING_CONFIG_FAILED
;
1410 as
= yang_dnode_get_uint32(bgp_glb_dnode
, "./global/local-as");
1412 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1415 * For backward compatibility with old commands we still
1416 * need to use the qobj infrastructure.
1418 bgp
= bgp_lookup(as
, NULL
);
1420 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1428 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1429 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1431 name
= argv
[idx_vrf
]->arg
;
1433 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1434 if (strmatch(name
, VRF_DEFAULT_NAME
))
1437 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1438 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1439 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1442 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1443 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1445 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1446 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1447 argv
[idx_asn
]->arg
);
1448 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1449 nb_cli_enqueue_change(vty
,
1450 "./global/instance-type-view",
1451 NB_OP_MODIFY
, "true");
1453 nb_cli_enqueue_change(vty
,
1454 "./global/instance-type-view",
1455 NB_OP_MODIFY
, "false");
1458 ret
= nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
1459 if (ret
== CMD_SUCCESS
) {
1460 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1463 * For backward compatibility with old commands we still
1464 * need to use the qobj infrastructure.
1466 bgp
= bgp_lookup(as
, name
);
1468 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1475 /* "no router bgp" commands. */
1476 DEFUN_YANG(no_router_bgp
,
1478 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1479 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1482 const char *name
= NULL
;
1483 char base_xpath
[XPATH_MAXLEN
];
1484 const struct lyd_node
*bgp_glb_dnode
;
1486 // "no router bgp" without an ASN
1488 // Pending: Make VRF option available for ASN less config
1489 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1490 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1492 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1494 if (!bgp_glb_dnode
) {
1495 vty_out(vty
, "%% No BGP process is configured\n");
1496 return CMD_WARNING_CONFIG_FAILED
;
1499 if (listcount(bm
->bgp
) > 1) {
1500 vty_out(vty
, "%% Please specify ASN and VRF\n");
1501 return CMD_WARNING_CONFIG_FAILED
;
1505 name
= argv
[idx_vrf
]->arg
;
1507 name
= VRF_DEFAULT_NAME
;
1509 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1510 "frr-bgp:bgp", "bgp", name
);
1513 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1515 /* We want to finish any classic config after a no router */
1516 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
1519 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1522 const struct lyd_node
*vrf_dnode
;
1523 const char *vrf_name
;
1526 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1527 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1528 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1530 vty_out(vty
, "!\n");
1531 vty_out(vty
, "router bgp %u", as
);
1532 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1533 vty_out(vty
, " vrf %s", vrf_name
);
1537 /* BGP router-id. */
1539 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1541 "Override configured router identifier\n"
1542 "Manually configured router identifier\n")
1544 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1547 return nb_cli_apply_changes(vty
, NULL
);
1550 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1552 "Override configured router identifier\n"
1553 "Manually configured router identifier\n")
1555 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1556 router_id_str
? router_id_str
: NULL
);
1558 return nb_cli_apply_changes(vty
, NULL
);
1561 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1564 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1567 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1568 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1570 "Add community specific parameters\n"
1571 "Create an alias for a community\n"
1572 "Community (AA:BB or AA:BB:CC)\n"
1575 struct community_alias ca1
;
1576 struct community_alias ca2
;
1577 struct community_alias
*lookup_community
;
1578 struct community_alias
*lookup_alias
;
1580 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1581 vty_out(vty
, "Invalid community format\n");
1585 memset(&ca1
, 0, sizeof(ca1
));
1586 memset(&ca2
, 0, sizeof(ca2
));
1587 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1588 strlcpy(ca1
.alias
, alias_name
, sizeof(ca1
.alias
));
1590 lookup_community
= bgp_ca_community_lookup(&ca1
);
1591 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1594 bgp_ca_alias_delete(&ca1
);
1595 bgp_ca_community_delete(&ca1
);
1598 /* Lookup if community hash table has an item
1599 * with the same alias name.
1601 strlcpy(ca2
.community
, lookup_alias
->community
,
1602 sizeof(ca2
.community
));
1603 if (bgp_ca_community_lookup(&ca2
)) {
1605 "community (%s) already has this alias (%s)\n",
1606 lookup_alias
->community
,
1607 lookup_alias
->alias
);
1610 bgp_ca_alias_delete(&ca1
);
1613 if (lookup_community
)
1614 bgp_ca_community_delete(&ca1
);
1616 bgp_ca_alias_insert(&ca1
);
1617 bgp_ca_community_insert(&ca1
);
1623 DEFPY (bgp_global_suppress_fib_pending
,
1624 bgp_global_suppress_fib_pending_cmd
,
1625 "[no] bgp suppress-fib-pending",
1628 "Advertise only routes that are programmed in kernel to peers globally\n")
1630 bm_wait_for_fib_set(!no
);
1635 DEFPY (bgp_suppress_fib_pending
,
1636 bgp_suppress_fib_pending_cmd
,
1637 "[no] bgp suppress-fib-pending",
1640 "Advertise only routes that are programmed in kernel to peers\n")
1642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1644 bgp_suppress_fib_pending_set(bgp
, !no
);
1649 /* BGP Cluster ID. */
1650 DEFUN_YANG(bgp_cluster_id
,
1652 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1654 "Configure Route-Reflector Cluster-id\n"
1655 "Route-Reflector Cluster-id in IP address format\n"
1656 "Route-Reflector Cluster-id as 32 bit quantity\n")
1660 nb_cli_enqueue_change(
1661 vty
, "./global/route-reflector/route-reflector-cluster-id",
1662 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1664 return nb_cli_apply_changes(vty
, NULL
);
1667 DEFUN_YANG(no_bgp_cluster_id
,
1668 no_bgp_cluster_id_cmd
,
1669 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1671 "Configure Route-Reflector Cluster-id\n"
1672 "Route-Reflector Cluster-id in IP address format\n"
1673 "Route-Reflector Cluster-id as 32 bit quantity\n")
1675 nb_cli_enqueue_change(
1676 vty
, "./global/route-reflector/route-reflector-cluster-id",
1677 NB_OP_DESTROY
, NULL
);
1679 return nb_cli_apply_changes(vty
, NULL
);
1686 "Disable BGP route installation to RIB (Zebra)\n")
1688 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1690 "%% No-RIB option is already set, nothing to do here.\n");
1694 bgp_option_norib_set_runtime();
1699 DEFPY (no_bgp_norib
,
1704 "Disable BGP route installation to RIB (Zebra)\n")
1706 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1708 "%% No-RIB option is not set, nothing to do here.\n");
1712 bgp_option_norib_unset_runtime();
1717 DEFPY (no_bgp_send_extra_data
,
1718 no_bgp_send_extra_data_cmd
,
1719 "[no] bgp send-extra-data zebra",
1722 "Extra data to Zebra for display/use\n"
1726 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1728 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1733 DEFUN_YANG(bgp_confederation_identifier
,
1734 bgp_confederation_identifier_cmd
,
1735 "bgp confederation identifier (1-4294967295)",
1736 "BGP specific commands\n"
1737 "AS confederation parameters\n"
1739 "Set routing domain confederation AS\n")
1743 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1744 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1746 return nb_cli_apply_changes(vty
, NULL
);
1749 DEFUN_YANG(no_bgp_confederation_identifier
,
1750 no_bgp_confederation_identifier_cmd
,
1751 "no bgp confederation identifier [(1-4294967295)]",
1753 "BGP specific commands\n"
1754 "AS confederation parameters\n"
1756 "Set routing domain confederation AS\n")
1758 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1759 NB_OP_DESTROY
, NULL
);
1761 return nb_cli_apply_changes(vty
, NULL
);
1764 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1765 struct lyd_node
*dnode
,
1768 vty_out(vty
, " bgp confederation identifier %u\n",
1769 yang_dnode_get_uint32(dnode
, NULL
));
1772 DEFUN_YANG(bgp_confederation_peers
,
1773 bgp_confederation_peers_cmd
,
1774 "bgp confederation peers (1-4294967295)...",
1775 "BGP specific commands\n"
1776 "AS confederation parameters\n"
1777 "Peer ASs in BGP confederation\n" AS_STR
)
1782 for (i
= idx_asn
; i
< argc
; i
++)
1783 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1784 NB_OP_CREATE
, argv
[i
]->arg
);
1786 return nb_cli_apply_changes(vty
, NULL
);
1789 DEFUN_YANG(no_bgp_confederation_peers
,
1790 no_bgp_confederation_peers_cmd
,
1791 "no bgp confederation peers (1-4294967295)...",
1793 "BGP specific commands\n"
1794 "AS confederation parameters\n"
1795 "Peer ASs in BGP confederation\n" AS_STR
)
1800 for (i
= idx_asn
; i
< argc
; i
++)
1801 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1802 NB_OP_DESTROY
, argv
[i
]->arg
);
1804 return nb_cli_apply_changes(vty
, NULL
);
1807 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1808 struct lyd_node
*dnode
,
1811 vty_out(vty
, " bgp confederation peers %u \n",
1812 yang_dnode_get_uint32(dnode
, NULL
));
1816 * Central routine for maximum-paths configuration.
1817 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1818 * @set: 1 for setting values, 0 for removing the max-paths config.
1820 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1821 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1822 int set
, char *errmsg
, size_t errmsg_len
)
1827 if (maxpaths
> multipath_num
) {
1830 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1831 maxpaths
, multipath_num
);
1832 return CMD_WARNING_CONFIG_FAILED
;
1834 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1837 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1842 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1843 (set
== 1) ? "" : "un",
1844 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1845 maxpaths
, afi
, safi
);
1846 return CMD_WARNING_CONFIG_FAILED
;
1849 bgp_recalculate_all_bestpaths(bgp
);
1854 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1857 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1858 uint32_t med_admin_val
;
1860 vty_out(vty
, " bgp max-med administrative");
1861 med_admin_val
= yang_dnode_get_uint32(dnode
, "./max-med-admin");
1862 if (med_admin_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1863 vty_out(vty
, " %u", med_admin_val
);
1867 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1868 uint32_t onstartup_val
;
1870 vty_out(vty
, " bgp max-med on-startup %u",
1871 yang_dnode_get_uint32(dnode
,
1872 "./max-med-onstart-up-time"));
1873 onstartup_val
= yang_dnode_get_uint32(
1874 dnode
, "./max-med-onstart-up-value");
1875 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1876 vty_out(vty
, " %u", onstartup_val
);
1882 DEFUN_YANG(bgp_maxmed_admin
,
1883 bgp_maxmed_admin_cmd
,
1884 "bgp max-med administrative ",
1886 "Advertise routes with max-med\n"
1887 "Administratively applied, for an indefinite period\n")
1889 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1890 NB_OP_MODIFY
, "true");
1892 return nb_cli_apply_changes(vty
, NULL
);
1895 DEFUN_YANG(bgp_maxmed_admin_medv
,
1896 bgp_maxmed_admin_medv_cmd
,
1897 "bgp max-med administrative (0-4294967295)",
1899 "Advertise routes with max-med\n"
1900 "Administratively applied, for an indefinite period\n"
1901 "Max MED value to be used\n")
1905 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1906 NB_OP_MODIFY
, "true");
1908 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1909 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1911 return nb_cli_apply_changes(vty
, NULL
);
1914 DEFUN_YANG(no_bgp_maxmed_admin
,
1915 no_bgp_maxmed_admin_cmd
,
1916 "no bgp max-med administrative [(0-4294967295)]",
1918 "Advertise routes with max-med\n"
1919 "Administratively applied, for an indefinite period\n"
1920 "Max MED value to be used\n")
1922 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1923 NB_OP_MODIFY
, "false");
1925 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1926 NB_OP_MODIFY
, NULL
);
1928 return nb_cli_apply_changes(vty
, NULL
);
1931 DEFUN_YANG (bgp_maxmed_onstartup
,
1932 bgp_maxmed_onstartup_cmd
,
1933 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1935 "Advertise routes with max-med\n"
1936 "Effective on a startup\n"
1937 "Time (seconds) period for max-med\n"
1938 "Max MED value to be used\n")
1942 argv_find(argv
, argc
, "(5-86400)", &idx
);
1943 nb_cli_enqueue_change(vty
,
1944 "./global/med-config/max-med-onstart-up-time",
1945 NB_OP_MODIFY
, argv
[idx
]->arg
);
1947 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1948 nb_cli_enqueue_change(
1949 vty
, "./global/med-config/max-med-onstart-up-value",
1950 NB_OP_MODIFY
, argv
[idx
]->arg
);
1952 nb_cli_enqueue_change(
1953 vty
, "./global/med-config/max-med-onstart-up-value",
1954 NB_OP_MODIFY
, NULL
);
1956 return nb_cli_apply_changes(vty
, NULL
);
1959 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1960 no_bgp_maxmed_onstartup_cmd
,
1961 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1963 "Advertise routes with max-med\n"
1964 "Effective on a startup\n"
1965 "Time (seconds) period for max-med\n"
1966 "Max MED value to be used\n")
1968 nb_cli_enqueue_change(vty
,
1969 "./global/med-config/max-med-onstart-up-time",
1970 NB_OP_DESTROY
, NULL
);
1972 nb_cli_enqueue_change(vty
,
1973 "./global/med-config/max-med-onstart-up-value",
1974 NB_OP_MODIFY
, NULL
);
1976 return nb_cli_apply_changes(vty
, NULL
);
1979 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1980 uint16_t update_delay
,
1981 uint16_t establish_wait
)
1983 struct listnode
*node
, *nnode
;
1985 bool vrf_cfg
= false;
1988 * See if update-delay is set per-vrf and warn user to delete it
1989 * Note that we only need to check this if this is the first time
1990 * setting the global config.
1992 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1993 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1994 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1996 "%% update-delay configuration found in vrf %s\n",
1997 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2007 "%%Failed: global update-delay config not permitted\n");
2011 if (!establish_wait
) { /* update-delay <delay> */
2012 bm
->v_update_delay
= update_delay
;
2013 bm
->v_establish_wait
= bm
->v_update_delay
;
2015 /* update-delay <delay> <establish-wait> */
2016 if (update_delay
< establish_wait
) {
2018 "%%Failed: update-delay less than the establish-wait!\n");
2019 return CMD_WARNING_CONFIG_FAILED
;
2022 bm
->v_update_delay
= update_delay
;
2023 bm
->v_establish_wait
= establish_wait
;
2026 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2027 bgp
->v_update_delay
= bm
->v_update_delay
;
2028 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2034 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2036 struct listnode
*node
, *nnode
;
2039 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2040 bm
->v_establish_wait
= bm
->v_update_delay
;
2042 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2043 bgp
->v_update_delay
= bm
->v_update_delay
;
2044 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2050 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2051 uint16_t establish_wait
)
2053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2055 /* if configured globally, per-instance config is not allowed */
2056 if (bm
->v_update_delay
) {
2058 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2059 return CMD_WARNING_CONFIG_FAILED
;
2063 if (!establish_wait
) /* update-delay <delay> */
2065 bgp
->v_update_delay
= update_delay
;
2066 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2070 /* update-delay <delay> <establish-wait> */
2071 if (update_delay
< establish_wait
) {
2073 "%%Failed: update-delay less than the establish-wait!\n");
2074 return CMD_WARNING_CONFIG_FAILED
;
2077 bgp
->v_update_delay
= update_delay
;
2078 bgp
->v_establish_wait
= establish_wait
;
2083 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2087 /* If configured globally, cannot remove from one bgp instance */
2088 if (bm
->v_update_delay
) {
2090 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2091 return CMD_WARNING_CONFIG_FAILED
;
2093 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2094 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2099 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2101 /* If configured globally, no need to display per-instance value */
2102 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2103 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2104 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2105 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2110 /* Global update-delay configuration */
2111 DEFPY (bgp_global_update_delay
,
2112 bgp_global_update_delay_cmd
,
2113 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2115 "Force initial delay for best-path and updates for all bgp instances\n"
2116 "Max delay in seconds\n"
2117 "Establish wait in seconds\n")
2119 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2122 /* Global update-delay deconfiguration */
2123 DEFPY (no_bgp_global_update_delay
,
2124 no_bgp_global_update_delay_cmd
,
2125 "no bgp update-delay [(0-3600) [(1-3600)]]",
2128 "Force initial delay for best-path and updates\n"
2129 "Max delay in seconds\n"
2130 "Establish wait in seconds\n")
2132 return bgp_global_update_delay_deconfig_vty(vty
);
2135 /* Update-delay configuration */
2137 DEFPY (bgp_update_delay
,
2138 bgp_update_delay_cmd
,
2139 "update-delay (0-3600)$delay [(1-3600)$wait]",
2140 "Force initial delay for best-path and updates\n"
2141 "Max delay in seconds\n"
2142 "Establish wait in seconds\n")
2144 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2147 /* Update-delay deconfiguration */
2148 DEFPY (no_bgp_update_delay
,
2149 no_bgp_update_delay_cmd
,
2150 "no update-delay [(0-3600) [(1-3600)]]",
2152 "Force initial delay for best-path and updates\n"
2153 "Max delay in seconds\n"
2154 "Establish wait in seconds\n")
2156 return bgp_update_delay_deconfig_vty(vty
);
2160 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2162 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2163 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2168 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2170 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2171 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2176 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2179 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2180 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2181 vty_out(vty
, " write-quanta %d\n", quanta
);
2184 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2187 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2188 if (quanta
!= BGP_READ_PACKET_MAX
)
2189 vty_out(vty
, " read-quanta %d\n", quanta
);
2192 /* Packet quanta configuration
2194 * XXX: The value set here controls the size of a stack buffer in the IO
2195 * thread. When changing these limits be careful to prevent stack overflow.
2197 * Furthermore, the maximums used here should correspond to
2198 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2200 DEFPY_YANG (bgp_wpkt_quanta
,
2201 bgp_wpkt_quanta_cmd
,
2202 "[no] write-quanta (1-64)$quanta",
2204 "How many packets to write to peer socket per run\n"
2205 "Number of packets\n")
2208 nb_cli_enqueue_change(
2210 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2211 NB_OP_MODIFY
, quanta_str
);
2213 nb_cli_enqueue_change(
2215 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2216 NB_OP_MODIFY
, NULL
);
2218 return nb_cli_apply_changes(vty
, NULL
);
2221 DEFPY_YANG (bgp_rpkt_quanta
,
2222 bgp_rpkt_quanta_cmd
,
2223 "[no] read-quanta (1-10)$quanta",
2225 "How many packets to read from peer socket per I/O cycle\n"
2226 "Number of packets\n")
2229 nb_cli_enqueue_change(
2231 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2232 NB_OP_MODIFY
, quanta_str
);
2234 nb_cli_enqueue_change(
2236 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2237 NB_OP_MODIFY
, NULL
);
2239 return nb_cli_apply_changes(vty
, NULL
);
2242 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2244 if (!bgp
->heuristic_coalesce
)
2245 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2248 void cli_show_router_global_update_group_config_coalesce_time(
2249 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2251 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2255 DEFUN_YANG (bgp_coalesce_time
,
2256 bgp_coalesce_time_cmd
,
2257 "coalesce-time (0-4294967295)",
2258 "Subgroup coalesce timer\n"
2259 "Subgroup coalesce timer value (in ms)\n")
2263 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2264 nb_cli_enqueue_change(
2265 vty
, "./global/global-update-group-config/coalesce-time",
2266 NB_OP_MODIFY
, argv
[idx
]->arg
);
2268 return nb_cli_apply_changes(vty
, NULL
);
2271 DEFUN_YANG(no_bgp_coalesce_time
,
2272 no_bgp_coalesce_time_cmd
,
2273 "no coalesce-time (0-4294967295)",
2275 "Subgroup coalesce timer\n"
2276 "Subgroup coalesce timer value (in ms)\n")
2278 nb_cli_enqueue_change(
2279 vty
, "./global/global-update-group-config/coalesce-time",
2280 NB_OP_MODIFY
, NULL
);
2282 return nb_cli_apply_changes(vty
, NULL
);
2285 /* Maximum-paths configuration */
2286 DEFUN_YANG (bgp_maxpaths
,
2288 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2289 "Forward packets over multiple paths\n"
2290 "Number of paths\n")
2293 char base_xpath
[XPATH_MAXLEN
];
2297 afi
= bgp_node_afi(vty
);
2298 safi
= bgp_node_safi(vty
);
2301 base_xpath
, sizeof(base_xpath
),
2302 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2303 yang_afi_safi_value2identity(afi
, safi
),
2304 bgp_afi_safi_get_container_str(afi
, safi
));
2306 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2307 argv
[idx_number
]->arg
);
2309 return nb_cli_apply_changes(vty
, NULL
);
2312 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2313 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2315 vty_out(vty
, " maximum-paths %d\n",
2316 yang_dnode_get_uint16(dnode
, NULL
));
2319 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2320 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2321 "Forward packets over multiple paths\n"
2322 "Number of paths\n")
2324 DEFUN_YANG (bgp_maxpaths_ibgp
,
2325 bgp_maxpaths_ibgp_cmd
,
2326 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2327 "Forward packets over multiple paths\n"
2329 "Number of paths\n")
2332 char base_xpath
[XPATH_MAXLEN
];
2336 afi
= bgp_node_afi(vty
);
2337 safi
= bgp_node_safi(vty
);
2340 base_xpath
, sizeof(base_xpath
),
2341 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2342 yang_afi_safi_value2identity(afi
, safi
),
2343 bgp_afi_safi_get_container_str(afi
, safi
));
2345 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2346 argv
[idx_number
]->arg
);
2348 return nb_cli_apply_changes(vty
, NULL
);
2351 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2352 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2353 "Forward packets over multiple paths\n"
2355 "Number of paths\n")
2357 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2358 bgp_maxpaths_ibgp_cluster_cmd
,
2359 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2360 "Forward packets over multiple paths\n"
2363 "Match the cluster length\n")
2366 char base_xpath
[XPATH_MAXLEN
];
2370 afi
= bgp_node_afi(vty
);
2371 safi
= bgp_node_safi(vty
);
2374 base_xpath
, sizeof(base_xpath
),
2375 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2376 yang_afi_safi_value2identity(afi
, safi
),
2377 bgp_afi_safi_get_container_str(afi
, safi
));
2379 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2380 argv
[idx_number
]->arg
);
2383 base_xpath
, sizeof(base_xpath
),
2384 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2385 yang_afi_safi_value2identity(afi
, safi
),
2386 bgp_afi_safi_get_container_str(afi
, safi
));
2388 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2390 return nb_cli_apply_changes(vty
, NULL
);
2393 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2394 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2396 vty_out(vty
, " maximum-paths ibgp %d",
2397 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2398 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2399 vty_out(vty
, " equal-cluster-length");
2403 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2404 "maximum-paths ibgp " CMD_RANGE_STR(
2405 1, MULTIPATH_NUM
) " equal-cluster-length",
2406 "Forward packets over multiple paths\n"
2409 "Match the cluster length\n")
2411 DEFUN_YANG (no_bgp_maxpaths
,
2412 no_bgp_maxpaths_cmd
,
2413 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2415 "Forward packets over multiple paths\n"
2416 "Number of paths\n")
2418 char base_xpath
[XPATH_MAXLEN
];
2422 afi
= bgp_node_afi(vty
);
2423 safi
= bgp_node_safi(vty
);
2426 base_xpath
, sizeof(base_xpath
),
2427 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2428 yang_afi_safi_value2identity(afi
, safi
),
2429 bgp_afi_safi_get_container_str(afi
, safi
));
2431 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2433 return nb_cli_apply_changes(vty
, NULL
);
2436 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2437 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2438 "Forward packets over multiple paths\n"
2439 "Number of paths\n")
2441 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2442 no_bgp_maxpaths_ibgp_cmd
,
2443 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2445 "Forward packets over multiple paths\n"
2448 "Match the cluster length\n")
2450 char base_xpath
[XPATH_MAXLEN
];
2454 afi
= bgp_node_afi(vty
);
2455 safi
= bgp_node_safi(vty
);
2458 base_xpath
, sizeof(base_xpath
),
2459 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2460 yang_afi_safi_value2identity(afi
, safi
),
2461 bgp_afi_safi_get_container_str(afi
, safi
));
2463 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2466 base_xpath
, sizeof(base_xpath
),
2467 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2468 yang_afi_safi_value2identity(afi
, safi
),
2469 bgp_afi_safi_get_container_str(afi
, safi
));
2471 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2473 return nb_cli_apply_changes(vty
, NULL
);
2476 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2477 "no maximum-paths ibgp [" CMD_RANGE_STR(
2478 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2480 "Forward packets over multiple paths\n"
2483 "Match the cluster length\n")
2485 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2486 afi_t afi
, safi_t safi
)
2488 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2489 vty_out(vty
, " maximum-paths %d\n",
2490 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2493 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2494 vty_out(vty
, " maximum-paths ibgp %d",
2495 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2496 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2497 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2498 vty_out(vty
, " equal-cluster-length");
2505 DEFUN_YANG (bgp_timers
,
2507 "timers bgp (0-65535) (0-65535)",
2508 "Adjust routing timers\n"
2510 "Keepalive interval\n"
2514 int idx_number_2
= 3;
2516 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2517 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2518 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2519 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2521 return nb_cli_apply_changes(vty
, NULL
);
2524 DEFUN_YANG (no_bgp_timers
,
2526 "no timers bgp [(0-65535) (0-65535)]",
2528 "Adjust routing timers\n"
2530 "Keepalive interval\n"
2533 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2534 NB_OP_DESTROY
, NULL
);
2535 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2536 NB_OP_DESTROY
, NULL
);
2538 return nb_cli_apply_changes(vty
, NULL
);
2541 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2542 struct lyd_node
*dnode
,
2545 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2546 vty_out(vty
, " no bgp client-to-client reflection\n");
2548 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2549 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2551 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2552 vty_out(vty
, " bgp cluster-id %s\n",
2553 yang_dnode_get_string(dnode
,
2554 "./route-reflector-cluster-id"));
2557 DEFUN_YANG(bgp_client_to_client_reflection
,
2558 bgp_client_to_client_reflection_cmd
,
2559 "bgp client-to-client reflection",
2560 "BGP specific commands\n"
2561 "Configure client to client route reflection\n"
2562 "reflection of routes allowed\n")
2564 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2565 NB_OP_MODIFY
, "false");
2567 return nb_cli_apply_changes(vty
, NULL
);
2570 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2571 no_bgp_client_to_client_reflection_cmd
,
2572 "no bgp client-to-client reflection",
2574 "BGP specific commands\n"
2575 "Configure client to client route reflection\n"
2576 "reflection of routes allowed\n")
2578 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2579 NB_OP_MODIFY
, "true");
2581 return nb_cli_apply_changes(vty
, NULL
);
2584 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2585 struct lyd_node
*dnode
,
2589 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2590 vty_out(vty
, " bgp always-compare-med\n");
2592 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2593 vty_out(vty
, " bgp bestpath as-path ignore\n");
2595 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2596 vty_out(vty
, " bgp bestpath as-path confed\n");
2598 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2599 vty_out(vty
, " bgp bestpath compare-routerid\n");
2601 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2602 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2604 " bgp bestpath as-path multipath-relax as-set\n");
2606 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2609 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2610 vty_out(vty
, " bgp deterministic-med\n");
2612 if (yang_dnode_get_bool(dnode
, "./confed-med")
2613 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2614 vty_out(vty
, " bgp bestpath med");
2615 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2616 vty_out(vty
, " confed");
2617 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2618 vty_out(vty
, " missing-as-worst");
2623 /* "bgp always-compare-med" configuration. */
2624 DEFUN_YANG(bgp_always_compare_med
,
2625 bgp_always_compare_med_cmd
,
2626 "bgp always-compare-med",
2627 "BGP specific commands\n"
2628 "Allow comparing MED from different neighbors\n")
2630 nb_cli_enqueue_change(
2631 vty
, "./global/route-selection-options/always-compare-med",
2632 NB_OP_MODIFY
, "true");
2634 return nb_cli_apply_changes(vty
, NULL
);
2637 DEFUN_YANG(no_bgp_always_compare_med
,
2638 no_bgp_always_compare_med_cmd
,
2639 "no bgp always-compare-med",
2641 "BGP specific commands\n"
2642 "Allow comparing MED from different neighbors\n")
2644 nb_cli_enqueue_change(
2645 vty
, "./global/route-selection-options/always-compare-med",
2646 NB_OP_MODIFY
, "false");
2648 return nb_cli_apply_changes(vty
, NULL
);
2651 DEFUN_YANG(bgp_suppress_duplicates
,
2652 bgp_suppress_duplicates_cmd
,
2653 "bgp suppress-duplicates",
2654 "BGP specific commands\n"
2655 "Suppress duplicate updates if the route actually not changed\n")
2657 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2658 NB_OP_MODIFY
, "true");
2659 return nb_cli_apply_changes(vty
, NULL
);
2662 DEFUN_YANG(no_bgp_suppress_duplicates
,
2663 no_bgp_suppress_duplicates_cmd
,
2664 "no bgp suppress-duplicates",
2666 "BGP specific commands\n"
2667 "Suppress duplicate updates if the route actually not changed\n")
2669 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2670 NB_OP_MODIFY
, "false");
2671 return nb_cli_apply_changes(vty
, NULL
);
2674 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2675 struct lyd_node
*dnode
,
2678 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2679 vty_out(vty
, " bgp suppress-duplicates\n");
2682 DEFUN_YANG(bgp_ebgp_requires_policy
,
2683 bgp_ebgp_requires_policy_cmd
,
2684 "bgp ebgp-requires-policy",
2685 "BGP specific commands\n"
2686 "Require in and out policy for eBGP peers (RFC8212)\n")
2688 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2689 NB_OP_MODIFY
, "true");
2690 return nb_cli_apply_changes(vty
, NULL
);
2693 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2694 no_bgp_ebgp_requires_policy_cmd
,
2695 "no bgp ebgp-requires-policy",
2697 "BGP specific commands\n"
2698 "Require in and out policy for eBGP peers (RFC8212)\n")
2700 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2701 NB_OP_MODIFY
, "false");
2702 return nb_cli_apply_changes(vty
, NULL
);
2705 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2706 struct lyd_node
*dnode
,
2709 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2710 vty_out(vty
, " bgp ebgp-requires-policy\n");
2713 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2714 "bgp reject-as-sets",
2715 "BGP specific commands\n"
2716 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2719 struct listnode
*node
, *nnode
;
2722 bgp
->reject_as_sets
= true;
2724 /* Reset existing BGP sessions to reject routes
2725 * with aspath containing AS_SET or AS_CONFED_SET.
2727 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2728 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2729 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2730 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2731 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2738 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2739 "no bgp reject-as-sets",
2741 "BGP specific commands\n"
2742 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2744 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2745 struct listnode
*node
, *nnode
;
2748 bgp
->reject_as_sets
= false;
2750 /* Reset existing BGP sessions to reject routes
2751 * with aspath containing AS_SET or AS_CONFED_SET.
2753 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2754 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2755 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2756 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2757 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2764 /* "bgp deterministic-med" configuration. */
2765 DEFUN_YANG (bgp_deterministic_med
,
2766 bgp_deterministic_med_cmd
,
2767 "bgp deterministic-med",
2768 "BGP specific commands\n"
2769 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2771 nb_cli_enqueue_change(
2772 vty
, "./global/route-selection-options/deterministic-med",
2773 NB_OP_MODIFY
, "true");
2775 return nb_cli_apply_changes(vty
, NULL
);
2778 DEFUN_YANG (no_bgp_deterministic_med
,
2779 no_bgp_deterministic_med_cmd
,
2780 "no bgp deterministic-med",
2782 "BGP specific commands\n"
2783 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2785 nb_cli_enqueue_change(
2786 vty
, "./global/route-selection-options/deterministic-med",
2787 NB_OP_MODIFY
, "false");
2789 return nb_cli_apply_changes(vty
, NULL
);
2792 /* "bgp graceful-restart mode" configuration. */
2793 DEFUN (bgp_graceful_restart
,
2794 bgp_graceful_restart_cmd
,
2795 "bgp graceful-restart",
2796 "BGP specific commands\n"
2800 int ret
= BGP_GR_FAILURE
;
2802 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2803 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2807 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2809 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2812 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2813 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2815 "Graceful restart configuration changed, reset all peers to take effect\n");
2816 return bgp_vty_return(vty
, ret
);
2819 DEFUN (no_bgp_graceful_restart
,
2820 no_bgp_graceful_restart_cmd
,
2821 "no bgp graceful-restart",
2823 "BGP specific commands\n"
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2829 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2830 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2832 int ret
= BGP_GR_FAILURE
;
2834 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2836 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2839 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2840 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2842 "Graceful restart configuration changed, reset all peers to take effect\n");
2844 return bgp_vty_return(vty
, ret
);
2847 DEFUN (bgp_graceful_restart_stalepath_time
,
2848 bgp_graceful_restart_stalepath_time_cmd
,
2849 "bgp graceful-restart stalepath-time (1-4095)",
2850 "BGP specific commands\n"
2851 "Graceful restart capability parameters\n"
2852 "Set the max time to hold onto restarting peer's stale paths\n"
2853 "Delay value (seconds)\n")
2855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2859 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2860 bgp
->stalepath_time
= stalepath
;
2864 DEFUN (bgp_graceful_restart_restart_time
,
2865 bgp_graceful_restart_restart_time_cmd
,
2866 "bgp graceful-restart restart-time (1-4095)",
2867 "BGP specific commands\n"
2868 "Graceful restart capability parameters\n"
2869 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2870 "Delay value (seconds)\n")
2872 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2876 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2877 bgp
->restart_time
= restart
;
2881 DEFUN (bgp_graceful_restart_select_defer_time
,
2882 bgp_graceful_restart_select_defer_time_cmd
,
2883 "bgp graceful-restart select-defer-time (0-3600)",
2884 "BGP specific commands\n"
2885 "Graceful restart capability parameters\n"
2886 "Set the time to defer the BGP route selection after restart\n"
2887 "Delay value (seconds, 0 - disable)\n")
2889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2891 uint32_t defer_time
;
2893 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2894 bgp
->select_defer_time
= defer_time
;
2895 if (defer_time
== 0)
2896 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2898 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2903 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2904 no_bgp_graceful_restart_stalepath_time_cmd
,
2905 "no bgp graceful-restart stalepath-time [(1-4095)]",
2907 "BGP specific commands\n"
2908 "Graceful restart capability parameters\n"
2909 "Set the max time to hold onto restarting peer's stale paths\n"
2910 "Delay value (seconds)\n")
2912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2914 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2918 DEFUN (no_bgp_graceful_restart_restart_time
,
2919 no_bgp_graceful_restart_restart_time_cmd
,
2920 "no bgp graceful-restart restart-time [(1-4095)]",
2922 "BGP specific commands\n"
2923 "Graceful restart capability parameters\n"
2924 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2925 "Delay value (seconds)\n")
2927 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2929 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2933 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2934 no_bgp_graceful_restart_select_defer_time_cmd
,
2935 "no bgp graceful-restart select-defer-time [(0-3600)]",
2937 "BGP specific commands\n"
2938 "Graceful restart capability parameters\n"
2939 "Set the time to defer the BGP route selection after restart\n"
2940 "Delay value (seconds)\n")
2942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2944 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2945 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2950 DEFUN (bgp_graceful_restart_preserve_fw
,
2951 bgp_graceful_restart_preserve_fw_cmd
,
2952 "bgp graceful-restart preserve-fw-state",
2953 "BGP specific commands\n"
2954 "Graceful restart capability parameters\n"
2955 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2958 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2962 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2963 no_bgp_graceful_restart_preserve_fw_cmd
,
2964 "no bgp graceful-restart preserve-fw-state",
2966 "BGP specific commands\n"
2967 "Graceful restart capability parameters\n"
2968 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2970 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2971 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2975 DEFUN (bgp_graceful_restart_disable
,
2976 bgp_graceful_restart_disable_cmd
,
2977 "bgp graceful-restart-disable",
2978 "BGP specific commands\n"
2981 int ret
= BGP_GR_FAILURE
;
2983 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2985 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2989 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2991 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2994 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2996 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2998 "Graceful restart configuration changed, reset all peers to take effect\n");
3000 return bgp_vty_return(vty
, ret
);
3003 DEFUN (no_bgp_graceful_restart_disable
,
3004 no_bgp_graceful_restart_disable_cmd
,
3005 "no bgp graceful-restart-disable",
3007 "BGP specific commands\n"
3011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3013 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3015 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3017 int ret
= BGP_GR_FAILURE
;
3019 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3021 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3024 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3026 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3028 "Graceful restart configuration changed, reset all peers to take effect\n");
3030 return bgp_vty_return(vty
, ret
);
3033 DEFUN (bgp_neighbor_graceful_restart_set
,
3034 bgp_neighbor_graceful_restart_set_cmd
,
3035 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3043 int ret
= BGP_GR_FAILURE
;
3045 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3047 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3049 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3051 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3053 return CMD_WARNING_CONFIG_FAILED
;
3055 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3057 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3058 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3060 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3062 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3064 "Graceful restart configuration changed, reset this peer to take effect\n");
3066 return bgp_vty_return(vty
, ret
);
3069 DEFUN (no_bgp_neighbor_graceful_restart
,
3070 no_bgp_neighbor_graceful_restart_set_cmd
,
3071 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3079 int ret
= BGP_GR_FAILURE
;
3082 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3084 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3086 return CMD_WARNING_CONFIG_FAILED
;
3088 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3090 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3092 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3094 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3095 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3097 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3099 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3101 "Graceful restart configuration changed, reset this peer to take effect\n");
3103 return bgp_vty_return(vty
, ret
);
3106 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3107 bgp_neighbor_graceful_restart_helper_set_cmd
,
3108 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3111 GR_NEIGHBOR_HELPER_CMD
3116 int ret
= BGP_GR_FAILURE
;
3118 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3120 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3122 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3124 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3127 return CMD_WARNING_CONFIG_FAILED
;
3130 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3132 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3133 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3135 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3137 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3139 "Graceful restart configuration changed, reset this peer to take effect\n");
3141 return bgp_vty_return(vty
, ret
);
3144 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3145 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3146 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3150 NO_GR_NEIGHBOR_HELPER_CMD
3154 int ret
= BGP_GR_FAILURE
;
3157 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3159 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3161 return CMD_WARNING_CONFIG_FAILED
;
3163 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3165 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3167 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3169 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3170 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3172 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3174 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3176 "Graceful restart configuration changed, reset this peer to take effect\n");
3178 return bgp_vty_return(vty
, ret
);
3181 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3182 bgp_neighbor_graceful_restart_disable_set_cmd
,
3183 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3186 GR_NEIGHBOR_DISABLE_CMD
3191 int ret
= BGP_GR_FAILURE
;
3193 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3195 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3197 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3199 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3201 return CMD_WARNING_CONFIG_FAILED
;
3203 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3205 if (peer
->bgp
->t_startup
)
3206 bgp_peer_gr_flags_update(peer
);
3208 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3209 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3211 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3213 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3215 "Graceful restart configuration changed, reset this peer to take effect\n");
3217 return bgp_vty_return(vty
, ret
);
3220 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3221 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3222 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3226 NO_GR_NEIGHBOR_DISABLE_CMD
3230 int ret
= BGP_GR_FAILURE
;
3233 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3235 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3237 return CMD_WARNING_CONFIG_FAILED
;
3239 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3241 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3243 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3245 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3246 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3248 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3250 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3252 "Graceful restart configuration changed, reset this peer to take effect\n");
3254 return bgp_vty_return(vty
, ret
);
3257 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3258 bgp_graceful_restart_disable_eor_cmd
,
3259 "bgp graceful-restart disable-eor",
3260 "BGP specific commands\n"
3261 "Graceful restart configuration parameters\n"
3262 "Disable EOR Check\n")
3264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3265 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3270 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3271 no_bgp_graceful_restart_disable_eor_cmd
,
3272 "no bgp graceful-restart disable-eor",
3274 "BGP specific commands\n"
3275 "Graceful restart configuration parameters\n"
3276 "Disable EOR Check\n")
3278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3279 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3284 DEFUN (bgp_graceful_restart_rib_stale_time
,
3285 bgp_graceful_restart_rib_stale_time_cmd
,
3286 "bgp graceful-restart rib-stale-time (1-3600)",
3287 "BGP specific commands\n"
3288 "Graceful restart configuration parameters\n"
3289 "Specify the stale route removal timer in rib\n"
3290 "Delay value (seconds)\n")
3292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3294 uint32_t stale_time
;
3296 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3297 bgp
->rib_stale_time
= stale_time
;
3298 /* Send the stale timer update message to RIB */
3299 if (bgp_zebra_stale_timer_update(bgp
))
3305 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3306 no_bgp_graceful_restart_rib_stale_time_cmd
,
3307 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3309 "BGP specific commands\n"
3310 "Graceful restart configuration parameters\n"
3311 "Specify the stale route removal timer in rib\n"
3312 "Delay value (seconds)\n")
3314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3316 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3317 /* Send the stale timer update message to RIB */
3318 if (bgp_zebra_stale_timer_update(bgp
))
3324 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3328 bgp_static_redo_import_check(bgp
);
3329 bgp_redistribute_redo(bgp
);
3330 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3332 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3338 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3340 struct listnode
*node
, *nnode
;
3342 bool vrf_cfg
= false;
3343 char errmsg
[BUFSIZ
] = {'\0'};
3345 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3348 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3349 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3350 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3352 "%% graceful-shutdown configuration found in vrf %s\n",
3353 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3354 VRF_DEFAULT_NAME
: bgp
->name
);
3361 "%%Failed: global graceful-shutdown not permitted\n");
3365 /* Set flag globally */
3366 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3368 /* Initiate processing for all BGP instances. */
3369 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3370 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3374 vty_out(vty
, "%s\n", errmsg
);
3380 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3382 struct listnode
*node
, *nnode
;
3384 char errmsg
[BUFSIZ
] = {'\0'};
3386 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3389 /* Unset flag globally */
3390 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3392 /* Initiate processing for all BGP instances. */
3393 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3394 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3398 vty_out(vty
, "%s\n", errmsg
);
3404 /* "bgp graceful-shutdown" configuration */
3405 DEFUN (bgp_graceful_shutdown
,
3406 bgp_graceful_shutdown_cmd
,
3407 "bgp graceful-shutdown",
3409 "Graceful shutdown parameters\n")
3411 if (vty
->node
== CONFIG_NODE
)
3412 return bgp_global_graceful_shutdown_config_vty(vty
);
3414 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3415 NB_OP_MODIFY
, "true");
3417 return nb_cli_apply_changes(vty
, NULL
);
3420 DEFUN_YANG (no_bgp_graceful_shutdown
,
3421 no_bgp_graceful_shutdown_cmd
,
3422 "no bgp graceful-shutdown",
3425 "Graceful shutdown parameters\n")
3427 if (vty
->node
== CONFIG_NODE
)
3428 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3430 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3431 NB_OP_MODIFY
, "false");
3433 return nb_cli_apply_changes(vty
, NULL
);
3436 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3437 struct lyd_node
*dnode
,
3440 if (yang_dnode_get_bool(dnode
, NULL
))
3441 vty_out(vty
, " bgp graceful-shutdown\n");
3444 /* "bgp fast-external-failover" configuration. */
3445 DEFUN_YANG (bgp_fast_external_failover
,
3446 bgp_fast_external_failover_cmd
,
3447 "bgp fast-external-failover",
3449 "Immediately reset session if a link to a directly connected external peer goes down\n")
3451 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3452 NB_OP_MODIFY
, "false");
3454 return nb_cli_apply_changes(vty
, NULL
);
3457 DEFUN_YANG (no_bgp_fast_external_failover
,
3458 no_bgp_fast_external_failover_cmd
,
3459 "no bgp fast-external-failover",
3462 "Immediately reset session if a link to a directly connected external peer goes down\n")
3464 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3465 NB_OP_MODIFY
, "true");
3467 return nb_cli_apply_changes(vty
, NULL
);
3470 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3471 struct lyd_node
*dnode
,
3474 if (!yang_dnode_get_bool(dnode
, NULL
))
3475 vty_out(vty
, " no bgp fast-external-failover\n");
3478 /* "bgp bestpath compare-routerid" configuration. */
3479 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3480 bgp_bestpath_compare_router_id_cmd
,
3481 "bgp bestpath compare-routerid",
3482 "BGP specific commands\n"
3483 "Change the default bestpath selection\n"
3484 "Compare router-id for identical EBGP paths\n")
3486 nb_cli_enqueue_change(
3488 "./global/route-selection-options/external-compare-router-id",
3489 NB_OP_MODIFY
, "true");
3491 return nb_cli_apply_changes(vty
, NULL
);
3494 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3495 no_bgp_bestpath_compare_router_id_cmd
,
3496 "no bgp bestpath compare-routerid",
3498 "BGP specific commands\n"
3499 "Change the default bestpath selection\n"
3500 "Compare router-id for identical EBGP paths\n")
3502 nb_cli_enqueue_change(
3504 "./global/route-selection-options/external-compare-router-id",
3505 NB_OP_MODIFY
, "false");
3507 return nb_cli_apply_changes(vty
, NULL
);
3510 /* "bgp bestpath as-path ignore" configuration. */
3511 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3512 bgp_bestpath_aspath_ignore_cmd
,
3513 "bgp bestpath as-path ignore",
3514 "BGP specific commands\n"
3515 "Change the default bestpath selection\n"
3516 "AS-path attribute\n"
3517 "Ignore as-path length in selecting a route\n")
3519 nb_cli_enqueue_change(
3520 vty
, "./global/route-selection-options/ignore-as-path-length",
3521 NB_OP_MODIFY
, "true");
3523 return nb_cli_apply_changes(vty
, NULL
);
3526 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3527 no_bgp_bestpath_aspath_ignore_cmd
,
3528 "no bgp bestpath as-path ignore",
3530 "BGP specific commands\n"
3531 "Change the default bestpath selection\n"
3532 "AS-path attribute\n"
3533 "Ignore as-path length in selecting a route\n")
3535 nb_cli_enqueue_change(
3536 vty
, "./global/route-selection-options/ignore-as-path-length",
3537 NB_OP_MODIFY
, "false");
3539 return nb_cli_apply_changes(vty
, NULL
);
3542 /* "bgp bestpath as-path confed" configuration. */
3543 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3544 bgp_bestpath_aspath_confed_cmd
,
3545 "bgp bestpath as-path confed",
3546 "BGP specific commands\n"
3547 "Change the default bestpath selection\n"
3548 "AS-path attribute\n"
3549 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3551 nb_cli_enqueue_change(vty
,
3552 "./global/route-selection-options/aspath-confed",
3553 NB_OP_MODIFY
, "true");
3555 return nb_cli_apply_changes(vty
, NULL
);
3558 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3559 no_bgp_bestpath_aspath_confed_cmd
,
3560 "no bgp bestpath as-path confed",
3562 "BGP specific commands\n"
3563 "Change the default bestpath selection\n"
3564 "AS-path attribute\n"
3565 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3567 nb_cli_enqueue_change(vty
,
3568 "./global/route-selection-options/aspath-confed",
3569 NB_OP_MODIFY
, "false");
3571 return nb_cli_apply_changes(vty
, NULL
);
3574 /* "bgp bestpath as-path multipath-relax" configuration. */
3575 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3576 bgp_bestpath_aspath_multipath_relax_cmd
,
3577 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3578 "BGP specific commands\n"
3579 "Change the default bestpath selection\n"
3580 "AS-path attribute\n"
3581 "Allow load sharing across routes that have different AS paths (but same length)\n"
3582 "Generate an AS_SET\n"
3583 "Do not generate an AS_SET\n")
3587 nb_cli_enqueue_change(
3588 vty
, "./global/route-selection-options/allow-multiple-as",
3589 NB_OP_MODIFY
, "true");
3590 if (argv_find(argv
, argc
, "as-set", &idx
))
3591 nb_cli_enqueue_change(
3593 "./global/route-selection-options/multi-path-as-set",
3594 NB_OP_MODIFY
, "true");
3596 nb_cli_enqueue_change(
3598 "./global/route-selection-options/multi-path-as-set",
3599 NB_OP_MODIFY
, "false");
3601 return nb_cli_apply_changes(vty
, NULL
);
3604 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3605 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3606 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3608 "BGP specific commands\n"
3609 "Change the default bestpath selection\n"
3610 "AS-path attribute\n"
3611 "Allow load sharing across routes that have different AS paths (but same length)\n"
3612 "Generate an AS_SET\n"
3613 "Do not generate an AS_SET\n")
3615 nb_cli_enqueue_change(
3616 vty
, "./global/route-selection-options/allow-multiple-as",
3617 NB_OP_MODIFY
, "false");
3618 nb_cli_enqueue_change(
3619 vty
, "./global/route-selection-options/multi-path-as-set",
3620 NB_OP_MODIFY
, "false");
3622 return nb_cli_apply_changes(vty
, NULL
);
3625 /* "bgp bestpath peer-type multipath-relax" configuration. */
3626 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3627 bgp_bestpath_peer_type_multipath_relax_cmd
,
3628 "bgp bestpath peer-type multipath-relax",
3630 "Change the default bestpath selection\n"
3632 "Allow load sharing across routes learned from different peer types\n")
3634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3635 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3636 bgp_recalculate_all_bestpaths(bgp
);
3641 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3642 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3643 "no bgp bestpath peer-type multipath-relax",
3645 "Change the default bestpath selection\n"
3647 "Allow load sharing across routes learned from different peer types\n")
3649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3650 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3651 bgp_recalculate_all_bestpaths(bgp
);
3656 /* "bgp log-neighbor-changes" configuration. */
3657 DEFUN_YANG(bgp_log_neighbor_changes
,
3658 bgp_log_neighbor_changes_cmd
,
3659 "bgp log-neighbor-changes",
3660 "BGP specific commands\n"
3661 "Log neighbor up/down and reset reason\n")
3663 nb_cli_enqueue_change(
3664 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3665 NB_OP_MODIFY
, "true");
3667 return nb_cli_apply_changes(vty
, NULL
);
3670 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3671 no_bgp_log_neighbor_changes_cmd
,
3672 "no bgp log-neighbor-changes",
3674 "BGP specific commands\n"
3675 "Log neighbor up/down and reset reason\n")
3677 nb_cli_enqueue_change(
3678 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3679 NB_OP_MODIFY
, "false");
3681 return nb_cli_apply_changes(vty
, NULL
);
3684 /* "bgp bestpath med" configuration. */
3685 DEFUN_YANG (bgp_bestpath_med
,
3686 bgp_bestpath_med_cmd
,
3687 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3688 "BGP specific commands\n"
3689 "Change the default bestpath selection\n"
3691 "Compare MED among confederation paths\n"
3692 "Treat missing MED as the least preferred one\n"
3693 "Treat missing MED as the least preferred one\n"
3694 "Compare MED among confederation paths\n")
3697 bool confed
= false;
3698 bool worst_med
= false;
3701 if (argv_find(argv
, argc
, "confed", &idx
))
3704 nb_cli_enqueue_change(vty
,
3705 "./global/route-selection-options/confed-med",
3706 NB_OP_MODIFY
, confed
? "true" : "false");
3709 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3712 nb_cli_enqueue_change(
3713 vty
, "./global/route-selection-options/missing-as-worst-med",
3714 NB_OP_MODIFY
, worst_med
? "true" : "false");
3716 return nb_cli_apply_changes(vty
, NULL
);
3719 DEFUN_YANG (no_bgp_bestpath_med
,
3720 no_bgp_bestpath_med_cmd
,
3721 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3723 "BGP specific commands\n"
3724 "Change the default bestpath selection\n"
3726 "Compare MED among confederation paths\n"
3727 "Treat missing MED as the least preferred one\n"
3728 "Treat missing MED as the least preferred one\n"
3729 "Compare MED among confederation paths\n")
3733 if (argv_find(argv
, argc
, "confed", &idx
))
3734 nb_cli_enqueue_change(
3735 vty
, "./global/route-selection-options/confed-med",
3736 NB_OP_MODIFY
, "false");
3739 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3740 nb_cli_enqueue_change(
3742 "./global/route-selection-options/missing-as-worst-med",
3743 NB_OP_MODIFY
, "false");
3745 return nb_cli_apply_changes(vty
, NULL
);
3748 /* "bgp bestpath bandwidth" configuration. */
3749 DEFPY (bgp_bestpath_bw
,
3750 bgp_bestpath_bw_cmd
,
3751 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3752 "BGP specific commands\n"
3753 "Change the default bestpath selection\n"
3754 "Link Bandwidth attribute\n"
3755 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3756 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3757 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3759 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3764 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3765 return CMD_ERR_INCOMPLETE
;
3767 if (!strcmp(bw_cfg
, "ignore"))
3768 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3769 else if (!strcmp(bw_cfg
, "skip-missing"))
3770 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3771 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3772 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3774 return CMD_ERR_NO_MATCH
;
3776 /* This config is used in route install, so redo that. */
3777 FOREACH_AFI_SAFI (afi
, safi
) {
3778 if (!bgp_fibupd_safi(safi
))
3780 bgp_zebra_announce_table(bgp
, afi
, safi
);
3786 DEFPY (no_bgp_bestpath_bw
,
3787 no_bgp_bestpath_bw_cmd
,
3788 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3790 "BGP specific commands\n"
3791 "Change the default bestpath selection\n"
3792 "Link Bandwidth attribute\n"
3793 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3794 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3795 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3801 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3803 /* This config is used in route install, so redo that. */
3804 FOREACH_AFI_SAFI (afi
, safi
) {
3805 if (!bgp_fibupd_safi(safi
))
3807 bgp_zebra_announce_table(bgp
, afi
, safi
);
3812 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3813 "[no] bgp default <ipv4-unicast|"
3816 "ipv4-labeled-unicast|"
3821 "ipv6-labeled-unicast|"
3823 "l2vpn-evpn>$afi_safi",
3825 "BGP specific commands\n"
3826 "Configure BGP defaults\n"
3827 "Activate ipv4-unicast for a peer by default\n"
3828 "Activate ipv4-multicast for a peer by default\n"
3829 "Activate ipv4-vpn for a peer by default\n"
3830 "Activate ipv4-labeled-unicast for a peer by default\n"
3831 "Activate ipv4-flowspec for a peer by default\n"
3832 "Activate ipv6-unicast for a peer by default\n"
3833 "Activate ipv6-multicast for a peer by default\n"
3834 "Activate ipv6-vpn for a peer by default\n"
3835 "Activate ipv6-labeled-unicast for a peer by default\n"
3836 "Activate ipv6-flowspec for a peer by default\n"
3837 "Activate l2vpn-evpn for a peer by default\n")
3839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3840 char afi_safi_str
[strlen(afi_safi
) + 1];
3841 char *afi_safi_str_tok
;
3843 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3844 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3845 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3846 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3849 if (strmatch(safi_str
, "labeled"))
3850 safi
= bgp_vty_safi_from_str("labeled-unicast");
3852 safi
= bgp_vty_safi_from_str(safi_str
);
3855 bgp
->default_af
[afi
][safi
] = false;
3857 if ((safi
== SAFI_LABELED_UNICAST
3858 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3859 || (safi
== SAFI_UNICAST
3860 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3861 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3863 bgp
->default_af
[afi
][safi
] = true;
3869 /* Display hostname in certain command outputs */
3870 DEFUN_YANG (bgp_default_show_hostname
,
3871 bgp_default_show_hostname_cmd
,
3872 "bgp default show-hostname",
3873 "BGP specific commands\n"
3874 "Configure BGP defaults\n"
3875 "Show hostname in certain command outputs\n")
3877 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3880 return nb_cli_apply_changes(vty
, NULL
);
3883 DEFUN_YANG(no_bgp_default_show_hostname
,
3884 no_bgp_default_show_hostname_cmd
,
3885 "no bgp default show-hostname",
3887 "BGP specific commands\n"
3888 "Configure BGP defaults\n"
3889 "Show hostname in certain command outputs\n")
3891 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3894 return nb_cli_apply_changes(vty
, NULL
);
3897 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3900 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3901 vty_out(vty
, " bgp default show-hostname\n");
3904 /* Display hostname in certain command outputs */
3905 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3906 bgp_default_show_nexthop_hostname_cmd
,
3907 "bgp default show-nexthop-hostname",
3908 "BGP specific commands\n"
3909 "Configure BGP defaults\n"
3910 "Show hostname for nexthop in certain command outputs\n")
3912 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3913 NB_OP_MODIFY
, "true");
3915 return nb_cli_apply_changes(vty
, NULL
);
3918 DEFUN (no_bgp_default_show_nexthop_hostname
,
3919 no_bgp_default_show_nexthop_hostname_cmd
,
3920 "no bgp default show-nexthop-hostname",
3922 "BGP specific commands\n"
3923 "Configure BGP defaults\n"
3924 "Show hostname for nexthop in certain command outputs\n")
3926 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3927 NB_OP_MODIFY
, "false");
3929 return nb_cli_apply_changes(vty
, NULL
);
3932 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3933 struct lyd_node
*dnode
,
3936 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3937 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3940 /* "bgp network import-check" configuration. */
3941 DEFUN_YANG(bgp_network_import_check
,
3942 bgp_network_import_check_cmd
,
3943 "bgp network import-check",
3944 "BGP specific commands\n"
3945 "BGP network command\n"
3946 "Check BGP network route exists in IGP\n")
3948 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3951 return nb_cli_apply_changes(vty
, NULL
);
3954 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3955 "bgp network import-check exact",
3956 "BGP specific commands\n"
3957 "BGP network command\n"
3958 "Check BGP network route exists in IGP\n"
3959 "Match route precisely\n")
3961 DEFUN_YANG(no_bgp_network_import_check
,
3962 no_bgp_network_import_check_cmd
,
3963 "no bgp network import-check",
3965 "BGP specific commands\n"
3966 "BGP network command\n"
3967 "Check BGP network route exists in IGP\n")
3969 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3972 return nb_cli_apply_changes(vty
, NULL
);
3975 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3978 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3979 vty_out(vty
, " bgp network import-check\n");
3982 DEFUN_YANG(bgp_default_local_preference
,
3983 bgp_default_local_preference_cmd
,
3984 "bgp default local-preference (0-4294967295)",
3985 "BGP specific commands\n"
3986 "Configure BGP defaults\n"
3987 "local preference (higher=more preferred)\n"
3988 "Configure default local preference value\n")
3992 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3993 argv
[idx_number
]->arg
);
3995 return nb_cli_apply_changes(vty
, NULL
);
3998 DEFUN_YANG(no_bgp_default_local_preference
,
3999 no_bgp_default_local_preference_cmd
,
4000 "no bgp default local-preference [(0-4294967295)]",
4002 "BGP specific commands\n"
4003 "Configure BGP defaults\n"
4004 "local preference (higher=more preferred)\n"
4005 "Configure default local preference value\n")
4007 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
4009 return nb_cli_apply_changes(vty
, NULL
);
4012 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
4015 vty_out(vty
, " bgp default local-preference %u\n",
4016 yang_dnode_get_uint32(dnode
, NULL
));
4020 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
4021 bgp_default_subgroup_pkt_queue_max_cmd
,
4022 "bgp default subgroup-pkt-queue-max (20-100)",
4023 "BGP specific commands\n"
4024 "Configure BGP defaults\n"
4025 "subgroup-pkt-queue-max\n"
4026 "Configure subgroup packet queue max\n")
4030 nb_cli_enqueue_change(
4032 "./global/global-update-group-config/subgroup-pkt-queue-size",
4033 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4035 return nb_cli_apply_changes(vty
, NULL
);
4038 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
4039 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4040 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4042 "BGP specific commands\n"
4043 "Configure BGP defaults\n"
4044 "subgroup-pkt-queue-max\n"
4045 "Configure subgroup packet queue max\n")
4047 nb_cli_enqueue_change(
4049 "./global/global-update-group-config/subgroup-pkt-queue-size",
4050 NB_OP_MODIFY
, NULL
);
4052 return nb_cli_apply_changes(vty
, NULL
);
4055 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
4056 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4058 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
4059 yang_dnode_get_uint32(dnode
, NULL
));
4062 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
4063 bgp_rr_allow_outbound_policy_cmd
,
4064 "bgp route-reflector allow-outbound-policy",
4065 "BGP specific commands\n"
4066 "Allow modifications made by out route-map\n"
4067 "on ibgp neighbors\n")
4069 nb_cli_enqueue_change(vty
,
4070 "./global/route-reflector/allow-outbound-policy",
4071 NB_OP_MODIFY
, "true");
4073 return nb_cli_apply_changes(vty
, NULL
);
4076 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
4077 no_bgp_rr_allow_outbound_policy_cmd
,
4078 "no bgp route-reflector allow-outbound-policy",
4080 "BGP specific commands\n"
4081 "Allow modifications made by out route-map\n"
4082 "on ibgp neighbors\n")
4084 nb_cli_enqueue_change(vty
,
4085 "./global/route-reflector/allow-outbound-policy",
4086 NB_OP_MODIFY
, "false");
4088 return nb_cli_apply_changes(vty
, NULL
);
4092 void cli_show_router_global_neighbor_config(struct vty
*vty
,
4093 struct lyd_node
*dnode
,
4096 uint32_t write_quanta
, read_quanta
;
4098 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
4099 vty_out(vty
, " bgp log-neighbor-changes\n");
4101 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
4102 uint32_t listen_limit
= yang_dnode_get_uint32(
4103 dnode
, "./dynamic-neighbors-limit");
4104 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
4107 write_quanta
= yang_dnode_get_uint32(
4108 dnode
, "./packet-quanta-config/wpkt-quanta");
4109 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
4110 vty_out(vty
, " write-quanta %d\n", write_quanta
);
4112 read_quanta
= yang_dnode_get_uint32(
4113 dnode
, "./packet-quanta-config/rpkt-quanta");
4115 if (read_quanta
!= BGP_READ_PACKET_MAX
)
4116 vty_out(vty
, " read-quanta %d\n", read_quanta
);
4119 DEFUN_YANG(bgp_listen_limit
,
4120 bgp_listen_limit_cmd
,
4121 "bgp listen limit (1-65535)",
4122 "BGP specific commands\n"
4123 "BGP Dynamic Neighbors listen commands\n"
4124 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4125 "Configure Dynamic Neighbors listen limit value\n")
4129 nb_cli_enqueue_change(
4130 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4131 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4133 return nb_cli_apply_changes(vty
, NULL
);
4136 DEFUN_YANG(no_bgp_listen_limit
,
4137 no_bgp_listen_limit_cmd
,
4138 "no bgp listen limit [(1-65535)]",
4140 "BGP specific commands\n"
4141 "BGP Dynamic Neighbors listen commands\n"
4142 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4143 "Configure Dynamic Neighbors listen limit value\n")
4145 nb_cli_enqueue_change(
4146 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4147 NB_OP_DESTROY
, NULL
);
4149 return nb_cli_apply_changes(vty
, NULL
);
4154 * Check if this listen range is already configured. Check for exact
4155 * match or overlap based on input.
4157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4158 struct prefix
*range
, int exact
)
4160 struct listnode
*node
, *nnode
;
4161 struct listnode
*node1
, *nnode1
;
4162 struct peer_group
*group
;
4167 afi
= family2afi(range
->family
);
4168 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4169 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4172 match
= prefix_same(range
, lr
);
4174 match
= (prefix_match(range
, lr
)
4175 || prefix_match(lr
, range
));
4184 DEFUN (bgp_listen_range
,
4185 bgp_listen_range_cmd
,
4186 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4187 "BGP specific commands\n"
4188 "Configure BGP dynamic neighbors listen range\n"
4189 "Configure BGP dynamic neighbors listen range\n"
4191 "Member of the peer-group\n"
4192 "Peer-group name\n")
4194 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4195 struct prefix range
;
4196 struct peer_group
*group
, *existing_group
;
4201 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4202 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4203 char *prefix
= argv
[idx
]->arg
;
4204 argv_find(argv
, argc
, "PGNAME", &idx
);
4205 char *peergroup
= argv
[idx
]->arg
;
4207 /* Convert IP prefix string to struct prefix. */
4208 ret
= str2prefix(prefix
, &range
);
4210 vty_out(vty
, "%% Malformed listen range\n");
4211 return CMD_WARNING_CONFIG_FAILED
;
4214 afi
= family2afi(range
.family
);
4216 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4218 "%% Malformed listen range (link-local address)\n");
4219 return CMD_WARNING_CONFIG_FAILED
;
4224 /* Check if same listen range is already configured. */
4225 existing_group
= listen_range_exists(bgp
, &range
, 1);
4226 if (existing_group
) {
4227 if (strcmp(existing_group
->name
, peergroup
) == 0)
4231 "%% Same listen range is attached to peer-group %s\n",
4232 existing_group
->name
);
4233 return CMD_WARNING_CONFIG_FAILED
;
4237 /* Check if an overlapping listen range exists. */
4238 if (listen_range_exists(bgp
, &range
, 0)) {
4240 "%% Listen range overlaps with existing listen range\n");
4241 return CMD_WARNING_CONFIG_FAILED
;
4244 group
= peer_group_lookup(bgp
, peergroup
);
4246 vty_out(vty
, "%% Configure the peer-group first\n");
4247 return CMD_WARNING_CONFIG_FAILED
;
4250 ret
= peer_group_listen_range_add(group
, &range
);
4251 return bgp_vty_return(vty
, ret
);
4254 DEFUN (no_bgp_listen_range
,
4255 no_bgp_listen_range_cmd
,
4256 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4258 "BGP specific commands\n"
4259 "Unconfigure BGP dynamic neighbors listen range\n"
4260 "Unconfigure BGP dynamic neighbors listen range\n"
4262 "Member of the peer-group\n"
4263 "Peer-group name\n")
4265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4266 struct prefix range
;
4267 struct peer_group
*group
;
4272 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4273 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4274 char *prefix
= argv
[idx
]->arg
;
4275 argv_find(argv
, argc
, "PGNAME", &idx
);
4276 char *peergroup
= argv
[idx
]->arg
;
4278 /* Convert IP prefix string to struct prefix. */
4279 ret
= str2prefix(prefix
, &range
);
4281 vty_out(vty
, "%% Malformed listen range\n");
4282 return CMD_WARNING_CONFIG_FAILED
;
4285 afi
= family2afi(range
.family
);
4287 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4289 "%% Malformed listen range (link-local address)\n");
4290 return CMD_WARNING_CONFIG_FAILED
;
4295 group
= peer_group_lookup(bgp
, peergroup
);
4297 vty_out(vty
, "%% Peer-group does not exist\n");
4298 return CMD_WARNING_CONFIG_FAILED
;
4301 ret
= peer_group_listen_range_del(group
, &range
);
4302 return bgp_vty_return(vty
, ret
);
4305 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4307 struct peer_group
*group
;
4308 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4309 struct prefix
*range
;
4312 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4313 vty_out(vty
, " bgp listen limit %d\n",
4314 bgp
->dynamic_neighbors_limit
);
4316 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4317 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4318 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4321 " bgp listen range %pFX peer-group %s\n",
4322 range
, group
->name
);
4329 DEFUN_YANG(bgp_disable_connected_route_check
,
4330 bgp_disable_connected_route_check_cmd
,
4331 "bgp disable-ebgp-connected-route-check",
4332 "BGP specific commands\n"
4333 "Disable checking if nexthop is connected on ebgp sessions\n")
4335 nb_cli_enqueue_change(vty
,
4336 "./global/ebgp-multihop-connected-route-check",
4337 NB_OP_MODIFY
, "true");
4339 return nb_cli_apply_changes(vty
, NULL
);
4342 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4343 no_bgp_disable_connected_route_check_cmd
,
4344 "no bgp disable-ebgp-connected-route-check",
4346 "BGP specific commands\n"
4347 "Disable checking if nexthop is connected on ebgp sessions\n")
4349 nb_cli_enqueue_change(vty
,
4350 "./global/ebgp-multihop-connected-route-check",
4351 NB_OP_MODIFY
, "false");
4353 return nb_cli_apply_changes(vty
, NULL
);
4356 void cli_show_router_global_ebgp_multihop_connected_route_check(
4357 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4359 if (yang_dnode_get_bool(dnode
, NULL
))
4360 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4363 DEFUN_YANG(bgp_default_shutdown
,
4364 bgp_default_shutdown_cmd
,
4365 "[no] bgp default shutdown",
4367 "Configure BGP defaults\n"
4368 "Apply administrative shutdown to newly configured peers\n")
4370 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4371 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4373 return nb_cli_apply_changes(vty
, NULL
);
4376 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4377 struct lyd_node
*dnode
,
4380 if (yang_dnode_get_bool(dnode
, NULL
))
4381 vty_out(vty
, " bgp default shutdown\n");
4384 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4386 "Administrative shutdown of the BGP instance\n"
4387 "Add a shutdown message (RFC 8203)\n"
4388 "Shutdown message\n")
4390 char *msgstr
= NULL
;
4392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4395 msgstr
= argv_concat(argv
, argc
, 3);
4397 bgp_shutdown_enable(bgp
, msgstr
);
4398 XFREE(MTYPE_TMP
, msgstr
);
4403 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4404 BGP_STR
"Administrative shutdown of the BGP instance\n")
4406 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4408 bgp_shutdown_enable(bgp
, NULL
);
4413 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4414 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4418 bgp_shutdown_disable(bgp
);
4423 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4424 "no bgp shutdown message MSG...", NO_STR BGP_STR
4425 "Administrative shutdown of the BGP instance\n"
4426 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4428 DEFUN_YANG(neighbor_remote_as
,
4429 neighbor_remote_as_cmd
,
4430 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4431 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4432 "Specify a BGP neighbor\n" AS_STR
4433 "Internal BGP peer\n"
4434 "External BGP peer\n")
4437 int idx_remote_as
= 3;
4438 char base_xpath
[XPATH_MAXLEN
];
4439 char unnbr_xpath
[XPATH_MAXLEN
];
4440 char prgrp_xpath
[XPATH_MAXLEN
];
4442 const char *as_type_str
= "as-specified";
4444 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4445 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4446 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4448 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4449 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4451 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4452 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4453 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4454 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
4455 "%s%s", VTY_CURR_XPATH
,
4457 snprintf(base_xpath
, sizeof(base_xpath
),
4458 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4462 "%% Create the peer-group or interface first\n");
4463 return CMD_WARNING_CONFIG_FAILED
;
4466 snprintf(base_xpath
, sizeof(base_xpath
),
4467 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4470 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4471 as_type_str
= "internal";
4472 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4473 as_type_str
= "external";
4475 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4476 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4478 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4479 NB_OP_MODIFY
, as_type_str
);
4481 return nb_cli_apply_changes(vty
, base_xpath
);
4484 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
,
4485 bool v6only
, const char *peer_group_name
,
4486 int as_type
, as_t as
, char *errmsg
,
4490 struct peer_group
*group
;
4493 group
= peer_group_lookup(bgp
, conf_if
);
4496 snprintf(errmsg
, errmsg_len
,
4497 "Name conflict with peer-group \n");
4501 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4503 if (as_type
!= AS_UNSPECIFIED
)
4504 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4506 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4510 snprintf(errmsg
, errmsg_len
,
4511 "BGP failed to create peer\n");
4516 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4518 /* Request zebra to initiate IPv6 RAs on this interface. We do
4520 * any unnumbered peer in order to not worry about run-time
4522 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4524 * gets deleted later etc.)
4527 bgp_zebra_initiate_radv(bgp
, peer
);
4530 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4531 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4533 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4535 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4537 /* v6only flag changed. Reset bgp seesion */
4538 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4539 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4540 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4541 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4543 bgp_session_reset(peer
);
4546 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4547 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4548 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4549 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4552 if (peer_group_name
) {
4553 group
= peer_group_lookup(bgp
, peer_group_name
);
4555 snprintf(errmsg
, errmsg_len
,
4556 "Configure the peer-group first\n");
4560 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4563 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4566 DEFUN_YANG(neighbor_interface_config
,
4567 neighbor_interface_config_cmd
,
4568 "neighbor WORD interface [peer-group PGNAME]",
4570 "Interface name or neighbor tag\n"
4571 "Enable BGP on interface\n"
4572 "Member of the peer-group\n"
4573 "Peer-group name\n")
4576 int idx_peer_group_word
= 4;
4577 char base_xpath
[XPATH_MAXLEN
];
4579 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4580 argv
[idx_word
]->arg
, "");
4582 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4583 if (argc
> idx_peer_group_word
)
4584 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4585 argv
[idx_peer_group_word
]->arg
);
4587 return nb_cli_apply_changes(vty
, base_xpath
);
4590 DEFUN_YANG(neighbor_interface_config_v6only
,
4591 neighbor_interface_config_v6only_cmd
,
4592 "neighbor WORD interface v6only [peer-group PGNAME]",
4594 "Interface name or neighbor tag\n"
4595 "Enable BGP on interface\n"
4596 "Enable BGP with v6 link-local only\n"
4597 "Member of the peer-group\n"
4598 "Peer-group name\n")
4601 int idx_peer_group_word
= 5;
4602 char base_xpath
[XPATH_MAXLEN
];
4604 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4605 argv
[idx_word
]->arg
, "");
4607 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4608 if (argc
> idx_peer_group_word
)
4609 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4610 argv
[idx_peer_group_word
]->arg
);
4612 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4614 return nb_cli_apply_changes(vty
, base_xpath
);
4619 neighbor_interface_config_remote_as
,
4620 neighbor_interface_config_remote_as_cmd
,
4621 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4623 "Interface name or neighbor tag\n"
4624 "Enable BGP on interface\n"
4625 "Specify a BGP neighbor\n" AS_STR
4626 "Internal BGP peer\n"
4627 "External BGP peer\n")
4630 int idx_remote_as
= 4;
4631 char base_xpath
[XPATH_MAXLEN
];
4632 const char *as_type_str
= "as-specified";
4634 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4635 argv
[idx_word
]->arg
, "");
4637 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4639 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4640 as_type_str
= "internal";
4641 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4642 as_type_str
= "external";
4644 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4645 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4647 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4648 NB_OP_MODIFY
, as_type_str
);
4650 return nb_cli_apply_changes(vty
, base_xpath
);
4654 neighbor_interface_v6only_config_remote_as
,
4655 neighbor_interface_v6only_config_remote_as_cmd
,
4656 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4658 "Interface name or neighbor tag\n"
4659 "Enable BGP with v6 link-local only\n"
4660 "Enable BGP on interface\n"
4661 "Specify a BGP neighbor\n" AS_STR
4662 "Internal BGP peer\n"
4663 "External BGP peer\n")
4666 int idx_remote_as
= 5;
4667 char base_xpath
[XPATH_MAXLEN
];
4668 const char *as_type_str
= "as-specified";
4670 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4671 argv
[idx_word
]->arg
, "");
4673 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4675 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4677 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4678 as_type_str
= "internal";
4679 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4680 as_type_str
= "external";
4682 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4683 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4685 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4686 NB_OP_MODIFY
, as_type_str
);
4688 return nb_cli_apply_changes(vty
, base_xpath
);
4691 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4692 "neighbor WORD peer-group",
4694 "Interface name or neighbor tag\n"
4695 "Configure peer-group\n")
4697 char base_xpath
[XPATH_MAXLEN
];
4700 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4701 argv
[idx_word
]->arg
, "");
4703 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4705 return nb_cli_apply_changes(vty
, base_xpath
);
4708 DEFUN_YANG(no_neighbor
,
4710 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4713 "Specify a BGP neighbor\n" AS_STR
4714 "Internal BGP peer\n"
4715 "External BGP peer\n")
4718 char base_xpath
[XPATH_MAXLEN
];
4719 char num_xpath
[XPATH_MAXLEN
];
4720 char unnbr_xpath
[XPATH_MAXLEN
];
4721 char prgrp_xpath
[XPATH_MAXLEN
];
4724 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4725 snprintf(num_xpath
, sizeof(num_xpath
),
4726 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4727 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4728 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4729 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4732 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4733 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4735 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4736 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4738 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4739 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4740 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4741 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
4742 "%s%s", VTY_CURR_XPATH
,
4744 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4747 "%% Create the peer-group or interface first\n");
4748 return CMD_WARNING_CONFIG_FAILED
;
4752 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4755 * Need to commit any pending so this command doesn't merge with a
4756 * create into a modify, which BGP can't handle
4758 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
4761 DEFUN_YANG(no_neighbor_interface_config
,
4762 no_neighbor_interface_config_cmd
,
4763 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4766 "Configure BGP on interface\n"
4767 "Enable BGP with v6 link-local only\n"
4768 "Member of the peer-group\n"
4770 "Specify a BGP neighbor\n" AS_STR
4771 "Internal BGP peer\n"
4772 "External BGP peer\n")
4775 char base_xpath
[XPATH_MAXLEN
];
4777 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4778 argv
[idx_word
]->arg
, "");
4780 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4783 * Need to commit any pending so this command doesn't merge with a
4784 * create into a modify, which BGP can't handle
4786 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
4789 DEFUN_YANG(no_neighbor_peer_group
,
4790 no_neighbor_peer_group_cmd
,
4791 "no neighbor WORD peer-group",
4794 "Configure peer-group\n")
4796 char base_xpath
[XPATH_MAXLEN
];
4799 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4800 argv
[idx_word
]->arg
, "");
4802 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4805 * Need to commit any pending so this command doesn't merge with a
4806 * create into a modify, which BGP can't handle
4808 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
4811 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4812 no_neighbor_interface_peer_group_remote_as_cmd
,
4813 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4815 "Interface name or neighbor tag\n"
4816 "Specify a BGP neighbor\n" AS_STR
4817 "Internal BGP peer\n"
4818 "External BGP peer\n")
4821 char base_xpath
[XPATH_MAXLEN
];
4822 char unnbr_xpath
[XPATH_MAXLEN
];
4823 char prgrp_xpath
[XPATH_MAXLEN
];
4825 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4826 argv
[idx_peer
]->arg
, "");
4828 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4829 argv
[idx_peer
]->arg
, "");
4831 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4832 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4833 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4834 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4835 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4836 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4838 vty_out(vty
, "%% Create the peer-group or interface first\n");
4839 return CMD_WARNING_CONFIG_FAILED
;
4842 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4843 sizeof(base_xpath
));
4845 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4848 * Need to commit any pending so this command doesn't merge with a
4849 * create into a modify, which BGP can't handle
4851 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
4854 DEFUN_YANG(neighbor_local_as
,
4855 neighbor_local_as_cmd
,
4856 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4857 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4858 "Specify a local-as number\n"
4859 "AS number used as local AS\n")
4863 char base_xpath
[XPATH_MAXLEN
];
4865 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4866 sizeof(base_xpath
), NULL
)
4868 return CMD_WARNING_CONFIG_FAILED
;
4870 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4871 argv
[idx_number
]->arg
);
4873 return nb_cli_apply_changes(vty
, base_xpath
);
4877 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4878 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4879 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4880 "Specify a local-as number\n"
4881 "AS number used as local AS\n"
4882 "Do not prepend local-as to updates from ebgp peers\n")
4886 char base_xpath
[XPATH_MAXLEN
];
4888 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4889 sizeof(base_xpath
), NULL
)
4891 return CMD_WARNING_CONFIG_FAILED
;
4893 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4894 argv
[idx_number
]->arg
);
4895 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4898 return nb_cli_apply_changes(vty
, base_xpath
);
4902 neighbor_local_as_no_prepend_replace_as
,
4903 neighbor_local_as_no_prepend_replace_as_cmd
,
4904 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4905 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4906 "Specify a local-as number\n"
4907 "AS number used as local AS\n"
4908 "Do not prepend local-as to updates from ebgp peers\n"
4909 "Do not prepend local-as to updates from ibgp peers\n")
4913 char base_xpath
[XPATH_MAXLEN
];
4915 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4916 sizeof(base_xpath
), NULL
)
4918 return CMD_WARNING_CONFIG_FAILED
;
4920 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4921 argv
[idx_number
]->arg
);
4922 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4924 nb_cli_enqueue_change(vty
, "./local-as/replace-as", NB_OP_MODIFY
,
4927 return nb_cli_apply_changes(vty
, base_xpath
);
4930 DEFUN_YANG(no_neighbor_local_as
,
4931 no_neighbor_local_as_cmd
,
4932 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4933 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4934 "Specify a local-as number\n"
4935 "AS number used as local AS\n"
4936 "Do not prepend local-as to updates from ebgp peers\n"
4937 "Do not prepend local-as to updates from ibgp peers\n")
4940 char base_xpath
[XPATH_MAXLEN
];
4942 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4943 sizeof(base_xpath
), NULL
)
4945 return CMD_WARNING_CONFIG_FAILED
;
4947 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4948 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4950 nb_cli_enqueue_change(vty
, "./local-as/replace-as", NB_OP_MODIFY
,
4953 return nb_cli_apply_changes(vty
, base_xpath
);
4957 DEFUN (neighbor_solo
,
4959 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4962 "Solo peer - part of its own update group\n")
4968 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4970 return CMD_WARNING_CONFIG_FAILED
;
4972 ret
= update_group_adjust_soloness(peer
, 1);
4973 return bgp_vty_return(vty
, ret
);
4976 DEFUN (no_neighbor_solo
,
4977 no_neighbor_solo_cmd
,
4978 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4982 "Solo peer - part of its own update group\n")
4988 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4990 return CMD_WARNING_CONFIG_FAILED
;
4992 ret
= update_group_adjust_soloness(peer
, 0);
4993 return bgp_vty_return(vty
, ret
);
4996 DEFUN_YANG(neighbor_password
,
4997 neighbor_password_cmd
,
4998 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4999 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5005 char base_xpath
[XPATH_MAXLEN
];
5007 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5008 sizeof(base_xpath
), NULL
)
5010 return CMD_WARNING_CONFIG_FAILED
;
5012 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
5013 argv
[idx_line
]->arg
);
5015 return nb_cli_apply_changes(vty
, base_xpath
);
5018 DEFUN_YANG(no_neighbor_password
,
5019 no_neighbor_password_cmd
,
5020 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5021 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5026 char base_xpath
[XPATH_MAXLEN
];
5028 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5029 sizeof(base_xpath
), NULL
)
5031 return CMD_WARNING_CONFIG_FAILED
;
5033 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
5035 return nb_cli_apply_changes(vty
, base_xpath
);
5038 DEFUN_YANG(neighbor_activate
,
5039 neighbor_activate_cmd
,
5040 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5041 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5042 "Enable the Address Family for this Neighbor\n")
5045 char base_xpath
[XPATH_MAXLEN
];
5046 char af_xpath
[XPATH_MAXLEN
];
5047 afi_t afi
= bgp_node_afi(vty
);
5048 safi_t safi
= bgp_node_safi(vty
);
5050 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5051 yang_afi_safi_value2identity(afi
, safi
));
5052 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5053 sizeof(base_xpath
), af_xpath
)
5055 return CMD_WARNING_CONFIG_FAILED
;
5057 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
5059 return nb_cli_apply_changes(vty
, base_xpath
);
5062 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5063 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5064 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5065 "Enable the Address Family for this Neighbor\n")
5067 DEFUN_YANG(no_neighbor_activate
,
5068 no_neighbor_activate_cmd
,
5069 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5072 "Enable the Address Family for this Neighbor\n")
5075 char base_xpath
[XPATH_MAXLEN
];
5076 char af_xpath
[XPATH_MAXLEN
];
5077 afi_t afi
= bgp_node_afi(vty
);
5078 safi_t safi
= bgp_node_safi(vty
);
5080 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5081 yang_afi_safi_value2identity(afi
, safi
));
5083 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5084 sizeof(base_xpath
), af_xpath
)
5086 return CMD_WARNING_CONFIG_FAILED
;
5088 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
5090 return nb_cli_apply_changes(vty
, base_xpath
);
5093 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5094 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5095 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5096 "Enable the Address Family for this Neighbor\n")
5098 DEFUN (neighbor_set_peer_group
,
5099 neighbor_set_peer_group_cmd
,
5100 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5103 "Member of the peer-group\n"
5104 "Peer-group name\n")
5106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5113 struct peer_group
*group
;
5115 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5117 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5119 vty_out(vty
, "%% Malformed address or name: %s\n",
5120 argv
[idx_peer
]->arg
);
5121 return CMD_WARNING_CONFIG_FAILED
;
5124 if (peer_address_self_check(bgp
, &su
)) {
5126 "%% Can not configure the local system as neighbor\n");
5127 return CMD_WARNING_CONFIG_FAILED
;
5130 /* Disallow for dynamic neighbor. */
5131 peer
= peer_lookup(bgp
, &su
);
5132 if (peer
&& peer_dynamic_neighbor(peer
)) {
5134 "%% Operation not allowed on a dynamic neighbor\n");
5135 return CMD_WARNING_CONFIG_FAILED
;
5139 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5141 vty_out(vty
, "%% Configure the peer-group first\n");
5142 return CMD_WARNING_CONFIG_FAILED
;
5145 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5147 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
5149 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
5151 return CMD_WARNING_CONFIG_FAILED
;
5154 return bgp_vty_return(vty
, ret
);
5157 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5158 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5159 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5160 "Member of the peer-group\n"
5161 "Peer-group name\n")
5163 DEFUN_YANG (no_neighbor_set_peer_group
,
5164 no_neighbor_set_peer_group_cmd
,
5165 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5169 "Member of the peer-group\n"
5170 "Peer-group name\n")
5173 char base_xpath
[XPATH_MAXLEN
];
5175 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5176 sizeof(base_xpath
), NULL
)
5178 return CMD_WARNING_CONFIG_FAILED
;
5180 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5183 * Need to commit any pending so this command doesn't merge with a
5184 * create into a modify, which BGP can't handle
5186 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
5189 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5190 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5191 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5192 "Member of the peer-group\n"
5193 "Peer-group name\n")
5195 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5196 uint32_t flag
, int set
)
5201 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5203 return CMD_WARNING_CONFIG_FAILED
;
5206 * If 'neighbor <interface>', then this is for directly connected peers,
5207 * we should not accept disable-connected-check.
5209 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5211 "%s is directly connected peer, cannot accept disable-connected-check\n",
5213 return CMD_WARNING_CONFIG_FAILED
;
5216 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5217 peer_tx_shutdown_message_unset(peer
);
5220 ret
= peer_flag_set(peer
, flag
);
5222 ret
= peer_flag_unset(peer
, flag
);
5224 return bgp_vty_return(vty
, ret
);
5227 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5229 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5232 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5235 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5238 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5239 uint32_t flag
, bool set
, char *errmsg
,
5245 * If 'neighbor <interface>', then this is for directly connected peers,
5246 * we should not accept disable-connected-check.
5248 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5251 "%s is directly connected peer, cannot accept disable-connected-check\n",
5256 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5257 peer_tx_shutdown_message_unset(peer
);
5260 ret
= peer_flag_set(peer
, flag
);
5262 ret
= peer_flag_unset(peer
, flag
);
5264 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5267 /* neighbor passive. */
5268 DEFUN_YANG(neighbor_passive
,
5269 neighbor_passive_cmd
,
5270 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5273 "Don't send open messages to this neighbor\n")
5276 char base_xpath
[XPATH_MAXLEN
];
5278 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5279 sizeof(base_xpath
), NULL
)
5281 return CMD_WARNING_CONFIG_FAILED
;
5283 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5285 return nb_cli_apply_changes(vty
, base_xpath
);
5288 DEFUN_YANG(no_neighbor_passive
,
5289 no_neighbor_passive_cmd
,
5290 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5293 "Don't send open messages to this neighbor\n")
5296 char base_xpath
[XPATH_MAXLEN
];
5298 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5299 sizeof(base_xpath
), NULL
)
5301 return CMD_WARNING_CONFIG_FAILED
;
5303 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5305 return nb_cli_apply_changes(vty
, base_xpath
);
5308 /* neighbor shutdown. */
5309 DEFUN_YANG(neighbor_shutdown_msg
,
5310 neighbor_shutdown_msg_cmd
,
5311 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5312 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5313 "Administratively shut down this neighbor\n"
5314 "Add a shutdown message (RFC 8203)\n"
5315 "Shutdown message\n")
5318 char base_xpath
[XPATH_MAXLEN
];
5320 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5321 sizeof(base_xpath
), NULL
)
5323 return CMD_WARNING_CONFIG_FAILED
;
5328 message
= argv_concat(argv
, argc
, 4);
5329 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5330 NB_OP_MODIFY
, message
);
5333 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5336 return nb_cli_apply_changes(vty
, base_xpath
);
5339 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5340 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5341 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5342 "Administratively shut down this neighbor\n")
5344 DEFUN_YANG(no_neighbor_shutdown_msg
,
5345 no_neighbor_shutdown_msg_cmd
,
5346 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5349 "Administratively shut down this neighbor\n"
5350 "Remove a shutdown message (RFC 8203)\n"
5351 "Shutdown message\n")
5354 char base_xpath
[XPATH_MAXLEN
];
5356 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5357 sizeof(base_xpath
), NULL
)
5359 return CMD_WARNING_CONFIG_FAILED
;
5361 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5364 return nb_cli_apply_changes(vty
, base_xpath
);
5367 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5368 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5369 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5370 "Administratively shut down this neighbor\n")
5372 DEFUN(neighbor_shutdown_rtt
,
5373 neighbor_shutdown_rtt_cmd
,
5374 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5377 "Administratively shut down this neighbor\n"
5378 "Shutdown if round-trip-time is higher than expected\n"
5379 "Round-trip-time in milliseconds\n"
5380 "Specify the number of keepalives before shutdown\n"
5381 "The number of keepalives with higher RTT to shutdown\n")
5388 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5391 return CMD_WARNING_CONFIG_FAILED
;
5393 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5395 if (argv_find(argv
, argc
, "count", &idx_count
))
5396 peer
->rtt_keepalive_conf
=
5397 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5399 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5400 PEER_FLAG_RTT_SHUTDOWN
);
5403 DEFUN(no_neighbor_shutdown_rtt
,
5404 no_neighbor_shutdown_rtt_cmd
,
5405 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5409 "Administratively shut down this neighbor\n"
5410 "Shutdown if round-trip-time is higher than expected\n"
5411 "Round-trip-time in milliseconds\n"
5412 "Specify the number of keepalives before shutdown\n"
5413 "The number of keepalives with higher RTT to shutdown\n")
5418 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5421 return CMD_WARNING_CONFIG_FAILED
;
5423 peer
->rtt_expected
= 0;
5424 peer
->rtt_keepalive_conf
= 1;
5426 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5427 PEER_FLAG_RTT_SHUTDOWN
);
5430 /* neighbor capability dynamic. */
5431 DEFUN_YANG (neighbor_capability_dynamic
,
5432 neighbor_capability_dynamic_cmd
,
5433 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5436 "Advertise capability to the peer\n"
5437 "Advertise dynamic capability to this neighbor\n")
5440 char base_xpath
[XPATH_MAXLEN
];
5442 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5443 sizeof(base_xpath
), NULL
)
5445 return CMD_WARNING_CONFIG_FAILED
;
5447 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5448 NB_OP_MODIFY
, "true");
5450 return nb_cli_apply_changes(vty
, base_xpath
);
5453 DEFUN_YANG (no_neighbor_capability_dynamic
,
5454 no_neighbor_capability_dynamic_cmd
,
5455 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5459 "Advertise capability to the peer\n"
5460 "Advertise dynamic capability to this neighbor\n")
5463 char base_xpath
[XPATH_MAXLEN
];
5465 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5466 sizeof(base_xpath
), NULL
)
5468 return CMD_WARNING_CONFIG_FAILED
;
5470 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5471 NB_OP_MODIFY
, "false");
5473 return nb_cli_apply_changes(vty
, base_xpath
);
5476 /* neighbor dont-capability-negotiate */
5477 DEFUN (neighbor_dont_capability_negotiate
,
5478 neighbor_dont_capability_negotiate_cmd
,
5479 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5482 "Do not perform capability negotiation\n")
5485 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5486 PEER_FLAG_DONT_CAPABILITY
);
5489 DEFUN (no_neighbor_dont_capability_negotiate
,
5490 no_neighbor_dont_capability_negotiate_cmd
,
5491 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5495 "Do not perform capability negotiation\n")
5498 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5499 PEER_FLAG_DONT_CAPABILITY
);
5502 /* neighbor capability extended next hop encoding */
5503 DEFUN_YANG (neighbor_capability_enhe
,
5504 neighbor_capability_enhe_cmd
,
5505 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5508 "Advertise capability to the peer\n"
5509 "Advertise extended next-hop capability to the peer\n")
5512 char base_xpath
[XPATH_MAXLEN
];
5514 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5515 sizeof(base_xpath
), NULL
)
5517 return CMD_WARNING_CONFIG_FAILED
;
5519 nb_cli_enqueue_change(
5520 vty
, "./capability-options/extended-nexthop-capability",
5521 NB_OP_MODIFY
, "true");
5523 return nb_cli_apply_changes(vty
, base_xpath
);
5526 DEFUN_YANG (no_neighbor_capability_enhe
,
5527 no_neighbor_capability_enhe_cmd
,
5528 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5532 "Advertise capability to the peer\n"
5533 "Advertise extended next-hop capability to the peer\n")
5536 char base_xpath
[XPATH_MAXLEN
];
5538 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5539 sizeof(base_xpath
), NULL
)
5541 return CMD_WARNING_CONFIG_FAILED
;
5543 nb_cli_enqueue_change(
5544 vty
, "./capability-options/extended-nexthop-capability",
5545 NB_OP_MODIFY
, "false");
5547 return nb_cli_apply_changes(vty
, base_xpath
);
5550 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5551 uint32_t flag
, int set
, char *errmsg
,
5557 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5559 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5561 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5564 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5565 afi_t afi
, safi_t safi
, uint32_t flag
,
5571 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5573 return CMD_WARNING_CONFIG_FAILED
;
5576 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5578 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5580 return bgp_vty_return(vty
, ret
);
5583 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5584 afi_t afi
, safi_t safi
, uint32_t flag
)
5586 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5589 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5590 afi_t afi
, safi_t safi
, uint32_t flag
)
5592 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5595 /* neighbor capability orf prefix-list. */
5596 DEFUN (neighbor_capability_orf_prefix
,
5597 neighbor_capability_orf_prefix_cmd
,
5598 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5601 "Advertise capability to the peer\n"
5602 "Advertise ORF capability to the peer\n"
5603 "Advertise prefixlist ORF capability to this neighbor\n"
5604 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5605 "Capability to RECEIVE the ORF from this neighbor\n"
5606 "Capability to SEND the ORF to this neighbor\n")
5608 int idx_send_recv
= 5;
5609 char *peer_str
= argv
[1]->arg
;
5611 afi_t afi
= bgp_node_afi(vty
);
5612 safi_t safi
= bgp_node_safi(vty
);
5614 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5616 return CMD_WARNING_CONFIG_FAILED
;
5618 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5619 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5620 PEER_FLAG_ORF_PREFIX_SM
);
5622 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5623 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5624 PEER_FLAG_ORF_PREFIX_RM
);
5626 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5627 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5628 PEER_FLAG_ORF_PREFIX_SM
)
5629 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5630 PEER_FLAG_ORF_PREFIX_RM
);
5632 return CMD_WARNING_CONFIG_FAILED
;
5636 neighbor_capability_orf_prefix
,
5637 neighbor_capability_orf_prefix_hidden_cmd
,
5638 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5639 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5640 "Advertise capability to the peer\n"
5641 "Advertise ORF capability to the peer\n"
5642 "Advertise prefixlist ORF capability to this neighbor\n"
5643 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5644 "Capability to RECEIVE the ORF from this neighbor\n"
5645 "Capability to SEND the ORF to this neighbor\n")
5647 DEFUN (no_neighbor_capability_orf_prefix
,
5648 no_neighbor_capability_orf_prefix_cmd
,
5649 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5653 "Advertise capability to the peer\n"
5654 "Advertise ORF capability to the peer\n"
5655 "Advertise prefixlist ORF capability to this neighbor\n"
5656 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5657 "Capability to RECEIVE the ORF from this neighbor\n"
5658 "Capability to SEND the ORF to this neighbor\n")
5660 int idx_send_recv
= 6;
5661 char *peer_str
= argv
[2]->arg
;
5663 afi_t afi
= bgp_node_afi(vty
);
5664 safi_t safi
= bgp_node_safi(vty
);
5666 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5668 return CMD_WARNING_CONFIG_FAILED
;
5670 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5671 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5672 PEER_FLAG_ORF_PREFIX_SM
);
5674 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5675 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5676 PEER_FLAG_ORF_PREFIX_RM
);
5678 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5679 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5680 PEER_FLAG_ORF_PREFIX_SM
)
5681 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5682 PEER_FLAG_ORF_PREFIX_RM
);
5684 return CMD_WARNING_CONFIG_FAILED
;
5688 no_neighbor_capability_orf_prefix
,
5689 no_neighbor_capability_orf_prefix_hidden_cmd
,
5690 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5691 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5692 "Advertise capability to the peer\n"
5693 "Advertise ORF capability to the peer\n"
5694 "Advertise prefixlist ORF capability to this neighbor\n"
5695 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5696 "Capability to RECEIVE the ORF from this neighbor\n"
5697 "Capability to SEND the ORF to this neighbor\n")
5699 /* neighbor next-hop-self. */
5700 DEFUN_YANG (neighbor_nexthop_self
,
5701 neighbor_nexthop_self_cmd
,
5702 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5705 "Disable the next hop calculation for this neighbor\n")
5708 char base_xpath
[XPATH_MAXLEN
];
5709 char af_xpath
[XPATH_MAXLEN
];
5710 char attr_xpath
[XPATH_MAXLEN
];
5711 afi_t afi
= bgp_node_afi(vty
);
5712 safi_t safi
= bgp_node_safi(vty
);
5714 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5715 yang_afi_safi_value2identity(afi
, safi
));
5717 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5718 sizeof(base_xpath
), af_xpath
)
5720 return CMD_WARNING_CONFIG_FAILED
;
5722 snprintf(attr_xpath
, sizeof(attr_xpath
),
5723 "./%s/nexthop-self/next-hop-self",
5724 bgp_afi_safi_get_container_str(afi
, safi
));
5726 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5728 return nb_cli_apply_changes(vty
, base_xpath
);
5731 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5732 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5733 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5734 "Disable the next hop calculation for this neighbor\n")
5736 /* neighbor next-hop-self. */
5737 DEFUN_YANG(neighbor_nexthop_self_force
,
5738 neighbor_nexthop_self_force_cmd
,
5739 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5742 "Disable the next hop calculation for this neighbor\n"
5743 "Set the next hop to self for reflected routes\n")
5746 char base_xpath
[XPATH_MAXLEN
];
5747 char af_xpath
[XPATH_MAXLEN
];
5748 char attr_xpath
[XPATH_MAXLEN
];
5749 afi_t afi
= bgp_node_afi(vty
);
5750 safi_t safi
= bgp_node_safi(vty
);
5752 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5753 yang_afi_safi_value2identity(afi
, safi
));
5755 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5756 sizeof(base_xpath
), af_xpath
)
5758 return CMD_WARNING_CONFIG_FAILED
;
5760 snprintf(attr_xpath
, sizeof(attr_xpath
),
5761 "./%s/nexthop-self/next-hop-self-force",
5762 bgp_afi_safi_get_container_str(afi
, safi
));
5764 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5766 return nb_cli_apply_changes(vty
, base_xpath
);
5769 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5770 neighbor_nexthop_self_force_hidden_cmd
,
5771 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5772 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5773 "Disable the next hop calculation for this neighbor\n"
5774 "Set the next hop to self for reflected routes\n")
5776 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5777 neighbor_nexthop_self_all_hidden_cmd
,
5778 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5779 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5780 "Disable the next hop calculation for this neighbor\n"
5781 "Set the next hop to self for reflected routes\n")
5783 DEFUN_YANG (no_neighbor_nexthop_self
,
5784 no_neighbor_nexthop_self_cmd
,
5785 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5789 "Disable the next hop calculation for this neighbor\n")
5792 char base_xpath
[XPATH_MAXLEN
];
5793 char af_xpath
[XPATH_MAXLEN
];
5794 char attr_xpath
[XPATH_MAXLEN
];
5795 afi_t afi
= bgp_node_afi(vty
);
5796 safi_t safi
= bgp_node_safi(vty
);
5798 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5799 yang_afi_safi_value2identity(afi
, safi
));
5801 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5802 sizeof(base_xpath
), af_xpath
)
5804 return CMD_WARNING_CONFIG_FAILED
;
5806 snprintf(attr_xpath
, sizeof(attr_xpath
),
5807 "./%s/nexthop-self/next-hop-self",
5808 bgp_afi_safi_get_container_str(afi
, safi
));
5810 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5812 return nb_cli_apply_changes(vty
, base_xpath
);
5815 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5816 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5817 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5818 "Disable the next hop calculation for this neighbor\n")
5820 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5821 no_neighbor_nexthop_self_force_cmd
,
5822 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5826 "Disable the next hop calculation for this neighbor\n"
5827 "Set the next hop to self for reflected routes\n")
5830 char base_xpath
[XPATH_MAXLEN
];
5831 char af_xpath
[XPATH_MAXLEN
];
5832 char attr_xpath
[XPATH_MAXLEN
];
5833 afi_t afi
= bgp_node_afi(vty
);
5834 safi_t safi
= bgp_node_safi(vty
);
5836 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5837 yang_afi_safi_value2identity(afi
, safi
));
5839 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5840 sizeof(base_xpath
), af_xpath
)
5842 return CMD_WARNING_CONFIG_FAILED
;
5844 snprintf(attr_xpath
, sizeof(attr_xpath
),
5845 "./%s/nexthop-self/next-hop-self-force",
5846 bgp_afi_safi_get_container_str(afi
, safi
));
5848 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5850 return nb_cli_apply_changes(vty
, base_xpath
);
5853 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5854 no_neighbor_nexthop_self_force_hidden_cmd
,
5855 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5856 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5857 "Disable the next hop calculation for this neighbor\n"
5858 "Set the next hop to self for reflected routes\n")
5860 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5861 no_neighbor_nexthop_self_all_hidden_cmd
,
5862 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5863 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5864 "Disable the next hop calculation for this neighbor\n"
5865 "Set the next hop to self for reflected routes\n")
5867 /* neighbor as-override */
5868 DEFUN_YANG (neighbor_as_override
,
5869 neighbor_as_override_cmd
,
5870 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5873 "Override ASNs in outbound updates if aspath equals remote-as\n")
5876 char base_xpath
[XPATH_MAXLEN
];
5877 char af_xpath
[XPATH_MAXLEN
];
5878 char attr_xpath
[XPATH_MAXLEN
];
5879 afi_t afi
= bgp_node_afi(vty
);
5880 safi_t safi
= bgp_node_safi(vty
);
5882 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5883 yang_afi_safi_value2identity(afi
, safi
));
5885 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5886 sizeof(base_xpath
), af_xpath
)
5888 return CMD_WARNING_CONFIG_FAILED
;
5890 snprintf(attr_xpath
, sizeof(attr_xpath
),
5891 "./%s/as-path-options/replace-peer-as",
5892 bgp_afi_safi_get_container_str(afi
, safi
));
5894 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5896 return nb_cli_apply_changes(vty
, base_xpath
);
5899 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5900 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5901 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5902 "Override ASNs in outbound updates if aspath equals remote-as\n")
5904 DEFUN_YANG (no_neighbor_as_override
,
5905 no_neighbor_as_override_cmd
,
5906 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5910 "Override ASNs in outbound updates if aspath equals remote-as\n")
5913 char base_xpath
[XPATH_MAXLEN
];
5914 char af_xpath
[XPATH_MAXLEN
];
5915 char attr_xpath
[XPATH_MAXLEN
];
5916 afi_t afi
= bgp_node_afi(vty
);
5917 safi_t safi
= bgp_node_safi(vty
);
5919 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5920 yang_afi_safi_value2identity(afi
, safi
));
5922 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5923 sizeof(base_xpath
), af_xpath
)
5925 return CMD_WARNING_CONFIG_FAILED
;
5927 snprintf(attr_xpath
, sizeof(attr_xpath
),
5928 "./%s/as-path-options/replace-peer-as",
5929 bgp_afi_safi_get_container_str(afi
, safi
));
5931 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5933 return nb_cli_apply_changes(vty
, base_xpath
);
5936 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5937 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5938 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5939 "Override ASNs in outbound updates if aspath equals remote-as\n")
5941 /* neighbor remove-private-AS. */
5942 DEFUN_YANG (neighbor_remove_private_as
,
5943 neighbor_remove_private_as_cmd
,
5944 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5947 "Remove private ASNs in outbound updates\n")
5950 char base_xpath
[XPATH_MAXLEN
];
5951 char af_xpath
[XPATH_MAXLEN
];
5952 char attr_xpath
[XPATH_MAXLEN
];
5953 afi_t afi
= bgp_node_afi(vty
);
5954 safi_t safi
= bgp_node_safi(vty
);
5956 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5957 yang_afi_safi_value2identity(afi
, safi
));
5959 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5960 sizeof(base_xpath
), af_xpath
)
5962 return CMD_WARNING_CONFIG_FAILED
;
5964 snprintf(attr_xpath
, sizeof(attr_xpath
),
5965 "./%s/private-as/remove-private-as",
5966 bgp_afi_safi_get_container_str(afi
, safi
));
5968 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5970 return nb_cli_apply_changes(vty
, base_xpath
);
5973 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5974 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5975 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5976 "Remove private ASNs in outbound updates\n")
5978 DEFUN_YANG (neighbor_remove_private_as_all
,
5979 neighbor_remove_private_as_all_cmd
,
5980 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5983 "Remove private ASNs in outbound updates\n"
5984 "Apply to all AS numbers\n")
5987 char base_xpath
[XPATH_MAXLEN
];
5988 char af_xpath
[XPATH_MAXLEN
];
5989 char attr_xpath
[XPATH_MAXLEN
];
5990 afi_t afi
= bgp_node_afi(vty
);
5991 safi_t safi
= bgp_node_safi(vty
);
5993 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5994 yang_afi_safi_value2identity(afi
, safi
));
5996 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5997 sizeof(base_xpath
), af_xpath
)
5999 return CMD_WARNING_CONFIG_FAILED
;
6001 snprintf(attr_xpath
, sizeof(attr_xpath
),
6002 "./%s/private-as/remove-private-as-all",
6003 bgp_afi_safi_get_container_str(afi
, safi
));
6005 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6007 return nb_cli_apply_changes(vty
, base_xpath
);
6010 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
6011 neighbor_remove_private_as_all_hidden_cmd
,
6012 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6013 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6014 "Remove private ASNs in outbound updates\n"
6015 "Apply to all AS numbers")
6017 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
6018 neighbor_remove_private_as_replace_as_cmd
,
6019 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6022 "Remove private ASNs in outbound updates\n"
6023 "Replace private ASNs with our ASN in outbound updates\n")
6026 char base_xpath
[XPATH_MAXLEN
];
6027 char af_xpath
[XPATH_MAXLEN
];
6028 char attr_xpath
[XPATH_MAXLEN
];
6029 afi_t afi
= bgp_node_afi(vty
);
6030 safi_t safi
= bgp_node_safi(vty
);
6032 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6033 yang_afi_safi_value2identity(afi
, safi
));
6035 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6036 sizeof(base_xpath
), af_xpath
)
6038 return CMD_WARNING_CONFIG_FAILED
;
6040 snprintf(attr_xpath
, sizeof(attr_xpath
),
6041 "./%s/private-as/remove-private-as-replace",
6042 bgp_afi_safi_get_container_str(afi
, safi
));
6044 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6046 return nb_cli_apply_changes(vty
, base_xpath
);
6049 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
6050 neighbor_remove_private_as_replace_as_hidden_cmd
,
6051 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6052 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6053 "Remove private ASNs in outbound updates\n"
6054 "Replace private ASNs with our ASN in outbound updates\n")
6056 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
6057 neighbor_remove_private_as_all_replace_as_cmd
,
6058 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6061 "Remove private ASNs in outbound updates\n"
6062 "Apply to all AS numbers\n"
6063 "Replace private ASNs with our ASN in outbound updates\n")
6066 char base_xpath
[XPATH_MAXLEN
];
6067 char af_xpath
[XPATH_MAXLEN
];
6068 char attr_xpath
[XPATH_MAXLEN
];
6069 afi_t afi
= bgp_node_afi(vty
);
6070 safi_t safi
= bgp_node_safi(vty
);
6072 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6073 yang_afi_safi_value2identity(afi
, safi
));
6075 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6076 sizeof(base_xpath
), af_xpath
)
6078 return CMD_WARNING_CONFIG_FAILED
;
6080 snprintf(attr_xpath
, sizeof(attr_xpath
),
6081 "./%s/private-as/remove-private-as-all-replace",
6082 bgp_afi_safi_get_container_str(afi
, safi
));
6084 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6086 return nb_cli_apply_changes(vty
, base_xpath
);
6090 neighbor_remove_private_as_all_replace_as
,
6091 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6092 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6094 "Remove private ASNs in outbound updates\n"
6095 "Apply to all AS numbers\n"
6096 "Replace private ASNs with our ASN in outbound updates\n")
6098 DEFUN_YANG (no_neighbor_remove_private_as
,
6099 no_neighbor_remove_private_as_cmd
,
6100 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6104 "Remove private ASNs in outbound updates\n")
6107 char base_xpath
[XPATH_MAXLEN
];
6108 char af_xpath
[XPATH_MAXLEN
];
6109 char attr_xpath
[XPATH_MAXLEN
];
6110 afi_t afi
= bgp_node_afi(vty
);
6111 safi_t safi
= bgp_node_safi(vty
);
6113 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6114 yang_afi_safi_value2identity(afi
, safi
));
6116 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6117 sizeof(base_xpath
), af_xpath
)
6119 return CMD_WARNING_CONFIG_FAILED
;
6121 snprintf(attr_xpath
, sizeof(attr_xpath
),
6122 "./%s/private-as/remove-private-as",
6123 bgp_afi_safi_get_container_str(afi
, safi
));
6125 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6127 return nb_cli_apply_changes(vty
, base_xpath
);
6130 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
6131 no_neighbor_remove_private_as_hidden_cmd
,
6132 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6133 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6134 "Remove private ASNs in outbound updates\n")
6136 DEFUN_YANG (no_neighbor_remove_private_as_all
,
6137 no_neighbor_remove_private_as_all_cmd
,
6138 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6142 "Remove private ASNs in outbound updates\n"
6143 "Apply to all AS numbers\n")
6146 char base_xpath
[XPATH_MAXLEN
];
6147 char af_xpath
[XPATH_MAXLEN
];
6148 char attr_xpath
[XPATH_MAXLEN
];
6149 afi_t afi
= bgp_node_afi(vty
);
6150 safi_t safi
= bgp_node_safi(vty
);
6152 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6153 yang_afi_safi_value2identity(afi
, safi
));
6155 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6156 sizeof(base_xpath
), af_xpath
)
6158 return CMD_WARNING_CONFIG_FAILED
;
6160 snprintf(attr_xpath
, sizeof(attr_xpath
),
6161 "./%s/private-as/remove-private-as-all",
6162 bgp_afi_safi_get_container_str(afi
, safi
));
6164 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6166 return nb_cli_apply_changes(vty
, base_xpath
);
6169 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6170 no_neighbor_remove_private_as_all_hidden_cmd
,
6171 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6172 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6173 "Remove private ASNs in outbound updates\n"
6174 "Apply to all AS numbers\n")
6176 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6177 no_neighbor_remove_private_as_replace_as_cmd
,
6178 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6182 "Remove private ASNs in outbound updates\n"
6183 "Replace private ASNs with our ASN in outbound updates\n")
6186 char base_xpath
[XPATH_MAXLEN
];
6187 char af_xpath
[XPATH_MAXLEN
];
6188 char attr_xpath
[XPATH_MAXLEN
];
6189 afi_t afi
= bgp_node_afi(vty
);
6190 safi_t safi
= bgp_node_safi(vty
);
6192 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6193 yang_afi_safi_value2identity(afi
, safi
));
6195 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6196 sizeof(base_xpath
), af_xpath
)
6198 return CMD_WARNING_CONFIG_FAILED
;
6200 snprintf(attr_xpath
, sizeof(attr_xpath
),
6201 "./%s/private-as/remove-private-as-replace",
6202 bgp_afi_safi_get_container_str(afi
, safi
));
6204 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6206 return nb_cli_apply_changes(vty
, base_xpath
);
6209 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6210 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6211 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6213 "Remove private ASNs in outbound updates\n"
6214 "Replace private ASNs with our ASN in outbound updates\n")
6216 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6217 no_neighbor_remove_private_as_all_replace_as_cmd
,
6218 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6222 "Remove private ASNs in outbound updates\n"
6223 "Apply to all AS numbers\n"
6224 "Replace private ASNs with our ASN in outbound updates\n")
6227 char base_xpath
[XPATH_MAXLEN
];
6228 char af_xpath
[XPATH_MAXLEN
];
6229 char attr_xpath
[XPATH_MAXLEN
];
6230 afi_t afi
= bgp_node_afi(vty
);
6231 safi_t safi
= bgp_node_safi(vty
);
6233 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6234 yang_afi_safi_value2identity(afi
, safi
));
6236 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6237 sizeof(base_xpath
), af_xpath
)
6239 return CMD_WARNING_CONFIG_FAILED
;
6241 snprintf(attr_xpath
, sizeof(attr_xpath
),
6242 "./%s/private-as/remove-private-as-all-replace",
6243 bgp_afi_safi_get_container_str(afi
, safi
));
6245 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6247 return nb_cli_apply_changes(vty
, base_xpath
);
6251 no_neighbor_remove_private_as_all_replace_as
,
6252 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6253 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6254 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6255 "Remove private ASNs in outbound updates\n"
6256 "Apply to all AS numbers\n"
6257 "Replace private ASNs with our ASN in outbound updates\n")
6260 /* neighbor send-community. */
6261 DEFUN_YANG (neighbor_send_community
,
6262 neighbor_send_community_cmd
,
6263 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6266 "Send Community attribute to this neighbor\n")
6269 char *peer_str
= argv
[idx_peer
]->arg
;
6270 char base_xpath
[XPATH_MAXLEN
];
6271 char af_xpath
[XPATH_MAXLEN
];
6272 char std_xpath
[XPATH_MAXLEN
];
6273 afi_t afi
= bgp_node_afi(vty
);
6274 safi_t safi
= bgp_node_safi(vty
);
6276 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6277 yang_afi_safi_value2identity(afi
, safi
));
6279 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6280 sizeof(base_xpath
), af_xpath
)
6282 return CMD_WARNING_CONFIG_FAILED
;
6284 snprintf(std_xpath
, sizeof(std_xpath
),
6285 "./%s/send-community/send-community",
6286 bgp_afi_safi_get_container_str(afi
, safi
));
6288 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6290 return nb_cli_apply_changes(vty
, base_xpath
);
6293 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6295 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6296 "Send Community attribute to this neighbor\n")
6298 DEFUN_YANG (no_neighbor_send_community
,
6299 no_neighbor_send_community_cmd
,
6300 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6304 "Send Community attribute to this neighbor\n")
6307 char *peer_str
= argv
[idx_peer
]->arg
;
6308 char base_xpath
[XPATH_MAXLEN
];
6309 char af_xpath
[XPATH_MAXLEN
];
6310 char std_xpath
[XPATH_MAXLEN
];
6311 afi_t afi
= bgp_node_afi(vty
);
6312 safi_t safi
= bgp_node_safi(vty
);
6314 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6315 yang_afi_safi_value2identity(afi
, safi
));
6317 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6318 sizeof(base_xpath
), af_xpath
)
6320 return CMD_WARNING_CONFIG_FAILED
;
6322 snprintf(std_xpath
, sizeof(std_xpath
),
6323 "./%s/send-community/send-community",
6324 bgp_afi_safi_get_container_str(afi
, safi
));
6326 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6328 return nb_cli_apply_changes(vty
, base_xpath
);
6331 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6332 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6333 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6334 "Send Community attribute to this neighbor\n")
6336 /* neighbor send-community extended. */
6337 DEFUN_YANG (neighbor_send_community_type
,
6338 neighbor_send_community_type_cmd
,
6339 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6342 "Send Community attribute to this neighbor\n"
6343 "Send Standard and Extended Community attributes\n"
6344 "Send Standard, Large and Extended Community attributes\n"
6345 "Send Extended Community attributes\n"
6346 "Send Standard Community attributes\n"
6347 "Send Large Community attributes\n")
6349 const char *type
= argv
[argc
- 1]->text
;
6350 char *peer_str
= argv
[1]->arg
;
6351 char base_xpath
[XPATH_MAXLEN
];
6352 char af_xpath
[XPATH_MAXLEN
];
6353 char std_xpath
[XPATH_MAXLEN
];
6354 char ext_xpath
[XPATH_MAXLEN
];
6355 char lrg_xpath
[XPATH_MAXLEN
];
6356 afi_t afi
= bgp_node_afi(vty
);
6357 safi_t safi
= bgp_node_safi(vty
);
6359 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6360 yang_afi_safi_value2identity(afi
, safi
));
6362 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6363 sizeof(base_xpath
), af_xpath
)
6365 return CMD_WARNING_CONFIG_FAILED
;
6367 if (strmatch(type
, "standard")) {
6368 snprintf(std_xpath
, sizeof(std_xpath
),
6369 "./%s/send-community/send-community",
6370 bgp_afi_safi_get_container_str(afi
, safi
));
6372 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6375 if (strmatch(type
, "extended")) {
6376 snprintf(ext_xpath
, sizeof(ext_xpath
),
6377 "./%s/send-community/send-ext-community",
6378 bgp_afi_safi_get_container_str(afi
, safi
));
6380 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6383 if (strmatch(type
, "large")) {
6384 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6385 "./%s/send-community/send-large-community",
6386 bgp_afi_safi_get_container_str(afi
, safi
));
6388 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6391 if (strmatch(type
, "both")) {
6392 snprintf(std_xpath
, sizeof(std_xpath
),
6393 "./%s/send-community/send-community",
6394 bgp_afi_safi_get_container_str(afi
, safi
));
6396 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6398 snprintf(ext_xpath
, sizeof(ext_xpath
),
6399 "./%s/send-community/send-ext-community",
6400 bgp_afi_safi_get_container_str(afi
, safi
));
6402 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6405 if (strmatch(type
, "all")) {
6406 snprintf(std_xpath
, sizeof(std_xpath
),
6407 "./%s/send-community/send-community",
6408 bgp_afi_safi_get_container_str(afi
, safi
));
6410 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6412 snprintf(ext_xpath
, sizeof(ext_xpath
),
6413 "./%s/send-community/send-ext-community",
6414 bgp_afi_safi_get_container_str(afi
, safi
));
6416 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6418 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6419 "./%s/send-community/send-large-community",
6420 bgp_afi_safi_get_container_str(afi
, safi
));
6422 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6425 return nb_cli_apply_changes(vty
, base_xpath
);
6429 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6430 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6431 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6432 "Send Community attribute to this neighbor\n"
6433 "Send Standard and Extended Community attributes\n"
6434 "Send Standard, Large and Extended Community attributes\n"
6435 "Send Extended Community attributes\n"
6436 "Send Standard Community attributes\n"
6437 "Send Large Community attributes\n")
6439 DEFUN_YANG (no_neighbor_send_community_type
,
6440 no_neighbor_send_community_type_cmd
,
6441 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6445 "Send Community attribute to this neighbor\n"
6446 "Send Standard and Extended Community attributes\n"
6447 "Send Standard, Large and Extended Community attributes\n"
6448 "Send Extended Community attributes\n"
6449 "Send Standard Community attributes\n"
6450 "Send Large Community attributes\n")
6452 const char *type
= argv
[argc
- 1]->text
;
6453 char *peer_str
= argv
[2]->arg
;
6454 char base_xpath
[XPATH_MAXLEN
];
6455 char af_xpath
[XPATH_MAXLEN
];
6456 char std_xpath
[XPATH_MAXLEN
];
6457 char ext_xpath
[XPATH_MAXLEN
];
6458 char lrg_xpath
[XPATH_MAXLEN
];
6459 afi_t afi
= bgp_node_afi(vty
);
6460 safi_t safi
= bgp_node_safi(vty
);
6462 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6463 yang_afi_safi_value2identity(afi
, safi
));
6465 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6466 sizeof(base_xpath
), af_xpath
)
6468 return CMD_WARNING_CONFIG_FAILED
;
6470 if (strmatch(type
, "standard")) {
6471 snprintf(std_xpath
, sizeof(std_xpath
),
6472 "./%s/send-community/send-community",
6473 bgp_afi_safi_get_container_str(afi
, safi
));
6475 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6478 if (strmatch(type
, "extended")) {
6479 snprintf(ext_xpath
, sizeof(ext_xpath
),
6480 "./%s/send-community/send-ext-community",
6481 bgp_afi_safi_get_container_str(afi
, safi
));
6483 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6486 if (strmatch(type
, "large")) {
6487 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6488 "./%s/send-community/send-large-community",
6489 bgp_afi_safi_get_container_str(afi
, safi
));
6491 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6494 if (strmatch(type
, "both")) {
6495 snprintf(std_xpath
, sizeof(std_xpath
),
6496 "./%s/send-community/send-community",
6497 bgp_afi_safi_get_container_str(afi
, safi
));
6499 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6501 snprintf(ext_xpath
, sizeof(ext_xpath
),
6502 "./%s/send-community/send-ext-community",
6503 bgp_afi_safi_get_container_str(afi
, safi
));
6505 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6508 if (strmatch(type
, "all")) {
6509 snprintf(std_xpath
, sizeof(std_xpath
),
6510 "./%s/send-community/send-community",
6511 bgp_afi_safi_get_container_str(afi
, safi
));
6513 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6515 snprintf(ext_xpath
, sizeof(ext_xpath
),
6516 "./%s/send-community/send-ext-community",
6517 bgp_afi_safi_get_container_str(afi
, safi
));
6519 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6521 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6522 "./%s/send-community/send-large-community",
6523 bgp_afi_safi_get_container_str(afi
, safi
));
6525 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6528 return nb_cli_apply_changes(vty
, base_xpath
);
6532 no_neighbor_send_community_type
,
6533 no_neighbor_send_community_type_hidden_cmd
,
6534 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6535 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6536 "Send Community attribute to this neighbor\n"
6537 "Send Standard and Extended Community attributes\n"
6538 "Send Standard, Large and Extended Community attributes\n"
6539 "Send Extended Community attributes\n"
6540 "Send Standard Community attributes\n"
6541 "Send Large Community attributes\n")
6543 /* neighbor soft-reconfig. */
6544 DEFUN_YANG (neighbor_soft_reconfiguration
,
6545 neighbor_soft_reconfiguration_cmd
,
6546 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6547 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6548 "Per neighbor soft reconfiguration\n"
6549 "Allow inbound soft reconfiguration for this neighbor\n")
6552 char base_xpath
[XPATH_MAXLEN
];
6553 char af_xpath
[XPATH_MAXLEN
];
6554 char soft_xpath
[XPATH_MAXLEN
];
6555 afi_t afi
= bgp_node_afi(vty
);
6556 safi_t safi
= bgp_node_safi(vty
);
6558 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6559 yang_afi_safi_value2identity(afi
, safi
));
6561 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6562 sizeof(base_xpath
), af_xpath
)
6564 return CMD_WARNING_CONFIG_FAILED
;
6566 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6567 bgp_afi_safi_get_container_str(afi
, safi
));
6569 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6571 return nb_cli_apply_changes(vty
, base_xpath
);
6574 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6575 neighbor_soft_reconfiguration_hidden_cmd
,
6576 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6578 "Per neighbor soft reconfiguration\n"
6579 "Allow inbound soft reconfiguration for this neighbor\n")
6581 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6582 no_neighbor_soft_reconfiguration_cmd
,
6583 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6584 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6585 "Per neighbor soft reconfiguration\n"
6586 "Allow inbound soft reconfiguration for this neighbor\n")
6589 char base_xpath
[XPATH_MAXLEN
];
6590 char af_xpath
[XPATH_MAXLEN
];
6591 char soft_xpath
[XPATH_MAXLEN
];
6592 afi_t afi
= bgp_node_afi(vty
);
6593 safi_t safi
= bgp_node_safi(vty
);
6595 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6596 yang_afi_safi_value2identity(afi
, safi
));
6598 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6599 bgp_afi_safi_get_container_str(afi
, safi
));
6601 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6602 sizeof(base_xpath
), af_xpath
)
6604 return CMD_WARNING_CONFIG_FAILED
;
6606 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6608 return nb_cli_apply_changes(vty
, base_xpath
);
6611 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6612 no_neighbor_soft_reconfiguration_hidden_cmd
,
6613 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6614 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6615 "Per neighbor soft reconfiguration\n"
6616 "Allow inbound soft reconfiguration for this neighbor\n")
6618 DEFUN_YANG (neighbor_route_reflector_client
,
6619 neighbor_route_reflector_client_cmd
,
6620 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6623 "Configure a neighbor as Route Reflector client\n")
6626 char base_xpath
[XPATH_MAXLEN
];
6627 char af_xpath
[XPATH_MAXLEN
];
6628 char attr_xpath
[XPATH_MAXLEN
];
6629 afi_t afi
= bgp_node_afi(vty
);
6630 safi_t safi
= bgp_node_safi(vty
);
6632 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6633 yang_afi_safi_value2identity(afi
, safi
));
6635 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6636 sizeof(base_xpath
), af_xpath
)
6638 return CMD_WARNING_CONFIG_FAILED
;
6640 snprintf(attr_xpath
, sizeof(attr_xpath
),
6641 "./%s/route-reflector/route-reflector-client",
6642 bgp_afi_safi_get_container_str(afi
, safi
));
6644 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6646 return nb_cli_apply_changes(vty
, base_xpath
);
6649 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6650 neighbor_route_reflector_client_hidden_cmd
,
6651 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6652 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6653 "Configure a neighbor as Route Reflector client\n")
6655 DEFUN_YANG (no_neighbor_route_reflector_client
,
6656 no_neighbor_route_reflector_client_cmd
,
6657 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6661 "Configure a neighbor as Route Reflector client\n")
6664 char base_xpath
[XPATH_MAXLEN
];
6665 char af_xpath
[XPATH_MAXLEN
];
6666 char attr_xpath
[XPATH_MAXLEN
];
6667 afi_t afi
= bgp_node_afi(vty
);
6668 safi_t safi
= bgp_node_safi(vty
);
6670 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6671 yang_afi_safi_value2identity(afi
, safi
));
6673 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6674 sizeof(base_xpath
), af_xpath
)
6676 return CMD_WARNING_CONFIG_FAILED
;
6678 snprintf(attr_xpath
, sizeof(attr_xpath
),
6679 "./%s/route-reflector/route-reflector-client",
6680 bgp_afi_safi_get_container_str(afi
, safi
));
6682 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6684 return nb_cli_apply_changes(vty
, base_xpath
);
6687 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6688 no_neighbor_route_reflector_client_hidden_cmd
,
6689 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6690 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6691 "Configure a neighbor as Route Reflector client\n")
6693 /* neighbor route-server-client. */
6694 DEFUN_YANG (neighbor_route_server_client
,
6695 neighbor_route_server_client_cmd
,
6696 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6699 "Configure a neighbor as Route Server client\n")
6702 char base_xpath
[XPATH_MAXLEN
];
6703 char af_xpath
[XPATH_MAXLEN
];
6704 char attr_xpath
[XPATH_MAXLEN
];
6705 afi_t afi
= bgp_node_afi(vty
);
6706 safi_t safi
= bgp_node_safi(vty
);
6708 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6709 yang_afi_safi_value2identity(afi
, safi
));
6711 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6712 sizeof(base_xpath
), af_xpath
)
6714 return CMD_WARNING_CONFIG_FAILED
;
6716 snprintf(attr_xpath
, sizeof(attr_xpath
),
6717 "./%s/route-server/route-server-client",
6718 bgp_afi_safi_get_container_str(afi
, safi
));
6720 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6722 return nb_cli_apply_changes(vty
, base_xpath
);
6725 ALIAS_HIDDEN(neighbor_route_server_client
,
6726 neighbor_route_server_client_hidden_cmd
,
6727 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6728 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6729 "Configure a neighbor as Route Server client\n")
6731 DEFUN_YANG (no_neighbor_route_server_client
,
6732 no_neighbor_route_server_client_cmd
,
6733 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6737 "Configure a neighbor as Route Server client\n")
6740 char base_xpath
[XPATH_MAXLEN
];
6741 char af_xpath
[XPATH_MAXLEN
];
6742 char attr_xpath
[XPATH_MAXLEN
];
6743 afi_t afi
= bgp_node_afi(vty
);
6744 safi_t safi
= bgp_node_safi(vty
);
6746 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6747 yang_afi_safi_value2identity(afi
, safi
));
6749 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6750 sizeof(base_xpath
), af_xpath
)
6752 return CMD_WARNING_CONFIG_FAILED
;
6754 snprintf(attr_xpath
, sizeof(attr_xpath
),
6755 "./%s/route-server/route-server-client",
6756 bgp_afi_safi_get_container_str(afi
, safi
));
6758 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6760 return nb_cli_apply_changes(vty
, base_xpath
);
6763 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6764 no_neighbor_route_server_client_hidden_cmd
,
6765 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6766 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6767 "Configure a neighbor as Route Server client\n")
6769 DEFUN (neighbor_nexthop_local_unchanged
,
6770 neighbor_nexthop_local_unchanged_cmd
,
6771 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6774 "Configure treatment of outgoing link-local nexthop attribute\n"
6775 "Leave link-local nexthop unchanged for this peer\n")
6778 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6780 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6783 DEFUN (no_neighbor_nexthop_local_unchanged
,
6784 no_neighbor_nexthop_local_unchanged_cmd
,
6785 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6789 "Configure treatment of outgoing link-local-nexthop attribute\n"
6790 "Leave link-local nexthop unchanged for this peer\n")
6793 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6794 bgp_node_afi(vty
), bgp_node_safi(vty
),
6795 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6798 DEFUN_YANG (neighbor_attr_unchanged
,
6799 neighbor_attr_unchanged_cmd
,
6800 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6803 "BGP attribute is propagated unchanged to this neighbor\n"
6804 "As-path attribute\n"
6805 "Nexthop attribute\n"
6809 char *peer_str
= argv
[1]->arg
;
6810 bool aspath
= false;
6811 bool nexthop
= false;
6813 afi_t afi
= bgp_node_afi(vty
);
6814 safi_t safi
= bgp_node_safi(vty
);
6815 char base_xpath
[XPATH_MAXLEN
];
6816 char af_xpath
[XPATH_MAXLEN
];
6817 char as_xpath
[XPATH_MAXLEN
];
6818 char nxthop_xpath
[XPATH_MAXLEN
];
6819 char med_xpath
[XPATH_MAXLEN
];
6821 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6822 yang_afi_safi_value2identity(afi
, safi
));
6824 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6825 sizeof(base_xpath
), af_xpath
)
6827 return CMD_WARNING_CONFIG_FAILED
;
6829 if (argv_find(argv
, argc
, "as-path", &idx
))
6833 if (argv_find(argv
, argc
, "next-hop", &idx
))
6837 if (argv_find(argv
, argc
, "med", &idx
))
6840 snprintf(as_xpath
, sizeof(as_xpath
),
6841 "./%s/attr-unchanged/as-path-unchanged",
6842 bgp_afi_safi_get_container_str(afi
, safi
));
6843 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6844 "./%s/attr-unchanged/next-hop-unchanged",
6845 bgp_afi_safi_get_container_str(afi
, safi
));
6846 snprintf(med_xpath
, sizeof(med_xpath
),
6847 "./%s/attr-unchanged/med-unchanged",
6848 bgp_afi_safi_get_container_str(afi
, safi
));
6850 /* no flags means all of them! */
6851 if (!aspath
&& !nexthop
&& !med
) {
6852 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6853 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6854 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6857 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6860 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6864 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6867 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6871 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6874 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6878 return nb_cli_apply_changes(vty
, base_xpath
);
6882 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6883 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6884 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6885 "BGP attribute is propagated unchanged to this neighbor\n"
6886 "As-path attribute\n"
6887 "Nexthop attribute\n"
6890 DEFUN_YANG (no_neighbor_attr_unchanged
,
6891 no_neighbor_attr_unchanged_cmd
,
6892 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6896 "BGP attribute is propagated unchanged to this neighbor\n"
6897 "As-path attribute\n"
6898 "Nexthop attribute\n"
6902 char *peer_str
= argv
[2]->arg
;
6903 bool aspath
= false;
6904 bool nexthop
= false;
6906 afi_t afi
= bgp_node_afi(vty
);
6907 safi_t safi
= bgp_node_safi(vty
);
6908 char base_xpath
[XPATH_MAXLEN
];
6909 char af_xpath
[XPATH_MAXLEN
];
6910 char as_xpath
[XPATH_MAXLEN
];
6911 char nxthop_xpath
[XPATH_MAXLEN
];
6912 char med_xpath
[XPATH_MAXLEN
];
6914 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6915 yang_afi_safi_value2identity(afi
, safi
));
6917 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6918 sizeof(base_xpath
), af_xpath
)
6920 return CMD_WARNING_CONFIG_FAILED
;
6922 if (argv_find(argv
, argc
, "as-path", &idx
))
6926 if (argv_find(argv
, argc
, "next-hop", &idx
))
6930 if (argv_find(argv
, argc
, "med", &idx
))
6933 snprintf(as_xpath
, sizeof(as_xpath
),
6934 "./%s/attr-unchanged/as-path-unchanged",
6935 bgp_afi_safi_get_container_str(afi
, safi
));
6936 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6937 "./%s/attr-unchanged/next-hop-unchanged",
6938 bgp_afi_safi_get_container_str(afi
, safi
));
6939 snprintf(med_xpath
, sizeof(med_xpath
),
6940 "./%s/attr-unchanged/med-unchanged",
6941 bgp_afi_safi_get_container_str(afi
, safi
));
6943 /* no flags means all of them! */
6944 if (!aspath
&& !nexthop
&& !med
) {
6945 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6946 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6947 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6951 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6954 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6957 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6959 return nb_cli_apply_changes(vty
, base_xpath
);
6963 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6964 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6965 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6966 "BGP attribute is propagated unchanged to this neighbor\n"
6967 "As-path attribute\n"
6968 "Nexthop attribute\n"
6971 /* neighbor ebgp-multihop. */
6972 DEFUN_YANG (neighbor_ebgp_multihop
,
6973 neighbor_ebgp_multihop_cmd
,
6974 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6975 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6976 "Allow EBGP neighbors not on directly connected networks\n")
6979 char base_xpath
[XPATH_MAXLEN
];
6981 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6982 sizeof(base_xpath
), NULL
)
6984 return CMD_WARNING_CONFIG_FAILED
;
6986 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6989 return nb_cli_apply_changes(vty
, base_xpath
);
6992 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6993 neighbor_ebgp_multihop_ttl_cmd
,
6994 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6995 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6996 "Allow EBGP neighbors not on directly connected networks\n"
6997 "maximum hop count\n")
7001 char base_xpath
[XPATH_MAXLEN
];
7003 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7004 sizeof(base_xpath
), NULL
)
7006 return CMD_WARNING_CONFIG_FAILED
;
7008 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
7009 argv
[idx_number
]->arg
);
7011 return nb_cli_apply_changes(vty
, base_xpath
);
7014 DEFUN_YANG (no_neighbor_ebgp_multihop
,
7015 no_neighbor_ebgp_multihop_cmd
,
7016 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
7017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7018 "Allow EBGP neighbors not on directly connected networks\n"
7019 "maximum hop count\n")
7022 char base_xpath
[XPATH_MAXLEN
];
7024 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7025 sizeof(base_xpath
), NULL
)
7027 return CMD_WARNING_CONFIG_FAILED
;
7030 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
7031 NB_OP_DESTROY
, NULL
);
7033 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
7034 NB_OP_MODIFY
, "false");
7036 return nb_cli_apply_changes(vty
, base_xpath
);
7040 /* disable-connected-check */
7041 DEFUN_YANG (neighbor_disable_connected_check
,
7042 neighbor_disable_connected_check_cmd
,
7043 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
7044 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7045 "one-hop away EBGP peer using loopback address\n"
7046 "Enforce EBGP neighbors perform multihop\n")
7049 char base_xpath
[XPATH_MAXLEN
];
7051 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7052 sizeof(base_xpath
), NULL
)
7054 return CMD_WARNING_CONFIG_FAILED
;
7056 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
7057 NB_OP_MODIFY
, "true");
7059 return nb_cli_apply_changes(vty
, base_xpath
);
7062 DEFUN_YANG (no_neighbor_disable_connected_check
,
7063 no_neighbor_disable_connected_check_cmd
,
7064 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
7065 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7066 "one-hop away EBGP peer using loopback address\n"
7067 "Enforce EBGP neighbors perform multihop\n")
7070 char base_xpath
[XPATH_MAXLEN
];
7072 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7073 sizeof(base_xpath
), NULL
)
7075 return CMD_WARNING_CONFIG_FAILED
;
7077 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
7078 NB_OP_MODIFY
, "false");
7080 return nb_cli_apply_changes(vty
, base_xpath
);
7084 /* enforce-first-as */
7085 DEFUN_YANG (neighbor_enforce_first_as
,
7086 neighbor_enforce_first_as_cmd
,
7087 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
7088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7089 "Enforce the first AS for EBGP routes\n")
7092 char base_xpath
[XPATH_MAXLEN
];
7094 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7095 sizeof(base_xpath
), NULL
)
7097 return CMD_WARNING_CONFIG_FAILED
;
7099 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
7101 return nb_cli_apply_changes(vty
, base_xpath
);
7104 DEFUN_YANG (no_neighbor_enforce_first_as
,
7105 no_neighbor_enforce_first_as_cmd
,
7106 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
7107 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7108 "Enforce the first AS for EBGP routes\n")
7111 char base_xpath
[XPATH_MAXLEN
];
7113 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7114 sizeof(base_xpath
), NULL
)
7116 return CMD_WARNING_CONFIG_FAILED
;
7118 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
7120 return nb_cli_apply_changes(vty
, base_xpath
);
7123 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
7124 char *base_xpath
, int xpath_len
,
7128 char num_xpath
[XPATH_MAXLEN
];
7129 char unnbr_xpath
[XPATH_MAXLEN
];
7130 char prgrp_xpath
[XPATH_MAXLEN
];
7132 if (str2sockunion(peer_str
, &su
) == 0) {
7133 snprintf(num_xpath
, sizeof(num_xpath
),
7134 "/neighbors/neighbor[remote-address='%s']", peer_str
);
7135 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
7136 VTY_CURR_XPATH
, num_xpath
)) {
7137 snprintf(base_xpath
, xpath_len
,
7138 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
7139 xpath
? xpath
: "");
7142 "%% Specify remote-as or peer-group commands first\n");
7147 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
7148 "/neighbors/unnumbered-neighbor[interface='%s']",
7151 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
7152 "/peer-groups/peer-group[peer-group-name='%s']",
7155 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
7156 VTY_CURR_XPATH
, unnbr_xpath
)) {
7157 snprintf(base_xpath
, xpath_len
,
7158 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
7159 xpath
? xpath
: "");
7160 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
7161 "%s%s", VTY_CURR_XPATH
,
7163 snprintf(base_xpath
, xpath_len
,
7164 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
7165 xpath
? xpath
: "");
7168 "%% Create the peer-group or interface first\n");
7176 DEFUN_YANG (neighbor_description
,
7177 neighbor_description_cmd
,
7178 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7179 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7180 "Neighbor specific description\n"
7181 "Up to 80 characters describing this neighbor\n")
7186 char base_xpath
[XPATH_MAXLEN
];
7189 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7190 sizeof(base_xpath
), NULL
)
7192 return CMD_WARNING_CONFIG_FAILED
;
7194 str
= argv_concat(argv
, argc
, idx_line
);
7196 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
7198 ret
= nb_cli_apply_changes(vty
, base_xpath
);
7200 XFREE(MTYPE_TMP
, str
);
7205 DEFUN_YANG (no_neighbor_description
,
7206 no_neighbor_description_cmd
,
7207 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
7208 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7209 "Neighbor specific description\n")
7212 char base_xpath
[XPATH_MAXLEN
];
7214 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7215 sizeof(base_xpath
), NULL
)
7217 return CMD_WARNING_CONFIG_FAILED
;
7219 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7221 return nb_cli_apply_changes(vty
, base_xpath
);
7224 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7225 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7227 "Neighbor specific description\n"
7228 "Up to 80 characters describing this neighbor\n")
7230 #define BGP_UPDATE_SOURCE_HELP_STR \
7233 "Interface name (requires zebra to be running)\n"
7235 DEFUN_YANG (neighbor_update_source
,
7236 neighbor_update_source_cmd
,
7237 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7238 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7239 "Source of routing updates\n"
7240 BGP_UPDATE_SOURCE_HELP_STR
)
7245 char base_xpath
[XPATH_MAXLEN
];
7247 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7248 sizeof(base_xpath
), NULL
)
7250 return CMD_WARNING_CONFIG_FAILED
;
7252 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7253 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7254 argv
[idx_peer_2
]->arg
);
7256 nb_cli_enqueue_change(vty
, "./update-source/interface",
7257 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7259 return nb_cli_apply_changes(vty
, base_xpath
);
7262 DEFUN_YANG (no_neighbor_update_source
,
7263 no_neighbor_update_source_cmd
,
7264 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7267 "Source of routing updates\n"
7268 BGP_UPDATE_SOURCE_HELP_STR
)
7271 char base_xpath
[XPATH_MAXLEN
];
7273 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7274 sizeof(base_xpath
), NULL
)
7276 return CMD_WARNING_CONFIG_FAILED
;
7278 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7279 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7282 return nb_cli_apply_changes(vty
, base_xpath
);
7285 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7286 afi_t afi
, safi_t safi
,
7287 const char *rmap
, int set
)
7291 struct route_map
*route_map
= NULL
;
7293 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7295 return CMD_WARNING_CONFIG_FAILED
;
7299 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7300 ret
= peer_default_originate_set(peer
, afi
, safi
,
7303 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7305 return bgp_vty_return(vty
, ret
);
7308 /* neighbor default-originate. */
7309 DEFUN (neighbor_default_originate
,
7310 neighbor_default_originate_cmd
,
7311 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7314 "Originate default route to this neighbor\n")
7317 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7319 bgp_node_safi(vty
), NULL
, 1);
7322 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7323 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7324 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7325 "Originate default route to this neighbor\n")
7327 DEFUN (neighbor_default_originate_rmap
,
7328 neighbor_default_originate_rmap_cmd
,
7329 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7332 "Originate default route to this neighbor\n"
7333 "Route-map to specify criteria to originate default\n"
7338 return peer_default_originate_set_vty(
7339 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7340 argv
[idx_word
]->arg
, 1);
7344 neighbor_default_originate_rmap
,
7345 neighbor_default_originate_rmap_hidden_cmd
,
7346 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7347 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7348 "Originate default route to this neighbor\n"
7349 "Route-map to specify criteria to originate default\n"
7352 DEFUN (no_neighbor_default_originate
,
7353 no_neighbor_default_originate_cmd
,
7354 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7358 "Originate default route to this neighbor\n"
7359 "Route-map to specify criteria to originate default\n"
7363 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7365 bgp_node_safi(vty
), NULL
, 0);
7369 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7370 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7372 "Originate default route to this neighbor\n"
7373 "Route-map to specify criteria to originate default\n"
7377 /* Set specified peer's BGP port. */
7378 DEFUN_YANG (neighbor_port
,
7380 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7383 "Neighbor's BGP port\n"
7384 "TCP port number\n")
7388 char base_xpath
[XPATH_MAXLEN
];
7390 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7391 argv
[idx_ip
]->arg
, "");
7393 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7394 argv
[idx_number
]->arg
);
7396 return nb_cli_apply_changes(vty
, base_xpath
);
7399 DEFUN_YANG (no_neighbor_port
,
7400 no_neighbor_port_cmd
,
7401 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7402 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7403 "Neighbor's BGP port\n"
7404 "TCP port number\n")
7407 char base_xpath
[XPATH_MAXLEN
];
7409 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7410 argv
[idx_ip
]->arg
, "");
7412 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7414 return nb_cli_apply_changes(vty
, base_xpath
);
7417 DEFUN_YANG (neighbor_weight
,
7418 neighbor_weight_cmd
,
7419 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7420 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7421 "Set default weight for routes from this neighbor\n"
7426 char base_xpath
[XPATH_MAXLEN
];
7427 char af_xpath
[XPATH_MAXLEN
];
7428 char attr_xpath
[XPATH_MAXLEN
];
7429 afi_t afi
= bgp_node_afi(vty
);
7430 safi_t safi
= bgp_node_safi(vty
);
7432 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7433 yang_afi_safi_value2identity(afi
, safi
));
7435 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7436 sizeof(base_xpath
), af_xpath
)
7438 return CMD_WARNING_CONFIG_FAILED
;
7440 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7441 bgp_afi_safi_get_container_str(afi
, safi
));
7443 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7444 argv
[idx_number
]->arg
);
7446 return nb_cli_apply_changes(vty
, base_xpath
);
7449 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7450 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7451 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7452 "Set default weight for routes from this neighbor\n"
7455 DEFUN_YANG (no_neighbor_weight
,
7456 no_neighbor_weight_cmd
,
7457 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7458 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7459 "Set default weight for routes from this neighbor\n"
7463 char base_xpath
[XPATH_MAXLEN
];
7464 char af_xpath
[XPATH_MAXLEN
];
7465 char attr_xpath
[XPATH_MAXLEN
];
7466 afi_t afi
= bgp_node_afi(vty
);
7467 safi_t safi
= bgp_node_safi(vty
);
7469 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7470 yang_afi_safi_value2identity(afi
, safi
));
7472 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7473 sizeof(base_xpath
), af_xpath
)
7475 return CMD_WARNING_CONFIG_FAILED
;
7477 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7478 bgp_afi_safi_get_container_str(afi
, safi
));
7480 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7482 return nb_cli_apply_changes(vty
, base_xpath
);
7485 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7486 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7487 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7488 "Set default weight for routes from this neighbor\n"
7492 /* Override capability negotiation. */
7493 DEFUN_YANG (neighbor_override_capability
,
7494 neighbor_override_capability_cmd
,
7495 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7498 "Override capability negotiation result\n")
7501 char base_xpath
[XPATH_MAXLEN
];
7503 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7504 sizeof(base_xpath
), NULL
)
7506 return CMD_WARNING_CONFIG_FAILED
;
7508 nb_cli_enqueue_change(
7509 vty
, "./capability-options/override-capability",
7510 NB_OP_MODIFY
, "true");
7512 return nb_cli_apply_changes(vty
, base_xpath
);
7515 DEFUN_YANG (no_neighbor_override_capability
,
7516 no_neighbor_override_capability_cmd
,
7517 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7521 "Override capability negotiation result\n")
7524 char base_xpath
[XPATH_MAXLEN
];
7526 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7527 sizeof(base_xpath
), NULL
)
7529 return CMD_WARNING_CONFIG_FAILED
;
7531 nb_cli_enqueue_change(
7532 vty
, "./capability-options/override-capability",
7533 NB_OP_MODIFY
, "false");
7535 return nb_cli_apply_changes(vty
, base_xpath
);
7538 DEFUN_YANG (neighbor_strict_capability
,
7539 neighbor_strict_capability_cmd
,
7540 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7543 "Strict capability negotiation match\n")
7546 char base_xpath
[XPATH_MAXLEN
];
7548 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7549 sizeof(base_xpath
), NULL
)
7551 return CMD_WARNING_CONFIG_FAILED
;
7553 nb_cli_enqueue_change(
7554 vty
, "./capability-options/strict-capability",
7555 NB_OP_MODIFY
, "true");
7557 return nb_cli_apply_changes(vty
, base_xpath
);
7560 DEFUN_YANG (no_neighbor_strict_capability
,
7561 no_neighbor_strict_capability_cmd
,
7562 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7566 "Strict capability negotiation match\n")
7569 char base_xpath
[XPATH_MAXLEN
];
7571 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7572 sizeof(base_xpath
), NULL
)
7574 return CMD_WARNING_CONFIG_FAILED
;
7576 nb_cli_enqueue_change(
7577 vty
, "./capability-options/strict-capability",
7578 NB_OP_MODIFY
, "false");
7580 return nb_cli_apply_changes(vty
, base_xpath
);
7583 DEFUN_YANG (neighbor_timers
,
7584 neighbor_timers_cmd
,
7585 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7586 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7587 "BGP per neighbor timers\n"
7588 "Keepalive interval\n"
7593 int idx_number_2
= 4;
7594 char base_xpath
[XPATH_MAXLEN
];
7596 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7597 sizeof(base_xpath
), NULL
)
7599 return CMD_WARNING_CONFIG_FAILED
;
7601 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7602 argv
[idx_number
]->arg
);
7604 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7605 argv
[idx_number_2
]->arg
);
7607 return nb_cli_apply_changes(vty
, base_xpath
);
7610 DEFUN_YANG (no_neighbor_timers
,
7611 no_neighbor_timers_cmd
,
7612 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7613 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7614 "BGP per neighbor timers\n"
7615 "Keepalive interval\n"
7619 char base_xpath
[XPATH_MAXLEN
];
7621 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7622 sizeof(base_xpath
), NULL
)
7624 return CMD_WARNING_CONFIG_FAILED
;
7626 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7628 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7630 return nb_cli_apply_changes(vty
, base_xpath
);
7633 DEFUN_YANG (neighbor_timers_connect
,
7634 neighbor_timers_connect_cmd
,
7635 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7636 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7637 "BGP per neighbor timers\n"
7638 "BGP connect timer\n"
7643 char base_xpath
[XPATH_MAXLEN
];
7645 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7646 sizeof(base_xpath
), NULL
)
7648 return CMD_WARNING_CONFIG_FAILED
;
7650 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7651 argv
[idx_number
]->arg
);
7653 return nb_cli_apply_changes(vty
, base_xpath
);
7656 DEFUN_YANG (no_neighbor_timers_connect
,
7657 no_neighbor_timers_connect_cmd
,
7658 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7659 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7660 "BGP per neighbor timers\n"
7661 "BGP connect timer\n"
7665 char base_xpath
[XPATH_MAXLEN
];
7667 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7668 sizeof(base_xpath
), NULL
)
7670 return CMD_WARNING_CONFIG_FAILED
;
7672 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7675 return nb_cli_apply_changes(vty
, base_xpath
);
7678 DEFPY (neighbor_timers_delayopen
,
7679 neighbor_timers_delayopen_cmd
,
7680 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7683 "BGP per neighbor timers\n"
7684 "RFC 4271 DelayOpenTimer\n"
7685 "DelayOpenTime timer interval\n")
7689 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7691 return CMD_WARNING_CONFIG_FAILED
;
7694 if (peer_timers_delayopen_unset(peer
))
7695 return CMD_WARNING_CONFIG_FAILED
;
7697 if (peer_timers_delayopen_set(peer
, interval
))
7698 return CMD_WARNING_CONFIG_FAILED
;
7704 DEFPY (no_neighbor_timers_delayopen
,
7705 no_neighbor_timers_delayopen_cmd
,
7706 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7710 "BGP per neighbor timers\n"
7711 "RFC 4271 DelayOpenTimer\n"
7712 "DelayOpenTime timer interval\n")
7716 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7718 return CMD_WARNING_CONFIG_FAILED
;
7720 if (peer_timers_delayopen_unset(peer
))
7721 return CMD_WARNING_CONFIG_FAILED
;
7726 DEFUN_YANG (neighbor_advertise_interval
,
7727 neighbor_advertise_interval_cmd
,
7728 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7729 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7730 "Minimum interval between sending BGP routing updates\n"
7731 "time in seconds\n")
7735 char base_xpath
[XPATH_MAXLEN
];
7737 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7738 sizeof(base_xpath
), NULL
)
7740 return CMD_WARNING_CONFIG_FAILED
;
7742 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7743 argv
[idx_number
]->arg
);
7745 return nb_cli_apply_changes(vty
, base_xpath
);
7748 DEFUN_YANG (no_neighbor_advertise_interval
,
7749 no_neighbor_advertise_interval_cmd
,
7750 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7751 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7752 "Minimum interval between sending BGP routing updates\n"
7753 "time in seconds\n")
7756 char base_xpath
[XPATH_MAXLEN
];
7758 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7759 sizeof(base_xpath
), NULL
)
7761 return CMD_WARNING_CONFIG_FAILED
;
7763 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7766 return nb_cli_apply_changes(vty
, base_xpath
);
7770 /* Time to wait before processing route-map updates */
7771 DEFUN (bgp_set_route_map_delay_timer
,
7772 bgp_set_route_map_delay_timer_cmd
,
7773 "bgp route-map delay-timer (0-600)",
7775 "BGP route-map delay timer\n"
7776 "Time in secs to wait before processing route-map changes\n"
7777 "0 disables the timer, no route updates happen when route-maps change\n")
7780 uint32_t rmap_delay_timer
;
7782 if (argv
[idx_number
]->arg
) {
7783 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7784 bm
->rmap_update_timer
= rmap_delay_timer
;
7786 /* if the dynamic update handling is being disabled, and a timer
7788 * running, stop the timer and act as if the timer has already
7791 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7792 BGP_TIMER_OFF(bm
->t_rmap_update
);
7793 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7798 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7799 return CMD_WARNING_CONFIG_FAILED
;
7803 DEFUN (no_bgp_set_route_map_delay_timer
,
7804 no_bgp_set_route_map_delay_timer_cmd
,
7805 "no bgp route-map delay-timer [(0-600)]",
7808 "Default BGP route-map delay timer\n"
7809 "Reset to default time to wait for processing route-map changes\n"
7810 "0 disables the timer, no route updates happen when route-maps change\n")
7813 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7818 DEFUN_YANG (neighbor_interface
,
7819 neighbor_interface_cmd
,
7820 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7821 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7827 char base_xpath
[XPATH_MAXLEN
];
7829 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7830 argv
[idx_ip
]->arg
, "");
7832 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7833 argv
[idx_word
]->arg
);
7835 return nb_cli_apply_changes(vty
, base_xpath
);
7838 DEFUN_YANG (no_neighbor_interface
,
7839 no_neighbor_interface_cmd
,
7840 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7841 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7846 char base_xpath
[XPATH_MAXLEN
];
7848 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7849 argv
[idx_peer
]->arg
, "");
7851 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7853 return nb_cli_apply_changes(vty
, base_xpath
);
7856 DEFUN (neighbor_distribute_list
,
7857 neighbor_distribute_list_cmd
,
7858 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7861 "Filter updates to/from this neighbor\n"
7862 "IP access-list number\n"
7863 "IP access-list number (expanded range)\n"
7864 "IP Access-list name\n"
7865 "Filter incoming updates\n"
7866 "Filter outgoing updates\n")
7873 const char *pstr
= argv
[idx_peer
]->arg
;
7874 const char *acl
= argv
[idx_acl
]->arg
;
7875 const char *inout
= argv
[argc
- 1]->text
;
7877 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7879 return CMD_WARNING_CONFIG_FAILED
;
7881 /* Check filter direction. */
7882 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7883 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7886 return bgp_vty_return(vty
, ret
);
7890 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7891 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7892 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7893 "Filter updates to/from this neighbor\n"
7894 "IP access-list number\n"
7895 "IP access-list number (expanded range)\n"
7896 "IP Access-list name\n"
7897 "Filter incoming updates\n"
7898 "Filter outgoing updates\n")
7900 DEFUN (no_neighbor_distribute_list
,
7901 no_neighbor_distribute_list_cmd
,
7902 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7906 "Filter updates to/from this neighbor\n"
7907 "IP access-list number\n"
7908 "IP access-list number (expanded range)\n"
7909 "IP Access-list name\n"
7910 "Filter incoming updates\n"
7911 "Filter outgoing updates\n")
7917 const char *pstr
= argv
[idx_peer
]->arg
;
7918 const char *inout
= argv
[argc
- 1]->text
;
7920 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7922 return CMD_WARNING_CONFIG_FAILED
;
7924 /* Check filter direction. */
7925 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7926 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7929 return bgp_vty_return(vty
, ret
);
7933 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7934 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7935 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7936 "Filter updates to/from this neighbor\n"
7937 "IP access-list number\n"
7938 "IP access-list number (expanded range)\n"
7939 "IP Access-list name\n"
7940 "Filter incoming updates\n"
7941 "Filter outgoing updates\n")
7943 /* Set prefix list to the peer. */
7945 neighbor_prefix_list
, neighbor_prefix_list_cmd
,
7946 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction",
7947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7948 "Filter updates to/from this neighbor\n"
7949 "Name of a prefix list\n"
7950 "Filter incoming updates\n"
7951 "Filter outgoing updates\n")
7953 char base_xpath
[XPATH_MAXLEN
];
7954 char af_xpath
[XPATH_MAXLEN
];
7955 char plist_xpath
[XPATH_MAXLEN
];
7956 afi_t afi
= bgp_node_afi(vty
);
7957 safi_t safi
= bgp_node_safi(vty
);
7959 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7960 yang_afi_safi_value2identity(afi
, safi
));
7961 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
7962 sizeof(base_xpath
), af_xpath
)
7964 return CMD_WARNING_CONFIG_FAILED
;
7966 if (strmatch(direction
, "in"))
7967 snprintf(plist_xpath
, sizeof(plist_xpath
),
7968 "./%s/filter-config/plist-import",
7969 bgp_afi_safi_get_container_str(afi
, safi
));
7970 else if (strmatch(direction
, "out"))
7971 snprintf(plist_xpath
, sizeof(plist_xpath
),
7972 "./%s/filter-config/plist-export",
7973 bgp_afi_safi_get_container_str(afi
, safi
));
7976 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_MODIFY
,
7979 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_DESTROY
, NULL
);
7981 return nb_cli_apply_changes(vty
, base_xpath
);
7984 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7985 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7986 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7987 "Filter updates to/from this neighbor\n"
7988 "Name of a prefix list\n"
7989 "Filter incoming updates\n"
7990 "Filter outgoing updates\n")
7992 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7993 safi_t safi
, const char *name_str
,
7994 const char *direct_str
)
7998 int direct
= FILTER_IN
;
8000 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8002 return CMD_WARNING_CONFIG_FAILED
;
8004 /* Check filter direction. */
8005 if (strncmp(direct_str
, "i", 1) == 0)
8007 else if (strncmp(direct_str
, "o", 1) == 0)
8008 direct
= FILTER_OUT
;
8010 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
8012 return bgp_vty_return(vty
, ret
);
8015 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
8016 safi_t safi
, const char *direct_str
)
8020 int direct
= FILTER_IN
;
8022 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8024 return CMD_WARNING_CONFIG_FAILED
;
8026 /* Check filter direction. */
8027 if (strncmp(direct_str
, "i", 1) == 0)
8029 else if (strncmp(direct_str
, "o", 1) == 0)
8030 direct
= FILTER_OUT
;
8032 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
8034 return bgp_vty_return(vty
, ret
);
8037 DEFUN (neighbor_filter_list
,
8038 neighbor_filter_list_cmd
,
8039 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8042 "Establish BGP filters\n"
8043 "AS path access-list name\n"
8044 "Filter incoming routes\n"
8045 "Filter outgoing routes\n")
8050 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
8051 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
8052 argv
[idx_in_out
]->arg
);
8055 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
8056 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8057 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8058 "Establish BGP filters\n"
8059 "AS path access-list name\n"
8060 "Filter incoming routes\n"
8061 "Filter outgoing routes\n")
8063 DEFUN (no_neighbor_filter_list
,
8064 no_neighbor_filter_list_cmd
,
8065 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8069 "Establish BGP filters\n"
8070 "AS path access-list name\n"
8071 "Filter incoming routes\n"
8072 "Filter outgoing routes\n")
8076 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
8077 bgp_node_afi(vty
), bgp_node_safi(vty
),
8078 argv
[idx_in_out
]->arg
);
8081 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
8082 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8083 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8084 "Establish BGP filters\n"
8085 "AS path access-list name\n"
8086 "Filter incoming routes\n"
8087 "Filter outgoing routes\n")
8089 /* Set advertise-map to the peer. */
8090 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
8091 afi_t afi
, safi_t safi
,
8092 const char *advertise_str
,
8093 const char *condition_str
, bool condition
,
8096 int ret
= CMD_WARNING_CONFIG_FAILED
;
8098 struct route_map
*advertise_map
;
8099 struct route_map
*condition_map
;
8101 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8105 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
8106 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
8109 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
8110 advertise_map
, condition_str
,
8111 condition_map
, condition
);
8113 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
8114 advertise_map
, condition_str
,
8115 condition_map
, condition
);
8117 return bgp_vty_return(vty
, ret
);
8120 DEFPY (bgp_condadv_period
,
8121 bgp_condadv_period_cmd
,
8122 "[no$no] bgp conditional-advertisement timer (5-240)$period",
8125 "Conditional advertisement settings\n"
8126 "Set period to rescan BGP table to check if condition is met\n"
8127 "Period between BGP table scans, in seconds; default 60\n")
8129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8131 bgp
->condition_check_period
=
8132 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
8137 DEFPY (neighbor_advertise_map
,
8138 neighbor_advertise_map_cmd
,
8139 "[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",
8143 "Route-map to conditionally advertise routes\n"
8144 "Name of advertise map\n"
8145 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8146 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8147 "Name of the exist or non exist map\n")
8149 bool condition
= CONDITION_EXIST
;
8151 if (!strcmp(exist
, "non-exist-map"))
8152 condition
= CONDITION_NON_EXIST
;
8154 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
8155 bgp_node_safi(vty
), advertise_str
,
8156 condition_str
, condition
, !no
);
8159 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
8160 "[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",
8161 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8162 "Route-map to conditionally advertise routes\n"
8163 "Name of advertise map\n"
8164 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8165 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8166 "Name of the exist or non exist map\n")
8168 /* Set route-map to the peer. */
8170 neighbor_route_map
, neighbor_route_map_cmd
,
8171 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction",
8172 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8173 "Apply route map to neighbor\n"
8174 "Name of route map\n"
8175 "Apply map to incoming routes\n"
8176 "Apply map to outbound routes\n")
8178 char base_xpath
[XPATH_MAXLEN
];
8179 char af_xpath
[XPATH_MAXLEN
];
8180 char rmap_xpath
[XPATH_MAXLEN
];
8181 afi_t afi
= bgp_node_afi(vty
);
8182 safi_t safi
= bgp_node_safi(vty
);
8184 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8185 yang_afi_safi_value2identity(afi
, safi
));
8186 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
8187 sizeof(base_xpath
), af_xpath
)
8189 return CMD_WARNING_CONFIG_FAILED
;
8191 if (strmatch(direction
, "in"))
8192 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8193 "./%s/filter-config/rmap-import",
8194 bgp_afi_safi_get_container_str(afi
, safi
));
8195 else if (strmatch(direction
, "out"))
8196 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8197 "./%s/filter-config/rmap-export",
8198 bgp_afi_safi_get_container_str(afi
, safi
));
8201 if (!yang_dnode_existsf(
8202 vty
->candidate_config
->dnode
,
8203 "/frr-route-map:lib/route-map[name='%s']",
8205 if (vty_shell_serv(vty
))
8207 "The route-map '%s' does not exist.\n",
8210 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_MODIFY
, rmap_str
);
8212 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_DESTROY
, NULL
);
8214 return nb_cli_apply_changes(vty
, base_xpath
);
8217 /* Set unsuppress-map to the peer. */
8218 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8219 afi_t afi
, safi_t safi
,
8220 const char *name_str
)
8224 struct route_map
*route_map
;
8226 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8228 return CMD_WARNING_CONFIG_FAILED
;
8230 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8231 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8233 return bgp_vty_return(vty
, ret
);
8236 /* Unset route-map from the peer. */
8237 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8238 afi_t afi
, safi_t safi
)
8243 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8245 return CMD_WARNING_CONFIG_FAILED
;
8247 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8249 return bgp_vty_return(vty
, ret
);
8252 DEFUN (neighbor_unsuppress_map
,
8253 neighbor_unsuppress_map_cmd
,
8254 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8257 "Route-map to selectively unsuppress suppressed routes\n"
8258 "Name of route map\n")
8262 return peer_unsuppress_map_set_vty(
8263 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8264 argv
[idx_word
]->arg
);
8267 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8268 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8269 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8270 "Route-map to selectively unsuppress suppressed routes\n"
8271 "Name of route map\n")
8273 DEFUN (no_neighbor_unsuppress_map
,
8274 no_neighbor_unsuppress_map_cmd
,
8275 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8279 "Route-map to selectively unsuppress suppressed routes\n"
8280 "Name of route map\n")
8283 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8285 bgp_node_safi(vty
));
8288 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8289 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8290 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8291 "Route-map to selectively unsuppress suppressed routes\n"
8292 "Name of route map\n")
8294 /* Maximum number of prefix to be sent to the neighbor. */
8295 DEFUN_YANG(neighbor_maximum_prefix_out
,
8296 neighbor_maximum_prefix_out_cmd
,
8297 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8298 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8299 "Maximum number of prefixes to be sent to this peer\n"
8300 "Maximum no. of prefix limit\n")
8302 char base_xpath
[XPATH_MAXLEN
];
8303 char af_xpath
[XPATH_MAXLEN
];
8304 char attr_xpath
[XPATH_MAXLEN
];
8307 afi_t afi
= bgp_node_afi(vty
);
8308 safi_t safi
= bgp_node_safi(vty
);
8310 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8311 yang_afi_safi_value2identity(afi
, safi
));
8312 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8313 sizeof(base_xpath
), af_xpath
)
8315 return CMD_WARNING_CONFIG_FAILED
;
8317 snprintf(attr_xpath
, sizeof(attr_xpath
),
8318 "/%s/prefix-limit/direction-list[direction='out']",
8319 bgp_afi_safi_get_container_str(afi
, safi
));
8320 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8322 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8324 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8325 argv
[idx_number
]->arg
);
8327 return nb_cli_apply_changes(vty
, base_xpath
);
8330 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8331 no_neighbor_maximum_prefix_out_cmd
,
8332 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8333 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8334 "Maximum number of prefixes to be sent to this peer\n")
8336 char base_xpath
[XPATH_MAXLEN
];
8337 char af_xpath
[XPATH_MAXLEN
];
8338 char attr_xpath
[XPATH_MAXLEN
];
8340 afi_t afi
= bgp_node_afi(vty
);
8341 safi_t safi
= bgp_node_safi(vty
);
8343 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8344 yang_afi_safi_value2identity(afi
, safi
));
8345 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8346 sizeof(base_xpath
), af_xpath
)
8348 return CMD_WARNING_CONFIG_FAILED
;
8350 snprintf(attr_xpath
, sizeof(attr_xpath
),
8351 "/%s/prefix-limit/direction-list[direction='out']",
8352 bgp_afi_safi_get_container_str(afi
, safi
));
8353 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8355 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8357 return nb_cli_apply_changes(vty
, base_xpath
);
8360 /* Maximum number of prefix configuration. Prefix count is different
8361 for each peer configuration. So this configuration can be set for
8362 each peer configuration. */
8363 DEFUN_YANG(neighbor_maximum_prefix
,
8364 neighbor_maximum_prefix_cmd
,
8365 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8366 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8367 "Maximum number of prefix accept from this peer\n"
8368 "maximum no. of prefix limit\n"
8369 "Force checking all received routes not only accepted\n")
8374 char base_xpath
[XPATH_MAXLEN
];
8375 char af_xpath
[XPATH_MAXLEN
];
8376 char attr_xpath
[XPATH_MAXLEN
];
8377 afi_t afi
= bgp_node_afi(vty
);
8378 safi_t safi
= bgp_node_safi(vty
);
8380 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8381 yang_afi_safi_value2identity(afi
, safi
));
8382 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8383 sizeof(base_xpath
), af_xpath
)
8385 return CMD_WARNING_CONFIG_FAILED
;
8387 snprintf(attr_xpath
, sizeof(attr_xpath
),
8388 "/%s/prefix-limit/direction-list[direction='in']",
8389 bgp_afi_safi_get_container_str(afi
, safi
));
8390 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8392 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8394 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8395 argv
[idx_number
]->arg
);
8396 if (argv_find(argv
, argc
, "force", &idx_force
))
8397 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8400 return nb_cli_apply_changes(vty
, base_xpath
);
8403 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8404 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8405 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8406 "Maximum number of prefix accept from this peer\n"
8407 "maximum no. of prefix limit\n"
8408 "Force checking all received routes not only accepted\n")
8410 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8411 neighbor_maximum_prefix_threshold_cmd
,
8412 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8413 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8414 "Maximum number of prefix accept from this peer\n"
8415 "maximum no. of prefix limit\n"
8416 "Threshold value (%) at which to generate a warning msg\n"
8417 "Force checking all received routes not only accepted\n")
8421 int idx_number_2
= 4;
8423 char base_xpath
[XPATH_MAXLEN
];
8424 char af_xpath
[XPATH_MAXLEN
];
8425 char attr_xpath
[XPATH_MAXLEN
];
8426 afi_t afi
= bgp_node_afi(vty
);
8427 safi_t safi
= bgp_node_safi(vty
);
8429 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8430 yang_afi_safi_value2identity(afi
, safi
));
8431 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8432 sizeof(base_xpath
), af_xpath
)
8434 return CMD_WARNING_CONFIG_FAILED
;
8436 snprintf(attr_xpath
, sizeof(attr_xpath
),
8437 "/%s/prefix-limit/direction-list[direction='in']",
8438 bgp_afi_safi_get_container_str(afi
, safi
));
8439 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8441 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8443 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8444 argv
[idx_number
]->arg
);
8446 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8447 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8449 if (argv_find(argv
, argc
, "force", &idx_force
))
8450 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8453 return nb_cli_apply_changes(vty
, base_xpath
);
8457 neighbor_maximum_prefix_threshold
,
8458 neighbor_maximum_prefix_threshold_hidden_cmd
,
8459 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8460 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8461 "Maximum number of prefix accept from this peer\n"
8462 "maximum no. of prefix limit\n"
8463 "Threshold value (%) at which to generate a warning msg\n"
8464 "Force checking all received routes not only accepted\n")
8466 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8467 neighbor_maximum_prefix_warning_cmd
,
8468 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8469 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8470 "Maximum number of prefix accept from this peer\n"
8471 "maximum no. of prefix limit\n"
8472 "Only give warning message when limit is exceeded\n"
8473 "Force checking all received routes not only accepted\n")
8478 char base_xpath
[XPATH_MAXLEN
];
8479 char af_xpath
[XPATH_MAXLEN
];
8480 char attr_xpath
[XPATH_MAXLEN
];
8481 afi_t afi
= bgp_node_afi(vty
);
8482 safi_t safi
= bgp_node_safi(vty
);
8484 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8485 yang_afi_safi_value2identity(afi
, safi
));
8486 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8487 sizeof(base_xpath
), af_xpath
)
8489 return CMD_WARNING_CONFIG_FAILED
;
8491 snprintf(attr_xpath
, sizeof(attr_xpath
),
8492 "/%s/prefix-limit/direction-list[direction='in']",
8493 bgp_afi_safi_get_container_str(afi
, safi
));
8494 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8496 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8498 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8499 argv
[idx_number
]->arg
);
8501 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8503 if (argv_find(argv
, argc
, "force", &idx_force
))
8504 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8507 return nb_cli_apply_changes(vty
, base_xpath
);
8511 neighbor_maximum_prefix_warning
,
8512 neighbor_maximum_prefix_warning_hidden_cmd
,
8513 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8514 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8515 "Maximum number of prefix accept from this peer\n"
8516 "maximum no. of prefix limit\n"
8517 "Only give warning message when limit is exceeded\n"
8518 "Force checking all received routes not only accepted\n")
8520 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8521 neighbor_maximum_prefix_threshold_warning_cmd
,
8522 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8523 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8524 "Maximum number of prefix accept from this peer\n"
8525 "maximum no. of prefix limit\n"
8526 "Threshold value (%) at which to generate a warning msg\n"
8527 "Only give warning message when limit is exceeded\n"
8528 "Force checking all received routes not only accepted\n")
8532 int idx_number_2
= 4;
8534 char base_xpath
[XPATH_MAXLEN
];
8535 char af_xpath
[XPATH_MAXLEN
];
8536 char attr_xpath
[XPATH_MAXLEN
];
8537 afi_t afi
= bgp_node_afi(vty
);
8538 safi_t safi
= bgp_node_safi(vty
);
8540 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8541 yang_afi_safi_value2identity(afi
, safi
));
8542 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8543 sizeof(base_xpath
), af_xpath
)
8545 return CMD_WARNING_CONFIG_FAILED
;
8547 snprintf(attr_xpath
, sizeof(attr_xpath
),
8548 "/%s/prefix-limit/direction-list[direction='in']",
8549 bgp_afi_safi_get_container_str(afi
, safi
));
8550 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8552 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8554 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8555 argv
[idx_number
]->arg
);
8556 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8557 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8558 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8560 if (argv_find(argv
, argc
, "force", &idx_force
))
8561 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8564 return nb_cli_apply_changes(vty
, base_xpath
);
8568 neighbor_maximum_prefix_threshold_warning
,
8569 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8570 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8571 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8572 "Maximum number of prefix accept from this peer\n"
8573 "maximum no. of prefix limit\n"
8574 "Threshold value (%) at which to generate a warning msg\n"
8575 "Only give warning message when limit is exceeded\n"
8576 "Force checking all received routes not only accepted\n")
8578 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8579 neighbor_maximum_prefix_restart_cmd
,
8580 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8582 "Maximum number of prefix accept from this peer\n"
8583 "maximum no. of prefix limit\n"
8584 "Restart bgp connection after limit is exceeded\n"
8585 "Restart interval in minutes\n"
8586 "Force checking all received routes not only accepted\n")
8590 int idx_number_2
= 5;
8592 char base_xpath
[XPATH_MAXLEN
];
8593 char af_xpath
[XPATH_MAXLEN
];
8594 char attr_xpath
[XPATH_MAXLEN
];
8595 afi_t afi
= bgp_node_afi(vty
);
8596 safi_t safi
= bgp_node_safi(vty
);
8598 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8599 yang_afi_safi_value2identity(afi
, safi
));
8600 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8601 sizeof(base_xpath
), af_xpath
)
8603 return CMD_WARNING_CONFIG_FAILED
;
8605 snprintf(attr_xpath
, sizeof(attr_xpath
),
8606 "/%s/prefix-limit/direction-list[direction='in']",
8607 bgp_afi_safi_get_container_str(afi
, safi
));
8608 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8610 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8612 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8613 argv
[idx_number
]->arg
);
8614 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8615 argv
[idx_number_2
]->arg
);
8616 if (argv_find(argv
, argc
, "force", &idx_force
))
8617 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8620 return nb_cli_apply_changes(vty
, base_xpath
);
8624 neighbor_maximum_prefix_restart
,
8625 neighbor_maximum_prefix_restart_hidden_cmd
,
8626 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8627 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8628 "Maximum number of prefix accept from this peer\n"
8629 "maximum no. of prefix limit\n"
8630 "Restart bgp connection after limit is exceeded\n"
8631 "Restart interval in minutes\n"
8632 "Force checking all received routes not only accepted\n")
8634 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8635 neighbor_maximum_prefix_threshold_restart_cmd
,
8636 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8637 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8638 "Maximum number of prefixes to accept from this peer\n"
8639 "maximum no. of prefix limit\n"
8640 "Threshold value (%) at which to generate a warning msg\n"
8641 "Restart bgp connection after limit is exceeded\n"
8642 "Restart interval in minutes\n"
8643 "Force checking all received routes not only accepted\n")
8647 int idx_number_2
= 4;
8648 int idx_number_3
= 6;
8650 char base_xpath
[XPATH_MAXLEN
];
8651 char af_xpath
[XPATH_MAXLEN
];
8652 char attr_xpath
[XPATH_MAXLEN
];
8653 afi_t afi
= bgp_node_afi(vty
);
8654 safi_t safi
= bgp_node_safi(vty
);
8656 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8657 yang_afi_safi_value2identity(afi
, safi
));
8658 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8659 sizeof(base_xpath
), af_xpath
)
8661 return CMD_WARNING_CONFIG_FAILED
;
8663 snprintf(attr_xpath
, sizeof(attr_xpath
),
8664 "/%s/prefix-limit/direction-list[direction='in']",
8665 bgp_afi_safi_get_container_str(afi
, safi
));
8666 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8668 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8670 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8671 argv
[idx_number
]->arg
);
8672 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8673 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8674 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8675 argv
[idx_number_3
]->arg
);
8676 if (argv_find(argv
, argc
, "force", &idx_force
))
8677 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8680 return nb_cli_apply_changes(vty
, base_xpath
);
8684 neighbor_maximum_prefix_threshold_restart
,
8685 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8686 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8687 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8688 "Maximum number of prefixes to accept from this peer\n"
8689 "maximum no. of prefix limit\n"
8690 "Threshold value (%) at which to generate a warning msg\n"
8691 "Restart bgp connection after limit is exceeded\n"
8692 "Restart interval in minutes\n"
8693 "Force checking all received routes not only accepted\n")
8695 DEFUN_YANG(no_neighbor_maximum_prefix
,
8696 no_neighbor_maximum_prefix_cmd
,
8697 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8698 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8699 "Maximum number of prefixes to accept from this peer\n"
8700 "maximum no. of prefix limit\n"
8701 "Threshold value (%) at which to generate a warning msg\n"
8702 "Restart bgp connection after limit is exceeded\n"
8703 "Restart interval in minutes\n"
8704 "Only give warning message when limit is exceeded\n"
8705 "Force checking all received routes not only accepted\n")
8708 char base_xpath
[XPATH_MAXLEN
];
8709 char af_xpath
[XPATH_MAXLEN
];
8710 char attr_xpath
[XPATH_MAXLEN
];
8711 afi_t afi
= bgp_node_afi(vty
);
8712 safi_t safi
= bgp_node_safi(vty
);
8714 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8715 yang_afi_safi_value2identity(afi
, safi
));
8716 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8717 sizeof(base_xpath
), af_xpath
)
8719 return CMD_WARNING_CONFIG_FAILED
;
8721 snprintf(attr_xpath
, sizeof(attr_xpath
),
8722 "/%s/prefix-limit/direction-list[direction='in']",
8723 bgp_afi_safi_get_container_str(afi
, safi
));
8724 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8726 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8728 return nb_cli_apply_changes(vty
, base_xpath
);
8732 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8733 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8734 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8735 "Maximum number of prefixes to accept from this peer\n"
8736 "maximum no. of prefix limit\n"
8737 "Threshold value (%) at which to generate a warning msg\n"
8738 "Restart bgp connection after limit is exceeded\n"
8739 "Restart interval in minutes\n"
8740 "Only give warning message when limit is exceeded\n"
8741 "Force checking all received routes not only accepted\n")
8744 /* "neighbor allowas-in" */
8745 DEFUN (neighbor_allowas_in
,
8746 neighbor_allowas_in_cmd
,
8747 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8750 "Accept as-path with my AS present in it\n"
8751 "Number of occurrences of AS number\n"
8752 "Only accept my AS in the as-path if the route was originated in my AS\n")
8755 int idx_number_origin
= 3;
8761 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8763 return CMD_WARNING_CONFIG_FAILED
;
8765 if (argc
<= idx_number_origin
)
8768 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8771 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8774 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8777 return bgp_vty_return(vty
, ret
);
8781 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8782 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8783 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8784 "Accept as-path with my AS present in it\n"
8785 "Number of occurrences of AS number\n"
8786 "Only accept my AS in the as-path if the route was originated in my AS\n")
8788 DEFUN (no_neighbor_allowas_in
,
8789 no_neighbor_allowas_in_cmd
,
8790 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8794 "allow local ASN appears in aspath attribute\n"
8795 "Number of occurrences of AS number\n"
8796 "Only accept my AS in the as-path if the route was originated in my AS\n")
8802 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8804 return CMD_WARNING_CONFIG_FAILED
;
8806 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8807 bgp_node_safi(vty
));
8809 return bgp_vty_return(vty
, ret
);
8813 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8814 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8815 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8816 "allow local ASN appears in aspath attribute\n"
8817 "Number of occurrences of AS number\n"
8818 "Only accept my AS in the as-path if the route was originated in my AS\n")
8820 DEFUN_YANG (neighbor_ttl_security
,
8821 neighbor_ttl_security_cmd
,
8822 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8825 "BGP ttl-security parameters\n"
8826 "Specify the maximum number of hops to the BGP peer\n"
8827 "Number of hops to BGP peer\n")
8831 char base_xpath
[XPATH_MAXLEN
];
8833 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8834 sizeof(base_xpath
), NULL
)
8836 return CMD_WARNING_CONFIG_FAILED
;
8838 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8839 argv
[idx_number
]->arg
);
8841 return nb_cli_apply_changes(vty
, base_xpath
);
8844 DEFUN_YANG(no_neighbor_ttl_security
,
8845 no_neighbor_ttl_security_cmd
,
8846 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8848 "BGP ttl-security parameters\n"
8849 "Specify the maximum number of hops to the BGP peer\n"
8850 "Number of hops to BGP peer\n")
8853 char base_xpath
[XPATH_MAXLEN
];
8855 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8856 sizeof(base_xpath
), NULL
)
8858 return CMD_WARNING_CONFIG_FAILED
;
8860 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8862 return nb_cli_apply_changes(vty
, base_xpath
);
8865 DEFUN (neighbor_addpath_tx_all_paths
,
8866 neighbor_addpath_tx_all_paths_cmd
,
8867 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8870 "Use addpath to advertise all paths to a neighbor\n")
8875 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8877 return CMD_WARNING_CONFIG_FAILED
;
8879 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8884 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8885 neighbor_addpath_tx_all_paths_hidden_cmd
,
8886 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8887 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8888 "Use addpath to advertise all paths to a neighbor\n")
8890 DEFUN (no_neighbor_addpath_tx_all_paths
,
8891 no_neighbor_addpath_tx_all_paths_cmd
,
8892 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8896 "Use addpath to advertise all paths to a neighbor\n")
8901 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8903 return CMD_WARNING_CONFIG_FAILED
;
8905 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8906 != BGP_ADDPATH_ALL
) {
8908 "%% Peer not currently configured to transmit all paths.");
8909 return CMD_WARNING_CONFIG_FAILED
;
8912 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8918 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8919 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8920 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8921 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8922 "Use addpath to advertise all paths to a neighbor\n")
8924 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8925 neighbor_addpath_tx_bestpath_per_as_cmd
,
8926 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8929 "Use addpath to advertise the bestpath per each neighboring AS\n")
8934 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8936 return CMD_WARNING_CONFIG_FAILED
;
8938 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8939 BGP_ADDPATH_BEST_PER_AS
);
8944 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8945 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8946 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8948 "Use addpath to advertise the bestpath per each neighboring AS\n")
8950 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8951 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8952 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8956 "Use addpath to advertise the bestpath per each neighboring AS\n")
8961 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8963 return CMD_WARNING_CONFIG_FAILED
;
8965 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8966 != BGP_ADDPATH_BEST_PER_AS
) {
8968 "%% Peer not currently configured to transmit all best path per as.");
8969 return CMD_WARNING_CONFIG_FAILED
;
8972 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8978 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8979 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8980 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8982 "Use addpath to advertise the bestpath per each neighboring AS\n")
8985 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8986 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8989 "Detect AS loops before sending to neighbor\n")
8993 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8995 return CMD_WARNING_CONFIG_FAILED
;
8997 peer
->as_path_loop_detection
= true;
9003 no_neighbor_aspath_loop_detection
,
9004 no_neighbor_aspath_loop_detection_cmd
,
9005 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
9009 "Detect AS loops before sending to neighbor\n")
9013 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9015 return CMD_WARNING_CONFIG_FAILED
;
9017 peer
->as_path_loop_detection
= false;
9022 DEFPY(neighbor_damp
,
9024 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
9027 "Enable neighbor route-flap dampening\n"
9028 "Half-life time for the penalty\n"
9029 "Value to start reusing a route\n"
9030 "Value to start suppressing a route\n"
9031 "Maximum duration to suppress a stable route\n")
9033 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9036 return CMD_WARNING_CONFIG_FAILED
;
9038 half
= DEFAULT_HALF_LIFE
;
9040 reuse
= DEFAULT_REUSE
;
9041 suppress
= DEFAULT_SUPPRESS
;
9044 if (suppress
< reuse
) {
9046 "Suppress value cannot be less than reuse value\n");
9047 return CMD_WARNING_CONFIG_FAILED
;
9049 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
9050 half
* 60, reuse
, suppress
, max
* 60);
9054 DEFPY(no_neighbor_damp
,
9055 no_neighbor_damp_cmd
,
9056 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
9060 "Enable neighbor route-flap dampening\n"
9061 "Half-life time for the penalty\n"
9062 "Value to start reusing a route\n"
9063 "Value to start suppressing a route\n"
9064 "Maximum duration to suppress a stable route\n")
9066 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9069 return CMD_WARNING_CONFIG_FAILED
;
9070 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
9074 DEFPY (show_ip_bgp_neighbor_damp_param
,
9075 show_ip_bgp_neighbor_damp_param_cmd
,
9076 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
9081 "Address Family modifier\n"
9084 "Neighbor route-flap dampening information\n"
9085 "Display detail of configured dampening parameters\n"
9088 bool use_json
= false;
9091 safi_t safi
= SAFI_UNICAST
;
9094 if (argv_find(argv
, argc
, "ip", &idx
))
9096 if (argv_find(argv
, argc
, "ipv4", &idx
))
9098 if (argv_find(argv
, argc
, "ipv6", &idx
))
9100 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9105 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
9109 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
9110 struct ecommunity
**list
, bool is_rt6
)
9112 struct ecommunity
*ecom
= NULL
;
9113 struct ecommunity
*ecomadd
;
9115 for (; argc
; --argc
, ++argv
) {
9117 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
9118 ECOMMUNITY_ROUTE_TARGET
,
9121 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
9122 ECOMMUNITY_ROUTE_TARGET
,
9125 vty_out(vty
, "Malformed community-list value\n");
9127 ecommunity_free(&ecom
);
9128 return CMD_WARNING_CONFIG_FAILED
;
9132 ecommunity_merge(ecom
, ecomadd
);
9133 ecommunity_free(&ecomadd
);
9140 ecommunity_free(&*list
);
9147 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
9148 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
9151 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9152 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9153 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9154 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9156 errmsg
, errmsg_len
, "%s",
9157 "%% error: Please unconfigure import vrf commands before using vpn commands");
9161 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9162 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9163 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9164 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9166 errmsg
, errmsg_len
, "%s",
9167 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
9175 * v2vimport is true if we are handling a `import vrf ...` command
9177 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9181 switch (vty
->node
) {
9190 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9195 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9196 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9197 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9198 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9200 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9204 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9205 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9206 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9207 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9209 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9218 af_rd_vpn_export_cmd
,
9219 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9221 "Specify route distinguisher\n"
9222 "Between current address-family and vpn\n"
9223 "For routes leaked from current address-family to vpn\n"
9224 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9226 char base_xpath
[XPATH_MAXLEN
];
9231 afi
= bgp_node_afi(vty
);
9232 safi
= bgp_node_safi(vty
);
9235 base_xpath
, sizeof(base_xpath
),
9236 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9237 yang_afi_safi_value2identity(afi
, safi
),
9238 bgp_afi_safi_get_container_str(afi
, safi
));
9240 if (argv_find(argv
, argc
, "no", &idx
))
9241 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9243 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9245 return nb_cli_apply_changes(vty
, base_xpath
);
9248 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9249 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9253 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9254 yang_dnode_get_string(dnode
, NULL
));
9257 ALIAS (af_rd_vpn_export
,
9258 af_no_rd_vpn_export_cmd
,
9261 "Specify route distinguisher\n"
9262 "Between current address-family and vpn\n"
9263 "For routes leaked from current address-family to vpn\n")
9265 DEFPY (af_label_vpn_export
,
9266 af_label_vpn_export_cmd
,
9267 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9269 "label value for VRF\n"
9270 "Between current address-family and vpn\n"
9271 "For routes leaked from current address-family to vpn\n"
9272 "Label Value <0-1048575>\n"
9273 "Automatically assign a label\n")
9275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9276 mpls_label_t label
= MPLS_LABEL_NONE
;
9281 if (argv_find(argv
, argc
, "no", &idx
))
9284 /* If "no ...", squash trailing parameter */
9290 label
= label_val
; /* parser should force unsigned */
9293 afi
= vpn_policy_getafi(vty
, bgp
, false);
9295 return CMD_WARNING_CONFIG_FAILED
;
9298 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9299 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9304 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9306 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9307 bgp_get_default(), bgp
);
9309 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9310 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9312 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9315 * label has previously been automatically
9316 * assigned by labelpool: release it
9318 * NB if tovpn_label == MPLS_LABEL_NONE it
9319 * means the automatic assignment is in flight
9320 * and therefore the labelpool callback must
9321 * detect that the auto label is not needed.
9324 bgp_lp_release(LP_TYPE_VRF
,
9325 &bgp
->vpn_policy
[afi
],
9326 bgp
->vpn_policy
[afi
].tovpn_label
);
9328 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9329 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9332 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9334 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9335 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9336 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9337 vpn_leak_label_callback
);
9340 /* post-change: re-export vpn routes */
9341 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9342 bgp_get_default(), bgp
);
9344 hook_call(bgp_snmp_update_last_changed
, bgp
);
9348 DEFPY (af_sid_vpn_export
,
9349 af_sid_vpn_export_cmd
,
9350 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
9352 "sid value for VRF\n"
9353 "Between current address-family and vpn\n"
9354 "For routes leaked from current address-family to vpn\n"
9355 "Sid allocation index\n"
9356 "Automatically assign a label\n")
9358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9364 if (argv_find(argv
, argc
, "no", &idx
))
9366 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9367 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9369 afi
= vpn_policy_getafi(vty
, bgp
, false);
9371 return CMD_WARNING_CONFIG_FAILED
;
9375 vty_out(vty
, "It's not implemented");
9376 return CMD_WARNING_CONFIG_FAILED
;
9379 /* skip when it's already configured */
9380 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9381 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9382 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9386 * mode change between sid_idx and sid_auto isn't supported.
9387 * user must negate sid vpn export when they want to change the mode
9389 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9390 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9391 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9392 vty_out(vty
, "it's already configured as %s.\n",
9393 sid_auto
? "auto-mode" : "idx-mode");
9394 return CMD_WARNING_CONFIG_FAILED
;
9398 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9399 bgp_get_default(), bgp
);
9402 /* SID allocation auto-mode */
9404 zlog_debug("%s: auto sid alloc.", __func__
);
9405 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9406 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9408 /* SID allocation index-mode */
9410 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9411 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9415 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9416 bgp_get_default(), bgp
);
9420 ALIAS (af_label_vpn_export
,
9421 af_no_label_vpn_export_cmd
,
9422 "no label vpn export",
9424 "label value for VRF\n"
9425 "Between current address-family and vpn\n"
9426 "For routes leaked from current address-family to vpn\n")
9428 DEFPY_YANG (af_nexthop_vpn_export
,
9429 af_nexthop_vpn_export_cmd
,
9430 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9432 "Specify next hop to use for VRF advertised prefixes\n"
9433 "Between current address-family and vpn\n"
9434 "For routes leaked from current address-family to vpn\n"
9438 char base_xpath
[XPATH_MAXLEN
];
9446 vty_out(vty
, "%% Nexthop required\n");
9447 return CMD_WARNING_CONFIG_FAILED
;
9449 if (!sockunion2hostprefix(nexthop_su
, &p
))
9450 return CMD_WARNING_CONFIG_FAILED
;
9453 afi
= bgp_node_afi(vty
);
9454 safi
= bgp_node_safi(vty
);
9457 base_xpath
, sizeof(base_xpath
),
9458 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9459 yang_afi_safi_value2identity(afi
, safi
),
9460 bgp_afi_safi_get_container_str(afi
, safi
));
9462 if (argv_find(argv
, argc
, "no", &idx
))
9463 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9465 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9468 return nb_cli_apply_changes(vty
, base_xpath
);
9471 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9472 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9476 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9477 yang_dnode_get_string(dnode
, NULL
));
9480 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9482 if (!strcmp(dstr
, "import")) {
9483 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9484 } else if (!strcmp(dstr
, "export")) {
9485 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9486 } else if (!strcmp(dstr
, "both")) {
9487 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9488 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9490 vty_out(vty
, "%% direction parse error\n");
9491 return CMD_WARNING_CONFIG_FAILED
;
9496 DEFPY (af_rt_vpn_imexport
,
9497 af_rt_vpn_imexport_cmd
,
9498 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9500 "Specify route target list\n"
9501 "Specify route target list\n"
9502 "Between current address-family and vpn\n"
9503 "For routes leaked from vpn to current address-family: match any\n"
9504 "For routes leaked from current address-family to vpn: set\n"
9505 "both import: match any and export: set\n"
9506 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9510 struct ecommunity
*ecom
= NULL
;
9511 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9512 vpn_policy_direction_t dir
;
9517 if (argv_find(argv
, argc
, "no", &idx
))
9520 afi
= vpn_policy_getafi(vty
, bgp
, false);
9522 return CMD_WARNING_CONFIG_FAILED
;
9524 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9525 if (ret
!= CMD_SUCCESS
)
9529 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9530 vty_out(vty
, "%% Missing RTLIST\n");
9531 return CMD_WARNING_CONFIG_FAILED
;
9533 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9534 if (ret
!= CMD_SUCCESS
) {
9539 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9543 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9546 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9548 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9549 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9550 ecommunity_dup(ecom
);
9552 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9554 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9555 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9558 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9562 ecommunity_free(&ecom
);
9567 ALIAS (af_rt_vpn_imexport
,
9568 af_no_rt_vpn_imexport_cmd
,
9569 "no <rt|route-target> vpn <import|export|both>$direction_str",
9571 "Specify route target list\n"
9572 "Specify route target list\n"
9573 "Between current address-family and vpn\n"
9574 "For routes leaked from vpn to current address-family\n"
9575 "For routes leaked from current address-family to vpn\n"
9576 "both import and export\n")
9578 DEFPY_YANG (af_route_map_vpn_imexport
,
9579 af_route_map_vpn_imexport_cmd
,
9580 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9581 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9583 "Specify route map\n"
9584 "Between current address-family and vpn\n"
9585 "For routes leaked from vpn to current address-family\n"
9586 "For routes leaked from current address-family to vpn\n"
9587 "name of route-map\n")
9589 char base_xpath
[XPATH_MAXLEN
];
9594 afi
= bgp_node_afi(vty
);
9595 safi
= bgp_node_safi(vty
);
9598 base_xpath
, sizeof(base_xpath
),
9599 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9600 yang_afi_safi_value2identity(afi
, safi
),
9601 bgp_afi_safi_get_container_str(afi
, safi
));
9603 if (argv_find(argv
, argc
, "no", &idx
)) {
9604 if (!strcmp(direction_str
, "import"))
9605 nb_cli_enqueue_change(vty
, "./rmap-import",
9606 NB_OP_DESTROY
, NULL
);
9607 else if (!strcmp(direction_str
, "export"))
9608 nb_cli_enqueue_change(vty
, "./rmap-export",
9609 NB_OP_DESTROY
, NULL
);
9611 if (!strcmp(direction_str
, "import"))
9612 nb_cli_enqueue_change(vty
, "./rmap-import",
9613 NB_OP_MODIFY
, rmap_str
);
9614 if (!strcmp(direction_str
, "export"))
9615 nb_cli_enqueue_change(vty
, "./rmap-export",
9616 NB_OP_MODIFY
, rmap_str
);
9618 return nb_cli_apply_changes(vty
, base_xpath
);
9621 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9622 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9626 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9627 yang_dnode_get_string(dnode
, NULL
));
9630 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9631 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9635 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9636 yang_dnode_get_string(dnode
, NULL
));
9639 ALIAS (af_route_map_vpn_imexport
,
9640 af_no_route_map_vpn_imexport_cmd
,
9641 "no route-map vpn <import|export>$direction_str",
9643 "Specify route map\n"
9644 "Between current address-family and vpn\n"
9645 "For routes leaked from vpn to current address-family\n"
9646 "For routes leaked from current address-family to vpn\n")
9648 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9649 "import vrf route-map RMAP$rmap_str",
9650 "Import routes from another VRF\n"
9651 "Vrf routes being filtered\n"
9652 "Specify route map\n"
9653 "name of route-map\n")
9655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9656 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9658 struct bgp
*bgp_default
;
9660 afi
= vpn_policy_getafi(vty
, bgp
, true);
9662 return CMD_WARNING_CONFIG_FAILED
;
9664 bgp_default
= bgp_get_default();
9669 /* Auto-create assuming the same AS */
9670 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9671 BGP_INSTANCE_TYPE_DEFAULT
);
9675 "VRF default is not configured as a bgp instance\n");
9680 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9682 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9683 XFREE(MTYPE_ROUTE_MAP_NAME
,
9684 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9685 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9686 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9687 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9688 route_map_lookup_warn_noexist(vty
, rmap_str
);
9689 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9692 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9693 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9695 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9700 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9701 "no import vrf route-map [RMAP$rmap_str]",
9703 "Import routes from another VRF\n"
9704 "Vrf routes being filtered\n"
9705 "Specify route map\n"
9706 "name of route-map\n")
9708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9709 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9712 afi
= vpn_policy_getafi(vty
, bgp
, true);
9714 return CMD_WARNING_CONFIG_FAILED
;
9716 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9718 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9719 XFREE(MTYPE_ROUTE_MAP_NAME
,
9720 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9721 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9722 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9724 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9725 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9726 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9728 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9733 DEFPY_YANG(bgp_imexport_vrf
,
9734 bgp_imexport_vrf_cmd
,
9735 "[no] import vrf VIEWVRFNAME$import_name",
9737 "Import routes from another VRF\n"
9738 "VRF to import from\n"
9739 "The name of the VRF\n")
9741 char base_xpath
[XPATH_MAXLEN
];
9746 if (import_name
== NULL
) {
9747 vty_out(vty
, "%% Missing import name\n");
9751 if (strcmp(import_name
, "route-map") == 0) {
9752 vty_out(vty
, "%% Must include route-map name\n");
9756 afi
= bgp_node_afi(vty
);
9757 safi
= bgp_node_safi(vty
);
9760 base_xpath
, sizeof(base_xpath
),
9761 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9762 yang_afi_safi_value2identity(afi
, safi
),
9763 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9765 if (argv_find(argv
, argc
, "no", &idx
))
9766 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9768 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9770 return nb_cli_apply_changes(vty
, base_xpath
);
9773 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9774 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9776 vty_out(vty
, " import vrf %s\n",
9777 yang_dnode_get_string(dnode
, "./vrf"));
9780 /* This command is valid only in a bgp vrf instance or the default instance */
9781 DEFPY_YANG (bgp_imexport_vpn
,
9782 bgp_imexport_vpn_cmd
,
9783 "[no] <import|export>$direction_str vpn",
9785 "Import routes to this address-family\n"
9786 "Export routes from this address-family\n"
9787 "to/from default instance VPN RIB\n")
9789 char base_xpath
[XPATH_MAXLEN
];
9794 afi
= bgp_node_afi(vty
);
9795 safi
= bgp_node_safi(vty
);
9797 if (!strcmp(direction_str
, "import")) {
9799 base_xpath
, sizeof(base_xpath
),
9800 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9801 yang_afi_safi_value2identity(afi
, safi
),
9802 bgp_afi_safi_get_container_str(afi
, safi
));
9803 } else if (!strcmp(direction_str
, "export")) {
9805 base_xpath
, sizeof(base_xpath
),
9806 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9807 yang_afi_safi_value2identity(afi
, safi
),
9808 bgp_afi_safi_get_container_str(afi
, safi
));
9810 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9811 return CMD_WARNING_CONFIG_FAILED
;
9814 if (argv_find(argv
, argc
, "no", &idx
))
9815 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9817 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9819 return nb_cli_apply_changes(vty
, base_xpath
);
9822 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9823 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9825 if (yang_dnode_get_bool(dnode
, NULL
))
9826 vty_out(vty
, " import vpn\n");
9829 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9830 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9832 if (yang_dnode_get_bool(dnode
, NULL
))
9833 vty_out(vty
, " export vpn\n");
9836 DEFPY (af_routetarget_import
,
9837 af_routetarget_import_cmd
,
9838 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9840 "Specify route target list\n"
9841 "Specify route target list\n"
9842 "Specify route target list\n"
9843 "Specify route target list\n"
9844 "Flow-spec redirect type route target\n"
9845 "Import routes to this address-family\n"
9846 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9850 struct ecommunity
*ecom
= NULL
;
9852 int idx
= 0, idx_unused
= 0;
9856 if (argv_find(argv
, argc
, "no", &idx
))
9859 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9860 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9863 afi
= vpn_policy_getafi(vty
, bgp
, false);
9865 return CMD_WARNING_CONFIG_FAILED
;
9867 if (rt6
&& afi
!= AFI_IP6
)
9868 return CMD_WARNING_CONFIG_FAILED
;
9871 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9872 vty_out(vty
, "%% Missing RTLIST\n");
9873 return CMD_WARNING_CONFIG_FAILED
;
9875 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9876 if (ret
!= CMD_SUCCESS
)
9881 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9882 ecommunity_free(&bgp
->vpn_policy
[afi
]
9883 .import_redirect_rtlist
);
9884 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9885 ecommunity_dup(ecom
);
9887 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9888 ecommunity_free(&bgp
->vpn_policy
[afi
]
9889 .import_redirect_rtlist
);
9890 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9894 ecommunity_free(&ecom
);
9899 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9900 struct lyd_node
*dnode
,
9903 const char *af_name
;
9907 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9908 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9910 vty_out(vty
, " !\n address-family ");
9911 if (afi
== AFI_IP
) {
9912 if (safi
== SAFI_UNICAST
)
9913 vty_out(vty
, "ipv4 unicast");
9914 else if (safi
== SAFI_LABELED_UNICAST
)
9915 vty_out(vty
, "ipv4 labeled-unicast");
9916 else if (safi
== SAFI_MULTICAST
)
9917 vty_out(vty
, "ipv4 multicast");
9918 else if (safi
== SAFI_MPLS_VPN
)
9919 vty_out(vty
, "ipv4 vpn");
9920 else if (safi
== SAFI_ENCAP
)
9921 vty_out(vty
, "ipv4 encap");
9922 else if (safi
== SAFI_FLOWSPEC
)
9923 vty_out(vty
, "ipv4 flowspec");
9924 } else if (afi
== AFI_IP6
) {
9925 if (safi
== SAFI_UNICAST
)
9926 vty_out(vty
, "ipv6 unicast");
9927 else if (safi
== SAFI_LABELED_UNICAST
)
9928 vty_out(vty
, "ipv6 labeled-unicast");
9929 else if (safi
== SAFI_MULTICAST
)
9930 vty_out(vty
, "ipv6 multicast");
9931 else if (safi
== SAFI_MPLS_VPN
)
9932 vty_out(vty
, "ipv6 vpn");
9933 else if (safi
== SAFI_ENCAP
)
9934 vty_out(vty
, "ipv6 encap");
9935 else if (safi
== SAFI_FLOWSPEC
)
9936 vty_out(vty
, "ipv6 flowspec");
9937 } else if (afi
== AFI_L2VPN
) {
9938 if (safi
== SAFI_EVPN
)
9939 vty_out(vty
, "l2vpn evpn");
9944 DEFUN_NOSH (address_family_ipv4_safi
,
9945 address_family_ipv4_safi_cmd
,
9946 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9947 "Enter Address Family command mode\n"
9949 BGP_SAFI_WITH_LABEL_HELP_STR
)
9952 safi_t safi
= SAFI_UNICAST
;
9953 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9954 const char *vrf_name
= NULL
;
9957 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9959 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9961 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9962 "control-plane-protocol");
9963 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9965 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9966 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9967 && safi
!= SAFI_EVPN
) {
9969 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9970 return CMD_WARNING_CONFIG_FAILED
;
9973 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9978 DEFUN_NOSH (address_family_ipv6_safi
,
9979 address_family_ipv6_safi_cmd
,
9980 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9981 "Enter Address Family command mode\n"
9983 BGP_SAFI_WITH_LABEL_HELP_STR
)
9985 safi_t safi
= SAFI_UNICAST
;
9986 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9987 const char *vrf_name
= NULL
;
9990 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9991 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9993 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9994 "control-plane-protocol");
9995 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9997 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9998 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9999 && safi
!= SAFI_EVPN
) {
10001 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
10002 return CMD_WARNING_CONFIG_FAILED
;
10005 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
10007 return CMD_SUCCESS
;
10010 #ifdef KEEP_OLD_VPN_COMMANDS
10011 DEFUN_NOSH (address_family_vpnv4
,
10012 address_family_vpnv4_cmd
,
10013 "address-family vpnv4 [unicast]",
10014 "Enter Address Family command mode\n"
10016 "Address Family modifier\n")
10018 vty
->node
= BGP_VPNV4_NODE
;
10019 return CMD_SUCCESS
;
10022 DEFUN_NOSH (address_family_vpnv6
,
10023 address_family_vpnv6_cmd
,
10024 "address-family vpnv6 [unicast]",
10025 "Enter Address Family command mode\n"
10027 "Address Family modifier\n")
10029 vty
->node
= BGP_VPNV6_NODE
;
10030 return CMD_SUCCESS
;
10032 #endif /* KEEP_OLD_VPN_COMMANDS */
10034 DEFUN_NOSH (address_family_evpn
,
10035 address_family_evpn_cmd
,
10036 "address-family l2vpn evpn",
10037 "Enter Address Family command mode\n"
10039 "Address Family modifier\n")
10041 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10042 vty
->node
= BGP_EVPN_NODE
;
10043 return CMD_SUCCESS
;
10046 DEFUN_NOSH (bgp_segment_routing_srv6
,
10047 bgp_segment_routing_srv6_cmd
,
10048 "segment-routing srv6",
10049 "Segment-Routing configuration\n"
10050 "Segment-Routing SRv6 configuration\n")
10052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10053 bgp
->srv6_enabled
= true;
10054 vty
->node
= BGP_SRV6_NODE
;
10055 return CMD_SUCCESS
;
10058 DEFPY (bgp_srv6_locator
,
10059 bgp_srv6_locator_cmd
,
10060 "locator NAME$name",
10061 "Specify SRv6 locator\n"
10062 "Specify SRv6 locator\n")
10064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10067 if (strlen(bgp
->srv6_locator_name
) > 0
10068 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
10069 vty_out(vty
, "srv6 locator is already configured\n");
10070 return CMD_WARNING_CONFIG_FAILED
;
10073 snprintf(bgp
->srv6_locator_name
,
10074 sizeof(bgp
->srv6_locator_name
), "%s", name
);
10076 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
10078 return CMD_WARNING_CONFIG_FAILED
;
10080 return CMD_SUCCESS
;
10083 DEFPY (show_bgp_srv6
,
10085 "show bgp segment-routing srv6",
10088 "BGP Segment Routing\n"
10089 "BGP Segment Routing SRv6\n")
10092 struct listnode
*node
;
10093 struct prefix_ipv6
*chunk
;
10094 struct bgp_srv6_function
*func
;
10095 struct in6_addr
*tovpn4_sid
;
10096 struct in6_addr
*tovpn6_sid
;
10098 char buf_tovpn4_sid
[256];
10099 char buf_tovpn6_sid
[256];
10101 bgp
= bgp_get_default();
10103 return CMD_SUCCESS
;
10105 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
10106 vty_out(vty
, "locator_chunks:\n");
10107 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10108 prefix2str(chunk
, buf
, sizeof(buf
));
10109 vty_out(vty
, "- %s\n", buf
);
10112 vty_out(vty
, "functions:\n");
10113 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10114 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
10115 vty_out(vty
, "- sid: %s\n", buf
);
10116 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10119 vty_out(vty
, "bgps:\n");
10120 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10121 vty_out(vty
, "- name: %s\n",
10122 bgp
->name
? bgp
->name
: "default");
10124 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
10125 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
10127 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
10128 sizeof(buf_tovpn4_sid
));
10130 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
10131 sizeof(buf_tovpn6_sid
));
10133 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
10134 tovpn4_sid
? buf_tovpn4_sid
: "none");
10135 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
10136 tovpn6_sid
? buf_tovpn6_sid
: "none");
10139 return CMD_SUCCESS
;
10142 DEFUN_NOSH (exit_address_family
,
10143 exit_address_family_cmd
,
10144 "exit-address-family",
10145 "Exit from Address Family configuration mode\n")
10147 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10148 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10149 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10150 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10151 || vty
->node
== BGP_EVPN_NODE
10152 || vty
->node
== BGP_FLOWSPECV4_NODE
10153 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10154 vty
->node
= BGP_NODE
;
10155 return CMD_SUCCESS
;
10158 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
10159 struct lyd_node
*dnode
10160 __attribute__((__unused__
)))
10162 vty_out(vty
, " exit-address-family\n");
10165 /* Recalculate bestpath and re-advertise a prefix */
10166 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10167 const char *ip_str
, afi_t afi
, safi_t safi
,
10168 struct prefix_rd
*prd
)
10171 struct prefix match
;
10172 struct bgp_dest
*dest
;
10173 struct bgp_dest
*rm
;
10175 struct bgp_table
*table
;
10176 struct bgp_table
*rib
;
10178 /* BGP structure lookup. */
10180 bgp
= bgp_lookup_by_name(view_name
);
10182 vty_out(vty
, "%% Can't find BGP instance %s\n",
10184 return CMD_WARNING
;
10187 bgp
= bgp_get_default();
10189 vty_out(vty
, "%% No BGP process is configured\n");
10190 return CMD_WARNING
;
10194 /* Check IP address argument. */
10195 ret
= str2prefix(ip_str
, &match
);
10197 vty_out(vty
, "%% address is malformed\n");
10198 return CMD_WARNING
;
10201 match
.family
= afi2family(afi
);
10202 rib
= bgp
->rib
[afi
][safi
];
10204 if (safi
== SAFI_MPLS_VPN
) {
10205 for (dest
= bgp_table_top(rib
); dest
;
10206 dest
= bgp_route_next(dest
)) {
10207 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10209 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10212 table
= bgp_dest_get_bgp_table_info(dest
);
10216 rm
= bgp_node_match(table
, &match
);
10218 const struct prefix
*rm_p
=
10219 bgp_dest_get_prefix(rm
);
10221 if (rm_p
->prefixlen
== match
.prefixlen
) {
10222 SET_FLAG(rm
->flags
,
10223 BGP_NODE_USER_CLEAR
);
10224 bgp_process(bgp
, rm
, afi
, safi
);
10226 bgp_dest_unlock_node(rm
);
10230 dest
= bgp_node_match(rib
, &match
);
10231 if (dest
!= NULL
) {
10232 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10234 if (dest_p
->prefixlen
== match
.prefixlen
) {
10235 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10236 bgp_process(bgp
, dest
, afi
, safi
);
10238 bgp_dest_unlock_node(dest
);
10242 return CMD_SUCCESS
;
10245 /* one clear bgp command to rule them all */
10246 DEFUN (clear_ip_bgp_all
,
10247 clear_ip_bgp_all_cmd
,
10248 "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>]",
10252 BGP_INSTANCE_HELP_STR
10255 BGP_SAFI_WITH_LABEL_HELP_STR
10256 "Address Family modifier\n"
10257 "Clear all peers\n"
10258 "BGP IPv4 neighbor to clear\n"
10259 "BGP IPv6 neighbor to clear\n"
10260 "BGP neighbor on interface to clear\n"
10261 "Clear peers with the AS number\n"
10262 "Clear all external peers\n"
10263 "Clear all members of peer-group\n"
10264 "BGP peer-group name\n"
10269 "Push out prefix-list ORF and do inbound soft reconfig\n"
10274 afi_t afi
= AFI_UNSPEC
;
10275 safi_t safi
= SAFI_UNSPEC
;
10276 enum clear_sort clr_sort
= clear_peer
;
10277 enum bgp_clear_type clr_type
;
10278 char *clr_arg
= NULL
;
10281 char errmsg
[BUFSIZ
] = {'\0'};
10284 /* clear [ip] bgp */
10285 if (argv_find(argv
, argc
, "ip", &idx
))
10288 /* [<vrf> VIEWVRFNAME] */
10289 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10290 vrf
= argv
[idx
+ 1]->arg
;
10292 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10294 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10295 /* [<view> VIEWVRFNAME] */
10296 vrf
= argv
[idx
+ 1]->arg
;
10299 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10300 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10301 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10303 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10304 if (argv_find(argv
, argc
, "*", &idx
)) {
10305 clr_sort
= clear_all
;
10306 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10307 clr_sort
= clear_peer
;
10308 clr_arg
= argv
[idx
]->arg
;
10309 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10310 clr_sort
= clear_peer
;
10311 clr_arg
= argv
[idx
]->arg
;
10312 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10313 clr_sort
= clear_group
;
10315 clr_arg
= argv
[idx
]->arg
;
10316 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10317 clr_sort
= clear_peer
;
10318 clr_arg
= argv
[idx
]->arg
;
10319 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10320 clr_sort
= clear_peer
;
10321 clr_arg
= argv
[idx
]->arg
;
10322 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10323 clr_sort
= clear_as
;
10324 clr_arg
= argv
[idx
]->arg
;
10325 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10326 clr_sort
= clear_external
;
10329 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
10330 if (argv_find(argv
, argc
, "soft", &idx
)) {
10331 if (argv_find(argv
, argc
, "in", &idx
)
10332 || argv_find(argv
, argc
, "out", &idx
))
10333 clr_type
= strmatch(argv
[idx
]->text
, "in")
10334 ? BGP_CLEAR_SOFT_IN
10335 : BGP_CLEAR_SOFT_OUT
;
10337 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10338 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10339 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10340 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10341 : BGP_CLEAR_SOFT_IN
;
10342 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10343 clr_type
= BGP_CLEAR_SOFT_OUT
;
10345 clr_type
= BGP_CLEAR_SOFT_NONE
;
10347 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
10350 vty_out(vty
, "Error description: %s\n", errmsg
);
10355 DEFUN (clear_ip_bgp_prefix
,
10356 clear_ip_bgp_prefix_cmd
,
10357 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10361 BGP_INSTANCE_HELP_STR
10362 "Clear bestpath and re-advertise\n"
10366 char *prefix
= NULL
;
10370 /* [<view|vrf> VIEWVRFNAME] */
10371 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10372 vrf
= argv
[idx
+ 1]->arg
;
10374 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10376 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10377 /* [<view> VIEWVRFNAME] */
10378 vrf
= argv
[idx
+ 1]->arg
;
10382 prefix
= argv
[argc
- 1]->arg
;
10384 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10387 DEFUN (clear_bgp_ipv6_safi_prefix
,
10388 clear_bgp_ipv6_safi_prefix_cmd
,
10389 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10395 "Clear bestpath and re-advertise\n"
10399 int idx_ipv6_prefix
= 0;
10400 safi_t safi
= SAFI_UNICAST
;
10401 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10402 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10404 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10405 return bgp_clear_prefix(
10406 vty
, NULL
, prefix
, AFI_IP6
,
10410 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10411 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10412 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10416 BGP_INSTANCE_HELP_STR
10419 "Clear bestpath and re-advertise\n"
10423 int idx_vrfview
= 0;
10424 int idx_ipv6_prefix
= 0;
10425 safi_t safi
= SAFI_UNICAST
;
10426 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10427 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10428 char *vrfview
= NULL
;
10430 /* [<view|vrf> VIEWVRFNAME] */
10431 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10432 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10433 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10435 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10436 /* [<view> VIEWVRFNAME] */
10437 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10439 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10441 return bgp_clear_prefix(
10442 vty
, vrfview
, prefix
,
10443 AFI_IP6
, safi
, NULL
);
10446 DEFUN (show_bgp_views
,
10447 show_bgp_views_cmd
,
10448 "show [ip] bgp views",
10452 "Show the defined BGP views\n")
10454 struct list
*inst
= bm
->bgp
;
10455 struct listnode
*node
;
10458 vty_out(vty
, "Defined BGP views:\n");
10459 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10461 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10463 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10467 return CMD_SUCCESS
;
10470 DEFUN (show_bgp_vrfs
,
10472 "show [ip] bgp vrfs [json]",
10479 char buf
[ETHER_ADDR_STRLEN
];
10480 struct list
*inst
= bm
->bgp
;
10481 struct listnode
*node
;
10483 bool uj
= use_json(argc
, argv
);
10484 json_object
*json
= NULL
;
10485 json_object
*json_vrfs
= NULL
;
10489 json
= json_object_new_object();
10490 json_vrfs
= json_object_new_object();
10493 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10494 const char *name
, *type
;
10496 struct listnode
*node2
, *nnode2
;
10497 int peers_cfg
, peers_estb
;
10498 json_object
*json_vrf
= NULL
;
10501 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10505 if (!uj
&& count
== 1) {
10507 "%4s %-5s %-16s %9s %10s %-37s\n",
10508 "Type", "Id", "routerId", "#PeersCfg",
10509 "#PeersEstb", "Name");
10510 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10511 "L3-VNI", "RouterMAC", "Interface");
10514 peers_cfg
= peers_estb
= 0;
10516 json_vrf
= json_object_new_object();
10519 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10520 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10523 if (peer_established(peer
))
10527 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10528 name
= VRF_DEFAULT_NAME
;
10537 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10539 : (int64_t)bgp
->vrf_id
;
10540 char buf
[BUFSIZ
] = {0};
10542 json_object_string_add(json_vrf
, "type", type
);
10543 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10544 json_object_string_add(json_vrf
, "routerId",
10546 &bgp
->router_id
, buf
,
10548 json_object_int_add(json_vrf
, "numConfiguredPeers",
10550 json_object_int_add(json_vrf
, "numEstablishedPeers",
10553 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10554 json_object_string_add(
10556 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10557 json_object_string_add(json_vrf
, "interface",
10558 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10560 json_object_object_add(json_vrfs
, name
, json_vrf
);
10562 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10564 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10565 : (int)bgp
->vrf_id
,
10566 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10567 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10569 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10570 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10576 json_object_object_add(json
, "vrfs", json_vrfs
);
10578 json_object_int_add(json
, "totalVrfs", count
);
10580 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10581 json
, JSON_C_TO_STRING_PRETTY
));
10582 json_object_free(json
);
10586 "\nTotal number of VRFs (including default): %d\n",
10590 return CMD_SUCCESS
;
10593 DEFUN (show_bgp_mac_hash
,
10594 show_bgp_mac_hash_cmd
,
10595 "show bgp mac hash",
10599 "Mac Address database\n")
10601 bgp_mac_dump_table(vty
);
10603 return CMD_SUCCESS
;
10606 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10608 struct vty
*vty
= (struct vty
*)args
;
10609 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10611 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10614 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10616 vty_out(vty
, "self nexthop database:\n");
10617 bgp_nexthop_show_address_hash(vty
, bgp
);
10619 vty_out(vty
, "Tunnel-ip database:\n");
10620 hash_iterate(bgp
->tip_hash
,
10621 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10625 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10626 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10627 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10628 "martian next-hops\n"
10629 "martian next-hop database\n")
10631 struct bgp
*bgp
= NULL
;
10635 /* [<vrf> VIEWVRFNAME] */
10636 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10637 name
= argv
[idx
+ 1]->arg
;
10638 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10640 } else if (argv_find(argv
, argc
, "view", &idx
))
10641 /* [<view> VIEWVRFNAME] */
10642 name
= argv
[idx
+ 1]->arg
;
10644 bgp
= bgp_lookup_by_name(name
);
10646 bgp
= bgp_get_default();
10649 vty_out(vty
, "%% No BGP process is configured\n");
10650 return CMD_WARNING
;
10652 bgp_show_martian_nexthops(vty
, bgp
);
10654 return CMD_SUCCESS
;
10657 DEFUN (show_bgp_memory
,
10658 show_bgp_memory_cmd
,
10659 "show [ip] bgp memory",
10663 "Global BGP memory statistics\n")
10665 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10666 unsigned long count
;
10668 /* RIB related usage stats */
10669 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10670 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10671 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10672 count
* sizeof(struct bgp_dest
)));
10674 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10675 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10676 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10677 count
* sizeof(struct bgp_path_info
)));
10678 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10679 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10682 memstrbuf
, sizeof(memstrbuf
),
10683 count
* sizeof(struct bgp_path_info_extra
)));
10685 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10686 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10687 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10688 count
* sizeof(struct bgp_static
)));
10690 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10691 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10692 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10693 count
* sizeof(struct bpacket
)));
10696 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10697 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10698 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10699 count
* sizeof(struct bgp_adj_in
)));
10700 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10701 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10702 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10703 count
* sizeof(struct bgp_adj_out
)));
10705 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10706 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10708 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10709 count
* sizeof(struct bgp_nexthop_cache
)));
10711 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10712 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10714 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10715 count
* sizeof(struct bgp_damp_info
)));
10718 count
= attr_count();
10719 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10720 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10721 count
* sizeof(struct attr
)));
10723 if ((count
= attr_unknown_count()))
10724 vty_out(vty
, "%ld unknown attributes\n", count
);
10726 /* AS_PATH attributes */
10727 count
= aspath_count();
10728 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10729 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10730 count
* sizeof(struct aspath
)));
10732 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10733 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10734 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10735 count
* sizeof(struct assegment
)));
10737 /* Other attributes */
10738 if ((count
= community_count()))
10739 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10740 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10741 count
* sizeof(struct community
)));
10742 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10743 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10744 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10745 count
* sizeof(struct ecommunity
)));
10746 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10748 "%ld BGP large-community entries, using %s of memory\n",
10749 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10750 count
* sizeof(struct lcommunity
)));
10752 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10753 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10754 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10755 count
* sizeof(struct cluster_list
)));
10757 /* Peer related usage */
10758 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10759 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10760 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10761 count
* sizeof(struct peer
)));
10763 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10764 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10765 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10766 count
* sizeof(struct peer_group
)));
10769 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10770 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10771 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10772 count
* sizeof(regex_t
)));
10773 return CMD_SUCCESS
;
10776 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10778 json_object
*bestpath
= json_object_new_object();
10780 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10781 json_object_string_add(bestpath
, "asPath", "ignore");
10783 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10784 json_object_string_add(bestpath
, "asPath", "confed");
10786 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10787 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10788 json_object_string_add(bestpath
, "multiPathRelax",
10791 json_object_string_add(bestpath
, "multiPathRelax",
10794 json_object_string_add(bestpath
, "multiPathRelax", "false");
10796 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10797 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10799 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10800 json_object_string_add(bestpath
, "compareRouterId", "true");
10801 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10802 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10803 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10804 json_object_string_add(bestpath
, "med", "confed");
10805 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10806 json_object_string_add(bestpath
, "med",
10807 "missing-as-worst");
10809 json_object_string_add(bestpath
, "med", "true");
10812 json_object_object_add(json
, "bestPath", bestpath
);
10815 /* Print the error code/subcode for why the peer is down */
10816 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10817 json_object
*json_peer
, bool use_json
)
10819 const char *code_str
;
10820 const char *subcode_str
;
10823 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10824 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10825 char errorcodesubcode_hexstr
[5];
10826 char errorcodesubcode_str
[256];
10828 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10829 subcode_str
= bgp_notify_subcode_str(
10831 peer
->notify
.subcode
);
10833 snprintf(errorcodesubcode_hexstr
,
10834 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10835 peer
->notify
.code
, peer
->notify
.subcode
);
10836 json_object_string_add(json_peer
,
10837 "lastErrorCodeSubcode",
10838 errorcodesubcode_hexstr
);
10839 snprintf(errorcodesubcode_str
, 255, "%s%s",
10840 code_str
, subcode_str
);
10841 json_object_string_add(json_peer
,
10842 "lastNotificationReason",
10843 errorcodesubcode_str
);
10844 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10845 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10846 && (peer
->notify
.subcode
10847 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10848 || peer
->notify
.subcode
10849 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10850 && peer
->notify
.length
) {
10852 const char *msg_str
;
10854 msg_str
= bgp_notify_admin_message(
10855 msgbuf
, sizeof(msgbuf
),
10856 (uint8_t *)peer
->notify
.data
,
10857 peer
->notify
.length
);
10859 json_object_string_add(
10861 "lastShutdownDescription",
10866 json_object_string_add(json_peer
, "lastResetDueTo",
10867 peer_down_str
[(int)peer
->last_reset
]);
10868 json_object_int_add(json_peer
, "lastResetCode",
10871 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10872 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10873 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10875 bgp_notify_subcode_str(peer
->notify
.code
,
10876 peer
->notify
.subcode
);
10877 vty_out(vty
, " Notification %s (%s%s)\n",
10878 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10881 code_str
, subcode_str
);
10883 vty_out(vty
, " %s\n",
10884 peer_down_str
[(int)peer
->last_reset
]);
10889 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10892 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10895 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10896 struct peer
*peer
, json_object
*json_peer
,
10897 int max_neighbor_width
, bool use_json
)
10899 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10903 if (peer_dynamic_neighbor(peer
))
10904 json_object_boolean_true_add(json_peer
,
10906 if (peer
->hostname
)
10907 json_object_string_add(json_peer
, "hostname",
10910 if (peer
->domainname
)
10911 json_object_string_add(json_peer
, "domainname",
10913 json_object_int_add(json_peer
, "connectionsEstablished",
10914 peer
->established
);
10915 json_object_int_add(json_peer
, "connectionsDropped",
10917 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10918 use_json
, json_peer
);
10919 if (peer_established(peer
))
10920 json_object_string_add(json_peer
, "lastResetDueTo",
10921 "AFI/SAFI Not Negotiated");
10923 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10926 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10928 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10929 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10930 peer
->hostname
, peer
->host
);
10932 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10934 /* pad the neighbor column with spaces */
10935 if (len
< max_neighbor_width
)
10936 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10938 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10940 peer_uptime(peer
->uptime
, timebuf
,
10941 BGP_UPTIME_LEN
, 0, NULL
));
10942 if (peer_established(peer
))
10943 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10945 bgp_show_peer_reset(vty
, peer
, NULL
,
10950 /* If the peer's description includes whitespaces
10951 * then return the first occurrence. Also strip description
10952 * to the given size if needed.
10954 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10956 static char stripped
[BUFSIZ
];
10958 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10960 pnt
= strchr(desc
, ' ');
10962 len
= size
> (uint32_t)(pnt
- desc
) ? (uint32_t)(pnt
- desc
)
10965 strlcpy(stripped
, desc
, len
+ 1);
10970 /* Determine whether var peer should be filtered out of the summary. */
10971 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10972 struct peer
*fpeer
, int as_type
,
10976 /* filter neighbor XXXX */
10977 if (fpeer
&& fpeer
!= peer
)
10980 /* filter remote-as (internal|external) */
10981 if (as_type
!= AS_UNSPECIFIED
) {
10982 if (peer
->as_type
== AS_SPECIFIED
) {
10983 if (as_type
== AS_INTERNAL
) {
10984 if (peer
->as
!= peer
->local_as
)
10986 } else if (peer
->as
== peer
->local_as
)
10988 } else if (as_type
!= peer
->as_type
)
10990 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10996 /* Show BGP peer's summary information. */
10997 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10998 struct peer
*fpeer
, int as_type
, as_t as
,
10999 uint16_t show_flags
)
11002 struct listnode
*node
, *nnode
;
11003 unsigned int count
= 0, dn_count
= 0;
11004 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
11005 char neighbor_buf
[VTY_BUFSIZ
];
11006 int neighbor_col_default_width
= 16;
11007 int len
, failed_count
= 0;
11008 unsigned int filtered_count
= 0;
11009 int max_neighbor_width
= 0;
11011 json_object
*json
= NULL
;
11012 json_object
*json_peer
= NULL
;
11013 json_object
*json_peers
= NULL
;
11014 struct peer_af
*paf
;
11015 struct bgp_filter
*filter
;
11016 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11017 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11018 bool show_established
=
11019 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11020 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11021 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11023 /* labeled-unicast routes are installed in the unicast table so in order
11025 * display the correct PfxRcd value we must look at SAFI_UNICAST
11028 if (safi
== SAFI_LABELED_UNICAST
)
11029 pfx_rcd_safi
= SAFI_UNICAST
;
11031 pfx_rcd_safi
= safi
;
11034 json
= json_object_new_object();
11035 json_peers
= json_object_new_object();
11036 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11037 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11044 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11047 if (peer
->afc
[afi
][safi
]) {
11048 /* See if we have at least a single failed peer */
11049 if (bgp_has_peer_failed(peer
, afi
, safi
))
11053 if (peer_dynamic_neighbor(peer
))
11058 /* Loop over all neighbors that will be displayed to determine
11060 * characters are needed for the Neighbor column
11062 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11063 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11070 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11073 if (peer
->afc
[afi
][safi
]) {
11074 memset(dn_flag
, '\0', sizeof(dn_flag
));
11075 if (peer_dynamic_neighbor(peer
))
11079 && CHECK_FLAG(bgp
->flags
,
11080 BGP_FLAG_SHOW_HOSTNAME
))
11081 snprintf(neighbor_buf
,
11082 sizeof(neighbor_buf
),
11083 "%s%s(%s) ", dn_flag
,
11084 peer
->hostname
, peer
->host
);
11086 snprintf(neighbor_buf
,
11087 sizeof(neighbor_buf
), "%s%s ",
11088 dn_flag
, peer
->host
);
11090 len
= strlen(neighbor_buf
);
11092 if (len
> max_neighbor_width
)
11093 max_neighbor_width
= len
;
11095 /* See if we have at least a single failed peer */
11096 if (bgp_has_peer_failed(peer
, afi
, safi
))
11102 /* Originally we displayed the Neighbor column as 16
11103 * characters wide so make that the default
11105 if (max_neighbor_width
< neighbor_col_default_width
)
11106 max_neighbor_width
= neighbor_col_default_width
;
11109 if (show_failed
&& !failed_count
) {
11111 json_object_int_add(json
, "failedPeersCount", 0);
11112 json_object_int_add(json
, "dynamicPeers", dn_count
);
11113 json_object_int_add(json
, "totalPeers", count
);
11115 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11116 json
, JSON_C_TO_STRING_PRETTY
));
11117 json_object_free(json
);
11119 vty_out(vty
, "%% No failed BGP neighbors found\n");
11121 return CMD_SUCCESS
;
11124 count
= 0; /* Reset the value as its used again */
11125 filtered_count
= 0;
11126 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11127 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11130 if (!peer
->afc
[afi
][safi
])
11134 unsigned long ents
;
11135 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11138 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11140 : (int64_t)bgp
->vrf_id
;
11142 /* Usage summary and header */
11144 char buf
[BUFSIZ
] = {0};
11146 json_object_string_add(
11148 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
11150 json_object_int_add(json
, "as", bgp
->as
);
11151 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11152 json_object_string_add(
11155 == BGP_INSTANCE_TYPE_DEFAULT
)
11160 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11161 &bgp
->router_id
, bgp
->as
,
11162 bgp
->vrf_id
== VRF_UNKNOWN
11164 : (int)bgp
->vrf_id
);
11165 vty_out(vty
, "\n");
11168 if (bgp_update_delay_configured(bgp
)) {
11170 json_object_int_add(
11171 json
, "updateDelayLimit",
11172 bgp
->v_update_delay
);
11174 if (bgp
->v_update_delay
11175 != bgp
->v_establish_wait
)
11176 json_object_int_add(
11178 "updateDelayEstablishWait",
11179 bgp
->v_establish_wait
);
11181 if (bgp_update_delay_active(bgp
)) {
11182 json_object_string_add(
11184 "updateDelayFirstNeighbor",
11185 bgp
->update_delay_begin_time
);
11186 json_object_boolean_true_add(
11188 "updateDelayInProgress");
11190 if (bgp
->update_delay_over
) {
11191 json_object_string_add(
11193 "updateDelayFirstNeighbor",
11194 bgp
->update_delay_begin_time
);
11195 json_object_string_add(
11197 "updateDelayBestpathResumed",
11198 bgp
->update_delay_end_time
);
11199 json_object_string_add(
11201 "updateDelayZebraUpdateResume",
11202 bgp
->update_delay_zebra_resume_time
);
11203 json_object_string_add(
11205 "updateDelayPeerUpdateResume",
11206 bgp
->update_delay_peers_resume_time
);
11211 "Read-only mode update-delay limit: %d seconds\n",
11212 bgp
->v_update_delay
);
11213 if (bgp
->v_update_delay
11214 != bgp
->v_establish_wait
)
11216 " Establish wait: %d seconds\n",
11217 bgp
->v_establish_wait
);
11219 if (bgp_update_delay_active(bgp
)) {
11221 " First neighbor established: %s\n",
11222 bgp
->update_delay_begin_time
);
11224 " Delay in progress\n");
11226 if (bgp
->update_delay_over
) {
11228 " First neighbor established: %s\n",
11229 bgp
->update_delay_begin_time
);
11231 " Best-paths resumed: %s\n",
11232 bgp
->update_delay_end_time
);
11234 " zebra update resumed: %s\n",
11235 bgp
->update_delay_zebra_resume_time
);
11237 " peers update resumed: %s\n",
11238 bgp
->update_delay_peers_resume_time
);
11245 if (bgp_maxmed_onstartup_configured(bgp
)
11246 && bgp
->maxmed_active
)
11247 json_object_boolean_true_add(
11248 json
, "maxMedOnStartup");
11249 if (bgp
->v_maxmed_admin
)
11250 json_object_boolean_true_add(
11251 json
, "maxMedAdministrative");
11253 json_object_int_add(
11254 json
, "tableVersion",
11255 bgp_table_version(bgp
->rib
[afi
][safi
]));
11257 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11258 json_object_int_add(json
, "ribCount", ents
);
11259 json_object_int_add(
11261 ents
* sizeof(struct bgp_dest
));
11263 ents
= bgp
->af_peer_count
[afi
][safi
];
11264 json_object_int_add(json
, "peerCount", ents
);
11265 json_object_int_add(json
, "peerMemory",
11266 ents
* sizeof(struct peer
));
11268 if ((ents
= listcount(bgp
->group
))) {
11269 json_object_int_add(
11270 json
, "peerGroupCount", ents
);
11271 json_object_int_add(
11272 json
, "peerGroupMemory",
11273 ents
* sizeof(struct
11277 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11278 BGP_CONFIG_DAMPENING
))
11279 json_object_boolean_true_add(
11280 json
, "dampeningEnabled");
11283 if (bgp_maxmed_onstartup_configured(bgp
)
11284 && bgp
->maxmed_active
)
11286 "Max-med on-startup active\n");
11287 if (bgp
->v_maxmed_admin
)
11289 "Max-med administrative active\n");
11292 "BGP table version %" PRIu64
11295 bgp
->rib
[afi
][safi
]));
11297 ents
= bgp_table_count(
11298 bgp
->rib
[afi
][safi
]);
11300 "RIB entries %ld, using %s of memory\n",
11310 /* Peer related usage */
11311 ents
= bgp
->af_peer_count
[afi
][safi
];
11313 "Peers %ld, using %s of memory\n",
11323 if ((ents
= listcount(bgp
->group
)))
11325 "Peer groups %ld, using %s of memory\n",
11335 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11336 BGP_CONFIG_DAMPENING
))
11338 "Dampening enabled.\n");
11341 vty_out(vty
, "\n");
11343 /* Subtract 8 here because 'Neighbor' is
11345 vty_out(vty
, "Neighbor");
11346 vty_out(vty
, "%*s",
11347 max_neighbor_width
- 8, " ");
11349 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11354 paf
= peer_af_find(peer
, afi
, safi
);
11355 filter
= &peer
->filter
[afi
][safi
];
11358 /* Works for both failed & successful cases */
11359 if (peer_dynamic_neighbor(peer
))
11364 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11370 bgp_has_peer_failed(peer
, afi
, safi
)) {
11371 json_peer
= json_object_new_object();
11372 bgp_show_failed_summary(vty
, bgp
, peer
,
11373 json_peer
, 0, use_json
);
11374 } else if (!show_failed
) {
11375 if (show_established
11376 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11381 json_peer
= json_object_new_object();
11382 if (peer_dynamic_neighbor(peer
)) {
11383 json_object_boolean_true_add(json_peer
,
11387 if (peer
->hostname
)
11388 json_object_string_add(json_peer
, "hostname",
11391 if (peer
->domainname
)
11392 json_object_string_add(json_peer
, "domainname",
11395 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11396 json_object_int_add(
11397 json_peer
, "localAs",
11398 peer
->change_local_as
11399 ? peer
->change_local_as
11401 json_object_int_add(json_peer
, "version", 4);
11402 json_object_int_add(json_peer
, "msgRcvd",
11403 PEER_TOTAL_RX(peer
));
11404 json_object_int_add(json_peer
, "msgSent",
11405 PEER_TOTAL_TX(peer
));
11407 atomic_size_t outq_count
, inq_count
;
11408 outq_count
= atomic_load_explicit(
11409 &peer
->obuf
->count
,
11410 memory_order_relaxed
);
11411 inq_count
= atomic_load_explicit(
11412 &peer
->ibuf
->count
,
11413 memory_order_relaxed
);
11415 json_object_int_add(json_peer
, "tableVersion",
11416 peer
->version
[afi
][safi
]);
11417 json_object_int_add(json_peer
, "outq",
11419 json_object_int_add(json_peer
, "inq",
11421 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11422 use_json
, json_peer
);
11424 json_object_int_add(json_peer
, "pfxRcd",
11425 peer
->pcount
[afi
][pfx_rcd_safi
]);
11427 if (paf
&& PAF_SUBGRP(paf
))
11428 json_object_int_add(
11429 json_peer
, "pfxSnt",
11430 (PAF_SUBGRP(paf
))->scount
);
11432 json_object_int_add(json_peer
, "pfxSnt",
11435 /* BGP FSM state */
11436 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11437 || CHECK_FLAG(peer
->bgp
->flags
,
11438 BGP_FLAG_SHUTDOWN
))
11439 json_object_string_add(json_peer
,
11442 else if (peer
->afc_recv
[afi
][safi
])
11443 json_object_string_add(
11444 json_peer
, "state",
11445 lookup_msg(bgp_status_msg
,
11446 peer
->status
, NULL
));
11447 else if (CHECK_FLAG(
11449 PEER_STATUS_PREFIX_OVERFLOW
))
11450 json_object_string_add(json_peer
,
11454 json_object_string_add(
11455 json_peer
, "state",
11456 lookup_msg(bgp_status_msg
,
11457 peer
->status
, NULL
));
11459 /* BGP peer state */
11460 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11461 || CHECK_FLAG(peer
->bgp
->flags
,
11462 BGP_FLAG_SHUTDOWN
))
11463 json_object_string_add(json_peer
,
11466 else if (CHECK_FLAG(
11468 PEER_STATUS_PREFIX_OVERFLOW
))
11469 json_object_string_add(json_peer
,
11472 else if (CHECK_FLAG(peer
->flags
,
11473 PEER_FLAG_PASSIVE
))
11474 json_object_string_add(json_peer
,
11477 else if (CHECK_FLAG(peer
->sflags
,
11478 PEER_STATUS_NSF_WAIT
))
11479 json_object_string_add(json_peer
,
11482 else if (CHECK_FLAG(
11484 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11485 && (!bgp_inbound_policy_exists(peer
,
11487 || !bgp_outbound_policy_exists(
11489 json_object_string_add(json_peer
,
11493 json_object_string_add(
11494 json_peer
, "peerState", "OK");
11496 json_object_int_add(json_peer
, "connectionsEstablished",
11497 peer
->established
);
11498 json_object_int_add(json_peer
, "connectionsDropped",
11501 json_object_string_add(
11502 json_peer
, "desc", peer
->desc
);
11504 /* Avoid creating empty peer dicts in JSON */
11505 if (json_peer
== NULL
)
11509 json_object_string_add(json_peer
, "idType",
11511 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11512 json_object_string_add(json_peer
, "idType",
11514 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11515 json_object_string_add(json_peer
, "idType",
11517 json_object_object_add(json_peers
, peer
->host
,
11520 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11526 bgp_has_peer_failed(peer
, afi
, safi
)) {
11527 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11528 max_neighbor_width
,
11530 } else if (!show_failed
) {
11531 if (show_established
11532 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11537 if ((count
- filtered_count
) == 1) {
11538 /* display headline before the first
11540 vty_out(vty
, "\n");
11542 /* Subtract 8 here because 'Neighbor' is
11544 vty_out(vty
, "Neighbor");
11545 vty_out(vty
, "%*s",
11546 max_neighbor_width
- 8, " ");
11549 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11550 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11553 memset(dn_flag
, '\0', sizeof(dn_flag
));
11554 if (peer_dynamic_neighbor(peer
)) {
11559 && CHECK_FLAG(bgp
->flags
,
11560 BGP_FLAG_SHOW_HOSTNAME
))
11561 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11565 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11567 /* pad the neighbor column with spaces */
11568 if (len
< max_neighbor_width
)
11569 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11572 atomic_size_t outq_count
, inq_count
;
11573 outq_count
= atomic_load_explicit(
11574 &peer
->obuf
->count
,
11575 memory_order_relaxed
);
11576 inq_count
= atomic_load_explicit(
11577 &peer
->ibuf
->count
,
11578 memory_order_relaxed
);
11582 "4 %10u %10u %9u %9u %8" PRIu64
11585 peer
->change_local_as
11586 ? peer
->change_local_as
11588 PEER_TOTAL_RX(peer
),
11589 PEER_TOTAL_TX(peer
),
11590 peer
->version
[afi
][safi
],
11591 inq_count
, outq_count
,
11592 peer_uptime(peer
->uptime
,
11597 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11599 peer
->as
, PEER_TOTAL_RX(peer
),
11600 PEER_TOTAL_TX(peer
),
11601 peer
->version
[afi
][safi
],
11602 inq_count
, outq_count
,
11603 peer_uptime(peer
->uptime
,
11608 if (peer_established(peer
)) {
11609 if (peer
->afc_recv
[afi
][safi
]) {
11612 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11613 && !bgp_inbound_policy_exists(
11615 vty_out(vty
, " %12s",
11624 vty_out(vty
, " NoNeg");
11627 if (paf
&& PAF_SUBGRP(paf
)) {
11630 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11631 && !bgp_outbound_policy_exists(
11633 vty_out(vty
, " %8s",
11642 vty_out(vty
, " NoNeg");
11645 if (CHECK_FLAG(peer
->flags
,
11646 PEER_FLAG_SHUTDOWN
)
11647 || CHECK_FLAG(peer
->bgp
->flags
,
11648 BGP_FLAG_SHUTDOWN
))
11649 vty_out(vty
, " Idle (Admin)");
11650 else if (CHECK_FLAG(
11652 PEER_STATUS_PREFIX_OVERFLOW
))
11653 vty_out(vty
, " Idle (PfxCt)");
11655 vty_out(vty
, " %12s",
11656 lookup_msg(bgp_status_msg
,
11657 peer
->status
, NULL
));
11659 vty_out(vty
, " %8u", 0);
11662 vty_out(vty
, " %s",
11663 bgp_peer_description_stripped(
11665 show_wide
? 64 : 20));
11667 vty_out(vty
, " N/A");
11668 vty_out(vty
, "\n");
11675 json_object_object_add(json
, "peers", json_peers
);
11676 json_object_int_add(json
, "failedPeers", failed_count
);
11677 json_object_int_add(json
, "displayedPeers",
11678 count
- filtered_count
);
11679 json_object_int_add(json
, "totalPeers", count
);
11680 json_object_int_add(json
, "dynamicPeers", dn_count
);
11683 bgp_show_bestpath_json(bgp
, json
);
11685 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11686 json
, JSON_C_TO_STRING_PRETTY
));
11687 json_object_free(json
);
11690 if (filtered_count
== count
)
11691 vty_out(vty
, "\n%% No matching neighbor\n");
11694 vty_out(vty
, "\nDisplayed neighbors %d",
11696 else if (as_type
!= AS_UNSPECIFIED
|| as
11697 || fpeer
|| show_established
)
11698 vty_out(vty
, "\nDisplayed neighbors %d",
11699 count
- filtered_count
);
11701 vty_out(vty
, "\nTotal number of neighbors %d\n",
11705 vty_out(vty
, "No %s neighbor is configured\n",
11706 get_afi_safi_str(afi
, safi
, false));
11710 vty_out(vty
, "* - dynamic neighbor\n");
11711 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11712 dn_count
, bgp
->dynamic_neighbors_limit
);
11716 return CMD_SUCCESS
;
11719 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11720 int safi
, struct peer
*fpeer
, int as_type
,
11721 as_t as
, uint16_t show_flags
)
11724 int afi_wildcard
= (afi
== AFI_MAX
);
11725 int safi_wildcard
= (safi
== SAFI_MAX
);
11726 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11727 bool nbr_output
= false;
11728 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11730 if (use_json
&& is_wildcard
)
11731 vty_out(vty
, "{\n");
11733 afi
= 1; /* AFI_IP */
11734 while (afi
< AFI_MAX
) {
11736 safi
= 1; /* SAFI_UNICAST */
11737 while (safi
< SAFI_MAX
) {
11738 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11743 * So limit output to those afi/safi
11745 * actualy have something interesting in
11750 vty_out(vty
, ",\n");
11754 vty_out(vty
, "\"%s\":",
11755 get_afi_safi_str(afi
,
11760 "\n%s Summary (%s):\n",
11761 get_afi_safi_str(afi
,
11767 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11768 as_type
, as
, show_flags
);
11771 if (!safi_wildcard
)
11779 if (use_json
&& is_wildcard
)
11780 vty_out(vty
, "}\n");
11781 else if (!nbr_output
) {
11783 vty_out(vty
, "{}\n");
11785 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11790 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11792 const char *neighbor
,
11793 int as_type
, as_t as
,
11794 uint16_t show_flags
)
11796 struct listnode
*node
, *nnode
;
11798 struct peer
*fpeer
= NULL
;
11800 bool nbr_output
= false;
11801 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11804 vty_out(vty
, "{\n");
11806 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11810 vty_out(vty
, ",\n");
11814 vty_out(vty
, "\"%s\":",
11815 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11820 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11825 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11830 vty_out(vty
, "}\n");
11831 else if (!nbr_output
)
11832 vty_out(vty
, "%% BGP instance not found\n");
11835 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11836 safi_t safi
, const char *neighbor
, int as_type
,
11837 as_t as
, uint16_t show_flags
)
11840 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11841 struct peer
*fpeer
= NULL
;
11844 if (strmatch(name
, "all")) {
11845 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11848 return CMD_SUCCESS
;
11850 bgp
= bgp_lookup_by_name(name
);
11854 vty_out(vty
, "{}\n");
11857 "%% BGP instance not found\n");
11858 return CMD_WARNING
;
11862 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11865 return CMD_WARNING
;
11867 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11868 as_type
, as
, show_flags
);
11869 return CMD_SUCCESS
;
11873 bgp
= bgp_get_default();
11877 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11880 return CMD_WARNING
;
11882 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11886 vty_out(vty
, "{}\n");
11888 vty_out(vty
, "%% BGP instance not found\n");
11889 return CMD_WARNING
;
11892 return CMD_SUCCESS
;
11895 /* `show [ip] bgp summary' commands. */
11896 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11897 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11898 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11899 "]] [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]",
11900 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11901 BGP_SAFI_WITH_LABEL_HELP_STR
11902 "Display the entries for all address families\n"
11903 "Summary of BGP neighbor status\n"
11904 "Show only sessions in Established state\n"
11905 "Show only sessions not in Established state\n"
11906 "Show only the specified neighbor session\n"
11907 "Neighbor to display information about\n"
11908 "Neighbor to display information about\n"
11909 "Neighbor on BGP configured interface\n"
11910 "Show only the specified remote AS sessions\n"
11912 "Internal (iBGP) AS sessions\n"
11913 "External (eBGP) AS sessions\n"
11914 "Shorten the information on BGP instances\n"
11915 "Increase table width for longer output\n" JSON_STR
)
11918 afi_t afi
= AFI_MAX
;
11919 safi_t safi
= SAFI_MAX
;
11920 as_t as
= 0; /* 0 means AS filter not set */
11921 int as_type
= AS_UNSPECIFIED
;
11922 uint16_t show_flags
= 0;
11926 /* show [ip] bgp */
11927 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11929 /* [<vrf> VIEWVRFNAME] */
11930 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11931 vrf
= argv
[idx
+ 1]->arg
;
11932 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11934 } else if (argv_find(argv
, argc
, "view", &idx
))
11935 /* [<view> VIEWVRFNAME] */
11936 vrf
= argv
[idx
+ 1]->arg
;
11937 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11938 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11939 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11942 if (argv_find(argv
, argc
, "failed", &idx
))
11943 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11945 if (argv_find(argv
, argc
, "established", &idx
))
11946 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11948 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11949 if (argv
[idx
+ 1]->arg
[0] == 'i')
11950 as_type
= AS_INTERNAL
;
11951 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11952 as_type
= AS_EXTERNAL
;
11954 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11957 if (argv_find(argv
, argc
, "terse", &idx
))
11958 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11960 if (argv_find(argv
, argc
, "wide", &idx
))
11961 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11963 if (argv_find(argv
, argc
, "json", &idx
))
11964 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11966 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11970 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11973 return get_afi_safi_json_str(afi
, safi
);
11975 return get_afi_safi_vty_str(afi
, safi
);
11979 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11980 afi_t afi
, safi_t safi
,
11981 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11982 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11983 bool use_json
, json_object
*json_pref
)
11986 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11987 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11989 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11990 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11991 json_object_string_add(json_pref
, "sendMode",
11992 "advertisedAndReceived");
11993 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11994 json_object_string_add(json_pref
, "sendMode",
11996 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11997 json_object_string_add(json_pref
, "sendMode",
12000 vty_out(vty
, " Send-mode: ");
12001 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
12002 vty_out(vty
, "advertised");
12003 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
12004 vty_out(vty
, "%sreceived",
12005 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12009 vty_out(vty
, "\n");
12014 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12015 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
12017 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12018 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12019 json_object_string_add(json_pref
, "recvMode",
12020 "advertisedAndReceived");
12021 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12022 json_object_string_add(json_pref
, "recvMode",
12024 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12025 json_object_string_add(json_pref
, "recvMode",
12028 vty_out(vty
, " Receive-mode: ");
12029 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12030 vty_out(vty
, "advertised");
12031 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12032 vty_out(vty
, "%sreceived",
12033 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12037 vty_out(vty
, "\n");
12042 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
12047 bool rbit_status
= false;
12050 vty_out(vty
, "\n R bit: ");
12052 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12053 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12054 && (peer_established(p
))) {
12056 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
12057 rbit_status
= true;
12059 rbit_status
= false;
12064 json_object_boolean_true_add(json
, "rBit");
12066 vty_out(vty
, "True\n");
12069 json_object_boolean_false_add(json
, "rBit");
12071 vty_out(vty
, "False\n");
12075 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12080 const char *mode
= "NotApplicable";
12083 vty_out(vty
, "\n Remote GR Mode: ");
12085 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12086 && (peer_established(peer
))) {
12088 if ((peer
->nsf_af_count
== 0)
12089 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12093 } else if (peer
->nsf_af_count
== 0
12094 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12098 } else if (peer
->nsf_af_count
!= 0
12099 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12106 json_object_string_add(json
, "remoteGrMode", mode
);
12108 vty_out(vty
, mode
, "\n");
12111 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12116 const char *mode
= "Invalid";
12119 vty_out(vty
, " Local GR Mode: ");
12121 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12123 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12125 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12127 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12128 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12130 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12132 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12139 json_object_string_add(json
, "localGrMode", mode
);
12141 vty_out(vty
, mode
, "\n");
12145 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12146 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
12150 json_object
*json_afi_safi
= NULL
;
12151 json_object
*json_timer
= NULL
;
12152 json_object
*json_endofrib_status
= NULL
;
12153 bool eor_flag
= false;
12155 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12156 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
12157 if (!peer
->afc
[afi
][safi
])
12160 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12161 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12165 json_afi_safi
= json_object_new_object();
12166 json_endofrib_status
= json_object_new_object();
12167 json_timer
= json_object_new_object();
12170 if (peer
->eor_stime
[afi
][safi
]
12171 >= peer
->pkt_stime
[afi
][safi
])
12177 vty_out(vty
, " %s:\n",
12178 get_afi_safi_str(afi
, safi
, false));
12180 vty_out(vty
, " F bit: ");
12183 if (peer
->nsf
[afi
][safi
]
12184 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12185 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12188 json_object_boolean_true_add(
12189 json_afi_safi
, "fBit");
12191 vty_out(vty
, "True\n");
12194 json_object_boolean_false_add(
12195 json_afi_safi
, "fBit");
12197 vty_out(vty
, "False\n");
12201 vty_out(vty
, " End-of-RIB sent: ");
12203 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12204 PEER_STATUS_EOR_SEND
)) {
12206 json_object_boolean_true_add(
12207 json_endofrib_status
,
12210 PRINT_EOR_JSON(eor_flag
);
12212 vty_out(vty
, "Yes\n");
12214 " End-of-RIB sent after update: ");
12216 PRINT_EOR(eor_flag
);
12220 json_object_boolean_false_add(
12221 json_endofrib_status
,
12223 json_object_boolean_false_add(
12224 json_endofrib_status
,
12225 "endOfRibSentAfterUpdate");
12227 vty_out(vty
, "No\n");
12229 " End-of-RIB sent after update: ");
12230 vty_out(vty
, "No\n");
12235 vty_out(vty
, " End-of-RIB received: ");
12237 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12238 PEER_STATUS_EOR_RECEIVED
)) {
12240 json_object_boolean_true_add(
12241 json_endofrib_status
,
12244 vty_out(vty
, "Yes\n");
12247 json_object_boolean_false_add(
12248 json_endofrib_status
,
12251 vty_out(vty
, "No\n");
12255 json_object_int_add(json_timer
,
12257 peer
->bgp
->stalepath_time
);
12259 if (peer
->t_gr_stale
!= NULL
) {
12260 json_object_int_add(
12262 "stalePathTimerRemaining",
12263 thread_timer_remain_second(
12264 peer
->t_gr_stale
));
12267 /* Display Configured Selection
12268 * Deferral only when when
12269 * Gr mode is enabled.
12271 if (CHECK_FLAG(peer
->flags
,
12272 PEER_FLAG_GRACEFUL_RESTART
)) {
12273 json_object_int_add(
12275 "selectionDeferralTimer",
12276 peer
->bgp
->stalepath_time
);
12279 if (peer
->bgp
->gr_info
[afi
][safi
]
12283 json_object_int_add(
12285 "selectionDeferralTimerRemaining",
12286 thread_timer_remain_second(
12290 .t_select_deferral
));
12293 vty_out(vty
, " Timers:\n");
12295 " Configured Stale Path Time(sec): %u\n",
12296 peer
->bgp
->stalepath_time
);
12298 if (peer
->t_gr_stale
!= NULL
)
12300 " Stale Path Remaining(sec): %ld\n",
12301 thread_timer_remain_second(
12302 peer
->t_gr_stale
));
12303 /* Display Configured Selection
12304 * Deferral only when when
12305 * Gr mode is enabled.
12307 if (CHECK_FLAG(peer
->flags
,
12308 PEER_FLAG_GRACEFUL_RESTART
))
12310 " Configured Selection Deferral Time(sec): %u\n",
12311 peer
->bgp
->select_defer_time
);
12313 if (peer
->bgp
->gr_info
[afi
][safi
]
12317 " Selection Deferral Time Remaining(sec): %ld\n",
12318 thread_timer_remain_second(
12322 .t_select_deferral
));
12325 json_object_object_add(json_afi_safi
,
12327 json_endofrib_status
);
12328 json_object_object_add(json_afi_safi
, "timers",
12330 json_object_object_add(
12331 json
, get_afi_safi_str(afi
, safi
, true),
12338 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12344 json_object
*json_timer
= NULL
;
12346 json_timer
= json_object_new_object();
12348 json_object_int_add(json_timer
, "configuredRestartTimer",
12349 p
->bgp
->restart_time
);
12351 json_object_int_add(json_timer
, "receivedRestartTimer",
12354 if (p
->t_gr_restart
!= NULL
)
12355 json_object_int_add(
12356 json_timer
, "restartTimerRemaining",
12357 thread_timer_remain_second(p
->t_gr_restart
));
12359 json_object_object_add(json
, "timers", json_timer
);
12362 vty_out(vty
, " Timers:\n");
12363 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12364 p
->bgp
->restart_time
);
12366 vty_out(vty
, " Received Restart Time(sec): %u\n",
12368 if (p
->t_gr_restart
!= NULL
)
12369 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12370 thread_timer_remain_second(p
->t_gr_restart
));
12371 if (p
->t_gr_restart
!= NULL
) {
12372 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12373 thread_timer_remain_second(p
->t_gr_restart
));
12378 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12379 bool use_json
, json_object
*json
)
12381 char buf
[SU_ADDRSTRLEN
] = {0};
12382 char dn_flag
[2] = {0};
12383 /* '*' + v6 address of neighbor */
12384 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12386 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12391 json_object_string_add(
12392 json
, "neighborAddr",
12393 BGP_PEER_SU_UNSPEC(p
)
12395 : sockunion2str(&p
->su
, buf
,
12398 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
12399 BGP_PEER_SU_UNSPEC(p
)
12401 : sockunion2str(&p
->su
, buf
,
12404 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12408 json_object_string_add(json
, "neighborAddr",
12411 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12414 /* more gr info in new format */
12415 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12418 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12419 safi_t safi
, bool use_json
,
12420 json_object
*json_neigh
)
12422 struct bgp_filter
*filter
;
12423 struct peer_af
*paf
;
12424 char orf_pfx_name
[BUFSIZ
];
12426 json_object
*json_af
= NULL
;
12427 json_object
*json_prefA
= NULL
;
12428 json_object
*json_prefB
= NULL
;
12429 json_object
*json_addr
= NULL
;
12430 json_object
*json_advmap
= NULL
;
12433 json_addr
= json_object_new_object();
12434 json_af
= json_object_new_object();
12435 filter
= &p
->filter
[afi
][safi
];
12437 if (peer_group_active(p
))
12438 json_object_string_add(json_addr
, "peerGroupMember",
12441 paf
= peer_af_find(p
, afi
, safi
);
12442 if (paf
&& PAF_SUBGRP(paf
)) {
12443 json_object_int_add(json_addr
, "updateGroupId",
12444 PAF_UPDGRP(paf
)->id
);
12445 json_object_int_add(json_addr
, "subGroupId",
12446 PAF_SUBGRP(paf
)->id
);
12447 json_object_int_add(json_addr
, "packetQueueLength",
12448 bpacket_queue_virtual_length(paf
));
12451 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12452 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12453 PEER_CAP_ORF_PREFIX_SM_RCV
)
12454 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12455 PEER_CAP_ORF_PREFIX_RM_ADV
)
12456 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12457 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12458 json_object_int_add(json_af
, "orfType",
12460 json_prefA
= json_object_new_object();
12461 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12462 PEER_CAP_ORF_PREFIX_SM_ADV
,
12463 PEER_CAP_ORF_PREFIX_RM_ADV
,
12464 PEER_CAP_ORF_PREFIX_SM_RCV
,
12465 PEER_CAP_ORF_PREFIX_RM_RCV
,
12466 use_json
, json_prefA
);
12467 json_object_object_add(json_af
, "orfPrefixList",
12471 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12472 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12473 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12474 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12475 PEER_CAP_ORF_PREFIX_RM_ADV
)
12476 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12477 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12478 json_object_int_add(json_af
, "orfOldType",
12479 ORF_TYPE_PREFIX_OLD
);
12480 json_prefB
= json_object_new_object();
12481 bgp_show_peer_afi_orf_cap(
12482 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12483 PEER_CAP_ORF_PREFIX_RM_ADV
,
12484 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12485 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12487 json_object_object_add(json_af
, "orfOldPrefixList",
12491 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12492 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12493 PEER_CAP_ORF_PREFIX_SM_RCV
)
12494 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12495 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12496 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12497 PEER_CAP_ORF_PREFIX_RM_ADV
)
12498 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12499 PEER_CAP_ORF_PREFIX_RM_RCV
)
12500 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12501 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12502 json_object_object_add(json_addr
, "afDependentCap",
12505 json_object_free(json_af
);
12507 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12508 p
->host
, afi
, safi
);
12509 orf_pfx_count
= prefix_bgp_show_prefix_list(
12510 NULL
, afi
, orf_pfx_name
, use_json
);
12512 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12513 PEER_STATUS_ORF_PREFIX_SEND
)
12514 || orf_pfx_count
) {
12515 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12516 PEER_STATUS_ORF_PREFIX_SEND
))
12517 json_object_boolean_true_add(json_neigh
,
12520 json_object_int_add(json_addr
, "orfRecvCounter",
12523 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12524 PEER_STATUS_ORF_WAIT_REFRESH
))
12525 json_object_string_add(
12526 json_addr
, "orfFirstUpdate",
12527 "deferredUntilORFOrRouteRefreshRecvd");
12529 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12530 PEER_FLAG_REFLECTOR_CLIENT
))
12531 json_object_boolean_true_add(json_addr
,
12532 "routeReflectorClient");
12533 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12534 PEER_FLAG_RSERVER_CLIENT
))
12535 json_object_boolean_true_add(json_addr
,
12536 "routeServerClient");
12537 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12538 json_object_boolean_true_add(json_addr
,
12539 "inboundSoftConfigPermit");
12541 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12542 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12543 json_object_boolean_true_add(
12545 "privateAsNumsAllReplacedInUpdatesToNbr");
12546 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12547 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12548 json_object_boolean_true_add(
12550 "privateAsNumsReplacedInUpdatesToNbr");
12551 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12552 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12553 json_object_boolean_true_add(
12555 "privateAsNumsAllRemovedInUpdatesToNbr");
12556 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12557 PEER_FLAG_REMOVE_PRIVATE_AS
))
12558 json_object_boolean_true_add(
12560 "privateAsNumsRemovedInUpdatesToNbr");
12562 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12563 json_object_boolean_true_add(
12565 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12568 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12569 json_object_string_add(json_addr
,
12570 "overrideASNsInOutboundUpdates",
12571 "ifAspathEqualRemoteAs");
12573 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12574 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12575 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12576 json_object_boolean_true_add(json_addr
,
12577 "routerAlwaysNextHop");
12578 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12579 PEER_FLAG_AS_PATH_UNCHANGED
))
12580 json_object_boolean_true_add(
12581 json_addr
, "unchangedAsPathPropogatedToNbr");
12582 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12583 PEER_FLAG_NEXTHOP_UNCHANGED
))
12584 json_object_boolean_true_add(
12585 json_addr
, "unchangedNextHopPropogatedToNbr");
12586 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12587 json_object_boolean_true_add(
12588 json_addr
, "unchangedMedPropogatedToNbr");
12589 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12590 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12591 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12592 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12593 PEER_FLAG_SEND_COMMUNITY
)
12594 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12595 PEER_FLAG_SEND_EXT_COMMUNITY
))
12596 json_object_string_add(json_addr
,
12597 "commAttriSentToNbr",
12598 "extendedAndStandard");
12599 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12600 PEER_FLAG_SEND_EXT_COMMUNITY
))
12601 json_object_string_add(json_addr
,
12602 "commAttriSentToNbr",
12605 json_object_string_add(json_addr
,
12606 "commAttriSentToNbr",
12609 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12610 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12611 if (p
->default_rmap
[afi
][safi
].name
)
12612 json_object_string_add(
12613 json_addr
, "defaultRouteMap",
12614 p
->default_rmap
[afi
][safi
].name
);
12616 if (paf
&& PAF_SUBGRP(paf
)
12617 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12618 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12619 json_object_boolean_true_add(json_addr
,
12622 json_object_boolean_true_add(json_addr
,
12626 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12627 if (is_evpn_enabled())
12628 json_object_boolean_true_add(
12629 json_addr
, "advertiseAllVnis");
12632 if (filter
->plist
[FILTER_IN
].name
12633 || filter
->dlist
[FILTER_IN
].name
12634 || filter
->aslist
[FILTER_IN
].name
12635 || filter
->map
[RMAP_IN
].name
)
12636 json_object_boolean_true_add(json_addr
,
12637 "inboundPathPolicyConfig");
12638 if (filter
->plist
[FILTER_OUT
].name
12639 || filter
->dlist
[FILTER_OUT
].name
12640 || filter
->aslist
[FILTER_OUT
].name
12641 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12642 json_object_boolean_true_add(
12643 json_addr
, "outboundPathPolicyConfig");
12646 if (filter
->plist
[FILTER_IN
].name
)
12647 json_object_string_add(json_addr
,
12648 "incomingUpdatePrefixFilterList",
12649 filter
->plist
[FILTER_IN
].name
);
12650 if (filter
->plist
[FILTER_OUT
].name
)
12651 json_object_string_add(json_addr
,
12652 "outgoingUpdatePrefixFilterList",
12653 filter
->plist
[FILTER_OUT
].name
);
12655 /* distribute-list */
12656 if (filter
->dlist
[FILTER_IN
].name
)
12657 json_object_string_add(
12658 json_addr
, "incomingUpdateNetworkFilterList",
12659 filter
->dlist
[FILTER_IN
].name
);
12660 if (filter
->dlist
[FILTER_OUT
].name
)
12661 json_object_string_add(
12662 json_addr
, "outgoingUpdateNetworkFilterList",
12663 filter
->dlist
[FILTER_OUT
].name
);
12666 if (filter
->aslist
[FILTER_IN
].name
)
12667 json_object_string_add(json_addr
,
12668 "incomingUpdateAsPathFilterList",
12669 filter
->aslist
[FILTER_IN
].name
);
12670 if (filter
->aslist
[FILTER_OUT
].name
)
12671 json_object_string_add(json_addr
,
12672 "outgoingUpdateAsPathFilterList",
12673 filter
->aslist
[FILTER_OUT
].name
);
12676 if (filter
->map
[RMAP_IN
].name
)
12677 json_object_string_add(
12678 json_addr
, "routeMapForIncomingAdvertisements",
12679 filter
->map
[RMAP_IN
].name
);
12680 if (filter
->map
[RMAP_OUT
].name
)
12681 json_object_string_add(
12682 json_addr
, "routeMapForOutgoingAdvertisements",
12683 filter
->map
[RMAP_OUT
].name
);
12685 /* ebgp-requires-policy (inbound) */
12686 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12687 && !bgp_inbound_policy_exists(p
, filter
))
12688 json_object_string_add(
12689 json_addr
, "inboundEbgpRequiresPolicy",
12690 "Inbound updates discarded due to missing policy");
12692 /* ebgp-requires-policy (outbound) */
12693 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12694 && (!bgp_outbound_policy_exists(p
, filter
)))
12695 json_object_string_add(
12696 json_addr
, "outboundEbgpRequiresPolicy",
12697 "Outbound updates discarded due to missing policy");
12699 /* unsuppress-map */
12700 if (filter
->usmap
.name
)
12701 json_object_string_add(json_addr
,
12702 "selectiveUnsuppressRouteMap",
12703 filter
->usmap
.name
);
12705 /* advertise-map */
12706 if (filter
->advmap
.aname
) {
12707 json_advmap
= json_object_new_object();
12708 json_object_string_add(json_advmap
, "condition",
12709 filter
->advmap
.condition
12712 json_object_string_add(json_advmap
, "conditionMap",
12713 filter
->advmap
.cname
);
12714 json_object_string_add(json_advmap
, "advertiseMap",
12715 filter
->advmap
.aname
);
12716 json_object_string_add(json_advmap
, "advertiseStatus",
12717 filter
->advmap
.update_type
12721 json_object_object_add(json_addr
, "advertiseMap",
12725 /* Receive prefix count */
12726 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12727 p
->pcount
[afi
][safi
]);
12728 if (paf
&& PAF_SUBGRP(paf
))
12729 json_object_int_add(json_addr
, "sentPrefixCounter",
12730 (PAF_SUBGRP(paf
))->scount
);
12732 /* Maximum prefix */
12733 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12734 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12735 p
->pmax_out
[afi
][safi
]);
12737 /* Maximum prefix */
12738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12739 json_object_int_add(json_addr
, "prefixAllowedMax",
12740 p
->pmax
[afi
][safi
]);
12741 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12742 PEER_FLAG_MAX_PREFIX_WARNING
))
12743 json_object_boolean_true_add(
12744 json_addr
, "prefixAllowedMaxWarning");
12745 json_object_int_add(json_addr
,
12746 "prefixAllowedWarningThresh",
12747 p
->pmax_threshold
[afi
][safi
]);
12748 if (p
->pmax_restart
[afi
][safi
])
12749 json_object_int_add(
12751 "prefixAllowedRestartIntervalMsecs",
12752 p
->pmax_restart
[afi
][safi
] * 60000);
12754 json_object_object_add(json_neigh
,
12755 get_afi_safi_str(afi
, safi
, true),
12759 filter
= &p
->filter
[afi
][safi
];
12761 vty_out(vty
, " For address family: %s\n",
12762 get_afi_safi_str(afi
, safi
, false));
12764 if (peer_group_active(p
))
12765 vty_out(vty
, " %s peer-group member\n",
12768 paf
= peer_af_find(p
, afi
, safi
);
12769 if (paf
&& PAF_SUBGRP(paf
)) {
12770 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12771 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12772 vty_out(vty
, " Packet Queue length %d\n",
12773 bpacket_queue_virtual_length(paf
));
12775 vty_out(vty
, " Not part of any update group\n");
12777 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12778 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12779 PEER_CAP_ORF_PREFIX_SM_RCV
)
12780 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12781 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12782 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12783 PEER_CAP_ORF_PREFIX_RM_ADV
)
12784 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12785 PEER_CAP_ORF_PREFIX_RM_RCV
)
12786 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12787 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12788 vty_out(vty
, " AF-dependant capabilities:\n");
12790 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12791 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12792 PEER_CAP_ORF_PREFIX_SM_RCV
)
12793 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12794 PEER_CAP_ORF_PREFIX_RM_ADV
)
12795 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12796 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12798 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12800 bgp_show_peer_afi_orf_cap(
12801 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12802 PEER_CAP_ORF_PREFIX_RM_ADV
,
12803 PEER_CAP_ORF_PREFIX_SM_RCV
,
12804 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12806 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12807 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12808 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12809 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12810 PEER_CAP_ORF_PREFIX_RM_ADV
)
12811 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12812 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12814 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12815 ORF_TYPE_PREFIX_OLD
);
12816 bgp_show_peer_afi_orf_cap(
12817 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12818 PEER_CAP_ORF_PREFIX_RM_ADV
,
12819 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12820 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12823 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12824 p
->host
, afi
, safi
);
12825 orf_pfx_count
= prefix_bgp_show_prefix_list(
12826 NULL
, afi
, orf_pfx_name
, use_json
);
12828 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12829 PEER_STATUS_ORF_PREFIX_SEND
)
12830 || orf_pfx_count
) {
12831 vty_out(vty
, " Outbound Route Filter (ORF):");
12832 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12833 PEER_STATUS_ORF_PREFIX_SEND
))
12834 vty_out(vty
, " sent;");
12836 vty_out(vty
, " received (%d entries)",
12838 vty_out(vty
, "\n");
12840 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12841 PEER_STATUS_ORF_WAIT_REFRESH
))
12843 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12845 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12846 PEER_FLAG_REFLECTOR_CLIENT
))
12847 vty_out(vty
, " Route-Reflector Client\n");
12848 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12849 PEER_FLAG_RSERVER_CLIENT
))
12850 vty_out(vty
, " Route-Server Client\n");
12851 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12853 " Inbound soft reconfiguration allowed\n");
12855 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12856 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12858 " Private AS numbers (all) replaced in updates to this neighbor\n");
12859 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12860 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12862 " Private AS numbers replaced in updates to this neighbor\n");
12863 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12864 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12866 " Private AS numbers (all) removed in updates to this neighbor\n");
12867 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12868 PEER_FLAG_REMOVE_PRIVATE_AS
))
12870 " Private AS numbers removed in updates to this neighbor\n");
12872 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12873 vty_out(vty
, " %s\n",
12874 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12875 ->human_description
);
12877 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12879 " Override ASNs in outbound updates if aspath equals remote-as\n");
12881 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12882 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12883 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12884 vty_out(vty
, " NEXT_HOP is always this router\n");
12885 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12886 PEER_FLAG_AS_PATH_UNCHANGED
))
12888 " AS_PATH is propagated unchanged to this neighbor\n");
12889 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12890 PEER_FLAG_NEXTHOP_UNCHANGED
))
12892 " NEXT_HOP is propagated unchanged to this neighbor\n");
12893 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12895 " MED is propagated unchanged to this neighbor\n");
12896 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12897 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12898 PEER_FLAG_SEND_EXT_COMMUNITY
)
12899 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12900 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12902 " Community attribute sent to this neighbor");
12903 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12904 PEER_FLAG_SEND_COMMUNITY
)
12905 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12906 PEER_FLAG_SEND_EXT_COMMUNITY
)
12907 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12908 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12909 vty_out(vty
, "(all)\n");
12910 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12911 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12912 vty_out(vty
, "(large)\n");
12913 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12914 PEER_FLAG_SEND_EXT_COMMUNITY
))
12915 vty_out(vty
, "(extended)\n");
12917 vty_out(vty
, "(standard)\n");
12919 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12920 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12921 vty_out(vty
, " Default information originate,");
12923 if (p
->default_rmap
[afi
][safi
].name
)
12924 vty_out(vty
, " default route-map %s%s,",
12925 p
->default_rmap
[afi
][safi
].map
? "*"
12927 p
->default_rmap
[afi
][safi
].name
);
12928 if (paf
&& PAF_SUBGRP(paf
)
12929 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12930 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12931 vty_out(vty
, " default sent\n");
12933 vty_out(vty
, " default not sent\n");
12936 /* advertise-vni-all */
12937 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12938 if (is_evpn_enabled())
12939 vty_out(vty
, " advertise-all-vni\n");
12942 if (filter
->plist
[FILTER_IN
].name
12943 || filter
->dlist
[FILTER_IN
].name
12944 || filter
->aslist
[FILTER_IN
].name
12945 || filter
->map
[RMAP_IN
].name
)
12946 vty_out(vty
, " Inbound path policy configured\n");
12947 if (filter
->plist
[FILTER_OUT
].name
12948 || filter
->dlist
[FILTER_OUT
].name
12949 || filter
->aslist
[FILTER_OUT
].name
12950 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12951 vty_out(vty
, " Outbound path policy configured\n");
12954 if (filter
->plist
[FILTER_IN
].name
)
12956 " Incoming update prefix filter list is %s%s\n",
12957 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12958 filter
->plist
[FILTER_IN
].name
);
12959 if (filter
->plist
[FILTER_OUT
].name
)
12961 " Outgoing update prefix filter list is %s%s\n",
12962 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12963 filter
->plist
[FILTER_OUT
].name
);
12965 /* distribute-list */
12966 if (filter
->dlist
[FILTER_IN
].name
)
12968 " Incoming update network filter list is %s%s\n",
12969 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12970 filter
->dlist
[FILTER_IN
].name
);
12971 if (filter
->dlist
[FILTER_OUT
].name
)
12973 " Outgoing update network filter list is %s%s\n",
12974 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12975 filter
->dlist
[FILTER_OUT
].name
);
12978 if (filter
->aslist
[FILTER_IN
].name
)
12980 " Incoming update AS path filter list is %s%s\n",
12981 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12982 filter
->aslist
[FILTER_IN
].name
);
12983 if (filter
->aslist
[FILTER_OUT
].name
)
12985 " Outgoing update AS path filter list is %s%s\n",
12986 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12987 filter
->aslist
[FILTER_OUT
].name
);
12990 if (filter
->map
[RMAP_IN
].name
)
12992 " Route map for incoming advertisements is %s%s\n",
12993 filter
->map
[RMAP_IN
].map
? "*" : "",
12994 filter
->map
[RMAP_IN
].name
);
12995 if (filter
->map
[RMAP_OUT
].name
)
12997 " Route map for outgoing advertisements is %s%s\n",
12998 filter
->map
[RMAP_OUT
].map
? "*" : "",
12999 filter
->map
[RMAP_OUT
].name
);
13001 /* ebgp-requires-policy (inbound) */
13002 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
13003 && !bgp_inbound_policy_exists(p
, filter
))
13005 " Inbound updates discarded due to missing policy\n");
13007 /* ebgp-requires-policy (outbound) */
13008 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
13009 && !bgp_outbound_policy_exists(p
, filter
))
13011 " Outbound updates discarded due to missing policy\n");
13013 /* unsuppress-map */
13014 if (filter
->usmap
.name
)
13016 " Route map for selective unsuppress is %s%s\n",
13017 filter
->usmap
.map
? "*" : "",
13018 filter
->usmap
.name
);
13020 /* advertise-map */
13021 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
13023 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
13024 filter
->advmap
.condition
? "EXIST"
13026 filter
->advmap
.cmap
? "*" : "",
13027 filter
->advmap
.cname
,
13028 filter
->advmap
.amap
? "*" : "",
13029 filter
->advmap
.aname
,
13030 filter
->advmap
.update_type
== ADVERTISE
13034 /* Receive prefix count */
13035 vty_out(vty
, " %u accepted prefixes\n",
13036 p
->pcount
[afi
][safi
]);
13038 /* maximum-prefix-out */
13039 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
13040 PEER_FLAG_MAX_PREFIX_OUT
))
13042 " Maximum allowed prefixes sent %u\n",
13043 p
->pmax_out
[afi
][safi
]);
13045 /* Maximum prefix */
13046 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13048 " Maximum prefixes allowed %u%s\n",
13049 p
->pmax
[afi
][safi
],
13050 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13051 PEER_FLAG_MAX_PREFIX_WARNING
)
13052 ? " (warning-only)"
13054 vty_out(vty
, " Threshold for warning message %d%%",
13055 p
->pmax_threshold
[afi
][safi
]);
13056 if (p
->pmax_restart
[afi
][safi
])
13057 vty_out(vty
, ", restart interval %d min",
13058 p
->pmax_restart
[afi
][safi
]);
13059 vty_out(vty
, "\n");
13062 vty_out(vty
, "\n");
13066 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13070 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
13071 char timebuf
[BGP_UPTIME_LEN
];
13077 json_object
*json_neigh
= NULL
;
13079 uint32_t sync_tcp_mss
;
13084 json_neigh
= json_object_new_object();
13086 memset(dn_flag
, '\0', sizeof(dn_flag
));
13087 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13091 if (p
->conf_if
) /* Configured interface name. */
13092 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
13093 BGP_PEER_SU_UNSPEC(p
)
13095 : sockunion2str(&p
->su
, buf
,
13097 else /* Configured IP address. */
13098 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13103 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13104 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13106 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13107 json_object_string_add(
13108 json_neigh
, "bgpNeighborAddr",
13109 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
13111 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13113 if (p
->change_local_as
)
13114 json_object_int_add(json_neigh
, "localAs",
13115 p
->change_local_as
);
13117 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13119 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13120 json_object_boolean_true_add(json_neigh
,
13121 "localAsNoPrepend");
13123 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13124 json_object_boolean_true_add(json_neigh
,
13125 "localAsReplaceAs");
13127 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13128 || (p
->as_type
== AS_INTERNAL
))
13129 vty_out(vty
, "remote AS %u, ", p
->as
);
13131 vty_out(vty
, "remote AS Unspecified, ");
13132 vty_out(vty
, "local AS %u%s%s, ",
13133 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13134 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13137 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13141 /* peer type internal or confed-internal */
13142 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13144 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13145 json_object_boolean_true_add(
13146 json_neigh
, "nbrConfedInternalLink");
13148 json_object_boolean_true_add(json_neigh
,
13149 "nbrInternalLink");
13151 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13152 vty_out(vty
, "confed-internal link\n");
13154 vty_out(vty
, "internal link\n");
13156 /* peer type external or confed-external */
13157 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13159 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13160 json_object_boolean_true_add(
13161 json_neigh
, "nbrConfedExternalLink");
13163 json_object_boolean_true_add(json_neigh
,
13164 "nbrExternalLink");
13166 if (bgp_confederation_peers_check(bgp
, p
->as
))
13167 vty_out(vty
, "confed-external link\n");
13169 vty_out(vty
, "external link\n");
13173 json_object_boolean_true_add(json_neigh
,
13174 "nbrUnspecifiedLink");
13176 vty_out(vty
, "unspecified link\n");
13182 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13184 vty_out(vty
, " Description: %s\n", p
->desc
);
13190 json_object_string_add(json_neigh
, "hostname",
13194 json_object_string_add(json_neigh
, "domainname",
13197 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13198 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13201 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13208 json_object_string_add(json_neigh
, "peerGroup",
13212 struct prefix prefix
, *range
= NULL
;
13214 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13215 range
= peer_group_lookup_dynamic_neighbor_range(
13216 p
->group
, &prefix
);
13219 prefix2str(range
, buf1
, sizeof(buf1
));
13220 json_object_string_add(
13222 "peerSubnetRangeGroup", buf1
);
13227 " Member of peer-group %s for session parameters\n",
13231 struct prefix prefix
, *range
= NULL
;
13233 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13234 range
= peer_group_lookup_dynamic_neighbor_range(
13235 p
->group
, &prefix
);
13239 " Belongs to the subnet range group: %pFX\n",
13247 /* Administrative shutdown. */
13248 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13249 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13250 json_object_boolean_true_add(json_neigh
,
13254 json_object_int_add(json_neigh
, "bgpVersion", 4);
13255 json_object_string_add(
13256 json_neigh
, "remoteRouterId",
13257 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13258 json_object_string_add(
13259 json_neigh
, "localRouterId",
13260 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13263 /* Confederation */
13264 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13265 && bgp_confederation_peers_check(bgp
, p
->as
))
13266 json_object_boolean_true_add(json_neigh
,
13270 json_object_string_add(
13271 json_neigh
, "bgpState",
13272 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13274 if (peer_established(p
)) {
13277 uptime
= bgp_clock();
13278 uptime
-= p
->uptime
;
13279 epoch_tbuf
= time(NULL
) - uptime
;
13281 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13283 json_object_string_add(json_neigh
, "bgpTimerUpString",
13284 peer_uptime(p
->uptime
, timebuf
,
13287 json_object_int_add(json_neigh
,
13288 "bgpTimerUpEstablishedEpoch",
13292 else if (p
->status
== Active
) {
13293 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13294 json_object_string_add(json_neigh
, "bgpStateIs",
13296 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13297 json_object_string_add(json_neigh
, "bgpStateIs",
13305 uptime
= bgp_clock();
13306 uptime
-= p
->readtime
;
13307 gmtime_r(&uptime
, &tm
);
13309 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13310 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13311 + (tm
.tm_hour
* 3600000));
13313 uptime
= bgp_clock();
13314 uptime
-= p
->last_write
;
13315 gmtime_r(&uptime
, &tm
);
13317 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13318 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13319 + (tm
.tm_hour
* 3600000));
13321 uptime
= bgp_clock();
13322 uptime
-= p
->update_time
;
13323 gmtime_r(&uptime
, &tm
);
13325 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13326 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13327 + (tm
.tm_hour
* 3600000));
13329 /* Configured timer values. */
13330 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13331 p
->v_holdtime
* 1000);
13332 json_object_int_add(json_neigh
,
13333 "bgpTimerKeepAliveIntervalMsecs",
13334 p
->v_keepalive
* 1000);
13335 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13336 json_object_int_add(json_neigh
,
13337 "bgpTimerDelayOpenTimeMsecs",
13338 p
->v_delayopen
* 1000);
13341 /* Configured and Synced tcp-mss value for peer */
13342 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13343 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13344 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13346 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13350 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
13351 json_object_int_add(json_neigh
,
13352 "bgpTimerConfiguredHoldTimeMsecs",
13353 p
->holdtime
* 1000);
13354 json_object_int_add(
13356 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13357 p
->keepalive
* 1000);
13358 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
13359 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
13360 json_object_int_add(json_neigh
,
13361 "bgpTimerConfiguredHoldTimeMsecs",
13362 bgp
->default_holdtime
);
13363 json_object_int_add(
13365 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13366 bgp
->default_keepalive
);
13369 /* Administrative shutdown. */
13370 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13371 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13372 vty_out(vty
, " Administratively shut down\n");
13375 vty_out(vty
, " BGP version 4");
13376 vty_out(vty
, ", remote router ID %s",
13377 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13378 vty_out(vty
, ", local router ID %s\n",
13379 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13382 /* Confederation */
13383 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13384 && bgp_confederation_peers_check(bgp
, p
->as
))
13386 " Neighbor under common administration\n");
13389 vty_out(vty
, " BGP state = %s",
13390 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13392 if (peer_established(p
))
13393 vty_out(vty
, ", up for %8s",
13394 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13397 else if (p
->status
== Active
) {
13398 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13399 vty_out(vty
, " (passive)");
13400 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13401 vty_out(vty
, " (NSF passive)");
13403 vty_out(vty
, "\n");
13406 vty_out(vty
, " Last read %s",
13407 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13409 vty_out(vty
, ", Last write %s\n",
13410 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13413 /* Configured timer values. */
13415 " Hold time is %d, keepalive interval is %d seconds\n",
13416 p
->v_holdtime
, p
->v_keepalive
);
13417 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
13418 vty_out(vty
, " Configured hold time is %d",
13420 vty_out(vty
, ", keepalive interval is %d seconds\n",
13422 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
13423 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
13424 vty_out(vty
, " Configured hold time is %d",
13425 bgp
->default_holdtime
);
13426 vty_out(vty
, ", keepalive interval is %d seconds\n",
13427 bgp
->default_keepalive
);
13429 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13431 " Configured DelayOpenTime is %d seconds\n",
13434 /* Configured and synced tcp-mss value for peer */
13435 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13436 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13437 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13438 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13442 if (peer_established(p
)) {
13443 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
13444 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
13445 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
13446 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
13447 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
13448 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
13449 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
13450 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
13451 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
13452 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
13453 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
13454 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
13455 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
13456 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
13457 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
13458 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
13459 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
13460 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
13461 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
13462 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
13464 json_object
*json_cap
= NULL
;
13466 json_cap
= json_object_new_object();
13469 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13470 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13471 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
13472 && CHECK_FLAG(p
->cap
,
13474 json_object_string_add(
13475 json_cap
, "4byteAs",
13476 "advertisedAndReceived");
13477 else if (CHECK_FLAG(p
->cap
,
13479 json_object_string_add(
13480 json_cap
, "4byteAs",
13482 else if (CHECK_FLAG(p
->cap
,
13484 json_object_string_add(
13485 json_cap
, "4byteAs",
13489 /* Extended Message Support */
13490 if (CHECK_FLAG(p
->cap
,
13491 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13494 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13495 json_object_string_add(
13496 json_cap
, "extendedMessage",
13497 "advertisedAndReceived");
13498 else if (CHECK_FLAG(
13500 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13501 json_object_string_add(
13502 json_cap
, "extendedMessage",
13504 else if (CHECK_FLAG(
13506 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13507 json_object_string_add(
13508 json_cap
, "extendedMessage",
13512 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13513 || CHECK_FLAG(p
->cap
,
13514 PEER_CAP_ADDPATH_ADV
)) {
13515 json_object
*json_add
= NULL
;
13516 const char *print_store
;
13518 json_add
= json_object_new_object();
13520 FOREACH_AFI_SAFI (afi
, safi
) {
13521 json_object
*json_sub
= NULL
;
13523 json_object_new_object();
13524 print_store
= get_afi_safi_str(
13530 PEER_CAP_ADDPATH_AF_TX_ADV
)
13534 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13539 PEER_CAP_ADDPATH_AF_TX_ADV
)
13544 PEER_CAP_ADDPATH_AF_TX_RCV
))
13545 json_object_boolean_true_add(
13547 "txAdvertisedAndReceived");
13553 PEER_CAP_ADDPATH_AF_TX_ADV
))
13554 json_object_boolean_true_add(
13562 PEER_CAP_ADDPATH_AF_TX_RCV
))
13563 json_object_boolean_true_add(
13571 PEER_CAP_ADDPATH_AF_RX_ADV
)
13575 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13580 PEER_CAP_ADDPATH_AF_RX_ADV
)
13585 PEER_CAP_ADDPATH_AF_RX_RCV
))
13586 json_object_boolean_true_add(
13588 "rxAdvertisedAndReceived");
13594 PEER_CAP_ADDPATH_AF_RX_ADV
))
13595 json_object_boolean_true_add(
13603 PEER_CAP_ADDPATH_AF_RX_RCV
))
13604 json_object_boolean_true_add(
13612 PEER_CAP_ADDPATH_AF_TX_ADV
)
13616 PEER_CAP_ADDPATH_AF_TX_RCV
)
13620 PEER_CAP_ADDPATH_AF_RX_ADV
)
13624 PEER_CAP_ADDPATH_AF_RX_RCV
))
13625 json_object_object_add(
13634 json_object_object_add(
13635 json_cap
, "addPath", json_add
);
13639 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13640 || CHECK_FLAG(p
->cap
,
13641 PEER_CAP_DYNAMIC_ADV
)) {
13642 if (CHECK_FLAG(p
->cap
,
13643 PEER_CAP_DYNAMIC_ADV
)
13644 && CHECK_FLAG(p
->cap
,
13645 PEER_CAP_DYNAMIC_RCV
))
13646 json_object_string_add(
13647 json_cap
, "dynamic",
13648 "advertisedAndReceived");
13649 else if (CHECK_FLAG(
13651 PEER_CAP_DYNAMIC_ADV
))
13652 json_object_string_add(
13653 json_cap
, "dynamic",
13655 else if (CHECK_FLAG(
13657 PEER_CAP_DYNAMIC_RCV
))
13658 json_object_string_add(
13659 json_cap
, "dynamic",
13663 /* Extended nexthop */
13664 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13665 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13666 json_object
*json_nxt
= NULL
;
13667 const char *print_store
;
13670 if (CHECK_FLAG(p
->cap
,
13672 && CHECK_FLAG(p
->cap
,
13673 PEER_CAP_ENHE_RCV
))
13674 json_object_string_add(
13677 "advertisedAndReceived");
13678 else if (CHECK_FLAG(p
->cap
,
13679 PEER_CAP_ENHE_ADV
))
13680 json_object_string_add(
13684 else if (CHECK_FLAG(p
->cap
,
13685 PEER_CAP_ENHE_RCV
))
13686 json_object_string_add(
13691 if (CHECK_FLAG(p
->cap
,
13692 PEER_CAP_ENHE_RCV
)) {
13694 json_object_new_object();
13696 for (safi
= SAFI_UNICAST
;
13697 safi
< SAFI_MAX
; safi
++) {
13702 PEER_CAP_ENHE_AF_RCV
)) {
13703 print_store
= get_afi_safi_str(
13706 json_object_string_add(
13709 "recieved"); /* misspelled for compatibility */
13712 json_object_object_add(
13714 "extendedNexthopFamililesByPeer",
13719 /* Route Refresh */
13720 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13721 || CHECK_FLAG(p
->cap
,
13722 PEER_CAP_REFRESH_NEW_RCV
)
13723 || CHECK_FLAG(p
->cap
,
13724 PEER_CAP_REFRESH_OLD_RCV
)) {
13725 if (CHECK_FLAG(p
->cap
,
13726 PEER_CAP_REFRESH_ADV
)
13729 PEER_CAP_REFRESH_NEW_RCV
)
13732 PEER_CAP_REFRESH_OLD_RCV
))) {
13735 PEER_CAP_REFRESH_OLD_RCV
)
13738 PEER_CAP_REFRESH_NEW_RCV
))
13739 json_object_string_add(
13742 "advertisedAndReceivedOldNew");
13746 PEER_CAP_REFRESH_OLD_RCV
))
13747 json_object_string_add(
13750 "advertisedAndReceivedOld");
13752 json_object_string_add(
13755 "advertisedAndReceivedNew");
13760 PEER_CAP_REFRESH_ADV
))
13761 json_object_string_add(
13768 PEER_CAP_REFRESH_NEW_RCV
)
13771 PEER_CAP_REFRESH_OLD_RCV
))
13772 json_object_string_add(
13778 /* Enhanced Route Refresh */
13779 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13780 || CHECK_FLAG(p
->cap
,
13781 PEER_CAP_ENHANCED_RR_RCV
)) {
13782 if (CHECK_FLAG(p
->cap
,
13783 PEER_CAP_ENHANCED_RR_ADV
)
13786 PEER_CAP_ENHANCED_RR_RCV
))
13787 json_object_string_add(
13789 "enhancedRouteRefresh",
13790 "advertisedAndReceived");
13794 PEER_CAP_ENHANCED_RR_ADV
))
13795 json_object_string_add(
13797 "enhancedRouteRefresh",
13802 PEER_CAP_ENHANCED_RR_RCV
))
13803 json_object_string_add(
13805 "enhancedRouteRefresh",
13809 /* Multiprotocol Extensions */
13810 json_object
*json_multi
= NULL
;
13811 json_multi
= json_object_new_object();
13813 FOREACH_AFI_SAFI (afi
, safi
) {
13814 if (p
->afc_adv
[afi
][safi
]
13815 || p
->afc_recv
[afi
][safi
]) {
13816 json_object
*json_exten
= NULL
;
13818 json_object_new_object();
13820 if (p
->afc_adv
[afi
][safi
]
13821 && p
->afc_recv
[afi
][safi
])
13822 json_object_boolean_true_add(
13824 "advertisedAndReceived");
13825 else if (p
->afc_adv
[afi
][safi
])
13826 json_object_boolean_true_add(
13829 else if (p
->afc_recv
[afi
][safi
])
13830 json_object_boolean_true_add(
13834 json_object_object_add(
13836 get_afi_safi_str(afi
,
13842 json_object_object_add(
13843 json_cap
, "multiprotocolExtensions",
13846 /* Hostname capabilities */
13847 json_object
*json_hname
= NULL
;
13849 json_hname
= json_object_new_object();
13851 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13852 json_object_string_add(
13853 json_hname
, "advHostName",
13854 bgp
->peer_self
->hostname
13858 json_object_string_add(
13859 json_hname
, "advDomainName",
13860 bgp
->peer_self
->domainname
13867 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13868 json_object_string_add(
13869 json_hname
, "rcvHostName",
13870 p
->hostname
? p
->hostname
13872 json_object_string_add(
13873 json_hname
, "rcvDomainName",
13874 p
->domainname
? p
->domainname
13878 json_object_object_add(json_cap
, "hostName",
13881 /* Gracefull Restart */
13882 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13883 || CHECK_FLAG(p
->cap
,
13884 PEER_CAP_RESTART_ADV
)) {
13885 if (CHECK_FLAG(p
->cap
,
13886 PEER_CAP_RESTART_ADV
)
13887 && CHECK_FLAG(p
->cap
,
13888 PEER_CAP_RESTART_RCV
))
13889 json_object_string_add(
13892 "advertisedAndReceived");
13893 else if (CHECK_FLAG(
13895 PEER_CAP_RESTART_ADV
))
13896 json_object_string_add(
13898 "gracefulRestartCapability",
13900 else if (CHECK_FLAG(
13902 PEER_CAP_RESTART_RCV
))
13903 json_object_string_add(
13905 "gracefulRestartCapability",
13908 if (CHECK_FLAG(p
->cap
,
13909 PEER_CAP_RESTART_RCV
)) {
13910 int restart_af_count
= 0;
13911 json_object
*json_restart
=
13914 json_object_new_object();
13916 json_object_int_add(
13918 "gracefulRestartRemoteTimerMsecs",
13919 p
->v_gr_restart
* 1000);
13921 FOREACH_AFI_SAFI (afi
, safi
) {
13926 PEER_CAP_RESTART_AF_RCV
)) {
13931 json_object_new_object();
13937 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13938 json_object_boolean_true_add(
13941 restart_af_count
++;
13942 json_object_object_add(
13951 if (!restart_af_count
) {
13952 json_object_string_add(
13954 "addressFamiliesByPeer",
13959 json_object_object_add(
13961 "addressFamiliesByPeer",
13965 json_object_object_add(json_neigh
,
13966 "neighborCapabilities",
13969 vty_out(vty
, " Neighbor capabilities:\n");
13972 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13973 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13974 vty_out(vty
, " 4 Byte AS:");
13975 if (CHECK_FLAG(p
->cap
,
13977 vty_out(vty
, " advertised");
13978 if (CHECK_FLAG(p
->cap
,
13980 vty_out(vty
, " %sreceived",
13986 vty_out(vty
, "\n");
13989 /* Extended Message Support */
13990 if (CHECK_FLAG(p
->cap
,
13991 PEER_CAP_EXTENDED_MESSAGE_RCV
)
13994 PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13995 vty_out(vty
, " Extended Message:");
13998 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13999 vty_out(vty
, " advertised");
14002 PEER_CAP_EXTENDED_MESSAGE_RCV
))
14003 vty_out(vty
, " %sreceived",
14006 PEER_CAP_EXTENDED_MESSAGE_ADV
)
14009 vty_out(vty
, "\n");
14013 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
14014 || CHECK_FLAG(p
->cap
,
14015 PEER_CAP_ADDPATH_ADV
)) {
14016 vty_out(vty
, " AddPath:\n");
14018 FOREACH_AFI_SAFI (afi
, safi
) {
14022 PEER_CAP_ADDPATH_AF_TX_ADV
)
14026 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
14038 PEER_CAP_ADDPATH_AF_TX_ADV
))
14050 PEER_CAP_ADDPATH_AF_TX_RCV
))
14057 PEER_CAP_ADDPATH_AF_TX_ADV
)
14061 vty_out(vty
, "\n");
14067 PEER_CAP_ADDPATH_AF_RX_ADV
)
14071 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14083 PEER_CAP_ADDPATH_AF_RX_ADV
))
14095 PEER_CAP_ADDPATH_AF_RX_RCV
))
14102 PEER_CAP_ADDPATH_AF_RX_ADV
)
14106 vty_out(vty
, "\n");
14112 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
14113 || CHECK_FLAG(p
->cap
,
14114 PEER_CAP_DYNAMIC_ADV
)) {
14115 vty_out(vty
, " Dynamic:");
14116 if (CHECK_FLAG(p
->cap
,
14117 PEER_CAP_DYNAMIC_ADV
))
14118 vty_out(vty
, " advertised");
14119 if (CHECK_FLAG(p
->cap
,
14120 PEER_CAP_DYNAMIC_RCV
))
14121 vty_out(vty
, " %sreceived",
14124 PEER_CAP_DYNAMIC_ADV
)
14127 vty_out(vty
, "\n");
14130 /* Extended nexthop */
14131 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
14132 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14133 vty_out(vty
, " Extended nexthop:");
14134 if (CHECK_FLAG(p
->cap
,
14135 PEER_CAP_ENHE_ADV
))
14136 vty_out(vty
, " advertised");
14137 if (CHECK_FLAG(p
->cap
,
14138 PEER_CAP_ENHE_RCV
))
14139 vty_out(vty
, " %sreceived",
14145 vty_out(vty
, "\n");
14147 if (CHECK_FLAG(p
->cap
,
14148 PEER_CAP_ENHE_RCV
)) {
14150 " Address families by peer:\n ");
14151 for (safi
= SAFI_UNICAST
;
14152 safi
< SAFI_MAX
; safi
++)
14157 PEER_CAP_ENHE_AF_RCV
))
14167 /* Route Refresh */
14168 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
14169 || CHECK_FLAG(p
->cap
,
14170 PEER_CAP_REFRESH_NEW_RCV
)
14171 || CHECK_FLAG(p
->cap
,
14172 PEER_CAP_REFRESH_OLD_RCV
)) {
14173 vty_out(vty
, " Route refresh:");
14174 if (CHECK_FLAG(p
->cap
,
14175 PEER_CAP_REFRESH_ADV
))
14176 vty_out(vty
, " advertised");
14177 if (CHECK_FLAG(p
->cap
,
14178 PEER_CAP_REFRESH_NEW_RCV
)
14181 PEER_CAP_REFRESH_OLD_RCV
))
14182 vty_out(vty
, " %sreceived(%s)",
14185 PEER_CAP_REFRESH_ADV
)
14190 PEER_CAP_REFRESH_OLD_RCV
)
14193 PEER_CAP_REFRESH_NEW_RCV
))
14197 PEER_CAP_REFRESH_OLD_RCV
)
14201 vty_out(vty
, "\n");
14204 /* Enhanced Route Refresh */
14205 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
14206 || CHECK_FLAG(p
->cap
,
14207 PEER_CAP_ENHANCED_RR_RCV
)) {
14209 " Enhanced Route Refresh:");
14212 PEER_CAP_ENHANCED_RR_ADV
))
14213 vty_out(vty
, " advertised");
14216 PEER_CAP_ENHANCED_RR_RCV
))
14217 vty_out(vty
, " %sreceived",
14220 PEER_CAP_REFRESH_ADV
)
14223 vty_out(vty
, "\n");
14226 /* Multiprotocol Extensions */
14227 FOREACH_AFI_SAFI (afi
, safi
)
14228 if (p
->afc_adv
[afi
][safi
]
14229 || p
->afc_recv
[afi
][safi
]) {
14231 " Address Family %s:",
14236 if (p
->afc_adv
[afi
][safi
])
14239 if (p
->afc_recv
[afi
][safi
])
14246 vty_out(vty
, "\n");
14249 /* Hostname capability */
14250 vty_out(vty
, " Hostname Capability:");
14252 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14254 " advertised (name: %s,domain name: %s)",
14255 bgp
->peer_self
->hostname
14259 bgp
->peer_self
->domainname
14264 vty_out(vty
, " not advertised");
14267 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14269 " received (name: %s,domain name: %s)",
14270 p
->hostname
? p
->hostname
14272 p
->domainname
? p
->domainname
14275 vty_out(vty
, " not received");
14278 vty_out(vty
, "\n");
14280 /* Graceful Restart */
14281 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
14282 || CHECK_FLAG(p
->cap
,
14283 PEER_CAP_RESTART_ADV
)) {
14285 " Graceful Restart Capability:");
14286 if (CHECK_FLAG(p
->cap
,
14287 PEER_CAP_RESTART_ADV
))
14288 vty_out(vty
, " advertised");
14289 if (CHECK_FLAG(p
->cap
,
14290 PEER_CAP_RESTART_RCV
))
14291 vty_out(vty
, " %sreceived",
14294 PEER_CAP_RESTART_ADV
)
14297 vty_out(vty
, "\n");
14299 if (CHECK_FLAG(p
->cap
,
14300 PEER_CAP_RESTART_RCV
)) {
14301 int restart_af_count
= 0;
14304 " Remote Restart timer is %d seconds\n",
14307 " Address families by peer:\n ");
14309 FOREACH_AFI_SAFI (afi
, safi
)
14314 PEER_CAP_RESTART_AF_RCV
)) {
14328 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14330 : "not preserved");
14331 restart_af_count
++;
14333 if (!restart_af_count
)
14334 vty_out(vty
, "none");
14335 vty_out(vty
, "\n");
14337 } /* Gracefull Restart */
14342 /* graceful restart information */
14343 json_object
*json_grace
= NULL
;
14344 json_object
*json_grace_send
= NULL
;
14345 json_object
*json_grace_recv
= NULL
;
14346 int eor_send_af_count
= 0;
14347 int eor_receive_af_count
= 0;
14350 json_grace
= json_object_new_object();
14351 json_grace_send
= json_object_new_object();
14352 json_grace_recv
= json_object_new_object();
14354 if ((peer_established(p
))
14355 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14356 FOREACH_AFI_SAFI (afi
, safi
) {
14357 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14358 PEER_STATUS_EOR_SEND
)) {
14359 json_object_boolean_true_add(
14361 get_afi_safi_str(afi
,
14364 eor_send_af_count
++;
14367 FOREACH_AFI_SAFI (afi
, safi
) {
14369 p
->af_sflags
[afi
][safi
],
14370 PEER_STATUS_EOR_RECEIVED
)) {
14371 json_object_boolean_true_add(
14373 get_afi_safi_str(afi
,
14376 eor_receive_af_count
++;
14380 json_object_object_add(json_grace
, "endOfRibSend",
14382 json_object_object_add(json_grace
, "endOfRibRecv",
14386 if (p
->t_gr_restart
)
14387 json_object_int_add(json_grace
,
14388 "gracefulRestartTimerMsecs",
14389 thread_timer_remain_second(
14394 json_object_int_add(
14396 "gracefulStalepathTimerMsecs",
14397 thread_timer_remain_second(
14400 /* more gr info in new format */
14401 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
14403 json_object_object_add(
14404 json_neigh
, "gracefulRestartInfo", json_grace
);
14406 vty_out(vty
, " Graceful restart information:\n");
14407 if ((peer_established(p
))
14408 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14410 vty_out(vty
, " End-of-RIB send: ");
14411 FOREACH_AFI_SAFI (afi
, safi
) {
14412 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14413 PEER_STATUS_EOR_SEND
)) {
14414 vty_out(vty
, "%s%s",
14415 eor_send_af_count
? ", "
14420 eor_send_af_count
++;
14423 vty_out(vty
, "\n");
14424 vty_out(vty
, " End-of-RIB received: ");
14425 FOREACH_AFI_SAFI (afi
, safi
) {
14427 p
->af_sflags
[afi
][safi
],
14428 PEER_STATUS_EOR_RECEIVED
)) {
14429 vty_out(vty
, "%s%s",
14430 eor_receive_af_count
14433 get_afi_safi_str(afi
,
14436 eor_receive_af_count
++;
14439 vty_out(vty
, "\n");
14442 if (p
->t_gr_restart
)
14444 " The remaining time of restart timer is %ld\n",
14445 thread_timer_remain_second(
14450 " The remaining time of stalepath timer is %ld\n",
14451 thread_timer_remain_second(
14454 /* more gr info in new format */
14455 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14459 json_object
*json_stat
= NULL
;
14460 json_stat
= json_object_new_object();
14461 /* Packet counts. */
14463 atomic_size_t outq_count
, inq_count
;
14464 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14465 memory_order_relaxed
);
14466 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14467 memory_order_relaxed
);
14469 json_object_int_add(json_stat
, "depthInq",
14470 (unsigned long)inq_count
);
14471 json_object_int_add(json_stat
, "depthOutq",
14472 (unsigned long)outq_count
);
14473 json_object_int_add(json_stat
, "opensSent",
14474 atomic_load_explicit(&p
->open_out
,
14475 memory_order_relaxed
));
14476 json_object_int_add(json_stat
, "opensRecv",
14477 atomic_load_explicit(&p
->open_in
,
14478 memory_order_relaxed
));
14479 json_object_int_add(json_stat
, "notificationsSent",
14480 atomic_load_explicit(&p
->notify_out
,
14481 memory_order_relaxed
));
14482 json_object_int_add(json_stat
, "notificationsRecv",
14483 atomic_load_explicit(&p
->notify_in
,
14484 memory_order_relaxed
));
14485 json_object_int_add(json_stat
, "updatesSent",
14486 atomic_load_explicit(&p
->update_out
,
14487 memory_order_relaxed
));
14488 json_object_int_add(json_stat
, "updatesRecv",
14489 atomic_load_explicit(&p
->update_in
,
14490 memory_order_relaxed
));
14491 json_object_int_add(json_stat
, "keepalivesSent",
14492 atomic_load_explicit(&p
->keepalive_out
,
14493 memory_order_relaxed
));
14494 json_object_int_add(json_stat
, "keepalivesRecv",
14495 atomic_load_explicit(&p
->keepalive_in
,
14496 memory_order_relaxed
));
14497 json_object_int_add(json_stat
, "routeRefreshSent",
14498 atomic_load_explicit(&p
->refresh_out
,
14499 memory_order_relaxed
));
14500 json_object_int_add(json_stat
, "routeRefreshRecv",
14501 atomic_load_explicit(&p
->refresh_in
,
14502 memory_order_relaxed
));
14503 json_object_int_add(json_stat
, "capabilitySent",
14504 atomic_load_explicit(&p
->dynamic_cap_out
,
14505 memory_order_relaxed
));
14506 json_object_int_add(json_stat
, "capabilityRecv",
14507 atomic_load_explicit(&p
->dynamic_cap_in
,
14508 memory_order_relaxed
));
14509 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14510 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14511 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14513 atomic_size_t outq_count
, inq_count
;
14514 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14515 memory_order_relaxed
);
14516 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14517 memory_order_relaxed
);
14519 /* Packet counts. */
14520 vty_out(vty
, " Message statistics:\n");
14521 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14522 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14523 vty_out(vty
, " Sent Rcvd\n");
14524 vty_out(vty
, " Opens: %10d %10d\n",
14525 atomic_load_explicit(&p
->open_out
,
14526 memory_order_relaxed
),
14527 atomic_load_explicit(&p
->open_in
,
14528 memory_order_relaxed
));
14529 vty_out(vty
, " Notifications: %10d %10d\n",
14530 atomic_load_explicit(&p
->notify_out
,
14531 memory_order_relaxed
),
14532 atomic_load_explicit(&p
->notify_in
,
14533 memory_order_relaxed
));
14534 vty_out(vty
, " Updates: %10d %10d\n",
14535 atomic_load_explicit(&p
->update_out
,
14536 memory_order_relaxed
),
14537 atomic_load_explicit(&p
->update_in
,
14538 memory_order_relaxed
));
14539 vty_out(vty
, " Keepalives: %10d %10d\n",
14540 atomic_load_explicit(&p
->keepalive_out
,
14541 memory_order_relaxed
),
14542 atomic_load_explicit(&p
->keepalive_in
,
14543 memory_order_relaxed
));
14544 vty_out(vty
, " Route Refresh: %10d %10d\n",
14545 atomic_load_explicit(&p
->refresh_out
,
14546 memory_order_relaxed
),
14547 atomic_load_explicit(&p
->refresh_in
,
14548 memory_order_relaxed
));
14549 vty_out(vty
, " Capability: %10d %10d\n",
14550 atomic_load_explicit(&p
->dynamic_cap_out
,
14551 memory_order_relaxed
),
14552 atomic_load_explicit(&p
->dynamic_cap_in
,
14553 memory_order_relaxed
));
14554 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14559 /* advertisement-interval */
14560 json_object_int_add(json_neigh
,
14561 "minBtwnAdvertisementRunsTimerMsecs",
14562 p
->v_routeadv
* 1000);
14564 /* Update-source. */
14565 if (p
->update_if
|| p
->update_source
) {
14567 json_object_string_add(json_neigh
,
14570 else if (p
->update_source
)
14571 json_object_string_add(
14572 json_neigh
, "updateSource",
14573 sockunion2str(p
->update_source
, buf1
,
14577 /* advertisement-interval */
14579 " Minimum time between advertisement runs is %d seconds\n",
14582 /* Update-source. */
14583 if (p
->update_if
|| p
->update_source
) {
14584 vty_out(vty
, " Update source is ");
14586 vty_out(vty
, "%s", p
->update_if
);
14587 else if (p
->update_source
)
14589 sockunion2str(p
->update_source
, buf1
,
14591 vty_out(vty
, "\n");
14594 vty_out(vty
, "\n");
14597 /* Address Family Information */
14598 json_object
*json_hold
= NULL
;
14601 json_hold
= json_object_new_object();
14603 FOREACH_AFI_SAFI (afi
, safi
)
14604 if (p
->afc
[afi
][safi
])
14605 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14609 json_object_object_add(json_neigh
, "addressFamilyInfo",
14611 json_object_int_add(json_neigh
, "connectionsEstablished",
14613 json_object_int_add(json_neigh
, "connectionsDropped",
14616 vty_out(vty
, " Connections established %d; dropped %d\n",
14617 p
->established
, p
->dropped
);
14619 if (!p
->last_reset
) {
14621 json_object_string_add(json_neigh
, "lastReset",
14624 vty_out(vty
, " Last reset never\n");
14630 uptime
= bgp_clock();
14631 uptime
-= p
->resettime
;
14632 gmtime_r(&uptime
, &tm
);
14634 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14636 + (tm
.tm_min
* 60000)
14637 + (tm
.tm_hour
* 3600000));
14638 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14640 vty_out(vty
, " Last reset %s, ",
14641 peer_uptime(p
->resettime
, timebuf
,
14642 BGP_UPTIME_LEN
, 0, NULL
));
14644 bgp_show_peer_reset(vty
, p
, NULL
, false);
14645 if (p
->last_reset_cause_size
) {
14646 msg
= p
->last_reset_cause
;
14648 " Message received that caused BGP to send a NOTIFICATION:\n ");
14649 for (i
= 1; i
<= p
->last_reset_cause_size
;
14651 vty_out(vty
, "%02X", *msg
++);
14653 if (i
!= p
->last_reset_cause_size
) {
14655 vty_out(vty
, "\n ");
14656 } else if (i
% 4 == 0) {
14661 vty_out(vty
, "\n");
14666 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14668 json_object_boolean_true_add(json_neigh
,
14669 "prefixesConfigExceedMax");
14672 " Peer had exceeded the max. no. of prefixes configured.\n");
14674 if (p
->t_pmax_restart
) {
14676 json_object_boolean_true_add(
14677 json_neigh
, "reducePrefixNumFrom");
14678 json_object_int_add(json_neigh
,
14679 "restartInTimerMsec",
14680 thread_timer_remain_second(
14685 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14686 p
->host
, thread_timer_remain_second(
14687 p
->t_pmax_restart
));
14690 json_object_boolean_true_add(
14692 "reducePrefixNumAndClearIpBgp");
14695 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14700 /* EBGP Multihop and GTSM */
14701 if (p
->sort
!= BGP_PEER_IBGP
) {
14703 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14704 json_object_int_add(json_neigh
,
14705 "externalBgpNbrMaxHopsAway",
14707 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14708 json_object_int_add(json_neigh
,
14709 "externalBgpNbrMaxHopsAway",
14712 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14714 " External BGP neighbor may be up to %d hops away.\n",
14716 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14718 " External BGP neighbor may be up to %d hops away.\n",
14722 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14724 json_object_int_add(json_neigh
,
14725 "internalBgpNbrMaxHopsAway",
14729 " Internal BGP neighbor may be up to %d hops away.\n",
14734 /* Local address. */
14737 json_object_string_add(json_neigh
, "hostLocal",
14738 sockunion2str(p
->su_local
, buf1
,
14740 json_object_int_add(json_neigh
, "portLocal",
14741 ntohs(p
->su_local
->sin
.sin_port
));
14743 vty_out(vty
, "Local host: %s, Local port: %d\n",
14744 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14745 ntohs(p
->su_local
->sin
.sin_port
));
14748 /* Remote address. */
14749 if (p
->su_remote
) {
14751 json_object_string_add(json_neigh
, "hostForeign",
14752 sockunion2str(p
->su_remote
, buf1
,
14754 json_object_int_add(json_neigh
, "portForeign",
14755 ntohs(p
->su_remote
->sin
.sin_port
));
14757 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14758 sockunion2str(p
->su_remote
, buf1
,
14760 ntohs(p
->su_remote
->sin
.sin_port
));
14763 /* Nexthop display. */
14766 json_object_string_add(json_neigh
, "nexthop",
14768 &p
->nexthop
.v4
, buf1
,
14770 json_object_string_add(json_neigh
, "nexthopGlobal",
14771 inet_ntop(AF_INET6
,
14772 &p
->nexthop
.v6_global
,
14773 buf1
, sizeof(buf1
)));
14774 json_object_string_add(json_neigh
, "nexthopLocal",
14775 inet_ntop(AF_INET6
,
14776 &p
->nexthop
.v6_local
,
14777 buf1
, sizeof(buf1
)));
14778 if (p
->shared_network
)
14779 json_object_string_add(json_neigh
,
14783 json_object_string_add(json_neigh
,
14785 "nonSharedNetwork");
14787 vty_out(vty
, "Nexthop: %s\n",
14788 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14790 vty_out(vty
, "Nexthop global: %s\n",
14791 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14793 vty_out(vty
, "Nexthop local: %s\n",
14794 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14796 vty_out(vty
, "BGP connection: %s\n",
14797 p
->shared_network
? "shared network"
14798 : "non shared network");
14802 /* Timer information. */
14804 json_object_int_add(json_neigh
, "connectRetryTimer",
14806 if (peer_established(p
) && p
->rtt
)
14807 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14810 json_object_int_add(
14811 json_neigh
, "nextStartTimerDueInMsecs",
14812 thread_timer_remain_second(p
->t_start
) * 1000);
14814 json_object_int_add(
14815 json_neigh
, "nextConnectTimerDueInMsecs",
14816 thread_timer_remain_second(p
->t_connect
)
14818 if (p
->t_routeadv
) {
14819 json_object_int_add(json_neigh
, "mraiInterval",
14821 json_object_int_add(
14822 json_neigh
, "mraiTimerExpireInMsecs",
14823 thread_timer_remain_second(p
->t_routeadv
)
14827 json_object_int_add(json_neigh
, "authenticationEnabled",
14831 json_object_string_add(json_neigh
, "readThread", "on");
14833 json_object_string_add(json_neigh
, "readThread", "off");
14835 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14836 json_object_string_add(json_neigh
, "writeThread", "on");
14838 json_object_string_add(json_neigh
, "writeThread",
14841 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14843 if (peer_established(p
) && p
->rtt
)
14844 vty_out(vty
, "Estimated round trip time: %d ms\n",
14847 vty_out(vty
, "Next start timer due in %ld seconds\n",
14848 thread_timer_remain_second(p
->t_start
));
14850 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14851 thread_timer_remain_second(p
->t_connect
));
14854 "MRAI (interval %u) timer expires in %ld seconds\n",
14856 thread_timer_remain_second(p
->t_routeadv
));
14858 vty_out(vty
, "Peer Authentication Enabled\n");
14860 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14861 p
->t_read
? "on" : "off",
14862 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14867 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14868 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14869 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14872 vty_out(vty
, "\n");
14874 /* BFD information. */
14876 bgp_bfd_show_info(vty
, p
, json_neigh
);
14879 if (p
->conf_if
) /* Configured interface name. */
14880 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14881 else /* Configured IP address. */
14882 json_object_object_add(json
, p
->host
, json_neigh
);
14886 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14887 enum show_type type
,
14888 union sockunion
*su
,
14889 const char *conf_if
, afi_t afi
,
14892 struct listnode
*node
, *nnode
;
14895 safi_t safi
= SAFI_UNICAST
;
14896 json_object
*json
= NULL
;
14897 json_object
*json_neighbor
= NULL
;
14900 json
= json_object_new_object();
14901 json_neighbor
= json_object_new_object();
14904 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14906 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14909 if ((peer
->afc
[afi
][safi
]) == 0)
14912 if (type
== show_all
) {
14913 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14917 json_object_object_add(json
, peer
->host
,
14919 json_neighbor
= NULL
;
14922 } else if (type
== show_peer
) {
14925 && !strcmp(peer
->conf_if
, conf_if
))
14927 && !strcmp(peer
->hostname
, conf_if
))) {
14929 bgp_show_peer_gr_status(vty
, peer
,
14934 if (sockunion_same(&peer
->su
, su
)) {
14936 bgp_show_peer_gr_status(vty
, peer
,
14941 if (use_json
&& find
)
14942 json_object_object_add(json
, peer
->host
,
14947 json_neighbor
= NULL
;
14952 if (type
== show_peer
&& !find
) {
14954 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14956 vty_out(vty
, "%% No such neighbor\n");
14959 vty_out(vty
, "%s\n",
14960 json_object_to_json_string_ext(
14961 json
, JSON_C_TO_STRING_PRETTY
));
14964 json_object_free(json_neighbor
);
14965 json_object_free(json
);
14967 vty_out(vty
, "\n");
14970 return CMD_SUCCESS
;
14973 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14974 enum show_type type
, union sockunion
*su
,
14975 const char *conf_if
, bool use_json
,
14978 struct listnode
*node
, *nnode
;
14981 bool nbr_output
= false;
14982 afi_t afi
= AFI_MAX
;
14983 safi_t safi
= SAFI_MAX
;
14985 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14987 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14991 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14992 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14997 bgp_show_peer(vty
, peer
, use_json
, json
);
15003 && !strcmp(peer
->conf_if
, conf_if
))
15005 && !strcmp(peer
->hostname
, conf_if
))) {
15007 bgp_show_peer(vty
, peer
, use_json
,
15011 if (sockunion_same(&peer
->su
, su
)) {
15013 bgp_show_peer(vty
, peer
, use_json
,
15018 case show_ipv4_peer
:
15019 case show_ipv6_peer
:
15020 FOREACH_SAFI (safi
) {
15021 if (peer
->afc
[afi
][safi
]) {
15024 && !strcmp(peer
->conf_if
, conf_if
))
15026 && !strcmp(peer
->hostname
, conf_if
))) {
15028 bgp_show_peer(vty
, peer
, use_json
,
15033 if (sockunion_same(&peer
->su
, su
)) {
15035 bgp_show_peer(vty
, peer
, use_json
,
15043 case show_ipv4_all
:
15044 case show_ipv6_all
:
15045 FOREACH_SAFI (safi
) {
15046 if (peer
->afc
[afi
][safi
]) {
15047 bgp_show_peer(vty
, peer
, use_json
, json
);
15056 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15057 type
== show_ipv6_peer
) && !find
) {
15059 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15061 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15064 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15065 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15066 vty_out(vty
, "%% No BGP neighbors found\n");
15069 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15070 json
, JSON_C_TO_STRING_PRETTY
));
15072 vty_out(vty
, "\n");
15075 return CMD_SUCCESS
;
15078 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15079 enum show_type type
,
15080 const char *ip_str
,
15081 afi_t afi
, bool use_json
)
15086 union sockunion su
;
15088 bgp
= bgp_get_default();
15094 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
15098 ret
= str2sockunion(ip_str
, &su
);
15100 bgp_show_neighbor_graceful_restart(
15101 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
15103 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15104 NULL
, afi
, use_json
);
15106 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15110 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15111 enum show_type type
,
15112 const char *ip_str
,
15115 struct listnode
*node
, *nnode
;
15117 union sockunion su
;
15118 json_object
*json
= NULL
;
15119 int ret
, is_first
= 1;
15120 bool nbr_output
= false;
15123 vty_out(vty
, "{\n");
15125 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15128 if (!(json
= json_object_new_object())) {
15130 EC_BGP_JSON_MEM_ERROR
,
15131 "Unable to allocate memory for JSON object");
15133 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15137 json_object_int_add(json
, "vrfId",
15138 (bgp
->vrf_id
== VRF_UNKNOWN
)
15140 : (int64_t)bgp
->vrf_id
);
15141 json_object_string_add(
15143 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15148 vty_out(vty
, ",\n");
15152 vty_out(vty
, "\"%s\":",
15153 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15157 vty_out(vty
, "\nInstance %s:\n",
15158 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15163 if (type
== show_peer
|| type
== show_ipv4_peer
||
15164 type
== show_ipv6_peer
) {
15165 ret
= str2sockunion(ip_str
, &su
);
15167 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15170 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15173 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15176 json_object_free(json
);
15181 vty_out(vty
, "}\n");
15182 else if (!nbr_output
)
15183 vty_out(vty
, "%% BGP instance not found\n");
15186 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15187 enum show_type type
, const char *ip_str
,
15192 union sockunion su
;
15193 json_object
*json
= NULL
;
15196 if (strmatch(name
, "all")) {
15197 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15199 return CMD_SUCCESS
;
15201 bgp
= bgp_lookup_by_name(name
);
15204 json
= json_object_new_object();
15205 vty_out(vty
, "%s\n",
15206 json_object_to_json_string_ext(
15208 JSON_C_TO_STRING_PRETTY
));
15209 json_object_free(json
);
15212 "%% BGP instance not found\n");
15214 return CMD_WARNING
;
15218 bgp
= bgp_get_default();
15222 json
= json_object_new_object();
15224 ret
= str2sockunion(ip_str
, &su
);
15226 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15229 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15232 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15235 json_object_free(json
);
15238 vty_out(vty
, "{}\n");
15240 vty_out(vty
, "%% BGP instance not found\n");
15243 return CMD_SUCCESS
;
15248 /* "show [ip] bgp neighbors graceful-restart" commands. */
15249 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
15250 show_ip_bgp_neighbors_graceful_restart_cmd
,
15251 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15257 "Neighbor to display information about\n"
15258 "Neighbor to display information about\n"
15259 "Neighbor on BGP configured interface\n"
15263 char *sh_arg
= NULL
;
15264 enum show_type sh_type
;
15266 afi_t afi
= AFI_MAX
;
15267 bool uj
= use_json(argc
, argv
);
15269 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15274 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15275 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15276 || argv_find(argv
, argc
, "WORD", &idx
)) {
15277 sh_type
= show_peer
;
15278 sh_arg
= argv
[idx
]->arg
;
15280 sh_type
= show_all
;
15282 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15283 return CMD_SUCCESS
;
15286 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15290 /* "show [ip] bgp neighbors" commands. */
15291 DEFUN (show_ip_bgp_neighbors
,
15292 show_ip_bgp_neighbors_cmd
,
15293 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15297 BGP_INSTANCE_HELP_STR
15300 "Detailed information on TCP and BGP neighbor connections\n"
15301 "Neighbor to display information about\n"
15302 "Neighbor to display information about\n"
15303 "Neighbor on BGP configured interface\n"
15307 char *sh_arg
= NULL
;
15308 enum show_type sh_type
;
15309 afi_t afi
= AFI_MAX
;
15311 bool uj
= use_json(argc
, argv
);
15315 /* [<vrf> VIEWVRFNAME] */
15316 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15317 vrf
= argv
[idx
+ 1]->arg
;
15318 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15320 } else if (argv_find(argv
, argc
, "view", &idx
))
15321 /* [<view> VIEWVRFNAME] */
15322 vrf
= argv
[idx
+ 1]->arg
;
15326 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15327 sh_type
= show_ipv4_all
;
15329 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15330 sh_type
= show_ipv6_all
;
15333 sh_type
= show_all
;
15336 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15337 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15338 || argv_find(argv
, argc
, "WORD", &idx
)) {
15339 sh_type
= show_peer
;
15340 sh_arg
= argv
[idx
]->arg
;
15343 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15344 sh_type
= show_ipv4_peer
;
15345 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15346 sh_type
= show_ipv6_peer
;
15349 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15352 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15353 paths' and `show ip mbgp paths'. Those functions results are the
15355 DEFUN (show_ip_bgp_paths
,
15356 show_ip_bgp_paths_cmd
,
15357 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15362 "Path information\n")
15364 vty_out(vty
, "Address Refcnt Path\n");
15365 aspath_print_all_vty(vty
);
15366 return CMD_SUCCESS
;
15371 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15374 struct community
*com
;
15376 com
= (struct community
*)bucket
->data
;
15377 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15378 community_str(com
, false));
15381 /* Show BGP's community internal data. */
15382 DEFUN (show_ip_bgp_community_info
,
15383 show_ip_bgp_community_info_cmd
,
15384 "show [ip] bgp community-info",
15388 "List all bgp community information\n")
15390 vty_out(vty
, "Address Refcnt Community\n");
15392 hash_iterate(community_hash(),
15393 (void (*)(struct hash_bucket
*,
15394 void *))community_show_all_iterator
,
15397 return CMD_SUCCESS
;
15400 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15403 struct lcommunity
*lcom
;
15405 lcom
= (struct lcommunity
*)bucket
->data
;
15406 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15407 lcommunity_str(lcom
, false));
15410 /* Show BGP's community internal data. */
15411 DEFUN (show_ip_bgp_lcommunity_info
,
15412 show_ip_bgp_lcommunity_info_cmd
,
15413 "show ip bgp large-community-info",
15417 "List all bgp large-community information\n")
15419 vty_out(vty
, "Address Refcnt Large-community\n");
15421 hash_iterate(lcommunity_hash(),
15422 (void (*)(struct hash_bucket
*,
15423 void *))lcommunity_show_all_iterator
,
15426 return CMD_SUCCESS
;
15428 /* Graceful Restart */
15430 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15437 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15439 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15441 switch (bgp_global_gr_mode
) {
15443 case GLOBAL_HELPER
:
15444 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15448 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15451 case GLOBAL_DISABLE
:
15452 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15455 case GLOBAL_INVALID
:
15457 "Global BGP GR Mode Invalid\n");
15460 vty_out(vty
, "\n");
15463 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15464 enum show_type type
,
15465 const char *ip_str
,
15466 afi_t afi
, bool use_json
)
15468 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15471 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15473 bgp_show_neighbor_graceful_restart_vty(
15474 vty
, type
, ip_str
, afi
, use_json
);
15477 } else if (afi
!= AFI_MAX
) {
15478 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15481 return CMD_ERR_INCOMPLETE
;
15484 return CMD_SUCCESS
;
15486 /* Graceful Restart */
15488 DEFUN (show_ip_bgp_attr_info
,
15489 show_ip_bgp_attr_info_cmd
,
15490 "show [ip] bgp attribute-info",
15494 "List all bgp attribute information\n")
15496 attr_show_all(vty
);
15497 return CMD_SUCCESS
;
15500 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15501 afi_t afi
, safi_t safi
,
15502 bool use_json
, json_object
*json
)
15505 struct listnode
*node
;
15507 char buf1
[INET6_ADDRSTRLEN
];
15509 vpn_policy_direction_t dir
;
15512 json_object
*json_import_vrfs
= NULL
;
15513 json_object
*json_export_vrfs
= NULL
;
15515 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15518 vty_out(vty
, "%s\n",
15519 json_object_to_json_string_ext(
15521 JSON_C_TO_STRING_PRETTY
));
15522 json_object_free(json
);
15524 return CMD_WARNING
;
15527 /* Provide context for the block */
15528 json_object_string_add(json
, "vrf", name
? name
: "default");
15529 json_object_string_add(json
, "afiSafi",
15530 get_afi_safi_str(afi
, safi
, true));
15532 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15533 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15534 json_object_string_add(json
, "importFromVrfs", "none");
15535 json_object_string_add(json
, "importRts", "none");
15537 json_import_vrfs
= json_object_new_array();
15539 for (ALL_LIST_ELEMENTS_RO(
15540 bgp
->vpn_policy
[afi
].import_vrf
,
15542 json_object_array_add(json_import_vrfs
,
15543 json_object_new_string(vname
));
15545 json_object_object_add(json
, "importFromVrfs",
15547 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15548 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15549 ecom_str
= ecommunity_ecom2str(
15550 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15551 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15552 json_object_string_add(json
, "importRts",
15554 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15556 json_object_string_add(json
, "importRts",
15560 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15561 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15562 json_object_string_add(json
, "exportToVrfs", "none");
15563 json_object_string_add(json
, "routeDistinguisher",
15565 json_object_string_add(json
, "exportRts", "none");
15567 json_export_vrfs
= json_object_new_array();
15569 for (ALL_LIST_ELEMENTS_RO(
15570 bgp
->vpn_policy
[afi
].export_vrf
,
15572 json_object_array_add(json_export_vrfs
,
15573 json_object_new_string(vname
));
15574 json_object_object_add(json
, "exportToVrfs",
15576 json_object_string_add(json
, "routeDistinguisher",
15577 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15578 buf1
, RD_ADDRSTRLEN
));
15580 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15581 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15582 ecom_str
= ecommunity_ecom2str(
15583 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15584 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15585 json_object_string_add(json
, "exportRts",
15587 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15589 json_object_string_add(json
, "exportRts",
15594 vty_out(vty
, "%s\n",
15595 json_object_to_json_string_ext(json
,
15596 JSON_C_TO_STRING_PRETTY
));
15597 json_object_free(json
);
15600 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15603 vty_out(vty
, "%% No such BGP instance exist\n");
15604 return CMD_WARNING
;
15607 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15608 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15610 "This VRF is not importing %s routes from any other VRF\n",
15611 get_afi_safi_str(afi
, safi
, false));
15614 "This VRF is importing %s routes from the following VRFs:\n",
15615 get_afi_safi_str(afi
, safi
, false));
15617 for (ALL_LIST_ELEMENTS_RO(
15618 bgp
->vpn_policy
[afi
].import_vrf
,
15620 vty_out(vty
, " %s\n", vname
);
15622 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15624 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15625 ecom_str
= ecommunity_ecom2str(
15626 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15627 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15628 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15630 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15632 vty_out(vty
, "Import RT(s):\n");
15635 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15636 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15638 "This VRF is not exporting %s routes to any other VRF\n",
15639 get_afi_safi_str(afi
, safi
, false));
15642 "This VRF is exporting %s routes to the following VRFs:\n",
15643 get_afi_safi_str(afi
, safi
, false));
15645 for (ALL_LIST_ELEMENTS_RO(
15646 bgp
->vpn_policy
[afi
].export_vrf
,
15648 vty_out(vty
, " %s\n", vname
);
15650 vty_out(vty
, "RD: %s\n",
15651 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15652 buf1
, RD_ADDRSTRLEN
));
15654 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15655 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15656 ecom_str
= ecommunity_ecom2str(
15657 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15658 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15659 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15660 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15662 vty_out(vty
, "Import RT(s):\n");
15666 return CMD_SUCCESS
;
15669 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15670 safi_t safi
, bool use_json
)
15672 struct listnode
*node
, *nnode
;
15674 char *vrf_name
= NULL
;
15675 json_object
*json
= NULL
;
15676 json_object
*json_vrf
= NULL
;
15677 json_object
*json_vrfs
= NULL
;
15680 json
= json_object_new_object();
15681 json_vrfs
= json_object_new_object();
15684 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15686 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15687 vrf_name
= bgp
->name
;
15690 json_vrf
= json_object_new_object();
15692 vty_out(vty
, "\nInstance %s:\n",
15693 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15694 ? VRF_DEFAULT_NAME
: bgp
->name
);
15696 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15698 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15699 json_object_object_add(json_vrfs
,
15700 VRF_DEFAULT_NAME
, json_vrf
);
15702 json_object_object_add(json_vrfs
, vrf_name
,
15708 json_object_object_add(json
, "vrfs", json_vrfs
);
15709 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15710 JSON_C_TO_STRING_PRETTY
));
15711 json_object_free(json
);
15714 return CMD_SUCCESS
;
15717 /* "show [ip] bgp route-leak" command. */
15718 DEFUN (show_ip_bgp_route_leak
,
15719 show_ip_bgp_route_leak_cmd
,
15720 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15724 BGP_INSTANCE_HELP_STR
15727 "Route leaking information\n"
15731 afi_t afi
= AFI_MAX
;
15732 safi_t safi
= SAFI_MAX
;
15734 bool uj
= use_json(argc
, argv
);
15736 json_object
*json
= NULL
;
15738 /* show [ip] bgp */
15739 if (argv_find(argv
, argc
, "ip", &idx
)) {
15741 safi
= SAFI_UNICAST
;
15743 /* [vrf VIEWVRFNAME] */
15744 if (argv_find(argv
, argc
, "view", &idx
)) {
15746 "%% This command is not applicable to BGP views\n");
15747 return CMD_WARNING
;
15750 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15751 vrf
= argv
[idx
+ 1]->arg
;
15752 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15755 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15756 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15757 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15760 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15762 "%% This command is applicable only for unicast ipv4|ipv6\n");
15763 return CMD_WARNING
;
15766 if (vrf
&& strmatch(vrf
, "all"))
15767 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15770 json
= json_object_new_object();
15772 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15775 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15778 struct listnode
*node
, *nnode
;
15781 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15782 vty_out(vty
, "\nInstance %s:\n",
15783 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15786 update_group_show(bgp
, afi
, safi
, vty
, 0);
15790 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15791 int safi
, uint64_t subgrp_id
)
15796 if (strmatch(name
, "all")) {
15797 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15798 return CMD_SUCCESS
;
15800 bgp
= bgp_lookup_by_name(name
);
15803 bgp
= bgp_get_default();
15807 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15808 return CMD_SUCCESS
;
15811 DEFUN (show_ip_bgp_updgrps
,
15812 show_ip_bgp_updgrps_cmd
,
15813 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15817 BGP_INSTANCE_HELP_STR
15819 BGP_SAFI_WITH_LABEL_HELP_STR
15820 "Detailed info about dynamic update groups\n"
15821 "Specific subgroup to display detailed info for\n")
15824 afi_t afi
= AFI_IP6
;
15825 safi_t safi
= SAFI_UNICAST
;
15826 uint64_t subgrp_id
= 0;
15830 /* show [ip] bgp */
15831 if (argv_find(argv
, argc
, "ip", &idx
))
15833 /* [<vrf> VIEWVRFNAME] */
15834 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15835 vrf
= argv
[idx
+ 1]->arg
;
15836 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15838 } else if (argv_find(argv
, argc
, "view", &idx
))
15839 /* [<view> VIEWVRFNAME] */
15840 vrf
= argv
[idx
+ 1]->arg
;
15841 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15842 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15843 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15846 /* get subgroup id, if provided */
15848 if (argv
[idx
]->type
== VARIABLE_TKN
)
15849 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15851 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15854 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15855 show_bgp_instance_all_ipv6_updgrps_cmd
,
15856 "show [ip] bgp <view|vrf> all update-groups",
15860 BGP_INSTANCE_ALL_HELP_STR
15861 "Detailed info about dynamic update groups\n")
15863 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15864 return CMD_SUCCESS
;
15867 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15868 show_bgp_l2vpn_evpn_updgrps_cmd
,
15869 "show [ip] bgp l2vpn evpn update-groups",
15873 "l2vpn address family\n"
15874 "evpn sub-address family\n"
15875 "Detailed info about dynamic update groups\n")
15878 uint64_t subgrp_id
= 0;
15880 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15881 return CMD_SUCCESS
;
15884 DEFUN (show_bgp_updgrps_stats
,
15885 show_bgp_updgrps_stats_cmd
,
15886 "show [ip] bgp update-groups statistics",
15890 "Detailed info about dynamic update groups\n"
15895 bgp
= bgp_get_default();
15897 update_group_show_stats(bgp
, vty
);
15899 return CMD_SUCCESS
;
15902 DEFUN (show_bgp_instance_updgrps_stats
,
15903 show_bgp_instance_updgrps_stats_cmd
,
15904 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15908 BGP_INSTANCE_HELP_STR
15909 "Detailed info about dynamic update groups\n"
15915 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15917 update_group_show_stats(bgp
, vty
);
15919 return CMD_SUCCESS
;
15922 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15923 afi_t afi
, safi_t safi
,
15924 const char *what
, uint64_t subgrp_id
)
15929 bgp
= bgp_lookup_by_name(name
);
15931 bgp
= bgp_get_default();
15934 if (!strcmp(what
, "advertise-queue"))
15935 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15937 else if (!strcmp(what
, "advertised-routes"))
15938 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15940 else if (!strcmp(what
, "packet-queue"))
15941 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15946 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15947 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15948 "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",
15949 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15951 "Detailed info about dynamic update groups\n"
15952 "Specific subgroup to display info for\n"
15953 "Advertisement queue\n"
15954 "Announced routes\n"
15957 uint64_t subgrp_id
= 0;
15961 subgrp_id
= strtoull(sgid
, NULL
, 10);
15966 afiz
= bgp_vty_afi_from_str(afi
);
15970 afiz
= bgp_vty_afi_from_str(afi
);
15971 if (afiz
!= AFI_IP
)
15973 "%% Cannot specify both 'ip' and 'ipv6'\n");
15974 return CMD_WARNING
;
15977 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15979 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15980 return CMD_SUCCESS
;
15983 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15986 struct listnode
*node
, *nnode
;
15987 struct prefix
*range
;
15992 const char *peer_status
;
15996 json_object
*json_peer_group
= NULL
;
15997 json_object
*json_peer_group_afc
= NULL
;
15998 json_object
*json_peer_group_members
= NULL
;
15999 json_object
*json_peer_group_dynamic
= NULL
;
16000 json_object
*json_peer_group_dynamic_af
= NULL
;
16001 json_object
*json_peer_group_ranges
= NULL
;
16003 conf
= group
->conf
;
16006 json_peer_group
= json_object_new_object();
16007 json_peer_group_afc
= json_object_new_array();
16010 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
16012 json_object_int_add(json_peer_group
, "remoteAs",
16015 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
16016 group
->name
, conf
->as
);
16017 } else if (conf
->as_type
== AS_INTERNAL
) {
16019 json_object_int_add(json_peer_group
, "remoteAs",
16022 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
16023 group
->name
, group
->bgp
->as
);
16026 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
16029 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
16031 json_object_string_add(json_peer_group
, "type",
16034 vty_out(vty
, " Peer-group type is internal\n");
16037 json_object_string_add(json_peer_group
, "type",
16040 vty_out(vty
, " Peer-group type is external\n");
16043 /* Display AFs configured. */
16045 vty_out(vty
, " Configured address-families:");
16047 FOREACH_AFI_SAFI (afi
, safi
) {
16048 if (conf
->afc
[afi
][safi
]) {
16051 json_object_array_add(
16052 json_peer_group_afc
,
16053 json_object_new_string(get_afi_safi_str(
16054 afi
, safi
, false)));
16056 vty_out(vty
, " %s;",
16057 get_afi_safi_str(afi
, safi
, false));
16062 json_object_object_add(json_peer_group
,
16063 "addressFamiliesConfigured",
16064 json_peer_group_afc
);
16067 vty_out(vty
, " none\n");
16069 vty_out(vty
, "\n");
16072 /* Display listen ranges (for dynamic neighbors), if any */
16073 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16074 lr_count
= listcount(group
->listen_range
[afi
]);
16077 if (!json_peer_group_dynamic
)
16078 json_peer_group_dynamic
=
16079 json_object_new_object();
16081 json_peer_group_dynamic_af
=
16082 json_object_new_object();
16083 json_peer_group_ranges
=
16084 json_object_new_array();
16085 json_object_int_add(json_peer_group_dynamic_af
,
16086 "count", lr_count
);
16088 vty_out(vty
, " %d %s listen range(s)\n",
16089 lr_count
, afi2str(afi
));
16092 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16097 snprintfrr(buf
, sizeof(buf
), "%pFX",
16100 json_object_array_add(
16101 json_peer_group_ranges
,
16102 json_object_new_string(buf
));
16104 vty_out(vty
, " %pFX\n", range
);
16109 json_object_object_add(
16110 json_peer_group_dynamic_af
, "ranges",
16111 json_peer_group_ranges
);
16113 json_object_object_add(
16114 json_peer_group_dynamic
, afi2str(afi
),
16115 json_peer_group_dynamic_af
);
16120 if (json_peer_group_dynamic
)
16121 json_object_object_add(json_peer_group
, "dynamicRanges",
16122 json_peer_group_dynamic
);
16124 /* Display group members and their status */
16125 if (listcount(group
->peer
)) {
16127 json_peer_group_members
= json_object_new_object();
16129 vty_out(vty
, " Peer-group members:\n");
16130 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16131 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16132 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16133 peer_status
= "Idle (Admin)";
16134 else if (CHECK_FLAG(peer
->sflags
,
16135 PEER_STATUS_PREFIX_OVERFLOW
))
16136 peer_status
= "Idle (PfxCt)";
16138 peer_status
= lookup_msg(bgp_status_msg
,
16139 peer
->status
, NULL
);
16141 dynamic
= peer_dynamic_neighbor(peer
);
16144 json_object
*json_peer_group_member
=
16145 json_object_new_object();
16147 json_object_string_add(json_peer_group_member
,
16148 "status", peer_status
);
16151 json_object_boolean_true_add(
16152 json_peer_group_member
,
16155 json_object_object_add(json_peer_group_members
,
16157 json_peer_group_member
);
16159 vty_out(vty
, " %s %s %s \n", peer
->host
,
16160 dynamic
? "(dynamic)" : "",
16165 json_object_object_add(json_peer_group
, "members",
16166 json_peer_group_members
);
16170 json_object_object_add(json
, group
->name
, json_peer_group
);
16172 return CMD_SUCCESS
;
16175 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16176 const char *group_name
, bool uj
)
16179 struct listnode
*node
, *nnode
;
16180 struct peer_group
*group
;
16181 bool found
= false;
16182 json_object
*json
= NULL
;
16185 json
= json_object_new_object();
16187 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16191 vty_out(vty
, "%s\n",
16192 json_object_to_json_string_ext(
16193 json
, JSON_C_TO_STRING_PRETTY
));
16194 json_object_free(json
);
16196 vty_out(vty
, "%% BGP instance not found\n");
16199 return CMD_WARNING
;
16202 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16204 if (strmatch(group
->name
, group_name
)) {
16205 bgp_show_one_peer_group(vty
, group
, json
);
16210 bgp_show_one_peer_group(vty
, group
, json
);
16214 if (group_name
&& !found
&& !uj
)
16215 vty_out(vty
, "%% No such peer-group\n");
16218 vty_out(vty
, "%s\n",
16219 json_object_to_json_string_ext(
16220 json
, JSON_C_TO_STRING_PRETTY
));
16221 json_object_free(json
);
16224 return CMD_SUCCESS
;
16227 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16228 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16229 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16230 "Detailed information on BGP peer groups\n"
16231 "Peer group name\n" JSON_STR
)
16235 bool uj
= use_json(argc
, argv
);
16237 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16239 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16241 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16245 /* Redistribute VTY commands. */
16247 DEFUN_YANG (bgp_redistribute_ipv4
,
16248 bgp_redistribute_ipv4_cmd
,
16249 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16250 "Redistribute information from another routing protocol\n"
16251 FRR_IP_REDIST_HELP_STR_BGPD
)
16253 int idx_protocol
= 1;
16254 char base_xpath
[XPATH_MAXLEN
];
16256 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16257 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16258 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16259 argv
[idx_protocol
]->text
, "0");
16261 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16263 return nb_cli_apply_changes(vty
, base_xpath
);
16267 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16268 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16269 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16271 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
16272 bgp_redistribute_ipv4_rmap_cmd
,
16273 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
16274 "Redistribute information from another routing protocol\n"
16275 FRR_IP_REDIST_HELP_STR_BGPD
16276 "Route map reference\n"
16277 "Pointer to route-map entries\n")
16279 int idx_protocol
= 1;
16281 char base_xpath
[XPATH_MAXLEN
];
16283 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16284 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16285 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16286 argv
[idx_protocol
]->text
, "0");
16288 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16289 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16290 argv
[idx_word
]->arg
);
16292 return nb_cli_apply_changes(vty
, base_xpath
);
16296 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16297 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
16298 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16299 "Route map reference\n"
16300 "Pointer to route-map entries\n")
16302 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
16303 bgp_redistribute_ipv4_metric_cmd
,
16304 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16305 "Redistribute information from another routing protocol\n"
16306 FRR_IP_REDIST_HELP_STR_BGPD
16307 "Metric for redistributed routes\n"
16308 "Default metric\n")
16310 int idx_protocol
= 1;
16311 int idx_number
= 3;
16312 char base_xpath
[XPATH_MAXLEN
];
16314 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16315 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16316 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16317 argv
[idx_protocol
]->text
, "0");
16319 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16320 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16321 argv
[idx_number
]->arg
);
16323 return nb_cli_apply_changes(vty
, base_xpath
);
16327 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16328 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16329 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16330 "Metric for redistributed routes\n"
16331 "Default metric\n")
16334 bgp_redistribute_ipv4_rmap_metric
,
16335 bgp_redistribute_ipv4_rmap_metric_cmd
,
16336 "redistribute " FRR_IP_REDIST_STR_BGPD
16337 " route-map WORD metric (0-4294967295)",
16338 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16339 "Route map reference\n"
16340 "Pointer to route-map entries\n"
16341 "Metric for redistributed routes\n"
16342 "Default metric\n")
16344 int idx_protocol
= 1;
16346 int idx_number
= 5;
16347 char base_xpath
[XPATH_MAXLEN
];
16349 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16350 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16351 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16352 argv
[idx_protocol
]->text
, "0");
16354 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16355 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16356 argv
[idx_word
]->arg
);
16357 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16358 argv
[idx_number
]->arg
);
16360 return nb_cli_apply_changes(vty
, base_xpath
);
16364 bgp_redistribute_ipv4_rmap_metric
,
16365 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16366 "redistribute " FRR_IP_REDIST_STR_BGPD
16367 " route-map WORD metric (0-4294967295)",
16368 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16369 "Route map reference\n"
16370 "Pointer to route-map entries\n"
16371 "Metric for redistributed routes\n"
16372 "Default metric\n")
16375 bgp_redistribute_ipv4_metric_rmap
,
16376 bgp_redistribute_ipv4_metric_rmap_cmd
,
16377 "redistribute " FRR_IP_REDIST_STR_BGPD
16378 " metric (0-4294967295) route-map WORD",
16379 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16380 "Metric for redistributed routes\n"
16382 "Route map reference\n"
16383 "Pointer to route-map entries\n")
16385 int idx_protocol
= 1;
16387 int idx_number
= 3;
16388 char base_xpath
[XPATH_MAXLEN
];
16390 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16391 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16392 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16393 argv
[idx_protocol
]->text
, "0");
16395 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16396 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16397 argv
[idx_number
]->arg
);
16398 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16399 argv
[idx_word
]->arg
);
16401 return nb_cli_apply_changes(vty
, base_xpath
);
16405 bgp_redistribute_ipv4_metric_rmap
,
16406 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16407 "redistribute " FRR_IP_REDIST_STR_BGPD
16408 " metric (0-4294967295) route-map WORD",
16409 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16410 "Metric for redistributed routes\n"
16412 "Route map reference\n"
16413 "Pointer to route-map entries\n")
16415 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
16416 bgp_redistribute_ipv4_ospf_cmd
,
16417 "redistribute <ospf|table> (1-65535)",
16418 "Redistribute information from another routing protocol\n"
16419 "Open Shortest Path First (OSPFv2)\n"
16420 "Non-main Kernel Routing Table\n"
16421 "Instance ID/Table ID\n")
16423 int idx_protocol
= 1;
16424 int idx_number
= 2;
16425 char base_xpath
[XPATH_MAXLEN
];
16427 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16428 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16429 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16430 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16432 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16434 return nb_cli_apply_changes(vty
, base_xpath
);
16437 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16438 "redistribute <ospf|table> (1-65535)",
16439 "Redistribute information from another routing protocol\n"
16440 "Open Shortest Path First (OSPFv2)\n"
16441 "Non-main Kernel Routing Table\n"
16442 "Instance ID/Table ID\n")
16444 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
16445 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16446 "redistribute <ospf|table> (1-65535) route-map WORD",
16447 "Redistribute information from another routing protocol\n"
16448 "Open Shortest Path First (OSPFv2)\n"
16449 "Non-main Kernel Routing Table\n"
16450 "Instance ID/Table ID\n"
16451 "Route map reference\n"
16452 "Pointer to route-map entries\n")
16454 int idx_protocol
= 1;
16455 int idx_number
= 2;
16457 char base_xpath
[XPATH_MAXLEN
];
16459 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16460 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16461 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16462 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16464 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16466 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16467 argv
[idx_word
]->arg
);
16469 return nb_cli_apply_changes(vty
, base_xpath
);
16472 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16473 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16474 "redistribute <ospf|table> (1-65535) route-map WORD",
16475 "Redistribute information from another routing protocol\n"
16476 "Open Shortest Path First (OSPFv2)\n"
16477 "Non-main Kernel Routing Table\n"
16478 "Instance ID/Table ID\n"
16479 "Route map reference\n"
16480 "Pointer to route-map entries\n")
16482 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
16483 bgp_redistribute_ipv4_ospf_metric_cmd
,
16484 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16485 "Redistribute information from another routing protocol\n"
16486 "Open Shortest Path First (OSPFv2)\n"
16487 "Non-main Kernel Routing Table\n"
16488 "Instance ID/Table ID\n"
16489 "Metric for redistributed routes\n"
16490 "Default metric\n")
16492 int idx_protocol
= 1;
16493 int idx_number
= 2;
16494 int idx_number_2
= 4;
16495 char base_xpath
[XPATH_MAXLEN
];
16497 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16498 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16499 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16500 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16502 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16504 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16505 argv
[idx_number_2
]->arg
);
16507 return nb_cli_apply_changes(vty
, base_xpath
);
16510 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16511 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16512 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16513 "Redistribute information from another routing protocol\n"
16514 "Open Shortest Path First (OSPFv2)\n"
16515 "Non-main Kernel Routing Table\n"
16516 "Instance ID/Table ID\n"
16517 "Metric for redistributed routes\n"
16518 "Default metric\n")
16521 bgp_redistribute_ipv4_ospf_rmap_metric
,
16522 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16523 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16524 "Redistribute information from another routing protocol\n"
16525 "Open Shortest Path First (OSPFv2)\n"
16526 "Non-main Kernel Routing Table\n"
16527 "Instance ID/Table ID\n"
16528 "Route map reference\n"
16529 "Pointer to route-map entries\n"
16530 "Metric for redistributed routes\n"
16531 "Default metric\n")
16533 int idx_protocol
= 1;
16534 int idx_number
= 2;
16536 int idx_number_2
= 6;
16537 char base_xpath
[XPATH_MAXLEN
];
16539 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16540 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16541 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16542 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16544 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16546 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16547 argv
[idx_word
]->arg
);
16548 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16549 argv
[idx_number_2
]->arg
);
16551 return nb_cli_apply_changes(vty
, base_xpath
);
16555 bgp_redistribute_ipv4_ospf_rmap_metric
,
16556 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16557 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16558 "Redistribute information from another routing protocol\n"
16559 "Open Shortest Path First (OSPFv2)\n"
16560 "Non-main Kernel Routing Table\n"
16561 "Instance ID/Table ID\n"
16562 "Route map reference\n"
16563 "Pointer to route-map entries\n"
16564 "Metric for redistributed routes\n"
16565 "Default metric\n")
16568 bgp_redistribute_ipv4_ospf_metric_rmap
,
16569 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16570 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16571 "Redistribute information from another routing protocol\n"
16572 "Open Shortest Path First (OSPFv2)\n"
16573 "Non-main Kernel Routing Table\n"
16574 "Instance ID/Table ID\n"
16575 "Metric for redistributed routes\n"
16577 "Route map reference\n"
16578 "Pointer to route-map entries\n")
16580 int idx_protocol
= 1;
16581 int idx_number
= 2;
16582 int idx_number_2
= 4;
16584 char base_xpath
[XPATH_MAXLEN
];
16586 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16587 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16588 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16589 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16591 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16593 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16594 argv
[idx_number_2
]->arg
);
16595 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16596 argv
[idx_word
]->arg
);
16598 return nb_cli_apply_changes(vty
, base_xpath
);
16602 bgp_redistribute_ipv4_ospf_metric_rmap
,
16603 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16604 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16605 "Redistribute information from another routing protocol\n"
16606 "Open Shortest Path First (OSPFv2)\n"
16607 "Non-main Kernel Routing Table\n"
16608 "Instance ID/Table ID\n"
16609 "Metric for redistributed routes\n"
16611 "Route map reference\n"
16612 "Pointer to route-map entries\n")
16614 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
16615 no_bgp_redistribute_ipv4_ospf_cmd
,
16616 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16618 "Redistribute information from another routing protocol\n"
16619 "Open Shortest Path First (OSPFv2)\n"
16620 "Non-main Kernel Routing Table\n"
16621 "Instance ID/Table ID\n"
16622 "Metric for redistributed routes\n"
16624 "Route map reference\n"
16625 "Pointer to route-map entries\n")
16627 int idx_protocol
= 2;
16628 int idx_number
= 3;
16629 char base_xpath
[XPATH_MAXLEN
];
16631 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16632 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16633 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16634 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16636 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16638 return nb_cli_apply_changes(vty
, base_xpath
);
16642 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16643 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16645 "Redistribute information from another routing protocol\n"
16646 "Open Shortest Path First (OSPFv2)\n"
16647 "Non-main Kernel Routing Table\n"
16648 "Instance ID/Table ID\n"
16649 "Metric for redistributed routes\n"
16651 "Route map reference\n"
16652 "Pointer to route-map entries\n")
16654 DEFUN_YANG (no_bgp_redistribute_ipv4
,
16655 no_bgp_redistribute_ipv4_cmd
,
16656 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16658 "Redistribute information from another routing protocol\n"
16659 FRR_IP_REDIST_HELP_STR_BGPD
16660 "Metric for redistributed routes\n"
16662 "Route map reference\n"
16663 "Pointer to route-map entries\n")
16665 int idx_protocol
= 2;
16666 char base_xpath
[XPATH_MAXLEN
];
16668 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16669 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16670 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16671 argv
[idx_protocol
]->text
, "0");
16673 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16675 return nb_cli_apply_changes(vty
, base_xpath
);
16679 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16680 "no redistribute " FRR_IP_REDIST_STR_BGPD
16681 " [{metric (0-4294967295)|route-map WORD}]",
16683 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16684 "Metric for redistributed routes\n"
16686 "Route map reference\n"
16687 "Pointer to route-map entries\n")
16689 DEFUN_YANG (bgp_redistribute_ipv6
,
16690 bgp_redistribute_ipv6_cmd
,
16691 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16692 "Redistribute information from another routing protocol\n"
16693 FRR_IP6_REDIST_HELP_STR_BGPD
)
16695 int idx_protocol
= 1;
16696 char base_xpath
[XPATH_MAXLEN
];
16698 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16699 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16700 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16701 argv
[idx_protocol
]->text
, "0");
16703 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16705 return nb_cli_apply_changes(vty
, base_xpath
);
16708 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16709 bgp_redistribute_ipv6_rmap_cmd
,
16710 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16711 "Redistribute information from another routing protocol\n"
16712 FRR_IP6_REDIST_HELP_STR_BGPD
16713 "Route map reference\n"
16714 "Pointer to route-map entries\n")
16716 int idx_protocol
= 1;
16718 char base_xpath
[XPATH_MAXLEN
];
16720 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16721 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16722 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16723 argv
[idx_protocol
]->text
, "0");
16725 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16726 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16727 argv
[idx_word
]->arg
);
16729 return nb_cli_apply_changes(vty
, base_xpath
);
16732 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16733 bgp_redistribute_ipv6_metric_cmd
,
16734 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16735 "Redistribute information from another routing protocol\n"
16736 FRR_IP6_REDIST_HELP_STR_BGPD
16737 "Metric for redistributed routes\n"
16738 "Default metric\n")
16740 int idx_protocol
= 1;
16741 int idx_number
= 3;
16742 char base_xpath
[XPATH_MAXLEN
];
16744 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16745 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16746 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16747 argv
[idx_protocol
]->text
, "0");
16749 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16750 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16751 argv
[idx_number
]->arg
);
16753 return nb_cli_apply_changes(vty
, base_xpath
);
16757 bgp_redistribute_ipv6_rmap_metric
,
16758 bgp_redistribute_ipv6_rmap_metric_cmd
,
16759 "redistribute " FRR_IP6_REDIST_STR_BGPD
16760 " route-map WORD metric (0-4294967295)",
16761 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16762 "Route map reference\n"
16763 "Pointer to route-map entries\n"
16764 "Metric for redistributed routes\n"
16765 "Default metric\n")
16767 int idx_protocol
= 1;
16769 int idx_number
= 5;
16770 char base_xpath
[XPATH_MAXLEN
];
16772 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16773 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16774 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16775 argv
[idx_protocol
]->text
, "0");
16777 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16778 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16779 argv
[idx_word
]->arg
);
16780 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16781 argv
[idx_number
]->arg
);
16783 return nb_cli_apply_changes(vty
, base_xpath
);
16787 bgp_redistribute_ipv6_metric_rmap
,
16788 bgp_redistribute_ipv6_metric_rmap_cmd
,
16789 "redistribute " FRR_IP6_REDIST_STR_BGPD
16790 " metric (0-4294967295) route-map WORD",
16791 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16792 "Metric for redistributed routes\n"
16794 "Route map reference\n"
16795 "Pointer to route-map entries\n")
16797 int idx_protocol
= 1;
16799 int idx_number
= 3;
16800 char base_xpath
[XPATH_MAXLEN
];
16802 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16803 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16804 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16805 argv
[idx_protocol
]->text
, "0");
16807 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16808 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16809 argv
[idx_number
]->arg
);
16810 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16811 argv
[idx_word
]->arg
);
16813 return nb_cli_apply_changes(vty
, base_xpath
);
16817 no_bgp_redistribute_ipv6
,
16818 no_bgp_redistribute_ipv6_cmd
,
16819 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16820 " [{metric (0-4294967295)|route-map WORD}]",
16822 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16823 "Metric for redistributed routes\n"
16825 "Route map reference\n"
16826 "Pointer to route-map entries\n")
16828 int idx_protocol
= 2;
16829 char base_xpath
[XPATH_MAXLEN
];
16831 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16832 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16833 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16834 argv
[idx_protocol
]->text
, "0");
16836 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16838 return nb_cli_apply_changes(vty
, base_xpath
);
16841 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16842 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16844 uint32_t instance
= 0;
16846 vty_out(vty
, " redistribute %s",
16847 yang_dnode_get_string(dnode
, "./route-type"));
16848 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16849 vty_out(vty
, " %d", instance
);
16850 if (yang_dnode_exists(dnode
, "./metric"))
16851 vty_out(vty
, " metric %u",
16852 yang_dnode_get_uint32(dnode
, "./metric"));
16853 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16854 vty_out(vty
, " route-map %s",
16855 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16856 vty_out(vty
, "\n");
16859 /* Neighbor update tcp-mss. */
16860 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16861 const char *tcp_mss_str
)
16864 uint32_t tcp_mss_val
= 0;
16866 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16868 return CMD_WARNING_CONFIG_FAILED
;
16871 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16872 peer_tcp_mss_set(peer
, tcp_mss_val
);
16874 peer_tcp_mss_unset(peer
);
16877 return CMD_SUCCESS
;
16880 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16881 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16882 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16883 "TCP max segment size\n"
16886 int peer_index
= 1;
16890 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16891 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16892 argv
[mss_index
]->arg
);
16895 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16896 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16897 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16898 "TCP max segment size\n"
16901 int peer_index
= 2;
16904 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16905 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16908 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16909 afi_t afi
, safi_t safi
)
16913 /* Unicast redistribution only. */
16914 if (safi
!= SAFI_UNICAST
)
16917 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16918 /* Redistribute BGP does not make sense. */
16919 if (i
!= ZEBRA_ROUTE_BGP
) {
16920 struct list
*red_list
;
16921 struct listnode
*node
;
16922 struct bgp_redist
*red
;
16924 red_list
= bgp
->redist
[afi
][i
];
16928 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16929 /* "redistribute" configuration. */
16930 vty_out(vty
, " redistribute %s",
16931 zebra_route_string(i
));
16933 vty_out(vty
, " %d", red
->instance
);
16934 if (red
->redist_metric_flag
)
16935 vty_out(vty
, " metric %u",
16936 red
->redist_metric
);
16937 if (red
->rmap
.name
)
16938 vty_out(vty
, " route-map %s",
16940 vty_out(vty
, "\n");
16946 /* peer-group helpers for config-write */
16948 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16950 if (!peer_group_active(peer
)) {
16951 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16952 return !CHECK_FLAG(peer
->flags
, flag
);
16954 return !!CHECK_FLAG(peer
->flags
, flag
);
16957 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16960 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16963 if (!peer_group_active(peer
)) {
16964 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16965 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16967 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16970 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16973 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16974 uint8_t type
, int direct
)
16976 struct bgp_filter
*filter
;
16978 if (peer_group_active(peer
))
16979 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16982 filter
= &peer
->filter
[afi
][safi
];
16984 case PEER_FT_DISTRIBUTE_LIST
:
16985 return !!(filter
->dlist
[direct
].name
);
16986 case PEER_FT_FILTER_LIST
:
16987 return !!(filter
->aslist
[direct
].name
);
16988 case PEER_FT_PREFIX_LIST
:
16989 return !!(filter
->plist
[direct
].name
);
16990 case PEER_FT_ROUTE_MAP
:
16991 return !!(filter
->map
[direct
].name
);
16992 case PEER_FT_UNSUPPRESS_MAP
:
16993 return !!(filter
->usmap
.name
);
16994 case PEER_FT_ADVERTISE_MAP
:
16995 return !!(filter
->advmap
.aname
16996 && ((filter
->advmap
.condition
== direct
)
16997 && filter
->advmap
.cname
));
17003 /* Return true if the addpath type is set for peer and different from
17006 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
17009 enum bgp_addpath_strat type
, g_type
;
17011 type
= peer
->addpath_type
[afi
][safi
];
17013 if (type
!= BGP_ADDPATH_NONE
) {
17014 if (peer_group_active(peer
)) {
17015 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
17017 if (type
!= g_type
)
17029 /* This is part of the address-family block (unicast only) */
17030 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17035 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17036 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17037 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17038 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17039 bgp
->vpn_policy
[afi
]
17040 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17042 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17043 bgp
->vpn_policy
[afi
]
17044 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17046 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17047 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17048 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17049 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17052 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17053 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17055 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17058 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17059 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17060 bgp
->vpn_policy
[afi
].tovpn_label
);
17063 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17064 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
17065 char buf
[RD_ADDRSTRLEN
];
17066 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
17067 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
17070 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17071 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17073 char buf
[PREFIX_STRLEN
];
17074 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17075 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17078 vty_out(vty
, "%*snexthop vpn export %s\n",
17082 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17083 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17085 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17086 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17088 char *b
= ecommunity_ecom2str(
17089 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17090 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17091 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17092 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17094 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17095 char *b
= ecommunity_ecom2str(
17096 bgp
->vpn_policy
[afi
]
17097 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17098 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17099 ECOMMUNITY_ROUTE_TARGET
);
17100 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17101 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17103 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17104 char *b
= ecommunity_ecom2str(
17105 bgp
->vpn_policy
[afi
]
17106 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17107 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17108 ECOMMUNITY_ROUTE_TARGET
);
17109 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17110 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17114 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17115 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17116 bgp
->vpn_policy
[afi
]
17117 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17119 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17120 char *b
= ecommunity_ecom2str(
17121 bgp
->vpn_policy
[afi
]
17122 .import_redirect_rtlist
,
17123 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17124 ECOMMUNITY_ROUTE_TARGET
);
17126 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17127 != ECOMMUNITY_SIZE
)
17128 vty_out(vty
, "%*srt6 redirect import %s\n",
17131 vty_out(vty
, "%*srt redirect import %s\n",
17133 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17137 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17138 afi_t afi
, safi_t safi
)
17140 struct bgp_filter
*filter
;
17144 filter
= &peer
->filter
[afi
][safi
];
17146 /* distribute-list. */
17147 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17149 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17150 filter
->dlist
[FILTER_IN
].name
);
17152 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17154 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17155 filter
->dlist
[FILTER_OUT
].name
);
17158 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17160 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17161 filter
->plist
[FILTER_IN
].name
);
17163 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17165 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17166 filter
->plist
[FILTER_OUT
].name
);
17169 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17170 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17171 filter
->map
[RMAP_IN
].name
);
17173 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17175 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17176 filter
->map
[RMAP_OUT
].name
);
17178 /* unsuppress-map */
17179 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17180 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17181 filter
->usmap
.name
);
17183 /* advertise-map : always applied in OUT direction*/
17184 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17185 CONDITION_NON_EXIST
))
17187 " neighbor %s advertise-map %s non-exist-map %s\n",
17188 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17190 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17192 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17193 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17196 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17198 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17199 filter
->aslist
[FILTER_IN
].name
);
17201 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17203 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17204 filter
->aslist
[FILTER_OUT
].name
);
17207 /* BGP peer configuration display function. */
17208 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17211 struct peer
*g_peer
= NULL
;
17212 char buf
[SU_ADDRSTRLEN
];
17214 int if_pg_printed
= false;
17215 int if_ras_printed
= false;
17217 /* Skip dynamic neighbors. */
17218 if (peer_dynamic_neighbor(peer
))
17222 addr
= peer
->conf_if
;
17226 /************************************
17227 ****** Global to the neighbor ******
17228 ************************************/
17229 if (peer
->conf_if
) {
17230 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17231 vty_out(vty
, " neighbor %s interface v6only", addr
);
17233 vty_out(vty
, " neighbor %s interface", addr
);
17235 if (peer_group_active(peer
)) {
17236 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17237 if_pg_printed
= true;
17238 } else if (peer
->as_type
== AS_SPECIFIED
) {
17239 vty_out(vty
, " remote-as %u", peer
->as
);
17240 if_ras_printed
= true;
17241 } else if (peer
->as_type
== AS_INTERNAL
) {
17242 vty_out(vty
, " remote-as internal");
17243 if_ras_printed
= true;
17244 } else if (peer
->as_type
== AS_EXTERNAL
) {
17245 vty_out(vty
, " remote-as external");
17246 if_ras_printed
= true;
17249 vty_out(vty
, "\n");
17252 /* remote-as and peer-group */
17253 /* peer is a member of a peer-group */
17254 if (peer_group_active(peer
)) {
17255 g_peer
= peer
->group
->conf
;
17257 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17258 if (peer
->as_type
== AS_SPECIFIED
) {
17259 vty_out(vty
, " neighbor %s remote-as %u\n",
17261 } else if (peer
->as_type
== AS_INTERNAL
) {
17263 " neighbor %s remote-as internal\n",
17265 } else if (peer
->as_type
== AS_EXTERNAL
) {
17267 " neighbor %s remote-as external\n",
17272 /* For swpX peers we displayed the peer-group
17273 * via 'neighbor swpX interface peer-group PGNAME' */
17274 if (!if_pg_printed
)
17275 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17276 peer
->group
->name
);
17279 /* peer is NOT a member of a peer-group */
17281 /* peer is a peer-group, declare the peer-group */
17282 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17283 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17286 if (!if_ras_printed
) {
17287 if (peer
->as_type
== AS_SPECIFIED
) {
17288 vty_out(vty
, " neighbor %s remote-as %u\n",
17290 } else if (peer
->as_type
== AS_INTERNAL
) {
17292 " neighbor %s remote-as internal\n",
17294 } else if (peer
->as_type
== AS_EXTERNAL
) {
17296 " neighbor %s remote-as external\n",
17303 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17304 vty_out(vty
, " neighbor %s local-as %u", addr
,
17305 peer
->change_local_as
);
17306 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17307 vty_out(vty
, " no-prepend");
17308 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17309 vty_out(vty
, " replace-as");
17310 vty_out(vty
, "\n");
17315 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17319 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17320 if (peer
->tx_shutdown_message
)
17321 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17322 peer
->tx_shutdown_message
);
17324 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17327 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17328 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17329 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17332 if (peer
->bfd_config
)
17333 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17336 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17337 vty_out(vty
, " neighbor %s password %s\n", addr
,
17340 /* neighbor solo */
17341 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17342 if (!peer_group_active(peer
)) {
17343 vty_out(vty
, " neighbor %s solo\n", addr
);
17348 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17349 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17352 /* Local interface name */
17353 if (peer
->ifname
) {
17354 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17357 /* TCP max segment size */
17358 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17359 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17362 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17363 vty_out(vty
, " neighbor %s passive\n", addr
);
17365 /* ebgp-multihop */
17366 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17367 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17368 && peer
->ttl
== MAXTTL
)) {
17369 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17370 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17375 /* ttl-security hops */
17376 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17377 if (!peer_group_active(peer
)
17378 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17379 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17380 addr
, peer
->gtsm_hops
);
17384 /* disable-connected-check */
17385 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17386 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17388 /* enforce-first-as */
17389 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17390 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17392 /* update-source */
17393 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17394 if (peer
->update_source
)
17395 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17396 sockunion2str(peer
->update_source
, buf
,
17398 else if (peer
->update_if
)
17399 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17403 /* advertisement-interval */
17404 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17405 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17409 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17410 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17411 peer
->keepalive
, peer
->holdtime
);
17413 /* timers connect */
17414 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17415 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17417 /* need special-case handling for changed default values due to
17418 * config profile / version (because there is no "timers bgp connect"
17419 * command, we need to save this per-peer :/)
17421 else if (!peer_group_active(peer
) && !peer
->connect
&&
17422 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17423 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17424 peer
->bgp
->default_connect_retry
);
17426 /* timers delayopen */
17427 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17428 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17430 /* Save config even though flag is not set if default values have been
17433 else if (!peer_group_active(peer
) && !peer
->delayopen
17434 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17435 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17436 peer
->bgp
->default_delayopen
);
17438 /* capability dynamic */
17439 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17440 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17442 /* capability extended-nexthop */
17443 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17444 if (!peer
->conf_if
) {
17445 if (CHECK_FLAG(peer
->flags_invert
,
17446 PEER_FLAG_CAPABILITY_ENHE
))
17448 " no neighbor %s capability extended-nexthop\n",
17452 " neighbor %s capability extended-nexthop\n",
17457 /* dont-capability-negotiation */
17458 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17459 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17461 /* override-capability */
17462 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17463 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17465 /* strict-capability-match */
17466 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17467 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17469 /* Sender side AS path loop detection. */
17470 if (peer
->as_path_loop_detection
)
17471 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17474 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17475 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17477 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17478 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17480 " neighbor %s graceful-restart-helper\n", addr
);
17481 } else if (CHECK_FLAG(
17482 peer
->peer_gr_new_status_flag
,
17483 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17485 " neighbor %s graceful-restart\n", addr
);
17487 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17488 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17490 peer
->peer_gr_new_status_flag
,
17491 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17492 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17498 /* BGP peer configuration display function. */
17499 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17500 struct peer
*peer
, afi_t afi
, safi_t safi
)
17502 struct peer
*g_peer
= NULL
;
17504 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17506 /* Skip dynamic neighbors. */
17507 if (peer_dynamic_neighbor(peer
))
17511 addr
= peer
->conf_if
;
17515 /************************************
17516 ****** Per AF to the neighbor ******
17517 ************************************/
17518 if (peer_group_active(peer
)) {
17519 g_peer
= peer
->group
->conf
;
17521 /* If the peer-group is active but peer is not, print a 'no
17523 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17524 vty_out(vty
, " no neighbor %s activate\n", addr
);
17527 /* If the peer-group is not active but peer is, print an
17529 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17530 vty_out(vty
, " neighbor %s activate\n", addr
);
17533 if (peer
->afc
[afi
][safi
]) {
17534 if (safi
== SAFI_ENCAP
)
17535 vty_out(vty
, " neighbor %s activate\n", addr
);
17536 else if (!bgp
->default_af
[afi
][safi
])
17537 vty_out(vty
, " neighbor %s activate\n", addr
);
17539 if (bgp
->default_af
[afi
][safi
])
17540 vty_out(vty
, " no neighbor %s activate\n",
17545 /* addpath TX knobs */
17546 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17547 switch (peer
->addpath_type
[afi
][safi
]) {
17548 case BGP_ADDPATH_ALL
:
17549 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17552 case BGP_ADDPATH_BEST_PER_AS
:
17554 " neighbor %s addpath-tx-bestpath-per-AS\n",
17557 case BGP_ADDPATH_MAX
:
17558 case BGP_ADDPATH_NONE
:
17563 /* ORF capability. */
17564 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17565 || peergroup_af_flag_check(peer
, afi
, safi
,
17566 PEER_FLAG_ORF_PREFIX_RM
)) {
17567 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17569 if (peergroup_af_flag_check(peer
, afi
, safi
,
17570 PEER_FLAG_ORF_PREFIX_SM
)
17571 && peergroup_af_flag_check(peer
, afi
, safi
,
17572 PEER_FLAG_ORF_PREFIX_RM
))
17573 vty_out(vty
, " both");
17574 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17575 PEER_FLAG_ORF_PREFIX_SM
))
17576 vty_out(vty
, " send");
17578 vty_out(vty
, " receive");
17579 vty_out(vty
, "\n");
17582 /* Route reflector client. */
17583 if (peergroup_af_flag_check(peer
, afi
, safi
,
17584 PEER_FLAG_REFLECTOR_CLIENT
)) {
17585 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17588 /* next-hop-self force */
17589 if (peergroup_af_flag_check(peer
, afi
, safi
,
17590 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17591 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17594 /* next-hop-self */
17595 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17596 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17599 /* remove-private-AS */
17600 if (peergroup_af_flag_check(peer
, afi
, safi
,
17601 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17602 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17606 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17607 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17608 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17612 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17613 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17614 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17617 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17618 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17619 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17623 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17624 vty_out(vty
, " neighbor %s as-override\n", addr
);
17627 /* send-community print. */
17628 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17629 PEER_FLAG_SEND_COMMUNITY
);
17630 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17631 PEER_FLAG_SEND_EXT_COMMUNITY
);
17632 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17633 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17635 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17636 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17639 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17642 " no neighbor %s send-community extended\n",
17646 vty_out(vty
, " no neighbor %s send-community large\n",
17650 /* Default information */
17651 if (peergroup_af_flag_check(peer
, afi
, safi
,
17652 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17653 vty_out(vty
, " neighbor %s default-originate", addr
);
17655 if (peer
->default_rmap
[afi
][safi
].name
)
17656 vty_out(vty
, " route-map %s",
17657 peer
->default_rmap
[afi
][safi
].name
);
17659 vty_out(vty
, "\n");
17662 /* Soft reconfiguration inbound. */
17663 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17664 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17668 /* maximum-prefix. */
17669 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17670 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17671 peer
->pmax
[afi
][safi
]);
17673 if (peer
->pmax_threshold
[afi
][safi
]
17674 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17675 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17676 if (peer_af_flag_check(peer
, afi
, safi
,
17677 PEER_FLAG_MAX_PREFIX_WARNING
))
17678 vty_out(vty
, " warning-only");
17679 if (peer
->pmax_restart
[afi
][safi
])
17680 vty_out(vty
, " restart %u",
17681 peer
->pmax_restart
[afi
][safi
]);
17682 if (peer_af_flag_check(peer
, afi
, safi
,
17683 PEER_FLAG_MAX_PREFIX_FORCE
))
17684 vty_out(vty
, " force");
17686 vty_out(vty
, "\n");
17689 /* maximum-prefix-out */
17690 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17691 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17692 addr
, peer
->pmax_out
[afi
][safi
]);
17694 /* Route server client. */
17695 if (peergroup_af_flag_check(peer
, afi
, safi
,
17696 PEER_FLAG_RSERVER_CLIENT
)) {
17697 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17700 /* Nexthop-local unchanged. */
17701 if (peergroup_af_flag_check(peer
, afi
, safi
,
17702 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17703 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17706 /* allowas-in <1-10> */
17707 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17708 if (peer_af_flag_check(peer
, afi
, safi
,
17709 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17710 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17711 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17712 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17714 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17715 peer
->allowas_in
[afi
][safi
]);
17720 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17721 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17722 peer
->weight
[afi
][safi
]);
17725 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17727 /* atribute-unchanged. */
17728 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17729 || (safi
!= SAFI_EVPN
17730 && peer_af_flag_check(peer
, afi
, safi
,
17731 PEER_FLAG_NEXTHOP_UNCHANGED
))
17732 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17734 if (!peer_group_active(peer
)
17735 || peergroup_af_flag_check(peer
, afi
, safi
,
17736 PEER_FLAG_AS_PATH_UNCHANGED
)
17737 || peergroup_af_flag_check(peer
, afi
, safi
,
17738 PEER_FLAG_NEXTHOP_UNCHANGED
)
17739 || peergroup_af_flag_check(peer
, afi
, safi
,
17740 PEER_FLAG_MED_UNCHANGED
)) {
17743 " neighbor %s attribute-unchanged%s%s%s\n",
17745 peer_af_flag_check(peer
, afi
, safi
,
17746 PEER_FLAG_AS_PATH_UNCHANGED
)
17749 peer_af_flag_check(peer
, afi
, safi
,
17750 PEER_FLAG_NEXTHOP_UNCHANGED
)
17753 peer_af_flag_check(peer
, afi
, safi
,
17754 PEER_FLAG_MED_UNCHANGED
)
17760 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_CONFIG_DAMPENING
))
17761 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17764 /* Address family based peer configuration display. */
17765 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17769 struct peer_group
*group
;
17770 struct listnode
*node
, *nnode
;
17773 vty_frame(vty
, " !\n address-family ");
17774 if (afi
== AFI_IP
) {
17775 if (safi
== SAFI_UNICAST
)
17776 vty_frame(vty
, "ipv4 unicast");
17777 else if (safi
== SAFI_LABELED_UNICAST
)
17778 vty_frame(vty
, "ipv4 labeled-unicast");
17779 else if (safi
== SAFI_MULTICAST
)
17780 vty_frame(vty
, "ipv4 multicast");
17781 else if (safi
== SAFI_MPLS_VPN
)
17782 vty_frame(vty
, "ipv4 vpn");
17783 else if (safi
== SAFI_ENCAP
)
17784 vty_frame(vty
, "ipv4 encap");
17785 else if (safi
== SAFI_FLOWSPEC
)
17786 vty_frame(vty
, "ipv4 flowspec");
17787 } else if (afi
== AFI_IP6
) {
17788 if (safi
== SAFI_UNICAST
)
17789 vty_frame(vty
, "ipv6 unicast");
17790 else if (safi
== SAFI_LABELED_UNICAST
)
17791 vty_frame(vty
, "ipv6 labeled-unicast");
17792 else if (safi
== SAFI_MULTICAST
)
17793 vty_frame(vty
, "ipv6 multicast");
17794 else if (safi
== SAFI_MPLS_VPN
)
17795 vty_frame(vty
, "ipv6 vpn");
17796 else if (safi
== SAFI_ENCAP
)
17797 vty_frame(vty
, "ipv6 encap");
17798 else if (safi
== SAFI_FLOWSPEC
)
17799 vty_frame(vty
, "ipv6 flowspec");
17800 } else if (afi
== AFI_L2VPN
) {
17801 if (safi
== SAFI_EVPN
)
17802 vty_frame(vty
, "l2vpn evpn");
17804 vty_frame(vty
, "\n");
17806 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17808 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17810 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17812 /* BGP flag dampening. */
17813 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17814 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17816 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17817 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17819 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17820 /* Do not display doppelganger peers */
17821 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17822 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17825 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17826 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17828 if (safi
== SAFI_EVPN
)
17829 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17831 if (safi
== SAFI_FLOWSPEC
)
17832 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17834 if (safi
== SAFI_UNICAST
) {
17835 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17836 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17837 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17839 vty_out(vty
, " export vpn\n");
17841 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17842 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17844 vty_out(vty
, " import vpn\n");
17846 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17847 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17850 for (ALL_LIST_ELEMENTS_RO(
17851 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17853 vty_out(vty
, " import vrf %s\n", name
);
17857 vty_endframe(vty
, " exit-address-family\n");
17860 int bgp_config_write(struct vty
*vty
)
17863 struct peer_group
*group
;
17865 struct listnode
*node
, *nnode
;
17866 struct listnode
*mnode
, *mnnode
;
17870 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17871 vty_out(vty
, "bgp route-map delay-timer %u\n",
17872 bm
->rmap_update_timer
);
17874 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17875 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17876 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17877 vty_out(vty
, " %d", bm
->v_establish_wait
);
17878 vty_out(vty
, "\n");
17881 if (bm
->wait_for_fib
)
17882 vty_out(vty
, "bgp suppress-fib-pending\n");
17884 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17885 vty_out(vty
, "bgp graceful-shutdown\n");
17887 /* No-RIB (Zebra) option flag configuration */
17888 if (bgp_option_check(BGP_OPT_NO_FIB
))
17889 vty_out(vty
, "bgp no-rib\n");
17891 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17892 vty_out(vty
, "no bgp send-extra-data zebra\n");
17894 /* BGP configuration. */
17895 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17897 /* skip all auto created vrf as they dont have user config */
17898 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17901 /* Router bgp ASN */
17902 vty_out(vty
, "router bgp %u", bgp
->as
);
17905 vty_out(vty
, " %s %s",
17906 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17907 ? "view" : "vrf", bgp
->name
);
17908 vty_out(vty
, "\n");
17910 /* BGP fast-external-failover. */
17911 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17912 vty_out(vty
, " no bgp fast-external-failover\n");
17914 /* BGP router ID. */
17915 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17916 vty_out(vty
, " bgp router-id %pI4\n",
17917 &bgp
->router_id_static
);
17919 /* Suppress fib pending */
17920 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17921 vty_out(vty
, " bgp suppress-fib-pending\n");
17923 /* BGP log-neighbor-changes. */
17924 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17925 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17926 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17927 CHECK_FLAG(bgp
->flags
,
17928 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17932 /* BGP configuration. */
17933 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17934 vty_out(vty
, " bgp always-compare-med\n");
17936 /* RFC8212 default eBGP policy. */
17937 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17938 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17939 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17940 CHECK_FLAG(bgp
->flags
,
17941 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17945 /* draft-ietf-idr-deprecate-as-set-confed-set */
17946 if (bgp
->reject_as_sets
)
17947 vty_out(vty
, " bgp reject-as-sets\n");
17949 /* Suppress duplicate updates if the route actually not changed
17951 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17952 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17953 vty_out(vty
, " %sbgp suppress-duplicates\n",
17954 CHECK_FLAG(bgp
->flags
,
17955 BGP_FLAG_SUPPRESS_DUPLICATES
)
17959 /* BGP default <afi>-<safi> */
17960 FOREACH_AFI_SAFI (afi
, safi
) {
17961 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17962 if (!bgp
->default_af
[afi
][safi
])
17963 vty_out(vty
, " no bgp default %s\n",
17964 get_bgp_default_af_flag(afi
,
17966 } else if (bgp
->default_af
[afi
][safi
])
17967 vty_out(vty
, " bgp default %s\n",
17968 get_bgp_default_af_flag(afi
, safi
));
17971 /* BGP default local-preference. */
17972 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17973 vty_out(vty
, " bgp default local-preference %u\n",
17974 bgp
->default_local_pref
);
17976 /* BGP default show-hostname */
17977 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17978 != SAVE_BGP_SHOW_HOSTNAME
)
17979 vty_out(vty
, " %sbgp default show-hostname\n",
17980 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17984 /* BGP default show-nexthop-hostname */
17985 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17986 != SAVE_BGP_SHOW_HOSTNAME
)
17987 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17988 CHECK_FLAG(bgp
->flags
,
17989 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17993 /* BGP default subgroup-pkt-queue-max. */
17994 if (bgp
->default_subgroup_pkt_queue_max
17995 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17996 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17997 bgp
->default_subgroup_pkt_queue_max
);
17999 /* BGP client-to-client reflection. */
18000 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18001 vty_out(vty
, " no bgp client-to-client reflection\n");
18003 /* BGP cluster ID. */
18004 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18005 vty_out(vty
, " bgp cluster-id %pI4\n",
18008 /* Disable ebgp connected nexthop check */
18009 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18011 " bgp disable-ebgp-connected-route-check\n");
18013 /* Confederation identifier*/
18014 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18015 vty_out(vty
, " bgp confederation identifier %u\n",
18018 /* Confederation peer */
18019 if (bgp
->confed_peers_cnt
> 0) {
18022 vty_out(vty
, " bgp confederation peers");
18024 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18025 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18027 vty_out(vty
, "\n");
18030 /* BGP deterministic-med. */
18031 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18032 != SAVE_BGP_DETERMINISTIC_MED
)
18033 vty_out(vty
, " %sbgp deterministic-med\n",
18034 CHECK_FLAG(bgp
->flags
,
18035 BGP_FLAG_DETERMINISTIC_MED
)
18039 /* BGP update-delay. */
18040 bgp_config_write_update_delay(vty
, bgp
);
18042 if (bgp
->v_maxmed_onstartup
18043 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18044 vty_out(vty
, " bgp max-med on-startup %u",
18045 bgp
->v_maxmed_onstartup
);
18046 if (bgp
->maxmed_onstartup_value
18047 != BGP_MAXMED_VALUE_DEFAULT
)
18048 vty_out(vty
, " %u",
18049 bgp
->maxmed_onstartup_value
);
18050 vty_out(vty
, "\n");
18052 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18053 vty_out(vty
, " bgp max-med administrative");
18054 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18055 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18056 vty_out(vty
, "\n");
18060 bgp_config_write_wpkt_quanta(vty
, bgp
);
18062 bgp_config_write_rpkt_quanta(vty
, bgp
);
18064 /* coalesce time */
18065 bgp_config_write_coalesce_time(vty
, bgp
);
18067 /* BGP per-instance graceful-shutdown */
18068 /* BGP-wide settings and per-instance settings are mutually
18071 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18072 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18073 vty_out(vty
, " bgp graceful-shutdown\n");
18075 /* BGP graceful-restart. */
18076 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18078 " bgp graceful-restart stalepath-time %u\n",
18079 bgp
->stalepath_time
);
18081 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18082 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18083 bgp
->restart_time
);
18085 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18087 " bgp graceful-restart select-defer-time %u\n",
18088 bgp
->select_defer_time
);
18090 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18091 vty_out(vty
, " bgp graceful-restart\n");
18093 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18094 vty_out(vty
, " bgp graceful-restart-disable\n");
18096 /* BGP graceful-restart Preserve State F bit. */
18097 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18099 " bgp graceful-restart preserve-fw-state\n");
18101 /* Stale timer for RIB */
18102 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18104 " bgp graceful-restart rib-stale-time %u\n",
18105 bgp
->rib_stale_time
);
18107 /* BGP bestpath method. */
18108 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18109 vty_out(vty
, " bgp bestpath as-path ignore\n");
18110 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18111 vty_out(vty
, " bgp bestpath as-path confed\n");
18113 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18114 if (CHECK_FLAG(bgp
->flags
,
18115 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18117 " bgp bestpath as-path multipath-relax as-set\n");
18120 " bgp bestpath as-path multipath-relax\n");
18124 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18126 " bgp route-reflector allow-outbound-policy\n");
18128 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18129 vty_out(vty
, " bgp bestpath compare-routerid\n");
18130 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18131 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18132 vty_out(vty
, " bgp bestpath med");
18133 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18134 vty_out(vty
, " confed");
18135 if (CHECK_FLAG(bgp
->flags
,
18136 BGP_FLAG_MED_MISSING_AS_WORST
))
18137 vty_out(vty
, " missing-as-worst");
18138 vty_out(vty
, "\n");
18141 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18143 " bgp bestpath peer-type multipath-relax\n");
18145 /* Link bandwidth handling. */
18146 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18147 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18148 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18149 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18150 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18151 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18153 /* BGP network import check. */
18154 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18155 != SAVE_BGP_IMPORT_CHECK
)
18156 vty_out(vty
, " %sbgp network import-check\n",
18157 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18161 /* BGP timers configuration. */
18162 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18163 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18164 vty_out(vty
, " timers bgp %u %u\n",
18165 bgp
->default_keepalive
, bgp
->default_holdtime
);
18167 /* Conditional advertisement timer configuration */
18168 if (bgp
->condition_check_period
18169 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18171 " bgp conditional-advertisement timer %u\n",
18172 bgp
->condition_check_period
);
18175 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18176 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18179 /* Normal neighbor configuration. */
18180 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18181 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18182 bgp_config_write_peer_global(vty
, bgp
, peer
);
18185 /* listen range and limit for dynamic BGP neighbors */
18186 bgp_config_write_listen(vty
, bgp
);
18189 * BGP default autoshutdown neighbors
18191 * This must be placed after any peer and peer-group
18192 * configuration, to avoid setting all peers to shutdown after
18193 * a daemon restart, which is undesired behavior. (see #2286)
18195 if (bgp
->autoshutdown
)
18196 vty_out(vty
, " bgp default shutdown\n");
18198 /* BGP instance administrative shutdown */
18199 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18200 vty_out(vty
, " bgp shutdown\n");
18202 if (bgp
->srv6_enabled
) {
18203 vty_frame(vty
, " !\n segment-routing srv6\n");
18204 if (strlen(bgp
->srv6_locator_name
))
18205 vty_out(vty
, " locator %s\n",
18206 bgp
->srv6_locator_name
);
18210 /* IPv4 unicast configuration. */
18211 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18213 /* IPv4 multicast configuration. */
18214 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18216 /* IPv4 labeled-unicast configuration. */
18217 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18219 /* IPv4 VPN configuration. */
18220 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18222 /* ENCAPv4 configuration. */
18223 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18225 /* FLOWSPEC v4 configuration. */
18226 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18228 /* IPv6 unicast configuration. */
18229 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18231 /* IPv6 multicast configuration. */
18232 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18234 /* IPv6 labeled-unicast configuration. */
18235 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18236 SAFI_LABELED_UNICAST
);
18238 /* IPv6 VPN configuration. */
18239 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18241 /* ENCAPv6 configuration. */
18242 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18244 /* FLOWSPEC v6 configuration. */
18245 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18247 /* EVPN configuration. */
18248 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18250 hook_call(bgp_inst_config_write
, bgp
, vty
);
18252 #ifdef ENABLE_BGP_VNC
18253 bgp_rfapi_cfg_write(vty
, bgp
);
18256 vty_out(vty
, "!\n");
18262 /* BGP node structure. */
18263 static struct cmd_node bgp_node
= {
18266 .parent_node
= CONFIG_NODE
,
18267 .prompt
= "%s(config-router)# ",
18268 .config_write
= bgp_config_write
,
18271 static struct cmd_node bgp_ipv4_unicast_node
= {
18272 .name
= "bgp ipv4 unicast",
18273 .node
= BGP_IPV4_NODE
,
18274 .parent_node
= BGP_NODE
,
18275 .prompt
= "%s(config-router-af)# ",
18278 static struct cmd_node bgp_ipv4_multicast_node
= {
18279 .name
= "bgp ipv4 multicast",
18280 .node
= BGP_IPV4M_NODE
,
18281 .parent_node
= BGP_NODE
,
18282 .prompt
= "%s(config-router-af)# ",
18285 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18286 .name
= "bgp ipv4 labeled unicast",
18287 .node
= BGP_IPV4L_NODE
,
18288 .parent_node
= BGP_NODE
,
18289 .prompt
= "%s(config-router-af)# ",
18292 static struct cmd_node bgp_ipv6_unicast_node
= {
18293 .name
= "bgp ipv6 unicast",
18294 .node
= BGP_IPV6_NODE
,
18295 .parent_node
= BGP_NODE
,
18296 .prompt
= "%s(config-router-af)# ",
18299 static struct cmd_node bgp_ipv6_multicast_node
= {
18300 .name
= "bgp ipv6 multicast",
18301 .node
= BGP_IPV6M_NODE
,
18302 .parent_node
= BGP_NODE
,
18303 .prompt
= "%s(config-router-af)# ",
18306 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18307 .name
= "bgp ipv6 labeled unicast",
18308 .node
= BGP_IPV6L_NODE
,
18309 .parent_node
= BGP_NODE
,
18310 .prompt
= "%s(config-router-af)# ",
18313 static struct cmd_node bgp_vpnv4_node
= {
18314 .name
= "bgp vpnv4",
18315 .node
= BGP_VPNV4_NODE
,
18316 .parent_node
= BGP_NODE
,
18317 .prompt
= "%s(config-router-af)# ",
18320 static struct cmd_node bgp_vpnv6_node
= {
18321 .name
= "bgp vpnv6",
18322 .node
= BGP_VPNV6_NODE
,
18323 .parent_node
= BGP_NODE
,
18324 .prompt
= "%s(config-router-af-vpnv6)# ",
18327 static struct cmd_node bgp_evpn_node
= {
18328 .name
= "bgp evpn",
18329 .node
= BGP_EVPN_NODE
,
18330 .parent_node
= BGP_NODE
,
18331 .prompt
= "%s(config-router-evpn)# ",
18334 static struct cmd_node bgp_evpn_vni_node
= {
18335 .name
= "bgp evpn vni",
18336 .node
= BGP_EVPN_VNI_NODE
,
18337 .parent_node
= BGP_EVPN_NODE
,
18338 .prompt
= "%s(config-router-af-vni)# ",
18341 static struct cmd_node bgp_flowspecv4_node
= {
18342 .name
= "bgp ipv4 flowspec",
18343 .node
= BGP_FLOWSPECV4_NODE
,
18344 .parent_node
= BGP_NODE
,
18345 .prompt
= "%s(config-router-af)# ",
18348 static struct cmd_node bgp_flowspecv6_node
= {
18349 .name
= "bgp ipv6 flowspec",
18350 .node
= BGP_FLOWSPECV6_NODE
,
18351 .parent_node
= BGP_NODE
,
18352 .prompt
= "%s(config-router-af-vpnv6)# ",
18355 static struct cmd_node bgp_srv6_node
= {
18356 .name
= "bgp srv6",
18357 .node
= BGP_SRV6_NODE
,
18358 .parent_node
= BGP_NODE
,
18359 .prompt
= "%s(config-router-srv6)# ",
18362 static void community_list_vty(void);
18364 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18368 struct listnode
*lnbgp
, *lnpeer
;
18370 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18371 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18372 /* only provide suggestions on the appropriate input
18374 * they'll otherwise show up multiple times */
18375 enum cmd_token_type match_type
;
18376 char *name
= peer
->host
;
18378 if (peer
->conf_if
) {
18379 match_type
= VARIABLE_TKN
;
18380 name
= peer
->conf_if
;
18381 } else if (strchr(peer
->host
, ':'))
18382 match_type
= IPV6_TKN
;
18384 match_type
= IPV4_TKN
;
18386 if (token
->type
!= match_type
)
18389 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18394 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18395 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18396 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18397 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18398 {.completions
= NULL
}};
18400 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18403 struct peer_group
*group
;
18404 struct listnode
*lnbgp
, *lnpeer
;
18406 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18407 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18408 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
18413 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18414 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18415 {.completions
= NULL
} };
18417 void bgp_vty_init(void)
18419 cmd_variable_handler_register(bgp_var_neighbor
);
18420 cmd_variable_handler_register(bgp_var_peergroup
);
18422 /* Install bgp top node. */
18423 install_node(&bgp_node
);
18424 install_node(&bgp_ipv4_unicast_node
);
18425 install_node(&bgp_ipv4_multicast_node
);
18426 install_node(&bgp_ipv4_labeled_unicast_node
);
18427 install_node(&bgp_ipv6_unicast_node
);
18428 install_node(&bgp_ipv6_multicast_node
);
18429 install_node(&bgp_ipv6_labeled_unicast_node
);
18430 install_node(&bgp_vpnv4_node
);
18431 install_node(&bgp_vpnv6_node
);
18432 install_node(&bgp_evpn_node
);
18433 install_node(&bgp_evpn_vni_node
);
18434 install_node(&bgp_flowspecv4_node
);
18435 install_node(&bgp_flowspecv6_node
);
18436 install_node(&bgp_srv6_node
);
18438 /* Install default VTY commands to new nodes. */
18439 install_default(BGP_NODE
);
18440 install_default(BGP_IPV4_NODE
);
18441 install_default(BGP_IPV4M_NODE
);
18442 install_default(BGP_IPV4L_NODE
);
18443 install_default(BGP_IPV6_NODE
);
18444 install_default(BGP_IPV6M_NODE
);
18445 install_default(BGP_IPV6L_NODE
);
18446 install_default(BGP_VPNV4_NODE
);
18447 install_default(BGP_VPNV6_NODE
);
18448 install_default(BGP_FLOWSPECV4_NODE
);
18449 install_default(BGP_FLOWSPECV6_NODE
);
18450 install_default(BGP_EVPN_NODE
);
18451 install_default(BGP_EVPN_VNI_NODE
);
18452 install_default(BGP_SRV6_NODE
);
18454 /* "bgp local-mac" hidden commands. */
18455 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18456 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18458 /* "bgp suppress-fib-pending" global */
18459 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18461 /* bgp route-map delay-timer commands. */
18462 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18463 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18465 /* global bgp update-delay command */
18466 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18467 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18469 /* global bgp graceful-shutdown command */
18470 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18471 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18473 /* Dummy commands (Currently not supported) */
18474 install_element(BGP_NODE
, &no_synchronization_cmd
);
18475 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18477 /* "router bgp" commands. */
18478 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18480 /* "no router bgp" commands. */
18481 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18483 /* "bgp router-id" commands. */
18484 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18485 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18487 /* "bgp suppress-fib-pending" command */
18488 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18490 /* "bgp cluster-id" commands. */
18491 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18492 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18494 /* "bgp no-rib" commands. */
18495 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18496 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18498 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18500 /* "bgp confederation" commands. */
18501 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18502 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18504 /* "bgp confederation peers" commands. */
18505 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18506 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18508 /* bgp max-med command */
18509 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18510 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18511 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18512 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18513 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18515 /* bgp disable-ebgp-connected-nh-check */
18516 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18519 /* bgp update-delay command */
18520 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18521 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18523 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18524 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18526 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18527 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18529 /* "maximum-paths" commands. */
18530 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18531 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18532 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18533 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18534 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18535 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18536 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18537 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18538 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18539 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18540 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18541 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18542 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18543 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18544 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18546 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18547 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18548 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18549 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18550 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18551 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18552 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18553 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18554 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18555 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18557 /* "timers bgp" commands. */
18558 install_element(BGP_NODE
, &bgp_timers_cmd
);
18559 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18561 /* route-map delay-timer commands - per instance for backwards compat.
18563 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18564 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18566 /* "bgp client-to-client reflection" commands */
18567 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18568 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18570 /* "bgp always-compare-med" commands */
18571 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18572 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18574 /* bgp ebgp-requires-policy */
18575 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18576 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18578 /* bgp suppress-duplicates */
18579 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18580 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18582 /* bgp reject-as-sets */
18583 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18584 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18586 /* "bgp deterministic-med" commands */
18587 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18588 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18590 /* "bgp graceful-restart" command */
18591 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18592 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18594 /* "bgp graceful-restart-disable" command */
18595 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18596 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18598 /* "neighbor a:b:c:d graceful-restart" command */
18599 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18600 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18602 /* "neighbor a:b:c:d graceful-restart-disable" command */
18603 install_element(BGP_NODE
,
18604 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18605 install_element(BGP_NODE
,
18606 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18608 /* "neighbor a:b:c:d graceful-restart-helper" command */
18609 install_element(BGP_NODE
,
18610 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18611 install_element(BGP_NODE
,
18612 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18614 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18615 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18616 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18617 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18618 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18619 install_element(BGP_NODE
,
18620 &no_bgp_graceful_restart_select_defer_time_cmd
);
18621 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18622 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18624 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18625 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18626 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18627 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18629 /* "bgp graceful-shutdown" commands */
18630 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18631 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18633 /* "bgp fast-external-failover" commands */
18634 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18635 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18637 /* "bgp bestpath compare-routerid" commands */
18638 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18639 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18641 /* "bgp bestpath as-path ignore" commands */
18642 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18643 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18645 /* "bgp bestpath as-path confed" commands */
18646 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18647 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18649 /* "bgp bestpath as-path multipath-relax" commands */
18650 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18651 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18653 /* "bgp bestpath peer-type multipath-relax" commands */
18654 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18655 install_element(BGP_NODE
,
18656 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18658 /* "bgp log-neighbor-changes" commands */
18659 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18660 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18662 /* "bgp bestpath med" commands */
18663 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18664 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18666 /* "bgp bestpath bandwidth" commands */
18667 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18668 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18670 /* "no bgp default <afi>-<safi>" commands. */
18671 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18673 /* "bgp network import-check" commands. */
18674 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18675 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18676 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18678 /* "bgp default local-preference" commands. */
18679 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18680 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18682 /* bgp default show-hostname */
18683 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18684 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18686 /* bgp default show-nexthop-hostname */
18687 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18688 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18690 /* "bgp default subgroup-pkt-queue-max" commands. */
18691 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18692 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18694 /* bgp ibgp-allow-policy-mods command */
18695 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18696 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18698 /* "bgp listen limit" commands. */
18699 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18700 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18702 /* "bgp listen range" commands. */
18703 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18704 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18706 /* "bgp default shutdown" command */
18707 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18709 /* "bgp shutdown" commands */
18710 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18711 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18712 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18713 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18715 /* "neighbor remote-as" commands. */
18716 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18717 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18718 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18719 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18720 install_element(BGP_NODE
,
18721 &neighbor_interface_v6only_config_remote_as_cmd
);
18722 install_element(BGP_NODE
, &no_neighbor_cmd
);
18723 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18725 /* "neighbor peer-group" commands. */
18726 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18727 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18728 install_element(BGP_NODE
,
18729 &no_neighbor_interface_peer_group_remote_as_cmd
);
18731 /* "neighbor local-as" commands. */
18732 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18733 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18734 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18735 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18737 /* "neighbor solo" commands. */
18738 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18739 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18741 /* "neighbor password" commands. */
18742 install_element(BGP_NODE
, &neighbor_password_cmd
);
18743 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18745 /* "neighbor activate" commands. */
18746 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18747 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18748 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18749 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18750 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18751 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18752 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18753 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18754 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18755 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18756 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18757 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18759 /* "no neighbor activate" commands. */
18760 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18761 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18762 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18763 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18764 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18765 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18766 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18767 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18768 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18769 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18770 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18771 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18773 /* "neighbor peer-group" set commands. */
18774 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18775 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18776 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18777 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18778 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18779 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18780 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18781 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18782 install_element(BGP_FLOWSPECV4_NODE
,
18783 &neighbor_set_peer_group_hidden_cmd
);
18784 install_element(BGP_FLOWSPECV6_NODE
,
18785 &neighbor_set_peer_group_hidden_cmd
);
18787 /* "no neighbor peer-group unset" commands. */
18788 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18789 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18790 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18791 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18792 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18793 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18794 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18795 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18796 install_element(BGP_FLOWSPECV4_NODE
,
18797 &no_neighbor_set_peer_group_hidden_cmd
);
18798 install_element(BGP_FLOWSPECV6_NODE
,
18799 &no_neighbor_set_peer_group_hidden_cmd
);
18801 /* "neighbor softreconfiguration inbound" commands.*/
18802 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18803 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18804 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18805 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18806 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18807 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18808 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18809 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18810 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18811 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18812 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18813 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18814 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18815 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18816 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18817 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18818 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18819 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18820 install_element(BGP_FLOWSPECV4_NODE
,
18821 &neighbor_soft_reconfiguration_cmd
);
18822 install_element(BGP_FLOWSPECV4_NODE
,
18823 &no_neighbor_soft_reconfiguration_cmd
);
18824 install_element(BGP_FLOWSPECV6_NODE
,
18825 &neighbor_soft_reconfiguration_cmd
);
18826 install_element(BGP_FLOWSPECV6_NODE
,
18827 &no_neighbor_soft_reconfiguration_cmd
);
18828 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18829 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18831 /* "neighbor attribute-unchanged" commands. */
18832 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18833 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18834 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18835 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18836 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18837 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18838 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18839 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18840 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18841 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18842 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18843 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18844 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18845 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18846 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18847 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18848 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18849 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18851 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18852 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18854 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18855 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18856 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18857 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18859 /* "nexthop-local unchanged" commands */
18860 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18861 install_element(BGP_IPV6_NODE
,
18862 &no_neighbor_nexthop_local_unchanged_cmd
);
18864 /* "neighbor next-hop-self" commands. */
18865 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18866 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18867 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18868 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18869 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18870 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18871 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18872 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18873 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18874 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18875 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18876 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18877 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18878 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18879 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18880 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18881 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18882 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18883 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18884 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18886 /* "neighbor next-hop-self force" commands. */
18887 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18888 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18889 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18890 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18891 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18892 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18893 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18894 install_element(BGP_IPV4_NODE
,
18895 &no_neighbor_nexthop_self_all_hidden_cmd
);
18896 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18897 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18898 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18899 install_element(BGP_IPV4M_NODE
,
18900 &no_neighbor_nexthop_self_all_hidden_cmd
);
18901 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18902 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18903 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18904 install_element(BGP_IPV4L_NODE
,
18905 &no_neighbor_nexthop_self_all_hidden_cmd
);
18906 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18907 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18908 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18909 install_element(BGP_IPV6_NODE
,
18910 &no_neighbor_nexthop_self_all_hidden_cmd
);
18911 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18912 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18913 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18914 install_element(BGP_IPV6M_NODE
,
18915 &no_neighbor_nexthop_self_all_hidden_cmd
);
18916 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18917 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18918 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18919 install_element(BGP_IPV6L_NODE
,
18920 &no_neighbor_nexthop_self_all_hidden_cmd
);
18921 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18922 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18923 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18924 install_element(BGP_VPNV4_NODE
,
18925 &no_neighbor_nexthop_self_all_hidden_cmd
);
18926 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18927 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18928 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18929 install_element(BGP_VPNV6_NODE
,
18930 &no_neighbor_nexthop_self_all_hidden_cmd
);
18931 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18932 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18934 /* "neighbor as-override" commands. */
18935 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18936 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18937 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18938 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18939 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18940 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18941 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18942 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18943 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18944 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18945 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18946 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18947 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18948 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18949 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18950 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18951 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18952 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18954 /* "neighbor remove-private-AS" commands. */
18955 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18956 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18957 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18958 install_element(BGP_NODE
,
18959 &no_neighbor_remove_private_as_all_hidden_cmd
);
18960 install_element(BGP_NODE
,
18961 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18962 install_element(BGP_NODE
,
18963 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18964 install_element(BGP_NODE
,
18965 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18968 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18969 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18970 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18971 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18972 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18973 install_element(BGP_IPV4_NODE
,
18974 &neighbor_remove_private_as_replace_as_cmd
);
18975 install_element(BGP_IPV4_NODE
,
18976 &no_neighbor_remove_private_as_replace_as_cmd
);
18977 install_element(BGP_IPV4_NODE
,
18978 &neighbor_remove_private_as_all_replace_as_cmd
);
18979 install_element(BGP_IPV4_NODE
,
18980 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18981 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18982 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18983 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18984 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18985 install_element(BGP_IPV4M_NODE
,
18986 &neighbor_remove_private_as_replace_as_cmd
);
18987 install_element(BGP_IPV4M_NODE
,
18988 &no_neighbor_remove_private_as_replace_as_cmd
);
18989 install_element(BGP_IPV4M_NODE
,
18990 &neighbor_remove_private_as_all_replace_as_cmd
);
18991 install_element(BGP_IPV4M_NODE
,
18992 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18993 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18994 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18995 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18996 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18997 install_element(BGP_IPV4L_NODE
,
18998 &neighbor_remove_private_as_replace_as_cmd
);
18999 install_element(BGP_IPV4L_NODE
,
19000 &no_neighbor_remove_private_as_replace_as_cmd
);
19001 install_element(BGP_IPV4L_NODE
,
19002 &neighbor_remove_private_as_all_replace_as_cmd
);
19003 install_element(BGP_IPV4L_NODE
,
19004 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19005 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19006 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19007 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19008 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19009 install_element(BGP_IPV6_NODE
,
19010 &neighbor_remove_private_as_replace_as_cmd
);
19011 install_element(BGP_IPV6_NODE
,
19012 &no_neighbor_remove_private_as_replace_as_cmd
);
19013 install_element(BGP_IPV6_NODE
,
19014 &neighbor_remove_private_as_all_replace_as_cmd
);
19015 install_element(BGP_IPV6_NODE
,
19016 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19017 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19018 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19019 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19020 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19021 install_element(BGP_IPV6M_NODE
,
19022 &neighbor_remove_private_as_replace_as_cmd
);
19023 install_element(BGP_IPV6M_NODE
,
19024 &no_neighbor_remove_private_as_replace_as_cmd
);
19025 install_element(BGP_IPV6M_NODE
,
19026 &neighbor_remove_private_as_all_replace_as_cmd
);
19027 install_element(BGP_IPV6M_NODE
,
19028 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19029 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19030 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19031 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19032 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19033 install_element(BGP_IPV6L_NODE
,
19034 &neighbor_remove_private_as_replace_as_cmd
);
19035 install_element(BGP_IPV6L_NODE
,
19036 &no_neighbor_remove_private_as_replace_as_cmd
);
19037 install_element(BGP_IPV6L_NODE
,
19038 &neighbor_remove_private_as_all_replace_as_cmd
);
19039 install_element(BGP_IPV6L_NODE
,
19040 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19041 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19042 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19043 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19044 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19045 install_element(BGP_VPNV4_NODE
,
19046 &neighbor_remove_private_as_replace_as_cmd
);
19047 install_element(BGP_VPNV4_NODE
,
19048 &no_neighbor_remove_private_as_replace_as_cmd
);
19049 install_element(BGP_VPNV4_NODE
,
19050 &neighbor_remove_private_as_all_replace_as_cmd
);
19051 install_element(BGP_VPNV4_NODE
,
19052 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19053 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19054 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19055 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19056 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19057 install_element(BGP_VPNV6_NODE
,
19058 &neighbor_remove_private_as_replace_as_cmd
);
19059 install_element(BGP_VPNV6_NODE
,
19060 &no_neighbor_remove_private_as_replace_as_cmd
);
19061 install_element(BGP_VPNV6_NODE
,
19062 &neighbor_remove_private_as_all_replace_as_cmd
);
19063 install_element(BGP_VPNV6_NODE
,
19064 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19066 /* "neighbor send-community" commands.*/
19067 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19068 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19069 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19070 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19071 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19072 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19073 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19074 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19075 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19076 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19077 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19078 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19079 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19080 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19081 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19082 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19083 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19084 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19085 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19086 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19087 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19088 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19089 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19090 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19091 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19092 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19093 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19094 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19095 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19096 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19097 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19098 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19099 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19100 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19101 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19102 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19104 /* "neighbor route-reflector" commands.*/
19105 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19106 install_element(BGP_NODE
,
19107 &no_neighbor_route_reflector_client_hidden_cmd
);
19108 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19109 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19110 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19111 install_element(BGP_IPV4M_NODE
,
19112 &no_neighbor_route_reflector_client_cmd
);
19113 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19114 install_element(BGP_IPV4L_NODE
,
19115 &no_neighbor_route_reflector_client_cmd
);
19116 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19117 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19118 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19119 install_element(BGP_IPV6M_NODE
,
19120 &no_neighbor_route_reflector_client_cmd
);
19121 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19122 install_element(BGP_IPV6L_NODE
,
19123 &no_neighbor_route_reflector_client_cmd
);
19124 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19125 install_element(BGP_VPNV4_NODE
,
19126 &no_neighbor_route_reflector_client_cmd
);
19127 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19128 install_element(BGP_VPNV6_NODE
,
19129 &no_neighbor_route_reflector_client_cmd
);
19130 install_element(BGP_FLOWSPECV4_NODE
,
19131 &neighbor_route_reflector_client_cmd
);
19132 install_element(BGP_FLOWSPECV4_NODE
,
19133 &no_neighbor_route_reflector_client_cmd
);
19134 install_element(BGP_FLOWSPECV6_NODE
,
19135 &neighbor_route_reflector_client_cmd
);
19136 install_element(BGP_FLOWSPECV6_NODE
,
19137 &no_neighbor_route_reflector_client_cmd
);
19138 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19139 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19141 /* "neighbor route-server" commands.*/
19142 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19143 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19144 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19145 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19146 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19147 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19148 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19149 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19150 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19151 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19152 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19153 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19154 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19155 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19156 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19157 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19158 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19159 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19160 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19161 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19162 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19163 install_element(BGP_FLOWSPECV4_NODE
,
19164 &no_neighbor_route_server_client_cmd
);
19165 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19166 install_element(BGP_FLOWSPECV6_NODE
,
19167 &no_neighbor_route_server_client_cmd
);
19169 /* "neighbor addpath-tx-all-paths" commands.*/
19170 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19171 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19172 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19173 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19174 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19175 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19176 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19177 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19178 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19179 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19180 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19181 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19182 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19183 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19184 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19185 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19186 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19187 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19189 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19190 install_element(BGP_NODE
,
19191 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19192 install_element(BGP_NODE
,
19193 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19194 install_element(BGP_IPV4_NODE
,
19195 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19196 install_element(BGP_IPV4_NODE
,
19197 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19198 install_element(BGP_IPV4M_NODE
,
19199 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19200 install_element(BGP_IPV4M_NODE
,
19201 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19202 install_element(BGP_IPV4L_NODE
,
19203 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19204 install_element(BGP_IPV4L_NODE
,
19205 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19206 install_element(BGP_IPV6_NODE
,
19207 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19208 install_element(BGP_IPV6_NODE
,
19209 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19210 install_element(BGP_IPV6M_NODE
,
19211 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19212 install_element(BGP_IPV6M_NODE
,
19213 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19214 install_element(BGP_IPV6L_NODE
,
19215 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19216 install_element(BGP_IPV6L_NODE
,
19217 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19218 install_element(BGP_VPNV4_NODE
,
19219 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19220 install_element(BGP_VPNV4_NODE
,
19221 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19222 install_element(BGP_VPNV6_NODE
,
19223 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19224 install_element(BGP_VPNV6_NODE
,
19225 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19227 /* "neighbor sender-as-path-loop-detection" commands. */
19228 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19229 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19231 /* "neighbor passive" commands. */
19232 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19233 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19236 /* "neighbor shutdown" commands. */
19237 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19238 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19239 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19240 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19241 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19242 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19244 /* "neighbor capability extended-nexthop" commands.*/
19245 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19246 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19248 /* "neighbor capability orf prefix-list" commands.*/
19249 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19250 install_element(BGP_NODE
,
19251 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19252 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19253 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19254 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19255 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19256 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19257 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19258 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19259 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19260 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19261 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19262 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19263 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19265 /* "neighbor capability dynamic" commands.*/
19266 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19267 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19269 /* "neighbor dont-capability-negotiate" commands. */
19270 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19271 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19273 /* "neighbor ebgp-multihop" commands. */
19274 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19275 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19276 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19278 /* "neighbor disable-connected-check" commands. */
19279 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19280 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19282 /* "neighbor enforce-first-as" commands. */
19283 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19284 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19286 /* "neighbor description" commands. */
19287 install_element(BGP_NODE
, &neighbor_description_cmd
);
19288 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19289 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19291 /* "neighbor update-source" commands. "*/
19292 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19293 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19295 /* "neighbor default-originate" commands. */
19296 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19297 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19298 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19299 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19300 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19301 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19302 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19303 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19304 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19305 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19306 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19307 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19308 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19309 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19310 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19311 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19312 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19313 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19314 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19315 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19316 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19318 /* "neighbor port" commands. */
19319 install_element(BGP_NODE
, &neighbor_port_cmd
);
19320 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19322 /* "neighbor weight" commands. */
19323 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19324 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19326 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19327 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19328 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19329 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19330 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19331 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19332 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19333 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19334 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19335 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19336 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19337 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19338 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19339 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19340 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19341 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19343 /* "neighbor override-capability" commands. */
19344 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19345 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19347 /* "neighbor strict-capability-match" commands. */
19348 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19349 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19351 /* "neighbor timers" commands. */
19352 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19353 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19355 /* "neighbor timers connect" commands. */
19356 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19357 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19359 /* "neighbor timers delayopen" commands. */
19360 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19361 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19363 /* "neighbor advertisement-interval" commands. */
19364 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19365 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19367 /* "neighbor interface" commands. */
19368 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19369 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19371 /* "neighbor distribute" commands. */
19372 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19373 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19374 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19375 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19376 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19377 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19378 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19379 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19380 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19381 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19382 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19383 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19384 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19385 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19386 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19387 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19388 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19389 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19391 /* "neighbor prefix-list" commands. */
19392 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19393 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19394 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19395 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19396 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19397 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19398 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19399 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19400 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19401 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19402 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19404 /* "neighbor filter-list" commands. */
19405 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19406 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19407 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19408 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19409 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19410 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19411 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19412 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19413 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19414 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19415 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19416 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19417 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19418 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19419 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19420 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19421 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19422 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19423 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19424 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19425 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19426 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19428 /* "neighbor route-map" commands. */
19429 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19430 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19431 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19432 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19433 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19434 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19435 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19436 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19437 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19438 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19439 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19441 /* "neighbor unsuppress-map" commands. */
19442 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19443 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19444 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19445 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19446 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19447 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19448 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19449 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19450 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19451 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19452 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19453 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19454 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19455 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19456 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19457 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19458 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19459 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19461 /* "neighbor advertise-map" commands. */
19462 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19463 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19464 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19465 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19466 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19467 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19468 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19469 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19470 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19471 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19473 /* neighbor maximum-prefix-out commands. */
19474 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19475 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19476 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19477 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19478 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19479 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19480 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19481 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19482 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19483 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19484 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19485 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19486 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19487 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19488 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19489 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19490 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19491 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19493 /* "neighbor maximum-prefix" commands. */
19494 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19495 install_element(BGP_NODE
,
19496 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19497 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19498 install_element(BGP_NODE
,
19499 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19500 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19501 install_element(BGP_NODE
,
19502 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19503 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19504 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19505 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19506 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19507 install_element(BGP_IPV4_NODE
,
19508 &neighbor_maximum_prefix_threshold_warning_cmd
);
19509 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19510 install_element(BGP_IPV4_NODE
,
19511 &neighbor_maximum_prefix_threshold_restart_cmd
);
19512 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19513 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19514 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19515 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19516 install_element(BGP_IPV4M_NODE
,
19517 &neighbor_maximum_prefix_threshold_warning_cmd
);
19518 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19519 install_element(BGP_IPV4M_NODE
,
19520 &neighbor_maximum_prefix_threshold_restart_cmd
);
19521 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19522 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19523 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19524 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19525 install_element(BGP_IPV4L_NODE
,
19526 &neighbor_maximum_prefix_threshold_warning_cmd
);
19527 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19528 install_element(BGP_IPV4L_NODE
,
19529 &neighbor_maximum_prefix_threshold_restart_cmd
);
19530 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19531 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19532 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19533 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19534 install_element(BGP_IPV6_NODE
,
19535 &neighbor_maximum_prefix_threshold_warning_cmd
);
19536 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19537 install_element(BGP_IPV6_NODE
,
19538 &neighbor_maximum_prefix_threshold_restart_cmd
);
19539 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19540 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19541 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19542 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19543 install_element(BGP_IPV6M_NODE
,
19544 &neighbor_maximum_prefix_threshold_warning_cmd
);
19545 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19546 install_element(BGP_IPV6M_NODE
,
19547 &neighbor_maximum_prefix_threshold_restart_cmd
);
19548 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19549 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19550 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19551 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19552 install_element(BGP_IPV6L_NODE
,
19553 &neighbor_maximum_prefix_threshold_warning_cmd
);
19554 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19555 install_element(BGP_IPV6L_NODE
,
19556 &neighbor_maximum_prefix_threshold_restart_cmd
);
19557 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19558 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19559 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19560 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19561 install_element(BGP_VPNV4_NODE
,
19562 &neighbor_maximum_prefix_threshold_warning_cmd
);
19563 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19564 install_element(BGP_VPNV4_NODE
,
19565 &neighbor_maximum_prefix_threshold_restart_cmd
);
19566 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19567 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19568 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19569 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19570 install_element(BGP_VPNV6_NODE
,
19571 &neighbor_maximum_prefix_threshold_warning_cmd
);
19572 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19573 install_element(BGP_VPNV6_NODE
,
19574 &neighbor_maximum_prefix_threshold_restart_cmd
);
19575 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19577 /* "neighbor allowas-in" */
19578 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19579 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19580 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19581 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19582 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19583 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19584 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19585 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19586 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19587 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19588 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19589 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19590 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19591 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19592 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19593 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19594 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19595 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19596 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19597 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19599 /* "neighbor dampening" commands. */
19600 install_element(BGP_NODE
, &neighbor_damp_cmd
);
19601 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
19602 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
19603 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
19604 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
19605 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
19606 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
19607 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
19608 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
19609 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
19610 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
19611 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
19612 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
19613 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
19614 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
19616 /* address-family commands. */
19617 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19618 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19619 #ifdef KEEP_OLD_VPN_COMMANDS
19620 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19621 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19622 #endif /* KEEP_OLD_VPN_COMMANDS */
19624 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19626 /* "exit-address-family" command. */
19627 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19628 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19629 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19630 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19631 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19632 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19633 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19634 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19635 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19636 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19637 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19639 /* "clear ip bgp commands" */
19640 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19642 /* clear ip bgp prefix */
19643 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19644 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19645 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19647 /* "show [ip] bgp summary" commands. */
19648 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19649 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19650 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19651 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19652 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19653 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19654 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19656 /* "show [ip] bgp neighbors" commands. */
19657 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19659 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19661 /* "show [ip] bgp peer-group" commands. */
19662 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19664 /* "show [ip] bgp paths" commands. */
19665 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19667 /* "show [ip] bgp community" commands. */
19668 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19670 /* "show ip bgp large-community" commands. */
19671 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19672 /* "show [ip] bgp attribute-info" commands. */
19673 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19674 /* "show [ip] bgp route-leak" command */
19675 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19677 /* "redistribute" commands. */
19678 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19679 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19680 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19681 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19682 install_element(BGP_NODE
,
19683 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19684 install_element(BGP_NODE
,
19685 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19686 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19687 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19688 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19689 install_element(BGP_NODE
,
19690 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19691 install_element(BGP_NODE
,
19692 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19693 install_element(BGP_NODE
,
19694 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19695 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19696 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19697 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19698 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19699 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19700 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19701 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19702 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19703 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19704 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19705 install_element(BGP_IPV4_NODE
,
19706 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19707 install_element(BGP_IPV4_NODE
,
19708 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19709 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19710 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19711 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19712 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19713 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19714 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19716 /* import|export vpn [route-map WORD] */
19717 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19718 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19720 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19721 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19723 /* ttl_security commands */
19724 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19725 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19727 /* "show [ip] bgp memory" commands. */
19728 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19730 /* "show bgp martian next-hop" */
19731 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19733 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19735 /* "show [ip] bgp views" commands. */
19736 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19738 /* "show [ip] bgp vrfs" commands. */
19739 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19741 /* Community-list. */
19742 community_list_vty();
19744 community_alias_vty();
19746 /* vpn-policy commands */
19747 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19748 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19749 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19750 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19751 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19752 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19753 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19754 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19755 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19756 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19757 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19758 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19760 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19761 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19763 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19764 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19765 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19766 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19767 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19768 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19769 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19770 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19771 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19772 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19774 /* tcp-mss command */
19775 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19776 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19778 /* srv6 commands */
19779 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19780 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19781 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19782 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19783 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19786 #include "memory.h"
19787 #include "bgp_regex.h"
19788 #include "bgp_clist.h"
19789 #include "bgp_ecommunity.h"
19791 /* VTY functions. */
19793 /* Direction value to string conversion. */
19794 static const char *community_direct_str(int direct
)
19797 case COMMUNITY_DENY
:
19799 case COMMUNITY_PERMIT
:
19806 /* Display error string. */
19807 static void community_list_perror(struct vty
*vty
, int ret
)
19810 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19811 vty_out(vty
, "%% Can't find community-list\n");
19813 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19814 vty_out(vty
, "%% Malformed community-list value\n");
19816 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19818 "%% Community name conflict, previously defined as standard community\n");
19820 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19822 "%% Community name conflict, previously defined as expanded community\n");
19827 /* "community-list" keyword help string. */
19828 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19830 /*community-list standard */
19831 DEFUN (community_list_standard
,
19832 bgp_community_list_standard_cmd
,
19833 "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19836 "Community list number (standard)\n"
19837 "Add an standard community-list entry\n"
19838 "Community list name\n"
19839 "Sequence number of an entry\n"
19840 "Sequence number\n"
19841 "Specify community to reject\n"
19842 "Specify community to accept\n"
19845 char *cl_name_or_number
= NULL
;
19848 int style
= COMMUNITY_LIST_STANDARD
;
19851 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19853 seq
= argv
[idx
]->arg
;
19856 argv_find(argv
, argc
, "(1-99)", &idx
);
19857 argv_find(argv
, argc
, "WORD", &idx
);
19858 cl_name_or_number
= argv
[idx
]->arg
;
19859 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19861 argv_find(argv
, argc
, "AA:NN", &idx
);
19862 char *str
= argv_concat(argv
, argc
, idx
);
19864 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19867 XFREE(MTYPE_TMP
, str
);
19870 /* Display error string. */
19871 community_list_perror(vty
, ret
);
19872 return CMD_WARNING_CONFIG_FAILED
;
19875 return CMD_SUCCESS
;
19878 DEFUN (no_community_list_standard_all
,
19879 no_bgp_community_list_standard_all_cmd
,
19880 "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19884 "Community list number (standard)\n"
19885 "Add an standard community-list entry\n"
19886 "Community list name\n"
19887 "Sequence number of an entry\n"
19888 "Sequence number\n"
19889 "Specify community to reject\n"
19890 "Specify community to accept\n"
19893 char *cl_name_or_number
= NULL
;
19896 int style
= COMMUNITY_LIST_STANDARD
;
19900 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19902 seq
= argv
[idx
]->arg
;
19905 argv_find(argv
, argc
, "permit", &idx
);
19906 argv_find(argv
, argc
, "deny", &idx
);
19909 direct
= argv_find(argv
, argc
, "permit", &idx
)
19914 argv_find(argv
, argc
, "AA:NN", &idx
);
19915 str
= argv_concat(argv
, argc
, idx
);
19919 argv_find(argv
, argc
, "(1-99)", &idx
);
19920 argv_find(argv
, argc
, "WORD", &idx
);
19921 cl_name_or_number
= argv
[idx
]->arg
;
19923 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19926 XFREE(MTYPE_TMP
, str
);
19929 community_list_perror(vty
, ret
);
19930 return CMD_WARNING_CONFIG_FAILED
;
19933 return CMD_SUCCESS
;
19936 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19937 "no bgp community-list <(1-99)|standard WORD>",
19938 NO_STR BGP_STR COMMUNITY_LIST_STR
19939 "Community list number (standard)\n"
19940 "Add an standard community-list entry\n"
19941 "Community list name\n")
19943 /*community-list expanded */
19944 DEFUN (community_list_expanded_all
,
19945 bgp_community_list_expanded_all_cmd
,
19946 "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19949 "Community list number (expanded)\n"
19950 "Add an expanded community-list entry\n"
19951 "Community list name\n"
19952 "Sequence number of an entry\n"
19953 "Sequence number\n"
19954 "Specify community to reject\n"
19955 "Specify community to accept\n"
19958 char *cl_name_or_number
= NULL
;
19961 int style
= COMMUNITY_LIST_EXPANDED
;
19964 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19966 seq
= argv
[idx
]->arg
;
19970 argv_find(argv
, argc
, "(100-500)", &idx
);
19971 argv_find(argv
, argc
, "WORD", &idx
);
19972 cl_name_or_number
= argv
[idx
]->arg
;
19973 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19975 argv_find(argv
, argc
, "AA:NN", &idx
);
19976 char *str
= argv_concat(argv
, argc
, idx
);
19978 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19981 XFREE(MTYPE_TMP
, str
);
19984 /* Display error string. */
19985 community_list_perror(vty
, ret
);
19986 return CMD_WARNING_CONFIG_FAILED
;
19989 return CMD_SUCCESS
;
19992 DEFUN (no_community_list_expanded_all
,
19993 no_bgp_community_list_expanded_all_cmd
,
19994 "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19998 "Community list number (expanded)\n"
19999 "Add an expanded community-list entry\n"
20000 "Community list name\n"
20001 "Sequence number of an entry\n"
20002 "Sequence number\n"
20003 "Specify community to reject\n"
20004 "Specify community to accept\n"
20007 char *cl_name_or_number
= NULL
;
20011 int style
= COMMUNITY_LIST_EXPANDED
;
20014 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
20016 seq
= argv
[idx
]->arg
;
20019 argv_find(argv
, argc
, "permit", &idx
);
20020 argv_find(argv
, argc
, "deny", &idx
);
20023 direct
= argv_find(argv
, argc
, "permit", &idx
)
20028 argv_find(argv
, argc
, "AA:NN", &idx
);
20029 str
= argv_concat(argv
, argc
, idx
);
20033 argv_find(argv
, argc
, "(100-500)", &idx
);
20034 argv_find(argv
, argc
, "WORD", &idx
);
20035 cl_name_or_number
= argv
[idx
]->arg
;
20037 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20040 XFREE(MTYPE_TMP
, str
);
20043 community_list_perror(vty
, ret
);
20044 return CMD_WARNING_CONFIG_FAILED
;
20047 return CMD_SUCCESS
;
20050 ALIAS(no_community_list_expanded_all
,
20051 no_bgp_community_list_expanded_all_list_cmd
,
20052 "no bgp community-list <(100-500)|expanded WORD>",
20053 NO_STR BGP_STR COMMUNITY_LIST_STR
20054 "Community list number (expanded)\n"
20055 "Add an expanded community-list entry\n"
20056 "Community list name\n")
20058 /* Return configuration string of community-list entry. */
20059 static const char *community_list_config_str(struct community_entry
*entry
)
20066 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20067 str
= community_str(entry
->u
.com
, false);
20068 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20069 str
= lcommunity_str(entry
->u
.lcom
, false);
20071 str
= entry
->config
;
20076 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20078 struct community_entry
*entry
;
20080 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20081 if (entry
== list
->head
) {
20082 if (all_digit(list
->name
))
20083 vty_out(vty
, "Community %s list %s\n",
20084 entry
->style
== COMMUNITY_LIST_STANDARD
20086 : "(expanded) access",
20089 vty_out(vty
, "Named Community %s list %s\n",
20090 entry
->style
== COMMUNITY_LIST_STANDARD
20096 vty_out(vty
, " %s\n",
20097 community_direct_str(entry
->direct
));
20099 vty_out(vty
, " %s %s\n",
20100 community_direct_str(entry
->direct
),
20101 community_list_config_str(entry
));
20105 DEFUN (show_community_list
,
20106 show_bgp_community_list_cmd
,
20107 "show bgp community-list",
20110 "List community-list\n")
20112 struct community_list
*list
;
20113 struct community_list_master
*cm
;
20115 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20117 return CMD_SUCCESS
;
20119 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20120 community_list_show(vty
, list
);
20122 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20123 community_list_show(vty
, list
);
20125 return CMD_SUCCESS
;
20128 DEFUN (show_community_list_arg
,
20129 show_bgp_community_list_arg_cmd
,
20130 "show bgp community-list <(1-500)|WORD> detail",
20133 "List community-list\n"
20134 "Community-list number\n"
20135 "Community-list name\n"
20136 "Detailed information on community-list\n")
20138 int idx_comm_list
= 3;
20139 struct community_list
*list
;
20141 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20142 COMMUNITY_LIST_MASTER
);
20144 vty_out(vty
, "%% Can't find community-list\n");
20145 return CMD_WARNING
;
20148 community_list_show(vty
, list
);
20150 return CMD_SUCCESS
;
20154 * Large Community code.
20156 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20157 struct cmd_token
**argv
, int style
,
20158 int reject_all_digit_name
)
20167 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20168 seq
= argv
[idx
]->arg
;
20171 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20174 /* All digit name check. */
20176 argv_find(argv
, argc
, "WORD", &idx
);
20177 argv_find(argv
, argc
, "(1-99)", &idx
);
20178 argv_find(argv
, argc
, "(100-500)", &idx
);
20179 cl_name
= argv
[idx
]->arg
;
20180 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20181 vty_out(vty
, "%% Community name cannot have all digits\n");
20182 return CMD_WARNING_CONFIG_FAILED
;
20186 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20187 argv_find(argv
, argc
, "LINE", &idx
);
20188 /* Concat community string argument. */
20190 str
= argv_concat(argv
, argc
, idx
);
20194 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20196 /* Free temporary community list string allocated by
20198 XFREE(MTYPE_TMP
, str
);
20201 community_list_perror(vty
, ret
);
20202 return CMD_WARNING_CONFIG_FAILED
;
20204 return CMD_SUCCESS
;
20207 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20208 struct cmd_token
**argv
, int style
)
20216 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20217 seq
= argv
[idx
]->arg
;
20220 argv_find(argv
, argc
, "permit", &idx
);
20221 argv_find(argv
, argc
, "deny", &idx
);
20224 /* Check the list direct. */
20225 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20226 direct
= COMMUNITY_PERMIT
;
20228 direct
= COMMUNITY_DENY
;
20231 argv_find(argv
, argc
, "LINE", &idx
);
20232 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20233 /* Concat community string argument. */
20234 str
= argv_concat(argv
, argc
, idx
);
20238 argv_find(argv
, argc
, "(1-99)", &idx
);
20239 argv_find(argv
, argc
, "(100-500)", &idx
);
20240 argv_find(argv
, argc
, "WORD", &idx
);
20242 /* Unset community list. */
20243 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20246 /* Free temporary community list string allocated by
20248 XFREE(MTYPE_TMP
, str
);
20251 community_list_perror(vty
, ret
);
20252 return CMD_WARNING_CONFIG_FAILED
;
20255 return CMD_SUCCESS
;
20258 /* "large-community-list" keyword help string. */
20259 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20260 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20262 DEFUN (lcommunity_list_standard
,
20263 bgp_lcommunity_list_standard_cmd
,
20264 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20266 LCOMMUNITY_LIST_STR
20267 "Large Community list number (standard)\n"
20268 "Sequence number of an entry\n"
20269 "Sequence number\n"
20270 "Specify large community to reject\n"
20271 "Specify large community to accept\n"
20272 LCOMMUNITY_VAL_STR
)
20274 return lcommunity_list_set_vty(vty
, argc
, argv
,
20275 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20278 DEFUN (lcommunity_list_expanded
,
20279 bgp_lcommunity_list_expanded_cmd
,
20280 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20282 LCOMMUNITY_LIST_STR
20283 "Large Community list number (expanded)\n"
20284 "Sequence number of an entry\n"
20285 "Sequence number\n"
20286 "Specify large community to reject\n"
20287 "Specify large community to accept\n"
20288 "An ordered list as a regular-expression\n")
20290 return lcommunity_list_set_vty(vty
, argc
, argv
,
20291 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20294 DEFUN (lcommunity_list_name_standard
,
20295 bgp_lcommunity_list_name_standard_cmd
,
20296 "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20298 LCOMMUNITY_LIST_STR
20299 "Specify standard large-community-list\n"
20300 "Large Community list name\n"
20301 "Sequence number of an entry\n"
20302 "Sequence number\n"
20303 "Specify large community to reject\n"
20304 "Specify large community to accept\n"
20305 LCOMMUNITY_VAL_STR
)
20307 return lcommunity_list_set_vty(vty
, argc
, argv
,
20308 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20311 DEFUN (lcommunity_list_name_expanded
,
20312 bgp_lcommunity_list_name_expanded_cmd
,
20313 "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
20315 LCOMMUNITY_LIST_STR
20316 "Specify expanded large-community-list\n"
20317 "Large Community list name\n"
20318 "Sequence number of an entry\n"
20319 "Sequence number\n"
20320 "Specify large community to reject\n"
20321 "Specify large community to accept\n"
20322 "An ordered list as a regular-expression\n")
20324 return lcommunity_list_set_vty(vty
, argc
, argv
,
20325 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20328 DEFUN (no_lcommunity_list_all
,
20329 no_bgp_lcommunity_list_all_cmd
,
20330 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
20333 LCOMMUNITY_LIST_STR
20334 "Large Community list number (standard)\n"
20335 "Large Community list number (expanded)\n"
20336 "Large Community list name\n")
20338 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20339 LARGE_COMMUNITY_LIST_STANDARD
);
20342 DEFUN (no_lcommunity_list_name_standard_all
,
20343 no_bgp_lcommunity_list_name_standard_all_cmd
,
20344 "no bgp large-community-list standard WORD",
20347 LCOMMUNITY_LIST_STR
20348 "Specify standard large-community-list\n"
20349 "Large Community list name\n")
20351 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20352 LARGE_COMMUNITY_LIST_STANDARD
);
20355 DEFUN (no_lcommunity_list_name_expanded_all
,
20356 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20357 "no bgp large-community-list expanded WORD",
20360 LCOMMUNITY_LIST_STR
20361 "Specify expanded large-community-list\n"
20362 "Large Community list name\n")
20364 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20365 LARGE_COMMUNITY_LIST_EXPANDED
);
20368 DEFUN (no_lcommunity_list_standard
,
20369 no_bgp_lcommunity_list_standard_cmd
,
20370 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20373 LCOMMUNITY_LIST_STR
20374 "Large Community list number (standard)\n"
20375 "Sequence number of an entry\n"
20376 "Sequence number\n"
20377 "Specify large community to reject\n"
20378 "Specify large community to accept\n"
20379 LCOMMUNITY_VAL_STR
)
20381 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20382 LARGE_COMMUNITY_LIST_STANDARD
);
20385 DEFUN (no_lcommunity_list_expanded
,
20386 no_bgp_lcommunity_list_expanded_cmd
,
20387 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20390 LCOMMUNITY_LIST_STR
20391 "Large Community list number (expanded)\n"
20392 "Sequence number of an entry\n"
20393 "Sequence number\n"
20394 "Specify large community to reject\n"
20395 "Specify large community to accept\n"
20396 "An ordered list as a regular-expression\n")
20398 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20399 LARGE_COMMUNITY_LIST_EXPANDED
);
20402 DEFUN (no_lcommunity_list_name_standard
,
20403 no_bgp_lcommunity_list_name_standard_cmd
,
20404 "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20407 LCOMMUNITY_LIST_STR
20408 "Specify standard large-community-list\n"
20409 "Large Community list name\n"
20410 "Sequence number of an entry\n"
20411 "Sequence number\n"
20412 "Specify large community to reject\n"
20413 "Specify large community to accept\n"
20414 LCOMMUNITY_VAL_STR
)
20416 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20417 LARGE_COMMUNITY_LIST_STANDARD
);
20420 DEFUN (no_lcommunity_list_name_expanded
,
20421 no_bgp_lcommunity_list_name_expanded_cmd
,
20422 "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
20425 LCOMMUNITY_LIST_STR
20426 "Specify expanded large-community-list\n"
20427 "Large community list name\n"
20428 "Sequence number of an entry\n"
20429 "Sequence number\n"
20430 "Specify large community to reject\n"
20431 "Specify large community to accept\n"
20432 "An ordered list as a regular-expression\n")
20434 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20435 LARGE_COMMUNITY_LIST_EXPANDED
);
20438 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20440 struct community_entry
*entry
;
20442 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20443 if (entry
== list
->head
) {
20444 if (all_digit(list
->name
))
20445 vty_out(vty
, "Large community %s list %s\n",
20447 LARGE_COMMUNITY_LIST_STANDARD
20449 : "(expanded) access",
20453 "Named large community %s list %s\n",
20455 LARGE_COMMUNITY_LIST_STANDARD
20461 vty_out(vty
, " %s\n",
20462 community_direct_str(entry
->direct
));
20464 vty_out(vty
, " %s %s\n",
20465 community_direct_str(entry
->direct
),
20466 community_list_config_str(entry
));
20470 DEFUN (show_lcommunity_list
,
20471 show_bgp_lcommunity_list_cmd
,
20472 "show bgp large-community-list",
20475 "List large-community list\n")
20477 struct community_list
*list
;
20478 struct community_list_master
*cm
;
20480 cm
= community_list_master_lookup(bgp_clist
,
20481 LARGE_COMMUNITY_LIST_MASTER
);
20483 return CMD_SUCCESS
;
20485 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20486 lcommunity_list_show(vty
, list
);
20488 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20489 lcommunity_list_show(vty
, list
);
20491 return CMD_SUCCESS
;
20494 DEFUN (show_lcommunity_list_arg
,
20495 show_bgp_lcommunity_list_arg_cmd
,
20496 "show bgp large-community-list <(1-500)|WORD> detail",
20499 "List large-community list\n"
20500 "Large-community-list number\n"
20501 "Large-community-list name\n"
20502 "Detailed information on large-community-list\n")
20504 struct community_list
*list
;
20506 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20507 LARGE_COMMUNITY_LIST_MASTER
);
20509 vty_out(vty
, "%% Can't find large-community-list\n");
20510 return CMD_WARNING
;
20513 lcommunity_list_show(vty
, list
);
20515 return CMD_SUCCESS
;
20518 /* "extcommunity-list" keyword help string. */
20519 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20520 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20522 DEFUN (extcommunity_list_standard
,
20523 bgp_extcommunity_list_standard_cmd
,
20524 "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20526 EXTCOMMUNITY_LIST_STR
20527 "Extended Community list number (standard)\n"
20528 "Specify standard extcommunity-list\n"
20529 "Community list name\n"
20530 "Sequence number of an entry\n"
20531 "Sequence number\n"
20532 "Specify community to reject\n"
20533 "Specify community to accept\n"
20534 EXTCOMMUNITY_VAL_STR
)
20536 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20538 char *cl_number_or_name
= NULL
;
20543 argv_find(argv
, argc
, "(1-99)", &idx
);
20544 argv_find(argv
, argc
, "WORD", &idx
);
20545 cl_number_or_name
= argv
[idx
]->arg
;
20547 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20548 seq
= argv
[idx
]->arg
;
20550 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20552 argv_find(argv
, argc
, "AA:NN", &idx
);
20553 char *str
= argv_concat(argv
, argc
, idx
);
20555 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20558 XFREE(MTYPE_TMP
, str
);
20561 community_list_perror(vty
, ret
);
20562 return CMD_WARNING_CONFIG_FAILED
;
20565 return CMD_SUCCESS
;
20568 DEFUN (extcommunity_list_name_expanded
,
20569 bgp_extcommunity_list_name_expanded_cmd
,
20570 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20572 EXTCOMMUNITY_LIST_STR
20573 "Extended Community list number (expanded)\n"
20574 "Specify expanded extcommunity-list\n"
20575 "Extended Community list name\n"
20576 "Sequence number of an entry\n"
20577 "Sequence number\n"
20578 "Specify community to reject\n"
20579 "Specify community to accept\n"
20580 "An ordered list as a regular-expression\n")
20582 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20584 char *cl_number_or_name
= NULL
;
20588 argv_find(argv
, argc
, "(100-500)", &idx
);
20589 argv_find(argv
, argc
, "WORD", &idx
);
20590 cl_number_or_name
= argv
[idx
]->arg
;
20592 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20593 seq
= argv
[idx
]->arg
;
20595 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20597 argv_find(argv
, argc
, "LINE", &idx
);
20598 char *str
= argv_concat(argv
, argc
, idx
);
20600 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20603 XFREE(MTYPE_TMP
, str
);
20606 community_list_perror(vty
, ret
);
20607 return CMD_WARNING_CONFIG_FAILED
;
20610 return CMD_SUCCESS
;
20613 DEFUN (no_extcommunity_list_standard_all
,
20614 no_bgp_extcommunity_list_standard_all_cmd
,
20615 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20618 EXTCOMMUNITY_LIST_STR
20619 "Extended Community list number (standard)\n"
20620 "Specify standard extcommunity-list\n"
20621 "Community list name\n"
20622 "Sequence number of an entry\n"
20623 "Sequence number\n"
20624 "Specify community to reject\n"
20625 "Specify community to accept\n"
20626 EXTCOMMUNITY_VAL_STR
)
20628 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20630 char *cl_number_or_name
= NULL
;
20635 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20636 seq
= argv
[idx
]->arg
;
20639 argv_find(argv
, argc
, "permit", &idx
);
20640 argv_find(argv
, argc
, "deny", &idx
);
20642 direct
= argv_find(argv
, argc
, "permit", &idx
)
20647 argv_find(argv
, argc
, "AA:NN", &idx
);
20648 str
= argv_concat(argv
, argc
, idx
);
20652 argv_find(argv
, argc
, "(1-99)", &idx
);
20653 argv_find(argv
, argc
, "WORD", &idx
);
20654 cl_number_or_name
= argv
[idx
]->arg
;
20656 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20657 seq
, direct
, style
);
20659 XFREE(MTYPE_TMP
, str
);
20662 community_list_perror(vty
, ret
);
20663 return CMD_WARNING_CONFIG_FAILED
;
20666 return CMD_SUCCESS
;
20669 ALIAS(no_extcommunity_list_standard_all
,
20670 no_bgp_extcommunity_list_standard_all_list_cmd
,
20671 "no bgp extcommunity-list <(1-99)|standard WORD>",
20672 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20673 "Extended Community list number (standard)\n"
20674 "Specify standard extcommunity-list\n"
20675 "Community list name\n")
20677 DEFUN (no_extcommunity_list_expanded_all
,
20678 no_bgp_extcommunity_list_expanded_all_cmd
,
20679 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20682 EXTCOMMUNITY_LIST_STR
20683 "Extended Community list number (expanded)\n"
20684 "Specify expanded extcommunity-list\n"
20685 "Extended Community list name\n"
20686 "Sequence number of an entry\n"
20687 "Sequence number\n"
20688 "Specify community to reject\n"
20689 "Specify community to accept\n"
20690 "An ordered list as a regular-expression\n")
20692 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20694 char *cl_number_or_name
= NULL
;
20699 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20700 seq
= argv
[idx
]->arg
;
20703 argv_find(argv
, argc
, "permit", &idx
);
20704 argv_find(argv
, argc
, "deny", &idx
);
20707 direct
= argv_find(argv
, argc
, "permit", &idx
)
20712 argv_find(argv
, argc
, "LINE", &idx
);
20713 str
= argv_concat(argv
, argc
, idx
);
20717 argv_find(argv
, argc
, "(100-500)", &idx
);
20718 argv_find(argv
, argc
, "WORD", &idx
);
20719 cl_number_or_name
= argv
[idx
]->arg
;
20721 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20722 seq
, direct
, style
);
20724 XFREE(MTYPE_TMP
, str
);
20727 community_list_perror(vty
, ret
);
20728 return CMD_WARNING_CONFIG_FAILED
;
20731 return CMD_SUCCESS
;
20734 ALIAS(no_extcommunity_list_expanded_all
,
20735 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20736 "no bgp extcommunity-list <(100-500)|expanded WORD>",
20737 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20738 "Extended Community list number (expanded)\n"
20739 "Specify expanded extcommunity-list\n"
20740 "Extended Community list name\n")
20742 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20744 struct community_entry
*entry
;
20746 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20747 if (entry
== list
->head
) {
20748 if (all_digit(list
->name
))
20749 vty_out(vty
, "Extended community %s list %s\n",
20750 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20752 : "(expanded) access",
20756 "Named extended community %s list %s\n",
20757 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20763 vty_out(vty
, " %s\n",
20764 community_direct_str(entry
->direct
));
20766 vty_out(vty
, " %s %s\n",
20767 community_direct_str(entry
->direct
),
20768 community_list_config_str(entry
));
20772 DEFUN (show_extcommunity_list
,
20773 show_bgp_extcommunity_list_cmd
,
20774 "show bgp extcommunity-list",
20777 "List extended-community list\n")
20779 struct community_list
*list
;
20780 struct community_list_master
*cm
;
20782 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20784 return CMD_SUCCESS
;
20786 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20787 extcommunity_list_show(vty
, list
);
20789 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20790 extcommunity_list_show(vty
, list
);
20792 return CMD_SUCCESS
;
20795 DEFUN (show_extcommunity_list_arg
,
20796 show_bgp_extcommunity_list_arg_cmd
,
20797 "show bgp extcommunity-list <(1-500)|WORD> detail",
20800 "List extended-community list\n"
20801 "Extcommunity-list number\n"
20802 "Extcommunity-list name\n"
20803 "Detailed information on extcommunity-list\n")
20805 int idx_comm_list
= 3;
20806 struct community_list
*list
;
20808 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20809 EXTCOMMUNITY_LIST_MASTER
);
20811 vty_out(vty
, "%% Can't find extcommunity-list\n");
20812 return CMD_WARNING
;
20815 extcommunity_list_show(vty
, list
);
20817 return CMD_SUCCESS
;
20820 /* Display community-list and extcommunity-list configuration. */
20821 static int community_list_config_write(struct vty
*vty
)
20823 struct community_list
*list
;
20824 struct community_entry
*entry
;
20825 struct community_list_master
*cm
;
20828 /* Community-list. */
20829 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20831 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20832 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20834 "bgp community-list %s seq %" PRId64
" %s %s\n",
20835 list
->name
, entry
->seq
,
20836 community_direct_str(entry
->direct
),
20837 community_list_config_str(entry
));
20840 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20841 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20843 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20844 entry
->style
== COMMUNITY_LIST_STANDARD
20847 list
->name
, entry
->seq
,
20848 community_direct_str(entry
->direct
),
20849 community_list_config_str(entry
));
20853 /* Extcommunity-list. */
20854 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20856 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20857 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20859 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20860 list
->name
, entry
->seq
,
20861 community_direct_str(entry
->direct
),
20862 community_list_config_str(entry
));
20865 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20866 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20868 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20869 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20872 list
->name
, entry
->seq
,
20873 community_direct_str(entry
->direct
),
20874 community_list_config_str(entry
));
20879 /* lcommunity-list. */
20880 cm
= community_list_master_lookup(bgp_clist
,
20881 LARGE_COMMUNITY_LIST_MASTER
);
20883 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20884 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20886 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20887 list
->name
, entry
->seq
,
20888 community_direct_str(entry
->direct
),
20889 community_list_config_str(entry
));
20892 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20893 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20895 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20897 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20900 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20901 community_list_config_str(entry
));
20908 static int community_list_config_write(struct vty
*vty
);
20909 static struct cmd_node community_list_node
= {
20910 .name
= "community list",
20911 .node
= COMMUNITY_LIST_NODE
,
20913 .config_write
= community_list_config_write
,
20916 static void community_list_vty(void)
20918 install_node(&community_list_node
);
20920 /* Community-list. */
20921 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20922 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20923 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20924 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20925 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20926 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20927 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20928 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20930 /* Extcommunity-list. */
20931 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20932 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20933 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20934 install_element(CONFIG_NODE
,
20935 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20936 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20937 install_element(CONFIG_NODE
,
20938 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20939 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20940 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20942 /* Large Community List */
20943 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20944 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20945 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20946 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20947 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20948 install_element(CONFIG_NODE
,
20949 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20950 install_element(CONFIG_NODE
,
20951 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20952 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20953 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20954 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20955 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20956 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20957 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20960 static struct cmd_node community_alias_node
= {
20961 .name
= "community alias",
20962 .node
= COMMUNITY_ALIAS_NODE
,
20964 .config_write
= bgp_community_alias_write
,
20967 void community_alias_vty(void)
20969 install_node(&community_alias_node
);
20971 /* Community-list. */
20972 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20974 bgp_community_alias_command_completion_setup();