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"
76 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
79 #include "northbound.h"
80 #include "northbound_cli.h"
81 #include "bgpd/bgp_nb.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
130 DEFINE_HOOK(bgp_inst_config_write
,
131 (struct bgp
*bgp
, struct vty
*vty
),
133 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
135 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
136 struct prefix
*range
, int exact
);
138 /* Show BGP peer's information. */
148 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
149 struct prefix
*range
, int exact
);
151 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
156 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
159 afi_t afi
, bool use_json
);
161 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
162 char *base_xpath
, int xpath_len
,
165 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
171 return BGP_IPV4_NODE
;
173 return BGP_IPV4M_NODE
;
174 case SAFI_LABELED_UNICAST
:
175 return BGP_IPV4L_NODE
;
177 return BGP_VPNV4_NODE
;
179 return BGP_FLOWSPECV4_NODE
;
182 return BGP_IPV4_NODE
;
188 return BGP_IPV6_NODE
;
190 return BGP_IPV6M_NODE
;
191 case SAFI_LABELED_UNICAST
:
192 return BGP_IPV6L_NODE
;
194 return BGP_VPNV6_NODE
;
196 return BGP_FLOWSPECV6_NODE
;
199 return BGP_IPV4_NODE
;
203 return BGP_EVPN_NODE
;
206 // We should never be here but to clarify the switch statement..
207 return BGP_IPV4_NODE
;
210 // Impossible to happen
211 return BGP_IPV4_NODE
;
214 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
217 if (safi
== SAFI_UNICAST
)
218 return "IPv4 Unicast";
219 if (safi
== SAFI_MULTICAST
)
220 return "IPv4 Multicast";
221 if (safi
== SAFI_LABELED_UNICAST
)
222 return "IPv4 Labeled Unicast";
223 if (safi
== SAFI_MPLS_VPN
)
225 if (safi
== SAFI_ENCAP
)
227 if (safi
== SAFI_FLOWSPEC
)
228 return "IPv4 Flowspec";
229 } else if (afi
== AFI_IP6
) {
230 if (safi
== SAFI_UNICAST
)
231 return "IPv6 Unicast";
232 if (safi
== SAFI_MULTICAST
)
233 return "IPv6 Multicast";
234 if (safi
== SAFI_LABELED_UNICAST
)
235 return "IPv6 Labeled Unicast";
236 if (safi
== SAFI_MPLS_VPN
)
238 if (safi
== SAFI_ENCAP
)
240 if (safi
== SAFI_FLOWSPEC
)
241 return "IPv6 Flowspec";
242 } else if (afi
== AFI_L2VPN
) {
243 if (safi
== SAFI_EVPN
)
251 * Please note that we have intentionally camelCased
252 * the return strings here. So if you want
253 * to use this function, please ensure you
254 * are doing this within json output
256 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
259 if (safi
== SAFI_UNICAST
)
260 return "ipv4Unicast";
261 if (safi
== SAFI_MULTICAST
)
262 return "ipv4Multicast";
263 if (safi
== SAFI_LABELED_UNICAST
)
264 return "ipv4LabeledUnicast";
265 if (safi
== SAFI_MPLS_VPN
)
267 if (safi
== SAFI_ENCAP
)
269 if (safi
== SAFI_FLOWSPEC
)
270 return "ipv4Flowspec";
271 } else if (afi
== AFI_IP6
) {
272 if (safi
== SAFI_UNICAST
)
273 return "ipv6Unicast";
274 if (safi
== SAFI_MULTICAST
)
275 return "ipv6Multicast";
276 if (safi
== SAFI_LABELED_UNICAST
)
277 return "ipv6LabeledUnicast";
278 if (safi
== SAFI_MPLS_VPN
)
280 if (safi
== SAFI_ENCAP
)
282 if (safi
== SAFI_FLOWSPEC
)
283 return "ipv6Flowspec";
284 } else if (afi
== AFI_L2VPN
) {
285 if (safi
== SAFI_EVPN
)
292 /* return string maps to afi-safi specific container names
293 * defined in bgp yang file.
295 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
298 if (safi
== SAFI_UNICAST
)
299 return "ipv4-unicast";
300 if (safi
== SAFI_MULTICAST
)
301 return "ipv4-multicast";
302 if (safi
== SAFI_LABELED_UNICAST
)
303 return "ipv4-labeled-unicast";
304 if (safi
== SAFI_MPLS_VPN
)
305 return "l3vpn-ipv4-unicast";
306 if (safi
== SAFI_FLOWSPEC
)
307 return "ipv4-flowspec";
308 } else if (afi
== AFI_IP6
) {
309 if (safi
== SAFI_UNICAST
)
310 return "ipv6-unicast";
311 if (safi
== SAFI_MULTICAST
)
312 return "ipv6-multicast";
313 if (safi
== SAFI_LABELED_UNICAST
)
314 return "ipv6-labeled-unicast";
315 if (safi
== SAFI_MPLS_VPN
)
316 return "l3vpn-ipv6-unicast";
317 if (safi
== SAFI_FLOWSPEC
)
318 return "ipv6-flowspec";
319 } else if (afi
== AFI_L2VPN
) {
320 if (safi
== SAFI_EVPN
)
327 /* Utility function to get address family from current node. */
328 afi_t
bgp_node_afi(struct vty
*vty
)
336 case BGP_FLOWSPECV6_NODE
:
349 /* Utility function to get subsequent address family from current
351 safi_t
bgp_node_safi(struct vty
*vty
)
357 safi
= SAFI_MPLS_VPN
;
361 safi
= SAFI_MULTICAST
;
368 safi
= SAFI_LABELED_UNICAST
;
370 case BGP_FLOWSPECV4_NODE
:
371 case BGP_FLOWSPECV6_NODE
:
372 safi
= SAFI_FLOWSPEC
;
382 * Converts an AFI in string form to afi_t
384 * @param afi string, one of
388 * @return the corresponding afi_t
390 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
392 afi_t afi
= AFI_MAX
; /* unknown */
393 if (strmatch(afi_str
, "ipv4"))
395 else if (strmatch(afi_str
, "ipv6"))
397 else if (strmatch(afi_str
, "l2vpn"))
402 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
406 if (argv_find(argv
, argc
, "ipv4", index
)) {
410 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
414 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
422 /* supports <unicast|multicast|vpn|labeled-unicast> */
423 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
425 safi_t safi
= SAFI_MAX
; /* unknown */
426 if (strmatch(safi_str
, "multicast"))
427 safi
= SAFI_MULTICAST
;
428 else if (strmatch(safi_str
, "unicast"))
430 else if (strmatch(safi_str
, "vpn"))
431 safi
= SAFI_MPLS_VPN
;
432 else if (strmatch(safi_str
, "evpn"))
434 else if (strmatch(safi_str
, "labeled-unicast"))
435 safi
= SAFI_LABELED_UNICAST
;
436 else if (strmatch(safi_str
, "flowspec"))
437 safi
= SAFI_FLOWSPEC
;
441 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
445 if (argv_find(argv
, argc
, "unicast", index
)) {
448 *safi
= SAFI_UNICAST
;
449 } else if (argv_find(argv
, argc
, "multicast", index
)) {
452 *safi
= SAFI_MULTICAST
;
453 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
456 *safi
= SAFI_LABELED_UNICAST
;
457 } else if (argv_find(argv
, argc
, "vpn", index
)) {
460 *safi
= SAFI_MPLS_VPN
;
461 } else if (argv_find(argv
, argc
, "evpn", index
)) {
465 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
468 *safi
= SAFI_FLOWSPEC
;
474 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
477 * address-family identifier
480 * subsequent address-family identifier
483 * default_af string corresponding to the supplied afi/safi pair.
484 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
487 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
493 return "ipv4-unicast";
495 return "ipv4-multicast";
500 case SAFI_LABELED_UNICAST
:
501 return "ipv4-labeled-unicast";
503 return "ipv4-flowspec";
505 return "unknown-afi/safi";
511 return "ipv6-unicast";
513 return "ipv6-multicast";
518 case SAFI_LABELED_UNICAST
:
519 return "ipv6-labeled-unicast";
521 return "ipv6-flowspec";
523 return "unknown-afi/safi";
531 return "unknown-afi/safi";
535 return "unknown-afi/safi";
537 /* all AFIs are accounted for above, so this shouldn't happen */
538 return "unknown-afi/safi";
541 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
542 enum bgp_instance_type inst_type
)
544 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
546 if (ret
== BGP_CREATED
) {
547 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
548 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
550 if (DFLT_BGP_IMPORT_CHECK
)
551 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
552 if (DFLT_BGP_SHOW_HOSTNAME
)
553 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
554 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
555 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
556 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
557 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
558 if (DFLT_BGP_DETERMINISTIC_MED
)
559 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
560 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
561 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
562 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
563 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
571 * bgp_vty_find_and_parse_afi_safi_bgp
573 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
574 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
575 * to appropriate values for the calling function. This is to allow the
576 * calling function to make decisions appropriate for the show command
577 * that is being parsed.
579 * The show commands are generally of the form:
580 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
581 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
583 * Since we use argv_find if the show command in particular doesn't have:
585 * [<view|vrf> VIEWVRFNAME]
586 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
587 * The command parsing should still be ok.
589 * vty -> The vty for the command so we can output some useful data in
590 * the event of a parse error in the vrf.
591 * argv -> The command tokens
592 * argc -> How many command tokens we have
593 * idx -> The current place in the command, generally should be 0 for this
595 * afi -> The parsed afi if it was included in the show command, returned here
596 * safi -> The parsed safi if it was included in the show command, returned here
597 * bgp -> Pointer to the bgp data structure we need to fill in.
598 * use_json -> json is configured or not
600 * The function returns the correct location in the parse tree for the
603 * Returns 0 for failure to parse correctly, else the idx position of where
604 * it found the last token.
606 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
607 struct cmd_token
**argv
, int argc
,
608 int *idx
, afi_t
*afi
, safi_t
*safi
,
609 struct bgp
**bgp
, bool use_json
)
611 char *vrf_name
= NULL
;
617 if (argv_find(argv
, argc
, "ip", idx
))
620 if (argv_find(argv
, argc
, "view", idx
))
621 vrf_name
= argv
[*idx
+ 1]->arg
;
622 else if (argv_find(argv
, argc
, "vrf", idx
)) {
623 vrf_name
= argv
[*idx
+ 1]->arg
;
624 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
628 if (strmatch(vrf_name
, "all"))
631 *bgp
= bgp_lookup_by_name(vrf_name
);
634 json_object
*json
= NULL
;
635 json
= json_object_new_object();
636 json_object_string_add(
638 "View/Vrf is unknown");
640 json_object_to_json_string_ext(json
,
641 JSON_C_TO_STRING_PRETTY
));
642 json_object_free(json
);
645 vty_out(vty
, "View/Vrf %s is unknown\n",
652 *bgp
= bgp_get_default();
655 json_object
*json
= NULL
;
656 json
= json_object_new_object();
657 json_object_string_add(
659 "Default BGP instance not found");
661 json_object_to_json_string_ext(json
,
662 JSON_C_TO_STRING_PRETTY
));
663 json_object_free(json
);
667 "Default BGP instance not found\n");
673 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
674 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
680 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
682 struct interface
*ifp
= NULL
;
684 if (su
->sa
.sa_family
== AF_INET
)
685 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
686 else if (su
->sa
.sa_family
== AF_INET6
)
687 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
688 su
->sin6
.sin6_scope_id
,
697 /* Utility function for looking up peer or peer group. */
698 /* This is used only for configuration, so disallow if attempted on
699 * a dynamic neighbor.
701 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
703 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
706 struct peer
*peer
= NULL
;
707 struct peer_group
*group
= NULL
;
713 ret
= str2sockunion(peer_str
, &su
);
715 /* IP address, locate peer. */
716 peer
= peer_lookup(bgp
, &su
);
718 /* Not IP, could match either peer configured on interface or a
720 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
722 group
= peer_group_lookup(bgp
, peer_str
);
726 if (peer_dynamic_neighbor(peer
)) {
728 "%% Operation not allowed on a dynamic neighbor\n");
738 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
743 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
745 const char *str
= NULL
;
748 case BGP_ERR_INVALID_VALUE
:
749 str
= "Invalid value";
751 case BGP_ERR_INVALID_FLAG
:
752 str
= "Invalid flag";
754 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
755 str
= "Peer-group has been shutdown. Activate the peer-group first";
757 case BGP_ERR_PEER_FLAG_CONFLICT
:
758 str
= "Can't set override-capability and strict-capability-match at the same time";
760 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
761 str
= "Specify remote-as or peer-group remote AS first";
763 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
764 str
= "Cannot change the peer-group. Deconfigure first";
766 case BGP_ERR_PEER_GROUP_MISMATCH
:
767 str
= "Peer is not a member of this peer-group";
769 case BGP_ERR_PEER_FILTER_CONFLICT
:
770 str
= "Prefix/distribute list can not co-exist";
772 case BGP_ERR_NOT_INTERNAL_PEER
:
773 str
= "Invalid command. Not an internal neighbor";
775 case BGP_ERR_REMOVE_PRIVATE_AS
:
776 str
= "remove-private-AS cannot be configured for IBGP peers";
778 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
779 str
= "Local-AS allowed only for EBGP peers";
781 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
782 str
= "Cannot have local-as same as BGP AS number";
784 case BGP_ERR_TCPSIG_FAILED
:
785 str
= "Error while applying TCP-Sig to session(s)";
787 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
788 str
= "ebgp-multihop and ttl-security cannot be configured together";
790 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
791 str
= "ttl-security only allowed for EBGP peers";
793 case BGP_ERR_AS_OVERRIDE
:
794 str
= "as-override cannot be configured for IBGP peers";
796 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
797 str
= "Invalid limit for number of dynamic neighbors";
799 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
800 str
= "Dynamic neighbor listen range already exists";
802 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
803 str
= "Operation not allowed on a dynamic neighbor";
805 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
806 str
= "Operation not allowed on a directly connected neighbor";
808 case BGP_ERR_PEER_SAFI_CONFLICT
:
809 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
811 case BGP_ERR_GR_INVALID_CMD
:
812 str
= "The Graceful Restart command used is not valid at this moment.";
814 case BGP_ERR_GR_OPERATION_FAILED
:
815 str
= "The Graceful Restart Operation failed due to an err.";
817 case BGP_ERR_PEER_GROUP_MEMBER
:
818 str
= "Peer-group member cannot override remote-as of peer-group";
820 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
821 str
= "Peer-group members must be all internal or all external";
825 snprintf(errmsg
, errmsg_len
, "%s", str
);
832 int bgp_vty_return(struct vty
*vty
, int ret
)
834 const char *str
= NULL
;
837 case BGP_ERR_INVALID_VALUE
:
838 str
= "Invalid value";
840 case BGP_ERR_INVALID_FLAG
:
841 str
= "Invalid flag";
843 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
844 str
= "Peer-group has been shutdown. Activate the peer-group first";
846 case BGP_ERR_PEER_FLAG_CONFLICT
:
847 str
= "Can't set override-capability and strict-capability-match at the same time";
849 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
850 str
= "Specify remote-as or peer-group remote AS first";
852 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
853 str
= "Cannot change the peer-group. Deconfigure first";
855 case BGP_ERR_PEER_GROUP_MISMATCH
:
856 str
= "Peer is not a member of this peer-group";
858 case BGP_ERR_PEER_FILTER_CONFLICT
:
859 str
= "Prefix/distribute list can not co-exist";
861 case BGP_ERR_NOT_INTERNAL_PEER
:
862 str
= "Invalid command. Not an internal neighbor";
864 case BGP_ERR_REMOVE_PRIVATE_AS
:
865 str
= "remove-private-AS cannot be configured for IBGP peers";
867 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
868 str
= "Local-AS allowed only for EBGP peers";
870 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
871 str
= "Cannot have local-as same as BGP AS number";
873 case BGP_ERR_TCPSIG_FAILED
:
874 str
= "Error while applying TCP-Sig to session(s)";
876 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
877 str
= "ebgp-multihop and ttl-security cannot be configured together";
879 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
880 str
= "ttl-security only allowed for EBGP peers";
882 case BGP_ERR_AS_OVERRIDE
:
883 str
= "as-override cannot be configured for IBGP peers";
885 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
886 str
= "Invalid limit for number of dynamic neighbors";
888 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
889 str
= "Dynamic neighbor listen range already exists";
891 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
892 str
= "Operation not allowed on a dynamic neighbor";
894 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
895 str
= "Operation not allowed on a directly connected neighbor";
897 case BGP_ERR_PEER_SAFI_CONFLICT
:
898 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
900 case BGP_ERR_GR_INVALID_CMD
:
901 str
= "The Graceful Restart command used is not valid at this moment.";
903 case BGP_ERR_GR_OPERATION_FAILED
:
904 str
= "The Graceful Restart Operation failed due to an err.";
908 vty_out(vty
, "%% %s\n", str
);
909 return CMD_WARNING_CONFIG_FAILED
;
914 /* BGP clear sort. */
923 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
924 int error
, char *errmsg
, size_t errmsg_len
)
927 case BGP_ERR_AF_UNCONFIGURED
:
928 snprintf(errmsg
, errmsg_len
,
929 "%%BGP: Enable %s address family for the neighbor %s",
930 get_afi_safi_str(afi
, safi
, false), peer
->host
);
932 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
935 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
943 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
944 struct listnode
**nnode
, enum bgp_clear_type stype
)
949 /* if afi/.safi not specified, spin thru all of them */
950 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
954 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
955 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
956 if (paf
&& paf
->subgroup
)
957 SET_FLAG(paf
->subgroup
->sflags
,
958 SUBGRP_STATUS_FORCE_UPDATES
);
960 if (!peer
->afc
[tmp_afi
][tmp_safi
])
963 if (stype
== BGP_CLEAR_SOFT_NONE
)
964 ret
= peer_clear(peer
, nnode
);
966 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
969 /* if afi specified and safi not, spin thru safis on this afi */
970 } else if (safi
== SAFI_UNSPEC
) {
973 for (tmp_safi
= SAFI_UNICAST
;
974 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
975 if (!peer
->afc
[afi
][tmp_safi
])
978 paf
= peer_af_find(peer
, afi
, tmp_safi
);
979 if (paf
&& paf
->subgroup
)
980 SET_FLAG(paf
->subgroup
->sflags
,
981 SUBGRP_STATUS_FORCE_UPDATES
);
983 if (stype
== BGP_CLEAR_SOFT_NONE
)
984 ret
= peer_clear(peer
, nnode
);
986 ret
= peer_clear_soft(peer
, afi
,
989 /* both afi/safi specified, let the caller know if not defined */
991 if (!peer
->afc
[afi
][safi
])
994 paf
= peer_af_find(peer
, afi
, safi
);
995 if (paf
&& paf
->subgroup
)
996 SET_FLAG(paf
->subgroup
->sflags
,
997 SUBGRP_STATUS_FORCE_UPDATES
);
999 if (stype
== BGP_CLEAR_SOFT_NONE
)
1000 ret
= peer_clear(peer
, nnode
);
1002 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1008 /* `clear ip bgp' functions. */
1009 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1010 enum clear_sort sort
, enum bgp_clear_type stype
,
1011 const char *arg
, char *errmsg
, size_t errmsg_len
)
1017 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1019 /* Clear all neighbors. */
1021 * Pass along pointer to next node to peer_clear() when walking all
1022 * nodes on the BGP instance as that may get freed if it is a
1025 if (sort
== clear_all
) {
1026 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1028 bgp_peer_gr_flags_update(peer
);
1030 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1031 gr_router_detected
= true;
1033 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1037 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1038 errmsg
, errmsg_len
);
1041 if (gr_router_detected
1042 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1043 bgp_zebra_send_capabilities(bgp
, false);
1044 } else if (!gr_router_detected
1045 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1046 bgp_zebra_send_capabilities(bgp
, true);
1049 /* This is to apply read-only mode on this clear. */
1050 if (stype
== BGP_CLEAR_SOFT_NONE
)
1051 bgp
->update_delay_over
= 0;
1056 /* Clear specified neighbor. */
1057 if (sort
== clear_peer
) {
1060 /* Make sockunion for lookup. */
1061 ret
= str2sockunion(arg
, &su
);
1063 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1065 peer
= peer_lookup_by_hostname(bgp
, arg
);
1069 "Malformed address or name: %s",
1075 peer
= peer_lookup(bgp
, &su
);
1077 snprintf(errmsg
, errmsg_len
,
1078 "%%BGP: Unknown neighbor - \"%s\"",
1084 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1085 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1087 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1089 /* if afi/safi not defined for this peer, let caller know */
1091 ret
= BGP_ERR_AF_UNCONFIGURED
;
1094 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1100 /* Clear all neighbors belonging to a specific peer-group. */
1101 if (sort
== clear_group
) {
1102 struct peer_group
*group
;
1104 group
= peer_group_lookup(bgp
, arg
);
1106 snprintf(errmsg
, errmsg_len
,
1107 "%%BGP: No such peer-group %s", arg
);
1111 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1112 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1115 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1116 errmsg
, errmsg_len
);
1124 "%%BGP: No %s peer belonging to peer-group %s is configured",
1125 get_afi_safi_str(afi
, safi
, false), arg
);
1130 /* Clear all external (eBGP) neighbors. */
1131 if (sort
== clear_external
) {
1132 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1133 if (peer
->sort
== BGP_PEER_IBGP
)
1136 bgp_peer_gr_flags_update(peer
);
1138 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1139 gr_router_detected
= true;
1141 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1144 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1145 errmsg
, errmsg_len
);
1150 if (gr_router_detected
1151 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1152 bgp_zebra_send_capabilities(bgp
, false);
1153 } else if (!gr_router_detected
1154 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1155 bgp_zebra_send_capabilities(bgp
, true);
1159 snprintf(errmsg
, errmsg_len
,
1160 "%%BGP: No external %s peer is configured",
1161 get_afi_safi_str(afi
, safi
, false));
1166 /* Clear all neighbors belonging to a specific AS. */
1167 if (sort
== clear_as
) {
1168 as_t as
= strtoul(arg
, NULL
, 10);
1170 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1174 bgp_peer_gr_flags_update(peer
);
1176 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1177 gr_router_detected
= true;
1179 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1182 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1183 errmsg
, errmsg_len
);
1188 if (gr_router_detected
1189 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1190 bgp_zebra_send_capabilities(bgp
, false);
1191 } else if (!gr_router_detected
1192 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1193 bgp_zebra_send_capabilities(bgp
, true);
1197 snprintf(errmsg
, errmsg_len
,
1198 "%%BGP: No %s peer is configured with AS %s",
1199 get_afi_safi_str(afi
, safi
, false), arg
);
1207 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1208 enum clear_sort sort
, enum bgp_clear_type stype
,
1209 const char *arg
, char *errmsg
, size_t errmsg_len
)
1213 /* BGP structure lookup. */
1215 bgp
= bgp_lookup_by_name(name
);
1217 snprintf(errmsg
, errmsg_len
,
1218 "Can't find BGP instance %s", name
);
1222 bgp
= bgp_get_default();
1224 snprintf(errmsg
, errmsg_len
,
1225 "No BGP process is configured");
1230 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1233 /* clear soft inbound */
1234 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1240 FOREACH_AFI_SAFI (afi
, safi
) {
1241 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1242 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1244 if (ret
!= CMD_SUCCESS
)
1251 /* clear soft outbound */
1252 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1258 FOREACH_AFI_SAFI (afi
, safi
) {
1259 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1260 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1262 if (ret
!= CMD_SUCCESS
)
1270 #ifndef VTYSH_EXTRACT_PL
1271 #include "bgpd/bgp_vty_clippy.c"
1274 DEFUN_HIDDEN (bgp_local_mac
,
1276 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1278 "Local MAC config\n"
1279 "VxLAN Network Identifier\n"
1283 "mac-mobility sequence\n"
1293 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1294 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1295 vty_out(vty
, "%% Malformed MAC address\n");
1298 memset(&ip
, 0, sizeof(ip
));
1299 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1301 bgp
= bgp_get_default();
1303 vty_out(vty
, "Default BGP instance is not there\n");
1307 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1310 vty_out(vty
, "Internal error\n");
1317 DEFUN_HIDDEN (no_bgp_local_mac
,
1318 no_bgp_local_mac_cmd
,
1319 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1322 "Local MAC config\n"
1323 "VxLAN Network Identifier\n"
1334 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1335 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1336 vty_out(vty
, "%% Malformed MAC address\n");
1339 memset(&ip
, 0, sizeof(ip
));
1341 bgp
= bgp_get_default();
1343 vty_out(vty
, "Default BGP instance is not there\n");
1347 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1349 vty_out(vty
, "Internal error\n");
1356 DEFUN (no_synchronization
,
1357 no_synchronization_cmd
,
1358 "no synchronization",
1360 "Perform IGP synchronization\n")
1365 DEFUN (no_auto_summary
,
1366 no_auto_summary_cmd
,
1369 "Enable automatic network number summarization\n")
1374 /* "router bgp" commands. */
1375 DEFUN_YANG_NOSH(router_bgp
,
1377 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1378 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1381 int idx_view_vrf
= 3;
1383 int ret
= CMD_SUCCESS
;
1386 const char *name
= NULL
;
1387 enum bgp_instance_type inst_type
;
1388 char base_xpath
[XPATH_MAXLEN
];
1389 const struct lyd_node
*bgp_glb_dnode
;
1391 // "router bgp" without an ASN
1393 // Pending: Make VRF option available for ASN less config
1394 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1395 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1397 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1399 if (!bgp_glb_dnode
) {
1400 vty_out(vty
, "%% No BGP process is configured\n");
1401 return CMD_WARNING_CONFIG_FAILED
;
1404 if (listcount(bm
->bgp
) > 1) {
1405 vty_out(vty
, "%% Please specify ASN and VRF\n");
1406 return CMD_WARNING_CONFIG_FAILED
;
1409 as
= yang_dnode_get_uint32(bgp_glb_dnode
, "./global/local-as");
1411 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1414 * For backward compatibility with old commands we still
1415 * need to use the qobj infrastructure.
1417 bgp
= bgp_lookup(as
, NULL
);
1419 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1427 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1428 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1430 name
= argv
[idx_vrf
]->arg
;
1432 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1433 if (strmatch(name
, VRF_DEFAULT_NAME
))
1436 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1437 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1438 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1441 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1442 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1444 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1445 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1446 argv
[idx_asn
]->arg
);
1447 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1448 nb_cli_enqueue_change(vty
,
1449 "./global/instance-type-view",
1450 NB_OP_MODIFY
, "true");
1452 nb_cli_enqueue_change(vty
,
1453 "./global/instance-type-view",
1454 NB_OP_MODIFY
, "false");
1457 ret
= nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
1458 if (ret
== CMD_SUCCESS
) {
1459 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1462 * For backward compatibility with old commands we still
1463 * need to use the qobj infrastructure.
1465 bgp
= bgp_lookup(as
, name
);
1467 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1474 /* "no router bgp" commands. */
1475 DEFUN_YANG(no_router_bgp
,
1477 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1478 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1481 const char *name
= NULL
;
1482 char base_xpath
[XPATH_MAXLEN
];
1483 const struct lyd_node
*bgp_glb_dnode
;
1485 // "no router bgp" without an ASN
1487 // Pending: Make VRF option available for ASN less config
1488 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1489 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1491 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1493 if (!bgp_glb_dnode
) {
1494 vty_out(vty
, "%% No BGP process is configured\n");
1495 return CMD_WARNING_CONFIG_FAILED
;
1498 if (listcount(bm
->bgp
) > 1) {
1499 vty_out(vty
, "%% Please specify ASN and VRF\n");
1500 return CMD_WARNING_CONFIG_FAILED
;
1504 name
= argv
[idx_vrf
]->arg
;
1506 name
= VRF_DEFAULT_NAME
;
1508 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1509 "frr-bgp:bgp", "bgp", name
);
1512 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1514 /* We want to finish any classic config after a no router */
1515 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
1518 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1521 const struct lyd_node
*vrf_dnode
;
1522 const char *vrf_name
;
1525 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1526 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1527 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1529 vty_out(vty
, "!\n");
1530 vty_out(vty
, "router bgp %u", as
);
1531 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1532 vty_out(vty
, " vrf %s", vrf_name
);
1536 /* BGP router-id. */
1538 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1540 "Override configured router identifier\n"
1541 "Manually configured router identifier\n")
1543 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1546 return nb_cli_apply_changes(vty
, NULL
);
1549 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1551 "Override configured router identifier\n"
1552 "Manually configured router identifier\n")
1554 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1555 router_id_str
? router_id_str
: NULL
);
1557 return nb_cli_apply_changes(vty
, NULL
);
1560 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1563 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1566 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1567 "[no$no] bgp community alias WORD$community WORD$alias",
1569 "Add community specific parameters\n"
1570 "Create an alias for a community\n"
1571 "Community (AA:BB or AA:BB:CC)\n"
1574 struct community_alias ca1
;
1575 struct community_alias ca2
;
1576 struct community_alias
*lookup_community
;
1577 struct community_alias
*lookup_alias
;
1579 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1580 vty_out(vty
, "Invalid community format\n");
1584 memset(&ca1
, 0, sizeof(ca1
));
1585 memset(&ca2
, 0, sizeof(ca2
));
1586 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1587 strlcpy(ca1
.alias
, alias
, sizeof(ca1
.alias
));
1589 lookup_community
= bgp_ca_community_lookup(&ca1
);
1590 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1593 bgp_ca_alias_delete(&ca1
);
1594 bgp_ca_community_delete(&ca1
);
1597 /* Lookup if community hash table has an item
1598 * with the same alias name.
1600 strlcpy(ca2
.community
, lookup_alias
->community
,
1601 sizeof(ca2
.community
));
1602 if (bgp_ca_community_lookup(&ca2
)) {
1604 "community (%s) already has this alias (%s)\n",
1605 lookup_alias
->community
,
1606 lookup_alias
->alias
);
1609 bgp_ca_alias_delete(&ca1
);
1612 if (lookup_community
)
1613 bgp_ca_community_delete(&ca1
);
1615 bgp_ca_alias_insert(&ca1
);
1616 bgp_ca_community_insert(&ca1
);
1622 DEFPY (bgp_global_suppress_fib_pending
,
1623 bgp_global_suppress_fib_pending_cmd
,
1624 "[no] bgp suppress-fib-pending",
1627 "Advertise only routes that are programmed in kernel to peers globally\n")
1629 bm_wait_for_fib_set(!no
);
1634 DEFPY (bgp_suppress_fib_pending
,
1635 bgp_suppress_fib_pending_cmd
,
1636 "[no] bgp suppress-fib-pending",
1639 "Advertise only routes that are programmed in kernel to peers\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1643 bgp_suppress_fib_pending_set(bgp
, !no
);
1648 /* BGP Cluster ID. */
1649 DEFUN_YANG(bgp_cluster_id
,
1651 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1653 "Configure Route-Reflector Cluster-id\n"
1654 "Route-Reflector Cluster-id in IP address format\n"
1655 "Route-Reflector Cluster-id as 32 bit quantity\n")
1659 nb_cli_enqueue_change(
1660 vty
, "./global/route-reflector/route-reflector-cluster-id",
1661 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1663 return nb_cli_apply_changes(vty
, NULL
);
1666 DEFUN_YANG(no_bgp_cluster_id
,
1667 no_bgp_cluster_id_cmd
,
1668 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1670 "Configure Route-Reflector Cluster-id\n"
1671 "Route-Reflector Cluster-id in IP address format\n"
1672 "Route-Reflector Cluster-id as 32 bit quantity\n")
1674 nb_cli_enqueue_change(
1675 vty
, "./global/route-reflector/route-reflector-cluster-id",
1676 NB_OP_DESTROY
, NULL
);
1678 return nb_cli_apply_changes(vty
, NULL
);
1685 "Disable BGP route installation to RIB (Zebra)\n")
1687 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1689 "%% No-RIB option is already set, nothing to do here.\n");
1693 bgp_option_norib_set_runtime();
1698 DEFPY (no_bgp_norib
,
1703 "Disable BGP route installation to RIB (Zebra)\n")
1705 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1707 "%% No-RIB option is not set, nothing to do here.\n");
1711 bgp_option_norib_unset_runtime();
1716 DEFPY (no_bgp_send_extra_data
,
1717 no_bgp_send_extra_data_cmd
,
1718 "[no] bgp send-extra-data zebra",
1721 "Extra data to Zebra for display/use\n"
1725 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1727 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1732 DEFUN_YANG(bgp_confederation_identifier
,
1733 bgp_confederation_identifier_cmd
,
1734 "bgp confederation identifier (1-4294967295)",
1735 "BGP specific commands\n"
1736 "AS confederation parameters\n"
1738 "Set routing domain confederation AS\n")
1742 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1743 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1745 return nb_cli_apply_changes(vty
, NULL
);
1748 DEFUN_YANG(no_bgp_confederation_identifier
,
1749 no_bgp_confederation_identifier_cmd
,
1750 "no bgp confederation identifier [(1-4294967295)]",
1752 "BGP specific commands\n"
1753 "AS confederation parameters\n"
1755 "Set routing domain confederation AS\n")
1757 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1758 NB_OP_DESTROY
, NULL
);
1760 return nb_cli_apply_changes(vty
, NULL
);
1763 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1764 struct lyd_node
*dnode
,
1767 vty_out(vty
, " bgp confederation identifier %u\n",
1768 yang_dnode_get_uint32(dnode
, NULL
));
1771 DEFUN_YANG(bgp_confederation_peers
,
1772 bgp_confederation_peers_cmd
,
1773 "bgp confederation peers (1-4294967295)...",
1774 "BGP specific commands\n"
1775 "AS confederation parameters\n"
1776 "Peer ASs in BGP confederation\n" AS_STR
)
1781 for (i
= idx_asn
; i
< argc
; i
++)
1782 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1783 NB_OP_CREATE
, argv
[i
]->arg
);
1785 return nb_cli_apply_changes(vty
, NULL
);
1788 DEFUN_YANG(no_bgp_confederation_peers
,
1789 no_bgp_confederation_peers_cmd
,
1790 "no bgp confederation peers (1-4294967295)...",
1792 "BGP specific commands\n"
1793 "AS confederation parameters\n"
1794 "Peer ASs in BGP confederation\n" AS_STR
)
1799 for (i
= idx_asn
; i
< argc
; i
++)
1800 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1801 NB_OP_DESTROY
, argv
[i
]->arg
);
1803 return nb_cli_apply_changes(vty
, NULL
);
1806 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1807 struct lyd_node
*dnode
,
1810 vty_out(vty
, " bgp confederation peers %u \n",
1811 yang_dnode_get_uint32(dnode
, NULL
));
1815 * Central routine for maximum-paths configuration.
1816 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1817 * @set: 1 for setting values, 0 for removing the max-paths config.
1819 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1820 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1821 int set
, char *errmsg
, size_t errmsg_len
)
1826 if (maxpaths
> multipath_num
) {
1829 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1830 maxpaths
, multipath_num
);
1831 return CMD_WARNING_CONFIG_FAILED
;
1833 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1836 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1841 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1842 (set
== 1) ? "" : "un",
1843 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1844 maxpaths
, afi
, safi
);
1845 return CMD_WARNING_CONFIG_FAILED
;
1848 bgp_recalculate_all_bestpaths(bgp
);
1853 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1856 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1857 uint32_t med_admin_val
;
1859 vty_out(vty
, " bgp max-med administrative");
1860 med_admin_val
= yang_dnode_get_uint32(dnode
, "./max-med-admin");
1861 if (med_admin_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1862 vty_out(vty
, " %u", med_admin_val
);
1866 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1867 uint32_t onstartup_val
;
1869 vty_out(vty
, " bgp max-med on-startup %u",
1870 yang_dnode_get_uint32(dnode
,
1871 "./max-med-onstart-up-time"));
1872 onstartup_val
= yang_dnode_get_uint32(
1873 dnode
, "./max-med-onstart-up-value");
1874 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1875 vty_out(vty
, " %u", onstartup_val
);
1881 DEFUN_YANG(bgp_maxmed_admin
,
1882 bgp_maxmed_admin_cmd
,
1883 "bgp max-med administrative ",
1885 "Advertise routes with max-med\n"
1886 "Administratively applied, for an indefinite period\n")
1888 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1889 NB_OP_MODIFY
, "true");
1891 return nb_cli_apply_changes(vty
, NULL
);
1894 DEFUN_YANG(bgp_maxmed_admin_medv
,
1895 bgp_maxmed_admin_medv_cmd
,
1896 "bgp max-med administrative (0-4294967295)",
1898 "Advertise routes with max-med\n"
1899 "Administratively applied, for an indefinite period\n"
1900 "Max MED value to be used\n")
1904 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1905 NB_OP_MODIFY
, "true");
1907 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1908 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1910 return nb_cli_apply_changes(vty
, NULL
);
1913 DEFUN_YANG(no_bgp_maxmed_admin
,
1914 no_bgp_maxmed_admin_cmd
,
1915 "no bgp max-med administrative [(0-4294967295)]",
1917 "Advertise routes with max-med\n"
1918 "Administratively applied, for an indefinite period\n"
1919 "Max MED value to be used\n")
1921 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1922 NB_OP_MODIFY
, "false");
1924 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1925 NB_OP_MODIFY
, NULL
);
1927 return nb_cli_apply_changes(vty
, NULL
);
1930 DEFUN_YANG (bgp_maxmed_onstartup
,
1931 bgp_maxmed_onstartup_cmd
,
1932 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1934 "Advertise routes with max-med\n"
1935 "Effective on a startup\n"
1936 "Time (seconds) period for max-med\n"
1937 "Max MED value to be used\n")
1941 argv_find(argv
, argc
, "(5-86400)", &idx
);
1942 nb_cli_enqueue_change(vty
,
1943 "./global/med-config/max-med-onstart-up-time",
1944 NB_OP_MODIFY
, argv
[idx
]->arg
);
1946 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1947 nb_cli_enqueue_change(
1948 vty
, "./global/med-config/max-med-onstart-up-value",
1949 NB_OP_MODIFY
, argv
[idx
]->arg
);
1951 nb_cli_enqueue_change(
1952 vty
, "./global/med-config/max-med-onstart-up-value",
1953 NB_OP_MODIFY
, NULL
);
1955 return nb_cli_apply_changes(vty
, NULL
);
1958 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1959 no_bgp_maxmed_onstartup_cmd
,
1960 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1962 "Advertise routes with max-med\n"
1963 "Effective on a startup\n"
1964 "Time (seconds) period for max-med\n"
1965 "Max MED value to be used\n")
1967 nb_cli_enqueue_change(vty
,
1968 "./global/med-config/max-med-onstart-up-time",
1969 NB_OP_DESTROY
, NULL
);
1971 nb_cli_enqueue_change(vty
,
1972 "./global/med-config/max-med-onstart-up-value",
1973 NB_OP_MODIFY
, NULL
);
1975 return nb_cli_apply_changes(vty
, NULL
);
1978 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1979 uint16_t update_delay
,
1980 uint16_t establish_wait
)
1982 struct listnode
*node
, *nnode
;
1984 bool vrf_cfg
= false;
1987 * See if update-delay is set per-vrf and warn user to delete it
1988 * Note that we only need to check this if this is the first time
1989 * setting the global config.
1991 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1992 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1993 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1995 "%% update-delay configuration found in vrf %s\n",
1996 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2006 "%%Failed: global update-delay config not permitted\n");
2010 if (!establish_wait
) { /* update-delay <delay> */
2011 bm
->v_update_delay
= update_delay
;
2012 bm
->v_establish_wait
= bm
->v_update_delay
;
2014 /* update-delay <delay> <establish-wait> */
2015 if (update_delay
< establish_wait
) {
2017 "%%Failed: update-delay less than the establish-wait!\n");
2018 return CMD_WARNING_CONFIG_FAILED
;
2021 bm
->v_update_delay
= update_delay
;
2022 bm
->v_establish_wait
= establish_wait
;
2025 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2026 bgp
->v_update_delay
= bm
->v_update_delay
;
2027 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2033 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2035 struct listnode
*node
, *nnode
;
2038 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2039 bm
->v_establish_wait
= bm
->v_update_delay
;
2041 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2042 bgp
->v_update_delay
= bm
->v_update_delay
;
2043 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2049 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2050 uint16_t establish_wait
)
2052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2054 /* if configured globally, per-instance config is not allowed */
2055 if (bm
->v_update_delay
) {
2057 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2058 return CMD_WARNING_CONFIG_FAILED
;
2062 if (!establish_wait
) /* update-delay <delay> */
2064 bgp
->v_update_delay
= update_delay
;
2065 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2069 /* update-delay <delay> <establish-wait> */
2070 if (update_delay
< establish_wait
) {
2072 "%%Failed: update-delay less than the establish-wait!\n");
2073 return CMD_WARNING_CONFIG_FAILED
;
2076 bgp
->v_update_delay
= update_delay
;
2077 bgp
->v_establish_wait
= establish_wait
;
2082 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2086 /* If configured globally, cannot remove from one bgp instance */
2087 if (bm
->v_update_delay
) {
2089 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2090 return CMD_WARNING_CONFIG_FAILED
;
2092 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2093 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2098 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2100 /* If configured globally, no need to display per-instance value */
2101 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2102 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2103 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2104 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2109 /* Global update-delay configuration */
2110 DEFPY (bgp_global_update_delay
,
2111 bgp_global_update_delay_cmd
,
2112 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2114 "Force initial delay for best-path and updates for all bgp instances\n"
2115 "Max delay in seconds\n"
2116 "Establish wait in seconds\n")
2118 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2121 /* Global update-delay deconfiguration */
2122 DEFPY (no_bgp_global_update_delay
,
2123 no_bgp_global_update_delay_cmd
,
2124 "no bgp update-delay [(0-3600) [(1-3600)]]",
2127 "Force initial delay for best-path and updates\n"
2128 "Max delay in seconds\n"
2129 "Establish wait in seconds\n")
2131 return bgp_global_update_delay_deconfig_vty(vty
);
2134 /* Update-delay configuration */
2136 DEFPY (bgp_update_delay
,
2137 bgp_update_delay_cmd
,
2138 "update-delay (0-3600)$delay [(1-3600)$wait]",
2139 "Force initial delay for best-path and updates\n"
2140 "Max delay in seconds\n"
2141 "Establish wait in seconds\n")
2143 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2146 /* Update-delay deconfiguration */
2147 DEFPY (no_bgp_update_delay
,
2148 no_bgp_update_delay_cmd
,
2149 "no update-delay [(0-3600) [(1-3600)]]",
2151 "Force initial delay for best-path and updates\n"
2152 "Max delay in seconds\n"
2153 "Establish wait in seconds\n")
2155 return bgp_update_delay_deconfig_vty(vty
);
2159 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2161 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2162 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2167 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2169 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2170 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2175 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2178 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2179 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2180 vty_out(vty
, " write-quanta %d\n", quanta
);
2183 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2186 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2187 if (quanta
!= BGP_READ_PACKET_MAX
)
2188 vty_out(vty
, " read-quanta %d\n", quanta
);
2191 /* Packet quanta configuration
2193 * XXX: The value set here controls the size of a stack buffer in the IO
2194 * thread. When changing these limits be careful to prevent stack overflow.
2196 * Furthermore, the maximums used here should correspond to
2197 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2199 DEFPY_YANG (bgp_wpkt_quanta
,
2200 bgp_wpkt_quanta_cmd
,
2201 "[no] write-quanta (1-64)$quanta",
2203 "How many packets to write to peer socket per run\n"
2204 "Number of packets\n")
2207 nb_cli_enqueue_change(
2209 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2210 NB_OP_MODIFY
, quanta_str
);
2212 nb_cli_enqueue_change(
2214 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2215 NB_OP_MODIFY
, NULL
);
2217 return nb_cli_apply_changes(vty
, NULL
);
2220 DEFPY_YANG (bgp_rpkt_quanta
,
2221 bgp_rpkt_quanta_cmd
,
2222 "[no] read-quanta (1-10)$quanta",
2224 "How many packets to read from peer socket per I/O cycle\n"
2225 "Number of packets\n")
2228 nb_cli_enqueue_change(
2230 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2231 NB_OP_MODIFY
, quanta_str
);
2233 nb_cli_enqueue_change(
2235 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2236 NB_OP_MODIFY
, NULL
);
2238 return nb_cli_apply_changes(vty
, NULL
);
2241 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2243 if (!bgp
->heuristic_coalesce
)
2244 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2247 void cli_show_router_global_update_group_config_coalesce_time(
2248 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2250 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2254 DEFUN_YANG (bgp_coalesce_time
,
2255 bgp_coalesce_time_cmd
,
2256 "coalesce-time (0-4294967295)",
2257 "Subgroup coalesce timer\n"
2258 "Subgroup coalesce timer value (in ms)\n")
2262 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2263 nb_cli_enqueue_change(
2264 vty
, "./global/global-update-group-config/coalesce-time",
2265 NB_OP_MODIFY
, argv
[idx
]->arg
);
2267 return nb_cli_apply_changes(vty
, NULL
);
2270 DEFUN_YANG(no_bgp_coalesce_time
,
2271 no_bgp_coalesce_time_cmd
,
2272 "no coalesce-time (0-4294967295)",
2274 "Subgroup coalesce timer\n"
2275 "Subgroup coalesce timer value (in ms)\n")
2277 nb_cli_enqueue_change(
2278 vty
, "./global/global-update-group-config/coalesce-time",
2279 NB_OP_MODIFY
, NULL
);
2281 return nb_cli_apply_changes(vty
, NULL
);
2284 /* Maximum-paths configuration */
2285 DEFUN_YANG (bgp_maxpaths
,
2287 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2288 "Forward packets over multiple paths\n"
2289 "Number of paths\n")
2292 char base_xpath
[XPATH_MAXLEN
];
2296 afi
= bgp_node_afi(vty
);
2297 safi
= bgp_node_safi(vty
);
2300 base_xpath
, sizeof(base_xpath
),
2301 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2302 yang_afi_safi_value2identity(afi
, safi
),
2303 bgp_afi_safi_get_container_str(afi
, safi
));
2305 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2306 argv
[idx_number
]->arg
);
2308 return nb_cli_apply_changes(vty
, NULL
);
2311 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2312 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2314 vty_out(vty
, " maximum-paths %d\n",
2315 yang_dnode_get_uint16(dnode
, NULL
));
2318 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2319 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2320 "Forward packets over multiple paths\n"
2321 "Number of paths\n")
2323 DEFUN_YANG (bgp_maxpaths_ibgp
,
2324 bgp_maxpaths_ibgp_cmd
,
2325 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2326 "Forward packets over multiple paths\n"
2328 "Number of paths\n")
2331 char base_xpath
[XPATH_MAXLEN
];
2335 afi
= bgp_node_afi(vty
);
2336 safi
= bgp_node_safi(vty
);
2339 base_xpath
, sizeof(base_xpath
),
2340 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2341 yang_afi_safi_value2identity(afi
, safi
),
2342 bgp_afi_safi_get_container_str(afi
, safi
));
2344 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2345 argv
[idx_number
]->arg
);
2347 return nb_cli_apply_changes(vty
, NULL
);
2350 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2351 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2352 "Forward packets over multiple paths\n"
2354 "Number of paths\n")
2356 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2357 bgp_maxpaths_ibgp_cluster_cmd
,
2358 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2359 "Forward packets over multiple paths\n"
2362 "Match the cluster length\n")
2365 char base_xpath
[XPATH_MAXLEN
];
2369 afi
= bgp_node_afi(vty
);
2370 safi
= bgp_node_safi(vty
);
2373 base_xpath
, sizeof(base_xpath
),
2374 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2375 yang_afi_safi_value2identity(afi
, safi
),
2376 bgp_afi_safi_get_container_str(afi
, safi
));
2378 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2379 argv
[idx_number
]->arg
);
2382 base_xpath
, sizeof(base_xpath
),
2383 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2384 yang_afi_safi_value2identity(afi
, safi
),
2385 bgp_afi_safi_get_container_str(afi
, safi
));
2387 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2389 return nb_cli_apply_changes(vty
, NULL
);
2392 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2393 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2395 vty_out(vty
, " maximum-paths ibgp %d",
2396 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2397 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2398 vty_out(vty
, " equal-cluster-length");
2402 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2403 "maximum-paths ibgp " CMD_RANGE_STR(
2404 1, MULTIPATH_NUM
) " equal-cluster-length",
2405 "Forward packets over multiple paths\n"
2408 "Match the cluster length\n")
2410 DEFUN_YANG (no_bgp_maxpaths
,
2411 no_bgp_maxpaths_cmd
,
2412 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2414 "Forward packets over multiple paths\n"
2415 "Number of paths\n")
2417 char base_xpath
[XPATH_MAXLEN
];
2421 afi
= bgp_node_afi(vty
);
2422 safi
= bgp_node_safi(vty
);
2425 base_xpath
, sizeof(base_xpath
),
2426 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2427 yang_afi_safi_value2identity(afi
, safi
),
2428 bgp_afi_safi_get_container_str(afi
, safi
));
2430 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2432 return nb_cli_apply_changes(vty
, NULL
);
2435 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2436 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2437 "Forward packets over multiple paths\n"
2438 "Number of paths\n")
2440 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2441 no_bgp_maxpaths_ibgp_cmd
,
2442 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2444 "Forward packets over multiple paths\n"
2447 "Match the cluster length\n")
2449 char base_xpath
[XPATH_MAXLEN
];
2453 afi
= bgp_node_afi(vty
);
2454 safi
= bgp_node_safi(vty
);
2457 base_xpath
, sizeof(base_xpath
),
2458 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2459 yang_afi_safi_value2identity(afi
, safi
),
2460 bgp_afi_safi_get_container_str(afi
, safi
));
2462 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2465 base_xpath
, sizeof(base_xpath
),
2466 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2467 yang_afi_safi_value2identity(afi
, safi
),
2468 bgp_afi_safi_get_container_str(afi
, safi
));
2470 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2472 return nb_cli_apply_changes(vty
, NULL
);
2475 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2476 "no maximum-paths ibgp [" CMD_RANGE_STR(
2477 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2479 "Forward packets over multiple paths\n"
2482 "Match the cluster length\n")
2484 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2485 afi_t afi
, safi_t safi
)
2487 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2488 vty_out(vty
, " maximum-paths %d\n",
2489 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2492 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2493 vty_out(vty
, " maximum-paths ibgp %d",
2494 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2495 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2496 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2497 vty_out(vty
, " equal-cluster-length");
2504 DEFUN_YANG (bgp_timers
,
2506 "timers bgp (0-65535) (0-65535)",
2507 "Adjust routing timers\n"
2509 "Keepalive interval\n"
2513 int idx_number_2
= 3;
2515 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2516 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2517 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2518 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2520 return nb_cli_apply_changes(vty
, NULL
);
2523 DEFUN_YANG (no_bgp_timers
,
2525 "no timers bgp [(0-65535) (0-65535)]",
2527 "Adjust routing timers\n"
2529 "Keepalive interval\n"
2532 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2533 NB_OP_DESTROY
, NULL
);
2534 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2535 NB_OP_DESTROY
, NULL
);
2537 return nb_cli_apply_changes(vty
, NULL
);
2540 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2541 struct lyd_node
*dnode
,
2544 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2545 vty_out(vty
, " no bgp client-to-client reflection\n");
2547 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2548 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2550 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2551 vty_out(vty
, " bgp cluster-id %s\n",
2552 yang_dnode_get_string(dnode
,
2553 "./route-reflector-cluster-id"));
2556 DEFUN_YANG(bgp_client_to_client_reflection
,
2557 bgp_client_to_client_reflection_cmd
,
2558 "bgp client-to-client reflection",
2559 "BGP specific commands\n"
2560 "Configure client to client route reflection\n"
2561 "reflection of routes allowed\n")
2563 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2564 NB_OP_MODIFY
, "false");
2566 return nb_cli_apply_changes(vty
, NULL
);
2569 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2570 no_bgp_client_to_client_reflection_cmd
,
2571 "no bgp client-to-client reflection",
2573 "BGP specific commands\n"
2574 "Configure client to client route reflection\n"
2575 "reflection of routes allowed\n")
2577 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2578 NB_OP_MODIFY
, "true");
2580 return nb_cli_apply_changes(vty
, NULL
);
2583 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2584 struct lyd_node
*dnode
,
2588 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2589 vty_out(vty
, " bgp always-compare-med\n");
2591 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2592 vty_out(vty
, " bgp bestpath as-path ignore\n");
2594 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2595 vty_out(vty
, " bgp bestpath as-path confed\n");
2597 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2598 vty_out(vty
, " bgp bestpath compare-routerid\n");
2600 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2601 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2603 " bgp bestpath as-path multipath-relax as-set\n");
2605 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2608 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2609 vty_out(vty
, " bgp deterministic-med\n");
2611 if (yang_dnode_get_bool(dnode
, "./confed-med")
2612 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2613 vty_out(vty
, " bgp bestpath med");
2614 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2615 vty_out(vty
, " confed");
2616 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2617 vty_out(vty
, " missing-as-worst");
2622 /* "bgp always-compare-med" configuration. */
2623 DEFUN_YANG(bgp_always_compare_med
,
2624 bgp_always_compare_med_cmd
,
2625 "bgp always-compare-med",
2626 "BGP specific commands\n"
2627 "Allow comparing MED from different neighbors\n")
2629 nb_cli_enqueue_change(
2630 vty
, "./global/route-selection-options/always-compare-med",
2631 NB_OP_MODIFY
, "true");
2633 return nb_cli_apply_changes(vty
, NULL
);
2636 DEFUN_YANG(no_bgp_always_compare_med
,
2637 no_bgp_always_compare_med_cmd
,
2638 "no bgp always-compare-med",
2640 "BGP specific commands\n"
2641 "Allow comparing MED from different neighbors\n")
2643 nb_cli_enqueue_change(
2644 vty
, "./global/route-selection-options/always-compare-med",
2645 NB_OP_MODIFY
, "false");
2647 return nb_cli_apply_changes(vty
, NULL
);
2650 DEFUN_YANG(bgp_suppress_duplicates
,
2651 bgp_suppress_duplicates_cmd
,
2652 "bgp suppress-duplicates",
2653 "BGP specific commands\n"
2654 "Suppress duplicate updates if the route actually not changed\n")
2656 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2657 NB_OP_MODIFY
, "true");
2658 return nb_cli_apply_changes(vty
, NULL
);
2661 DEFUN_YANG(no_bgp_suppress_duplicates
,
2662 no_bgp_suppress_duplicates_cmd
,
2663 "no bgp suppress-duplicates",
2665 "BGP specific commands\n"
2666 "Suppress duplicate updates if the route actually not changed\n")
2668 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2669 NB_OP_MODIFY
, "false");
2670 return nb_cli_apply_changes(vty
, NULL
);
2673 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2674 struct lyd_node
*dnode
,
2677 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2678 vty_out(vty
, " bgp suppress-duplicates\n");
2681 DEFUN_YANG(bgp_ebgp_requires_policy
,
2682 bgp_ebgp_requires_policy_cmd
,
2683 "bgp ebgp-requires-policy",
2684 "BGP specific commands\n"
2685 "Require in and out policy for eBGP peers (RFC8212)\n")
2687 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2688 NB_OP_MODIFY
, "true");
2689 return nb_cli_apply_changes(vty
, NULL
);
2692 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2693 no_bgp_ebgp_requires_policy_cmd
,
2694 "no bgp ebgp-requires-policy",
2696 "BGP specific commands\n"
2697 "Require in and out policy for eBGP peers (RFC8212)\n")
2699 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2700 NB_OP_MODIFY
, "false");
2701 return nb_cli_apply_changes(vty
, NULL
);
2704 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2705 struct lyd_node
*dnode
,
2708 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2709 vty_out(vty
, " bgp ebgp-requires-policy\n");
2712 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2713 "bgp reject-as-sets",
2714 "BGP specific commands\n"
2715 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2717 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2718 struct listnode
*node
, *nnode
;
2721 bgp
->reject_as_sets
= true;
2723 /* Reset existing BGP sessions to reject routes
2724 * with aspath containing AS_SET or AS_CONFED_SET.
2726 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2727 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2728 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2729 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2730 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2737 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2738 "no bgp reject-as-sets",
2740 "BGP specific commands\n"
2741 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2744 struct listnode
*node
, *nnode
;
2747 bgp
->reject_as_sets
= false;
2749 /* Reset existing BGP sessions to reject routes
2750 * with aspath containing AS_SET or AS_CONFED_SET.
2752 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2753 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2754 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2755 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2756 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2763 /* "bgp deterministic-med" configuration. */
2764 DEFUN_YANG (bgp_deterministic_med
,
2765 bgp_deterministic_med_cmd
,
2766 "bgp deterministic-med",
2767 "BGP specific commands\n"
2768 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2770 nb_cli_enqueue_change(
2771 vty
, "./global/route-selection-options/deterministic-med",
2772 NB_OP_MODIFY
, "true");
2774 return nb_cli_apply_changes(vty
, NULL
);
2777 DEFUN_YANG (no_bgp_deterministic_med
,
2778 no_bgp_deterministic_med_cmd
,
2779 "no bgp deterministic-med",
2781 "BGP specific commands\n"
2782 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2784 nb_cli_enqueue_change(
2785 vty
, "./global/route-selection-options/deterministic-med",
2786 NB_OP_MODIFY
, "false");
2788 return nb_cli_apply_changes(vty
, NULL
);
2791 /* "bgp graceful-restart mode" configuration. */
2792 DEFUN (bgp_graceful_restart
,
2793 bgp_graceful_restart_cmd
,
2794 "bgp graceful-restart",
2795 "BGP specific commands\n"
2799 int ret
= BGP_GR_FAILURE
;
2801 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2802 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2806 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2808 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2811 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2812 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2814 "Graceful restart configuration changed, reset all peers to take effect\n");
2815 return bgp_vty_return(vty
, ret
);
2818 DEFUN (no_bgp_graceful_restart
,
2819 no_bgp_graceful_restart_cmd
,
2820 "no bgp graceful-restart",
2822 "BGP specific commands\n"
2826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2828 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2829 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2831 int ret
= BGP_GR_FAILURE
;
2833 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2835 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2838 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2839 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2841 "Graceful restart configuration changed, reset all peers to take effect\n");
2843 return bgp_vty_return(vty
, ret
);
2846 DEFUN (bgp_graceful_restart_stalepath_time
,
2847 bgp_graceful_restart_stalepath_time_cmd
,
2848 "bgp graceful-restart stalepath-time (1-4095)",
2849 "BGP specific commands\n"
2850 "Graceful restart capability parameters\n"
2851 "Set the max time to hold onto restarting peer's stale paths\n"
2852 "Delay value (seconds)\n")
2854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2858 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2859 bgp
->stalepath_time
= stalepath
;
2863 DEFUN (bgp_graceful_restart_restart_time
,
2864 bgp_graceful_restart_restart_time_cmd
,
2865 "bgp graceful-restart restart-time (1-4095)",
2866 "BGP specific commands\n"
2867 "Graceful restart capability parameters\n"
2868 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2869 "Delay value (seconds)\n")
2871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2875 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2876 bgp
->restart_time
= restart
;
2880 DEFUN (bgp_graceful_restart_select_defer_time
,
2881 bgp_graceful_restart_select_defer_time_cmd
,
2882 "bgp graceful-restart select-defer-time (0-3600)",
2883 "BGP specific commands\n"
2884 "Graceful restart capability parameters\n"
2885 "Set the time to defer the BGP route selection after restart\n"
2886 "Delay value (seconds, 0 - disable)\n")
2888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2890 uint32_t defer_time
;
2892 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2893 bgp
->select_defer_time
= defer_time
;
2894 if (defer_time
== 0)
2895 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2897 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2902 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2903 no_bgp_graceful_restart_stalepath_time_cmd
,
2904 "no bgp graceful-restart stalepath-time [(1-4095)]",
2906 "BGP specific commands\n"
2907 "Graceful restart capability parameters\n"
2908 "Set the max time to hold onto restarting peer's stale paths\n"
2909 "Delay value (seconds)\n")
2911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2913 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2917 DEFUN (no_bgp_graceful_restart_restart_time
,
2918 no_bgp_graceful_restart_restart_time_cmd
,
2919 "no bgp graceful-restart restart-time [(1-4095)]",
2921 "BGP specific commands\n"
2922 "Graceful restart capability parameters\n"
2923 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2924 "Delay value (seconds)\n")
2926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2928 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2932 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2933 no_bgp_graceful_restart_select_defer_time_cmd
,
2934 "no bgp graceful-restart select-defer-time [(0-3600)]",
2936 "BGP specific commands\n"
2937 "Graceful restart capability parameters\n"
2938 "Set the time to defer the BGP route selection after restart\n"
2939 "Delay value (seconds)\n")
2941 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2943 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2944 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2949 DEFUN (bgp_graceful_restart_preserve_fw
,
2950 bgp_graceful_restart_preserve_fw_cmd
,
2951 "bgp graceful-restart preserve-fw-state",
2952 "BGP specific commands\n"
2953 "Graceful restart capability parameters\n"
2954 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2957 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2961 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2962 no_bgp_graceful_restart_preserve_fw_cmd
,
2963 "no bgp graceful-restart preserve-fw-state",
2965 "BGP specific commands\n"
2966 "Graceful restart capability parameters\n"
2967 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2970 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2974 DEFUN (bgp_graceful_restart_disable
,
2975 bgp_graceful_restart_disable_cmd
,
2976 "bgp graceful-restart-disable",
2977 "BGP specific commands\n"
2980 int ret
= BGP_GR_FAILURE
;
2982 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2984 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2988 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2990 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2993 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2995 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2997 "Graceful restart configuration changed, reset all peers to take effect\n");
2999 return bgp_vty_return(vty
, ret
);
3002 DEFUN (no_bgp_graceful_restart_disable
,
3003 no_bgp_graceful_restart_disable_cmd
,
3004 "no bgp graceful-restart-disable",
3006 "BGP specific commands\n"
3010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3012 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3014 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3016 int ret
= BGP_GR_FAILURE
;
3018 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3020 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3023 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3025 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3027 "Graceful restart configuration changed, reset all peers to take effect\n");
3029 return bgp_vty_return(vty
, ret
);
3032 DEFUN (bgp_neighbor_graceful_restart_set
,
3033 bgp_neighbor_graceful_restart_set_cmd
,
3034 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3042 int ret
= BGP_GR_FAILURE
;
3044 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3046 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3048 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3050 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3052 return CMD_WARNING_CONFIG_FAILED
;
3054 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3056 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3057 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3059 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3061 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3063 "Graceful restart configuration changed, reset this peer to take effect\n");
3065 return bgp_vty_return(vty
, ret
);
3068 DEFUN (no_bgp_neighbor_graceful_restart
,
3069 no_bgp_neighbor_graceful_restart_set_cmd
,
3070 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3078 int ret
= BGP_GR_FAILURE
;
3081 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3083 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3085 return CMD_WARNING_CONFIG_FAILED
;
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3091 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3093 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3094 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3096 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3098 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3100 "Graceful restart configuration changed, reset this peer to take effect\n");
3102 return bgp_vty_return(vty
, ret
);
3105 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3106 bgp_neighbor_graceful_restart_helper_set_cmd
,
3107 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3110 GR_NEIGHBOR_HELPER_CMD
3115 int ret
= BGP_GR_FAILURE
;
3117 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3119 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3121 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3123 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3126 return CMD_WARNING_CONFIG_FAILED
;
3129 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3131 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3132 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3134 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3136 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3138 "Graceful restart configuration changed, reset this peer to take effect\n");
3140 return bgp_vty_return(vty
, ret
);
3143 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3144 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3145 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3149 NO_GR_NEIGHBOR_HELPER_CMD
3153 int ret
= BGP_GR_FAILURE
;
3156 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3160 return CMD_WARNING_CONFIG_FAILED
;
3162 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3164 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3166 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3168 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3169 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3171 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3173 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3175 "Graceful restart configuration changed, reset this peer to take effect\n");
3177 return bgp_vty_return(vty
, ret
);
3180 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3181 bgp_neighbor_graceful_restart_disable_set_cmd
,
3182 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3185 GR_NEIGHBOR_DISABLE_CMD
3190 int ret
= BGP_GR_FAILURE
;
3192 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3194 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3196 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3198 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3200 return CMD_WARNING_CONFIG_FAILED
;
3202 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3204 if (peer
->bgp
->t_startup
)
3205 bgp_peer_gr_flags_update(peer
);
3207 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3208 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3210 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3212 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3214 "Graceful restart configuration changed, reset this peer to take effect\n");
3216 return bgp_vty_return(vty
, ret
);
3219 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3220 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3221 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3225 NO_GR_NEIGHBOR_DISABLE_CMD
3229 int ret
= BGP_GR_FAILURE
;
3232 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3234 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3236 return CMD_WARNING_CONFIG_FAILED
;
3238 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3240 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3242 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3244 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3245 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3247 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3249 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3251 "Graceful restart configuration changed, reset this peer to take effect\n");
3253 return bgp_vty_return(vty
, ret
);
3256 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3257 bgp_graceful_restart_disable_eor_cmd
,
3258 "bgp graceful-restart disable-eor",
3259 "BGP specific commands\n"
3260 "Graceful restart configuration parameters\n"
3261 "Disable EOR Check\n")
3263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3264 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3269 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3270 no_bgp_graceful_restart_disable_eor_cmd
,
3271 "no bgp graceful-restart disable-eor",
3273 "BGP specific commands\n"
3274 "Graceful restart configuration parameters\n"
3275 "Disable EOR Check\n")
3277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3278 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3283 DEFUN (bgp_graceful_restart_rib_stale_time
,
3284 bgp_graceful_restart_rib_stale_time_cmd
,
3285 "bgp graceful-restart rib-stale-time (1-3600)",
3286 "BGP specific commands\n"
3287 "Graceful restart configuration parameters\n"
3288 "Specify the stale route removal timer in rib\n"
3289 "Delay value (seconds)\n")
3291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3293 uint32_t stale_time
;
3295 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3296 bgp
->rib_stale_time
= stale_time
;
3297 /* Send the stale timer update message to RIB */
3298 if (bgp_zebra_stale_timer_update(bgp
))
3304 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3305 no_bgp_graceful_restart_rib_stale_time_cmd
,
3306 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3308 "BGP specific commands\n"
3309 "Graceful restart configuration parameters\n"
3310 "Specify the stale route removal timer in rib\n"
3311 "Delay value (seconds)\n")
3313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3315 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3316 /* Send the stale timer update message to RIB */
3317 if (bgp_zebra_stale_timer_update(bgp
))
3323 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3327 bgp_static_redo_import_check(bgp
);
3328 bgp_redistribute_redo(bgp
);
3329 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3331 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3337 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3339 struct listnode
*node
, *nnode
;
3341 bool vrf_cfg
= false;
3342 char errmsg
[BUFSIZ
] = {'\0'};
3344 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3347 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3348 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3349 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3351 "%% graceful-shutdown configuration found in vrf %s\n",
3352 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3353 VRF_DEFAULT_NAME
: bgp
->name
);
3360 "%%Failed: global graceful-shutdown not permitted\n");
3364 /* Set flag globally */
3365 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3367 /* Initiate processing for all BGP instances. */
3368 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3369 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3373 vty_out(vty
, "%s\n", errmsg
);
3379 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3381 struct listnode
*node
, *nnode
;
3383 char errmsg
[BUFSIZ
] = {'\0'};
3385 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3388 /* Unset flag globally */
3389 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3391 /* Initiate processing for all BGP instances. */
3392 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3393 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3397 vty_out(vty
, "%s\n", errmsg
);
3403 /* "bgp graceful-shutdown" configuration */
3404 DEFUN (bgp_graceful_shutdown
,
3405 bgp_graceful_shutdown_cmd
,
3406 "bgp graceful-shutdown",
3408 "Graceful shutdown parameters\n")
3410 if (vty
->node
== CONFIG_NODE
)
3411 return bgp_global_graceful_shutdown_config_vty(vty
);
3413 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3414 NB_OP_MODIFY
, "true");
3416 return nb_cli_apply_changes(vty
, NULL
);
3419 DEFUN_YANG (no_bgp_graceful_shutdown
,
3420 no_bgp_graceful_shutdown_cmd
,
3421 "no bgp graceful-shutdown",
3424 "Graceful shutdown parameters\n")
3426 if (vty
->node
== CONFIG_NODE
)
3427 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3429 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3430 NB_OP_MODIFY
, "false");
3432 return nb_cli_apply_changes(vty
, NULL
);
3435 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3436 struct lyd_node
*dnode
,
3439 if (yang_dnode_get_bool(dnode
, NULL
))
3440 vty_out(vty
, " bgp graceful-shutdown\n");
3443 /* "bgp fast-external-failover" configuration. */
3444 DEFUN_YANG (bgp_fast_external_failover
,
3445 bgp_fast_external_failover_cmd
,
3446 "bgp fast-external-failover",
3448 "Immediately reset session if a link to a directly connected external peer goes down\n")
3450 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3451 NB_OP_MODIFY
, "false");
3453 return nb_cli_apply_changes(vty
, NULL
);
3456 DEFUN_YANG (no_bgp_fast_external_failover
,
3457 no_bgp_fast_external_failover_cmd
,
3458 "no bgp fast-external-failover",
3461 "Immediately reset session if a link to a directly connected external peer goes down\n")
3463 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3464 NB_OP_MODIFY
, "true");
3466 return nb_cli_apply_changes(vty
, NULL
);
3469 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3470 struct lyd_node
*dnode
,
3473 if (!yang_dnode_get_bool(dnode
, NULL
))
3474 vty_out(vty
, " no bgp fast-external-failover\n");
3477 /* "bgp bestpath compare-routerid" configuration. */
3478 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3479 bgp_bestpath_compare_router_id_cmd
,
3480 "bgp bestpath compare-routerid",
3481 "BGP specific commands\n"
3482 "Change the default bestpath selection\n"
3483 "Compare router-id for identical EBGP paths\n")
3485 nb_cli_enqueue_change(
3487 "./global/route-selection-options/external-compare-router-id",
3488 NB_OP_MODIFY
, "true");
3490 return nb_cli_apply_changes(vty
, NULL
);
3493 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3494 no_bgp_bestpath_compare_router_id_cmd
,
3495 "no bgp bestpath compare-routerid",
3497 "BGP specific commands\n"
3498 "Change the default bestpath selection\n"
3499 "Compare router-id for identical EBGP paths\n")
3501 nb_cli_enqueue_change(
3503 "./global/route-selection-options/external-compare-router-id",
3504 NB_OP_MODIFY
, "false");
3506 return nb_cli_apply_changes(vty
, NULL
);
3509 /* "bgp bestpath as-path ignore" configuration. */
3510 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3511 bgp_bestpath_aspath_ignore_cmd
,
3512 "bgp bestpath as-path ignore",
3513 "BGP specific commands\n"
3514 "Change the default bestpath selection\n"
3515 "AS-path attribute\n"
3516 "Ignore as-path length in selecting a route\n")
3518 nb_cli_enqueue_change(
3519 vty
, "./global/route-selection-options/ignore-as-path-length",
3520 NB_OP_MODIFY
, "true");
3522 return nb_cli_apply_changes(vty
, NULL
);
3525 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3526 no_bgp_bestpath_aspath_ignore_cmd
,
3527 "no bgp bestpath as-path ignore",
3529 "BGP specific commands\n"
3530 "Change the default bestpath selection\n"
3531 "AS-path attribute\n"
3532 "Ignore as-path length in selecting a route\n")
3534 nb_cli_enqueue_change(
3535 vty
, "./global/route-selection-options/ignore-as-path-length",
3536 NB_OP_MODIFY
, "false");
3538 return nb_cli_apply_changes(vty
, NULL
);
3541 /* "bgp bestpath as-path confed" configuration. */
3542 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3543 bgp_bestpath_aspath_confed_cmd
,
3544 "bgp bestpath as-path confed",
3545 "BGP specific commands\n"
3546 "Change the default bestpath selection\n"
3547 "AS-path attribute\n"
3548 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3550 nb_cli_enqueue_change(vty
,
3551 "./global/route-selection-options/aspath-confed",
3552 NB_OP_MODIFY
, "true");
3554 return nb_cli_apply_changes(vty
, NULL
);
3557 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3558 no_bgp_bestpath_aspath_confed_cmd
,
3559 "no bgp bestpath as-path confed",
3561 "BGP specific commands\n"
3562 "Change the default bestpath selection\n"
3563 "AS-path attribute\n"
3564 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3566 nb_cli_enqueue_change(vty
,
3567 "./global/route-selection-options/aspath-confed",
3568 NB_OP_MODIFY
, "false");
3570 return nb_cli_apply_changes(vty
, NULL
);
3573 /* "bgp bestpath as-path multipath-relax" configuration. */
3574 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3575 bgp_bestpath_aspath_multipath_relax_cmd
,
3576 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3577 "BGP specific commands\n"
3578 "Change the default bestpath selection\n"
3579 "AS-path attribute\n"
3580 "Allow load sharing across routes that have different AS paths (but same length)\n"
3581 "Generate an AS_SET\n"
3582 "Do not generate an AS_SET\n")
3586 nb_cli_enqueue_change(
3587 vty
, "./global/route-selection-options/allow-multiple-as",
3588 NB_OP_MODIFY
, "true");
3589 if (argv_find(argv
, argc
, "as-set", &idx
))
3590 nb_cli_enqueue_change(
3592 "./global/route-selection-options/multi-path-as-set",
3593 NB_OP_MODIFY
, "true");
3595 nb_cli_enqueue_change(
3597 "./global/route-selection-options/multi-path-as-set",
3598 NB_OP_MODIFY
, "false");
3600 return nb_cli_apply_changes(vty
, NULL
);
3603 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3604 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3605 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3607 "BGP specific commands\n"
3608 "Change the default bestpath selection\n"
3609 "AS-path attribute\n"
3610 "Allow load sharing across routes that have different AS paths (but same length)\n"
3611 "Generate an AS_SET\n"
3612 "Do not generate an AS_SET\n")
3614 nb_cli_enqueue_change(
3615 vty
, "./global/route-selection-options/allow-multiple-as",
3616 NB_OP_MODIFY
, "false");
3617 nb_cli_enqueue_change(
3618 vty
, "./global/route-selection-options/multi-path-as-set",
3619 NB_OP_MODIFY
, "false");
3621 return nb_cli_apply_changes(vty
, NULL
);
3624 /* "bgp bestpath peer-type multipath-relax" configuration. */
3625 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3626 bgp_bestpath_peer_type_multipath_relax_cmd
,
3627 "bgp bestpath peer-type multipath-relax",
3629 "Change the default bestpath selection\n"
3631 "Allow load sharing across routes learned from different peer types\n")
3633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3634 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3635 bgp_recalculate_all_bestpaths(bgp
);
3640 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3641 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3642 "no bgp bestpath peer-type multipath-relax",
3644 "Change the default bestpath selection\n"
3646 "Allow load sharing across routes learned from different peer types\n")
3648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3649 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3650 bgp_recalculate_all_bestpaths(bgp
);
3655 /* "bgp log-neighbor-changes" configuration. */
3656 DEFUN_YANG(bgp_log_neighbor_changes
,
3657 bgp_log_neighbor_changes_cmd
,
3658 "bgp log-neighbor-changes",
3659 "BGP specific commands\n"
3660 "Log neighbor up/down and reset reason\n")
3662 nb_cli_enqueue_change(
3663 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3664 NB_OP_MODIFY
, "true");
3666 return nb_cli_apply_changes(vty
, NULL
);
3669 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3670 no_bgp_log_neighbor_changes_cmd
,
3671 "no bgp log-neighbor-changes",
3673 "BGP specific commands\n"
3674 "Log neighbor up/down and reset reason\n")
3676 nb_cli_enqueue_change(
3677 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3678 NB_OP_MODIFY
, "false");
3680 return nb_cli_apply_changes(vty
, NULL
);
3683 /* "bgp bestpath med" configuration. */
3684 DEFUN_YANG (bgp_bestpath_med
,
3685 bgp_bestpath_med_cmd
,
3686 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3687 "BGP specific commands\n"
3688 "Change the default bestpath selection\n"
3690 "Compare MED among confederation paths\n"
3691 "Treat missing MED as the least preferred one\n"
3692 "Treat missing MED as the least preferred one\n"
3693 "Compare MED among confederation paths\n")
3696 bool confed
= false;
3697 bool worst_med
= false;
3700 if (argv_find(argv
, argc
, "confed", &idx
))
3703 nb_cli_enqueue_change(vty
,
3704 "./global/route-selection-options/confed-med",
3705 NB_OP_MODIFY
, confed
? "true" : "false");
3708 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3711 nb_cli_enqueue_change(
3712 vty
, "./global/route-selection-options/missing-as-worst-med",
3713 NB_OP_MODIFY
, worst_med
? "true" : "false");
3715 return nb_cli_apply_changes(vty
, NULL
);
3718 DEFUN_YANG (no_bgp_bestpath_med
,
3719 no_bgp_bestpath_med_cmd
,
3720 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3722 "BGP specific commands\n"
3723 "Change the default bestpath selection\n"
3725 "Compare MED among confederation paths\n"
3726 "Treat missing MED as the least preferred one\n"
3727 "Treat missing MED as the least preferred one\n"
3728 "Compare MED among confederation paths\n")
3732 if (argv_find(argv
, argc
, "confed", &idx
))
3733 nb_cli_enqueue_change(
3734 vty
, "./global/route-selection-options/confed-med",
3735 NB_OP_MODIFY
, "false");
3738 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3739 nb_cli_enqueue_change(
3741 "./global/route-selection-options/missing-as-worst-med",
3742 NB_OP_MODIFY
, "false");
3744 return nb_cli_apply_changes(vty
, NULL
);
3747 /* "bgp bestpath bandwidth" configuration. */
3748 DEFPY (bgp_bestpath_bw
,
3749 bgp_bestpath_bw_cmd
,
3750 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3751 "BGP specific commands\n"
3752 "Change the default bestpath selection\n"
3753 "Link Bandwidth attribute\n"
3754 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3755 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3756 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3763 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3764 return CMD_ERR_INCOMPLETE
;
3766 if (!strcmp(bw_cfg
, "ignore"))
3767 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3768 else if (!strcmp(bw_cfg
, "skip-missing"))
3769 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3770 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3771 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3773 return CMD_ERR_NO_MATCH
;
3775 /* This config is used in route install, so redo that. */
3776 FOREACH_AFI_SAFI (afi
, safi
) {
3777 if (!bgp_fibupd_safi(safi
))
3779 bgp_zebra_announce_table(bgp
, afi
, safi
);
3785 DEFPY (no_bgp_bestpath_bw
,
3786 no_bgp_bestpath_bw_cmd
,
3787 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3789 "BGP specific commands\n"
3790 "Change the default bestpath selection\n"
3791 "Link Bandwidth attribute\n"
3792 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3793 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3794 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3800 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3802 /* This config is used in route install, so redo that. */
3803 FOREACH_AFI_SAFI (afi
, safi
) {
3804 if (!bgp_fibupd_safi(safi
))
3806 bgp_zebra_announce_table(bgp
, afi
, safi
);
3811 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3812 "[no] bgp default <ipv4-unicast|"
3815 "ipv4-labeled-unicast|"
3820 "ipv6-labeled-unicast|"
3822 "l2vpn-evpn>$afi_safi",
3824 "BGP specific commands\n"
3825 "Configure BGP defaults\n"
3826 "Activate ipv4-unicast for a peer by default\n"
3827 "Activate ipv4-multicast for a peer by default\n"
3828 "Activate ipv4-vpn for a peer by default\n"
3829 "Activate ipv4-labeled-unicast for a peer by default\n"
3830 "Activate ipv4-flowspec for a peer by default\n"
3831 "Activate ipv6-unicast for a peer by default\n"
3832 "Activate ipv6-multicast for a peer by default\n"
3833 "Activate ipv6-vpn for a peer by default\n"
3834 "Activate ipv6-labeled-unicast for a peer by default\n"
3835 "Activate ipv6-flowspec for a peer by default\n"
3836 "Activate l2vpn-evpn for a peer by default\n")
3838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3839 char afi_safi_str
[strlen(afi_safi
) + 1];
3840 char *afi_safi_str_tok
;
3842 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3843 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3844 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3845 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3848 if (strmatch(safi_str
, "labeled"))
3849 safi
= bgp_vty_safi_from_str("labeled-unicast");
3851 safi
= bgp_vty_safi_from_str(safi_str
);
3854 bgp
->default_af
[afi
][safi
] = false;
3856 if ((safi
== SAFI_LABELED_UNICAST
3857 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3858 || (safi
== SAFI_UNICAST
3859 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3860 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3862 bgp
->default_af
[afi
][safi
] = true;
3868 /* Display hostname in certain command outputs */
3869 DEFUN_YANG (bgp_default_show_hostname
,
3870 bgp_default_show_hostname_cmd
,
3871 "bgp default show-hostname",
3872 "BGP specific commands\n"
3873 "Configure BGP defaults\n"
3874 "Show hostname in certain command outputs\n")
3876 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3879 return nb_cli_apply_changes(vty
, NULL
);
3882 DEFUN_YANG(no_bgp_default_show_hostname
,
3883 no_bgp_default_show_hostname_cmd
,
3884 "no bgp default show-hostname",
3886 "BGP specific commands\n"
3887 "Configure BGP defaults\n"
3888 "Show hostname in certain command outputs\n")
3890 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3893 return nb_cli_apply_changes(vty
, NULL
);
3896 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3899 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3900 vty_out(vty
, " bgp default show-hostname\n");
3903 /* Display hostname in certain command outputs */
3904 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3905 bgp_default_show_nexthop_hostname_cmd
,
3906 "bgp default show-nexthop-hostname",
3907 "BGP specific commands\n"
3908 "Configure BGP defaults\n"
3909 "Show hostname for nexthop in certain command outputs\n")
3911 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3912 NB_OP_MODIFY
, "true");
3914 return nb_cli_apply_changes(vty
, NULL
);
3917 DEFUN (no_bgp_default_show_nexthop_hostname
,
3918 no_bgp_default_show_nexthop_hostname_cmd
,
3919 "no bgp default show-nexthop-hostname",
3921 "BGP specific commands\n"
3922 "Configure BGP defaults\n"
3923 "Show hostname for nexthop in certain command outputs\n")
3925 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3926 NB_OP_MODIFY
, "false");
3928 return nb_cli_apply_changes(vty
, NULL
);
3931 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3932 struct lyd_node
*dnode
,
3935 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3936 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3939 /* "bgp network import-check" configuration. */
3940 DEFUN_YANG(bgp_network_import_check
,
3941 bgp_network_import_check_cmd
,
3942 "bgp network import-check",
3943 "BGP specific commands\n"
3944 "BGP network command\n"
3945 "Check BGP network route exists in IGP\n")
3947 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3950 return nb_cli_apply_changes(vty
, NULL
);
3953 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3954 "bgp network import-check exact",
3955 "BGP specific commands\n"
3956 "BGP network command\n"
3957 "Check BGP network route exists in IGP\n"
3958 "Match route precisely\n")
3960 DEFUN_YANG(no_bgp_network_import_check
,
3961 no_bgp_network_import_check_cmd
,
3962 "no bgp network import-check",
3964 "BGP specific commands\n"
3965 "BGP network command\n"
3966 "Check BGP network route exists in IGP\n")
3968 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3971 return nb_cli_apply_changes(vty
, NULL
);
3974 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3977 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3978 vty_out(vty
, " bgp network import-check\n");
3981 DEFUN_YANG(bgp_default_local_preference
,
3982 bgp_default_local_preference_cmd
,
3983 "bgp default local-preference (0-4294967295)",
3984 "BGP specific commands\n"
3985 "Configure BGP defaults\n"
3986 "local preference (higher=more preferred)\n"
3987 "Configure default local preference value\n")
3991 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3992 argv
[idx_number
]->arg
);
3994 return nb_cli_apply_changes(vty
, NULL
);
3997 DEFUN_YANG(no_bgp_default_local_preference
,
3998 no_bgp_default_local_preference_cmd
,
3999 "no bgp default local-preference [(0-4294967295)]",
4001 "BGP specific commands\n"
4002 "Configure BGP defaults\n"
4003 "local preference (higher=more preferred)\n"
4004 "Configure default local preference value\n")
4006 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
4008 return nb_cli_apply_changes(vty
, NULL
);
4011 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
4014 vty_out(vty
, " bgp default local-preference %u\n",
4015 yang_dnode_get_uint32(dnode
, NULL
));
4019 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
4020 bgp_default_subgroup_pkt_queue_max_cmd
,
4021 "bgp default subgroup-pkt-queue-max (20-100)",
4022 "BGP specific commands\n"
4023 "Configure BGP defaults\n"
4024 "subgroup-pkt-queue-max\n"
4025 "Configure subgroup packet queue max\n")
4029 nb_cli_enqueue_change(
4031 "./global/global-update-group-config/subgroup-pkt-queue-size",
4032 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4034 return nb_cli_apply_changes(vty
, NULL
);
4037 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
4038 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4039 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4041 "BGP specific commands\n"
4042 "Configure BGP defaults\n"
4043 "subgroup-pkt-queue-max\n"
4044 "Configure subgroup packet queue max\n")
4046 nb_cli_enqueue_change(
4048 "./global/global-update-group-config/subgroup-pkt-queue-size",
4049 NB_OP_MODIFY
, NULL
);
4051 return nb_cli_apply_changes(vty
, NULL
);
4054 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
4055 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4057 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
4058 yang_dnode_get_uint32(dnode
, NULL
));
4061 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
4062 bgp_rr_allow_outbound_policy_cmd
,
4063 "bgp route-reflector allow-outbound-policy",
4064 "BGP specific commands\n"
4065 "Allow modifications made by out route-map\n"
4066 "on ibgp neighbors\n")
4068 nb_cli_enqueue_change(vty
,
4069 "./global/route-reflector/allow-outbound-policy",
4070 NB_OP_MODIFY
, "true");
4072 return nb_cli_apply_changes(vty
, NULL
);
4075 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
4076 no_bgp_rr_allow_outbound_policy_cmd
,
4077 "no bgp route-reflector allow-outbound-policy",
4079 "BGP specific commands\n"
4080 "Allow modifications made by out route-map\n"
4081 "on ibgp neighbors\n")
4083 nb_cli_enqueue_change(vty
,
4084 "./global/route-reflector/allow-outbound-policy",
4085 NB_OP_MODIFY
, "false");
4087 return nb_cli_apply_changes(vty
, NULL
);
4091 void cli_show_router_global_neighbor_config(struct vty
*vty
,
4092 struct lyd_node
*dnode
,
4095 uint32_t write_quanta
, read_quanta
;
4097 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
4098 vty_out(vty
, " bgp log-neighbor-changes\n");
4100 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
4101 uint32_t listen_limit
= yang_dnode_get_uint32(
4102 dnode
, "./dynamic-neighbors-limit");
4103 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
4106 write_quanta
= yang_dnode_get_uint32(
4107 dnode
, "./packet-quanta-config/wpkt-quanta");
4108 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
4109 vty_out(vty
, " write-quanta %d\n", write_quanta
);
4111 read_quanta
= yang_dnode_get_uint32(
4112 dnode
, "./packet-quanta-config/rpkt-quanta");
4114 if (read_quanta
!= BGP_READ_PACKET_MAX
)
4115 vty_out(vty
, " read-quanta %d\n", read_quanta
);
4118 DEFUN_YANG(bgp_listen_limit
,
4119 bgp_listen_limit_cmd
,
4120 "bgp listen limit (1-65535)",
4121 "BGP specific commands\n"
4122 "BGP Dynamic Neighbors listen commands\n"
4123 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4124 "Configure Dynamic Neighbors listen limit value\n")
4128 nb_cli_enqueue_change(
4129 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4130 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4132 return nb_cli_apply_changes(vty
, NULL
);
4135 DEFUN_YANG(no_bgp_listen_limit
,
4136 no_bgp_listen_limit_cmd
,
4137 "no bgp listen limit [(1-65535)]",
4139 "BGP specific commands\n"
4140 "BGP Dynamic Neighbors listen commands\n"
4141 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4142 "Configure Dynamic Neighbors listen limit value\n")
4144 nb_cli_enqueue_change(
4145 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4146 NB_OP_DESTROY
, NULL
);
4148 return nb_cli_apply_changes(vty
, NULL
);
4153 * Check if this listen range is already configured. Check for exact
4154 * match or overlap based on input.
4156 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4157 struct prefix
*range
, int exact
)
4159 struct listnode
*node
, *nnode
;
4160 struct listnode
*node1
, *nnode1
;
4161 struct peer_group
*group
;
4166 afi
= family2afi(range
->family
);
4167 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4168 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4171 match
= prefix_same(range
, lr
);
4173 match
= (prefix_match(range
, lr
)
4174 || prefix_match(lr
, range
));
4183 DEFUN (bgp_listen_range
,
4184 bgp_listen_range_cmd
,
4185 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4186 "BGP specific commands\n"
4187 "Configure BGP dynamic neighbors listen range\n"
4188 "Configure BGP dynamic neighbors listen range\n"
4190 "Member of the peer-group\n"
4191 "Peer-group name\n")
4193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4194 struct prefix range
;
4195 struct peer_group
*group
, *existing_group
;
4200 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4201 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4202 char *prefix
= argv
[idx
]->arg
;
4203 argv_find(argv
, argc
, "PGNAME", &idx
);
4204 char *peergroup
= argv
[idx
]->arg
;
4206 /* Convert IP prefix string to struct prefix. */
4207 ret
= str2prefix(prefix
, &range
);
4209 vty_out(vty
, "%% Malformed listen range\n");
4210 return CMD_WARNING_CONFIG_FAILED
;
4213 afi
= family2afi(range
.family
);
4215 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4217 "%% Malformed listen range (link-local address)\n");
4218 return CMD_WARNING_CONFIG_FAILED
;
4223 /* Check if same listen range is already configured. */
4224 existing_group
= listen_range_exists(bgp
, &range
, 1);
4225 if (existing_group
) {
4226 if (strcmp(existing_group
->name
, peergroup
) == 0)
4230 "%% Same listen range is attached to peer-group %s\n",
4231 existing_group
->name
);
4232 return CMD_WARNING_CONFIG_FAILED
;
4236 /* Check if an overlapping listen range exists. */
4237 if (listen_range_exists(bgp
, &range
, 0)) {
4239 "%% Listen range overlaps with existing listen range\n");
4240 return CMD_WARNING_CONFIG_FAILED
;
4243 group
= peer_group_lookup(bgp
, peergroup
);
4245 vty_out(vty
, "%% Configure the peer-group first\n");
4246 return CMD_WARNING_CONFIG_FAILED
;
4249 ret
= peer_group_listen_range_add(group
, &range
);
4250 return bgp_vty_return(vty
, ret
);
4253 DEFUN (no_bgp_listen_range
,
4254 no_bgp_listen_range_cmd
,
4255 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4257 "BGP specific commands\n"
4258 "Unconfigure BGP dynamic neighbors listen range\n"
4259 "Unconfigure BGP dynamic neighbors listen range\n"
4261 "Member of the peer-group\n"
4262 "Peer-group name\n")
4264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4265 struct prefix range
;
4266 struct peer_group
*group
;
4271 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4272 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4273 char *prefix
= argv
[idx
]->arg
;
4274 argv_find(argv
, argc
, "PGNAME", &idx
);
4275 char *peergroup
= argv
[idx
]->arg
;
4277 /* Convert IP prefix string to struct prefix. */
4278 ret
= str2prefix(prefix
, &range
);
4280 vty_out(vty
, "%% Malformed listen range\n");
4281 return CMD_WARNING_CONFIG_FAILED
;
4284 afi
= family2afi(range
.family
);
4286 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4288 "%% Malformed listen range (link-local address)\n");
4289 return CMD_WARNING_CONFIG_FAILED
;
4294 group
= peer_group_lookup(bgp
, peergroup
);
4296 vty_out(vty
, "%% Peer-group does not exist\n");
4297 return CMD_WARNING_CONFIG_FAILED
;
4300 ret
= peer_group_listen_range_del(group
, &range
);
4301 return bgp_vty_return(vty
, ret
);
4304 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4306 struct peer_group
*group
;
4307 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4308 struct prefix
*range
;
4311 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4312 vty_out(vty
, " bgp listen limit %d\n",
4313 bgp
->dynamic_neighbors_limit
);
4315 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4316 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4317 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4320 " bgp listen range %pFX peer-group %s\n",
4321 range
, group
->name
);
4328 DEFUN_YANG(bgp_disable_connected_route_check
,
4329 bgp_disable_connected_route_check_cmd
,
4330 "bgp disable-ebgp-connected-route-check",
4331 "BGP specific commands\n"
4332 "Disable checking if nexthop is connected on ebgp sessions\n")
4334 nb_cli_enqueue_change(vty
,
4335 "./global/ebgp-multihop-connected-route-check",
4336 NB_OP_MODIFY
, "true");
4338 return nb_cli_apply_changes(vty
, NULL
);
4341 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4342 no_bgp_disable_connected_route_check_cmd
,
4343 "no bgp disable-ebgp-connected-route-check",
4345 "BGP specific commands\n"
4346 "Disable checking if nexthop is connected on ebgp sessions\n")
4348 nb_cli_enqueue_change(vty
,
4349 "./global/ebgp-multihop-connected-route-check",
4350 NB_OP_MODIFY
, "false");
4352 return nb_cli_apply_changes(vty
, NULL
);
4355 void cli_show_router_global_ebgp_multihop_connected_route_check(
4356 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4358 if (yang_dnode_get_bool(dnode
, NULL
))
4359 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4362 DEFUN_YANG(bgp_default_shutdown
,
4363 bgp_default_shutdown_cmd
,
4364 "[no] bgp default shutdown",
4366 "Configure BGP defaults\n"
4367 "Apply administrative shutdown to newly configured peers\n")
4369 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4370 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4372 return nb_cli_apply_changes(vty
, NULL
);
4375 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4376 struct lyd_node
*dnode
,
4379 if (yang_dnode_get_bool(dnode
, NULL
))
4380 vty_out(vty
, " bgp default shutdown\n");
4383 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4385 "Administrative shutdown of the BGP instance\n"
4386 "Add a shutdown message (RFC 8203)\n"
4387 "Shutdown message\n")
4389 char *msgstr
= NULL
;
4391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4394 msgstr
= argv_concat(argv
, argc
, 3);
4396 bgp_shutdown_enable(bgp
, msgstr
);
4397 XFREE(MTYPE_TMP
, msgstr
);
4402 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4403 BGP_STR
"Administrative shutdown of the BGP instance\n")
4405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4407 bgp_shutdown_enable(bgp
, NULL
);
4412 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4413 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4417 bgp_shutdown_disable(bgp
);
4422 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4423 "no bgp shutdown message MSG...", NO_STR BGP_STR
4424 "Administrative shutdown of the BGP instance\n"
4425 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4427 DEFUN_YANG(neighbor_remote_as
,
4428 neighbor_remote_as_cmd
,
4429 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4430 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4431 "Specify a BGP neighbor\n" AS_STR
4432 "Internal BGP peer\n"
4433 "External BGP peer\n")
4436 int idx_remote_as
= 3;
4437 char base_xpath
[XPATH_MAXLEN
];
4438 char unnbr_xpath
[XPATH_MAXLEN
];
4439 char prgrp_xpath
[XPATH_MAXLEN
];
4441 const char *as_type_str
= "as-specified";
4443 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4444 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4445 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4447 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4448 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4450 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4451 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4452 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4453 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
4454 "%s%s", VTY_CURR_XPATH
,
4456 snprintf(base_xpath
, sizeof(base_xpath
),
4457 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4461 "%% Create the peer-group or interface first\n");
4462 return CMD_WARNING_CONFIG_FAILED
;
4465 snprintf(base_xpath
, sizeof(base_xpath
),
4466 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4469 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4470 as_type_str
= "internal";
4471 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4472 as_type_str
= "external";
4474 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4475 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4477 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4478 NB_OP_MODIFY
, as_type_str
);
4480 return nb_cli_apply_changes(vty
, base_xpath
);
4483 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
,
4484 bool v6only
, const char *peer_group_name
,
4485 int as_type
, as_t as
, char *errmsg
,
4489 struct peer_group
*group
;
4492 group
= peer_group_lookup(bgp
, conf_if
);
4495 snprintf(errmsg
, errmsg_len
,
4496 "Name conflict with peer-group \n");
4500 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4502 if (as_type
!= AS_UNSPECIFIED
)
4503 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4505 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4509 snprintf(errmsg
, errmsg_len
,
4510 "BGP failed to create peer\n");
4515 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4517 /* Request zebra to initiate IPv6 RAs on this interface. We do
4519 * any unnumbered peer in order to not worry about run-time
4521 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4523 * gets deleted later etc.)
4526 bgp_zebra_initiate_radv(bgp
, peer
);
4529 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4530 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4532 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4534 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4536 /* v6only flag changed. Reset bgp seesion */
4537 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4538 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4539 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4540 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4542 bgp_session_reset(peer
);
4545 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4546 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4547 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4548 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4551 if (peer_group_name
) {
4552 group
= peer_group_lookup(bgp
, peer_group_name
);
4554 snprintf(errmsg
, errmsg_len
,
4555 "Configure the peer-group first\n");
4559 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4562 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4565 DEFUN_YANG(neighbor_interface_config
,
4566 neighbor_interface_config_cmd
,
4567 "neighbor WORD interface [peer-group PGNAME]",
4569 "Interface name or neighbor tag\n"
4570 "Enable BGP on interface\n"
4571 "Member of the peer-group\n"
4572 "Peer-group name\n")
4575 int idx_peer_group_word
= 4;
4576 char base_xpath
[XPATH_MAXLEN
];
4578 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4579 argv
[idx_word
]->arg
, "");
4581 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4582 if (argc
> idx_peer_group_word
)
4583 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4584 argv
[idx_peer_group_word
]->arg
);
4586 return nb_cli_apply_changes(vty
, base_xpath
);
4589 DEFUN_YANG(neighbor_interface_config_v6only
,
4590 neighbor_interface_config_v6only_cmd
,
4591 "neighbor WORD interface v6only [peer-group PGNAME]",
4593 "Interface name or neighbor tag\n"
4594 "Enable BGP on interface\n"
4595 "Enable BGP with v6 link-local only\n"
4596 "Member of the peer-group\n"
4597 "Peer-group name\n")
4600 int idx_peer_group_word
= 5;
4601 char base_xpath
[XPATH_MAXLEN
];
4603 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4604 argv
[idx_word
]->arg
, "");
4606 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4607 if (argc
> idx_peer_group_word
)
4608 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4609 argv
[idx_peer_group_word
]->arg
);
4611 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4613 return nb_cli_apply_changes(vty
, base_xpath
);
4618 neighbor_interface_config_remote_as
,
4619 neighbor_interface_config_remote_as_cmd
,
4620 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4622 "Interface name or neighbor tag\n"
4623 "Enable BGP on interface\n"
4624 "Specify a BGP neighbor\n" AS_STR
4625 "Internal BGP peer\n"
4626 "External BGP peer\n")
4629 int idx_remote_as
= 4;
4630 char base_xpath
[XPATH_MAXLEN
];
4631 const char *as_type_str
= "as-specified";
4633 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4634 argv
[idx_word
]->arg
, "");
4636 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4638 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4639 as_type_str
= "internal";
4640 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4641 as_type_str
= "external";
4643 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4644 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4646 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4647 NB_OP_MODIFY
, as_type_str
);
4649 return nb_cli_apply_changes(vty
, base_xpath
);
4653 neighbor_interface_v6only_config_remote_as
,
4654 neighbor_interface_v6only_config_remote_as_cmd
,
4655 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4657 "Interface name or neighbor tag\n"
4658 "Enable BGP with v6 link-local only\n"
4659 "Enable BGP on interface\n"
4660 "Specify a BGP neighbor\n" AS_STR
4661 "Internal BGP peer\n"
4662 "External BGP peer\n")
4665 int idx_remote_as
= 5;
4666 char base_xpath
[XPATH_MAXLEN
];
4667 const char *as_type_str
= "as-specified";
4669 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4670 argv
[idx_word
]->arg
, "");
4672 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4674 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4676 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4677 as_type_str
= "internal";
4678 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4679 as_type_str
= "external";
4681 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4682 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4684 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4685 NB_OP_MODIFY
, as_type_str
);
4687 return nb_cli_apply_changes(vty
, base_xpath
);
4690 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4691 "neighbor WORD peer-group",
4693 "Interface name or neighbor tag\n"
4694 "Configure peer-group\n")
4696 char base_xpath
[XPATH_MAXLEN
];
4699 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4700 argv
[idx_word
]->arg
, "");
4702 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4704 return nb_cli_apply_changes(vty
, base_xpath
);
4707 DEFUN_YANG(no_neighbor
,
4709 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4712 "Specify a BGP neighbor\n" AS_STR
4713 "Internal BGP peer\n"
4714 "External BGP peer\n")
4717 char base_xpath
[XPATH_MAXLEN
];
4718 char num_xpath
[XPATH_MAXLEN
];
4719 char unnbr_xpath
[XPATH_MAXLEN
];
4720 char prgrp_xpath
[XPATH_MAXLEN
];
4723 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4724 snprintf(num_xpath
, sizeof(num_xpath
),
4725 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4726 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4727 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4728 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4731 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4732 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4734 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4735 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4737 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4738 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4739 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4740 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
4741 "%s%s", VTY_CURR_XPATH
,
4743 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4746 "%% Create the peer-group or interface first\n");
4747 return CMD_WARNING_CONFIG_FAILED
;
4751 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4754 * Need to commit any pending so this command doesn't merge with a
4755 * create into a modify, which BGP can't handle
4757 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
4760 DEFUN_YANG(no_neighbor_interface_config
,
4761 no_neighbor_interface_config_cmd
,
4762 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4765 "Configure BGP on interface\n"
4766 "Enable BGP with v6 link-local only\n"
4767 "Member of the peer-group\n"
4769 "Specify a BGP neighbor\n" AS_STR
4770 "Internal BGP peer\n"
4771 "External BGP peer\n")
4774 char base_xpath
[XPATH_MAXLEN
];
4776 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4777 argv
[idx_word
]->arg
, "");
4779 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4782 * Need to commit any pending so this command doesn't merge with a
4783 * create into a modify, which BGP can't handle
4785 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
4788 DEFUN_YANG(no_neighbor_peer_group
,
4789 no_neighbor_peer_group_cmd
,
4790 "no neighbor WORD peer-group",
4793 "Configure peer-group\n")
4795 char base_xpath
[XPATH_MAXLEN
];
4798 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4799 argv
[idx_word
]->arg
, "");
4801 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4804 * Need to commit any pending so this command doesn't merge with a
4805 * create into a modify, which BGP can't handle
4807 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
4810 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4811 no_neighbor_interface_peer_group_remote_as_cmd
,
4812 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4814 "Interface name or neighbor tag\n"
4815 "Specify a BGP neighbor\n" AS_STR
4816 "Internal BGP peer\n"
4817 "External BGP peer\n")
4820 char base_xpath
[XPATH_MAXLEN
];
4821 char unnbr_xpath
[XPATH_MAXLEN
];
4822 char prgrp_xpath
[XPATH_MAXLEN
];
4824 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4825 argv
[idx_peer
]->arg
, "");
4827 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4828 argv
[idx_peer
]->arg
, "");
4830 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4831 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4832 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4833 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
4834 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4835 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4837 vty_out(vty
, "%% Create the peer-group or interface first\n");
4838 return CMD_WARNING_CONFIG_FAILED
;
4841 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4842 sizeof(base_xpath
));
4844 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4847 * Need to commit any pending so this command doesn't merge with a
4848 * create into a modify, which BGP can't handle
4850 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
4853 DEFUN_YANG(neighbor_local_as
,
4854 neighbor_local_as_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4857 "Specify a local-as number\n"
4858 "AS number used as local AS\n")
4862 char base_xpath
[XPATH_MAXLEN
];
4864 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4865 sizeof(base_xpath
), NULL
)
4867 return CMD_WARNING_CONFIG_FAILED
;
4869 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4870 argv
[idx_number
]->arg
);
4872 return nb_cli_apply_changes(vty
, base_xpath
);
4876 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4877 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4878 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4879 "Specify a local-as number\n"
4880 "AS number used as local AS\n"
4881 "Do not prepend local-as to updates from ebgp peers\n")
4885 char base_xpath
[XPATH_MAXLEN
];
4887 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4888 sizeof(base_xpath
), NULL
)
4890 return CMD_WARNING_CONFIG_FAILED
;
4892 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4893 argv
[idx_number
]->arg
);
4894 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4897 return nb_cli_apply_changes(vty
, base_xpath
);
4901 neighbor_local_as_no_prepend_replace_as
,
4902 neighbor_local_as_no_prepend_replace_as_cmd
,
4903 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4904 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4905 "Specify a local-as number\n"
4906 "AS number used as local AS\n"
4907 "Do not prepend local-as to updates from ebgp peers\n"
4908 "Do not prepend local-as to updates from ibgp peers\n")
4912 char base_xpath
[XPATH_MAXLEN
];
4914 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4915 sizeof(base_xpath
), NULL
)
4917 return CMD_WARNING_CONFIG_FAILED
;
4919 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4920 argv
[idx_number
]->arg
);
4921 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4923 nb_cli_enqueue_change(vty
, "./local-as/replace-as", NB_OP_MODIFY
,
4926 return nb_cli_apply_changes(vty
, base_xpath
);
4929 DEFUN_YANG(no_neighbor_local_as
,
4930 no_neighbor_local_as_cmd
,
4931 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4932 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4933 "Specify a local-as number\n"
4934 "AS number used as local AS\n"
4935 "Do not prepend local-as to updates from ebgp peers\n"
4936 "Do not prepend local-as to updates from ibgp peers\n")
4939 char base_xpath
[XPATH_MAXLEN
];
4941 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4942 sizeof(base_xpath
), NULL
)
4944 return CMD_WARNING_CONFIG_FAILED
;
4946 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4947 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4949 nb_cli_enqueue_change(vty
, "./local-as/replace-as", NB_OP_MODIFY
,
4952 return nb_cli_apply_changes(vty
, base_xpath
);
4956 DEFUN (neighbor_solo
,
4958 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4961 "Solo peer - part of its own update group\n")
4967 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4969 return CMD_WARNING_CONFIG_FAILED
;
4971 ret
= update_group_adjust_soloness(peer
, 1);
4972 return bgp_vty_return(vty
, ret
);
4975 DEFUN (no_neighbor_solo
,
4976 no_neighbor_solo_cmd
,
4977 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4981 "Solo peer - part of its own update group\n")
4987 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4989 return CMD_WARNING_CONFIG_FAILED
;
4991 ret
= update_group_adjust_soloness(peer
, 0);
4992 return bgp_vty_return(vty
, ret
);
4995 DEFUN_YANG(neighbor_password
,
4996 neighbor_password_cmd
,
4997 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4998 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5004 char base_xpath
[XPATH_MAXLEN
];
5006 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5007 sizeof(base_xpath
), NULL
)
5009 return CMD_WARNING_CONFIG_FAILED
;
5011 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
5012 argv
[idx_line
]->arg
);
5014 return nb_cli_apply_changes(vty
, base_xpath
);
5017 DEFUN_YANG(no_neighbor_password
,
5018 no_neighbor_password_cmd
,
5019 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5020 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5025 char base_xpath
[XPATH_MAXLEN
];
5027 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5028 sizeof(base_xpath
), NULL
)
5030 return CMD_WARNING_CONFIG_FAILED
;
5032 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
5034 return nb_cli_apply_changes(vty
, base_xpath
);
5037 DEFUN_YANG(neighbor_activate
,
5038 neighbor_activate_cmd
,
5039 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5040 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5041 "Enable the Address Family for this Neighbor\n")
5044 char base_xpath
[XPATH_MAXLEN
];
5045 char af_xpath
[XPATH_MAXLEN
];
5046 afi_t afi
= bgp_node_afi(vty
);
5047 safi_t safi
= bgp_node_safi(vty
);
5049 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5050 yang_afi_safi_value2identity(afi
, safi
));
5051 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5052 sizeof(base_xpath
), af_xpath
)
5054 return CMD_WARNING_CONFIG_FAILED
;
5056 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
5058 return nb_cli_apply_changes(vty
, base_xpath
);
5061 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5062 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5063 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5064 "Enable the Address Family for this Neighbor\n")
5066 DEFUN_YANG(no_neighbor_activate
,
5067 no_neighbor_activate_cmd
,
5068 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5071 "Enable the Address Family for this Neighbor\n")
5074 char base_xpath
[XPATH_MAXLEN
];
5075 char af_xpath
[XPATH_MAXLEN
];
5076 afi_t afi
= bgp_node_afi(vty
);
5077 safi_t safi
= bgp_node_safi(vty
);
5079 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5080 yang_afi_safi_value2identity(afi
, safi
));
5082 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5083 sizeof(base_xpath
), af_xpath
)
5085 return CMD_WARNING_CONFIG_FAILED
;
5087 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
5089 return nb_cli_apply_changes(vty
, base_xpath
);
5092 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5093 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5094 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5095 "Enable the Address Family for this Neighbor\n")
5097 DEFUN (neighbor_set_peer_group
,
5098 neighbor_set_peer_group_cmd
,
5099 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5102 "Member of the peer-group\n"
5103 "Peer-group name\n")
5105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5112 struct peer_group
*group
;
5114 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5116 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5118 vty_out(vty
, "%% Malformed address or name: %s\n",
5119 argv
[idx_peer
]->arg
);
5120 return CMD_WARNING_CONFIG_FAILED
;
5123 if (peer_address_self_check(bgp
, &su
)) {
5125 "%% Can not configure the local system as neighbor\n");
5126 return CMD_WARNING_CONFIG_FAILED
;
5129 /* Disallow for dynamic neighbor. */
5130 peer
= peer_lookup(bgp
, &su
);
5131 if (peer
&& peer_dynamic_neighbor(peer
)) {
5133 "%% Operation not allowed on a dynamic neighbor\n");
5134 return CMD_WARNING_CONFIG_FAILED
;
5138 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5140 vty_out(vty
, "%% Configure the peer-group first\n");
5141 return CMD_WARNING_CONFIG_FAILED
;
5144 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5146 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
5148 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
5150 return CMD_WARNING_CONFIG_FAILED
;
5153 return bgp_vty_return(vty
, ret
);
5156 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5157 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5159 "Member of the peer-group\n"
5160 "Peer-group name\n")
5162 DEFUN_YANG (no_neighbor_set_peer_group
,
5163 no_neighbor_set_peer_group_cmd
,
5164 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5168 "Member of the peer-group\n"
5169 "Peer-group name\n")
5172 char base_xpath
[XPATH_MAXLEN
];
5174 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5175 sizeof(base_xpath
), NULL
)
5177 return CMD_WARNING_CONFIG_FAILED
;
5179 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5182 * Need to commit any pending so this command doesn't merge with a
5183 * create into a modify, which BGP can't handle
5185 return nb_cli_apply_changes_clear_pending(vty
, base_xpath
);
5188 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5189 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5190 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5191 "Member of the peer-group\n"
5192 "Peer-group name\n")
5194 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5195 uint32_t flag
, int set
)
5200 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5202 return CMD_WARNING_CONFIG_FAILED
;
5205 * If 'neighbor <interface>', then this is for directly connected peers,
5206 * we should not accept disable-connected-check.
5208 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5210 "%s is directly connected peer, cannot accept disable-connected-check\n",
5212 return CMD_WARNING_CONFIG_FAILED
;
5215 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5216 peer_tx_shutdown_message_unset(peer
);
5219 ret
= peer_flag_set(peer
, flag
);
5221 ret
= peer_flag_unset(peer
, flag
);
5223 return bgp_vty_return(vty
, ret
);
5226 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5228 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5231 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5234 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5237 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5238 uint32_t flag
, bool set
, char *errmsg
,
5244 * If 'neighbor <interface>', then this is for directly connected peers,
5245 * we should not accept disable-connected-check.
5247 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5250 "%s is directly connected peer, cannot accept disable-connected-check\n",
5255 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5256 peer_tx_shutdown_message_unset(peer
);
5259 ret
= peer_flag_set(peer
, flag
);
5261 ret
= peer_flag_unset(peer
, flag
);
5263 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5266 /* neighbor passive. */
5267 DEFUN_YANG(neighbor_passive
,
5268 neighbor_passive_cmd
,
5269 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5272 "Don't send open messages to this neighbor\n")
5275 char base_xpath
[XPATH_MAXLEN
];
5277 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5278 sizeof(base_xpath
), NULL
)
5280 return CMD_WARNING_CONFIG_FAILED
;
5282 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5284 return nb_cli_apply_changes(vty
, base_xpath
);
5287 DEFUN_YANG(no_neighbor_passive
,
5288 no_neighbor_passive_cmd
,
5289 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5292 "Don't send open messages to this neighbor\n")
5295 char base_xpath
[XPATH_MAXLEN
];
5297 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5298 sizeof(base_xpath
), NULL
)
5300 return CMD_WARNING_CONFIG_FAILED
;
5302 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5304 return nb_cli_apply_changes(vty
, base_xpath
);
5307 /* neighbor shutdown. */
5308 DEFUN_YANG(neighbor_shutdown_msg
,
5309 neighbor_shutdown_msg_cmd
,
5310 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5311 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5312 "Administratively shut down this neighbor\n"
5313 "Add a shutdown message (RFC 8203)\n"
5314 "Shutdown message\n")
5317 char base_xpath
[XPATH_MAXLEN
];
5319 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5320 sizeof(base_xpath
), NULL
)
5322 return CMD_WARNING_CONFIG_FAILED
;
5327 message
= argv_concat(argv
, argc
, 4);
5328 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5329 NB_OP_MODIFY
, message
);
5332 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5335 return nb_cli_apply_changes(vty
, base_xpath
);
5338 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5339 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5340 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5341 "Administratively shut down this neighbor\n")
5343 DEFUN_YANG(no_neighbor_shutdown_msg
,
5344 no_neighbor_shutdown_msg_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5348 "Administratively shut down this neighbor\n"
5349 "Remove a shutdown message (RFC 8203)\n"
5350 "Shutdown message\n")
5353 char base_xpath
[XPATH_MAXLEN
];
5355 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5356 sizeof(base_xpath
), NULL
)
5358 return CMD_WARNING_CONFIG_FAILED
;
5360 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5363 return nb_cli_apply_changes(vty
, base_xpath
);
5366 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5367 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5368 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5369 "Administratively shut down this neighbor\n")
5371 DEFUN(neighbor_shutdown_rtt
,
5372 neighbor_shutdown_rtt_cmd
,
5373 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5376 "Administratively shut down this neighbor\n"
5377 "Shutdown if round-trip-time is higher than expected\n"
5378 "Round-trip-time in milliseconds\n"
5379 "Specify the number of keepalives before shutdown\n"
5380 "The number of keepalives with higher RTT to shutdown\n")
5387 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5390 return CMD_WARNING_CONFIG_FAILED
;
5392 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5394 if (argv_find(argv
, argc
, "count", &idx_count
))
5395 peer
->rtt_keepalive_conf
=
5396 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5398 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5399 PEER_FLAG_RTT_SHUTDOWN
);
5402 DEFUN(no_neighbor_shutdown_rtt
,
5403 no_neighbor_shutdown_rtt_cmd
,
5404 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5408 "Administratively shut down this neighbor\n"
5409 "Shutdown if round-trip-time is higher than expected\n"
5410 "Round-trip-time in milliseconds\n"
5411 "Specify the number of keepalives before shutdown\n"
5412 "The number of keepalives with higher RTT to shutdown\n")
5417 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5420 return CMD_WARNING_CONFIG_FAILED
;
5422 peer
->rtt_expected
= 0;
5423 peer
->rtt_keepalive_conf
= 1;
5425 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5426 PEER_FLAG_RTT_SHUTDOWN
);
5429 /* neighbor capability dynamic. */
5430 DEFUN_YANG (neighbor_capability_dynamic
,
5431 neighbor_capability_dynamic_cmd
,
5432 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5435 "Advertise capability to the peer\n"
5436 "Advertise dynamic capability to this neighbor\n")
5439 char base_xpath
[XPATH_MAXLEN
];
5441 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5442 sizeof(base_xpath
), NULL
)
5444 return CMD_WARNING_CONFIG_FAILED
;
5446 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5447 NB_OP_MODIFY
, "true");
5449 return nb_cli_apply_changes(vty
, base_xpath
);
5452 DEFUN_YANG (no_neighbor_capability_dynamic
,
5453 no_neighbor_capability_dynamic_cmd
,
5454 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5458 "Advertise capability to the peer\n"
5459 "Advertise dynamic capability to this neighbor\n")
5462 char base_xpath
[XPATH_MAXLEN
];
5464 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5465 sizeof(base_xpath
), NULL
)
5467 return CMD_WARNING_CONFIG_FAILED
;
5469 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5470 NB_OP_MODIFY
, "false");
5472 return nb_cli_apply_changes(vty
, base_xpath
);
5475 /* neighbor dont-capability-negotiate */
5476 DEFUN (neighbor_dont_capability_negotiate
,
5477 neighbor_dont_capability_negotiate_cmd
,
5478 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5481 "Do not perform capability negotiation\n")
5484 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5485 PEER_FLAG_DONT_CAPABILITY
);
5488 DEFUN (no_neighbor_dont_capability_negotiate
,
5489 no_neighbor_dont_capability_negotiate_cmd
,
5490 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5494 "Do not perform capability negotiation\n")
5497 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5498 PEER_FLAG_DONT_CAPABILITY
);
5501 /* neighbor capability extended next hop encoding */
5502 DEFUN_YANG (neighbor_capability_enhe
,
5503 neighbor_capability_enhe_cmd
,
5504 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5507 "Advertise capability to the peer\n"
5508 "Advertise extended next-hop capability to the peer\n")
5511 char base_xpath
[XPATH_MAXLEN
];
5513 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5514 sizeof(base_xpath
), NULL
)
5516 return CMD_WARNING_CONFIG_FAILED
;
5518 nb_cli_enqueue_change(
5519 vty
, "./capability-options/extended-nexthop-capability",
5520 NB_OP_MODIFY
, "true");
5522 return nb_cli_apply_changes(vty
, base_xpath
);
5525 DEFUN_YANG (no_neighbor_capability_enhe
,
5526 no_neighbor_capability_enhe_cmd
,
5527 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5531 "Advertise capability to the peer\n"
5532 "Advertise extended next-hop capability to the peer\n")
5535 char base_xpath
[XPATH_MAXLEN
];
5537 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5538 sizeof(base_xpath
), NULL
)
5540 return CMD_WARNING_CONFIG_FAILED
;
5542 nb_cli_enqueue_change(
5543 vty
, "./capability-options/extended-nexthop-capability",
5544 NB_OP_MODIFY
, "false");
5546 return nb_cli_apply_changes(vty
, base_xpath
);
5549 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5550 uint32_t flag
, int set
, char *errmsg
,
5556 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5558 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5560 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5563 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5564 afi_t afi
, safi_t safi
, uint32_t flag
,
5570 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5572 return CMD_WARNING_CONFIG_FAILED
;
5575 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5577 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5579 return bgp_vty_return(vty
, ret
);
5582 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5583 afi_t afi
, safi_t safi
, uint32_t flag
)
5585 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5588 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5589 afi_t afi
, safi_t safi
, uint32_t flag
)
5591 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5594 /* neighbor capability orf prefix-list. */
5595 DEFUN (neighbor_capability_orf_prefix
,
5596 neighbor_capability_orf_prefix_cmd
,
5597 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5600 "Advertise capability to the peer\n"
5601 "Advertise ORF capability to the peer\n"
5602 "Advertise prefixlist ORF capability to this neighbor\n"
5603 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5604 "Capability to RECEIVE the ORF from this neighbor\n"
5605 "Capability to SEND the ORF to this neighbor\n")
5607 int idx_send_recv
= 5;
5608 char *peer_str
= argv
[1]->arg
;
5610 afi_t afi
= bgp_node_afi(vty
);
5611 safi_t safi
= bgp_node_safi(vty
);
5613 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5615 return CMD_WARNING_CONFIG_FAILED
;
5617 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5618 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5619 PEER_FLAG_ORF_PREFIX_SM
);
5621 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5622 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5623 PEER_FLAG_ORF_PREFIX_RM
);
5625 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5626 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5627 PEER_FLAG_ORF_PREFIX_SM
)
5628 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5629 PEER_FLAG_ORF_PREFIX_RM
);
5631 return CMD_WARNING_CONFIG_FAILED
;
5635 neighbor_capability_orf_prefix
,
5636 neighbor_capability_orf_prefix_hidden_cmd
,
5637 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5638 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5639 "Advertise capability to the peer\n"
5640 "Advertise ORF capability to the peer\n"
5641 "Advertise prefixlist ORF capability to this neighbor\n"
5642 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5643 "Capability to RECEIVE the ORF from this neighbor\n"
5644 "Capability to SEND the ORF to this neighbor\n")
5646 DEFUN (no_neighbor_capability_orf_prefix
,
5647 no_neighbor_capability_orf_prefix_cmd
,
5648 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5652 "Advertise capability to the peer\n"
5653 "Advertise ORF capability to the peer\n"
5654 "Advertise prefixlist ORF capability to this neighbor\n"
5655 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5656 "Capability to RECEIVE the ORF from this neighbor\n"
5657 "Capability to SEND the ORF to this neighbor\n")
5659 int idx_send_recv
= 6;
5660 char *peer_str
= argv
[2]->arg
;
5662 afi_t afi
= bgp_node_afi(vty
);
5663 safi_t safi
= bgp_node_safi(vty
);
5665 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5667 return CMD_WARNING_CONFIG_FAILED
;
5669 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5670 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5671 PEER_FLAG_ORF_PREFIX_SM
);
5673 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5674 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5675 PEER_FLAG_ORF_PREFIX_RM
);
5677 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5678 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5679 PEER_FLAG_ORF_PREFIX_SM
)
5680 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5681 PEER_FLAG_ORF_PREFIX_RM
);
5683 return CMD_WARNING_CONFIG_FAILED
;
5687 no_neighbor_capability_orf_prefix
,
5688 no_neighbor_capability_orf_prefix_hidden_cmd
,
5689 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5690 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5691 "Advertise capability to the peer\n"
5692 "Advertise ORF capability to the peer\n"
5693 "Advertise prefixlist ORF capability to this neighbor\n"
5694 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5695 "Capability to RECEIVE the ORF from this neighbor\n"
5696 "Capability to SEND the ORF to this neighbor\n")
5698 /* neighbor next-hop-self. */
5699 DEFUN_YANG (neighbor_nexthop_self
,
5700 neighbor_nexthop_self_cmd
,
5701 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5704 "Disable the next hop calculation for this neighbor\n")
5707 char base_xpath
[XPATH_MAXLEN
];
5708 char af_xpath
[XPATH_MAXLEN
];
5709 char attr_xpath
[XPATH_MAXLEN
];
5710 afi_t afi
= bgp_node_afi(vty
);
5711 safi_t safi
= bgp_node_safi(vty
);
5713 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5714 yang_afi_safi_value2identity(afi
, safi
));
5716 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5717 sizeof(base_xpath
), af_xpath
)
5719 return CMD_WARNING_CONFIG_FAILED
;
5721 snprintf(attr_xpath
, sizeof(attr_xpath
),
5722 "./%s/nexthop-self/next-hop-self",
5723 bgp_afi_safi_get_container_str(afi
, safi
));
5725 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5727 return nb_cli_apply_changes(vty
, base_xpath
);
5730 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5731 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5732 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5733 "Disable the next hop calculation for this neighbor\n")
5735 /* neighbor next-hop-self. */
5736 DEFUN_YANG(neighbor_nexthop_self_force
,
5737 neighbor_nexthop_self_force_cmd
,
5738 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5741 "Disable the next hop calculation for this neighbor\n"
5742 "Set the next hop to self for reflected routes\n")
5745 char base_xpath
[XPATH_MAXLEN
];
5746 char af_xpath
[XPATH_MAXLEN
];
5747 char attr_xpath
[XPATH_MAXLEN
];
5748 afi_t afi
= bgp_node_afi(vty
);
5749 safi_t safi
= bgp_node_safi(vty
);
5751 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5752 yang_afi_safi_value2identity(afi
, safi
));
5754 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5755 sizeof(base_xpath
), af_xpath
)
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 snprintf(attr_xpath
, sizeof(attr_xpath
),
5760 "./%s/nexthop-self/next-hop-self-force",
5761 bgp_afi_safi_get_container_str(afi
, safi
));
5763 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5765 return nb_cli_apply_changes(vty
, base_xpath
);
5768 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5769 neighbor_nexthop_self_force_hidden_cmd
,
5770 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5771 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5772 "Disable the next hop calculation for this neighbor\n"
5773 "Set the next hop to self for reflected routes\n")
5775 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5776 neighbor_nexthop_self_all_hidden_cmd
,
5777 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5778 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5779 "Disable the next hop calculation for this neighbor\n"
5780 "Set the next hop to self for reflected routes\n")
5782 DEFUN_YANG (no_neighbor_nexthop_self
,
5783 no_neighbor_nexthop_self_cmd
,
5784 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5788 "Disable the next hop calculation for this neighbor\n")
5791 char base_xpath
[XPATH_MAXLEN
];
5792 char af_xpath
[XPATH_MAXLEN
];
5793 char attr_xpath
[XPATH_MAXLEN
];
5794 afi_t afi
= bgp_node_afi(vty
);
5795 safi_t safi
= bgp_node_safi(vty
);
5797 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5798 yang_afi_safi_value2identity(afi
, safi
));
5800 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5801 sizeof(base_xpath
), af_xpath
)
5803 return CMD_WARNING_CONFIG_FAILED
;
5805 snprintf(attr_xpath
, sizeof(attr_xpath
),
5806 "./%s/nexthop-self/next-hop-self",
5807 bgp_afi_safi_get_container_str(afi
, safi
));
5809 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5811 return nb_cli_apply_changes(vty
, base_xpath
);
5814 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5815 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5816 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5817 "Disable the next hop calculation for this neighbor\n")
5819 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5820 no_neighbor_nexthop_self_force_cmd
,
5821 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5825 "Disable the next hop calculation for this neighbor\n"
5826 "Set the next hop to self for reflected routes\n")
5829 char base_xpath
[XPATH_MAXLEN
];
5830 char af_xpath
[XPATH_MAXLEN
];
5831 char attr_xpath
[XPATH_MAXLEN
];
5832 afi_t afi
= bgp_node_afi(vty
);
5833 safi_t safi
= bgp_node_safi(vty
);
5835 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5836 yang_afi_safi_value2identity(afi
, safi
));
5838 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5839 sizeof(base_xpath
), af_xpath
)
5841 return CMD_WARNING_CONFIG_FAILED
;
5843 snprintf(attr_xpath
, sizeof(attr_xpath
),
5844 "./%s/nexthop-self/next-hop-self-force",
5845 bgp_afi_safi_get_container_str(afi
, safi
));
5847 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5849 return nb_cli_apply_changes(vty
, base_xpath
);
5852 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5853 no_neighbor_nexthop_self_force_hidden_cmd
,
5854 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5855 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5856 "Disable the next hop calculation for this neighbor\n"
5857 "Set the next hop to self for reflected routes\n")
5859 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5860 no_neighbor_nexthop_self_all_hidden_cmd
,
5861 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5862 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5863 "Disable the next hop calculation for this neighbor\n"
5864 "Set the next hop to self for reflected routes\n")
5866 /* neighbor as-override */
5867 DEFUN_YANG (neighbor_as_override
,
5868 neighbor_as_override_cmd
,
5869 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5872 "Override ASNs in outbound updates if aspath equals remote-as\n")
5875 char base_xpath
[XPATH_MAXLEN
];
5876 char af_xpath
[XPATH_MAXLEN
];
5877 char attr_xpath
[XPATH_MAXLEN
];
5878 afi_t afi
= bgp_node_afi(vty
);
5879 safi_t safi
= bgp_node_safi(vty
);
5881 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5882 yang_afi_safi_value2identity(afi
, safi
));
5884 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5885 sizeof(base_xpath
), af_xpath
)
5887 return CMD_WARNING_CONFIG_FAILED
;
5889 snprintf(attr_xpath
, sizeof(attr_xpath
),
5890 "./%s/as-path-options/replace-peer-as",
5891 bgp_afi_safi_get_container_str(afi
, safi
));
5893 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5895 return nb_cli_apply_changes(vty
, base_xpath
);
5898 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5899 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5900 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5901 "Override ASNs in outbound updates if aspath equals remote-as\n")
5903 DEFUN_YANG (no_neighbor_as_override
,
5904 no_neighbor_as_override_cmd
,
5905 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5909 "Override ASNs in outbound updates if aspath equals remote-as\n")
5912 char base_xpath
[XPATH_MAXLEN
];
5913 char af_xpath
[XPATH_MAXLEN
];
5914 char attr_xpath
[XPATH_MAXLEN
];
5915 afi_t afi
= bgp_node_afi(vty
);
5916 safi_t safi
= bgp_node_safi(vty
);
5918 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5919 yang_afi_safi_value2identity(afi
, safi
));
5921 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5922 sizeof(base_xpath
), af_xpath
)
5924 return CMD_WARNING_CONFIG_FAILED
;
5926 snprintf(attr_xpath
, sizeof(attr_xpath
),
5927 "./%s/as-path-options/replace-peer-as",
5928 bgp_afi_safi_get_container_str(afi
, safi
));
5930 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5932 return nb_cli_apply_changes(vty
, base_xpath
);
5935 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5936 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5937 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5938 "Override ASNs in outbound updates if aspath equals remote-as\n")
5940 /* neighbor remove-private-AS. */
5941 DEFUN_YANG (neighbor_remove_private_as
,
5942 neighbor_remove_private_as_cmd
,
5943 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5946 "Remove private ASNs in outbound updates\n")
5949 char base_xpath
[XPATH_MAXLEN
];
5950 char af_xpath
[XPATH_MAXLEN
];
5951 char attr_xpath
[XPATH_MAXLEN
];
5952 afi_t afi
= bgp_node_afi(vty
);
5953 safi_t safi
= bgp_node_safi(vty
);
5955 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5956 yang_afi_safi_value2identity(afi
, safi
));
5958 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5959 sizeof(base_xpath
), af_xpath
)
5961 return CMD_WARNING_CONFIG_FAILED
;
5963 snprintf(attr_xpath
, sizeof(attr_xpath
),
5964 "./%s/private-as/remove-private-as",
5965 bgp_afi_safi_get_container_str(afi
, safi
));
5967 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5969 return nb_cli_apply_changes(vty
, base_xpath
);
5972 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5975 "Remove private ASNs in outbound updates\n")
5977 DEFUN_YANG (neighbor_remove_private_as_all
,
5978 neighbor_remove_private_as_all_cmd
,
5979 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5982 "Remove private ASNs in outbound updates\n"
5983 "Apply to all AS numbers\n")
5986 char base_xpath
[XPATH_MAXLEN
];
5987 char af_xpath
[XPATH_MAXLEN
];
5988 char attr_xpath
[XPATH_MAXLEN
];
5989 afi_t afi
= bgp_node_afi(vty
);
5990 safi_t safi
= bgp_node_safi(vty
);
5992 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5993 yang_afi_safi_value2identity(afi
, safi
));
5995 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5996 sizeof(base_xpath
), af_xpath
)
5998 return CMD_WARNING_CONFIG_FAILED
;
6000 snprintf(attr_xpath
, sizeof(attr_xpath
),
6001 "./%s/private-as/remove-private-as-all",
6002 bgp_afi_safi_get_container_str(afi
, safi
));
6004 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6006 return nb_cli_apply_changes(vty
, base_xpath
);
6009 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
6010 neighbor_remove_private_as_all_hidden_cmd
,
6011 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6012 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6013 "Remove private ASNs in outbound updates\n"
6014 "Apply to all AS numbers")
6016 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
6017 neighbor_remove_private_as_replace_as_cmd
,
6018 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6021 "Remove private ASNs in outbound updates\n"
6022 "Replace private ASNs with our ASN in outbound updates\n")
6025 char base_xpath
[XPATH_MAXLEN
];
6026 char af_xpath
[XPATH_MAXLEN
];
6027 char attr_xpath
[XPATH_MAXLEN
];
6028 afi_t afi
= bgp_node_afi(vty
);
6029 safi_t safi
= bgp_node_safi(vty
);
6031 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6032 yang_afi_safi_value2identity(afi
, safi
));
6034 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6035 sizeof(base_xpath
), af_xpath
)
6037 return CMD_WARNING_CONFIG_FAILED
;
6039 snprintf(attr_xpath
, sizeof(attr_xpath
),
6040 "./%s/private-as/remove-private-as-replace",
6041 bgp_afi_safi_get_container_str(afi
, safi
));
6043 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6045 return nb_cli_apply_changes(vty
, base_xpath
);
6048 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
6049 neighbor_remove_private_as_replace_as_hidden_cmd
,
6050 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6051 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6052 "Remove private ASNs in outbound updates\n"
6053 "Replace private ASNs with our ASN in outbound updates\n")
6055 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
6056 neighbor_remove_private_as_all_replace_as_cmd
,
6057 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6060 "Remove private ASNs in outbound updates\n"
6061 "Apply to all AS numbers\n"
6062 "Replace private ASNs with our ASN in outbound updates\n")
6065 char base_xpath
[XPATH_MAXLEN
];
6066 char af_xpath
[XPATH_MAXLEN
];
6067 char attr_xpath
[XPATH_MAXLEN
];
6068 afi_t afi
= bgp_node_afi(vty
);
6069 safi_t safi
= bgp_node_safi(vty
);
6071 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6072 yang_afi_safi_value2identity(afi
, safi
));
6074 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6075 sizeof(base_xpath
), af_xpath
)
6077 return CMD_WARNING_CONFIG_FAILED
;
6079 snprintf(attr_xpath
, sizeof(attr_xpath
),
6080 "./%s/private-as/remove-private-as-all-replace",
6081 bgp_afi_safi_get_container_str(afi
, safi
));
6083 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6085 return nb_cli_apply_changes(vty
, base_xpath
);
6089 neighbor_remove_private_as_all_replace_as
,
6090 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6091 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6092 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6093 "Remove private ASNs in outbound updates\n"
6094 "Apply to all AS numbers\n"
6095 "Replace private ASNs with our ASN in outbound updates\n")
6097 DEFUN_YANG (no_neighbor_remove_private_as
,
6098 no_neighbor_remove_private_as_cmd
,
6099 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6103 "Remove private ASNs in outbound updates\n")
6106 char base_xpath
[XPATH_MAXLEN
];
6107 char af_xpath
[XPATH_MAXLEN
];
6108 char attr_xpath
[XPATH_MAXLEN
];
6109 afi_t afi
= bgp_node_afi(vty
);
6110 safi_t safi
= bgp_node_safi(vty
);
6112 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6113 yang_afi_safi_value2identity(afi
, safi
));
6115 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6116 sizeof(base_xpath
), af_xpath
)
6118 return CMD_WARNING_CONFIG_FAILED
;
6120 snprintf(attr_xpath
, sizeof(attr_xpath
),
6121 "./%s/private-as/remove-private-as",
6122 bgp_afi_safi_get_container_str(afi
, safi
));
6124 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6126 return nb_cli_apply_changes(vty
, base_xpath
);
6129 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
6130 no_neighbor_remove_private_as_hidden_cmd
,
6131 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6132 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6133 "Remove private ASNs in outbound updates\n")
6135 DEFUN_YANG (no_neighbor_remove_private_as_all
,
6136 no_neighbor_remove_private_as_all_cmd
,
6137 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6141 "Remove private ASNs in outbound updates\n"
6142 "Apply to all AS numbers\n")
6145 char base_xpath
[XPATH_MAXLEN
];
6146 char af_xpath
[XPATH_MAXLEN
];
6147 char attr_xpath
[XPATH_MAXLEN
];
6148 afi_t afi
= bgp_node_afi(vty
);
6149 safi_t safi
= bgp_node_safi(vty
);
6151 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6152 yang_afi_safi_value2identity(afi
, safi
));
6154 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6155 sizeof(base_xpath
), af_xpath
)
6157 return CMD_WARNING_CONFIG_FAILED
;
6159 snprintf(attr_xpath
, sizeof(attr_xpath
),
6160 "./%s/private-as/remove-private-as-all",
6161 bgp_afi_safi_get_container_str(afi
, safi
));
6163 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6165 return nb_cli_apply_changes(vty
, base_xpath
);
6168 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6169 no_neighbor_remove_private_as_all_hidden_cmd
,
6170 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6171 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6172 "Remove private ASNs in outbound updates\n"
6173 "Apply to all AS numbers\n")
6175 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6176 no_neighbor_remove_private_as_replace_as_cmd
,
6177 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6181 "Remove private ASNs in outbound updates\n"
6182 "Replace private ASNs with our ASN in outbound updates\n")
6185 char base_xpath
[XPATH_MAXLEN
];
6186 char af_xpath
[XPATH_MAXLEN
];
6187 char attr_xpath
[XPATH_MAXLEN
];
6188 afi_t afi
= bgp_node_afi(vty
);
6189 safi_t safi
= bgp_node_safi(vty
);
6191 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6192 yang_afi_safi_value2identity(afi
, safi
));
6194 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6195 sizeof(base_xpath
), af_xpath
)
6197 return CMD_WARNING_CONFIG_FAILED
;
6199 snprintf(attr_xpath
, sizeof(attr_xpath
),
6200 "./%s/private-as/remove-private-as-replace",
6201 bgp_afi_safi_get_container_str(afi
, safi
));
6203 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6205 return nb_cli_apply_changes(vty
, base_xpath
);
6208 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6209 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6210 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6211 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6212 "Remove private ASNs in outbound updates\n"
6213 "Replace private ASNs with our ASN in outbound updates\n")
6215 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6216 no_neighbor_remove_private_as_all_replace_as_cmd
,
6217 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6221 "Remove private ASNs in outbound updates\n"
6222 "Apply to all AS numbers\n"
6223 "Replace private ASNs with our ASN in outbound updates\n")
6226 char base_xpath
[XPATH_MAXLEN
];
6227 char af_xpath
[XPATH_MAXLEN
];
6228 char attr_xpath
[XPATH_MAXLEN
];
6229 afi_t afi
= bgp_node_afi(vty
);
6230 safi_t safi
= bgp_node_safi(vty
);
6232 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6233 yang_afi_safi_value2identity(afi
, safi
));
6235 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6236 sizeof(base_xpath
), af_xpath
)
6238 return CMD_WARNING_CONFIG_FAILED
;
6240 snprintf(attr_xpath
, sizeof(attr_xpath
),
6241 "./%s/private-as/remove-private-as-all-replace",
6242 bgp_afi_safi_get_container_str(afi
, safi
));
6244 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6246 return nb_cli_apply_changes(vty
, base_xpath
);
6250 no_neighbor_remove_private_as_all_replace_as
,
6251 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6252 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6253 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6254 "Remove private ASNs in outbound updates\n"
6255 "Apply to all AS numbers\n"
6256 "Replace private ASNs with our ASN in outbound updates\n")
6259 /* neighbor send-community. */
6260 DEFUN_YANG (neighbor_send_community
,
6261 neighbor_send_community_cmd
,
6262 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6265 "Send Community attribute to this neighbor\n")
6268 char *peer_str
= argv
[idx_peer
]->arg
;
6269 char base_xpath
[XPATH_MAXLEN
];
6270 char af_xpath
[XPATH_MAXLEN
];
6271 char std_xpath
[XPATH_MAXLEN
];
6272 afi_t afi
= bgp_node_afi(vty
);
6273 safi_t safi
= bgp_node_safi(vty
);
6275 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6276 yang_afi_safi_value2identity(afi
, safi
));
6278 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6279 sizeof(base_xpath
), af_xpath
)
6281 return CMD_WARNING_CONFIG_FAILED
;
6283 snprintf(std_xpath
, sizeof(std_xpath
),
6284 "./%s/send-community/send-community",
6285 bgp_afi_safi_get_container_str(afi
, safi
));
6287 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6289 return nb_cli_apply_changes(vty
, base_xpath
);
6292 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6293 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6294 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6295 "Send Community attribute to this neighbor\n")
6297 DEFUN_YANG (no_neighbor_send_community
,
6298 no_neighbor_send_community_cmd
,
6299 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6303 "Send Community attribute to this neighbor\n")
6306 char *peer_str
= argv
[idx_peer
]->arg
;
6307 char base_xpath
[XPATH_MAXLEN
];
6308 char af_xpath
[XPATH_MAXLEN
];
6309 char std_xpath
[XPATH_MAXLEN
];
6310 afi_t afi
= bgp_node_afi(vty
);
6311 safi_t safi
= bgp_node_safi(vty
);
6313 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6314 yang_afi_safi_value2identity(afi
, safi
));
6316 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6317 sizeof(base_xpath
), af_xpath
)
6319 return CMD_WARNING_CONFIG_FAILED
;
6321 snprintf(std_xpath
, sizeof(std_xpath
),
6322 "./%s/send-community/send-community",
6323 bgp_afi_safi_get_container_str(afi
, safi
));
6325 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6327 return nb_cli_apply_changes(vty
, base_xpath
);
6330 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6331 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6332 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6333 "Send Community attribute to this neighbor\n")
6335 /* neighbor send-community extended. */
6336 DEFUN_YANG (neighbor_send_community_type
,
6337 neighbor_send_community_type_cmd
,
6338 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6341 "Send Community attribute to this neighbor\n"
6342 "Send Standard and Extended Community attributes\n"
6343 "Send Standard, Large and Extended Community attributes\n"
6344 "Send Extended Community attributes\n"
6345 "Send Standard Community attributes\n"
6346 "Send Large Community attributes\n")
6348 const char *type
= argv
[argc
- 1]->text
;
6349 char *peer_str
= argv
[1]->arg
;
6350 char base_xpath
[XPATH_MAXLEN
];
6351 char af_xpath
[XPATH_MAXLEN
];
6352 char std_xpath
[XPATH_MAXLEN
];
6353 char ext_xpath
[XPATH_MAXLEN
];
6354 char lrg_xpath
[XPATH_MAXLEN
];
6355 afi_t afi
= bgp_node_afi(vty
);
6356 safi_t safi
= bgp_node_safi(vty
);
6358 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6359 yang_afi_safi_value2identity(afi
, safi
));
6361 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6362 sizeof(base_xpath
), af_xpath
)
6364 return CMD_WARNING_CONFIG_FAILED
;
6366 if (strmatch(type
, "standard")) {
6367 snprintf(std_xpath
, sizeof(std_xpath
),
6368 "./%s/send-community/send-community",
6369 bgp_afi_safi_get_container_str(afi
, safi
));
6371 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6374 if (strmatch(type
, "extended")) {
6375 snprintf(ext_xpath
, sizeof(ext_xpath
),
6376 "./%s/send-community/send-ext-community",
6377 bgp_afi_safi_get_container_str(afi
, safi
));
6379 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6382 if (strmatch(type
, "large")) {
6383 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6384 "./%s/send-community/send-large-community",
6385 bgp_afi_safi_get_container_str(afi
, safi
));
6387 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6390 if (strmatch(type
, "both")) {
6391 snprintf(std_xpath
, sizeof(std_xpath
),
6392 "./%s/send-community/send-community",
6393 bgp_afi_safi_get_container_str(afi
, safi
));
6395 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6397 snprintf(ext_xpath
, sizeof(ext_xpath
),
6398 "./%s/send-community/send-ext-community",
6399 bgp_afi_safi_get_container_str(afi
, safi
));
6401 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6404 if (strmatch(type
, "all")) {
6405 snprintf(std_xpath
, sizeof(std_xpath
),
6406 "./%s/send-community/send-community",
6407 bgp_afi_safi_get_container_str(afi
, safi
));
6409 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6411 snprintf(ext_xpath
, sizeof(ext_xpath
),
6412 "./%s/send-community/send-ext-community",
6413 bgp_afi_safi_get_container_str(afi
, safi
));
6415 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6417 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6418 "./%s/send-community/send-large-community",
6419 bgp_afi_safi_get_container_str(afi
, safi
));
6421 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6424 return nb_cli_apply_changes(vty
, base_xpath
);
6428 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6429 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6430 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6431 "Send Community attribute to this neighbor\n"
6432 "Send Standard and Extended Community attributes\n"
6433 "Send Standard, Large and Extended Community attributes\n"
6434 "Send Extended Community attributes\n"
6435 "Send Standard Community attributes\n"
6436 "Send Large Community attributes\n")
6438 DEFUN_YANG (no_neighbor_send_community_type
,
6439 no_neighbor_send_community_type_cmd
,
6440 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6444 "Send Community attribute to this neighbor\n"
6445 "Send Standard and Extended Community attributes\n"
6446 "Send Standard, Large and Extended Community attributes\n"
6447 "Send Extended Community attributes\n"
6448 "Send Standard Community attributes\n"
6449 "Send Large Community attributes\n")
6451 const char *type
= argv
[argc
- 1]->text
;
6452 char *peer_str
= argv
[2]->arg
;
6453 char base_xpath
[XPATH_MAXLEN
];
6454 char af_xpath
[XPATH_MAXLEN
];
6455 char std_xpath
[XPATH_MAXLEN
];
6456 char ext_xpath
[XPATH_MAXLEN
];
6457 char lrg_xpath
[XPATH_MAXLEN
];
6458 afi_t afi
= bgp_node_afi(vty
);
6459 safi_t safi
= bgp_node_safi(vty
);
6461 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6462 yang_afi_safi_value2identity(afi
, safi
));
6464 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6465 sizeof(base_xpath
), af_xpath
)
6467 return CMD_WARNING_CONFIG_FAILED
;
6469 if (strmatch(type
, "standard")) {
6470 snprintf(std_xpath
, sizeof(std_xpath
),
6471 "./%s/send-community/send-community",
6472 bgp_afi_safi_get_container_str(afi
, safi
));
6474 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6477 if (strmatch(type
, "extended")) {
6478 snprintf(ext_xpath
, sizeof(ext_xpath
),
6479 "./%s/send-community/send-ext-community",
6480 bgp_afi_safi_get_container_str(afi
, safi
));
6482 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6485 if (strmatch(type
, "large")) {
6486 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6487 "./%s/send-community/send-large-community",
6488 bgp_afi_safi_get_container_str(afi
, safi
));
6490 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6493 if (strmatch(type
, "both")) {
6494 snprintf(std_xpath
, sizeof(std_xpath
),
6495 "./%s/send-community/send-community",
6496 bgp_afi_safi_get_container_str(afi
, safi
));
6498 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6500 snprintf(ext_xpath
, sizeof(ext_xpath
),
6501 "./%s/send-community/send-ext-community",
6502 bgp_afi_safi_get_container_str(afi
, safi
));
6504 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6507 if (strmatch(type
, "all")) {
6508 snprintf(std_xpath
, sizeof(std_xpath
),
6509 "./%s/send-community/send-community",
6510 bgp_afi_safi_get_container_str(afi
, safi
));
6512 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6514 snprintf(ext_xpath
, sizeof(ext_xpath
),
6515 "./%s/send-community/send-ext-community",
6516 bgp_afi_safi_get_container_str(afi
, safi
));
6518 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6520 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6521 "./%s/send-community/send-large-community",
6522 bgp_afi_safi_get_container_str(afi
, safi
));
6524 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6527 return nb_cli_apply_changes(vty
, base_xpath
);
6531 no_neighbor_send_community_type
,
6532 no_neighbor_send_community_type_hidden_cmd
,
6533 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6534 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6535 "Send Community attribute to this neighbor\n"
6536 "Send Standard and Extended Community attributes\n"
6537 "Send Standard, Large and Extended Community attributes\n"
6538 "Send Extended Community attributes\n"
6539 "Send Standard Community attributes\n"
6540 "Send Large Community attributes\n")
6542 /* neighbor soft-reconfig. */
6543 DEFUN_YANG (neighbor_soft_reconfiguration
,
6544 neighbor_soft_reconfiguration_cmd
,
6545 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6546 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6547 "Per neighbor soft reconfiguration\n"
6548 "Allow inbound soft reconfiguration for this neighbor\n")
6551 char base_xpath
[XPATH_MAXLEN
];
6552 char af_xpath
[XPATH_MAXLEN
];
6553 char soft_xpath
[XPATH_MAXLEN
];
6554 afi_t afi
= bgp_node_afi(vty
);
6555 safi_t safi
= bgp_node_safi(vty
);
6557 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6558 yang_afi_safi_value2identity(afi
, safi
));
6560 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6561 sizeof(base_xpath
), af_xpath
)
6563 return CMD_WARNING_CONFIG_FAILED
;
6565 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6566 bgp_afi_safi_get_container_str(afi
, safi
));
6568 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6570 return nb_cli_apply_changes(vty
, base_xpath
);
6573 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6574 neighbor_soft_reconfiguration_hidden_cmd
,
6575 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6576 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6577 "Per neighbor soft reconfiguration\n"
6578 "Allow inbound soft reconfiguration for this neighbor\n")
6580 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6581 no_neighbor_soft_reconfiguration_cmd
,
6582 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6583 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6584 "Per neighbor soft reconfiguration\n"
6585 "Allow inbound soft reconfiguration for this neighbor\n")
6588 char base_xpath
[XPATH_MAXLEN
];
6589 char af_xpath
[XPATH_MAXLEN
];
6590 char soft_xpath
[XPATH_MAXLEN
];
6591 afi_t afi
= bgp_node_afi(vty
);
6592 safi_t safi
= bgp_node_safi(vty
);
6594 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6595 yang_afi_safi_value2identity(afi
, safi
));
6597 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6598 bgp_afi_safi_get_container_str(afi
, safi
));
6600 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6601 sizeof(base_xpath
), af_xpath
)
6603 return CMD_WARNING_CONFIG_FAILED
;
6605 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6607 return nb_cli_apply_changes(vty
, base_xpath
);
6610 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6611 no_neighbor_soft_reconfiguration_hidden_cmd
,
6612 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6613 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6614 "Per neighbor soft reconfiguration\n"
6615 "Allow inbound soft reconfiguration for this neighbor\n")
6617 DEFUN_YANG (neighbor_route_reflector_client
,
6618 neighbor_route_reflector_client_cmd
,
6619 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6622 "Configure a neighbor as Route Reflector client\n")
6625 char base_xpath
[XPATH_MAXLEN
];
6626 char af_xpath
[XPATH_MAXLEN
];
6627 char attr_xpath
[XPATH_MAXLEN
];
6628 afi_t afi
= bgp_node_afi(vty
);
6629 safi_t safi
= bgp_node_safi(vty
);
6631 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6632 yang_afi_safi_value2identity(afi
, safi
));
6634 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6635 sizeof(base_xpath
), af_xpath
)
6637 return CMD_WARNING_CONFIG_FAILED
;
6639 snprintf(attr_xpath
, sizeof(attr_xpath
),
6640 "./%s/route-reflector/route-reflector-client",
6641 bgp_afi_safi_get_container_str(afi
, safi
));
6643 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6645 return nb_cli_apply_changes(vty
, base_xpath
);
6648 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6649 neighbor_route_reflector_client_hidden_cmd
,
6650 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6651 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6652 "Configure a neighbor as Route Reflector client\n")
6654 DEFUN_YANG (no_neighbor_route_reflector_client
,
6655 no_neighbor_route_reflector_client_cmd
,
6656 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6660 "Configure a neighbor as Route Reflector client\n")
6663 char base_xpath
[XPATH_MAXLEN
];
6664 char af_xpath
[XPATH_MAXLEN
];
6665 char attr_xpath
[XPATH_MAXLEN
];
6666 afi_t afi
= bgp_node_afi(vty
);
6667 safi_t safi
= bgp_node_safi(vty
);
6669 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6670 yang_afi_safi_value2identity(afi
, safi
));
6672 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6673 sizeof(base_xpath
), af_xpath
)
6675 return CMD_WARNING_CONFIG_FAILED
;
6677 snprintf(attr_xpath
, sizeof(attr_xpath
),
6678 "./%s/route-reflector/route-reflector-client",
6679 bgp_afi_safi_get_container_str(afi
, safi
));
6681 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6683 return nb_cli_apply_changes(vty
, base_xpath
);
6686 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6687 no_neighbor_route_reflector_client_hidden_cmd
,
6688 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6689 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6690 "Configure a neighbor as Route Reflector client\n")
6692 /* neighbor route-server-client. */
6693 DEFUN_YANG (neighbor_route_server_client
,
6694 neighbor_route_server_client_cmd
,
6695 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6698 "Configure a neighbor as Route Server client\n")
6701 char base_xpath
[XPATH_MAXLEN
];
6702 char af_xpath
[XPATH_MAXLEN
];
6703 char attr_xpath
[XPATH_MAXLEN
];
6704 afi_t afi
= bgp_node_afi(vty
);
6705 safi_t safi
= bgp_node_safi(vty
);
6707 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6708 yang_afi_safi_value2identity(afi
, safi
));
6710 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6711 sizeof(base_xpath
), af_xpath
)
6713 return CMD_WARNING_CONFIG_FAILED
;
6715 snprintf(attr_xpath
, sizeof(attr_xpath
),
6716 "./%s/route-server/route-server-client",
6717 bgp_afi_safi_get_container_str(afi
, safi
));
6719 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6721 return nb_cli_apply_changes(vty
, base_xpath
);
6724 ALIAS_HIDDEN(neighbor_route_server_client
,
6725 neighbor_route_server_client_hidden_cmd
,
6726 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6727 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6728 "Configure a neighbor as Route Server client\n")
6730 DEFUN_YANG (no_neighbor_route_server_client
,
6731 no_neighbor_route_server_client_cmd
,
6732 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6736 "Configure a neighbor as Route Server client\n")
6739 char base_xpath
[XPATH_MAXLEN
];
6740 char af_xpath
[XPATH_MAXLEN
];
6741 char attr_xpath
[XPATH_MAXLEN
];
6742 afi_t afi
= bgp_node_afi(vty
);
6743 safi_t safi
= bgp_node_safi(vty
);
6745 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6746 yang_afi_safi_value2identity(afi
, safi
));
6748 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6749 sizeof(base_xpath
), af_xpath
)
6751 return CMD_WARNING_CONFIG_FAILED
;
6753 snprintf(attr_xpath
, sizeof(attr_xpath
),
6754 "./%s/route-server/route-server-client",
6755 bgp_afi_safi_get_container_str(afi
, safi
));
6757 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6759 return nb_cli_apply_changes(vty
, base_xpath
);
6762 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6763 no_neighbor_route_server_client_hidden_cmd
,
6764 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6765 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6766 "Configure a neighbor as Route Server client\n")
6768 DEFUN (neighbor_nexthop_local_unchanged
,
6769 neighbor_nexthop_local_unchanged_cmd
,
6770 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6773 "Configure treatment of outgoing link-local nexthop attribute\n"
6774 "Leave link-local nexthop unchanged for this peer\n")
6777 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6779 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6782 DEFUN (no_neighbor_nexthop_local_unchanged
,
6783 no_neighbor_nexthop_local_unchanged_cmd
,
6784 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6788 "Configure treatment of outgoing link-local-nexthop attribute\n"
6789 "Leave link-local nexthop unchanged for this peer\n")
6792 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6793 bgp_node_afi(vty
), bgp_node_safi(vty
),
6794 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6797 DEFUN_YANG (neighbor_attr_unchanged
,
6798 neighbor_attr_unchanged_cmd
,
6799 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6802 "BGP attribute is propagated unchanged to this neighbor\n"
6803 "As-path attribute\n"
6804 "Nexthop attribute\n"
6808 char *peer_str
= argv
[1]->arg
;
6809 bool aspath
= false;
6810 bool nexthop
= false;
6812 afi_t afi
= bgp_node_afi(vty
);
6813 safi_t safi
= bgp_node_safi(vty
);
6814 char base_xpath
[XPATH_MAXLEN
];
6815 char af_xpath
[XPATH_MAXLEN
];
6816 char as_xpath
[XPATH_MAXLEN
];
6817 char nxthop_xpath
[XPATH_MAXLEN
];
6818 char med_xpath
[XPATH_MAXLEN
];
6820 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6821 yang_afi_safi_value2identity(afi
, safi
));
6823 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6824 sizeof(base_xpath
), af_xpath
)
6826 return CMD_WARNING_CONFIG_FAILED
;
6828 if (argv_find(argv
, argc
, "as-path", &idx
))
6832 if (argv_find(argv
, argc
, "next-hop", &idx
))
6836 if (argv_find(argv
, argc
, "med", &idx
))
6839 snprintf(as_xpath
, sizeof(as_xpath
),
6840 "./%s/attr-unchanged/as-path-unchanged",
6841 bgp_afi_safi_get_container_str(afi
, safi
));
6842 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6843 "./%s/attr-unchanged/next-hop-unchanged",
6844 bgp_afi_safi_get_container_str(afi
, safi
));
6845 snprintf(med_xpath
, sizeof(med_xpath
),
6846 "./%s/attr-unchanged/med-unchanged",
6847 bgp_afi_safi_get_container_str(afi
, safi
));
6849 /* no flags means all of them! */
6850 if (!aspath
&& !nexthop
&& !med
) {
6851 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6852 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6853 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6856 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6859 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6863 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6866 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6870 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6873 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6877 return nb_cli_apply_changes(vty
, base_xpath
);
6881 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6882 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6883 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6884 "BGP attribute is propagated unchanged to this neighbor\n"
6885 "As-path attribute\n"
6886 "Nexthop attribute\n"
6889 DEFUN_YANG (no_neighbor_attr_unchanged
,
6890 no_neighbor_attr_unchanged_cmd
,
6891 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6895 "BGP attribute is propagated unchanged to this neighbor\n"
6896 "As-path attribute\n"
6897 "Nexthop attribute\n"
6901 char *peer_str
= argv
[2]->arg
;
6902 bool aspath
= false;
6903 bool nexthop
= false;
6905 afi_t afi
= bgp_node_afi(vty
);
6906 safi_t safi
= bgp_node_safi(vty
);
6907 char base_xpath
[XPATH_MAXLEN
];
6908 char af_xpath
[XPATH_MAXLEN
];
6909 char as_xpath
[XPATH_MAXLEN
];
6910 char nxthop_xpath
[XPATH_MAXLEN
];
6911 char med_xpath
[XPATH_MAXLEN
];
6913 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6914 yang_afi_safi_value2identity(afi
, safi
));
6916 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6917 sizeof(base_xpath
), af_xpath
)
6919 return CMD_WARNING_CONFIG_FAILED
;
6921 if (argv_find(argv
, argc
, "as-path", &idx
))
6925 if (argv_find(argv
, argc
, "next-hop", &idx
))
6929 if (argv_find(argv
, argc
, "med", &idx
))
6932 snprintf(as_xpath
, sizeof(as_xpath
),
6933 "./%s/attr-unchanged/as-path-unchanged",
6934 bgp_afi_safi_get_container_str(afi
, safi
));
6935 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6936 "./%s/attr-unchanged/next-hop-unchanged",
6937 bgp_afi_safi_get_container_str(afi
, safi
));
6938 snprintf(med_xpath
, sizeof(med_xpath
),
6939 "./%s/attr-unchanged/med-unchanged",
6940 bgp_afi_safi_get_container_str(afi
, safi
));
6942 /* no flags means all of them! */
6943 if (!aspath
&& !nexthop
&& !med
) {
6944 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6945 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6946 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6950 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6953 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6956 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6958 return nb_cli_apply_changes(vty
, base_xpath
);
6962 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6963 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6964 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6965 "BGP attribute is propagated unchanged to this neighbor\n"
6966 "As-path attribute\n"
6967 "Nexthop attribute\n"
6970 /* neighbor ebgp-multihop. */
6971 DEFUN_YANG (neighbor_ebgp_multihop
,
6972 neighbor_ebgp_multihop_cmd
,
6973 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6975 "Allow EBGP neighbors not on directly connected networks\n")
6978 char base_xpath
[XPATH_MAXLEN
];
6980 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6981 sizeof(base_xpath
), NULL
)
6983 return CMD_WARNING_CONFIG_FAILED
;
6985 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6988 return nb_cli_apply_changes(vty
, base_xpath
);
6991 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6992 neighbor_ebgp_multihop_ttl_cmd
,
6993 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6994 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6995 "Allow EBGP neighbors not on directly connected networks\n"
6996 "maximum hop count\n")
7000 char base_xpath
[XPATH_MAXLEN
];
7002 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7003 sizeof(base_xpath
), NULL
)
7005 return CMD_WARNING_CONFIG_FAILED
;
7007 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
7008 argv
[idx_number
]->arg
);
7010 return nb_cli_apply_changes(vty
, base_xpath
);
7013 DEFUN_YANG (no_neighbor_ebgp_multihop
,
7014 no_neighbor_ebgp_multihop_cmd
,
7015 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
7016 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7017 "Allow EBGP neighbors not on directly connected networks\n"
7018 "maximum hop count\n")
7021 char base_xpath
[XPATH_MAXLEN
];
7023 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7024 sizeof(base_xpath
), NULL
)
7026 return CMD_WARNING_CONFIG_FAILED
;
7029 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
7030 NB_OP_DESTROY
, NULL
);
7032 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
7033 NB_OP_MODIFY
, "false");
7035 return nb_cli_apply_changes(vty
, base_xpath
);
7039 /* disable-connected-check */
7040 DEFUN_YANG (neighbor_disable_connected_check
,
7041 neighbor_disable_connected_check_cmd
,
7042 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
7043 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7044 "one-hop away EBGP peer using loopback address\n"
7045 "Enforce EBGP neighbors perform multihop\n")
7048 char base_xpath
[XPATH_MAXLEN
];
7050 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7051 sizeof(base_xpath
), NULL
)
7053 return CMD_WARNING_CONFIG_FAILED
;
7055 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
7056 NB_OP_MODIFY
, "true");
7058 return nb_cli_apply_changes(vty
, base_xpath
);
7061 DEFUN_YANG (no_neighbor_disable_connected_check
,
7062 no_neighbor_disable_connected_check_cmd
,
7063 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
7064 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7065 "one-hop away EBGP peer using loopback address\n"
7066 "Enforce EBGP neighbors perform multihop\n")
7069 char base_xpath
[XPATH_MAXLEN
];
7071 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7072 sizeof(base_xpath
), NULL
)
7074 return CMD_WARNING_CONFIG_FAILED
;
7076 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
7077 NB_OP_MODIFY
, "false");
7079 return nb_cli_apply_changes(vty
, base_xpath
);
7083 /* enforce-first-as */
7084 DEFUN_YANG (neighbor_enforce_first_as
,
7085 neighbor_enforce_first_as_cmd
,
7086 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
7087 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7088 "Enforce the first AS for EBGP routes\n")
7091 char base_xpath
[XPATH_MAXLEN
];
7093 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7094 sizeof(base_xpath
), NULL
)
7096 return CMD_WARNING_CONFIG_FAILED
;
7098 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
7100 return nb_cli_apply_changes(vty
, base_xpath
);
7103 DEFUN_YANG (no_neighbor_enforce_first_as
,
7104 no_neighbor_enforce_first_as_cmd
,
7105 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
7106 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7107 "Enforce the first AS for EBGP routes\n")
7110 char base_xpath
[XPATH_MAXLEN
];
7112 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7113 sizeof(base_xpath
), NULL
)
7115 return CMD_WARNING_CONFIG_FAILED
;
7117 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
7119 return nb_cli_apply_changes(vty
, base_xpath
);
7122 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
7123 char *base_xpath
, int xpath_len
,
7127 char num_xpath
[XPATH_MAXLEN
];
7128 char unnbr_xpath
[XPATH_MAXLEN
];
7129 char prgrp_xpath
[XPATH_MAXLEN
];
7131 if (str2sockunion(peer_str
, &su
) == 0) {
7132 snprintf(num_xpath
, sizeof(num_xpath
),
7133 "/neighbors/neighbor[remote-address='%s']", peer_str
);
7134 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
7135 VTY_CURR_XPATH
, num_xpath
)) {
7136 snprintf(base_xpath
, xpath_len
,
7137 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
7138 xpath
? xpath
: "");
7141 "%% Specify remote-as or peer-group commands first\n");
7146 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
7147 "/neighbors/unnumbered-neighbor[interface='%s']",
7150 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
7151 "/peer-groups/peer-group[peer-group-name='%s']",
7154 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
7155 VTY_CURR_XPATH
, unnbr_xpath
)) {
7156 snprintf(base_xpath
, xpath_len
,
7157 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
7158 xpath
? xpath
: "");
7159 } else if (yang_dnode_existsf(vty
->candidate_config
->dnode
,
7160 "%s%s", VTY_CURR_XPATH
,
7162 snprintf(base_xpath
, xpath_len
,
7163 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
7164 xpath
? xpath
: "");
7167 "%% Create the peer-group or interface first\n");
7175 DEFUN_YANG (neighbor_description
,
7176 neighbor_description_cmd
,
7177 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7178 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7179 "Neighbor specific description\n"
7180 "Up to 80 characters describing this neighbor\n")
7185 char base_xpath
[XPATH_MAXLEN
];
7188 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7189 sizeof(base_xpath
), NULL
)
7191 return CMD_WARNING_CONFIG_FAILED
;
7193 str
= argv_concat(argv
, argc
, idx_line
);
7195 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
7197 ret
= nb_cli_apply_changes(vty
, base_xpath
);
7199 XFREE(MTYPE_TMP
, str
);
7204 DEFUN_YANG (no_neighbor_description
,
7205 no_neighbor_description_cmd
,
7206 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
7207 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7208 "Neighbor specific description\n")
7211 char base_xpath
[XPATH_MAXLEN
];
7213 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7214 sizeof(base_xpath
), NULL
)
7216 return CMD_WARNING_CONFIG_FAILED
;
7218 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7220 return nb_cli_apply_changes(vty
, base_xpath
);
7223 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7224 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7225 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7226 "Neighbor specific description\n"
7227 "Up to 80 characters describing this neighbor\n")
7229 #define BGP_UPDATE_SOURCE_HELP_STR \
7232 "Interface name (requires zebra to be running)\n"
7234 DEFUN_YANG (neighbor_update_source
,
7235 neighbor_update_source_cmd
,
7236 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7237 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7238 "Source of routing updates\n"
7239 BGP_UPDATE_SOURCE_HELP_STR
)
7244 char base_xpath
[XPATH_MAXLEN
];
7246 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7247 sizeof(base_xpath
), NULL
)
7249 return CMD_WARNING_CONFIG_FAILED
;
7251 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7252 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7253 argv
[idx_peer_2
]->arg
);
7255 nb_cli_enqueue_change(vty
, "./update-source/interface",
7256 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7258 return nb_cli_apply_changes(vty
, base_xpath
);
7261 DEFUN_YANG (no_neighbor_update_source
,
7262 no_neighbor_update_source_cmd
,
7263 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7266 "Source of routing updates\n"
7267 BGP_UPDATE_SOURCE_HELP_STR
)
7270 char base_xpath
[XPATH_MAXLEN
];
7272 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7273 sizeof(base_xpath
), NULL
)
7275 return CMD_WARNING_CONFIG_FAILED
;
7277 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7278 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7281 return nb_cli_apply_changes(vty
, base_xpath
);
7284 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7285 afi_t afi
, safi_t safi
,
7286 const char *rmap
, int set
)
7290 struct route_map
*route_map
= NULL
;
7292 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7294 return CMD_WARNING_CONFIG_FAILED
;
7298 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7299 ret
= peer_default_originate_set(peer
, afi
, safi
,
7302 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7304 return bgp_vty_return(vty
, ret
);
7307 /* neighbor default-originate. */
7308 DEFUN (neighbor_default_originate
,
7309 neighbor_default_originate_cmd
,
7310 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7313 "Originate default route to this neighbor\n")
7316 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7318 bgp_node_safi(vty
), NULL
, 1);
7321 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7322 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7323 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7324 "Originate default route to this neighbor\n")
7326 DEFUN (neighbor_default_originate_rmap
,
7327 neighbor_default_originate_rmap_cmd
,
7328 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7331 "Originate default route to this neighbor\n"
7332 "Route-map to specify criteria to originate default\n"
7337 return peer_default_originate_set_vty(
7338 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7339 argv
[idx_word
]->arg
, 1);
7343 neighbor_default_originate_rmap
,
7344 neighbor_default_originate_rmap_hidden_cmd
,
7345 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7346 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7347 "Originate default route to this neighbor\n"
7348 "Route-map to specify criteria to originate default\n"
7351 DEFUN (no_neighbor_default_originate
,
7352 no_neighbor_default_originate_cmd
,
7353 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7357 "Originate default route to this neighbor\n"
7358 "Route-map to specify criteria to originate default\n"
7362 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7364 bgp_node_safi(vty
), NULL
, 0);
7368 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7369 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7370 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7371 "Originate default route to this neighbor\n"
7372 "Route-map to specify criteria to originate default\n"
7376 /* Set specified peer's BGP port. */
7377 DEFUN_YANG (neighbor_port
,
7379 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7382 "Neighbor's BGP port\n"
7383 "TCP port number\n")
7387 char base_xpath
[XPATH_MAXLEN
];
7389 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7390 argv
[idx_ip
]->arg
, "");
7392 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7393 argv
[idx_number
]->arg
);
7395 return nb_cli_apply_changes(vty
, base_xpath
);
7398 DEFUN_YANG (no_neighbor_port
,
7399 no_neighbor_port_cmd
,
7400 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7401 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7402 "Neighbor's BGP port\n"
7403 "TCP port number\n")
7406 char base_xpath
[XPATH_MAXLEN
];
7408 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7409 argv
[idx_ip
]->arg
, "");
7411 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7413 return nb_cli_apply_changes(vty
, base_xpath
);
7416 DEFUN_YANG (neighbor_weight
,
7417 neighbor_weight_cmd
,
7418 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7419 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7420 "Set default weight for routes from this neighbor\n"
7425 char base_xpath
[XPATH_MAXLEN
];
7426 char af_xpath
[XPATH_MAXLEN
];
7427 char attr_xpath
[XPATH_MAXLEN
];
7428 afi_t afi
= bgp_node_afi(vty
);
7429 safi_t safi
= bgp_node_safi(vty
);
7431 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7432 yang_afi_safi_value2identity(afi
, safi
));
7434 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7435 sizeof(base_xpath
), af_xpath
)
7437 return CMD_WARNING_CONFIG_FAILED
;
7439 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7440 bgp_afi_safi_get_container_str(afi
, safi
));
7442 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7443 argv
[idx_number
]->arg
);
7445 return nb_cli_apply_changes(vty
, base_xpath
);
7448 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7449 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7450 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7451 "Set default weight for routes from this neighbor\n"
7454 DEFUN_YANG (no_neighbor_weight
,
7455 no_neighbor_weight_cmd
,
7456 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7457 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7458 "Set default weight for routes from this neighbor\n"
7462 char base_xpath
[XPATH_MAXLEN
];
7463 char af_xpath
[XPATH_MAXLEN
];
7464 char attr_xpath
[XPATH_MAXLEN
];
7465 afi_t afi
= bgp_node_afi(vty
);
7466 safi_t safi
= bgp_node_safi(vty
);
7468 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7469 yang_afi_safi_value2identity(afi
, safi
));
7471 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7472 sizeof(base_xpath
), af_xpath
)
7474 return CMD_WARNING_CONFIG_FAILED
;
7476 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7477 bgp_afi_safi_get_container_str(afi
, safi
));
7479 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7481 return nb_cli_apply_changes(vty
, base_xpath
);
7484 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7485 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7486 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7487 "Set default weight for routes from this neighbor\n"
7491 /* Override capability negotiation. */
7492 DEFUN_YANG (neighbor_override_capability
,
7493 neighbor_override_capability_cmd
,
7494 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7497 "Override capability negotiation result\n")
7500 char base_xpath
[XPATH_MAXLEN
];
7502 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7503 sizeof(base_xpath
), NULL
)
7505 return CMD_WARNING_CONFIG_FAILED
;
7507 nb_cli_enqueue_change(
7508 vty
, "./capability-options/override-capability",
7509 NB_OP_MODIFY
, "true");
7511 return nb_cli_apply_changes(vty
, base_xpath
);
7514 DEFUN_YANG (no_neighbor_override_capability
,
7515 no_neighbor_override_capability_cmd
,
7516 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7520 "Override capability negotiation result\n")
7523 char base_xpath
[XPATH_MAXLEN
];
7525 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7526 sizeof(base_xpath
), NULL
)
7528 return CMD_WARNING_CONFIG_FAILED
;
7530 nb_cli_enqueue_change(
7531 vty
, "./capability-options/override-capability",
7532 NB_OP_MODIFY
, "false");
7534 return nb_cli_apply_changes(vty
, base_xpath
);
7537 DEFUN_YANG (neighbor_strict_capability
,
7538 neighbor_strict_capability_cmd
,
7539 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7542 "Strict capability negotiation match\n")
7545 char base_xpath
[XPATH_MAXLEN
];
7547 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7548 sizeof(base_xpath
), NULL
)
7550 return CMD_WARNING_CONFIG_FAILED
;
7552 nb_cli_enqueue_change(
7553 vty
, "./capability-options/strict-capability",
7554 NB_OP_MODIFY
, "true");
7556 return nb_cli_apply_changes(vty
, base_xpath
);
7559 DEFUN_YANG (no_neighbor_strict_capability
,
7560 no_neighbor_strict_capability_cmd
,
7561 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7565 "Strict capability negotiation match\n")
7568 char base_xpath
[XPATH_MAXLEN
];
7570 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7571 sizeof(base_xpath
), NULL
)
7573 return CMD_WARNING_CONFIG_FAILED
;
7575 nb_cli_enqueue_change(
7576 vty
, "./capability-options/strict-capability",
7577 NB_OP_MODIFY
, "false");
7579 return nb_cli_apply_changes(vty
, base_xpath
);
7582 DEFUN_YANG (neighbor_timers
,
7583 neighbor_timers_cmd
,
7584 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7585 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7586 "BGP per neighbor timers\n"
7587 "Keepalive interval\n"
7592 int idx_number_2
= 4;
7593 char base_xpath
[XPATH_MAXLEN
];
7595 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7596 sizeof(base_xpath
), NULL
)
7598 return CMD_WARNING_CONFIG_FAILED
;
7600 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7601 argv
[idx_number
]->arg
);
7603 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7604 argv
[idx_number_2
]->arg
);
7606 return nb_cli_apply_changes(vty
, base_xpath
);
7609 DEFUN_YANG (no_neighbor_timers
,
7610 no_neighbor_timers_cmd
,
7611 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7612 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7613 "BGP per neighbor timers\n"
7614 "Keepalive interval\n"
7618 char base_xpath
[XPATH_MAXLEN
];
7620 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7621 sizeof(base_xpath
), NULL
)
7623 return CMD_WARNING_CONFIG_FAILED
;
7625 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7627 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7629 return nb_cli_apply_changes(vty
, base_xpath
);
7632 DEFUN_YANG (neighbor_timers_connect
,
7633 neighbor_timers_connect_cmd
,
7634 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7635 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7636 "BGP per neighbor timers\n"
7637 "BGP connect timer\n"
7642 char base_xpath
[XPATH_MAXLEN
];
7644 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7645 sizeof(base_xpath
), NULL
)
7647 return CMD_WARNING_CONFIG_FAILED
;
7649 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7650 argv
[idx_number
]->arg
);
7652 return nb_cli_apply_changes(vty
, base_xpath
);
7655 DEFUN_YANG (no_neighbor_timers_connect
,
7656 no_neighbor_timers_connect_cmd
,
7657 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7658 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7659 "BGP per neighbor timers\n"
7660 "BGP connect timer\n"
7664 char base_xpath
[XPATH_MAXLEN
];
7666 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7667 sizeof(base_xpath
), NULL
)
7669 return CMD_WARNING_CONFIG_FAILED
;
7671 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7674 return nb_cli_apply_changes(vty
, base_xpath
);
7677 DEFPY (neighbor_timers_delayopen
,
7678 neighbor_timers_delayopen_cmd
,
7679 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7682 "BGP per neighbor timers\n"
7683 "RFC 4271 DelayOpenTimer\n"
7684 "DelayOpenTime timer interval\n")
7688 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7690 return CMD_WARNING_CONFIG_FAILED
;
7693 if (peer_timers_delayopen_unset(peer
))
7694 return CMD_WARNING_CONFIG_FAILED
;
7696 if (peer_timers_delayopen_set(peer
, interval
))
7697 return CMD_WARNING_CONFIG_FAILED
;
7703 DEFPY (no_neighbor_timers_delayopen
,
7704 no_neighbor_timers_delayopen_cmd
,
7705 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7709 "BGP per neighbor timers\n"
7710 "RFC 4271 DelayOpenTimer\n"
7711 "DelayOpenTime timer interval\n")
7715 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7717 return CMD_WARNING_CONFIG_FAILED
;
7719 if (peer_timers_delayopen_unset(peer
))
7720 return CMD_WARNING_CONFIG_FAILED
;
7725 DEFUN_YANG (neighbor_advertise_interval
,
7726 neighbor_advertise_interval_cmd
,
7727 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7728 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7729 "Minimum interval between sending BGP routing updates\n"
7730 "time in seconds\n")
7734 char base_xpath
[XPATH_MAXLEN
];
7736 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7737 sizeof(base_xpath
), NULL
)
7739 return CMD_WARNING_CONFIG_FAILED
;
7741 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7742 argv
[idx_number
]->arg
);
7744 return nb_cli_apply_changes(vty
, base_xpath
);
7747 DEFUN_YANG (no_neighbor_advertise_interval
,
7748 no_neighbor_advertise_interval_cmd
,
7749 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7750 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7751 "Minimum interval between sending BGP routing updates\n"
7752 "time in seconds\n")
7755 char base_xpath
[XPATH_MAXLEN
];
7757 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7758 sizeof(base_xpath
), NULL
)
7760 return CMD_WARNING_CONFIG_FAILED
;
7762 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7765 return nb_cli_apply_changes(vty
, base_xpath
);
7769 /* Time to wait before processing route-map updates */
7770 DEFUN (bgp_set_route_map_delay_timer
,
7771 bgp_set_route_map_delay_timer_cmd
,
7772 "bgp route-map delay-timer (0-600)",
7774 "BGP route-map delay timer\n"
7775 "Time in secs to wait before processing route-map changes\n"
7776 "0 disables the timer, no route updates happen when route-maps change\n")
7779 uint32_t rmap_delay_timer
;
7781 if (argv
[idx_number
]->arg
) {
7782 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7783 bm
->rmap_update_timer
= rmap_delay_timer
;
7785 /* if the dynamic update handling is being disabled, and a timer
7787 * running, stop the timer and act as if the timer has already
7790 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7791 BGP_TIMER_OFF(bm
->t_rmap_update
);
7792 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7797 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7798 return CMD_WARNING_CONFIG_FAILED
;
7802 DEFUN (no_bgp_set_route_map_delay_timer
,
7803 no_bgp_set_route_map_delay_timer_cmd
,
7804 "no bgp route-map delay-timer [(0-600)]",
7807 "Default BGP route-map delay timer\n"
7808 "Reset to default time to wait for processing route-map changes\n"
7809 "0 disables the timer, no route updates happen when route-maps change\n")
7812 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7817 DEFUN_YANG (neighbor_interface
,
7818 neighbor_interface_cmd
,
7819 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7820 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7826 char base_xpath
[XPATH_MAXLEN
];
7828 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7829 argv
[idx_ip
]->arg
, "");
7831 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7832 argv
[idx_word
]->arg
);
7834 return nb_cli_apply_changes(vty
, base_xpath
);
7837 DEFUN_YANG (no_neighbor_interface
,
7838 no_neighbor_interface_cmd
,
7839 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7840 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7845 char base_xpath
[XPATH_MAXLEN
];
7847 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7848 argv
[idx_peer
]->arg
, "");
7850 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7852 return nb_cli_apply_changes(vty
, base_xpath
);
7855 DEFUN (neighbor_distribute_list
,
7856 neighbor_distribute_list_cmd
,
7857 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7860 "Filter updates to/from this neighbor\n"
7861 "IP access-list number\n"
7862 "IP access-list number (expanded range)\n"
7863 "IP Access-list name\n"
7864 "Filter incoming updates\n"
7865 "Filter outgoing updates\n")
7872 const char *pstr
= argv
[idx_peer
]->arg
;
7873 const char *acl
= argv
[idx_acl
]->arg
;
7874 const char *inout
= argv
[argc
- 1]->text
;
7876 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7878 return CMD_WARNING_CONFIG_FAILED
;
7880 /* Check filter direction. */
7881 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7882 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7885 return bgp_vty_return(vty
, ret
);
7889 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7890 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7891 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7892 "Filter updates to/from this neighbor\n"
7893 "IP access-list number\n"
7894 "IP access-list number (expanded range)\n"
7895 "IP Access-list name\n"
7896 "Filter incoming updates\n"
7897 "Filter outgoing updates\n")
7899 DEFUN (no_neighbor_distribute_list
,
7900 no_neighbor_distribute_list_cmd
,
7901 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7905 "Filter updates to/from this neighbor\n"
7906 "IP access-list number\n"
7907 "IP access-list number (expanded range)\n"
7908 "IP Access-list name\n"
7909 "Filter incoming updates\n"
7910 "Filter outgoing updates\n")
7916 const char *pstr
= argv
[idx_peer
]->arg
;
7917 const char *inout
= argv
[argc
- 1]->text
;
7919 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7921 return CMD_WARNING_CONFIG_FAILED
;
7923 /* Check filter direction. */
7924 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7925 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7928 return bgp_vty_return(vty
, ret
);
7932 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7933 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7934 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7935 "Filter updates to/from this neighbor\n"
7936 "IP access-list number\n"
7937 "IP access-list number (expanded range)\n"
7938 "IP Access-list name\n"
7939 "Filter incoming updates\n"
7940 "Filter outgoing updates\n")
7942 /* Set prefix list to the peer. */
7944 neighbor_prefix_list
, neighbor_prefix_list_cmd
,
7945 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction",
7946 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7947 "Filter updates to/from this neighbor\n"
7948 "Name of a prefix list\n"
7949 "Filter incoming updates\n"
7950 "Filter outgoing updates\n")
7952 char base_xpath
[XPATH_MAXLEN
];
7953 char af_xpath
[XPATH_MAXLEN
];
7954 char plist_xpath
[XPATH_MAXLEN
];
7955 afi_t afi
= bgp_node_afi(vty
);
7956 safi_t safi
= bgp_node_safi(vty
);
7958 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7959 yang_afi_safi_value2identity(afi
, safi
));
7960 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
7961 sizeof(base_xpath
), af_xpath
)
7963 return CMD_WARNING_CONFIG_FAILED
;
7965 if (strmatch(direction
, "in"))
7966 snprintf(plist_xpath
, sizeof(plist_xpath
),
7967 "./%s/filter-config/plist-import",
7968 bgp_afi_safi_get_container_str(afi
, safi
));
7969 else if (strmatch(direction
, "out"))
7970 snprintf(plist_xpath
, sizeof(plist_xpath
),
7971 "./%s/filter-config/plist-export",
7972 bgp_afi_safi_get_container_str(afi
, safi
));
7975 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_MODIFY
,
7978 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_DESTROY
, NULL
);
7980 return nb_cli_apply_changes(vty
, base_xpath
);
7983 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7984 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7985 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7986 "Filter updates to/from this neighbor\n"
7987 "Name of a prefix list\n"
7988 "Filter incoming updates\n"
7989 "Filter outgoing updates\n")
7991 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7992 safi_t safi
, const char *name_str
,
7993 const char *direct_str
)
7997 int direct
= FILTER_IN
;
7999 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8001 return CMD_WARNING_CONFIG_FAILED
;
8003 /* Check filter direction. */
8004 if (strncmp(direct_str
, "i", 1) == 0)
8006 else if (strncmp(direct_str
, "o", 1) == 0)
8007 direct
= FILTER_OUT
;
8009 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
8011 return bgp_vty_return(vty
, ret
);
8014 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
8015 safi_t safi
, const char *direct_str
)
8019 int direct
= FILTER_IN
;
8021 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8023 return CMD_WARNING_CONFIG_FAILED
;
8025 /* Check filter direction. */
8026 if (strncmp(direct_str
, "i", 1) == 0)
8028 else if (strncmp(direct_str
, "o", 1) == 0)
8029 direct
= FILTER_OUT
;
8031 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
8033 return bgp_vty_return(vty
, ret
);
8036 DEFUN (neighbor_filter_list
,
8037 neighbor_filter_list_cmd
,
8038 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8041 "Establish BGP filters\n"
8042 "AS path access-list name\n"
8043 "Filter incoming routes\n"
8044 "Filter outgoing routes\n")
8049 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
8050 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
8051 argv
[idx_in_out
]->arg
);
8054 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
8055 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8056 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8057 "Establish BGP filters\n"
8058 "AS path access-list name\n"
8059 "Filter incoming routes\n"
8060 "Filter outgoing routes\n")
8062 DEFUN (no_neighbor_filter_list
,
8063 no_neighbor_filter_list_cmd
,
8064 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8068 "Establish BGP filters\n"
8069 "AS path access-list name\n"
8070 "Filter incoming routes\n"
8071 "Filter outgoing routes\n")
8075 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
8076 bgp_node_afi(vty
), bgp_node_safi(vty
),
8077 argv
[idx_in_out
]->arg
);
8080 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
8081 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
8082 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8083 "Establish BGP filters\n"
8084 "AS path access-list name\n"
8085 "Filter incoming routes\n"
8086 "Filter outgoing routes\n")
8088 /* Set advertise-map to the peer. */
8089 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
8090 afi_t afi
, safi_t safi
,
8091 const char *advertise_str
,
8092 const char *condition_str
, bool condition
,
8095 int ret
= CMD_WARNING_CONFIG_FAILED
;
8097 struct route_map
*advertise_map
;
8098 struct route_map
*condition_map
;
8100 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8104 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
8105 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
8108 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
8109 advertise_map
, condition_str
,
8110 condition_map
, condition
);
8112 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
8113 advertise_map
, condition_str
,
8114 condition_map
, condition
);
8116 return bgp_vty_return(vty
, ret
);
8119 DEFPY (neighbor_advertise_map
,
8120 neighbor_advertise_map_cmd
,
8121 "[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",
8125 "Route-map to conditionally advertise routes\n"
8126 "Name of advertise map\n"
8127 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8128 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8129 "Name of the exist or non exist map\n")
8131 bool condition
= CONDITION_EXIST
;
8133 if (!strcmp(exist
, "non-exist-map"))
8134 condition
= CONDITION_NON_EXIST
;
8136 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
8137 bgp_node_safi(vty
), advertise_str
,
8138 condition_str
, condition
, !no
);
8141 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
8142 "[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 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8144 "Route-map to conditionally advertise routes\n"
8145 "Name of advertise map\n"
8146 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8147 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8148 "Name of the exist or non exist map\n")
8150 /* Set route-map to the peer. */
8152 neighbor_route_map
, neighbor_route_map_cmd
,
8153 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction",
8154 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8155 "Apply route map to neighbor\n"
8156 "Name of route map\n"
8157 "Apply map to incoming routes\n"
8158 "Apply map to outbound routes\n")
8160 char base_xpath
[XPATH_MAXLEN
];
8161 char af_xpath
[XPATH_MAXLEN
];
8162 char rmap_xpath
[XPATH_MAXLEN
];
8163 afi_t afi
= bgp_node_afi(vty
);
8164 safi_t safi
= bgp_node_safi(vty
);
8166 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8167 yang_afi_safi_value2identity(afi
, safi
));
8168 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
8169 sizeof(base_xpath
), af_xpath
)
8171 return CMD_WARNING_CONFIG_FAILED
;
8173 if (strmatch(direction
, "in"))
8174 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8175 "./%s/filter-config/rmap-import",
8176 bgp_afi_safi_get_container_str(afi
, safi
));
8177 else if (strmatch(direction
, "out"))
8178 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8179 "./%s/filter-config/rmap-export",
8180 bgp_afi_safi_get_container_str(afi
, safi
));
8183 if (!yang_dnode_existsf(
8184 vty
->candidate_config
->dnode
,
8185 "/frr-route-map:lib/route-map[name='%s']",
8187 if (vty_shell_serv(vty
))
8189 "The route-map '%s' does not exist.\n",
8192 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_MODIFY
, rmap_str
);
8194 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_DESTROY
, NULL
);
8196 return nb_cli_apply_changes(vty
, base_xpath
);
8199 /* Set unsuppress-map to the peer. */
8200 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8201 afi_t afi
, safi_t safi
,
8202 const char *name_str
)
8206 struct route_map
*route_map
;
8208 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8210 return CMD_WARNING_CONFIG_FAILED
;
8212 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8213 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8215 return bgp_vty_return(vty
, ret
);
8218 /* Unset route-map from the peer. */
8219 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8220 afi_t afi
, safi_t safi
)
8225 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8227 return CMD_WARNING_CONFIG_FAILED
;
8229 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8231 return bgp_vty_return(vty
, ret
);
8234 DEFUN (neighbor_unsuppress_map
,
8235 neighbor_unsuppress_map_cmd
,
8236 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8239 "Route-map to selectively unsuppress suppressed routes\n"
8240 "Name of route map\n")
8244 return peer_unsuppress_map_set_vty(
8245 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8246 argv
[idx_word
]->arg
);
8249 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8250 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8251 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8252 "Route-map to selectively unsuppress suppressed routes\n"
8253 "Name of route map\n")
8255 DEFUN (no_neighbor_unsuppress_map
,
8256 no_neighbor_unsuppress_map_cmd
,
8257 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8261 "Route-map to selectively unsuppress suppressed routes\n"
8262 "Name of route map\n")
8265 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8267 bgp_node_safi(vty
));
8270 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8271 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8272 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8273 "Route-map to selectively unsuppress suppressed routes\n"
8274 "Name of route map\n")
8276 /* Maximum number of prefix to be sent to the neighbor. */
8277 DEFUN_YANG(neighbor_maximum_prefix_out
,
8278 neighbor_maximum_prefix_out_cmd
,
8279 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8280 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8281 "Maximum number of prefixes to be sent to this peer\n"
8282 "Maximum no. of prefix limit\n")
8284 char base_xpath
[XPATH_MAXLEN
];
8285 char af_xpath
[XPATH_MAXLEN
];
8286 char attr_xpath
[XPATH_MAXLEN
];
8289 afi_t afi
= bgp_node_afi(vty
);
8290 safi_t safi
= bgp_node_safi(vty
);
8292 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8293 yang_afi_safi_value2identity(afi
, safi
));
8294 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8295 sizeof(base_xpath
), af_xpath
)
8297 return CMD_WARNING_CONFIG_FAILED
;
8299 snprintf(attr_xpath
, sizeof(attr_xpath
),
8300 "/%s/prefix-limit/direction-list[direction='out']",
8301 bgp_afi_safi_get_container_str(afi
, safi
));
8302 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8304 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8306 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8307 argv
[idx_number
]->arg
);
8309 return nb_cli_apply_changes(vty
, base_xpath
);
8312 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8313 no_neighbor_maximum_prefix_out_cmd
,
8314 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8315 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8316 "Maximum number of prefixes to be sent to this peer\n")
8318 char base_xpath
[XPATH_MAXLEN
];
8319 char af_xpath
[XPATH_MAXLEN
];
8320 char attr_xpath
[XPATH_MAXLEN
];
8322 afi_t afi
= bgp_node_afi(vty
);
8323 safi_t safi
= bgp_node_safi(vty
);
8325 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8326 yang_afi_safi_value2identity(afi
, safi
));
8327 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8328 sizeof(base_xpath
), af_xpath
)
8330 return CMD_WARNING_CONFIG_FAILED
;
8332 snprintf(attr_xpath
, sizeof(attr_xpath
),
8333 "/%s/prefix-limit/direction-list[direction='out']",
8334 bgp_afi_safi_get_container_str(afi
, safi
));
8335 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8337 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8339 return nb_cli_apply_changes(vty
, base_xpath
);
8342 /* Maximum number of prefix configuration. Prefix count is different
8343 for each peer configuration. So this configuration can be set for
8344 each peer configuration. */
8345 DEFUN_YANG(neighbor_maximum_prefix
,
8346 neighbor_maximum_prefix_cmd
,
8347 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8348 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8349 "Maximum number of prefix accept from this peer\n"
8350 "maximum no. of prefix limit\n"
8351 "Force checking all received routes not only accepted\n")
8356 char base_xpath
[XPATH_MAXLEN
];
8357 char af_xpath
[XPATH_MAXLEN
];
8358 char attr_xpath
[XPATH_MAXLEN
];
8359 afi_t afi
= bgp_node_afi(vty
);
8360 safi_t safi
= bgp_node_safi(vty
);
8362 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8363 yang_afi_safi_value2identity(afi
, safi
));
8364 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8365 sizeof(base_xpath
), af_xpath
)
8367 return CMD_WARNING_CONFIG_FAILED
;
8369 snprintf(attr_xpath
, sizeof(attr_xpath
),
8370 "/%s/prefix-limit/direction-list[direction='in']",
8371 bgp_afi_safi_get_container_str(afi
, safi
));
8372 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8374 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8376 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8377 argv
[idx_number
]->arg
);
8378 if (argv_find(argv
, argc
, "force", &idx_force
))
8379 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8382 return nb_cli_apply_changes(vty
, base_xpath
);
8385 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8386 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8387 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8388 "Maximum number of prefix accept from this peer\n"
8389 "maximum no. of prefix limit\n"
8390 "Force checking all received routes not only accepted\n")
8392 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8393 neighbor_maximum_prefix_threshold_cmd
,
8394 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8395 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8396 "Maximum number of prefix accept from this peer\n"
8397 "maximum no. of prefix limit\n"
8398 "Threshold value (%) at which to generate a warning msg\n"
8399 "Force checking all received routes not only accepted\n")
8403 int idx_number_2
= 4;
8405 char base_xpath
[XPATH_MAXLEN
];
8406 char af_xpath
[XPATH_MAXLEN
];
8407 char attr_xpath
[XPATH_MAXLEN
];
8408 afi_t afi
= bgp_node_afi(vty
);
8409 safi_t safi
= bgp_node_safi(vty
);
8411 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8412 yang_afi_safi_value2identity(afi
, safi
));
8413 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8414 sizeof(base_xpath
), af_xpath
)
8416 return CMD_WARNING_CONFIG_FAILED
;
8418 snprintf(attr_xpath
, sizeof(attr_xpath
),
8419 "/%s/prefix-limit/direction-list[direction='in']",
8420 bgp_afi_safi_get_container_str(afi
, safi
));
8421 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8423 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8425 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8426 argv
[idx_number
]->arg
);
8428 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8429 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8431 if (argv_find(argv
, argc
, "force", &idx_force
))
8432 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8435 return nb_cli_apply_changes(vty
, base_xpath
);
8439 neighbor_maximum_prefix_threshold
,
8440 neighbor_maximum_prefix_threshold_hidden_cmd
,
8441 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8442 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8443 "Maximum number of prefix accept from this peer\n"
8444 "maximum no. of prefix limit\n"
8445 "Threshold value (%) at which to generate a warning msg\n"
8446 "Force checking all received routes not only accepted\n")
8448 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8449 neighbor_maximum_prefix_warning_cmd
,
8450 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8451 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8452 "Maximum number of prefix accept from this peer\n"
8453 "maximum no. of prefix limit\n"
8454 "Only give warning message when limit is exceeded\n"
8455 "Force checking all received routes not only accepted\n")
8460 char base_xpath
[XPATH_MAXLEN
];
8461 char af_xpath
[XPATH_MAXLEN
];
8462 char attr_xpath
[XPATH_MAXLEN
];
8463 afi_t afi
= bgp_node_afi(vty
);
8464 safi_t safi
= bgp_node_safi(vty
);
8466 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8467 yang_afi_safi_value2identity(afi
, safi
));
8468 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8469 sizeof(base_xpath
), af_xpath
)
8471 return CMD_WARNING_CONFIG_FAILED
;
8473 snprintf(attr_xpath
, sizeof(attr_xpath
),
8474 "/%s/prefix-limit/direction-list[direction='in']",
8475 bgp_afi_safi_get_container_str(afi
, safi
));
8476 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8478 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8480 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8481 argv
[idx_number
]->arg
);
8483 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8485 if (argv_find(argv
, argc
, "force", &idx_force
))
8486 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8489 return nb_cli_apply_changes(vty
, base_xpath
);
8493 neighbor_maximum_prefix_warning
,
8494 neighbor_maximum_prefix_warning_hidden_cmd
,
8495 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8496 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8497 "Maximum number of prefix accept from this peer\n"
8498 "maximum no. of prefix limit\n"
8499 "Only give warning message when limit is exceeded\n"
8500 "Force checking all received routes not only accepted\n")
8502 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8503 neighbor_maximum_prefix_threshold_warning_cmd
,
8504 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8505 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8506 "Maximum number of prefix accept from this peer\n"
8507 "maximum no. of prefix limit\n"
8508 "Threshold value (%) at which to generate a warning msg\n"
8509 "Only give warning message when limit is exceeded\n"
8510 "Force checking all received routes not only accepted\n")
8514 int idx_number_2
= 4;
8516 char base_xpath
[XPATH_MAXLEN
];
8517 char af_xpath
[XPATH_MAXLEN
];
8518 char attr_xpath
[XPATH_MAXLEN
];
8519 afi_t afi
= bgp_node_afi(vty
);
8520 safi_t safi
= bgp_node_safi(vty
);
8522 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8523 yang_afi_safi_value2identity(afi
, safi
));
8524 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8525 sizeof(base_xpath
), af_xpath
)
8527 return CMD_WARNING_CONFIG_FAILED
;
8529 snprintf(attr_xpath
, sizeof(attr_xpath
),
8530 "/%s/prefix-limit/direction-list[direction='in']",
8531 bgp_afi_safi_get_container_str(afi
, safi
));
8532 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8534 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8536 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8537 argv
[idx_number
]->arg
);
8538 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8539 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8540 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8542 if (argv_find(argv
, argc
, "force", &idx_force
))
8543 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8546 return nb_cli_apply_changes(vty
, base_xpath
);
8550 neighbor_maximum_prefix_threshold_warning
,
8551 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8552 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8553 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8554 "Maximum number of prefix accept from this peer\n"
8555 "maximum no. of prefix limit\n"
8556 "Threshold value (%) at which to generate a warning msg\n"
8557 "Only give warning message when limit is exceeded\n"
8558 "Force checking all received routes not only accepted\n")
8560 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8561 neighbor_maximum_prefix_restart_cmd
,
8562 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8563 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8564 "Maximum number of prefix accept from this peer\n"
8565 "maximum no. of prefix limit\n"
8566 "Restart bgp connection after limit is exceeded\n"
8567 "Restart interval in minutes\n"
8568 "Force checking all received routes not only accepted\n")
8572 int idx_number_2
= 5;
8574 char base_xpath
[XPATH_MAXLEN
];
8575 char af_xpath
[XPATH_MAXLEN
];
8576 char attr_xpath
[XPATH_MAXLEN
];
8577 afi_t afi
= bgp_node_afi(vty
);
8578 safi_t safi
= bgp_node_safi(vty
);
8580 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8581 yang_afi_safi_value2identity(afi
, safi
));
8582 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8583 sizeof(base_xpath
), af_xpath
)
8585 return CMD_WARNING_CONFIG_FAILED
;
8587 snprintf(attr_xpath
, sizeof(attr_xpath
),
8588 "/%s/prefix-limit/direction-list[direction='in']",
8589 bgp_afi_safi_get_container_str(afi
, safi
));
8590 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8592 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8594 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8595 argv
[idx_number
]->arg
);
8596 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8597 argv
[idx_number_2
]->arg
);
8598 if (argv_find(argv
, argc
, "force", &idx_force
))
8599 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8602 return nb_cli_apply_changes(vty
, base_xpath
);
8606 neighbor_maximum_prefix_restart
,
8607 neighbor_maximum_prefix_restart_hidden_cmd
,
8608 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8609 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8610 "Maximum number of prefix accept from this peer\n"
8611 "maximum no. of prefix limit\n"
8612 "Restart bgp connection after limit is exceeded\n"
8613 "Restart interval in minutes\n"
8614 "Force checking all received routes not only accepted\n")
8616 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8617 neighbor_maximum_prefix_threshold_restart_cmd
,
8618 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8619 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8620 "Maximum number of prefixes to accept from this peer\n"
8621 "maximum no. of prefix limit\n"
8622 "Threshold value (%) at which to generate a warning msg\n"
8623 "Restart bgp connection after limit is exceeded\n"
8624 "Restart interval in minutes\n"
8625 "Force checking all received routes not only accepted\n")
8629 int idx_number_2
= 4;
8630 int idx_number_3
= 6;
8632 char base_xpath
[XPATH_MAXLEN
];
8633 char af_xpath
[XPATH_MAXLEN
];
8634 char attr_xpath
[XPATH_MAXLEN
];
8635 afi_t afi
= bgp_node_afi(vty
);
8636 safi_t safi
= bgp_node_safi(vty
);
8638 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8639 yang_afi_safi_value2identity(afi
, safi
));
8640 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8641 sizeof(base_xpath
), af_xpath
)
8643 return CMD_WARNING_CONFIG_FAILED
;
8645 snprintf(attr_xpath
, sizeof(attr_xpath
),
8646 "/%s/prefix-limit/direction-list[direction='in']",
8647 bgp_afi_safi_get_container_str(afi
, safi
));
8648 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8650 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8652 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8653 argv
[idx_number
]->arg
);
8654 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8655 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8656 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8657 argv
[idx_number_3
]->arg
);
8658 if (argv_find(argv
, argc
, "force", &idx_force
))
8659 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8662 return nb_cli_apply_changes(vty
, base_xpath
);
8666 neighbor_maximum_prefix_threshold_restart
,
8667 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8668 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8670 "Maximum number of prefixes to accept from this peer\n"
8671 "maximum no. of prefix limit\n"
8672 "Threshold value (%) at which to generate a warning msg\n"
8673 "Restart bgp connection after limit is exceeded\n"
8674 "Restart interval in minutes\n"
8675 "Force checking all received routes not only accepted\n")
8677 DEFUN_YANG(no_neighbor_maximum_prefix
,
8678 no_neighbor_maximum_prefix_cmd
,
8679 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8680 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8681 "Maximum number of prefixes to accept from this peer\n"
8682 "maximum no. of prefix limit\n"
8683 "Threshold value (%) at which to generate a warning msg\n"
8684 "Restart bgp connection after limit is exceeded\n"
8685 "Restart interval in minutes\n"
8686 "Only give warning message when limit is exceeded\n"
8687 "Force checking all received routes not only accepted\n")
8690 char base_xpath
[XPATH_MAXLEN
];
8691 char af_xpath
[XPATH_MAXLEN
];
8692 char attr_xpath
[XPATH_MAXLEN
];
8693 afi_t afi
= bgp_node_afi(vty
);
8694 safi_t safi
= bgp_node_safi(vty
);
8696 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8697 yang_afi_safi_value2identity(afi
, safi
));
8698 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8699 sizeof(base_xpath
), af_xpath
)
8701 return CMD_WARNING_CONFIG_FAILED
;
8703 snprintf(attr_xpath
, sizeof(attr_xpath
),
8704 "/%s/prefix-limit/direction-list[direction='in']",
8705 bgp_afi_safi_get_container_str(afi
, safi
));
8706 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8708 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8710 return nb_cli_apply_changes(vty
, base_xpath
);
8714 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8715 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8716 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8717 "Maximum number of prefixes to accept from this peer\n"
8718 "maximum no. of prefix limit\n"
8719 "Threshold value (%) at which to generate a warning msg\n"
8720 "Restart bgp connection after limit is exceeded\n"
8721 "Restart interval in minutes\n"
8722 "Only give warning message when limit is exceeded\n"
8723 "Force checking all received routes not only accepted\n")
8726 /* "neighbor allowas-in" */
8727 DEFUN (neighbor_allowas_in
,
8728 neighbor_allowas_in_cmd
,
8729 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8732 "Accept as-path with my AS present in it\n"
8733 "Number of occurrences of AS number\n"
8734 "Only accept my AS in the as-path if the route was originated in my AS\n")
8737 int idx_number_origin
= 3;
8743 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8745 return CMD_WARNING_CONFIG_FAILED
;
8747 if (argc
<= idx_number_origin
)
8750 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8753 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8756 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8759 return bgp_vty_return(vty
, ret
);
8763 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8764 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8765 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8766 "Accept as-path with my AS present in it\n"
8767 "Number of occurrences of AS number\n"
8768 "Only accept my AS in the as-path if the route was originated in my AS\n")
8770 DEFUN (no_neighbor_allowas_in
,
8771 no_neighbor_allowas_in_cmd
,
8772 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8776 "allow local ASN appears in aspath attribute\n"
8777 "Number of occurrences of AS number\n"
8778 "Only accept my AS in the as-path if the route was originated in my AS\n")
8784 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8786 return CMD_WARNING_CONFIG_FAILED
;
8788 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8789 bgp_node_safi(vty
));
8791 return bgp_vty_return(vty
, ret
);
8795 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8796 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8797 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8798 "allow local ASN appears in aspath attribute\n"
8799 "Number of occurrences of AS number\n"
8800 "Only accept my AS in the as-path if the route was originated in my AS\n")
8802 DEFUN_YANG (neighbor_ttl_security
,
8803 neighbor_ttl_security_cmd
,
8804 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8807 "BGP ttl-security parameters\n"
8808 "Specify the maximum number of hops to the BGP peer\n"
8809 "Number of hops to BGP peer\n")
8813 char base_xpath
[XPATH_MAXLEN
];
8815 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8816 sizeof(base_xpath
), NULL
)
8818 return CMD_WARNING_CONFIG_FAILED
;
8820 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8821 argv
[idx_number
]->arg
);
8823 return nb_cli_apply_changes(vty
, base_xpath
);
8826 DEFUN_YANG(no_neighbor_ttl_security
,
8827 no_neighbor_ttl_security_cmd
,
8828 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8829 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8830 "BGP ttl-security parameters\n"
8831 "Specify the maximum number of hops to the BGP peer\n"
8832 "Number of hops to BGP peer\n")
8835 char base_xpath
[XPATH_MAXLEN
];
8837 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8838 sizeof(base_xpath
), NULL
)
8840 return CMD_WARNING_CONFIG_FAILED
;
8842 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8844 return nb_cli_apply_changes(vty
, base_xpath
);
8847 DEFUN (neighbor_addpath_tx_all_paths
,
8848 neighbor_addpath_tx_all_paths_cmd
,
8849 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8852 "Use addpath to advertise all paths to a neighbor\n")
8857 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8859 return CMD_WARNING_CONFIG_FAILED
;
8861 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8866 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8867 neighbor_addpath_tx_all_paths_hidden_cmd
,
8868 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8869 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8870 "Use addpath to advertise all paths to a neighbor\n")
8872 DEFUN (no_neighbor_addpath_tx_all_paths
,
8873 no_neighbor_addpath_tx_all_paths_cmd
,
8874 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8878 "Use addpath to advertise all paths to a neighbor\n")
8883 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8885 return CMD_WARNING_CONFIG_FAILED
;
8887 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8888 != BGP_ADDPATH_ALL
) {
8890 "%% Peer not currently configured to transmit all paths.");
8891 return CMD_WARNING_CONFIG_FAILED
;
8894 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8900 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8901 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8902 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8904 "Use addpath to advertise all paths to a neighbor\n")
8906 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8907 neighbor_addpath_tx_bestpath_per_as_cmd
,
8908 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8911 "Use addpath to advertise the bestpath per each neighboring AS\n")
8916 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8918 return CMD_WARNING_CONFIG_FAILED
;
8920 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8921 BGP_ADDPATH_BEST_PER_AS
);
8926 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8927 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8928 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8929 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8930 "Use addpath to advertise the bestpath per each neighboring AS\n")
8932 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8933 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8934 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8938 "Use addpath to advertise the bestpath per each neighboring AS\n")
8943 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8945 return CMD_WARNING_CONFIG_FAILED
;
8947 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8948 != BGP_ADDPATH_BEST_PER_AS
) {
8950 "%% Peer not currently configured to transmit all best path per as.");
8951 return CMD_WARNING_CONFIG_FAILED
;
8954 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8960 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8961 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8962 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8963 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8964 "Use addpath to advertise the bestpath per each neighboring AS\n")
8967 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8968 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8971 "Detect AS loops before sending to neighbor\n")
8975 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8977 return CMD_WARNING_CONFIG_FAILED
;
8979 peer
->as_path_loop_detection
= true;
8985 no_neighbor_aspath_loop_detection
,
8986 no_neighbor_aspath_loop_detection_cmd
,
8987 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8991 "Detect AS loops before sending to neighbor\n")
8995 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8997 return CMD_WARNING_CONFIG_FAILED
;
8999 peer
->as_path_loop_detection
= false;
9004 DEFPY(neighbor_damp
,
9006 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
9009 "Enable neighbor route-flap dampening\n"
9010 "Half-life time for the penalty\n"
9011 "Value to start reusing a route\n"
9012 "Value to start suppressing a route\n"
9013 "Maximum duration to suppress a stable route\n")
9015 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9018 return CMD_WARNING_CONFIG_FAILED
;
9020 half
= DEFAULT_HALF_LIFE
;
9022 reuse
= DEFAULT_REUSE
;
9023 suppress
= DEFAULT_SUPPRESS
;
9026 if (suppress
< reuse
) {
9028 "Suppress value cannot be less than reuse value\n");
9029 return CMD_WARNING_CONFIG_FAILED
;
9031 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
9032 half
* 60, reuse
, suppress
, max
* 60);
9036 DEFPY(no_neighbor_damp
,
9037 no_neighbor_damp_cmd
,
9038 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
9042 "Enable neighbor route-flap dampening\n"
9043 "Half-life time for the penalty\n"
9044 "Value to start reusing a route\n"
9045 "Value to start suppressing a route\n"
9046 "Maximum duration to suppress a stable route\n")
9048 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9051 return CMD_WARNING_CONFIG_FAILED
;
9052 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
9056 DEFPY (show_ip_bgp_neighbor_damp_param
,
9057 show_ip_bgp_neighbor_damp_param_cmd
,
9058 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
9063 "Address Family modifier\n"
9066 "Neighbor route-flap dampening information\n"
9067 "Display detail of configured dampening parameters\n"
9070 bool use_json
= false;
9073 safi_t safi
= SAFI_UNICAST
;
9076 if (argv_find(argv
, argc
, "ip", &idx
))
9078 if (argv_find(argv
, argc
, "ipv4", &idx
))
9080 if (argv_find(argv
, argc
, "ipv6", &idx
))
9082 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9087 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
9091 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
9092 struct ecommunity
**list
, bool is_rt6
)
9094 struct ecommunity
*ecom
= NULL
;
9095 struct ecommunity
*ecomadd
;
9097 for (; argc
; --argc
, ++argv
) {
9099 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
9100 ECOMMUNITY_ROUTE_TARGET
,
9103 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
9104 ECOMMUNITY_ROUTE_TARGET
,
9107 vty_out(vty
, "Malformed community-list value\n");
9109 ecommunity_free(&ecom
);
9110 return CMD_WARNING_CONFIG_FAILED
;
9114 ecommunity_merge(ecom
, ecomadd
);
9115 ecommunity_free(&ecomadd
);
9122 ecommunity_free(&*list
);
9129 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
9130 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
9133 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9134 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9135 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9136 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9138 errmsg
, errmsg_len
, "%s",
9139 "%% error: Please unconfigure import vrf commands before using vpn commands");
9143 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9144 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9145 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9146 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9148 errmsg
, errmsg_len
, "%s",
9149 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
9157 * v2vimport is true if we are handling a `import vrf ...` command
9159 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9163 switch (vty
->node
) {
9172 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9177 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9178 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9179 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9180 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9182 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9186 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9187 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9188 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9189 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9191 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9200 af_rd_vpn_export_cmd
,
9201 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9203 "Specify route distinguisher\n"
9204 "Between current address-family and vpn\n"
9205 "For routes leaked from current address-family to vpn\n"
9206 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9208 char base_xpath
[XPATH_MAXLEN
];
9213 afi
= bgp_node_afi(vty
);
9214 safi
= bgp_node_safi(vty
);
9217 base_xpath
, sizeof(base_xpath
),
9218 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9219 yang_afi_safi_value2identity(afi
, safi
),
9220 bgp_afi_safi_get_container_str(afi
, safi
));
9222 if (argv_find(argv
, argc
, "no", &idx
))
9223 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9225 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9227 return nb_cli_apply_changes(vty
, base_xpath
);
9230 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9231 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9235 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9236 yang_dnode_get_string(dnode
, NULL
));
9239 ALIAS (af_rd_vpn_export
,
9240 af_no_rd_vpn_export_cmd
,
9243 "Specify route distinguisher\n"
9244 "Between current address-family and vpn\n"
9245 "For routes leaked from current address-family to vpn\n")
9247 DEFPY (af_label_vpn_export
,
9248 af_label_vpn_export_cmd
,
9249 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9251 "label value for VRF\n"
9252 "Between current address-family and vpn\n"
9253 "For routes leaked from current address-family to vpn\n"
9254 "Label Value <0-1048575>\n"
9255 "Automatically assign a label\n")
9257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9258 mpls_label_t label
= MPLS_LABEL_NONE
;
9263 if (argv_find(argv
, argc
, "no", &idx
))
9266 /* If "no ...", squash trailing parameter */
9272 label
= label_val
; /* parser should force unsigned */
9275 afi
= vpn_policy_getafi(vty
, bgp
, false);
9277 return CMD_WARNING_CONFIG_FAILED
;
9280 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9281 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9286 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9288 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9289 bgp_get_default(), bgp
);
9291 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9292 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9294 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9297 * label has previously been automatically
9298 * assigned by labelpool: release it
9300 * NB if tovpn_label == MPLS_LABEL_NONE it
9301 * means the automatic assignment is in flight
9302 * and therefore the labelpool callback must
9303 * detect that the auto label is not needed.
9306 bgp_lp_release(LP_TYPE_VRF
,
9307 &bgp
->vpn_policy
[afi
],
9308 bgp
->vpn_policy
[afi
].tovpn_label
);
9310 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9311 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9314 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9316 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9317 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9318 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9319 vpn_leak_label_callback
);
9322 /* post-change: re-export vpn routes */
9323 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9324 bgp_get_default(), bgp
);
9326 hook_call(bgp_snmp_update_last_changed
, bgp
);
9330 DEFPY (af_sid_vpn_export
,
9331 af_sid_vpn_export_cmd
,
9332 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
9334 "sid value for VRF\n"
9335 "Between current address-family and vpn\n"
9336 "For routes leaked from current address-family to vpn\n"
9337 "Sid allocation index\n"
9338 "Automatically assign a label\n")
9340 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9346 if (argv_find(argv
, argc
, "no", &idx
))
9348 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9349 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9351 afi
= vpn_policy_getafi(vty
, bgp
, false);
9353 return CMD_WARNING_CONFIG_FAILED
;
9357 vty_out(vty
, "It's not implemented");
9358 return CMD_WARNING_CONFIG_FAILED
;
9361 /* skip when it's already configured */
9362 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9363 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9364 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9368 * mode change between sid_idx and sid_auto isn't supported.
9369 * user must negate sid vpn export when they want to change the mode
9371 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9372 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9373 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9374 vty_out(vty
, "it's already configured as %s.\n",
9375 sid_auto
? "auto-mode" : "idx-mode");
9376 return CMD_WARNING_CONFIG_FAILED
;
9380 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9381 bgp_get_default(), bgp
);
9384 /* SID allocation auto-mode */
9386 zlog_debug("%s: auto sid alloc.", __func__
);
9387 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9388 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9390 /* SID allocation index-mode */
9392 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9393 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9397 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9398 bgp_get_default(), bgp
);
9402 ALIAS (af_label_vpn_export
,
9403 af_no_label_vpn_export_cmd
,
9404 "no label vpn export",
9406 "label value for VRF\n"
9407 "Between current address-family and vpn\n"
9408 "For routes leaked from current address-family to vpn\n")
9410 DEFPY_YANG (af_nexthop_vpn_export
,
9411 af_nexthop_vpn_export_cmd
,
9412 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9414 "Specify next hop to use for VRF advertised prefixes\n"
9415 "Between current address-family and vpn\n"
9416 "For routes leaked from current address-family to vpn\n"
9420 char base_xpath
[XPATH_MAXLEN
];
9428 vty_out(vty
, "%% Nexthop required\n");
9429 return CMD_WARNING_CONFIG_FAILED
;
9431 if (!sockunion2hostprefix(nexthop_su
, &p
))
9432 return CMD_WARNING_CONFIG_FAILED
;
9435 afi
= bgp_node_afi(vty
);
9436 safi
= bgp_node_safi(vty
);
9439 base_xpath
, sizeof(base_xpath
),
9440 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9441 yang_afi_safi_value2identity(afi
, safi
),
9442 bgp_afi_safi_get_container_str(afi
, safi
));
9444 if (argv_find(argv
, argc
, "no", &idx
))
9445 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9447 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9450 return nb_cli_apply_changes(vty
, base_xpath
);
9453 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9454 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9458 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9459 yang_dnode_get_string(dnode
, NULL
));
9462 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9464 if (!strcmp(dstr
, "import")) {
9465 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9466 } else if (!strcmp(dstr
, "export")) {
9467 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9468 } else if (!strcmp(dstr
, "both")) {
9469 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9470 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9472 vty_out(vty
, "%% direction parse error\n");
9473 return CMD_WARNING_CONFIG_FAILED
;
9478 DEFPY (af_rt_vpn_imexport
,
9479 af_rt_vpn_imexport_cmd
,
9480 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9482 "Specify route target list\n"
9483 "Specify route target list\n"
9484 "Between current address-family and vpn\n"
9485 "For routes leaked from vpn to current address-family: match any\n"
9486 "For routes leaked from current address-family to vpn: set\n"
9487 "both import: match any and export: set\n"
9488 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9492 struct ecommunity
*ecom
= NULL
;
9493 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9494 vpn_policy_direction_t dir
;
9499 if (argv_find(argv
, argc
, "no", &idx
))
9502 afi
= vpn_policy_getafi(vty
, bgp
, false);
9504 return CMD_WARNING_CONFIG_FAILED
;
9506 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9507 if (ret
!= CMD_SUCCESS
)
9511 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9512 vty_out(vty
, "%% Missing RTLIST\n");
9513 return CMD_WARNING_CONFIG_FAILED
;
9515 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9516 if (ret
!= CMD_SUCCESS
) {
9521 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9525 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9528 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9530 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9531 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9532 ecommunity_dup(ecom
);
9534 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9536 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9537 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9540 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9544 ecommunity_free(&ecom
);
9549 ALIAS (af_rt_vpn_imexport
,
9550 af_no_rt_vpn_imexport_cmd
,
9551 "no <rt|route-target> vpn <import|export|both>$direction_str",
9553 "Specify route target list\n"
9554 "Specify route target list\n"
9555 "Between current address-family and vpn\n"
9556 "For routes leaked from vpn to current address-family\n"
9557 "For routes leaked from current address-family to vpn\n"
9558 "both import and export\n")
9560 DEFPY_YANG (af_route_map_vpn_imexport
,
9561 af_route_map_vpn_imexport_cmd
,
9562 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9563 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9565 "Specify route map\n"
9566 "Between current address-family and vpn\n"
9567 "For routes leaked from vpn to current address-family\n"
9568 "For routes leaked from current address-family to vpn\n"
9569 "name of route-map\n")
9571 char base_xpath
[XPATH_MAXLEN
];
9576 afi
= bgp_node_afi(vty
);
9577 safi
= bgp_node_safi(vty
);
9580 base_xpath
, sizeof(base_xpath
),
9581 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9582 yang_afi_safi_value2identity(afi
, safi
),
9583 bgp_afi_safi_get_container_str(afi
, safi
));
9585 if (argv_find(argv
, argc
, "no", &idx
)) {
9586 if (!strcmp(direction_str
, "import"))
9587 nb_cli_enqueue_change(vty
, "./rmap-import",
9588 NB_OP_DESTROY
, NULL
);
9589 else if (!strcmp(direction_str
, "export"))
9590 nb_cli_enqueue_change(vty
, "./rmap-export",
9591 NB_OP_DESTROY
, NULL
);
9593 if (!strcmp(direction_str
, "import"))
9594 nb_cli_enqueue_change(vty
, "./rmap-import",
9595 NB_OP_MODIFY
, rmap_str
);
9596 if (!strcmp(direction_str
, "export"))
9597 nb_cli_enqueue_change(vty
, "./rmap-export",
9598 NB_OP_MODIFY
, rmap_str
);
9600 return nb_cli_apply_changes(vty
, base_xpath
);
9603 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9604 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9608 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9609 yang_dnode_get_string(dnode
, NULL
));
9612 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9613 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9617 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9618 yang_dnode_get_string(dnode
, NULL
));
9621 ALIAS (af_route_map_vpn_imexport
,
9622 af_no_route_map_vpn_imexport_cmd
,
9623 "no route-map vpn <import|export>$direction_str",
9625 "Specify route map\n"
9626 "Between current address-family and vpn\n"
9627 "For routes leaked from vpn to current address-family\n"
9628 "For routes leaked from current address-family to vpn\n")
9630 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9631 "import vrf route-map RMAP$rmap_str",
9632 "Import routes from another VRF\n"
9633 "Vrf routes being filtered\n"
9634 "Specify route map\n"
9635 "name of route-map\n")
9637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9638 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9640 struct bgp
*bgp_default
;
9642 afi
= vpn_policy_getafi(vty
, bgp
, true);
9644 return CMD_WARNING_CONFIG_FAILED
;
9646 bgp_default
= bgp_get_default();
9651 /* Auto-create assuming the same AS */
9652 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9653 BGP_INSTANCE_TYPE_DEFAULT
);
9657 "VRF default is not configured as a bgp instance\n");
9662 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9664 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9665 XFREE(MTYPE_ROUTE_MAP_NAME
,
9666 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9667 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9668 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9669 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9670 route_map_lookup_warn_noexist(vty
, rmap_str
);
9671 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9674 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9675 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9677 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9682 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9683 "no import vrf route-map [RMAP$rmap_str]",
9685 "Import routes from another VRF\n"
9686 "Vrf routes being filtered\n"
9687 "Specify route map\n"
9688 "name of route-map\n")
9690 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9691 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9694 afi
= vpn_policy_getafi(vty
, bgp
, true);
9696 return CMD_WARNING_CONFIG_FAILED
;
9698 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9700 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9701 XFREE(MTYPE_ROUTE_MAP_NAME
,
9702 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9703 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9704 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9706 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9707 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9708 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9710 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9715 DEFPY_YANG(bgp_imexport_vrf
,
9716 bgp_imexport_vrf_cmd
,
9717 "[no] import vrf VIEWVRFNAME$import_name",
9719 "Import routes from another VRF\n"
9720 "VRF to import from\n"
9721 "The name of the VRF\n")
9723 char base_xpath
[XPATH_MAXLEN
];
9728 if (import_name
== NULL
) {
9729 vty_out(vty
, "%% Missing import name\n");
9733 if (strcmp(import_name
, "route-map") == 0) {
9734 vty_out(vty
, "%% Must include route-map name\n");
9738 afi
= bgp_node_afi(vty
);
9739 safi
= bgp_node_safi(vty
);
9742 base_xpath
, sizeof(base_xpath
),
9743 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9744 yang_afi_safi_value2identity(afi
, safi
),
9745 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9747 if (argv_find(argv
, argc
, "no", &idx
))
9748 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9750 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9752 return nb_cli_apply_changes(vty
, base_xpath
);
9755 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9756 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9758 vty_out(vty
, " import vrf %s\n",
9759 yang_dnode_get_string(dnode
, "./vrf"));
9762 /* This command is valid only in a bgp vrf instance or the default instance */
9763 DEFPY_YANG (bgp_imexport_vpn
,
9764 bgp_imexport_vpn_cmd
,
9765 "[no] <import|export>$direction_str vpn",
9767 "Import routes to this address-family\n"
9768 "Export routes from this address-family\n"
9769 "to/from default instance VPN RIB\n")
9771 char base_xpath
[XPATH_MAXLEN
];
9776 afi
= bgp_node_afi(vty
);
9777 safi
= bgp_node_safi(vty
);
9779 if (!strcmp(direction_str
, "import")) {
9781 base_xpath
, sizeof(base_xpath
),
9782 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9783 yang_afi_safi_value2identity(afi
, safi
),
9784 bgp_afi_safi_get_container_str(afi
, safi
));
9785 } else if (!strcmp(direction_str
, "export")) {
9787 base_xpath
, sizeof(base_xpath
),
9788 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9789 yang_afi_safi_value2identity(afi
, safi
),
9790 bgp_afi_safi_get_container_str(afi
, safi
));
9792 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9793 return CMD_WARNING_CONFIG_FAILED
;
9796 if (argv_find(argv
, argc
, "no", &idx
))
9797 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9799 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9801 return nb_cli_apply_changes(vty
, base_xpath
);
9804 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9805 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9807 if (yang_dnode_get_bool(dnode
, NULL
))
9808 vty_out(vty
, " import vpn\n");
9811 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9812 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9814 if (yang_dnode_get_bool(dnode
, NULL
))
9815 vty_out(vty
, " export vpn\n");
9818 DEFPY (af_routetarget_import
,
9819 af_routetarget_import_cmd
,
9820 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9822 "Specify route target list\n"
9823 "Specify route target list\n"
9824 "Specify route target list\n"
9825 "Specify route target list\n"
9826 "Flow-spec redirect type route target\n"
9827 "Import routes to this address-family\n"
9828 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9832 struct ecommunity
*ecom
= NULL
;
9834 int idx
= 0, idx_unused
= 0;
9838 if (argv_find(argv
, argc
, "no", &idx
))
9841 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9842 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9845 afi
= vpn_policy_getafi(vty
, bgp
, false);
9847 return CMD_WARNING_CONFIG_FAILED
;
9849 if (rt6
&& afi
!= AFI_IP6
)
9850 return CMD_WARNING_CONFIG_FAILED
;
9853 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9854 vty_out(vty
, "%% Missing RTLIST\n");
9855 return CMD_WARNING_CONFIG_FAILED
;
9857 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9858 if (ret
!= CMD_SUCCESS
)
9863 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9864 ecommunity_free(&bgp
->vpn_policy
[afi
]
9865 .import_redirect_rtlist
);
9866 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9867 ecommunity_dup(ecom
);
9869 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9870 ecommunity_free(&bgp
->vpn_policy
[afi
]
9871 .import_redirect_rtlist
);
9872 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9876 ecommunity_free(&ecom
);
9881 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9882 struct lyd_node
*dnode
,
9885 const char *af_name
;
9889 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9890 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9892 vty_out(vty
, " !\n address-family ");
9893 if (afi
== AFI_IP
) {
9894 if (safi
== SAFI_UNICAST
)
9895 vty_out(vty
, "ipv4 unicast");
9896 else if (safi
== SAFI_LABELED_UNICAST
)
9897 vty_out(vty
, "ipv4 labeled-unicast");
9898 else if (safi
== SAFI_MULTICAST
)
9899 vty_out(vty
, "ipv4 multicast");
9900 else if (safi
== SAFI_MPLS_VPN
)
9901 vty_out(vty
, "ipv4 vpn");
9902 else if (safi
== SAFI_ENCAP
)
9903 vty_out(vty
, "ipv4 encap");
9904 else if (safi
== SAFI_FLOWSPEC
)
9905 vty_out(vty
, "ipv4 flowspec");
9906 } else if (afi
== AFI_IP6
) {
9907 if (safi
== SAFI_UNICAST
)
9908 vty_out(vty
, "ipv6 unicast");
9909 else if (safi
== SAFI_LABELED_UNICAST
)
9910 vty_out(vty
, "ipv6 labeled-unicast");
9911 else if (safi
== SAFI_MULTICAST
)
9912 vty_out(vty
, "ipv6 multicast");
9913 else if (safi
== SAFI_MPLS_VPN
)
9914 vty_out(vty
, "ipv6 vpn");
9915 else if (safi
== SAFI_ENCAP
)
9916 vty_out(vty
, "ipv6 encap");
9917 else if (safi
== SAFI_FLOWSPEC
)
9918 vty_out(vty
, "ipv6 flowspec");
9919 } else if (afi
== AFI_L2VPN
) {
9920 if (safi
== SAFI_EVPN
)
9921 vty_out(vty
, "l2vpn evpn");
9926 DEFUN_NOSH (address_family_ipv4_safi
,
9927 address_family_ipv4_safi_cmd
,
9928 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9929 "Enter Address Family command mode\n"
9931 BGP_SAFI_WITH_LABEL_HELP_STR
)
9934 safi_t safi
= SAFI_UNICAST
;
9935 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9936 const char *vrf_name
= NULL
;
9939 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9941 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9943 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9944 "control-plane-protocol");
9945 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9947 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9948 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9949 && safi
!= SAFI_EVPN
) {
9951 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9952 return CMD_WARNING_CONFIG_FAILED
;
9955 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9960 DEFUN_NOSH (address_family_ipv6_safi
,
9961 address_family_ipv6_safi_cmd
,
9962 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9963 "Enter Address Family command mode\n"
9965 BGP_SAFI_WITH_LABEL_HELP_STR
)
9967 safi_t safi
= SAFI_UNICAST
;
9968 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9969 const char *vrf_name
= NULL
;
9972 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9973 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9975 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9976 "control-plane-protocol");
9977 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9979 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9980 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9981 && safi
!= SAFI_EVPN
) {
9983 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9984 return CMD_WARNING_CONFIG_FAILED
;
9987 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9992 #ifdef KEEP_OLD_VPN_COMMANDS
9993 DEFUN_NOSH (address_family_vpnv4
,
9994 address_family_vpnv4_cmd
,
9995 "address-family vpnv4 [unicast]",
9996 "Enter Address Family command mode\n"
9998 "Address Family modifier\n")
10000 vty
->node
= BGP_VPNV4_NODE
;
10001 return CMD_SUCCESS
;
10004 DEFUN_NOSH (address_family_vpnv6
,
10005 address_family_vpnv6_cmd
,
10006 "address-family vpnv6 [unicast]",
10007 "Enter Address Family command mode\n"
10009 "Address Family modifier\n")
10011 vty
->node
= BGP_VPNV6_NODE
;
10012 return CMD_SUCCESS
;
10014 #endif /* KEEP_OLD_VPN_COMMANDS */
10016 DEFUN_NOSH (address_family_evpn
,
10017 address_family_evpn_cmd
,
10018 "address-family l2vpn evpn",
10019 "Enter Address Family command mode\n"
10021 "Address Family modifier\n")
10023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10024 vty
->node
= BGP_EVPN_NODE
;
10025 return CMD_SUCCESS
;
10028 DEFUN_NOSH (bgp_segment_routing_srv6
,
10029 bgp_segment_routing_srv6_cmd
,
10030 "segment-routing srv6",
10031 "Segment-Routing configuration\n"
10032 "Segment-Routing SRv6 configuration\n")
10034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10035 bgp
->srv6_enabled
= true;
10036 vty
->node
= BGP_SRV6_NODE
;
10037 return CMD_SUCCESS
;
10040 DEFPY (bgp_srv6_locator
,
10041 bgp_srv6_locator_cmd
,
10042 "locator NAME$name",
10043 "Specify SRv6 locator\n"
10044 "Specify SRv6 locator\n")
10046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10049 if (strlen(bgp
->srv6_locator_name
) > 0
10050 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
10051 vty_out(vty
, "srv6 locator is already configured\n");
10052 return CMD_WARNING_CONFIG_FAILED
;
10055 snprintf(bgp
->srv6_locator_name
,
10056 sizeof(bgp
->srv6_locator_name
), "%s", name
);
10058 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
10060 return CMD_WARNING_CONFIG_FAILED
;
10062 return CMD_SUCCESS
;
10065 DEFPY (show_bgp_srv6
,
10067 "show bgp segment-routing srv6",
10070 "BGP Segment Routing\n"
10071 "BGP Segment Routing SRv6\n")
10074 struct listnode
*node
;
10075 struct prefix_ipv6
*chunk
;
10076 struct bgp_srv6_function
*func
;
10077 struct in6_addr
*tovpn4_sid
;
10078 struct in6_addr
*tovpn6_sid
;
10080 char buf_tovpn4_sid
[256];
10081 char buf_tovpn6_sid
[256];
10083 bgp
= bgp_get_default();
10085 return CMD_SUCCESS
;
10087 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
10088 vty_out(vty
, "locator_chunks:\n");
10089 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10090 prefix2str(chunk
, buf
, sizeof(buf
));
10091 vty_out(vty
, "- %s\n", buf
);
10094 vty_out(vty
, "functions:\n");
10095 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10096 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
10097 vty_out(vty
, "- sid: %s\n", buf
);
10098 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10101 vty_out(vty
, "bgps:\n");
10102 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10103 vty_out(vty
, "- name: %s\n",
10104 bgp
->name
? bgp
->name
: "default");
10106 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
10107 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
10109 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
10110 sizeof(buf_tovpn4_sid
));
10112 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
10113 sizeof(buf_tovpn6_sid
));
10115 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
10116 tovpn4_sid
? buf_tovpn4_sid
: "none");
10117 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
10118 tovpn6_sid
? buf_tovpn6_sid
: "none");
10121 return CMD_SUCCESS
;
10124 DEFUN_NOSH (exit_address_family
,
10125 exit_address_family_cmd
,
10126 "exit-address-family",
10127 "Exit from Address Family configuration mode\n")
10129 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10130 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10131 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10132 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10133 || vty
->node
== BGP_EVPN_NODE
10134 || vty
->node
== BGP_FLOWSPECV4_NODE
10135 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10136 vty
->node
= BGP_NODE
;
10137 return CMD_SUCCESS
;
10140 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
10141 struct lyd_node
*dnode
10142 __attribute__((__unused__
)))
10144 vty_out(vty
, " exit-address-family\n");
10147 /* Recalculate bestpath and re-advertise a prefix */
10148 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10149 const char *ip_str
, afi_t afi
, safi_t safi
,
10150 struct prefix_rd
*prd
)
10153 struct prefix match
;
10154 struct bgp_dest
*dest
;
10155 struct bgp_dest
*rm
;
10157 struct bgp_table
*table
;
10158 struct bgp_table
*rib
;
10160 /* BGP structure lookup. */
10162 bgp
= bgp_lookup_by_name(view_name
);
10164 vty_out(vty
, "%% Can't find BGP instance %s\n",
10166 return CMD_WARNING
;
10169 bgp
= bgp_get_default();
10171 vty_out(vty
, "%% No BGP process is configured\n");
10172 return CMD_WARNING
;
10176 /* Check IP address argument. */
10177 ret
= str2prefix(ip_str
, &match
);
10179 vty_out(vty
, "%% address is malformed\n");
10180 return CMD_WARNING
;
10183 match
.family
= afi2family(afi
);
10184 rib
= bgp
->rib
[afi
][safi
];
10186 if (safi
== SAFI_MPLS_VPN
) {
10187 for (dest
= bgp_table_top(rib
); dest
;
10188 dest
= bgp_route_next(dest
)) {
10189 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10191 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10194 table
= bgp_dest_get_bgp_table_info(dest
);
10198 rm
= bgp_node_match(table
, &match
);
10200 const struct prefix
*rm_p
=
10201 bgp_dest_get_prefix(rm
);
10203 if (rm_p
->prefixlen
== match
.prefixlen
) {
10204 SET_FLAG(rm
->flags
,
10205 BGP_NODE_USER_CLEAR
);
10206 bgp_process(bgp
, rm
, afi
, safi
);
10208 bgp_dest_unlock_node(rm
);
10212 dest
= bgp_node_match(rib
, &match
);
10213 if (dest
!= NULL
) {
10214 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10216 if (dest_p
->prefixlen
== match
.prefixlen
) {
10217 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10218 bgp_process(bgp
, dest
, afi
, safi
);
10220 bgp_dest_unlock_node(dest
);
10224 return CMD_SUCCESS
;
10227 /* one clear bgp command to rule them all */
10228 DEFUN (clear_ip_bgp_all
,
10229 clear_ip_bgp_all_cmd
,
10230 "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>]",
10234 BGP_INSTANCE_HELP_STR
10237 BGP_SAFI_WITH_LABEL_HELP_STR
10238 "Address Family modifier\n"
10239 "Clear all peers\n"
10240 "BGP IPv4 neighbor to clear\n"
10241 "BGP IPv6 neighbor to clear\n"
10242 "BGP neighbor on interface to clear\n"
10243 "Clear peers with the AS number\n"
10244 "Clear all external peers\n"
10245 "Clear all members of peer-group\n"
10246 "BGP peer-group name\n"
10251 "Push out prefix-list ORF and do inbound soft reconfig\n"
10256 afi_t afi
= AFI_UNSPEC
;
10257 safi_t safi
= SAFI_UNSPEC
;
10258 enum clear_sort clr_sort
= clear_peer
;
10259 enum bgp_clear_type clr_type
;
10260 char *clr_arg
= NULL
;
10263 char errmsg
[BUFSIZ
] = {'\0'};
10266 /* clear [ip] bgp */
10267 if (argv_find(argv
, argc
, "ip", &idx
))
10270 /* [<vrf> VIEWVRFNAME] */
10271 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10272 vrf
= argv
[idx
+ 1]->arg
;
10274 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10276 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10277 /* [<view> VIEWVRFNAME] */
10278 vrf
= argv
[idx
+ 1]->arg
;
10281 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10282 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10283 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10285 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10286 if (argv_find(argv
, argc
, "*", &idx
)) {
10287 clr_sort
= clear_all
;
10288 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10289 clr_sort
= clear_peer
;
10290 clr_arg
= argv
[idx
]->arg
;
10291 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10292 clr_sort
= clear_peer
;
10293 clr_arg
= argv
[idx
]->arg
;
10294 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10295 clr_sort
= clear_group
;
10297 clr_arg
= argv
[idx
]->arg
;
10298 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10299 clr_sort
= clear_peer
;
10300 clr_arg
= argv
[idx
]->arg
;
10301 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10302 clr_sort
= clear_peer
;
10303 clr_arg
= argv
[idx
]->arg
;
10304 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10305 clr_sort
= clear_as
;
10306 clr_arg
= argv
[idx
]->arg
;
10307 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10308 clr_sort
= clear_external
;
10311 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
10312 if (argv_find(argv
, argc
, "soft", &idx
)) {
10313 if (argv_find(argv
, argc
, "in", &idx
)
10314 || argv_find(argv
, argc
, "out", &idx
))
10315 clr_type
= strmatch(argv
[idx
]->text
, "in")
10316 ? BGP_CLEAR_SOFT_IN
10317 : BGP_CLEAR_SOFT_OUT
;
10319 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10320 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10321 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10322 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10323 : BGP_CLEAR_SOFT_IN
;
10324 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10325 clr_type
= BGP_CLEAR_SOFT_OUT
;
10327 clr_type
= BGP_CLEAR_SOFT_NONE
;
10329 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
10332 vty_out(vty
, "Error description: %s\n", errmsg
);
10337 DEFUN (clear_ip_bgp_prefix
,
10338 clear_ip_bgp_prefix_cmd
,
10339 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10343 BGP_INSTANCE_HELP_STR
10344 "Clear bestpath and re-advertise\n"
10348 char *prefix
= NULL
;
10352 /* [<view|vrf> VIEWVRFNAME] */
10353 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10354 vrf
= argv
[idx
+ 1]->arg
;
10356 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10358 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10359 /* [<view> VIEWVRFNAME] */
10360 vrf
= argv
[idx
+ 1]->arg
;
10364 prefix
= argv
[argc
- 1]->arg
;
10366 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10369 DEFUN (clear_bgp_ipv6_safi_prefix
,
10370 clear_bgp_ipv6_safi_prefix_cmd
,
10371 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10377 "Clear bestpath and re-advertise\n"
10381 int idx_ipv6_prefix
= 0;
10382 safi_t safi
= SAFI_UNICAST
;
10383 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10384 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10386 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10387 return bgp_clear_prefix(
10388 vty
, NULL
, prefix
, AFI_IP6
,
10392 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10393 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10394 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10398 BGP_INSTANCE_HELP_STR
10401 "Clear bestpath and re-advertise\n"
10405 int idx_vrfview
= 0;
10406 int idx_ipv6_prefix
= 0;
10407 safi_t safi
= SAFI_UNICAST
;
10408 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10409 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10410 char *vrfview
= NULL
;
10412 /* [<view|vrf> VIEWVRFNAME] */
10413 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10414 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10415 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10417 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10418 /* [<view> VIEWVRFNAME] */
10419 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10421 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10423 return bgp_clear_prefix(
10424 vty
, vrfview
, prefix
,
10425 AFI_IP6
, safi
, NULL
);
10428 DEFUN (show_bgp_views
,
10429 show_bgp_views_cmd
,
10430 "show [ip] bgp views",
10434 "Show the defined BGP views\n")
10436 struct list
*inst
= bm
->bgp
;
10437 struct listnode
*node
;
10440 vty_out(vty
, "Defined BGP views:\n");
10441 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10443 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10445 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10449 return CMD_SUCCESS
;
10452 DEFUN (show_bgp_vrfs
,
10454 "show [ip] bgp vrfs [json]",
10461 char buf
[ETHER_ADDR_STRLEN
];
10462 struct list
*inst
= bm
->bgp
;
10463 struct listnode
*node
;
10465 bool uj
= use_json(argc
, argv
);
10466 json_object
*json
= NULL
;
10467 json_object
*json_vrfs
= NULL
;
10471 json
= json_object_new_object();
10472 json_vrfs
= json_object_new_object();
10475 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10476 const char *name
, *type
;
10478 struct listnode
*node2
, *nnode2
;
10479 int peers_cfg
, peers_estb
;
10480 json_object
*json_vrf
= NULL
;
10483 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10487 if (!uj
&& count
== 1) {
10489 "%4s %-5s %-16s %9s %10s %-37s\n",
10490 "Type", "Id", "routerId", "#PeersCfg",
10491 "#PeersEstb", "Name");
10492 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10493 "L3-VNI", "RouterMAC", "Interface");
10496 peers_cfg
= peers_estb
= 0;
10498 json_vrf
= json_object_new_object();
10501 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10502 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10505 if (peer_established(peer
))
10509 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10510 name
= VRF_DEFAULT_NAME
;
10519 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10521 : (int64_t)bgp
->vrf_id
;
10522 char buf
[BUFSIZ
] = {0};
10524 json_object_string_add(json_vrf
, "type", type
);
10525 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10526 json_object_string_add(json_vrf
, "routerId",
10528 &bgp
->router_id
, buf
,
10530 json_object_int_add(json_vrf
, "numConfiguredPeers",
10532 json_object_int_add(json_vrf
, "numEstablishedPeers",
10535 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10536 json_object_string_add(
10538 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10539 json_object_string_add(json_vrf
, "interface",
10540 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10542 json_object_object_add(json_vrfs
, name
, json_vrf
);
10544 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10546 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10547 : (int)bgp
->vrf_id
,
10548 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10549 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10551 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10552 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10558 json_object_object_add(json
, "vrfs", json_vrfs
);
10560 json_object_int_add(json
, "totalVrfs", count
);
10562 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10563 json
, JSON_C_TO_STRING_PRETTY
));
10564 json_object_free(json
);
10568 "\nTotal number of VRFs (including default): %d\n",
10572 return CMD_SUCCESS
;
10575 DEFUN (show_bgp_mac_hash
,
10576 show_bgp_mac_hash_cmd
,
10577 "show bgp mac hash",
10581 "Mac Address database\n")
10583 bgp_mac_dump_table(vty
);
10585 return CMD_SUCCESS
;
10588 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10590 struct vty
*vty
= (struct vty
*)args
;
10591 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10593 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10596 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10598 vty_out(vty
, "self nexthop database:\n");
10599 bgp_nexthop_show_address_hash(vty
, bgp
);
10601 vty_out(vty
, "Tunnel-ip database:\n");
10602 hash_iterate(bgp
->tip_hash
,
10603 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10607 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10608 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10609 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10610 "martian next-hops\n"
10611 "martian next-hop database\n")
10613 struct bgp
*bgp
= NULL
;
10617 /* [<vrf> VIEWVRFNAME] */
10618 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10619 name
= argv
[idx
+ 1]->arg
;
10620 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10622 } else if (argv_find(argv
, argc
, "view", &idx
))
10623 /* [<view> VIEWVRFNAME] */
10624 name
= argv
[idx
+ 1]->arg
;
10626 bgp
= bgp_lookup_by_name(name
);
10628 bgp
= bgp_get_default();
10631 vty_out(vty
, "%% No BGP process is configured\n");
10632 return CMD_WARNING
;
10634 bgp_show_martian_nexthops(vty
, bgp
);
10636 return CMD_SUCCESS
;
10639 DEFUN (show_bgp_memory
,
10640 show_bgp_memory_cmd
,
10641 "show [ip] bgp memory",
10645 "Global BGP memory statistics\n")
10647 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10648 unsigned long count
;
10650 /* RIB related usage stats */
10651 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10652 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10653 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10654 count
* sizeof(struct bgp_dest
)));
10656 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10657 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10658 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10659 count
* sizeof(struct bgp_path_info
)));
10660 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10661 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10664 memstrbuf
, sizeof(memstrbuf
),
10665 count
* sizeof(struct bgp_path_info_extra
)));
10667 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10668 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10669 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10670 count
* sizeof(struct bgp_static
)));
10672 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10673 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10674 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10675 count
* sizeof(struct bpacket
)));
10678 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10679 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10680 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10681 count
* sizeof(struct bgp_adj_in
)));
10682 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10683 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10684 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10685 count
* sizeof(struct bgp_adj_out
)));
10687 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10688 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10690 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10691 count
* sizeof(struct bgp_nexthop_cache
)));
10693 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10694 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10696 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10697 count
* sizeof(struct bgp_damp_info
)));
10700 count
= attr_count();
10701 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10702 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10703 count
* sizeof(struct attr
)));
10705 if ((count
= attr_unknown_count()))
10706 vty_out(vty
, "%ld unknown attributes\n", count
);
10708 /* AS_PATH attributes */
10709 count
= aspath_count();
10710 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10711 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10712 count
* sizeof(struct aspath
)));
10714 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10715 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10716 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10717 count
* sizeof(struct assegment
)));
10719 /* Other attributes */
10720 if ((count
= community_count()))
10721 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10722 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10723 count
* sizeof(struct community
)));
10724 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10725 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10726 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10727 count
* sizeof(struct ecommunity
)));
10728 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10730 "%ld BGP large-community entries, using %s of memory\n",
10731 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10732 count
* sizeof(struct lcommunity
)));
10734 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10735 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10736 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10737 count
* sizeof(struct cluster_list
)));
10739 /* Peer related usage */
10740 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10741 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10742 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10743 count
* sizeof(struct peer
)));
10745 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10746 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10747 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10748 count
* sizeof(struct peer_group
)));
10751 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10752 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10753 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10754 count
* sizeof(regex_t
)));
10755 return CMD_SUCCESS
;
10758 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10760 json_object
*bestpath
= json_object_new_object();
10762 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10763 json_object_string_add(bestpath
, "asPath", "ignore");
10765 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10766 json_object_string_add(bestpath
, "asPath", "confed");
10768 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10769 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10770 json_object_string_add(bestpath
, "multiPathRelax",
10773 json_object_string_add(bestpath
, "multiPathRelax",
10776 json_object_string_add(bestpath
, "multiPathRelax", "false");
10778 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10779 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10781 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10782 json_object_string_add(bestpath
, "compareRouterId", "true");
10783 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10784 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10785 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10786 json_object_string_add(bestpath
, "med", "confed");
10787 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10788 json_object_string_add(bestpath
, "med",
10789 "missing-as-worst");
10791 json_object_string_add(bestpath
, "med", "true");
10794 json_object_object_add(json
, "bestPath", bestpath
);
10797 /* Print the error code/subcode for why the peer is down */
10798 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10799 json_object
*json_peer
, bool use_json
)
10801 const char *code_str
;
10802 const char *subcode_str
;
10805 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10806 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10807 char errorcodesubcode_hexstr
[5];
10808 char errorcodesubcode_str
[256];
10810 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10811 subcode_str
= bgp_notify_subcode_str(
10813 peer
->notify
.subcode
);
10815 snprintf(errorcodesubcode_hexstr
,
10816 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10817 peer
->notify
.code
, peer
->notify
.subcode
);
10818 json_object_string_add(json_peer
,
10819 "lastErrorCodeSubcode",
10820 errorcodesubcode_hexstr
);
10821 snprintf(errorcodesubcode_str
, 255, "%s%s",
10822 code_str
, subcode_str
);
10823 json_object_string_add(json_peer
,
10824 "lastNotificationReason",
10825 errorcodesubcode_str
);
10826 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10827 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10828 && (peer
->notify
.subcode
10829 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10830 || peer
->notify
.subcode
10831 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10832 && peer
->notify
.length
) {
10834 const char *msg_str
;
10836 msg_str
= bgp_notify_admin_message(
10837 msgbuf
, sizeof(msgbuf
),
10838 (uint8_t *)peer
->notify
.data
,
10839 peer
->notify
.length
);
10841 json_object_string_add(
10843 "lastShutdownDescription",
10848 json_object_string_add(json_peer
, "lastResetDueTo",
10849 peer_down_str
[(int)peer
->last_reset
]);
10850 json_object_int_add(json_peer
, "lastResetCode",
10853 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10854 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10855 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10857 bgp_notify_subcode_str(peer
->notify
.code
,
10858 peer
->notify
.subcode
);
10859 vty_out(vty
, " Notification %s (%s%s)\n",
10860 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10863 code_str
, subcode_str
);
10865 vty_out(vty
, " %s\n",
10866 peer_down_str
[(int)peer
->last_reset
]);
10871 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10874 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10877 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10878 struct peer
*peer
, json_object
*json_peer
,
10879 int max_neighbor_width
, bool use_json
)
10881 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10885 if (peer_dynamic_neighbor(peer
))
10886 json_object_boolean_true_add(json_peer
,
10888 if (peer
->hostname
)
10889 json_object_string_add(json_peer
, "hostname",
10892 if (peer
->domainname
)
10893 json_object_string_add(json_peer
, "domainname",
10895 json_object_int_add(json_peer
, "connectionsEstablished",
10896 peer
->established
);
10897 json_object_int_add(json_peer
, "connectionsDropped",
10899 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10900 use_json
, json_peer
);
10901 if (peer_established(peer
))
10902 json_object_string_add(json_peer
, "lastResetDueTo",
10903 "AFI/SAFI Not Negotiated");
10905 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10908 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10910 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10911 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10912 peer
->hostname
, peer
->host
);
10914 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10916 /* pad the neighbor column with spaces */
10917 if (len
< max_neighbor_width
)
10918 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10920 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10922 peer_uptime(peer
->uptime
, timebuf
,
10923 BGP_UPTIME_LEN
, 0, NULL
));
10924 if (peer_established(peer
))
10925 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10927 bgp_show_peer_reset(vty
, peer
, NULL
,
10932 /* If the peer's description includes whitespaces
10933 * then return the first occurrence. Also strip description
10934 * to the given size if needed.
10936 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10938 static char stripped
[BUFSIZ
];
10940 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10942 pnt
= strchr(desc
, ' ');
10944 len
= size
> (uint32_t)(pnt
- desc
) ? (uint32_t)(pnt
- desc
)
10947 strlcpy(stripped
, desc
, len
+ 1);
10952 /* Determine whether var peer should be filtered out of the summary. */
10953 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10954 struct peer
*fpeer
, int as_type
,
10958 /* filter neighbor XXXX */
10959 if (fpeer
&& fpeer
!= peer
)
10962 /* filter remote-as (internal|external) */
10963 if (as_type
!= AS_UNSPECIFIED
) {
10964 if (peer
->as_type
== AS_SPECIFIED
) {
10965 if (as_type
== AS_INTERNAL
) {
10966 if (peer
->as
!= peer
->local_as
)
10968 } else if (peer
->as
== peer
->local_as
)
10970 } else if (as_type
!= peer
->as_type
)
10972 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10978 /* Show BGP peer's summary information. */
10979 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10980 struct peer
*fpeer
, int as_type
, as_t as
,
10981 uint16_t show_flags
)
10984 struct listnode
*node
, *nnode
;
10985 unsigned int count
= 0, dn_count
= 0;
10986 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10987 char neighbor_buf
[VTY_BUFSIZ
];
10988 int neighbor_col_default_width
= 16;
10989 int len
, failed_count
= 0;
10990 unsigned int filtered_count
= 0;
10991 int max_neighbor_width
= 0;
10993 json_object
*json
= NULL
;
10994 json_object
*json_peer
= NULL
;
10995 json_object
*json_peers
= NULL
;
10996 struct peer_af
*paf
;
10997 struct bgp_filter
*filter
;
10998 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10999 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11000 bool show_established
=
11001 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11002 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11003 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11005 /* labeled-unicast routes are installed in the unicast table so in order
11007 * display the correct PfxRcd value we must look at SAFI_UNICAST
11010 if (safi
== SAFI_LABELED_UNICAST
)
11011 pfx_rcd_safi
= SAFI_UNICAST
;
11013 pfx_rcd_safi
= safi
;
11016 json
= json_object_new_object();
11017 json_peers
= json_object_new_object();
11018 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11019 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11026 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11029 if (peer
->afc
[afi
][safi
]) {
11030 /* See if we have at least a single failed peer */
11031 if (bgp_has_peer_failed(peer
, afi
, safi
))
11035 if (peer_dynamic_neighbor(peer
))
11040 /* Loop over all neighbors that will be displayed to determine
11042 * characters are needed for the Neighbor column
11044 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11045 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11052 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11055 if (peer
->afc
[afi
][safi
]) {
11056 memset(dn_flag
, '\0', sizeof(dn_flag
));
11057 if (peer_dynamic_neighbor(peer
))
11061 && CHECK_FLAG(bgp
->flags
,
11062 BGP_FLAG_SHOW_HOSTNAME
))
11063 snprintf(neighbor_buf
,
11064 sizeof(neighbor_buf
),
11065 "%s%s(%s) ", dn_flag
,
11066 peer
->hostname
, peer
->host
);
11068 snprintf(neighbor_buf
,
11069 sizeof(neighbor_buf
), "%s%s ",
11070 dn_flag
, peer
->host
);
11072 len
= strlen(neighbor_buf
);
11074 if (len
> max_neighbor_width
)
11075 max_neighbor_width
= len
;
11077 /* See if we have at least a single failed peer */
11078 if (bgp_has_peer_failed(peer
, afi
, safi
))
11084 /* Originally we displayed the Neighbor column as 16
11085 * characters wide so make that the default
11087 if (max_neighbor_width
< neighbor_col_default_width
)
11088 max_neighbor_width
= neighbor_col_default_width
;
11091 if (show_failed
&& !failed_count
) {
11093 json_object_int_add(json
, "failedPeersCount", 0);
11094 json_object_int_add(json
, "dynamicPeers", dn_count
);
11095 json_object_int_add(json
, "totalPeers", count
);
11097 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11098 json
, JSON_C_TO_STRING_PRETTY
));
11099 json_object_free(json
);
11101 vty_out(vty
, "%% No failed BGP neighbors found\n");
11103 return CMD_SUCCESS
;
11106 count
= 0; /* Reset the value as its used again */
11107 filtered_count
= 0;
11108 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11109 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11112 if (!peer
->afc
[afi
][safi
])
11116 unsigned long ents
;
11117 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11120 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11122 : (int64_t)bgp
->vrf_id
;
11124 /* Usage summary and header */
11126 char buf
[BUFSIZ
] = {0};
11128 json_object_string_add(
11130 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
11132 json_object_int_add(json
, "as", bgp
->as
);
11133 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11134 json_object_string_add(
11137 == BGP_INSTANCE_TYPE_DEFAULT
)
11142 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11143 &bgp
->router_id
, bgp
->as
,
11144 bgp
->vrf_id
== VRF_UNKNOWN
11146 : (int)bgp
->vrf_id
);
11147 vty_out(vty
, "\n");
11150 if (bgp_update_delay_configured(bgp
)) {
11152 json_object_int_add(
11153 json
, "updateDelayLimit",
11154 bgp
->v_update_delay
);
11156 if (bgp
->v_update_delay
11157 != bgp
->v_establish_wait
)
11158 json_object_int_add(
11160 "updateDelayEstablishWait",
11161 bgp
->v_establish_wait
);
11163 if (bgp_update_delay_active(bgp
)) {
11164 json_object_string_add(
11166 "updateDelayFirstNeighbor",
11167 bgp
->update_delay_begin_time
);
11168 json_object_boolean_true_add(
11170 "updateDelayInProgress");
11172 if (bgp
->update_delay_over
) {
11173 json_object_string_add(
11175 "updateDelayFirstNeighbor",
11176 bgp
->update_delay_begin_time
);
11177 json_object_string_add(
11179 "updateDelayBestpathResumed",
11180 bgp
->update_delay_end_time
);
11181 json_object_string_add(
11183 "updateDelayZebraUpdateResume",
11184 bgp
->update_delay_zebra_resume_time
);
11185 json_object_string_add(
11187 "updateDelayPeerUpdateResume",
11188 bgp
->update_delay_peers_resume_time
);
11193 "Read-only mode update-delay limit: %d seconds\n",
11194 bgp
->v_update_delay
);
11195 if (bgp
->v_update_delay
11196 != bgp
->v_establish_wait
)
11198 " Establish wait: %d seconds\n",
11199 bgp
->v_establish_wait
);
11201 if (bgp_update_delay_active(bgp
)) {
11203 " First neighbor established: %s\n",
11204 bgp
->update_delay_begin_time
);
11206 " Delay in progress\n");
11208 if (bgp
->update_delay_over
) {
11210 " First neighbor established: %s\n",
11211 bgp
->update_delay_begin_time
);
11213 " Best-paths resumed: %s\n",
11214 bgp
->update_delay_end_time
);
11216 " zebra update resumed: %s\n",
11217 bgp
->update_delay_zebra_resume_time
);
11219 " peers update resumed: %s\n",
11220 bgp
->update_delay_peers_resume_time
);
11227 if (bgp_maxmed_onstartup_configured(bgp
)
11228 && bgp
->maxmed_active
)
11229 json_object_boolean_true_add(
11230 json
, "maxMedOnStartup");
11231 if (bgp
->v_maxmed_admin
)
11232 json_object_boolean_true_add(
11233 json
, "maxMedAdministrative");
11235 json_object_int_add(
11236 json
, "tableVersion",
11237 bgp_table_version(bgp
->rib
[afi
][safi
]));
11239 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11240 json_object_int_add(json
, "ribCount", ents
);
11241 json_object_int_add(
11243 ents
* sizeof(struct bgp_dest
));
11245 ents
= bgp
->af_peer_count
[afi
][safi
];
11246 json_object_int_add(json
, "peerCount", ents
);
11247 json_object_int_add(json
, "peerMemory",
11248 ents
* sizeof(struct peer
));
11250 if ((ents
= listcount(bgp
->group
))) {
11251 json_object_int_add(
11252 json
, "peerGroupCount", ents
);
11253 json_object_int_add(
11254 json
, "peerGroupMemory",
11255 ents
* sizeof(struct
11259 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11260 BGP_CONFIG_DAMPENING
))
11261 json_object_boolean_true_add(
11262 json
, "dampeningEnabled");
11265 if (bgp_maxmed_onstartup_configured(bgp
)
11266 && bgp
->maxmed_active
)
11268 "Max-med on-startup active\n");
11269 if (bgp
->v_maxmed_admin
)
11271 "Max-med administrative active\n");
11274 "BGP table version %" PRIu64
11277 bgp
->rib
[afi
][safi
]));
11279 ents
= bgp_table_count(
11280 bgp
->rib
[afi
][safi
]);
11282 "RIB entries %ld, using %s of memory\n",
11292 /* Peer related usage */
11293 ents
= bgp
->af_peer_count
[afi
][safi
];
11295 "Peers %ld, using %s of memory\n",
11305 if ((ents
= listcount(bgp
->group
)))
11307 "Peer groups %ld, using %s of memory\n",
11317 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11318 BGP_CONFIG_DAMPENING
))
11320 "Dampening enabled.\n");
11323 vty_out(vty
, "\n");
11325 /* Subtract 8 here because 'Neighbor' is
11327 vty_out(vty
, "Neighbor");
11328 vty_out(vty
, "%*s",
11329 max_neighbor_width
- 8, " ");
11331 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11336 paf
= peer_af_find(peer
, afi
, safi
);
11337 filter
= &peer
->filter
[afi
][safi
];
11340 /* Works for both failed & successful cases */
11341 if (peer_dynamic_neighbor(peer
))
11346 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11352 bgp_has_peer_failed(peer
, afi
, safi
)) {
11353 json_peer
= json_object_new_object();
11354 bgp_show_failed_summary(vty
, bgp
, peer
,
11355 json_peer
, 0, use_json
);
11356 } else if (!show_failed
) {
11357 if (show_established
11358 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11363 json_peer
= json_object_new_object();
11364 if (peer_dynamic_neighbor(peer
)) {
11365 json_object_boolean_true_add(json_peer
,
11369 if (peer
->hostname
)
11370 json_object_string_add(json_peer
, "hostname",
11373 if (peer
->domainname
)
11374 json_object_string_add(json_peer
, "domainname",
11377 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11378 json_object_int_add(
11379 json_peer
, "localAs",
11380 peer
->change_local_as
11381 ? peer
->change_local_as
11383 json_object_int_add(json_peer
, "version", 4);
11384 json_object_int_add(json_peer
, "msgRcvd",
11385 PEER_TOTAL_RX(peer
));
11386 json_object_int_add(json_peer
, "msgSent",
11387 PEER_TOTAL_TX(peer
));
11389 atomic_size_t outq_count
, inq_count
;
11390 outq_count
= atomic_load_explicit(
11391 &peer
->obuf
->count
,
11392 memory_order_relaxed
);
11393 inq_count
= atomic_load_explicit(
11394 &peer
->ibuf
->count
,
11395 memory_order_relaxed
);
11397 json_object_int_add(json_peer
, "tableVersion",
11398 peer
->version
[afi
][safi
]);
11399 json_object_int_add(json_peer
, "outq",
11401 json_object_int_add(json_peer
, "inq",
11403 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11404 use_json
, json_peer
);
11406 json_object_int_add(json_peer
, "pfxRcd",
11407 peer
->pcount
[afi
][pfx_rcd_safi
]);
11409 if (paf
&& PAF_SUBGRP(paf
))
11410 json_object_int_add(
11411 json_peer
, "pfxSnt",
11412 (PAF_SUBGRP(paf
))->scount
);
11414 json_object_int_add(json_peer
, "pfxSnt",
11417 /* BGP FSM state */
11418 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11419 || CHECK_FLAG(peer
->bgp
->flags
,
11420 BGP_FLAG_SHUTDOWN
))
11421 json_object_string_add(json_peer
,
11424 else if (peer
->afc_recv
[afi
][safi
])
11425 json_object_string_add(
11426 json_peer
, "state",
11427 lookup_msg(bgp_status_msg
,
11428 peer
->status
, NULL
));
11429 else if (CHECK_FLAG(
11431 PEER_STATUS_PREFIX_OVERFLOW
))
11432 json_object_string_add(json_peer
,
11436 json_object_string_add(
11437 json_peer
, "state",
11438 lookup_msg(bgp_status_msg
,
11439 peer
->status
, NULL
));
11441 /* BGP peer state */
11442 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11443 || CHECK_FLAG(peer
->bgp
->flags
,
11444 BGP_FLAG_SHUTDOWN
))
11445 json_object_string_add(json_peer
,
11448 else if (CHECK_FLAG(
11450 PEER_STATUS_PREFIX_OVERFLOW
))
11451 json_object_string_add(json_peer
,
11454 else if (CHECK_FLAG(peer
->flags
,
11455 PEER_FLAG_PASSIVE
))
11456 json_object_string_add(json_peer
,
11459 else if (CHECK_FLAG(peer
->sflags
,
11460 PEER_STATUS_NSF_WAIT
))
11461 json_object_string_add(json_peer
,
11464 else if (CHECK_FLAG(
11466 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11467 && (!bgp_inbound_policy_exists(peer
,
11469 || !bgp_outbound_policy_exists(
11471 json_object_string_add(json_peer
,
11475 json_object_string_add(
11476 json_peer
, "peerState", "OK");
11478 json_object_int_add(json_peer
, "connectionsEstablished",
11479 peer
->established
);
11480 json_object_int_add(json_peer
, "connectionsDropped",
11483 json_object_string_add(
11484 json_peer
, "desc", peer
->desc
);
11486 /* Avoid creating empty peer dicts in JSON */
11487 if (json_peer
== NULL
)
11491 json_object_string_add(json_peer
, "idType",
11493 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11494 json_object_string_add(json_peer
, "idType",
11496 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11497 json_object_string_add(json_peer
, "idType",
11499 json_object_object_add(json_peers
, peer
->host
,
11502 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11508 bgp_has_peer_failed(peer
, afi
, safi
)) {
11509 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11510 max_neighbor_width
,
11512 } else if (!show_failed
) {
11513 if (show_established
11514 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11519 if ((count
- filtered_count
) == 1) {
11520 /* display headline before the first
11522 vty_out(vty
, "\n");
11524 /* Subtract 8 here because 'Neighbor' is
11526 vty_out(vty
, "Neighbor");
11527 vty_out(vty
, "%*s",
11528 max_neighbor_width
- 8, " ");
11531 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11532 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11535 memset(dn_flag
, '\0', sizeof(dn_flag
));
11536 if (peer_dynamic_neighbor(peer
)) {
11541 && CHECK_FLAG(bgp
->flags
,
11542 BGP_FLAG_SHOW_HOSTNAME
))
11543 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11547 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11549 /* pad the neighbor column with spaces */
11550 if (len
< max_neighbor_width
)
11551 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11554 atomic_size_t outq_count
, inq_count
;
11555 outq_count
= atomic_load_explicit(
11556 &peer
->obuf
->count
,
11557 memory_order_relaxed
);
11558 inq_count
= atomic_load_explicit(
11559 &peer
->ibuf
->count
,
11560 memory_order_relaxed
);
11564 "4 %10u %10u %9u %9u %8" PRIu64
11567 peer
->change_local_as
11568 ? peer
->change_local_as
11570 PEER_TOTAL_RX(peer
),
11571 PEER_TOTAL_TX(peer
),
11572 peer
->version
[afi
][safi
],
11573 inq_count
, outq_count
,
11574 peer_uptime(peer
->uptime
,
11579 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11581 peer
->as
, PEER_TOTAL_RX(peer
),
11582 PEER_TOTAL_TX(peer
),
11583 peer
->version
[afi
][safi
],
11584 inq_count
, outq_count
,
11585 peer_uptime(peer
->uptime
,
11590 if (peer_established(peer
)) {
11591 if (peer
->afc_recv
[afi
][safi
]) {
11594 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11595 && !bgp_inbound_policy_exists(
11597 vty_out(vty
, " %12s",
11606 vty_out(vty
, " NoNeg");
11609 if (paf
&& PAF_SUBGRP(paf
)) {
11612 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11613 && !bgp_outbound_policy_exists(
11615 vty_out(vty
, " %8s",
11624 vty_out(vty
, " NoNeg");
11627 if (CHECK_FLAG(peer
->flags
,
11628 PEER_FLAG_SHUTDOWN
)
11629 || CHECK_FLAG(peer
->bgp
->flags
,
11630 BGP_FLAG_SHUTDOWN
))
11631 vty_out(vty
, " Idle (Admin)");
11632 else if (CHECK_FLAG(
11634 PEER_STATUS_PREFIX_OVERFLOW
))
11635 vty_out(vty
, " Idle (PfxCt)");
11637 vty_out(vty
, " %12s",
11638 lookup_msg(bgp_status_msg
,
11639 peer
->status
, NULL
));
11641 vty_out(vty
, " %8u", 0);
11644 vty_out(vty
, " %s",
11645 bgp_peer_description_stripped(
11647 show_wide
? 64 : 20));
11649 vty_out(vty
, " N/A");
11650 vty_out(vty
, "\n");
11657 json_object_object_add(json
, "peers", json_peers
);
11658 json_object_int_add(json
, "failedPeers", failed_count
);
11659 json_object_int_add(json
, "displayedPeers",
11660 count
- filtered_count
);
11661 json_object_int_add(json
, "totalPeers", count
);
11662 json_object_int_add(json
, "dynamicPeers", dn_count
);
11665 bgp_show_bestpath_json(bgp
, json
);
11667 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11668 json
, JSON_C_TO_STRING_PRETTY
));
11669 json_object_free(json
);
11672 if (filtered_count
== count
)
11673 vty_out(vty
, "\n%% No matching neighbor\n");
11676 vty_out(vty
, "\nDisplayed neighbors %d",
11678 else if (as_type
!= AS_UNSPECIFIED
|| as
11679 || fpeer
|| show_established
)
11680 vty_out(vty
, "\nDisplayed neighbors %d",
11681 count
- filtered_count
);
11683 vty_out(vty
, "\nTotal number of neighbors %d\n",
11687 vty_out(vty
, "No %s neighbor is configured\n",
11688 get_afi_safi_str(afi
, safi
, false));
11692 vty_out(vty
, "* - dynamic neighbor\n");
11693 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11694 dn_count
, bgp
->dynamic_neighbors_limit
);
11698 return CMD_SUCCESS
;
11701 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11702 int safi
, struct peer
*fpeer
, int as_type
,
11703 as_t as
, uint16_t show_flags
)
11706 int afi_wildcard
= (afi
== AFI_MAX
);
11707 int safi_wildcard
= (safi
== SAFI_MAX
);
11708 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11709 bool nbr_output
= false;
11710 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11712 if (use_json
&& is_wildcard
)
11713 vty_out(vty
, "{\n");
11715 afi
= 1; /* AFI_IP */
11716 while (afi
< AFI_MAX
) {
11718 safi
= 1; /* SAFI_UNICAST */
11719 while (safi
< SAFI_MAX
) {
11720 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11725 * So limit output to those afi/safi
11727 * actualy have something interesting in
11732 vty_out(vty
, ",\n");
11736 vty_out(vty
, "\"%s\":",
11737 get_afi_safi_str(afi
,
11742 "\n%s Summary (%s):\n",
11743 get_afi_safi_str(afi
,
11749 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11750 as_type
, as
, show_flags
);
11753 if (!safi_wildcard
)
11761 if (use_json
&& is_wildcard
)
11762 vty_out(vty
, "}\n");
11763 else if (!nbr_output
) {
11765 vty_out(vty
, "{}\n");
11767 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11772 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11774 const char *neighbor
,
11775 int as_type
, as_t as
,
11776 uint16_t show_flags
)
11778 struct listnode
*node
, *nnode
;
11780 struct peer
*fpeer
= NULL
;
11782 bool nbr_output
= false;
11783 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11786 vty_out(vty
, "{\n");
11788 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11792 vty_out(vty
, ",\n");
11796 vty_out(vty
, "\"%s\":",
11797 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11802 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11807 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11812 vty_out(vty
, "}\n");
11813 else if (!nbr_output
)
11814 vty_out(vty
, "%% BGP instance not found\n");
11817 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11818 safi_t safi
, const char *neighbor
, int as_type
,
11819 as_t as
, uint16_t show_flags
)
11822 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11823 struct peer
*fpeer
= NULL
;
11826 if (strmatch(name
, "all")) {
11827 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11830 return CMD_SUCCESS
;
11832 bgp
= bgp_lookup_by_name(name
);
11836 vty_out(vty
, "{}\n");
11839 "%% BGP instance not found\n");
11840 return CMD_WARNING
;
11844 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11847 return CMD_WARNING
;
11849 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11850 as_type
, as
, show_flags
);
11851 return CMD_SUCCESS
;
11855 bgp
= bgp_get_default();
11859 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11862 return CMD_WARNING
;
11864 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11868 vty_out(vty
, "{}\n");
11870 vty_out(vty
, "%% BGP instance not found\n");
11871 return CMD_WARNING
;
11874 return CMD_SUCCESS
;
11877 /* `show [ip] bgp summary' commands. */
11878 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11879 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11880 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11881 "]] [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]",
11882 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11883 BGP_SAFI_WITH_LABEL_HELP_STR
11884 "Display the entries for all address families\n"
11885 "Summary of BGP neighbor status\n"
11886 "Show only sessions in Established state\n"
11887 "Show only sessions not in Established state\n"
11888 "Show only the specified neighbor session\n"
11889 "Neighbor to display information about\n"
11890 "Neighbor to display information about\n"
11891 "Neighbor on BGP configured interface\n"
11892 "Show only the specified remote AS sessions\n"
11894 "Internal (iBGP) AS sessions\n"
11895 "External (eBGP) AS sessions\n"
11896 "Shorten the information on BGP instances\n"
11897 "Increase table width for longer output\n" JSON_STR
)
11900 afi_t afi
= AFI_MAX
;
11901 safi_t safi
= SAFI_MAX
;
11902 as_t as
= 0; /* 0 means AS filter not set */
11903 int as_type
= AS_UNSPECIFIED
;
11904 uint16_t show_flags
= 0;
11908 /* show [ip] bgp */
11909 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11911 /* [<vrf> VIEWVRFNAME] */
11912 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11913 vrf
= argv
[idx
+ 1]->arg
;
11914 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11916 } else if (argv_find(argv
, argc
, "view", &idx
))
11917 /* [<view> VIEWVRFNAME] */
11918 vrf
= argv
[idx
+ 1]->arg
;
11919 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11920 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11921 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11924 if (argv_find(argv
, argc
, "failed", &idx
))
11925 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11927 if (argv_find(argv
, argc
, "established", &idx
))
11928 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11930 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11931 if (argv
[idx
+ 1]->arg
[0] == 'i')
11932 as_type
= AS_INTERNAL
;
11933 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11934 as_type
= AS_EXTERNAL
;
11936 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11939 if (argv_find(argv
, argc
, "terse", &idx
))
11940 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11942 if (argv_find(argv
, argc
, "wide", &idx
))
11943 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11945 if (argv_find(argv
, argc
, "json", &idx
))
11946 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11948 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11952 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11955 return get_afi_safi_json_str(afi
, safi
);
11957 return get_afi_safi_vty_str(afi
, safi
);
11961 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11962 afi_t afi
, safi_t safi
,
11963 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11964 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11965 bool use_json
, json_object
*json_pref
)
11968 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11969 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11971 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11972 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11973 json_object_string_add(json_pref
, "sendMode",
11974 "advertisedAndReceived");
11975 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11976 json_object_string_add(json_pref
, "sendMode",
11978 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11979 json_object_string_add(json_pref
, "sendMode",
11982 vty_out(vty
, " Send-mode: ");
11983 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11984 vty_out(vty
, "advertised");
11985 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11986 vty_out(vty
, "%sreceived",
11987 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11991 vty_out(vty
, "\n");
11996 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11997 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11999 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12000 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12001 json_object_string_add(json_pref
, "recvMode",
12002 "advertisedAndReceived");
12003 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12004 json_object_string_add(json_pref
, "recvMode",
12006 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12007 json_object_string_add(json_pref
, "recvMode",
12010 vty_out(vty
, " Receive-mode: ");
12011 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12012 vty_out(vty
, "advertised");
12013 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12014 vty_out(vty
, "%sreceived",
12015 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12019 vty_out(vty
, "\n");
12024 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
12029 bool rbit_status
= false;
12032 vty_out(vty
, "\n R bit: ");
12034 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12035 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12036 && (peer_established(p
))) {
12038 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
12039 rbit_status
= true;
12041 rbit_status
= false;
12046 json_object_boolean_true_add(json
, "rBit");
12048 vty_out(vty
, "True\n");
12051 json_object_boolean_false_add(json
, "rBit");
12053 vty_out(vty
, "False\n");
12057 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12062 const char *mode
= "NotApplicable";
12065 vty_out(vty
, "\n Remote GR Mode: ");
12067 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12068 && (peer_established(peer
))) {
12070 if ((peer
->nsf_af_count
== 0)
12071 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12075 } else if (peer
->nsf_af_count
== 0
12076 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12080 } else if (peer
->nsf_af_count
!= 0
12081 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12088 json_object_string_add(json
, "remoteGrMode", mode
);
12090 vty_out(vty
, mode
, "\n");
12093 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12098 const char *mode
= "Invalid";
12101 vty_out(vty
, " Local GR Mode: ");
12103 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12105 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12107 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12109 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12110 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12112 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12114 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12121 json_object_string_add(json
, "localGrMode", mode
);
12123 vty_out(vty
, mode
, "\n");
12127 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12128 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
12132 json_object
*json_afi_safi
= NULL
;
12133 json_object
*json_timer
= NULL
;
12134 json_object
*json_endofrib_status
= NULL
;
12135 bool eor_flag
= false;
12137 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12138 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
12139 if (!peer
->afc
[afi
][safi
])
12142 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12143 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12147 json_afi_safi
= json_object_new_object();
12148 json_endofrib_status
= json_object_new_object();
12149 json_timer
= json_object_new_object();
12152 if (peer
->eor_stime
[afi
][safi
]
12153 >= peer
->pkt_stime
[afi
][safi
])
12159 vty_out(vty
, " %s:\n",
12160 get_afi_safi_str(afi
, safi
, false));
12162 vty_out(vty
, " F bit: ");
12165 if (peer
->nsf
[afi
][safi
]
12166 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12167 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12170 json_object_boolean_true_add(
12171 json_afi_safi
, "fBit");
12173 vty_out(vty
, "True\n");
12176 json_object_boolean_false_add(
12177 json_afi_safi
, "fBit");
12179 vty_out(vty
, "False\n");
12183 vty_out(vty
, " End-of-RIB sent: ");
12185 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12186 PEER_STATUS_EOR_SEND
)) {
12188 json_object_boolean_true_add(
12189 json_endofrib_status
,
12192 PRINT_EOR_JSON(eor_flag
);
12194 vty_out(vty
, "Yes\n");
12196 " End-of-RIB sent after update: ");
12198 PRINT_EOR(eor_flag
);
12202 json_object_boolean_false_add(
12203 json_endofrib_status
,
12205 json_object_boolean_false_add(
12206 json_endofrib_status
,
12207 "endOfRibSentAfterUpdate");
12209 vty_out(vty
, "No\n");
12211 " End-of-RIB sent after update: ");
12212 vty_out(vty
, "No\n");
12217 vty_out(vty
, " End-of-RIB received: ");
12219 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12220 PEER_STATUS_EOR_RECEIVED
)) {
12222 json_object_boolean_true_add(
12223 json_endofrib_status
,
12226 vty_out(vty
, "Yes\n");
12229 json_object_boolean_false_add(
12230 json_endofrib_status
,
12233 vty_out(vty
, "No\n");
12237 json_object_int_add(json_timer
,
12239 peer
->bgp
->stalepath_time
);
12241 if (peer
->t_gr_stale
!= NULL
) {
12242 json_object_int_add(
12244 "stalePathTimerRemaining",
12245 thread_timer_remain_second(
12246 peer
->t_gr_stale
));
12249 /* Display Configured Selection
12250 * Deferral only when when
12251 * Gr mode is enabled.
12253 if (CHECK_FLAG(peer
->flags
,
12254 PEER_FLAG_GRACEFUL_RESTART
)) {
12255 json_object_int_add(
12257 "selectionDeferralTimer",
12258 peer
->bgp
->stalepath_time
);
12261 if (peer
->bgp
->gr_info
[afi
][safi
]
12265 json_object_int_add(
12267 "selectionDeferralTimerRemaining",
12268 thread_timer_remain_second(
12272 .t_select_deferral
));
12275 vty_out(vty
, " Timers:\n");
12277 " Configured Stale Path Time(sec): %u\n",
12278 peer
->bgp
->stalepath_time
);
12280 if (peer
->t_gr_stale
!= NULL
)
12282 " Stale Path Remaining(sec): %ld\n",
12283 thread_timer_remain_second(
12284 peer
->t_gr_stale
));
12285 /* Display Configured Selection
12286 * Deferral only when when
12287 * Gr mode is enabled.
12289 if (CHECK_FLAG(peer
->flags
,
12290 PEER_FLAG_GRACEFUL_RESTART
))
12292 " Configured Selection Deferral Time(sec): %u\n",
12293 peer
->bgp
->select_defer_time
);
12295 if (peer
->bgp
->gr_info
[afi
][safi
]
12299 " Selection Deferral Time Remaining(sec): %ld\n",
12300 thread_timer_remain_second(
12304 .t_select_deferral
));
12307 json_object_object_add(json_afi_safi
,
12309 json_endofrib_status
);
12310 json_object_object_add(json_afi_safi
, "timers",
12312 json_object_object_add(
12313 json
, get_afi_safi_str(afi
, safi
, true),
12320 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12326 json_object
*json_timer
= NULL
;
12328 json_timer
= json_object_new_object();
12330 json_object_int_add(json_timer
, "configuredRestartTimer",
12331 p
->bgp
->restart_time
);
12333 json_object_int_add(json_timer
, "receivedRestartTimer",
12336 if (p
->t_gr_restart
!= NULL
)
12337 json_object_int_add(
12338 json_timer
, "restartTimerRemaining",
12339 thread_timer_remain_second(p
->t_gr_restart
));
12341 json_object_object_add(json
, "timers", json_timer
);
12344 vty_out(vty
, " Timers:\n");
12345 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12346 p
->bgp
->restart_time
);
12348 vty_out(vty
, " Received Restart Time(sec): %u\n",
12350 if (p
->t_gr_restart
!= NULL
)
12351 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12352 thread_timer_remain_second(p
->t_gr_restart
));
12353 if (p
->t_gr_restart
!= NULL
) {
12354 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12355 thread_timer_remain_second(p
->t_gr_restart
));
12360 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12361 bool use_json
, json_object
*json
)
12363 char buf
[SU_ADDRSTRLEN
] = {0};
12364 char dn_flag
[2] = {0};
12365 /* '*' + v6 address of neighbor */
12366 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12368 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12373 json_object_string_add(
12374 json
, "neighborAddr",
12375 BGP_PEER_SU_UNSPEC(p
)
12377 : sockunion2str(&p
->su
, buf
,
12380 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
12381 BGP_PEER_SU_UNSPEC(p
)
12383 : sockunion2str(&p
->su
, buf
,
12386 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12390 json_object_string_add(json
, "neighborAddr",
12393 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12396 /* more gr info in new format */
12397 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12400 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12401 safi_t safi
, bool use_json
,
12402 json_object
*json_neigh
)
12404 struct bgp_filter
*filter
;
12405 struct peer_af
*paf
;
12406 char orf_pfx_name
[BUFSIZ
];
12408 json_object
*json_af
= NULL
;
12409 json_object
*json_prefA
= NULL
;
12410 json_object
*json_prefB
= NULL
;
12411 json_object
*json_addr
= NULL
;
12412 json_object
*json_advmap
= NULL
;
12415 json_addr
= json_object_new_object();
12416 json_af
= json_object_new_object();
12417 filter
= &p
->filter
[afi
][safi
];
12419 if (peer_group_active(p
))
12420 json_object_string_add(json_addr
, "peerGroupMember",
12423 paf
= peer_af_find(p
, afi
, safi
);
12424 if (paf
&& PAF_SUBGRP(paf
)) {
12425 json_object_int_add(json_addr
, "updateGroupId",
12426 PAF_UPDGRP(paf
)->id
);
12427 json_object_int_add(json_addr
, "subGroupId",
12428 PAF_SUBGRP(paf
)->id
);
12429 json_object_int_add(json_addr
, "packetQueueLength",
12430 bpacket_queue_virtual_length(paf
));
12433 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12434 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12435 PEER_CAP_ORF_PREFIX_SM_RCV
)
12436 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12437 PEER_CAP_ORF_PREFIX_RM_ADV
)
12438 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12439 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12440 json_object_int_add(json_af
, "orfType",
12442 json_prefA
= json_object_new_object();
12443 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12444 PEER_CAP_ORF_PREFIX_SM_ADV
,
12445 PEER_CAP_ORF_PREFIX_RM_ADV
,
12446 PEER_CAP_ORF_PREFIX_SM_RCV
,
12447 PEER_CAP_ORF_PREFIX_RM_RCV
,
12448 use_json
, json_prefA
);
12449 json_object_object_add(json_af
, "orfPrefixList",
12453 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12454 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12455 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12456 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12457 PEER_CAP_ORF_PREFIX_RM_ADV
)
12458 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12459 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12460 json_object_int_add(json_af
, "orfOldType",
12461 ORF_TYPE_PREFIX_OLD
);
12462 json_prefB
= json_object_new_object();
12463 bgp_show_peer_afi_orf_cap(
12464 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12465 PEER_CAP_ORF_PREFIX_RM_ADV
,
12466 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12467 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12469 json_object_object_add(json_af
, "orfOldPrefixList",
12473 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12474 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12475 PEER_CAP_ORF_PREFIX_SM_RCV
)
12476 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12477 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12478 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12479 PEER_CAP_ORF_PREFIX_RM_ADV
)
12480 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12481 PEER_CAP_ORF_PREFIX_RM_RCV
)
12482 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12483 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12484 json_object_object_add(json_addr
, "afDependentCap",
12487 json_object_free(json_af
);
12489 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12490 p
->host
, afi
, safi
);
12491 orf_pfx_count
= prefix_bgp_show_prefix_list(
12492 NULL
, afi
, orf_pfx_name
, use_json
);
12494 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12495 PEER_STATUS_ORF_PREFIX_SEND
)
12496 || orf_pfx_count
) {
12497 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12498 PEER_STATUS_ORF_PREFIX_SEND
))
12499 json_object_boolean_true_add(json_neigh
,
12502 json_object_int_add(json_addr
, "orfRecvCounter",
12505 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12506 PEER_STATUS_ORF_WAIT_REFRESH
))
12507 json_object_string_add(
12508 json_addr
, "orfFirstUpdate",
12509 "deferredUntilORFOrRouteRefreshRecvd");
12511 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12512 PEER_FLAG_REFLECTOR_CLIENT
))
12513 json_object_boolean_true_add(json_addr
,
12514 "routeReflectorClient");
12515 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12516 PEER_FLAG_RSERVER_CLIENT
))
12517 json_object_boolean_true_add(json_addr
,
12518 "routeServerClient");
12519 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12520 json_object_boolean_true_add(json_addr
,
12521 "inboundSoftConfigPermit");
12523 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12524 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12525 json_object_boolean_true_add(
12527 "privateAsNumsAllReplacedInUpdatesToNbr");
12528 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12529 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12530 json_object_boolean_true_add(
12532 "privateAsNumsReplacedInUpdatesToNbr");
12533 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12534 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12535 json_object_boolean_true_add(
12537 "privateAsNumsAllRemovedInUpdatesToNbr");
12538 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12539 PEER_FLAG_REMOVE_PRIVATE_AS
))
12540 json_object_boolean_true_add(
12542 "privateAsNumsRemovedInUpdatesToNbr");
12544 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12545 json_object_boolean_true_add(
12547 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12550 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12551 json_object_string_add(json_addr
,
12552 "overrideASNsInOutboundUpdates",
12553 "ifAspathEqualRemoteAs");
12555 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12556 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12557 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12558 json_object_boolean_true_add(json_addr
,
12559 "routerAlwaysNextHop");
12560 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12561 PEER_FLAG_AS_PATH_UNCHANGED
))
12562 json_object_boolean_true_add(
12563 json_addr
, "unchangedAsPathPropogatedToNbr");
12564 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12565 PEER_FLAG_NEXTHOP_UNCHANGED
))
12566 json_object_boolean_true_add(
12567 json_addr
, "unchangedNextHopPropogatedToNbr");
12568 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12569 json_object_boolean_true_add(
12570 json_addr
, "unchangedMedPropogatedToNbr");
12571 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12572 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12573 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12574 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12575 PEER_FLAG_SEND_COMMUNITY
)
12576 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12577 PEER_FLAG_SEND_EXT_COMMUNITY
))
12578 json_object_string_add(json_addr
,
12579 "commAttriSentToNbr",
12580 "extendedAndStandard");
12581 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12582 PEER_FLAG_SEND_EXT_COMMUNITY
))
12583 json_object_string_add(json_addr
,
12584 "commAttriSentToNbr",
12587 json_object_string_add(json_addr
,
12588 "commAttriSentToNbr",
12591 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12592 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12593 if (p
->default_rmap
[afi
][safi
].name
)
12594 json_object_string_add(
12595 json_addr
, "defaultRouteMap",
12596 p
->default_rmap
[afi
][safi
].name
);
12598 if (paf
&& PAF_SUBGRP(paf
)
12599 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12600 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12601 json_object_boolean_true_add(json_addr
,
12604 json_object_boolean_true_add(json_addr
,
12608 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12609 if (is_evpn_enabled())
12610 json_object_boolean_true_add(
12611 json_addr
, "advertiseAllVnis");
12614 if (filter
->plist
[FILTER_IN
].name
12615 || filter
->dlist
[FILTER_IN
].name
12616 || filter
->aslist
[FILTER_IN
].name
12617 || filter
->map
[RMAP_IN
].name
)
12618 json_object_boolean_true_add(json_addr
,
12619 "inboundPathPolicyConfig");
12620 if (filter
->plist
[FILTER_OUT
].name
12621 || filter
->dlist
[FILTER_OUT
].name
12622 || filter
->aslist
[FILTER_OUT
].name
12623 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12624 json_object_boolean_true_add(
12625 json_addr
, "outboundPathPolicyConfig");
12628 if (filter
->plist
[FILTER_IN
].name
)
12629 json_object_string_add(json_addr
,
12630 "incomingUpdatePrefixFilterList",
12631 filter
->plist
[FILTER_IN
].name
);
12632 if (filter
->plist
[FILTER_OUT
].name
)
12633 json_object_string_add(json_addr
,
12634 "outgoingUpdatePrefixFilterList",
12635 filter
->plist
[FILTER_OUT
].name
);
12637 /* distribute-list */
12638 if (filter
->dlist
[FILTER_IN
].name
)
12639 json_object_string_add(
12640 json_addr
, "incomingUpdateNetworkFilterList",
12641 filter
->dlist
[FILTER_IN
].name
);
12642 if (filter
->dlist
[FILTER_OUT
].name
)
12643 json_object_string_add(
12644 json_addr
, "outgoingUpdateNetworkFilterList",
12645 filter
->dlist
[FILTER_OUT
].name
);
12648 if (filter
->aslist
[FILTER_IN
].name
)
12649 json_object_string_add(json_addr
,
12650 "incomingUpdateAsPathFilterList",
12651 filter
->aslist
[FILTER_IN
].name
);
12652 if (filter
->aslist
[FILTER_OUT
].name
)
12653 json_object_string_add(json_addr
,
12654 "outgoingUpdateAsPathFilterList",
12655 filter
->aslist
[FILTER_OUT
].name
);
12658 if (filter
->map
[RMAP_IN
].name
)
12659 json_object_string_add(
12660 json_addr
, "routeMapForIncomingAdvertisements",
12661 filter
->map
[RMAP_IN
].name
);
12662 if (filter
->map
[RMAP_OUT
].name
)
12663 json_object_string_add(
12664 json_addr
, "routeMapForOutgoingAdvertisements",
12665 filter
->map
[RMAP_OUT
].name
);
12667 /* ebgp-requires-policy (inbound) */
12668 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12669 && !bgp_inbound_policy_exists(p
, filter
))
12670 json_object_string_add(
12671 json_addr
, "inboundEbgpRequiresPolicy",
12672 "Inbound updates discarded due to missing policy");
12674 /* ebgp-requires-policy (outbound) */
12675 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12676 && (!bgp_outbound_policy_exists(p
, filter
)))
12677 json_object_string_add(
12678 json_addr
, "outboundEbgpRequiresPolicy",
12679 "Outbound updates discarded due to missing policy");
12681 /* unsuppress-map */
12682 if (filter
->usmap
.name
)
12683 json_object_string_add(json_addr
,
12684 "selectiveUnsuppressRouteMap",
12685 filter
->usmap
.name
);
12687 /* advertise-map */
12688 if (filter
->advmap
.aname
) {
12689 json_advmap
= json_object_new_object();
12690 json_object_string_add(json_advmap
, "condition",
12691 filter
->advmap
.condition
12694 json_object_string_add(json_advmap
, "conditionMap",
12695 filter
->advmap
.cname
);
12696 json_object_string_add(json_advmap
, "advertiseMap",
12697 filter
->advmap
.aname
);
12698 json_object_string_add(json_advmap
, "advertiseStatus",
12699 filter
->advmap
.update_type
12703 json_object_object_add(json_addr
, "advertiseMap",
12707 /* Receive prefix count */
12708 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12709 p
->pcount
[afi
][safi
]);
12710 if (paf
&& PAF_SUBGRP(paf
))
12711 json_object_int_add(json_addr
, "sentPrefixCounter",
12712 (PAF_SUBGRP(paf
))->scount
);
12714 /* Maximum prefix */
12715 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12716 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12717 p
->pmax_out
[afi
][safi
]);
12719 /* Maximum prefix */
12720 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12721 json_object_int_add(json_addr
, "prefixAllowedMax",
12722 p
->pmax
[afi
][safi
]);
12723 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12724 PEER_FLAG_MAX_PREFIX_WARNING
))
12725 json_object_boolean_true_add(
12726 json_addr
, "prefixAllowedMaxWarning");
12727 json_object_int_add(json_addr
,
12728 "prefixAllowedWarningThresh",
12729 p
->pmax_threshold
[afi
][safi
]);
12730 if (p
->pmax_restart
[afi
][safi
])
12731 json_object_int_add(
12733 "prefixAllowedRestartIntervalMsecs",
12734 p
->pmax_restart
[afi
][safi
] * 60000);
12736 json_object_object_add(json_neigh
,
12737 get_afi_safi_str(afi
, safi
, true),
12741 filter
= &p
->filter
[afi
][safi
];
12743 vty_out(vty
, " For address family: %s\n",
12744 get_afi_safi_str(afi
, safi
, false));
12746 if (peer_group_active(p
))
12747 vty_out(vty
, " %s peer-group member\n",
12750 paf
= peer_af_find(p
, afi
, safi
);
12751 if (paf
&& PAF_SUBGRP(paf
)) {
12752 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12753 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12754 vty_out(vty
, " Packet Queue length %d\n",
12755 bpacket_queue_virtual_length(paf
));
12757 vty_out(vty
, " Not part of any update group\n");
12759 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12760 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12761 PEER_CAP_ORF_PREFIX_SM_RCV
)
12762 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12763 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12764 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12765 PEER_CAP_ORF_PREFIX_RM_ADV
)
12766 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12767 PEER_CAP_ORF_PREFIX_RM_RCV
)
12768 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12769 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12770 vty_out(vty
, " AF-dependant capabilities:\n");
12772 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12773 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12774 PEER_CAP_ORF_PREFIX_SM_RCV
)
12775 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12776 PEER_CAP_ORF_PREFIX_RM_ADV
)
12777 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12778 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12780 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12782 bgp_show_peer_afi_orf_cap(
12783 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12784 PEER_CAP_ORF_PREFIX_RM_ADV
,
12785 PEER_CAP_ORF_PREFIX_SM_RCV
,
12786 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12788 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12789 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12790 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12791 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12792 PEER_CAP_ORF_PREFIX_RM_ADV
)
12793 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12794 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12796 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12797 ORF_TYPE_PREFIX_OLD
);
12798 bgp_show_peer_afi_orf_cap(
12799 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12800 PEER_CAP_ORF_PREFIX_RM_ADV
,
12801 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12802 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12805 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12806 p
->host
, afi
, safi
);
12807 orf_pfx_count
= prefix_bgp_show_prefix_list(
12808 NULL
, afi
, orf_pfx_name
, use_json
);
12810 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12811 PEER_STATUS_ORF_PREFIX_SEND
)
12812 || orf_pfx_count
) {
12813 vty_out(vty
, " Outbound Route Filter (ORF):");
12814 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12815 PEER_STATUS_ORF_PREFIX_SEND
))
12816 vty_out(vty
, " sent;");
12818 vty_out(vty
, " received (%d entries)",
12820 vty_out(vty
, "\n");
12822 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12823 PEER_STATUS_ORF_WAIT_REFRESH
))
12825 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12827 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12828 PEER_FLAG_REFLECTOR_CLIENT
))
12829 vty_out(vty
, " Route-Reflector Client\n");
12830 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12831 PEER_FLAG_RSERVER_CLIENT
))
12832 vty_out(vty
, " Route-Server Client\n");
12833 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12835 " Inbound soft reconfiguration allowed\n");
12837 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12838 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12840 " Private AS numbers (all) replaced in updates to this neighbor\n");
12841 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12842 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12844 " Private AS numbers replaced in updates to this neighbor\n");
12845 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12846 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12848 " Private AS numbers (all) removed in updates to this neighbor\n");
12849 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12850 PEER_FLAG_REMOVE_PRIVATE_AS
))
12852 " Private AS numbers removed in updates to this neighbor\n");
12854 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12855 vty_out(vty
, " %s\n",
12856 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12857 ->human_description
);
12859 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12861 " Override ASNs in outbound updates if aspath equals remote-as\n");
12863 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12864 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12865 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12866 vty_out(vty
, " NEXT_HOP is always this router\n");
12867 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12868 PEER_FLAG_AS_PATH_UNCHANGED
))
12870 " AS_PATH is propagated unchanged to this neighbor\n");
12871 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12872 PEER_FLAG_NEXTHOP_UNCHANGED
))
12874 " NEXT_HOP is propagated unchanged to this neighbor\n");
12875 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12877 " MED is propagated unchanged to this neighbor\n");
12878 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12879 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12880 PEER_FLAG_SEND_EXT_COMMUNITY
)
12881 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12882 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12884 " Community attribute sent to this neighbor");
12885 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12886 PEER_FLAG_SEND_COMMUNITY
)
12887 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12888 PEER_FLAG_SEND_EXT_COMMUNITY
)
12889 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12890 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12891 vty_out(vty
, "(all)\n");
12892 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12893 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12894 vty_out(vty
, "(large)\n");
12895 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12896 PEER_FLAG_SEND_EXT_COMMUNITY
))
12897 vty_out(vty
, "(extended)\n");
12899 vty_out(vty
, "(standard)\n");
12901 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12902 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12903 vty_out(vty
, " Default information originate,");
12905 if (p
->default_rmap
[afi
][safi
].name
)
12906 vty_out(vty
, " default route-map %s%s,",
12907 p
->default_rmap
[afi
][safi
].map
? "*"
12909 p
->default_rmap
[afi
][safi
].name
);
12910 if (paf
&& PAF_SUBGRP(paf
)
12911 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12912 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12913 vty_out(vty
, " default sent\n");
12915 vty_out(vty
, " default not sent\n");
12918 /* advertise-vni-all */
12919 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12920 if (is_evpn_enabled())
12921 vty_out(vty
, " advertise-all-vni\n");
12924 if (filter
->plist
[FILTER_IN
].name
12925 || filter
->dlist
[FILTER_IN
].name
12926 || filter
->aslist
[FILTER_IN
].name
12927 || filter
->map
[RMAP_IN
].name
)
12928 vty_out(vty
, " Inbound path policy configured\n");
12929 if (filter
->plist
[FILTER_OUT
].name
12930 || filter
->dlist
[FILTER_OUT
].name
12931 || filter
->aslist
[FILTER_OUT
].name
12932 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12933 vty_out(vty
, " Outbound path policy configured\n");
12936 if (filter
->plist
[FILTER_IN
].name
)
12938 " Incoming update prefix filter list is %s%s\n",
12939 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12940 filter
->plist
[FILTER_IN
].name
);
12941 if (filter
->plist
[FILTER_OUT
].name
)
12943 " Outgoing update prefix filter list is %s%s\n",
12944 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12945 filter
->plist
[FILTER_OUT
].name
);
12947 /* distribute-list */
12948 if (filter
->dlist
[FILTER_IN
].name
)
12950 " Incoming update network filter list is %s%s\n",
12951 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12952 filter
->dlist
[FILTER_IN
].name
);
12953 if (filter
->dlist
[FILTER_OUT
].name
)
12955 " Outgoing update network filter list is %s%s\n",
12956 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12957 filter
->dlist
[FILTER_OUT
].name
);
12960 if (filter
->aslist
[FILTER_IN
].name
)
12962 " Incoming update AS path filter list is %s%s\n",
12963 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12964 filter
->aslist
[FILTER_IN
].name
);
12965 if (filter
->aslist
[FILTER_OUT
].name
)
12967 " Outgoing update AS path filter list is %s%s\n",
12968 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12969 filter
->aslist
[FILTER_OUT
].name
);
12972 if (filter
->map
[RMAP_IN
].name
)
12974 " Route map for incoming advertisements is %s%s\n",
12975 filter
->map
[RMAP_IN
].map
? "*" : "",
12976 filter
->map
[RMAP_IN
].name
);
12977 if (filter
->map
[RMAP_OUT
].name
)
12979 " Route map for outgoing advertisements is %s%s\n",
12980 filter
->map
[RMAP_OUT
].map
? "*" : "",
12981 filter
->map
[RMAP_OUT
].name
);
12983 /* ebgp-requires-policy (inbound) */
12984 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12985 && !bgp_inbound_policy_exists(p
, filter
))
12987 " Inbound updates discarded due to missing policy\n");
12989 /* ebgp-requires-policy (outbound) */
12990 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12991 && !bgp_outbound_policy_exists(p
, filter
))
12993 " Outbound updates discarded due to missing policy\n");
12995 /* unsuppress-map */
12996 if (filter
->usmap
.name
)
12998 " Route map for selective unsuppress is %s%s\n",
12999 filter
->usmap
.map
? "*" : "",
13000 filter
->usmap
.name
);
13002 /* advertise-map */
13003 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
13005 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
13006 filter
->advmap
.condition
? "EXIST"
13008 filter
->advmap
.cmap
? "*" : "",
13009 filter
->advmap
.cname
,
13010 filter
->advmap
.amap
? "*" : "",
13011 filter
->advmap
.aname
,
13012 filter
->advmap
.update_type
== ADVERTISE
13016 /* Receive prefix count */
13017 vty_out(vty
, " %u accepted prefixes\n",
13018 p
->pcount
[afi
][safi
]);
13020 /* maximum-prefix-out */
13021 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
13022 PEER_FLAG_MAX_PREFIX_OUT
))
13024 " Maximum allowed prefixes sent %u\n",
13025 p
->pmax_out
[afi
][safi
]);
13027 /* Maximum prefix */
13028 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13030 " Maximum prefixes allowed %u%s\n",
13031 p
->pmax
[afi
][safi
],
13032 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13033 PEER_FLAG_MAX_PREFIX_WARNING
)
13034 ? " (warning-only)"
13036 vty_out(vty
, " Threshold for warning message %d%%",
13037 p
->pmax_threshold
[afi
][safi
]);
13038 if (p
->pmax_restart
[afi
][safi
])
13039 vty_out(vty
, ", restart interval %d min",
13040 p
->pmax_restart
[afi
][safi
]);
13041 vty_out(vty
, "\n");
13044 vty_out(vty
, "\n");
13048 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13052 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
13053 char timebuf
[BGP_UPTIME_LEN
];
13059 json_object
*json_neigh
= NULL
;
13061 uint32_t sync_tcp_mss
;
13066 json_neigh
= json_object_new_object();
13068 memset(dn_flag
, '\0', sizeof(dn_flag
));
13069 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13073 if (p
->conf_if
) /* Configured interface name. */
13074 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
13075 BGP_PEER_SU_UNSPEC(p
)
13077 : sockunion2str(&p
->su
, buf
,
13079 else /* Configured IP address. */
13080 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13085 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13086 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13088 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13089 json_object_string_add(
13090 json_neigh
, "bgpNeighborAddr",
13091 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
13093 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13095 if (p
->change_local_as
)
13096 json_object_int_add(json_neigh
, "localAs",
13097 p
->change_local_as
);
13099 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13101 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13102 json_object_boolean_true_add(json_neigh
,
13103 "localAsNoPrepend");
13105 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13106 json_object_boolean_true_add(json_neigh
,
13107 "localAsReplaceAs");
13109 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13110 || (p
->as_type
== AS_INTERNAL
))
13111 vty_out(vty
, "remote AS %u, ", p
->as
);
13113 vty_out(vty
, "remote AS Unspecified, ");
13114 vty_out(vty
, "local AS %u%s%s, ",
13115 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13116 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13119 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13123 /* peer type internal or confed-internal */
13124 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13126 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13127 json_object_boolean_true_add(
13128 json_neigh
, "nbrConfedInternalLink");
13130 json_object_boolean_true_add(json_neigh
,
13131 "nbrInternalLink");
13133 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13134 vty_out(vty
, "confed-internal link\n");
13136 vty_out(vty
, "internal link\n");
13138 /* peer type external or confed-external */
13139 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13141 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13142 json_object_boolean_true_add(
13143 json_neigh
, "nbrConfedExternalLink");
13145 json_object_boolean_true_add(json_neigh
,
13146 "nbrExternalLink");
13148 if (bgp_confederation_peers_check(bgp
, p
->as
))
13149 vty_out(vty
, "confed-external link\n");
13151 vty_out(vty
, "external link\n");
13155 json_object_boolean_true_add(json_neigh
,
13156 "nbrUnspecifiedLink");
13158 vty_out(vty
, "unspecified link\n");
13164 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13166 vty_out(vty
, " Description: %s\n", p
->desc
);
13172 json_object_string_add(json_neigh
, "hostname",
13176 json_object_string_add(json_neigh
, "domainname",
13179 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13180 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13183 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13190 json_object_string_add(json_neigh
, "peerGroup",
13194 struct prefix prefix
, *range
= NULL
;
13196 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13197 range
= peer_group_lookup_dynamic_neighbor_range(
13198 p
->group
, &prefix
);
13201 prefix2str(range
, buf1
, sizeof(buf1
));
13202 json_object_string_add(
13204 "peerSubnetRangeGroup", buf1
);
13209 " Member of peer-group %s for session parameters\n",
13213 struct prefix prefix
, *range
= NULL
;
13215 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13216 range
= peer_group_lookup_dynamic_neighbor_range(
13217 p
->group
, &prefix
);
13221 " Belongs to the subnet range group: %pFX\n",
13229 /* Administrative shutdown. */
13230 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13231 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13232 json_object_boolean_true_add(json_neigh
,
13236 json_object_int_add(json_neigh
, "bgpVersion", 4);
13237 json_object_string_add(
13238 json_neigh
, "remoteRouterId",
13239 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13240 json_object_string_add(
13241 json_neigh
, "localRouterId",
13242 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13245 /* Confederation */
13246 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13247 && bgp_confederation_peers_check(bgp
, p
->as
))
13248 json_object_boolean_true_add(json_neigh
,
13252 json_object_string_add(
13253 json_neigh
, "bgpState",
13254 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13256 if (peer_established(p
)) {
13259 uptime
= bgp_clock();
13260 uptime
-= p
->uptime
;
13261 epoch_tbuf
= time(NULL
) - uptime
;
13263 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13265 json_object_string_add(json_neigh
, "bgpTimerUpString",
13266 peer_uptime(p
->uptime
, timebuf
,
13269 json_object_int_add(json_neigh
,
13270 "bgpTimerUpEstablishedEpoch",
13274 else if (p
->status
== Active
) {
13275 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13276 json_object_string_add(json_neigh
, "bgpStateIs",
13278 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13279 json_object_string_add(json_neigh
, "bgpStateIs",
13287 uptime
= bgp_clock();
13288 uptime
-= p
->readtime
;
13289 gmtime_r(&uptime
, &tm
);
13291 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13292 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13293 + (tm
.tm_hour
* 3600000));
13295 uptime
= bgp_clock();
13296 uptime
-= p
->last_write
;
13297 gmtime_r(&uptime
, &tm
);
13299 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13300 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13301 + (tm
.tm_hour
* 3600000));
13303 uptime
= bgp_clock();
13304 uptime
-= p
->update_time
;
13305 gmtime_r(&uptime
, &tm
);
13307 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13308 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13309 + (tm
.tm_hour
* 3600000));
13311 /* Configured timer values. */
13312 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13313 p
->v_holdtime
* 1000);
13314 json_object_int_add(json_neigh
,
13315 "bgpTimerKeepAliveIntervalMsecs",
13316 p
->v_keepalive
* 1000);
13317 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13318 json_object_int_add(json_neigh
,
13319 "bgpTimerDelayOpenTimeMsecs",
13320 p
->v_delayopen
* 1000);
13323 /* Configured and Synced tcp-mss value for peer */
13324 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13325 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13326 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13328 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13332 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
13333 json_object_int_add(json_neigh
,
13334 "bgpTimerConfiguredHoldTimeMsecs",
13335 p
->holdtime
* 1000);
13336 json_object_int_add(
13338 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13339 p
->keepalive
* 1000);
13340 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
13341 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
13342 json_object_int_add(json_neigh
,
13343 "bgpTimerConfiguredHoldTimeMsecs",
13344 bgp
->default_holdtime
);
13345 json_object_int_add(
13347 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13348 bgp
->default_keepalive
);
13351 /* Administrative shutdown. */
13352 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13353 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13354 vty_out(vty
, " Administratively shut down\n");
13357 vty_out(vty
, " BGP version 4");
13358 vty_out(vty
, ", remote router ID %s",
13359 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13360 vty_out(vty
, ", local router ID %s\n",
13361 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13364 /* Confederation */
13365 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13366 && bgp_confederation_peers_check(bgp
, p
->as
))
13368 " Neighbor under common administration\n");
13371 vty_out(vty
, " BGP state = %s",
13372 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13374 if (peer_established(p
))
13375 vty_out(vty
, ", up for %8s",
13376 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13379 else if (p
->status
== Active
) {
13380 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13381 vty_out(vty
, " (passive)");
13382 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13383 vty_out(vty
, " (NSF passive)");
13385 vty_out(vty
, "\n");
13388 vty_out(vty
, " Last read %s",
13389 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13391 vty_out(vty
, ", Last write %s\n",
13392 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13395 /* Configured timer values. */
13397 " Hold time is %d, keepalive interval is %d seconds\n",
13398 p
->v_holdtime
, p
->v_keepalive
);
13399 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
13400 vty_out(vty
, " Configured hold time is %d",
13402 vty_out(vty
, ", keepalive interval is %d seconds\n",
13404 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
13405 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
13406 vty_out(vty
, " Configured hold time is %d",
13407 bgp
->default_holdtime
);
13408 vty_out(vty
, ", keepalive interval is %d seconds\n",
13409 bgp
->default_keepalive
);
13411 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13413 " Configured DelayOpenTime is %d seconds\n",
13416 /* Configured and synced tcp-mss value for peer */
13417 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13418 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13419 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13420 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13424 if (peer_established(p
)) {
13425 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
13426 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
13427 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
13428 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
13429 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
13430 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
13431 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
13432 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
13433 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
13434 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
13435 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
13436 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
13437 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
13438 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
13439 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
13440 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
13441 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
13442 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
13443 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
13444 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
13446 json_object
*json_cap
= NULL
;
13448 json_cap
= json_object_new_object();
13451 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13452 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13453 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
13454 && CHECK_FLAG(p
->cap
,
13456 json_object_string_add(
13457 json_cap
, "4byteAs",
13458 "advertisedAndReceived");
13459 else if (CHECK_FLAG(p
->cap
,
13461 json_object_string_add(
13462 json_cap
, "4byteAs",
13464 else if (CHECK_FLAG(p
->cap
,
13466 json_object_string_add(
13467 json_cap
, "4byteAs",
13471 /* Extended Message Support */
13472 if (CHECK_FLAG(p
->cap
,
13473 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13476 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13477 json_object_string_add(
13478 json_cap
, "extendedMessage",
13479 "advertisedAndReceived");
13480 else if (CHECK_FLAG(
13482 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13483 json_object_string_add(
13484 json_cap
, "extendedMessage",
13486 else if (CHECK_FLAG(
13488 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13489 json_object_string_add(
13490 json_cap
, "extendedMessage",
13494 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13495 || CHECK_FLAG(p
->cap
,
13496 PEER_CAP_ADDPATH_ADV
)) {
13497 json_object
*json_add
= NULL
;
13498 const char *print_store
;
13500 json_add
= json_object_new_object();
13502 FOREACH_AFI_SAFI (afi
, safi
) {
13503 json_object
*json_sub
= NULL
;
13505 json_object_new_object();
13506 print_store
= get_afi_safi_str(
13512 PEER_CAP_ADDPATH_AF_TX_ADV
)
13516 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13521 PEER_CAP_ADDPATH_AF_TX_ADV
)
13526 PEER_CAP_ADDPATH_AF_TX_RCV
))
13527 json_object_boolean_true_add(
13529 "txAdvertisedAndReceived");
13535 PEER_CAP_ADDPATH_AF_TX_ADV
))
13536 json_object_boolean_true_add(
13544 PEER_CAP_ADDPATH_AF_TX_RCV
))
13545 json_object_boolean_true_add(
13553 PEER_CAP_ADDPATH_AF_RX_ADV
)
13557 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13562 PEER_CAP_ADDPATH_AF_RX_ADV
)
13567 PEER_CAP_ADDPATH_AF_RX_RCV
))
13568 json_object_boolean_true_add(
13570 "rxAdvertisedAndReceived");
13576 PEER_CAP_ADDPATH_AF_RX_ADV
))
13577 json_object_boolean_true_add(
13585 PEER_CAP_ADDPATH_AF_RX_RCV
))
13586 json_object_boolean_true_add(
13594 PEER_CAP_ADDPATH_AF_TX_ADV
)
13598 PEER_CAP_ADDPATH_AF_TX_RCV
)
13602 PEER_CAP_ADDPATH_AF_RX_ADV
)
13606 PEER_CAP_ADDPATH_AF_RX_RCV
))
13607 json_object_object_add(
13616 json_object_object_add(
13617 json_cap
, "addPath", json_add
);
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13622 || CHECK_FLAG(p
->cap
,
13623 PEER_CAP_DYNAMIC_ADV
)) {
13624 if (CHECK_FLAG(p
->cap
,
13625 PEER_CAP_DYNAMIC_ADV
)
13626 && CHECK_FLAG(p
->cap
,
13627 PEER_CAP_DYNAMIC_RCV
))
13628 json_object_string_add(
13629 json_cap
, "dynamic",
13630 "advertisedAndReceived");
13631 else if (CHECK_FLAG(
13633 PEER_CAP_DYNAMIC_ADV
))
13634 json_object_string_add(
13635 json_cap
, "dynamic",
13637 else if (CHECK_FLAG(
13639 PEER_CAP_DYNAMIC_RCV
))
13640 json_object_string_add(
13641 json_cap
, "dynamic",
13645 /* Extended nexthop */
13646 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13647 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13648 json_object
*json_nxt
= NULL
;
13649 const char *print_store
;
13652 if (CHECK_FLAG(p
->cap
,
13654 && CHECK_FLAG(p
->cap
,
13655 PEER_CAP_ENHE_RCV
))
13656 json_object_string_add(
13659 "advertisedAndReceived");
13660 else if (CHECK_FLAG(p
->cap
,
13661 PEER_CAP_ENHE_ADV
))
13662 json_object_string_add(
13666 else if (CHECK_FLAG(p
->cap
,
13667 PEER_CAP_ENHE_RCV
))
13668 json_object_string_add(
13673 if (CHECK_FLAG(p
->cap
,
13674 PEER_CAP_ENHE_RCV
)) {
13676 json_object_new_object();
13678 for (safi
= SAFI_UNICAST
;
13679 safi
< SAFI_MAX
; safi
++) {
13684 PEER_CAP_ENHE_AF_RCV
)) {
13685 print_store
= get_afi_safi_str(
13688 json_object_string_add(
13691 "recieved"); /* misspelled for compatibility */
13694 json_object_object_add(
13696 "extendedNexthopFamililesByPeer",
13701 /* Route Refresh */
13702 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13703 || CHECK_FLAG(p
->cap
,
13704 PEER_CAP_REFRESH_NEW_RCV
)
13705 || CHECK_FLAG(p
->cap
,
13706 PEER_CAP_REFRESH_OLD_RCV
)) {
13707 if (CHECK_FLAG(p
->cap
,
13708 PEER_CAP_REFRESH_ADV
)
13711 PEER_CAP_REFRESH_NEW_RCV
)
13714 PEER_CAP_REFRESH_OLD_RCV
))) {
13717 PEER_CAP_REFRESH_OLD_RCV
)
13720 PEER_CAP_REFRESH_NEW_RCV
))
13721 json_object_string_add(
13724 "advertisedAndReceivedOldNew");
13728 PEER_CAP_REFRESH_OLD_RCV
))
13729 json_object_string_add(
13732 "advertisedAndReceivedOld");
13734 json_object_string_add(
13737 "advertisedAndReceivedNew");
13742 PEER_CAP_REFRESH_ADV
))
13743 json_object_string_add(
13750 PEER_CAP_REFRESH_NEW_RCV
)
13753 PEER_CAP_REFRESH_OLD_RCV
))
13754 json_object_string_add(
13760 /* Enhanced Route Refresh */
13761 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13762 || CHECK_FLAG(p
->cap
,
13763 PEER_CAP_ENHANCED_RR_RCV
)) {
13764 if (CHECK_FLAG(p
->cap
,
13765 PEER_CAP_ENHANCED_RR_ADV
)
13768 PEER_CAP_ENHANCED_RR_RCV
))
13769 json_object_string_add(
13771 "enhancedRouteRefresh",
13772 "advertisedAndReceived");
13776 PEER_CAP_ENHANCED_RR_ADV
))
13777 json_object_string_add(
13779 "enhancedRouteRefresh",
13784 PEER_CAP_ENHANCED_RR_RCV
))
13785 json_object_string_add(
13787 "enhancedRouteRefresh",
13791 /* Multiprotocol Extensions */
13792 json_object
*json_multi
= NULL
;
13793 json_multi
= json_object_new_object();
13795 FOREACH_AFI_SAFI (afi
, safi
) {
13796 if (p
->afc_adv
[afi
][safi
]
13797 || p
->afc_recv
[afi
][safi
]) {
13798 json_object
*json_exten
= NULL
;
13800 json_object_new_object();
13802 if (p
->afc_adv
[afi
][safi
]
13803 && p
->afc_recv
[afi
][safi
])
13804 json_object_boolean_true_add(
13806 "advertisedAndReceived");
13807 else if (p
->afc_adv
[afi
][safi
])
13808 json_object_boolean_true_add(
13811 else if (p
->afc_recv
[afi
][safi
])
13812 json_object_boolean_true_add(
13816 json_object_object_add(
13818 get_afi_safi_str(afi
,
13824 json_object_object_add(
13825 json_cap
, "multiprotocolExtensions",
13828 /* Hostname capabilities */
13829 json_object
*json_hname
= NULL
;
13831 json_hname
= json_object_new_object();
13833 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13834 json_object_string_add(
13835 json_hname
, "advHostName",
13836 bgp
->peer_self
->hostname
13840 json_object_string_add(
13841 json_hname
, "advDomainName",
13842 bgp
->peer_self
->domainname
13849 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13850 json_object_string_add(
13851 json_hname
, "rcvHostName",
13852 p
->hostname
? p
->hostname
13854 json_object_string_add(
13855 json_hname
, "rcvDomainName",
13856 p
->domainname
? p
->domainname
13860 json_object_object_add(json_cap
, "hostName",
13863 /* Gracefull Restart */
13864 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13865 || CHECK_FLAG(p
->cap
,
13866 PEER_CAP_RESTART_ADV
)) {
13867 if (CHECK_FLAG(p
->cap
,
13868 PEER_CAP_RESTART_ADV
)
13869 && CHECK_FLAG(p
->cap
,
13870 PEER_CAP_RESTART_RCV
))
13871 json_object_string_add(
13874 "advertisedAndReceived");
13875 else if (CHECK_FLAG(
13877 PEER_CAP_RESTART_ADV
))
13878 json_object_string_add(
13880 "gracefulRestartCapability",
13882 else if (CHECK_FLAG(
13884 PEER_CAP_RESTART_RCV
))
13885 json_object_string_add(
13887 "gracefulRestartCapability",
13890 if (CHECK_FLAG(p
->cap
,
13891 PEER_CAP_RESTART_RCV
)) {
13892 int restart_af_count
= 0;
13893 json_object
*json_restart
=
13896 json_object_new_object();
13898 json_object_int_add(
13900 "gracefulRestartRemoteTimerMsecs",
13901 p
->v_gr_restart
* 1000);
13903 FOREACH_AFI_SAFI (afi
, safi
) {
13908 PEER_CAP_RESTART_AF_RCV
)) {
13913 json_object_new_object();
13919 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13920 json_object_boolean_true_add(
13923 restart_af_count
++;
13924 json_object_object_add(
13933 if (!restart_af_count
) {
13934 json_object_string_add(
13936 "addressFamiliesByPeer",
13941 json_object_object_add(
13943 "addressFamiliesByPeer",
13947 json_object_object_add(json_neigh
,
13948 "neighborCapabilities",
13951 vty_out(vty
, " Neighbor capabilities:\n");
13954 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13955 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13956 vty_out(vty
, " 4 Byte AS:");
13957 if (CHECK_FLAG(p
->cap
,
13959 vty_out(vty
, " advertised");
13960 if (CHECK_FLAG(p
->cap
,
13962 vty_out(vty
, " %sreceived",
13968 vty_out(vty
, "\n");
13971 /* Extended Message Support */
13972 if (CHECK_FLAG(p
->cap
,
13973 PEER_CAP_EXTENDED_MESSAGE_RCV
)
13976 PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13977 vty_out(vty
, " Extended Message:");
13980 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13981 vty_out(vty
, " advertised");
13984 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13985 vty_out(vty
, " %sreceived",
13988 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13991 vty_out(vty
, "\n");
13995 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13996 || CHECK_FLAG(p
->cap
,
13997 PEER_CAP_ADDPATH_ADV
)) {
13998 vty_out(vty
, " AddPath:\n");
14000 FOREACH_AFI_SAFI (afi
, safi
) {
14004 PEER_CAP_ADDPATH_AF_TX_ADV
)
14008 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
14020 PEER_CAP_ADDPATH_AF_TX_ADV
))
14032 PEER_CAP_ADDPATH_AF_TX_RCV
))
14039 PEER_CAP_ADDPATH_AF_TX_ADV
)
14043 vty_out(vty
, "\n");
14049 PEER_CAP_ADDPATH_AF_RX_ADV
)
14053 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14065 PEER_CAP_ADDPATH_AF_RX_ADV
))
14077 PEER_CAP_ADDPATH_AF_RX_RCV
))
14084 PEER_CAP_ADDPATH_AF_RX_ADV
)
14088 vty_out(vty
, "\n");
14094 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
14095 || CHECK_FLAG(p
->cap
,
14096 PEER_CAP_DYNAMIC_ADV
)) {
14097 vty_out(vty
, " Dynamic:");
14098 if (CHECK_FLAG(p
->cap
,
14099 PEER_CAP_DYNAMIC_ADV
))
14100 vty_out(vty
, " advertised");
14101 if (CHECK_FLAG(p
->cap
,
14102 PEER_CAP_DYNAMIC_RCV
))
14103 vty_out(vty
, " %sreceived",
14106 PEER_CAP_DYNAMIC_ADV
)
14109 vty_out(vty
, "\n");
14112 /* Extended nexthop */
14113 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
14114 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14115 vty_out(vty
, " Extended nexthop:");
14116 if (CHECK_FLAG(p
->cap
,
14117 PEER_CAP_ENHE_ADV
))
14118 vty_out(vty
, " advertised");
14119 if (CHECK_FLAG(p
->cap
,
14120 PEER_CAP_ENHE_RCV
))
14121 vty_out(vty
, " %sreceived",
14127 vty_out(vty
, "\n");
14129 if (CHECK_FLAG(p
->cap
,
14130 PEER_CAP_ENHE_RCV
)) {
14132 " Address families by peer:\n ");
14133 for (safi
= SAFI_UNICAST
;
14134 safi
< SAFI_MAX
; safi
++)
14139 PEER_CAP_ENHE_AF_RCV
))
14149 /* Route Refresh */
14150 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
14151 || CHECK_FLAG(p
->cap
,
14152 PEER_CAP_REFRESH_NEW_RCV
)
14153 || CHECK_FLAG(p
->cap
,
14154 PEER_CAP_REFRESH_OLD_RCV
)) {
14155 vty_out(vty
, " Route refresh:");
14156 if (CHECK_FLAG(p
->cap
,
14157 PEER_CAP_REFRESH_ADV
))
14158 vty_out(vty
, " advertised");
14159 if (CHECK_FLAG(p
->cap
,
14160 PEER_CAP_REFRESH_NEW_RCV
)
14163 PEER_CAP_REFRESH_OLD_RCV
))
14164 vty_out(vty
, " %sreceived(%s)",
14167 PEER_CAP_REFRESH_ADV
)
14172 PEER_CAP_REFRESH_OLD_RCV
)
14175 PEER_CAP_REFRESH_NEW_RCV
))
14179 PEER_CAP_REFRESH_OLD_RCV
)
14183 vty_out(vty
, "\n");
14186 /* Enhanced Route Refresh */
14187 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
14188 || CHECK_FLAG(p
->cap
,
14189 PEER_CAP_ENHANCED_RR_RCV
)) {
14191 " Enhanced Route Refresh:");
14194 PEER_CAP_ENHANCED_RR_ADV
))
14195 vty_out(vty
, " advertised");
14198 PEER_CAP_ENHANCED_RR_RCV
))
14199 vty_out(vty
, " %sreceived",
14202 PEER_CAP_REFRESH_ADV
)
14205 vty_out(vty
, "\n");
14208 /* Multiprotocol Extensions */
14209 FOREACH_AFI_SAFI (afi
, safi
)
14210 if (p
->afc_adv
[afi
][safi
]
14211 || p
->afc_recv
[afi
][safi
]) {
14213 " Address Family %s:",
14218 if (p
->afc_adv
[afi
][safi
])
14221 if (p
->afc_recv
[afi
][safi
])
14228 vty_out(vty
, "\n");
14231 /* Hostname capability */
14232 vty_out(vty
, " Hostname Capability:");
14234 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14236 " advertised (name: %s,domain name: %s)",
14237 bgp
->peer_self
->hostname
14241 bgp
->peer_self
->domainname
14246 vty_out(vty
, " not advertised");
14249 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14251 " received (name: %s,domain name: %s)",
14252 p
->hostname
? p
->hostname
14254 p
->domainname
? p
->domainname
14257 vty_out(vty
, " not received");
14260 vty_out(vty
, "\n");
14262 /* Graceful Restart */
14263 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
14264 || CHECK_FLAG(p
->cap
,
14265 PEER_CAP_RESTART_ADV
)) {
14267 " Graceful Restart Capability:");
14268 if (CHECK_FLAG(p
->cap
,
14269 PEER_CAP_RESTART_ADV
))
14270 vty_out(vty
, " advertised");
14271 if (CHECK_FLAG(p
->cap
,
14272 PEER_CAP_RESTART_RCV
))
14273 vty_out(vty
, " %sreceived",
14276 PEER_CAP_RESTART_ADV
)
14279 vty_out(vty
, "\n");
14281 if (CHECK_FLAG(p
->cap
,
14282 PEER_CAP_RESTART_RCV
)) {
14283 int restart_af_count
= 0;
14286 " Remote Restart timer is %d seconds\n",
14289 " Address families by peer:\n ");
14291 FOREACH_AFI_SAFI (afi
, safi
)
14296 PEER_CAP_RESTART_AF_RCV
)) {
14310 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14312 : "not preserved");
14313 restart_af_count
++;
14315 if (!restart_af_count
)
14316 vty_out(vty
, "none");
14317 vty_out(vty
, "\n");
14319 } /* Gracefull Restart */
14324 /* graceful restart information */
14325 json_object
*json_grace
= NULL
;
14326 json_object
*json_grace_send
= NULL
;
14327 json_object
*json_grace_recv
= NULL
;
14328 int eor_send_af_count
= 0;
14329 int eor_receive_af_count
= 0;
14332 json_grace
= json_object_new_object();
14333 json_grace_send
= json_object_new_object();
14334 json_grace_recv
= json_object_new_object();
14336 if ((peer_established(p
))
14337 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14338 FOREACH_AFI_SAFI (afi
, safi
) {
14339 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14340 PEER_STATUS_EOR_SEND
)) {
14341 json_object_boolean_true_add(
14343 get_afi_safi_str(afi
,
14346 eor_send_af_count
++;
14349 FOREACH_AFI_SAFI (afi
, safi
) {
14351 p
->af_sflags
[afi
][safi
],
14352 PEER_STATUS_EOR_RECEIVED
)) {
14353 json_object_boolean_true_add(
14355 get_afi_safi_str(afi
,
14358 eor_receive_af_count
++;
14362 json_object_object_add(json_grace
, "endOfRibSend",
14364 json_object_object_add(json_grace
, "endOfRibRecv",
14368 if (p
->t_gr_restart
)
14369 json_object_int_add(json_grace
,
14370 "gracefulRestartTimerMsecs",
14371 thread_timer_remain_second(
14376 json_object_int_add(
14378 "gracefulStalepathTimerMsecs",
14379 thread_timer_remain_second(
14382 /* more gr info in new format */
14383 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
14385 json_object_object_add(
14386 json_neigh
, "gracefulRestartInfo", json_grace
);
14388 vty_out(vty
, " Graceful restart information:\n");
14389 if ((peer_established(p
))
14390 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14392 vty_out(vty
, " End-of-RIB send: ");
14393 FOREACH_AFI_SAFI (afi
, safi
) {
14394 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14395 PEER_STATUS_EOR_SEND
)) {
14396 vty_out(vty
, "%s%s",
14397 eor_send_af_count
? ", "
14402 eor_send_af_count
++;
14405 vty_out(vty
, "\n");
14406 vty_out(vty
, " End-of-RIB received: ");
14407 FOREACH_AFI_SAFI (afi
, safi
) {
14409 p
->af_sflags
[afi
][safi
],
14410 PEER_STATUS_EOR_RECEIVED
)) {
14411 vty_out(vty
, "%s%s",
14412 eor_receive_af_count
14415 get_afi_safi_str(afi
,
14418 eor_receive_af_count
++;
14421 vty_out(vty
, "\n");
14424 if (p
->t_gr_restart
)
14426 " The remaining time of restart timer is %ld\n",
14427 thread_timer_remain_second(
14432 " The remaining time of stalepath timer is %ld\n",
14433 thread_timer_remain_second(
14436 /* more gr info in new format */
14437 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14441 json_object
*json_stat
= NULL
;
14442 json_stat
= json_object_new_object();
14443 /* Packet counts. */
14445 atomic_size_t outq_count
, inq_count
;
14446 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14447 memory_order_relaxed
);
14448 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14449 memory_order_relaxed
);
14451 json_object_int_add(json_stat
, "depthInq",
14452 (unsigned long)inq_count
);
14453 json_object_int_add(json_stat
, "depthOutq",
14454 (unsigned long)outq_count
);
14455 json_object_int_add(json_stat
, "opensSent",
14456 atomic_load_explicit(&p
->open_out
,
14457 memory_order_relaxed
));
14458 json_object_int_add(json_stat
, "opensRecv",
14459 atomic_load_explicit(&p
->open_in
,
14460 memory_order_relaxed
));
14461 json_object_int_add(json_stat
, "notificationsSent",
14462 atomic_load_explicit(&p
->notify_out
,
14463 memory_order_relaxed
));
14464 json_object_int_add(json_stat
, "notificationsRecv",
14465 atomic_load_explicit(&p
->notify_in
,
14466 memory_order_relaxed
));
14467 json_object_int_add(json_stat
, "updatesSent",
14468 atomic_load_explicit(&p
->update_out
,
14469 memory_order_relaxed
));
14470 json_object_int_add(json_stat
, "updatesRecv",
14471 atomic_load_explicit(&p
->update_in
,
14472 memory_order_relaxed
));
14473 json_object_int_add(json_stat
, "keepalivesSent",
14474 atomic_load_explicit(&p
->keepalive_out
,
14475 memory_order_relaxed
));
14476 json_object_int_add(json_stat
, "keepalivesRecv",
14477 atomic_load_explicit(&p
->keepalive_in
,
14478 memory_order_relaxed
));
14479 json_object_int_add(json_stat
, "routeRefreshSent",
14480 atomic_load_explicit(&p
->refresh_out
,
14481 memory_order_relaxed
));
14482 json_object_int_add(json_stat
, "routeRefreshRecv",
14483 atomic_load_explicit(&p
->refresh_in
,
14484 memory_order_relaxed
));
14485 json_object_int_add(json_stat
, "capabilitySent",
14486 atomic_load_explicit(&p
->dynamic_cap_out
,
14487 memory_order_relaxed
));
14488 json_object_int_add(json_stat
, "capabilityRecv",
14489 atomic_load_explicit(&p
->dynamic_cap_in
,
14490 memory_order_relaxed
));
14491 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14492 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14493 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14495 atomic_size_t outq_count
, inq_count
;
14496 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14497 memory_order_relaxed
);
14498 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14499 memory_order_relaxed
);
14501 /* Packet counts. */
14502 vty_out(vty
, " Message statistics:\n");
14503 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14504 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14505 vty_out(vty
, " Sent Rcvd\n");
14506 vty_out(vty
, " Opens: %10d %10d\n",
14507 atomic_load_explicit(&p
->open_out
,
14508 memory_order_relaxed
),
14509 atomic_load_explicit(&p
->open_in
,
14510 memory_order_relaxed
));
14511 vty_out(vty
, " Notifications: %10d %10d\n",
14512 atomic_load_explicit(&p
->notify_out
,
14513 memory_order_relaxed
),
14514 atomic_load_explicit(&p
->notify_in
,
14515 memory_order_relaxed
));
14516 vty_out(vty
, " Updates: %10d %10d\n",
14517 atomic_load_explicit(&p
->update_out
,
14518 memory_order_relaxed
),
14519 atomic_load_explicit(&p
->update_in
,
14520 memory_order_relaxed
));
14521 vty_out(vty
, " Keepalives: %10d %10d\n",
14522 atomic_load_explicit(&p
->keepalive_out
,
14523 memory_order_relaxed
),
14524 atomic_load_explicit(&p
->keepalive_in
,
14525 memory_order_relaxed
));
14526 vty_out(vty
, " Route Refresh: %10d %10d\n",
14527 atomic_load_explicit(&p
->refresh_out
,
14528 memory_order_relaxed
),
14529 atomic_load_explicit(&p
->refresh_in
,
14530 memory_order_relaxed
));
14531 vty_out(vty
, " Capability: %10d %10d\n",
14532 atomic_load_explicit(&p
->dynamic_cap_out
,
14533 memory_order_relaxed
),
14534 atomic_load_explicit(&p
->dynamic_cap_in
,
14535 memory_order_relaxed
));
14536 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14541 /* advertisement-interval */
14542 json_object_int_add(json_neigh
,
14543 "minBtwnAdvertisementRunsTimerMsecs",
14544 p
->v_routeadv
* 1000);
14546 /* Update-source. */
14547 if (p
->update_if
|| p
->update_source
) {
14549 json_object_string_add(json_neigh
,
14552 else if (p
->update_source
)
14553 json_object_string_add(
14554 json_neigh
, "updateSource",
14555 sockunion2str(p
->update_source
, buf1
,
14559 /* advertisement-interval */
14561 " Minimum time between advertisement runs is %d seconds\n",
14564 /* Update-source. */
14565 if (p
->update_if
|| p
->update_source
) {
14566 vty_out(vty
, " Update source is ");
14568 vty_out(vty
, "%s", p
->update_if
);
14569 else if (p
->update_source
)
14571 sockunion2str(p
->update_source
, buf1
,
14573 vty_out(vty
, "\n");
14576 vty_out(vty
, "\n");
14579 /* Address Family Information */
14580 json_object
*json_hold
= NULL
;
14583 json_hold
= json_object_new_object();
14585 FOREACH_AFI_SAFI (afi
, safi
)
14586 if (p
->afc
[afi
][safi
])
14587 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14591 json_object_object_add(json_neigh
, "addressFamilyInfo",
14593 json_object_int_add(json_neigh
, "connectionsEstablished",
14595 json_object_int_add(json_neigh
, "connectionsDropped",
14598 vty_out(vty
, " Connections established %d; dropped %d\n",
14599 p
->established
, p
->dropped
);
14601 if (!p
->last_reset
) {
14603 json_object_string_add(json_neigh
, "lastReset",
14606 vty_out(vty
, " Last reset never\n");
14612 uptime
= bgp_clock();
14613 uptime
-= p
->resettime
;
14614 gmtime_r(&uptime
, &tm
);
14616 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14618 + (tm
.tm_min
* 60000)
14619 + (tm
.tm_hour
* 3600000));
14620 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14622 vty_out(vty
, " Last reset %s, ",
14623 peer_uptime(p
->resettime
, timebuf
,
14624 BGP_UPTIME_LEN
, 0, NULL
));
14626 bgp_show_peer_reset(vty
, p
, NULL
, false);
14627 if (p
->last_reset_cause_size
) {
14628 msg
= p
->last_reset_cause
;
14630 " Message received that caused BGP to send a NOTIFICATION:\n ");
14631 for (i
= 1; i
<= p
->last_reset_cause_size
;
14633 vty_out(vty
, "%02X", *msg
++);
14635 if (i
!= p
->last_reset_cause_size
) {
14637 vty_out(vty
, "\n ");
14638 } else if (i
% 4 == 0) {
14643 vty_out(vty
, "\n");
14648 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14650 json_object_boolean_true_add(json_neigh
,
14651 "prefixesConfigExceedMax");
14654 " Peer had exceeded the max. no. of prefixes configured.\n");
14656 if (p
->t_pmax_restart
) {
14658 json_object_boolean_true_add(
14659 json_neigh
, "reducePrefixNumFrom");
14660 json_object_int_add(json_neigh
,
14661 "restartInTimerMsec",
14662 thread_timer_remain_second(
14667 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14668 p
->host
, thread_timer_remain_second(
14669 p
->t_pmax_restart
));
14672 json_object_boolean_true_add(
14674 "reducePrefixNumAndClearIpBgp");
14677 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14682 /* EBGP Multihop and GTSM */
14683 if (p
->sort
!= BGP_PEER_IBGP
) {
14685 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14686 json_object_int_add(json_neigh
,
14687 "externalBgpNbrMaxHopsAway",
14689 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14690 json_object_int_add(json_neigh
,
14691 "externalBgpNbrMaxHopsAway",
14694 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14696 " External BGP neighbor may be up to %d hops away.\n",
14698 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14700 " External BGP neighbor may be up to %d hops away.\n",
14704 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14706 json_object_int_add(json_neigh
,
14707 "internalBgpNbrMaxHopsAway",
14711 " Internal BGP neighbor may be up to %d hops away.\n",
14716 /* Local address. */
14719 json_object_string_add(json_neigh
, "hostLocal",
14720 sockunion2str(p
->su_local
, buf1
,
14722 json_object_int_add(json_neigh
, "portLocal",
14723 ntohs(p
->su_local
->sin
.sin_port
));
14725 vty_out(vty
, "Local host: %s, Local port: %d\n",
14726 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14727 ntohs(p
->su_local
->sin
.sin_port
));
14730 /* Remote address. */
14731 if (p
->su_remote
) {
14733 json_object_string_add(json_neigh
, "hostForeign",
14734 sockunion2str(p
->su_remote
, buf1
,
14736 json_object_int_add(json_neigh
, "portForeign",
14737 ntohs(p
->su_remote
->sin
.sin_port
));
14739 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14740 sockunion2str(p
->su_remote
, buf1
,
14742 ntohs(p
->su_remote
->sin
.sin_port
));
14745 /* Nexthop display. */
14748 json_object_string_add(json_neigh
, "nexthop",
14750 &p
->nexthop
.v4
, buf1
,
14752 json_object_string_add(json_neigh
, "nexthopGlobal",
14753 inet_ntop(AF_INET6
,
14754 &p
->nexthop
.v6_global
,
14755 buf1
, sizeof(buf1
)));
14756 json_object_string_add(json_neigh
, "nexthopLocal",
14757 inet_ntop(AF_INET6
,
14758 &p
->nexthop
.v6_local
,
14759 buf1
, sizeof(buf1
)));
14760 if (p
->shared_network
)
14761 json_object_string_add(json_neigh
,
14765 json_object_string_add(json_neigh
,
14767 "nonSharedNetwork");
14769 vty_out(vty
, "Nexthop: %s\n",
14770 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14772 vty_out(vty
, "Nexthop global: %s\n",
14773 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14775 vty_out(vty
, "Nexthop local: %s\n",
14776 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14778 vty_out(vty
, "BGP connection: %s\n",
14779 p
->shared_network
? "shared network"
14780 : "non shared network");
14784 /* Timer information. */
14786 json_object_int_add(json_neigh
, "connectRetryTimer",
14788 if (peer_established(p
) && p
->rtt
)
14789 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14792 json_object_int_add(
14793 json_neigh
, "nextStartTimerDueInMsecs",
14794 thread_timer_remain_second(p
->t_start
) * 1000);
14796 json_object_int_add(
14797 json_neigh
, "nextConnectTimerDueInMsecs",
14798 thread_timer_remain_second(p
->t_connect
)
14800 if (p
->t_routeadv
) {
14801 json_object_int_add(json_neigh
, "mraiInterval",
14803 json_object_int_add(
14804 json_neigh
, "mraiTimerExpireInMsecs",
14805 thread_timer_remain_second(p
->t_routeadv
)
14809 json_object_int_add(json_neigh
, "authenticationEnabled",
14813 json_object_string_add(json_neigh
, "readThread", "on");
14815 json_object_string_add(json_neigh
, "readThread", "off");
14817 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14818 json_object_string_add(json_neigh
, "writeThread", "on");
14820 json_object_string_add(json_neigh
, "writeThread",
14823 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14825 if (peer_established(p
) && p
->rtt
)
14826 vty_out(vty
, "Estimated round trip time: %d ms\n",
14829 vty_out(vty
, "Next start timer due in %ld seconds\n",
14830 thread_timer_remain_second(p
->t_start
));
14832 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14833 thread_timer_remain_second(p
->t_connect
));
14836 "MRAI (interval %u) timer expires in %ld seconds\n",
14838 thread_timer_remain_second(p
->t_routeadv
));
14840 vty_out(vty
, "Peer Authentication Enabled\n");
14842 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14843 p
->t_read
? "on" : "off",
14844 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14849 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14850 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14851 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14854 vty_out(vty
, "\n");
14856 /* BFD information. */
14858 bgp_bfd_show_info(vty
, p
, json_neigh
);
14861 if (p
->conf_if
) /* Configured interface name. */
14862 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14863 else /* Configured IP address. */
14864 json_object_object_add(json
, p
->host
, json_neigh
);
14868 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14869 enum show_type type
,
14870 union sockunion
*su
,
14871 const char *conf_if
, afi_t afi
,
14874 struct listnode
*node
, *nnode
;
14877 safi_t safi
= SAFI_UNICAST
;
14878 json_object
*json
= NULL
;
14879 json_object
*json_neighbor
= NULL
;
14882 json
= json_object_new_object();
14883 json_neighbor
= json_object_new_object();
14886 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14888 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14891 if ((peer
->afc
[afi
][safi
]) == 0)
14894 if (type
== show_all
) {
14895 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14899 json_object_object_add(json
, peer
->host
,
14901 json_neighbor
= NULL
;
14904 } else if (type
== show_peer
) {
14907 && !strcmp(peer
->conf_if
, conf_if
))
14909 && !strcmp(peer
->hostname
, conf_if
))) {
14911 bgp_show_peer_gr_status(vty
, peer
,
14916 if (sockunion_same(&peer
->su
, su
)) {
14918 bgp_show_peer_gr_status(vty
, peer
,
14923 if (use_json
&& find
)
14924 json_object_object_add(json
, peer
->host
,
14929 json_neighbor
= NULL
;
14934 if (type
== show_peer
&& !find
) {
14936 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14938 vty_out(vty
, "%% No such neighbor\n");
14941 vty_out(vty
, "%s\n",
14942 json_object_to_json_string_ext(
14943 json
, JSON_C_TO_STRING_PRETTY
));
14946 json_object_free(json_neighbor
);
14947 json_object_free(json
);
14949 vty_out(vty
, "\n");
14952 return CMD_SUCCESS
;
14955 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14956 enum show_type type
, union sockunion
*su
,
14957 const char *conf_if
, bool use_json
,
14960 struct listnode
*node
, *nnode
;
14963 bool nbr_output
= false;
14964 afi_t afi
= AFI_MAX
;
14965 safi_t safi
= SAFI_MAX
;
14967 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14969 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14973 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14974 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14979 bgp_show_peer(vty
, peer
, use_json
, json
);
14985 && !strcmp(peer
->conf_if
, conf_if
))
14987 && !strcmp(peer
->hostname
, conf_if
))) {
14989 bgp_show_peer(vty
, peer
, use_json
,
14993 if (sockunion_same(&peer
->su
, su
)) {
14995 bgp_show_peer(vty
, peer
, use_json
,
15000 case show_ipv4_peer
:
15001 case show_ipv6_peer
:
15002 FOREACH_SAFI (safi
) {
15003 if (peer
->afc
[afi
][safi
]) {
15006 && !strcmp(peer
->conf_if
, conf_if
))
15008 && !strcmp(peer
->hostname
, conf_if
))) {
15010 bgp_show_peer(vty
, peer
, use_json
,
15015 if (sockunion_same(&peer
->su
, su
)) {
15017 bgp_show_peer(vty
, peer
, use_json
,
15025 case show_ipv4_all
:
15026 case show_ipv6_all
:
15027 FOREACH_SAFI (safi
) {
15028 if (peer
->afc
[afi
][safi
]) {
15029 bgp_show_peer(vty
, peer
, use_json
, json
);
15038 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15039 type
== show_ipv6_peer
) && !find
) {
15041 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15043 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15046 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15047 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15048 vty_out(vty
, "%% No BGP neighbors found\n");
15051 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15052 json
, JSON_C_TO_STRING_PRETTY
));
15054 vty_out(vty
, "\n");
15057 return CMD_SUCCESS
;
15060 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15061 enum show_type type
,
15062 const char *ip_str
,
15063 afi_t afi
, bool use_json
)
15068 union sockunion su
;
15070 bgp
= bgp_get_default();
15076 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
15080 ret
= str2sockunion(ip_str
, &su
);
15082 bgp_show_neighbor_graceful_restart(
15083 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
15085 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15086 NULL
, afi
, use_json
);
15088 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15092 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15093 enum show_type type
,
15094 const char *ip_str
,
15097 struct listnode
*node
, *nnode
;
15099 union sockunion su
;
15100 json_object
*json
= NULL
;
15101 int ret
, is_first
= 1;
15102 bool nbr_output
= false;
15105 vty_out(vty
, "{\n");
15107 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15110 if (!(json
= json_object_new_object())) {
15112 EC_BGP_JSON_MEM_ERROR
,
15113 "Unable to allocate memory for JSON object");
15115 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15119 json_object_int_add(json
, "vrfId",
15120 (bgp
->vrf_id
== VRF_UNKNOWN
)
15122 : (int64_t)bgp
->vrf_id
);
15123 json_object_string_add(
15125 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15130 vty_out(vty
, ",\n");
15134 vty_out(vty
, "\"%s\":",
15135 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15139 vty_out(vty
, "\nInstance %s:\n",
15140 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15145 if (type
== show_peer
|| type
== show_ipv4_peer
||
15146 type
== show_ipv6_peer
) {
15147 ret
= str2sockunion(ip_str
, &su
);
15149 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15152 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15155 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15158 json_object_free(json
);
15163 vty_out(vty
, "}\n");
15164 else if (!nbr_output
)
15165 vty_out(vty
, "%% BGP instance not found\n");
15168 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15169 enum show_type type
, const char *ip_str
,
15174 union sockunion su
;
15175 json_object
*json
= NULL
;
15178 if (strmatch(name
, "all")) {
15179 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15181 return CMD_SUCCESS
;
15183 bgp
= bgp_lookup_by_name(name
);
15186 json
= json_object_new_object();
15187 vty_out(vty
, "%s\n",
15188 json_object_to_json_string_ext(
15190 JSON_C_TO_STRING_PRETTY
));
15191 json_object_free(json
);
15194 "%% BGP instance not found\n");
15196 return CMD_WARNING
;
15200 bgp
= bgp_get_default();
15204 json
= json_object_new_object();
15206 ret
= str2sockunion(ip_str
, &su
);
15208 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15211 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15214 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15217 json_object_free(json
);
15220 vty_out(vty
, "{}\n");
15222 vty_out(vty
, "%% BGP instance not found\n");
15225 return CMD_SUCCESS
;
15230 /* "show [ip] bgp neighbors graceful-restart" commands. */
15231 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
15232 show_ip_bgp_neighbors_graceful_restart_cmd
,
15233 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15239 "Neighbor to display information about\n"
15240 "Neighbor to display information about\n"
15241 "Neighbor on BGP configured interface\n"
15245 char *sh_arg
= NULL
;
15246 enum show_type sh_type
;
15248 afi_t afi
= AFI_MAX
;
15249 bool uj
= use_json(argc
, argv
);
15251 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15256 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15257 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15258 || argv_find(argv
, argc
, "WORD", &idx
)) {
15259 sh_type
= show_peer
;
15260 sh_arg
= argv
[idx
]->arg
;
15262 sh_type
= show_all
;
15264 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15265 return CMD_SUCCESS
;
15268 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15272 /* "show [ip] bgp neighbors" commands. */
15273 DEFUN (show_ip_bgp_neighbors
,
15274 show_ip_bgp_neighbors_cmd
,
15275 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15279 BGP_INSTANCE_HELP_STR
15282 "Detailed information on TCP and BGP neighbor connections\n"
15283 "Neighbor to display information about\n"
15284 "Neighbor to display information about\n"
15285 "Neighbor on BGP configured interface\n"
15289 char *sh_arg
= NULL
;
15290 enum show_type sh_type
;
15291 afi_t afi
= AFI_MAX
;
15293 bool uj
= use_json(argc
, argv
);
15297 /* [<vrf> VIEWVRFNAME] */
15298 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15299 vrf
= argv
[idx
+ 1]->arg
;
15300 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15302 } else if (argv_find(argv
, argc
, "view", &idx
))
15303 /* [<view> VIEWVRFNAME] */
15304 vrf
= argv
[idx
+ 1]->arg
;
15308 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15309 sh_type
= show_ipv4_all
;
15311 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15312 sh_type
= show_ipv6_all
;
15315 sh_type
= show_all
;
15318 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15319 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15320 || argv_find(argv
, argc
, "WORD", &idx
)) {
15321 sh_type
= show_peer
;
15322 sh_arg
= argv
[idx
]->arg
;
15325 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15326 sh_type
= show_ipv4_peer
;
15327 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15328 sh_type
= show_ipv6_peer
;
15331 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15334 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15335 paths' and `show ip mbgp paths'. Those functions results are the
15337 DEFUN (show_ip_bgp_paths
,
15338 show_ip_bgp_paths_cmd
,
15339 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15344 "Path information\n")
15346 vty_out(vty
, "Address Refcnt Path\n");
15347 aspath_print_all_vty(vty
);
15348 return CMD_SUCCESS
;
15353 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15356 struct community
*com
;
15358 com
= (struct community
*)bucket
->data
;
15359 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15360 community_str(com
, false));
15363 /* Show BGP's community internal data. */
15364 DEFUN (show_ip_bgp_community_info
,
15365 show_ip_bgp_community_info_cmd
,
15366 "show [ip] bgp community-info",
15370 "List all bgp community information\n")
15372 vty_out(vty
, "Address Refcnt Community\n");
15374 hash_iterate(community_hash(),
15375 (void (*)(struct hash_bucket
*,
15376 void *))community_show_all_iterator
,
15379 return CMD_SUCCESS
;
15382 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15385 struct lcommunity
*lcom
;
15387 lcom
= (struct lcommunity
*)bucket
->data
;
15388 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15389 lcommunity_str(lcom
, false));
15392 /* Show BGP's community internal data. */
15393 DEFUN (show_ip_bgp_lcommunity_info
,
15394 show_ip_bgp_lcommunity_info_cmd
,
15395 "show ip bgp large-community-info",
15399 "List all bgp large-community information\n")
15401 vty_out(vty
, "Address Refcnt Large-community\n");
15403 hash_iterate(lcommunity_hash(),
15404 (void (*)(struct hash_bucket
*,
15405 void *))lcommunity_show_all_iterator
,
15408 return CMD_SUCCESS
;
15410 /* Graceful Restart */
15412 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15419 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15421 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15423 switch (bgp_global_gr_mode
) {
15425 case GLOBAL_HELPER
:
15426 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15430 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15433 case GLOBAL_DISABLE
:
15434 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15437 case GLOBAL_INVALID
:
15439 "Global BGP GR Mode Invalid\n");
15442 vty_out(vty
, "\n");
15445 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15446 enum show_type type
,
15447 const char *ip_str
,
15448 afi_t afi
, bool use_json
)
15450 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15453 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15455 bgp_show_neighbor_graceful_restart_vty(
15456 vty
, type
, ip_str
, afi
, use_json
);
15459 } else if (afi
!= AFI_MAX
) {
15460 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15463 return CMD_ERR_INCOMPLETE
;
15466 return CMD_SUCCESS
;
15468 /* Graceful Restart */
15470 DEFUN (show_ip_bgp_attr_info
,
15471 show_ip_bgp_attr_info_cmd
,
15472 "show [ip] bgp attribute-info",
15476 "List all bgp attribute information\n")
15478 attr_show_all(vty
);
15479 return CMD_SUCCESS
;
15482 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15483 afi_t afi
, safi_t safi
,
15484 bool use_json
, json_object
*json
)
15487 struct listnode
*node
;
15489 char buf1
[INET6_ADDRSTRLEN
];
15491 vpn_policy_direction_t dir
;
15494 json_object
*json_import_vrfs
= NULL
;
15495 json_object
*json_export_vrfs
= NULL
;
15497 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15500 vty_out(vty
, "%s\n",
15501 json_object_to_json_string_ext(
15503 JSON_C_TO_STRING_PRETTY
));
15504 json_object_free(json
);
15506 return CMD_WARNING
;
15509 /* Provide context for the block */
15510 json_object_string_add(json
, "vrf", name
? name
: "default");
15511 json_object_string_add(json
, "afiSafi",
15512 get_afi_safi_str(afi
, safi
, true));
15514 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15515 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15516 json_object_string_add(json
, "importFromVrfs", "none");
15517 json_object_string_add(json
, "importRts", "none");
15519 json_import_vrfs
= json_object_new_array();
15521 for (ALL_LIST_ELEMENTS_RO(
15522 bgp
->vpn_policy
[afi
].import_vrf
,
15524 json_object_array_add(json_import_vrfs
,
15525 json_object_new_string(vname
));
15527 json_object_object_add(json
, "importFromVrfs",
15529 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15530 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15531 ecom_str
= ecommunity_ecom2str(
15532 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15533 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15534 json_object_string_add(json
, "importRts",
15536 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15538 json_object_string_add(json
, "importRts",
15542 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15543 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15544 json_object_string_add(json
, "exportToVrfs", "none");
15545 json_object_string_add(json
, "routeDistinguisher",
15547 json_object_string_add(json
, "exportRts", "none");
15549 json_export_vrfs
= json_object_new_array();
15551 for (ALL_LIST_ELEMENTS_RO(
15552 bgp
->vpn_policy
[afi
].export_vrf
,
15554 json_object_array_add(json_export_vrfs
,
15555 json_object_new_string(vname
));
15556 json_object_object_add(json
, "exportToVrfs",
15558 json_object_string_add(json
, "routeDistinguisher",
15559 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15560 buf1
, RD_ADDRSTRLEN
));
15562 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15563 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15564 ecom_str
= ecommunity_ecom2str(
15565 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15566 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15567 json_object_string_add(json
, "exportRts",
15569 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15571 json_object_string_add(json
, "exportRts",
15576 vty_out(vty
, "%s\n",
15577 json_object_to_json_string_ext(json
,
15578 JSON_C_TO_STRING_PRETTY
));
15579 json_object_free(json
);
15582 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15585 vty_out(vty
, "%% No such BGP instance exist\n");
15586 return CMD_WARNING
;
15589 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15590 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15592 "This VRF is not importing %s routes from any other VRF\n",
15593 get_afi_safi_str(afi
, safi
, false));
15596 "This VRF is importing %s routes from the following VRFs:\n",
15597 get_afi_safi_str(afi
, safi
, false));
15599 for (ALL_LIST_ELEMENTS_RO(
15600 bgp
->vpn_policy
[afi
].import_vrf
,
15602 vty_out(vty
, " %s\n", vname
);
15604 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15606 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15607 ecom_str
= ecommunity_ecom2str(
15608 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15609 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15610 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15612 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15614 vty_out(vty
, "Import RT(s):\n");
15617 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15618 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15620 "This VRF is not exporting %s routes to any other VRF\n",
15621 get_afi_safi_str(afi
, safi
, false));
15624 "This VRF is exporting %s routes to the following VRFs:\n",
15625 get_afi_safi_str(afi
, safi
, false));
15627 for (ALL_LIST_ELEMENTS_RO(
15628 bgp
->vpn_policy
[afi
].export_vrf
,
15630 vty_out(vty
, " %s\n", vname
);
15632 vty_out(vty
, "RD: %s\n",
15633 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15634 buf1
, RD_ADDRSTRLEN
));
15636 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15637 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15638 ecom_str
= ecommunity_ecom2str(
15639 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15640 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15641 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15642 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15644 vty_out(vty
, "Import RT(s):\n");
15648 return CMD_SUCCESS
;
15651 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15652 safi_t safi
, bool use_json
)
15654 struct listnode
*node
, *nnode
;
15656 char *vrf_name
= NULL
;
15657 json_object
*json
= NULL
;
15658 json_object
*json_vrf
= NULL
;
15659 json_object
*json_vrfs
= NULL
;
15662 json
= json_object_new_object();
15663 json_vrfs
= json_object_new_object();
15666 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15668 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15669 vrf_name
= bgp
->name
;
15672 json_vrf
= json_object_new_object();
15674 vty_out(vty
, "\nInstance %s:\n",
15675 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15676 ? VRF_DEFAULT_NAME
: bgp
->name
);
15678 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15680 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15681 json_object_object_add(json_vrfs
,
15682 VRF_DEFAULT_NAME
, json_vrf
);
15684 json_object_object_add(json_vrfs
, vrf_name
,
15690 json_object_object_add(json
, "vrfs", json_vrfs
);
15691 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15692 JSON_C_TO_STRING_PRETTY
));
15693 json_object_free(json
);
15696 return CMD_SUCCESS
;
15699 /* "show [ip] bgp route-leak" command. */
15700 DEFUN (show_ip_bgp_route_leak
,
15701 show_ip_bgp_route_leak_cmd
,
15702 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15706 BGP_INSTANCE_HELP_STR
15709 "Route leaking information\n"
15713 afi_t afi
= AFI_MAX
;
15714 safi_t safi
= SAFI_MAX
;
15716 bool uj
= use_json(argc
, argv
);
15718 json_object
*json
= NULL
;
15720 /* show [ip] bgp */
15721 if (argv_find(argv
, argc
, "ip", &idx
)) {
15723 safi
= SAFI_UNICAST
;
15725 /* [vrf VIEWVRFNAME] */
15726 if (argv_find(argv
, argc
, "view", &idx
)) {
15728 "%% This command is not applicable to BGP views\n");
15729 return CMD_WARNING
;
15732 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15733 vrf
= argv
[idx
+ 1]->arg
;
15734 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15737 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15738 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15739 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15742 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15744 "%% This command is applicable only for unicast ipv4|ipv6\n");
15745 return CMD_WARNING
;
15748 if (vrf
&& strmatch(vrf
, "all"))
15749 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15752 json
= json_object_new_object();
15754 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15757 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15760 struct listnode
*node
, *nnode
;
15763 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15764 vty_out(vty
, "\nInstance %s:\n",
15765 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15768 update_group_show(bgp
, afi
, safi
, vty
, 0);
15772 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15773 int safi
, uint64_t subgrp_id
)
15778 if (strmatch(name
, "all")) {
15779 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15780 return CMD_SUCCESS
;
15782 bgp
= bgp_lookup_by_name(name
);
15785 bgp
= bgp_get_default();
15789 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15790 return CMD_SUCCESS
;
15793 DEFUN (show_ip_bgp_updgrps
,
15794 show_ip_bgp_updgrps_cmd
,
15795 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15799 BGP_INSTANCE_HELP_STR
15801 BGP_SAFI_WITH_LABEL_HELP_STR
15802 "Detailed info about dynamic update groups\n"
15803 "Specific subgroup to display detailed info for\n")
15806 afi_t afi
= AFI_IP6
;
15807 safi_t safi
= SAFI_UNICAST
;
15808 uint64_t subgrp_id
= 0;
15812 /* show [ip] bgp */
15813 if (argv_find(argv
, argc
, "ip", &idx
))
15815 /* [<vrf> VIEWVRFNAME] */
15816 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15817 vrf
= argv
[idx
+ 1]->arg
;
15818 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15820 } else if (argv_find(argv
, argc
, "view", &idx
))
15821 /* [<view> VIEWVRFNAME] */
15822 vrf
= argv
[idx
+ 1]->arg
;
15823 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15824 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15825 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15828 /* get subgroup id, if provided */
15830 if (argv
[idx
]->type
== VARIABLE_TKN
)
15831 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15833 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15836 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15837 show_bgp_instance_all_ipv6_updgrps_cmd
,
15838 "show [ip] bgp <view|vrf> all update-groups",
15842 BGP_INSTANCE_ALL_HELP_STR
15843 "Detailed info about dynamic update groups\n")
15845 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15846 return CMD_SUCCESS
;
15849 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15850 show_bgp_l2vpn_evpn_updgrps_cmd
,
15851 "show [ip] bgp l2vpn evpn update-groups",
15855 "l2vpn address family\n"
15856 "evpn sub-address family\n"
15857 "Detailed info about dynamic update groups\n")
15860 uint64_t subgrp_id
= 0;
15862 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15863 return CMD_SUCCESS
;
15866 DEFUN (show_bgp_updgrps_stats
,
15867 show_bgp_updgrps_stats_cmd
,
15868 "show [ip] bgp update-groups statistics",
15872 "Detailed info about dynamic update groups\n"
15877 bgp
= bgp_get_default();
15879 update_group_show_stats(bgp
, vty
);
15881 return CMD_SUCCESS
;
15884 DEFUN (show_bgp_instance_updgrps_stats
,
15885 show_bgp_instance_updgrps_stats_cmd
,
15886 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15890 BGP_INSTANCE_HELP_STR
15891 "Detailed info about dynamic update groups\n"
15897 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15899 update_group_show_stats(bgp
, vty
);
15901 return CMD_SUCCESS
;
15904 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15905 afi_t afi
, safi_t safi
,
15906 const char *what
, uint64_t subgrp_id
)
15911 bgp
= bgp_lookup_by_name(name
);
15913 bgp
= bgp_get_default();
15916 if (!strcmp(what
, "advertise-queue"))
15917 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15919 else if (!strcmp(what
, "advertised-routes"))
15920 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15922 else if (!strcmp(what
, "packet-queue"))
15923 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15928 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15929 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15930 "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",
15931 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15933 "Detailed info about dynamic update groups\n"
15934 "Specific subgroup to display info for\n"
15935 "Advertisement queue\n"
15936 "Announced routes\n"
15939 uint64_t subgrp_id
= 0;
15943 subgrp_id
= strtoull(sgid
, NULL
, 10);
15948 afiz
= bgp_vty_afi_from_str(afi
);
15952 afiz
= bgp_vty_afi_from_str(afi
);
15953 if (afiz
!= AFI_IP
)
15955 "%% Cannot specify both 'ip' and 'ipv6'\n");
15956 return CMD_WARNING
;
15959 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15961 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15962 return CMD_SUCCESS
;
15965 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15968 struct listnode
*node
, *nnode
;
15969 struct prefix
*range
;
15974 const char *peer_status
;
15978 json_object
*json_peer_group
= NULL
;
15979 json_object
*json_peer_group_afc
= NULL
;
15980 json_object
*json_peer_group_members
= NULL
;
15981 json_object
*json_peer_group_dynamic
= NULL
;
15982 json_object
*json_peer_group_dynamic_af
= NULL
;
15983 json_object
*json_peer_group_ranges
= NULL
;
15985 conf
= group
->conf
;
15988 json_peer_group
= json_object_new_object();
15989 json_peer_group_afc
= json_object_new_array();
15992 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15994 json_object_int_add(json_peer_group
, "remoteAs",
15997 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15998 group
->name
, conf
->as
);
15999 } else if (conf
->as_type
== AS_INTERNAL
) {
16001 json_object_int_add(json_peer_group
, "remoteAs",
16004 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
16005 group
->name
, group
->bgp
->as
);
16008 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
16011 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
16013 json_object_string_add(json_peer_group
, "type",
16016 vty_out(vty
, " Peer-group type is internal\n");
16019 json_object_string_add(json_peer_group
, "type",
16022 vty_out(vty
, " Peer-group type is external\n");
16025 /* Display AFs configured. */
16027 vty_out(vty
, " Configured address-families:");
16029 FOREACH_AFI_SAFI (afi
, safi
) {
16030 if (conf
->afc
[afi
][safi
]) {
16033 json_object_array_add(
16034 json_peer_group_afc
,
16035 json_object_new_string(get_afi_safi_str(
16036 afi
, safi
, false)));
16038 vty_out(vty
, " %s;",
16039 get_afi_safi_str(afi
, safi
, false));
16044 json_object_object_add(json_peer_group
,
16045 "addressFamiliesConfigured",
16046 json_peer_group_afc
);
16049 vty_out(vty
, " none\n");
16051 vty_out(vty
, "\n");
16054 /* Display listen ranges (for dynamic neighbors), if any */
16055 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16056 lr_count
= listcount(group
->listen_range
[afi
]);
16059 if (!json_peer_group_dynamic
)
16060 json_peer_group_dynamic
=
16061 json_object_new_object();
16063 json_peer_group_dynamic_af
=
16064 json_object_new_object();
16065 json_peer_group_ranges
=
16066 json_object_new_array();
16067 json_object_int_add(json_peer_group_dynamic_af
,
16068 "count", lr_count
);
16070 vty_out(vty
, " %d %s listen range(s)\n",
16071 lr_count
, afi2str(afi
));
16074 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16079 snprintfrr(buf
, sizeof(buf
), "%pFX",
16082 json_object_array_add(
16083 json_peer_group_ranges
,
16084 json_object_new_string(buf
));
16086 vty_out(vty
, " %pFX\n", range
);
16091 json_object_object_add(
16092 json_peer_group_dynamic_af
, "ranges",
16093 json_peer_group_ranges
);
16095 json_object_object_add(
16096 json_peer_group_dynamic
, afi2str(afi
),
16097 json_peer_group_dynamic_af
);
16102 if (json_peer_group_dynamic
)
16103 json_object_object_add(json_peer_group
, "dynamicRanges",
16104 json_peer_group_dynamic
);
16106 /* Display group members and their status */
16107 if (listcount(group
->peer
)) {
16109 json_peer_group_members
= json_object_new_object();
16111 vty_out(vty
, " Peer-group members:\n");
16112 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16113 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16114 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16115 peer_status
= "Idle (Admin)";
16116 else if (CHECK_FLAG(peer
->sflags
,
16117 PEER_STATUS_PREFIX_OVERFLOW
))
16118 peer_status
= "Idle (PfxCt)";
16120 peer_status
= lookup_msg(bgp_status_msg
,
16121 peer
->status
, NULL
);
16123 dynamic
= peer_dynamic_neighbor(peer
);
16126 json_object
*json_peer_group_member
=
16127 json_object_new_object();
16129 json_object_string_add(json_peer_group_member
,
16130 "status", peer_status
);
16133 json_object_boolean_true_add(
16134 json_peer_group_member
,
16137 json_object_object_add(json_peer_group_members
,
16139 json_peer_group_member
);
16141 vty_out(vty
, " %s %s %s \n", peer
->host
,
16142 dynamic
? "(dynamic)" : "",
16147 json_object_object_add(json_peer_group
, "members",
16148 json_peer_group_members
);
16152 json_object_object_add(json
, group
->name
, json_peer_group
);
16154 return CMD_SUCCESS
;
16157 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16158 const char *group_name
, bool uj
)
16161 struct listnode
*node
, *nnode
;
16162 struct peer_group
*group
;
16163 bool found
= false;
16164 json_object
*json
= NULL
;
16167 json
= json_object_new_object();
16169 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16173 vty_out(vty
, "%s\n",
16174 json_object_to_json_string_ext(
16175 json
, JSON_C_TO_STRING_PRETTY
));
16176 json_object_free(json
);
16178 vty_out(vty
, "%% BGP instance not found\n");
16181 return CMD_WARNING
;
16184 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16186 if (strmatch(group
->name
, group_name
)) {
16187 bgp_show_one_peer_group(vty
, group
, json
);
16192 bgp_show_one_peer_group(vty
, group
, json
);
16196 if (group_name
&& !found
&& !uj
)
16197 vty_out(vty
, "%% No such peer-group\n");
16200 vty_out(vty
, "%s\n",
16201 json_object_to_json_string_ext(
16202 json
, JSON_C_TO_STRING_PRETTY
));
16203 json_object_free(json
);
16206 return CMD_SUCCESS
;
16209 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16210 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16211 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16212 "Detailed information on BGP peer groups\n"
16213 "Peer group name\n" JSON_STR
)
16217 bool uj
= use_json(argc
, argv
);
16219 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16221 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16223 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16227 /* Redistribute VTY commands. */
16229 DEFUN_YANG (bgp_redistribute_ipv4
,
16230 bgp_redistribute_ipv4_cmd
,
16231 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16232 "Redistribute information from another routing protocol\n"
16233 FRR_IP_REDIST_HELP_STR_BGPD
)
16235 int idx_protocol
= 1;
16236 char base_xpath
[XPATH_MAXLEN
];
16238 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16239 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16240 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16241 argv
[idx_protocol
]->text
, "0");
16243 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16245 return nb_cli_apply_changes(vty
, base_xpath
);
16249 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16250 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16251 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16253 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
16254 bgp_redistribute_ipv4_rmap_cmd
,
16255 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
16256 "Redistribute information from another routing protocol\n"
16257 FRR_IP_REDIST_HELP_STR_BGPD
16258 "Route map reference\n"
16259 "Pointer to route-map entries\n")
16261 int idx_protocol
= 1;
16263 char base_xpath
[XPATH_MAXLEN
];
16265 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16266 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16267 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16268 argv
[idx_protocol
]->text
, "0");
16270 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16271 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16272 argv
[idx_word
]->arg
);
16274 return nb_cli_apply_changes(vty
, base_xpath
);
16278 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16279 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
16280 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16281 "Route map reference\n"
16282 "Pointer to route-map entries\n")
16284 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
16285 bgp_redistribute_ipv4_metric_cmd
,
16286 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16287 "Redistribute information from another routing protocol\n"
16288 FRR_IP_REDIST_HELP_STR_BGPD
16289 "Metric for redistributed routes\n"
16290 "Default metric\n")
16292 int idx_protocol
= 1;
16293 int idx_number
= 3;
16294 char base_xpath
[XPATH_MAXLEN
];
16296 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16297 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16298 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16299 argv
[idx_protocol
]->text
, "0");
16301 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16302 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16303 argv
[idx_number
]->arg
);
16305 return nb_cli_apply_changes(vty
, base_xpath
);
16309 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16310 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16311 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16312 "Metric for redistributed routes\n"
16313 "Default metric\n")
16316 bgp_redistribute_ipv4_rmap_metric
,
16317 bgp_redistribute_ipv4_rmap_metric_cmd
,
16318 "redistribute " FRR_IP_REDIST_STR_BGPD
16319 " route-map WORD metric (0-4294967295)",
16320 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16321 "Route map reference\n"
16322 "Pointer to route-map entries\n"
16323 "Metric for redistributed routes\n"
16324 "Default metric\n")
16326 int idx_protocol
= 1;
16328 int idx_number
= 5;
16329 char base_xpath
[XPATH_MAXLEN
];
16331 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16332 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16333 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16334 argv
[idx_protocol
]->text
, "0");
16336 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16337 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16338 argv
[idx_word
]->arg
);
16339 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16340 argv
[idx_number
]->arg
);
16342 return nb_cli_apply_changes(vty
, base_xpath
);
16346 bgp_redistribute_ipv4_rmap_metric
,
16347 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16348 "redistribute " FRR_IP_REDIST_STR_BGPD
16349 " route-map WORD metric (0-4294967295)",
16350 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16351 "Route map reference\n"
16352 "Pointer to route-map entries\n"
16353 "Metric for redistributed routes\n"
16354 "Default metric\n")
16357 bgp_redistribute_ipv4_metric_rmap
,
16358 bgp_redistribute_ipv4_metric_rmap_cmd
,
16359 "redistribute " FRR_IP_REDIST_STR_BGPD
16360 " metric (0-4294967295) route-map WORD",
16361 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16362 "Metric for redistributed routes\n"
16364 "Route map reference\n"
16365 "Pointer to route-map entries\n")
16367 int idx_protocol
= 1;
16369 int idx_number
= 3;
16370 char base_xpath
[XPATH_MAXLEN
];
16372 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16373 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16374 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16375 argv
[idx_protocol
]->text
, "0");
16377 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16378 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16379 argv
[idx_number
]->arg
);
16380 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16381 argv
[idx_word
]->arg
);
16383 return nb_cli_apply_changes(vty
, base_xpath
);
16387 bgp_redistribute_ipv4_metric_rmap
,
16388 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16389 "redistribute " FRR_IP_REDIST_STR_BGPD
16390 " metric (0-4294967295) route-map WORD",
16391 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16392 "Metric for redistributed routes\n"
16394 "Route map reference\n"
16395 "Pointer to route-map entries\n")
16397 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
16398 bgp_redistribute_ipv4_ospf_cmd
,
16399 "redistribute <ospf|table> (1-65535)",
16400 "Redistribute information from another routing protocol\n"
16401 "Open Shortest Path First (OSPFv2)\n"
16402 "Non-main Kernel Routing Table\n"
16403 "Instance ID/Table ID\n")
16405 int idx_protocol
= 1;
16406 int idx_number
= 2;
16407 char base_xpath
[XPATH_MAXLEN
];
16409 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16410 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16411 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16412 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16414 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16416 return nb_cli_apply_changes(vty
, base_xpath
);
16419 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16420 "redistribute <ospf|table> (1-65535)",
16421 "Redistribute information from another routing protocol\n"
16422 "Open Shortest Path First (OSPFv2)\n"
16423 "Non-main Kernel Routing Table\n"
16424 "Instance ID/Table ID\n")
16426 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
16427 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16428 "redistribute <ospf|table> (1-65535) route-map WORD",
16429 "Redistribute information from another routing protocol\n"
16430 "Open Shortest Path First (OSPFv2)\n"
16431 "Non-main Kernel Routing Table\n"
16432 "Instance ID/Table ID\n"
16433 "Route map reference\n"
16434 "Pointer to route-map entries\n")
16436 int idx_protocol
= 1;
16437 int idx_number
= 2;
16439 char base_xpath
[XPATH_MAXLEN
];
16441 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16442 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16443 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16444 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16446 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16448 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16449 argv
[idx_word
]->arg
);
16451 return nb_cli_apply_changes(vty
, base_xpath
);
16454 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16455 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16456 "redistribute <ospf|table> (1-65535) route-map WORD",
16457 "Redistribute information from another routing protocol\n"
16458 "Open Shortest Path First (OSPFv2)\n"
16459 "Non-main Kernel Routing Table\n"
16460 "Instance ID/Table ID\n"
16461 "Route map reference\n"
16462 "Pointer to route-map entries\n")
16464 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
16465 bgp_redistribute_ipv4_ospf_metric_cmd
,
16466 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16467 "Redistribute information from another routing protocol\n"
16468 "Open Shortest Path First (OSPFv2)\n"
16469 "Non-main Kernel Routing Table\n"
16470 "Instance ID/Table ID\n"
16471 "Metric for redistributed routes\n"
16472 "Default metric\n")
16474 int idx_protocol
= 1;
16475 int idx_number
= 2;
16476 int idx_number_2
= 4;
16477 char base_xpath
[XPATH_MAXLEN
];
16479 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16480 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16481 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16482 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16484 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16486 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16487 argv
[idx_number_2
]->arg
);
16489 return nb_cli_apply_changes(vty
, base_xpath
);
16492 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16493 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16494 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16495 "Redistribute information from another routing protocol\n"
16496 "Open Shortest Path First (OSPFv2)\n"
16497 "Non-main Kernel Routing Table\n"
16498 "Instance ID/Table ID\n"
16499 "Metric for redistributed routes\n"
16500 "Default metric\n")
16503 bgp_redistribute_ipv4_ospf_rmap_metric
,
16504 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16505 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16506 "Redistribute information from another routing protocol\n"
16507 "Open Shortest Path First (OSPFv2)\n"
16508 "Non-main Kernel Routing Table\n"
16509 "Instance ID/Table ID\n"
16510 "Route map reference\n"
16511 "Pointer to route-map entries\n"
16512 "Metric for redistributed routes\n"
16513 "Default metric\n")
16515 int idx_protocol
= 1;
16516 int idx_number
= 2;
16518 int idx_number_2
= 6;
16519 char base_xpath
[XPATH_MAXLEN
];
16521 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16522 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16523 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16524 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16526 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16528 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16529 argv
[idx_word
]->arg
);
16530 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16531 argv
[idx_number_2
]->arg
);
16533 return nb_cli_apply_changes(vty
, base_xpath
);
16537 bgp_redistribute_ipv4_ospf_rmap_metric
,
16538 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16539 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16540 "Redistribute information from another routing protocol\n"
16541 "Open Shortest Path First (OSPFv2)\n"
16542 "Non-main Kernel Routing Table\n"
16543 "Instance ID/Table ID\n"
16544 "Route map reference\n"
16545 "Pointer to route-map entries\n"
16546 "Metric for redistributed routes\n"
16547 "Default metric\n")
16550 bgp_redistribute_ipv4_ospf_metric_rmap
,
16551 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16552 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16553 "Redistribute information from another routing protocol\n"
16554 "Open Shortest Path First (OSPFv2)\n"
16555 "Non-main Kernel Routing Table\n"
16556 "Instance ID/Table ID\n"
16557 "Metric for redistributed routes\n"
16559 "Route map reference\n"
16560 "Pointer to route-map entries\n")
16562 int idx_protocol
= 1;
16563 int idx_number
= 2;
16564 int idx_number_2
= 4;
16566 char base_xpath
[XPATH_MAXLEN
];
16568 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16569 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16570 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16571 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16573 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16575 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16576 argv
[idx_number_2
]->arg
);
16577 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16578 argv
[idx_word
]->arg
);
16580 return nb_cli_apply_changes(vty
, base_xpath
);
16584 bgp_redistribute_ipv4_ospf_metric_rmap
,
16585 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16586 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16587 "Redistribute information from another routing protocol\n"
16588 "Open Shortest Path First (OSPFv2)\n"
16589 "Non-main Kernel Routing Table\n"
16590 "Instance ID/Table ID\n"
16591 "Metric for redistributed routes\n"
16593 "Route map reference\n"
16594 "Pointer to route-map entries\n")
16596 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
16597 no_bgp_redistribute_ipv4_ospf_cmd
,
16598 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16600 "Redistribute information from another routing protocol\n"
16601 "Open Shortest Path First (OSPFv2)\n"
16602 "Non-main Kernel Routing Table\n"
16603 "Instance ID/Table ID\n"
16604 "Metric for redistributed routes\n"
16606 "Route map reference\n"
16607 "Pointer to route-map entries\n")
16609 int idx_protocol
= 2;
16610 int idx_number
= 3;
16611 char base_xpath
[XPATH_MAXLEN
];
16613 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16614 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16615 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16616 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16618 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16620 return nb_cli_apply_changes(vty
, base_xpath
);
16624 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16625 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16627 "Redistribute information from another routing protocol\n"
16628 "Open Shortest Path First (OSPFv2)\n"
16629 "Non-main Kernel Routing Table\n"
16630 "Instance ID/Table ID\n"
16631 "Metric for redistributed routes\n"
16633 "Route map reference\n"
16634 "Pointer to route-map entries\n")
16636 DEFUN_YANG (no_bgp_redistribute_ipv4
,
16637 no_bgp_redistribute_ipv4_cmd
,
16638 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16640 "Redistribute information from another routing protocol\n"
16641 FRR_IP_REDIST_HELP_STR_BGPD
16642 "Metric for redistributed routes\n"
16644 "Route map reference\n"
16645 "Pointer to route-map entries\n")
16647 int idx_protocol
= 2;
16648 char base_xpath
[XPATH_MAXLEN
];
16650 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16651 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16652 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16653 argv
[idx_protocol
]->text
, "0");
16655 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16657 return nb_cli_apply_changes(vty
, base_xpath
);
16661 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16662 "no redistribute " FRR_IP_REDIST_STR_BGPD
16663 " [{metric (0-4294967295)|route-map WORD}]",
16665 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16666 "Metric for redistributed routes\n"
16668 "Route map reference\n"
16669 "Pointer to route-map entries\n")
16671 DEFUN_YANG (bgp_redistribute_ipv6
,
16672 bgp_redistribute_ipv6_cmd
,
16673 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16674 "Redistribute information from another routing protocol\n"
16675 FRR_IP6_REDIST_HELP_STR_BGPD
)
16677 int idx_protocol
= 1;
16678 char base_xpath
[XPATH_MAXLEN
];
16680 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16681 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16682 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16683 argv
[idx_protocol
]->text
, "0");
16685 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16687 return nb_cli_apply_changes(vty
, base_xpath
);
16690 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16691 bgp_redistribute_ipv6_rmap_cmd
,
16692 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16693 "Redistribute information from another routing protocol\n"
16694 FRR_IP6_REDIST_HELP_STR_BGPD
16695 "Route map reference\n"
16696 "Pointer to route-map entries\n")
16698 int idx_protocol
= 1;
16700 char base_xpath
[XPATH_MAXLEN
];
16702 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16703 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16704 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16705 argv
[idx_protocol
]->text
, "0");
16707 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16708 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16709 argv
[idx_word
]->arg
);
16711 return nb_cli_apply_changes(vty
, base_xpath
);
16714 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16715 bgp_redistribute_ipv6_metric_cmd
,
16716 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16717 "Redistribute information from another routing protocol\n"
16718 FRR_IP6_REDIST_HELP_STR_BGPD
16719 "Metric for redistributed routes\n"
16720 "Default metric\n")
16722 int idx_protocol
= 1;
16723 int idx_number
= 3;
16724 char base_xpath
[XPATH_MAXLEN
];
16726 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16727 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16728 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16729 argv
[idx_protocol
]->text
, "0");
16731 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16732 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16733 argv
[idx_number
]->arg
);
16735 return nb_cli_apply_changes(vty
, base_xpath
);
16739 bgp_redistribute_ipv6_rmap_metric
,
16740 bgp_redistribute_ipv6_rmap_metric_cmd
,
16741 "redistribute " FRR_IP6_REDIST_STR_BGPD
16742 " route-map WORD metric (0-4294967295)",
16743 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16744 "Route map reference\n"
16745 "Pointer to route-map entries\n"
16746 "Metric for redistributed routes\n"
16747 "Default metric\n")
16749 int idx_protocol
= 1;
16751 int idx_number
= 5;
16752 char base_xpath
[XPATH_MAXLEN
];
16754 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16755 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16756 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16757 argv
[idx_protocol
]->text
, "0");
16759 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16760 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16761 argv
[idx_word
]->arg
);
16762 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16763 argv
[idx_number
]->arg
);
16765 return nb_cli_apply_changes(vty
, base_xpath
);
16769 bgp_redistribute_ipv6_metric_rmap
,
16770 bgp_redistribute_ipv6_metric_rmap_cmd
,
16771 "redistribute " FRR_IP6_REDIST_STR_BGPD
16772 " metric (0-4294967295) route-map WORD",
16773 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16774 "Metric for redistributed routes\n"
16776 "Route map reference\n"
16777 "Pointer to route-map entries\n")
16779 int idx_protocol
= 1;
16781 int idx_number
= 3;
16782 char base_xpath
[XPATH_MAXLEN
];
16784 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16785 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16786 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16787 argv
[idx_protocol
]->text
, "0");
16789 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16790 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16791 argv
[idx_number
]->arg
);
16792 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16793 argv
[idx_word
]->arg
);
16795 return nb_cli_apply_changes(vty
, base_xpath
);
16799 no_bgp_redistribute_ipv6
,
16800 no_bgp_redistribute_ipv6_cmd
,
16801 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16802 " [{metric (0-4294967295)|route-map WORD}]",
16804 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16805 "Metric for redistributed routes\n"
16807 "Route map reference\n"
16808 "Pointer to route-map entries\n")
16810 int idx_protocol
= 2;
16811 char base_xpath
[XPATH_MAXLEN
];
16813 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16814 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16815 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16816 argv
[idx_protocol
]->text
, "0");
16818 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16820 return nb_cli_apply_changes(vty
, base_xpath
);
16823 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16824 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16826 uint32_t instance
= 0;
16828 vty_out(vty
, " redistribute %s",
16829 yang_dnode_get_string(dnode
, "./route-type"));
16830 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16831 vty_out(vty
, " %d", instance
);
16832 if (yang_dnode_exists(dnode
, "./metric"))
16833 vty_out(vty
, " metric %u",
16834 yang_dnode_get_uint32(dnode
, "./metric"));
16835 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16836 vty_out(vty
, " route-map %s",
16837 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16838 vty_out(vty
, "\n");
16841 /* Neighbor update tcp-mss. */
16842 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16843 const char *tcp_mss_str
)
16846 uint32_t tcp_mss_val
= 0;
16848 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16850 return CMD_WARNING_CONFIG_FAILED
;
16853 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16854 peer_tcp_mss_set(peer
, tcp_mss_val
);
16856 peer_tcp_mss_unset(peer
);
16859 return CMD_SUCCESS
;
16862 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16863 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16864 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16865 "TCP max segment size\n"
16868 int peer_index
= 1;
16872 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16873 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16874 argv
[mss_index
]->arg
);
16877 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16878 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16879 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16880 "TCP max segment size\n"
16883 int peer_index
= 2;
16886 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16887 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16890 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16891 afi_t afi
, safi_t safi
)
16895 /* Unicast redistribution only. */
16896 if (safi
!= SAFI_UNICAST
)
16899 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16900 /* Redistribute BGP does not make sense. */
16901 if (i
!= ZEBRA_ROUTE_BGP
) {
16902 struct list
*red_list
;
16903 struct listnode
*node
;
16904 struct bgp_redist
*red
;
16906 red_list
= bgp
->redist
[afi
][i
];
16910 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16911 /* "redistribute" configuration. */
16912 vty_out(vty
, " redistribute %s",
16913 zebra_route_string(i
));
16915 vty_out(vty
, " %d", red
->instance
);
16916 if (red
->redist_metric_flag
)
16917 vty_out(vty
, " metric %u",
16918 red
->redist_metric
);
16919 if (red
->rmap
.name
)
16920 vty_out(vty
, " route-map %s",
16922 vty_out(vty
, "\n");
16928 /* peer-group helpers for config-write */
16930 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16932 if (!peer_group_active(peer
)) {
16933 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16934 return !CHECK_FLAG(peer
->flags
, flag
);
16936 return !!CHECK_FLAG(peer
->flags
, flag
);
16939 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16942 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16945 if (!peer_group_active(peer
)) {
16946 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16947 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16949 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16952 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16955 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16956 uint8_t type
, int direct
)
16958 struct bgp_filter
*filter
;
16960 if (peer_group_active(peer
))
16961 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16964 filter
= &peer
->filter
[afi
][safi
];
16966 case PEER_FT_DISTRIBUTE_LIST
:
16967 return !!(filter
->dlist
[direct
].name
);
16968 case PEER_FT_FILTER_LIST
:
16969 return !!(filter
->aslist
[direct
].name
);
16970 case PEER_FT_PREFIX_LIST
:
16971 return !!(filter
->plist
[direct
].name
);
16972 case PEER_FT_ROUTE_MAP
:
16973 return !!(filter
->map
[direct
].name
);
16974 case PEER_FT_UNSUPPRESS_MAP
:
16975 return !!(filter
->usmap
.name
);
16976 case PEER_FT_ADVERTISE_MAP
:
16977 return !!(filter
->advmap
.aname
16978 && ((filter
->advmap
.condition
== direct
)
16979 && filter
->advmap
.cname
));
16985 /* Return true if the addpath type is set for peer and different from
16988 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16991 enum bgp_addpath_strat type
, g_type
;
16993 type
= peer
->addpath_type
[afi
][safi
];
16995 if (type
!= BGP_ADDPATH_NONE
) {
16996 if (peer_group_active(peer
)) {
16997 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16999 if (type
!= g_type
)
17011 /* This is part of the address-family block (unicast only) */
17012 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17017 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17018 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17019 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17020 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17021 bgp
->vpn_policy
[afi
]
17022 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17024 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17025 bgp
->vpn_policy
[afi
]
17026 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17028 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17029 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17030 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17031 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17034 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17035 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17037 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17040 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17041 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17042 bgp
->vpn_policy
[afi
].tovpn_label
);
17045 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17046 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
17047 char buf
[RD_ADDRSTRLEN
];
17048 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
17049 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
17052 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17053 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17055 char buf
[PREFIX_STRLEN
];
17056 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17057 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17060 vty_out(vty
, "%*snexthop vpn export %s\n",
17064 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17065 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17067 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17068 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17070 char *b
= ecommunity_ecom2str(
17071 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17072 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17073 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17074 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17076 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17077 char *b
= ecommunity_ecom2str(
17078 bgp
->vpn_policy
[afi
]
17079 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17080 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17081 ECOMMUNITY_ROUTE_TARGET
);
17082 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17083 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17085 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17086 char *b
= ecommunity_ecom2str(
17087 bgp
->vpn_policy
[afi
]
17088 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17089 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17090 ECOMMUNITY_ROUTE_TARGET
);
17091 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17092 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17096 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17097 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17098 bgp
->vpn_policy
[afi
]
17099 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17101 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17102 char *b
= ecommunity_ecom2str(
17103 bgp
->vpn_policy
[afi
]
17104 .import_redirect_rtlist
,
17105 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17106 ECOMMUNITY_ROUTE_TARGET
);
17108 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17109 != ECOMMUNITY_SIZE
)
17110 vty_out(vty
, "%*srt6 redirect import %s\n",
17113 vty_out(vty
, "%*srt redirect import %s\n",
17115 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17119 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17120 afi_t afi
, safi_t safi
)
17122 struct bgp_filter
*filter
;
17126 filter
= &peer
->filter
[afi
][safi
];
17128 /* distribute-list. */
17129 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17131 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17132 filter
->dlist
[FILTER_IN
].name
);
17134 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17136 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17137 filter
->dlist
[FILTER_OUT
].name
);
17140 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17142 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17143 filter
->plist
[FILTER_IN
].name
);
17145 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17147 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17148 filter
->plist
[FILTER_OUT
].name
);
17151 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17152 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17153 filter
->map
[RMAP_IN
].name
);
17155 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17157 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17158 filter
->map
[RMAP_OUT
].name
);
17160 /* unsuppress-map */
17161 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17162 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17163 filter
->usmap
.name
);
17165 /* advertise-map : always applied in OUT direction*/
17166 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17167 CONDITION_NON_EXIST
))
17169 " neighbor %s advertise-map %s non-exist-map %s\n",
17170 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17172 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17174 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17175 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17178 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17180 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17181 filter
->aslist
[FILTER_IN
].name
);
17183 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17185 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17186 filter
->aslist
[FILTER_OUT
].name
);
17189 /* BGP peer configuration display function. */
17190 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17193 struct peer
*g_peer
= NULL
;
17194 char buf
[SU_ADDRSTRLEN
];
17196 int if_pg_printed
= false;
17197 int if_ras_printed
= false;
17199 /* Skip dynamic neighbors. */
17200 if (peer_dynamic_neighbor(peer
))
17204 addr
= peer
->conf_if
;
17208 /************************************
17209 ****** Global to the neighbor ******
17210 ************************************/
17211 if (peer
->conf_if
) {
17212 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17213 vty_out(vty
, " neighbor %s interface v6only", addr
);
17215 vty_out(vty
, " neighbor %s interface", addr
);
17217 if (peer_group_active(peer
)) {
17218 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17219 if_pg_printed
= true;
17220 } else if (peer
->as_type
== AS_SPECIFIED
) {
17221 vty_out(vty
, " remote-as %u", peer
->as
);
17222 if_ras_printed
= true;
17223 } else if (peer
->as_type
== AS_INTERNAL
) {
17224 vty_out(vty
, " remote-as internal");
17225 if_ras_printed
= true;
17226 } else if (peer
->as_type
== AS_EXTERNAL
) {
17227 vty_out(vty
, " remote-as external");
17228 if_ras_printed
= true;
17231 vty_out(vty
, "\n");
17234 /* remote-as and peer-group */
17235 /* peer is a member of a peer-group */
17236 if (peer_group_active(peer
)) {
17237 g_peer
= peer
->group
->conf
;
17239 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17240 if (peer
->as_type
== AS_SPECIFIED
) {
17241 vty_out(vty
, " neighbor %s remote-as %u\n",
17243 } else if (peer
->as_type
== AS_INTERNAL
) {
17245 " neighbor %s remote-as internal\n",
17247 } else if (peer
->as_type
== AS_EXTERNAL
) {
17249 " neighbor %s remote-as external\n",
17254 /* For swpX peers we displayed the peer-group
17255 * via 'neighbor swpX interface peer-group PGNAME' */
17256 if (!if_pg_printed
)
17257 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17258 peer
->group
->name
);
17261 /* peer is NOT a member of a peer-group */
17263 /* peer is a peer-group, declare the peer-group */
17264 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17265 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17268 if (!if_ras_printed
) {
17269 if (peer
->as_type
== AS_SPECIFIED
) {
17270 vty_out(vty
, " neighbor %s remote-as %u\n",
17272 } else if (peer
->as_type
== AS_INTERNAL
) {
17274 " neighbor %s remote-as internal\n",
17276 } else if (peer
->as_type
== AS_EXTERNAL
) {
17278 " neighbor %s remote-as external\n",
17285 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17286 vty_out(vty
, " neighbor %s local-as %u", addr
,
17287 peer
->change_local_as
);
17288 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17289 vty_out(vty
, " no-prepend");
17290 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17291 vty_out(vty
, " replace-as");
17292 vty_out(vty
, "\n");
17297 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17301 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17302 if (peer
->tx_shutdown_message
)
17303 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17304 peer
->tx_shutdown_message
);
17306 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17309 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17310 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17311 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17314 if (peer
->bfd_config
)
17315 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17318 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17319 vty_out(vty
, " neighbor %s password %s\n", addr
,
17322 /* neighbor solo */
17323 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17324 if (!peer_group_active(peer
)) {
17325 vty_out(vty
, " neighbor %s solo\n", addr
);
17330 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17331 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17334 /* Local interface name */
17335 if (peer
->ifname
) {
17336 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17339 /* TCP max segment size */
17340 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17341 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17344 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17345 vty_out(vty
, " neighbor %s passive\n", addr
);
17347 /* ebgp-multihop */
17348 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17349 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17350 && peer
->ttl
== MAXTTL
)) {
17351 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17352 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17357 /* ttl-security hops */
17358 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17359 if (!peer_group_active(peer
)
17360 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17361 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17362 addr
, peer
->gtsm_hops
);
17366 /* disable-connected-check */
17367 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17368 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17370 /* enforce-first-as */
17371 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17372 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17374 /* update-source */
17375 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17376 if (peer
->update_source
)
17377 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17378 sockunion2str(peer
->update_source
, buf
,
17380 else if (peer
->update_if
)
17381 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17385 /* advertisement-interval */
17386 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17387 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17391 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17392 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17393 peer
->keepalive
, peer
->holdtime
);
17395 /* timers connect */
17396 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17397 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17399 /* need special-case handling for changed default values due to
17400 * config profile / version (because there is no "timers bgp connect"
17401 * command, we need to save this per-peer :/)
17403 else if (!peer_group_active(peer
) && !peer
->connect
&&
17404 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17405 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17406 peer
->bgp
->default_connect_retry
);
17408 /* timers delayopen */
17409 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17410 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17412 /* Save config even though flag is not set if default values have been
17415 else if (!peer_group_active(peer
) && !peer
->delayopen
17416 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17417 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17418 peer
->bgp
->default_delayopen
);
17420 /* capability dynamic */
17421 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17422 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17424 /* capability extended-nexthop */
17425 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17426 if (!peer
->conf_if
) {
17427 if (CHECK_FLAG(peer
->flags_invert
,
17428 PEER_FLAG_CAPABILITY_ENHE
))
17430 " no neighbor %s capability extended-nexthop\n",
17434 " neighbor %s capability extended-nexthop\n",
17439 /* dont-capability-negotiation */
17440 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17441 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17443 /* override-capability */
17444 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17445 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17447 /* strict-capability-match */
17448 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17449 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17451 /* Sender side AS path loop detection. */
17452 if (peer
->as_path_loop_detection
)
17453 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17456 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17457 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17459 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17460 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17462 " neighbor %s graceful-restart-helper\n", addr
);
17463 } else if (CHECK_FLAG(
17464 peer
->peer_gr_new_status_flag
,
17465 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17467 " neighbor %s graceful-restart\n", addr
);
17469 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17470 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17472 peer
->peer_gr_new_status_flag
,
17473 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17474 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17480 /* BGP peer configuration display function. */
17481 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17482 struct peer
*peer
, afi_t afi
, safi_t safi
)
17484 struct peer
*g_peer
= NULL
;
17486 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17488 /* Skip dynamic neighbors. */
17489 if (peer_dynamic_neighbor(peer
))
17493 addr
= peer
->conf_if
;
17497 /************************************
17498 ****** Per AF to the neighbor ******
17499 ************************************/
17500 if (peer_group_active(peer
)) {
17501 g_peer
= peer
->group
->conf
;
17503 /* If the peer-group is active but peer is not, print a 'no
17505 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17506 vty_out(vty
, " no neighbor %s activate\n", addr
);
17509 /* If the peer-group is not active but peer is, print an
17511 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17512 vty_out(vty
, " neighbor %s activate\n", addr
);
17515 if (peer
->afc
[afi
][safi
]) {
17516 if (safi
== SAFI_ENCAP
)
17517 vty_out(vty
, " neighbor %s activate\n", addr
);
17518 else if (!bgp
->default_af
[afi
][safi
])
17519 vty_out(vty
, " neighbor %s activate\n", addr
);
17521 if (bgp
->default_af
[afi
][safi
])
17522 vty_out(vty
, " no neighbor %s activate\n",
17527 /* addpath TX knobs */
17528 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17529 switch (peer
->addpath_type
[afi
][safi
]) {
17530 case BGP_ADDPATH_ALL
:
17531 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17534 case BGP_ADDPATH_BEST_PER_AS
:
17536 " neighbor %s addpath-tx-bestpath-per-AS\n",
17539 case BGP_ADDPATH_MAX
:
17540 case BGP_ADDPATH_NONE
:
17545 /* ORF capability. */
17546 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17547 || peergroup_af_flag_check(peer
, afi
, safi
,
17548 PEER_FLAG_ORF_PREFIX_RM
)) {
17549 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17551 if (peergroup_af_flag_check(peer
, afi
, safi
,
17552 PEER_FLAG_ORF_PREFIX_SM
)
17553 && peergroup_af_flag_check(peer
, afi
, safi
,
17554 PEER_FLAG_ORF_PREFIX_RM
))
17555 vty_out(vty
, " both");
17556 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17557 PEER_FLAG_ORF_PREFIX_SM
))
17558 vty_out(vty
, " send");
17560 vty_out(vty
, " receive");
17561 vty_out(vty
, "\n");
17564 /* Route reflector client. */
17565 if (peergroup_af_flag_check(peer
, afi
, safi
,
17566 PEER_FLAG_REFLECTOR_CLIENT
)) {
17567 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17570 /* next-hop-self force */
17571 if (peergroup_af_flag_check(peer
, afi
, safi
,
17572 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17573 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17576 /* next-hop-self */
17577 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17578 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17581 /* remove-private-AS */
17582 if (peergroup_af_flag_check(peer
, afi
, safi
,
17583 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17584 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17588 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17589 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17590 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17594 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17595 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17596 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17599 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17600 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17601 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17605 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17606 vty_out(vty
, " neighbor %s as-override\n", addr
);
17609 /* send-community print. */
17610 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17611 PEER_FLAG_SEND_COMMUNITY
);
17612 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17613 PEER_FLAG_SEND_EXT_COMMUNITY
);
17614 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17615 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17617 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17618 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17621 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17624 " no neighbor %s send-community extended\n",
17628 vty_out(vty
, " no neighbor %s send-community large\n",
17632 /* Default information */
17633 if (peergroup_af_flag_check(peer
, afi
, safi
,
17634 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17635 vty_out(vty
, " neighbor %s default-originate", addr
);
17637 if (peer
->default_rmap
[afi
][safi
].name
)
17638 vty_out(vty
, " route-map %s",
17639 peer
->default_rmap
[afi
][safi
].name
);
17641 vty_out(vty
, "\n");
17644 /* Soft reconfiguration inbound. */
17645 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17646 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17650 /* maximum-prefix. */
17651 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17652 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17653 peer
->pmax
[afi
][safi
]);
17655 if (peer
->pmax_threshold
[afi
][safi
]
17656 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17657 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17658 if (peer_af_flag_check(peer
, afi
, safi
,
17659 PEER_FLAG_MAX_PREFIX_WARNING
))
17660 vty_out(vty
, " warning-only");
17661 if (peer
->pmax_restart
[afi
][safi
])
17662 vty_out(vty
, " restart %u",
17663 peer
->pmax_restart
[afi
][safi
]);
17664 if (peer_af_flag_check(peer
, afi
, safi
,
17665 PEER_FLAG_MAX_PREFIX_FORCE
))
17666 vty_out(vty
, " force");
17668 vty_out(vty
, "\n");
17671 /* maximum-prefix-out */
17672 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17673 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17674 addr
, peer
->pmax_out
[afi
][safi
]);
17676 /* Route server client. */
17677 if (peergroup_af_flag_check(peer
, afi
, safi
,
17678 PEER_FLAG_RSERVER_CLIENT
)) {
17679 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17682 /* Nexthop-local unchanged. */
17683 if (peergroup_af_flag_check(peer
, afi
, safi
,
17684 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17685 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17688 /* allowas-in <1-10> */
17689 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17690 if (peer_af_flag_check(peer
, afi
, safi
,
17691 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17692 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17693 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17694 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17696 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17697 peer
->allowas_in
[afi
][safi
]);
17702 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17703 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17704 peer
->weight
[afi
][safi
]);
17707 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17709 /* atribute-unchanged. */
17710 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17711 || (safi
!= SAFI_EVPN
17712 && peer_af_flag_check(peer
, afi
, safi
,
17713 PEER_FLAG_NEXTHOP_UNCHANGED
))
17714 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17716 if (!peer_group_active(peer
)
17717 || peergroup_af_flag_check(peer
, afi
, safi
,
17718 PEER_FLAG_AS_PATH_UNCHANGED
)
17719 || peergroup_af_flag_check(peer
, afi
, safi
,
17720 PEER_FLAG_NEXTHOP_UNCHANGED
)
17721 || peergroup_af_flag_check(peer
, afi
, safi
,
17722 PEER_FLAG_MED_UNCHANGED
)) {
17725 " neighbor %s attribute-unchanged%s%s%s\n",
17727 peer_af_flag_check(peer
, afi
, safi
,
17728 PEER_FLAG_AS_PATH_UNCHANGED
)
17731 peer_af_flag_check(peer
, afi
, safi
,
17732 PEER_FLAG_NEXTHOP_UNCHANGED
)
17735 peer_af_flag_check(peer
, afi
, safi
,
17736 PEER_FLAG_MED_UNCHANGED
)
17742 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_CONFIG_DAMPENING
))
17743 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17746 /* Address family based peer configuration display. */
17747 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17751 struct peer_group
*group
;
17752 struct listnode
*node
, *nnode
;
17755 vty_frame(vty
, " !\n address-family ");
17756 if (afi
== AFI_IP
) {
17757 if (safi
== SAFI_UNICAST
)
17758 vty_frame(vty
, "ipv4 unicast");
17759 else if (safi
== SAFI_LABELED_UNICAST
)
17760 vty_frame(vty
, "ipv4 labeled-unicast");
17761 else if (safi
== SAFI_MULTICAST
)
17762 vty_frame(vty
, "ipv4 multicast");
17763 else if (safi
== SAFI_MPLS_VPN
)
17764 vty_frame(vty
, "ipv4 vpn");
17765 else if (safi
== SAFI_ENCAP
)
17766 vty_frame(vty
, "ipv4 encap");
17767 else if (safi
== SAFI_FLOWSPEC
)
17768 vty_frame(vty
, "ipv4 flowspec");
17769 } else if (afi
== AFI_IP6
) {
17770 if (safi
== SAFI_UNICAST
)
17771 vty_frame(vty
, "ipv6 unicast");
17772 else if (safi
== SAFI_LABELED_UNICAST
)
17773 vty_frame(vty
, "ipv6 labeled-unicast");
17774 else if (safi
== SAFI_MULTICAST
)
17775 vty_frame(vty
, "ipv6 multicast");
17776 else if (safi
== SAFI_MPLS_VPN
)
17777 vty_frame(vty
, "ipv6 vpn");
17778 else if (safi
== SAFI_ENCAP
)
17779 vty_frame(vty
, "ipv6 encap");
17780 else if (safi
== SAFI_FLOWSPEC
)
17781 vty_frame(vty
, "ipv6 flowspec");
17782 } else if (afi
== AFI_L2VPN
) {
17783 if (safi
== SAFI_EVPN
)
17784 vty_frame(vty
, "l2vpn evpn");
17786 vty_frame(vty
, "\n");
17788 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17790 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17792 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17794 /* BGP flag dampening. */
17795 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17796 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17798 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17799 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17801 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17802 /* Do not display doppelganger peers */
17803 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17804 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17807 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17808 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17810 if (safi
== SAFI_EVPN
)
17811 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17813 if (safi
== SAFI_FLOWSPEC
)
17814 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17816 if (safi
== SAFI_UNICAST
) {
17817 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17818 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17819 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17821 vty_out(vty
, " export vpn\n");
17823 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17824 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17826 vty_out(vty
, " import vpn\n");
17828 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17829 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17832 for (ALL_LIST_ELEMENTS_RO(
17833 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17835 vty_out(vty
, " import vrf %s\n", name
);
17839 vty_endframe(vty
, " exit-address-family\n");
17842 int bgp_config_write(struct vty
*vty
)
17845 struct peer_group
*group
;
17847 struct listnode
*node
, *nnode
;
17848 struct listnode
*mnode
, *mnnode
;
17852 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17853 vty_out(vty
, "bgp route-map delay-timer %u\n",
17854 bm
->rmap_update_timer
);
17856 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17857 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17858 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17859 vty_out(vty
, " %d", bm
->v_establish_wait
);
17860 vty_out(vty
, "\n");
17863 if (bm
->wait_for_fib
)
17864 vty_out(vty
, "bgp suppress-fib-pending\n");
17866 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17867 vty_out(vty
, "bgp graceful-shutdown\n");
17869 /* No-RIB (Zebra) option flag configuration */
17870 if (bgp_option_check(BGP_OPT_NO_FIB
))
17871 vty_out(vty
, "bgp no-rib\n");
17873 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17874 vty_out(vty
, "no bgp send-extra-data zebra\n");
17876 /* BGP configuration. */
17877 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17879 /* skip all auto created vrf as they dont have user config */
17880 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17883 /* Router bgp ASN */
17884 vty_out(vty
, "router bgp %u", bgp
->as
);
17887 vty_out(vty
, " %s %s",
17888 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17889 ? "view" : "vrf", bgp
->name
);
17890 vty_out(vty
, "\n");
17892 /* BGP fast-external-failover. */
17893 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17894 vty_out(vty
, " no bgp fast-external-failover\n");
17896 /* BGP router ID. */
17897 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17898 vty_out(vty
, " bgp router-id %pI4\n",
17899 &bgp
->router_id_static
);
17901 /* Suppress fib pending */
17902 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17903 vty_out(vty
, " bgp suppress-fib-pending\n");
17905 /* BGP log-neighbor-changes. */
17906 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17907 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17908 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17909 CHECK_FLAG(bgp
->flags
,
17910 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17914 /* BGP configuration. */
17915 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17916 vty_out(vty
, " bgp always-compare-med\n");
17918 /* RFC8212 default eBGP policy. */
17919 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17920 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17921 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17922 CHECK_FLAG(bgp
->flags
,
17923 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17927 /* draft-ietf-idr-deprecate-as-set-confed-set */
17928 if (bgp
->reject_as_sets
)
17929 vty_out(vty
, " bgp reject-as-sets\n");
17931 /* Suppress duplicate updates if the route actually not changed
17933 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17934 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17935 vty_out(vty
, " %sbgp suppress-duplicates\n",
17936 CHECK_FLAG(bgp
->flags
,
17937 BGP_FLAG_SUPPRESS_DUPLICATES
)
17941 /* BGP default <afi>-<safi> */
17942 FOREACH_AFI_SAFI (afi
, safi
) {
17943 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17944 if (!bgp
->default_af
[afi
][safi
])
17945 vty_out(vty
, " no bgp default %s\n",
17946 get_bgp_default_af_flag(afi
,
17948 } else if (bgp
->default_af
[afi
][safi
])
17949 vty_out(vty
, " bgp default %s\n",
17950 get_bgp_default_af_flag(afi
, safi
));
17953 /* BGP default local-preference. */
17954 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17955 vty_out(vty
, " bgp default local-preference %u\n",
17956 bgp
->default_local_pref
);
17958 /* BGP default show-hostname */
17959 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17960 != SAVE_BGP_SHOW_HOSTNAME
)
17961 vty_out(vty
, " %sbgp default show-hostname\n",
17962 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17966 /* BGP default show-nexthop-hostname */
17967 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17968 != SAVE_BGP_SHOW_HOSTNAME
)
17969 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17970 CHECK_FLAG(bgp
->flags
,
17971 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17975 /* BGP default subgroup-pkt-queue-max. */
17976 if (bgp
->default_subgroup_pkt_queue_max
17977 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17978 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17979 bgp
->default_subgroup_pkt_queue_max
);
17981 /* BGP client-to-client reflection. */
17982 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17983 vty_out(vty
, " no bgp client-to-client reflection\n");
17985 /* BGP cluster ID. */
17986 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17987 vty_out(vty
, " bgp cluster-id %pI4\n",
17990 /* Disable ebgp connected nexthop check */
17991 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17993 " bgp disable-ebgp-connected-route-check\n");
17995 /* Confederation identifier*/
17996 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17997 vty_out(vty
, " bgp confederation identifier %u\n",
18000 /* Confederation peer */
18001 if (bgp
->confed_peers_cnt
> 0) {
18004 vty_out(vty
, " bgp confederation peers");
18006 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18007 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18009 vty_out(vty
, "\n");
18012 /* BGP deterministic-med. */
18013 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18014 != SAVE_BGP_DETERMINISTIC_MED
)
18015 vty_out(vty
, " %sbgp deterministic-med\n",
18016 CHECK_FLAG(bgp
->flags
,
18017 BGP_FLAG_DETERMINISTIC_MED
)
18021 /* BGP update-delay. */
18022 bgp_config_write_update_delay(vty
, bgp
);
18024 if (bgp
->v_maxmed_onstartup
18025 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18026 vty_out(vty
, " bgp max-med on-startup %u",
18027 bgp
->v_maxmed_onstartup
);
18028 if (bgp
->maxmed_onstartup_value
18029 != BGP_MAXMED_VALUE_DEFAULT
)
18030 vty_out(vty
, " %u",
18031 bgp
->maxmed_onstartup_value
);
18032 vty_out(vty
, "\n");
18034 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18035 vty_out(vty
, " bgp max-med administrative");
18036 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18037 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18038 vty_out(vty
, "\n");
18042 bgp_config_write_wpkt_quanta(vty
, bgp
);
18044 bgp_config_write_rpkt_quanta(vty
, bgp
);
18046 /* coalesce time */
18047 bgp_config_write_coalesce_time(vty
, bgp
);
18049 /* BGP per-instance graceful-shutdown */
18050 /* BGP-wide settings and per-instance settings are mutually
18053 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18054 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18055 vty_out(vty
, " bgp graceful-shutdown\n");
18057 /* BGP graceful-restart. */
18058 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18060 " bgp graceful-restart stalepath-time %u\n",
18061 bgp
->stalepath_time
);
18063 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18064 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18065 bgp
->restart_time
);
18067 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18069 " bgp graceful-restart select-defer-time %u\n",
18070 bgp
->select_defer_time
);
18072 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18073 vty_out(vty
, " bgp graceful-restart\n");
18075 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18076 vty_out(vty
, " bgp graceful-restart-disable\n");
18078 /* BGP graceful-restart Preserve State F bit. */
18079 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18081 " bgp graceful-restart preserve-fw-state\n");
18083 /* Stale timer for RIB */
18084 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18086 " bgp graceful-restart rib-stale-time %u\n",
18087 bgp
->rib_stale_time
);
18089 /* BGP bestpath method. */
18090 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18091 vty_out(vty
, " bgp bestpath as-path ignore\n");
18092 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18093 vty_out(vty
, " bgp bestpath as-path confed\n");
18095 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18096 if (CHECK_FLAG(bgp
->flags
,
18097 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18099 " bgp bestpath as-path multipath-relax as-set\n");
18102 " bgp bestpath as-path multipath-relax\n");
18106 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18108 " bgp route-reflector allow-outbound-policy\n");
18110 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18111 vty_out(vty
, " bgp bestpath compare-routerid\n");
18112 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18113 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18114 vty_out(vty
, " bgp bestpath med");
18115 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18116 vty_out(vty
, " confed");
18117 if (CHECK_FLAG(bgp
->flags
,
18118 BGP_FLAG_MED_MISSING_AS_WORST
))
18119 vty_out(vty
, " missing-as-worst");
18120 vty_out(vty
, "\n");
18123 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18125 " bgp bestpath peer-type multipath-relax\n");
18127 /* Link bandwidth handling. */
18128 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18129 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18130 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18131 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18132 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18133 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18135 /* BGP network import check. */
18136 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18137 != SAVE_BGP_IMPORT_CHECK
)
18138 vty_out(vty
, " %sbgp network import-check\n",
18139 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18143 /* BGP timers configuration. */
18144 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18145 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18146 vty_out(vty
, " timers bgp %u %u\n",
18147 bgp
->default_keepalive
, bgp
->default_holdtime
);
18150 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18151 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18154 /* Normal neighbor configuration. */
18155 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18156 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18157 bgp_config_write_peer_global(vty
, bgp
, peer
);
18160 /* listen range and limit for dynamic BGP neighbors */
18161 bgp_config_write_listen(vty
, bgp
);
18164 * BGP default autoshutdown neighbors
18166 * This must be placed after any peer and peer-group
18167 * configuration, to avoid setting all peers to shutdown after
18168 * a daemon restart, which is undesired behavior. (see #2286)
18170 if (bgp
->autoshutdown
)
18171 vty_out(vty
, " bgp default shutdown\n");
18173 /* BGP instance administrative shutdown */
18174 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18175 vty_out(vty
, " bgp shutdown\n");
18177 if (bgp
->srv6_enabled
) {
18178 vty_frame(vty
, " !\n segment-routing srv6\n");
18179 if (strlen(bgp
->srv6_locator_name
))
18180 vty_out(vty
, " locator %s\n",
18181 bgp
->srv6_locator_name
);
18185 /* IPv4 unicast configuration. */
18186 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18188 /* IPv4 multicast configuration. */
18189 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18191 /* IPv4 labeled-unicast configuration. */
18192 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18194 /* IPv4 VPN configuration. */
18195 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18197 /* ENCAPv4 configuration. */
18198 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18200 /* FLOWSPEC v4 configuration. */
18201 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18203 /* IPv6 unicast configuration. */
18204 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18206 /* IPv6 multicast configuration. */
18207 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18209 /* IPv6 labeled-unicast configuration. */
18210 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18211 SAFI_LABELED_UNICAST
);
18213 /* IPv6 VPN configuration. */
18214 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18216 /* ENCAPv6 configuration. */
18217 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18219 /* FLOWSPEC v6 configuration. */
18220 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18222 /* EVPN configuration. */
18223 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18225 hook_call(bgp_inst_config_write
, bgp
, vty
);
18227 #ifdef ENABLE_BGP_VNC
18228 bgp_rfapi_cfg_write(vty
, bgp
);
18231 vty_out(vty
, "!\n");
18237 /* BGP node structure. */
18238 static struct cmd_node bgp_node
= {
18241 .parent_node
= CONFIG_NODE
,
18242 .prompt
= "%s(config-router)# ",
18243 .config_write
= bgp_config_write
,
18246 static struct cmd_node bgp_ipv4_unicast_node
= {
18247 .name
= "bgp ipv4 unicast",
18248 .node
= BGP_IPV4_NODE
,
18249 .parent_node
= BGP_NODE
,
18250 .prompt
= "%s(config-router-af)# ",
18253 static struct cmd_node bgp_ipv4_multicast_node
= {
18254 .name
= "bgp ipv4 multicast",
18255 .node
= BGP_IPV4M_NODE
,
18256 .parent_node
= BGP_NODE
,
18257 .prompt
= "%s(config-router-af)# ",
18260 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18261 .name
= "bgp ipv4 labeled unicast",
18262 .node
= BGP_IPV4L_NODE
,
18263 .parent_node
= BGP_NODE
,
18264 .prompt
= "%s(config-router-af)# ",
18267 static struct cmd_node bgp_ipv6_unicast_node
= {
18268 .name
= "bgp ipv6",
18269 .node
= BGP_IPV6_NODE
,
18270 .parent_node
= BGP_NODE
,
18271 .prompt
= "%s(config-router-af)# ",
18274 static struct cmd_node bgp_ipv6_multicast_node
= {
18275 .name
= "bgp ipv6 multicast",
18276 .node
= BGP_IPV6M_NODE
,
18277 .parent_node
= BGP_NODE
,
18278 .prompt
= "%s(config-router-af)# ",
18281 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18282 .name
= "bgp ipv6 labeled unicast",
18283 .node
= BGP_IPV6L_NODE
,
18284 .parent_node
= BGP_NODE
,
18285 .prompt
= "%s(config-router-af)# ",
18288 static struct cmd_node bgp_vpnv4_node
= {
18289 .name
= "bgp vpnv4",
18290 .node
= BGP_VPNV4_NODE
,
18291 .parent_node
= BGP_NODE
,
18292 .prompt
= "%s(config-router-af)# ",
18295 static struct cmd_node bgp_vpnv6_node
= {
18296 .name
= "bgp vpnv6",
18297 .node
= BGP_VPNV6_NODE
,
18298 .parent_node
= BGP_NODE
,
18299 .prompt
= "%s(config-router-af-vpnv6)# ",
18302 static struct cmd_node bgp_evpn_node
= {
18303 .name
= "bgp evpn",
18304 .node
= BGP_EVPN_NODE
,
18305 .parent_node
= BGP_NODE
,
18306 .prompt
= "%s(config-router-evpn)# ",
18309 static struct cmd_node bgp_evpn_vni_node
= {
18310 .name
= "bgp evpn vni",
18311 .node
= BGP_EVPN_VNI_NODE
,
18312 .parent_node
= BGP_EVPN_NODE
,
18313 .prompt
= "%s(config-router-af-vni)# ",
18316 static struct cmd_node bgp_flowspecv4_node
= {
18317 .name
= "bgp ipv4 flowspec",
18318 .node
= BGP_FLOWSPECV4_NODE
,
18319 .parent_node
= BGP_NODE
,
18320 .prompt
= "%s(config-router-af)# ",
18323 static struct cmd_node bgp_flowspecv6_node
= {
18324 .name
= "bgp ipv6 flowspec",
18325 .node
= BGP_FLOWSPECV6_NODE
,
18326 .parent_node
= BGP_NODE
,
18327 .prompt
= "%s(config-router-af-vpnv6)# ",
18330 static struct cmd_node bgp_srv6_node
= {
18331 .name
= "bgp srv6",
18332 .node
= BGP_SRV6_NODE
,
18333 .parent_node
= BGP_NODE
,
18334 .prompt
= "%s(config-router-srv6)# ",
18337 static void community_list_vty(void);
18339 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18343 struct listnode
*lnbgp
, *lnpeer
;
18345 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18346 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18347 /* only provide suggestions on the appropriate input
18349 * they'll otherwise show up multiple times */
18350 enum cmd_token_type match_type
;
18351 char *name
= peer
->host
;
18353 if (peer
->conf_if
) {
18354 match_type
= VARIABLE_TKN
;
18355 name
= peer
->conf_if
;
18356 } else if (strchr(peer
->host
, ':'))
18357 match_type
= IPV6_TKN
;
18359 match_type
= IPV4_TKN
;
18361 if (token
->type
!= match_type
)
18364 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18369 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18370 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18371 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18372 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18373 {.completions
= NULL
}};
18375 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18378 struct peer_group
*group
;
18379 struct listnode
*lnbgp
, *lnpeer
;
18381 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18382 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18383 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
18388 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18389 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18390 {.completions
= NULL
} };
18392 void bgp_vty_init(void)
18394 cmd_variable_handler_register(bgp_var_neighbor
);
18395 cmd_variable_handler_register(bgp_var_peergroup
);
18397 /* Install bgp top node. */
18398 install_node(&bgp_node
);
18399 install_node(&bgp_ipv4_unicast_node
);
18400 install_node(&bgp_ipv4_multicast_node
);
18401 install_node(&bgp_ipv4_labeled_unicast_node
);
18402 install_node(&bgp_ipv6_unicast_node
);
18403 install_node(&bgp_ipv6_multicast_node
);
18404 install_node(&bgp_ipv6_labeled_unicast_node
);
18405 install_node(&bgp_vpnv4_node
);
18406 install_node(&bgp_vpnv6_node
);
18407 install_node(&bgp_evpn_node
);
18408 install_node(&bgp_evpn_vni_node
);
18409 install_node(&bgp_flowspecv4_node
);
18410 install_node(&bgp_flowspecv6_node
);
18411 install_node(&bgp_srv6_node
);
18413 /* Install default VTY commands to new nodes. */
18414 install_default(BGP_NODE
);
18415 install_default(BGP_IPV4_NODE
);
18416 install_default(BGP_IPV4M_NODE
);
18417 install_default(BGP_IPV4L_NODE
);
18418 install_default(BGP_IPV6_NODE
);
18419 install_default(BGP_IPV6M_NODE
);
18420 install_default(BGP_IPV6L_NODE
);
18421 install_default(BGP_VPNV4_NODE
);
18422 install_default(BGP_VPNV6_NODE
);
18423 install_default(BGP_FLOWSPECV4_NODE
);
18424 install_default(BGP_FLOWSPECV6_NODE
);
18425 install_default(BGP_EVPN_NODE
);
18426 install_default(BGP_EVPN_VNI_NODE
);
18427 install_default(BGP_SRV6_NODE
);
18429 /* "bgp local-mac" hidden commands. */
18430 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18431 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18433 /* "bgp suppress-fib-pending" global */
18434 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18436 /* bgp route-map delay-timer commands. */
18437 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18438 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18440 /* global bgp update-delay command */
18441 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18442 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18444 /* global bgp graceful-shutdown command */
18445 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18446 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18448 /* Dummy commands (Currently not supported) */
18449 install_element(BGP_NODE
, &no_synchronization_cmd
);
18450 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18452 /* "router bgp" commands. */
18453 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18455 /* "no router bgp" commands. */
18456 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18458 /* "bgp router-id" commands. */
18459 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18460 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18462 /* "bgp suppress-fib-pending" command */
18463 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18465 /* "bgp cluster-id" commands. */
18466 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18467 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18469 /* "bgp no-rib" commands. */
18470 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18471 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18473 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18475 /* "bgp confederation" commands. */
18476 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18477 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18479 /* "bgp confederation peers" commands. */
18480 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18481 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18483 /* bgp max-med command */
18484 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18485 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18486 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18487 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18488 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18490 /* bgp disable-ebgp-connected-nh-check */
18491 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18492 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18494 /* bgp update-delay command */
18495 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18496 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18498 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18499 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18501 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18502 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18504 /* "maximum-paths" commands. */
18505 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18506 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18507 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18508 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18509 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18510 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18511 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18512 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18513 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18514 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18515 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18516 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18517 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18518 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18519 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18521 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18522 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18523 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18524 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18525 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18526 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18527 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18528 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18529 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18530 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18532 /* "timers bgp" commands. */
18533 install_element(BGP_NODE
, &bgp_timers_cmd
);
18534 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18536 /* route-map delay-timer commands - per instance for backwards compat.
18538 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18539 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18541 /* "bgp client-to-client reflection" commands */
18542 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18543 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18545 /* "bgp always-compare-med" commands */
18546 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18547 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18549 /* bgp ebgp-requires-policy */
18550 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18551 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18553 /* bgp suppress-duplicates */
18554 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18555 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18557 /* bgp reject-as-sets */
18558 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18559 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18561 /* "bgp deterministic-med" commands */
18562 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18563 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18565 /* "bgp graceful-restart" command */
18566 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18567 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18569 /* "bgp graceful-restart-disable" command */
18570 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18571 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18573 /* "neighbor a:b:c:d graceful-restart" command */
18574 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18575 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18577 /* "neighbor a:b:c:d graceful-restart-disable" command */
18578 install_element(BGP_NODE
,
18579 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18580 install_element(BGP_NODE
,
18581 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18583 /* "neighbor a:b:c:d graceful-restart-helper" command */
18584 install_element(BGP_NODE
,
18585 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18586 install_element(BGP_NODE
,
18587 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18589 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18590 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18591 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18592 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18593 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18594 install_element(BGP_NODE
,
18595 &no_bgp_graceful_restart_select_defer_time_cmd
);
18596 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18597 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18599 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18600 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18601 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18602 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18604 /* "bgp graceful-shutdown" commands */
18605 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18606 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18608 /* "bgp fast-external-failover" commands */
18609 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18610 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18612 /* "bgp bestpath compare-routerid" commands */
18613 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18614 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18616 /* "bgp bestpath as-path ignore" commands */
18617 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18618 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18620 /* "bgp bestpath as-path confed" commands */
18621 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18622 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18624 /* "bgp bestpath as-path multipath-relax" commands */
18625 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18626 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18628 /* "bgp bestpath peer-type multipath-relax" commands */
18629 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18630 install_element(BGP_NODE
,
18631 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18633 /* "bgp log-neighbor-changes" commands */
18634 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18635 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18637 /* "bgp bestpath med" commands */
18638 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18639 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18641 /* "bgp bestpath bandwidth" commands */
18642 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18643 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18645 /* "no bgp default <afi>-<safi>" commands. */
18646 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18648 /* "bgp network import-check" commands. */
18649 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18650 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18651 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18653 /* "bgp default local-preference" commands. */
18654 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18655 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18657 /* bgp default show-hostname */
18658 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18659 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18661 /* bgp default show-nexthop-hostname */
18662 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18663 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18665 /* "bgp default subgroup-pkt-queue-max" commands. */
18666 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18667 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18669 /* bgp ibgp-allow-policy-mods command */
18670 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18671 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18673 /* "bgp listen limit" commands. */
18674 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18675 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18677 /* "bgp listen range" commands. */
18678 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18679 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18681 /* "bgp default shutdown" command */
18682 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18684 /* "bgp shutdown" commands */
18685 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18686 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18687 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18688 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18690 /* "neighbor remote-as" commands. */
18691 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18692 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18693 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18694 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18695 install_element(BGP_NODE
,
18696 &neighbor_interface_v6only_config_remote_as_cmd
);
18697 install_element(BGP_NODE
, &no_neighbor_cmd
);
18698 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18700 /* "neighbor peer-group" commands. */
18701 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18702 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18703 install_element(BGP_NODE
,
18704 &no_neighbor_interface_peer_group_remote_as_cmd
);
18706 /* "neighbor local-as" commands. */
18707 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18708 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18709 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18710 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18712 /* "neighbor solo" commands. */
18713 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18714 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18716 /* "neighbor password" commands. */
18717 install_element(BGP_NODE
, &neighbor_password_cmd
);
18718 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18720 /* "neighbor activate" commands. */
18721 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18722 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18723 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18724 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18725 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18726 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18727 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18728 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18729 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18730 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18731 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18732 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18734 /* "no neighbor activate" commands. */
18735 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18736 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18737 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18738 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18739 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18740 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18741 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18742 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18743 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18744 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18745 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18746 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18748 /* "neighbor peer-group" set commands. */
18749 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18750 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18751 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18752 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18753 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18754 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18755 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18756 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18757 install_element(BGP_FLOWSPECV4_NODE
,
18758 &neighbor_set_peer_group_hidden_cmd
);
18759 install_element(BGP_FLOWSPECV6_NODE
,
18760 &neighbor_set_peer_group_hidden_cmd
);
18762 /* "no neighbor peer-group unset" commands. */
18763 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18764 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18765 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18766 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18767 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18768 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18769 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18770 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18771 install_element(BGP_FLOWSPECV4_NODE
,
18772 &no_neighbor_set_peer_group_hidden_cmd
);
18773 install_element(BGP_FLOWSPECV6_NODE
,
18774 &no_neighbor_set_peer_group_hidden_cmd
);
18776 /* "neighbor softreconfiguration inbound" commands.*/
18777 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18778 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18779 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18780 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18781 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18782 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18783 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18784 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18785 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18786 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18787 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18788 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18789 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18790 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18791 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18792 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18793 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18794 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18795 install_element(BGP_FLOWSPECV4_NODE
,
18796 &neighbor_soft_reconfiguration_cmd
);
18797 install_element(BGP_FLOWSPECV4_NODE
,
18798 &no_neighbor_soft_reconfiguration_cmd
);
18799 install_element(BGP_FLOWSPECV6_NODE
,
18800 &neighbor_soft_reconfiguration_cmd
);
18801 install_element(BGP_FLOWSPECV6_NODE
,
18802 &no_neighbor_soft_reconfiguration_cmd
);
18803 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18804 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18806 /* "neighbor attribute-unchanged" commands. */
18807 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18808 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18809 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18810 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18811 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18812 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18813 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18814 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18815 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18816 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18817 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18818 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18819 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18820 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18821 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18822 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18823 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18824 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18826 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18827 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18829 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18830 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18831 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18832 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18834 /* "nexthop-local unchanged" commands */
18835 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18836 install_element(BGP_IPV6_NODE
,
18837 &no_neighbor_nexthop_local_unchanged_cmd
);
18839 /* "neighbor next-hop-self" commands. */
18840 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18841 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18842 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18843 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18844 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18845 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18846 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18847 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18848 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18849 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18850 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18851 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18852 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18853 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18854 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18855 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18856 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18857 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18858 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18859 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18861 /* "neighbor next-hop-self force" commands. */
18862 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18863 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18864 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18865 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18866 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18867 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18868 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18869 install_element(BGP_IPV4_NODE
,
18870 &no_neighbor_nexthop_self_all_hidden_cmd
);
18871 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18872 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18873 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18874 install_element(BGP_IPV4M_NODE
,
18875 &no_neighbor_nexthop_self_all_hidden_cmd
);
18876 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18877 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18878 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18879 install_element(BGP_IPV4L_NODE
,
18880 &no_neighbor_nexthop_self_all_hidden_cmd
);
18881 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18882 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18883 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18884 install_element(BGP_IPV6_NODE
,
18885 &no_neighbor_nexthop_self_all_hidden_cmd
);
18886 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18887 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18888 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18889 install_element(BGP_IPV6M_NODE
,
18890 &no_neighbor_nexthop_self_all_hidden_cmd
);
18891 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18892 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18893 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18894 install_element(BGP_IPV6L_NODE
,
18895 &no_neighbor_nexthop_self_all_hidden_cmd
);
18896 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18897 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18898 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18899 install_element(BGP_VPNV4_NODE
,
18900 &no_neighbor_nexthop_self_all_hidden_cmd
);
18901 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18902 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18903 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18904 install_element(BGP_VPNV6_NODE
,
18905 &no_neighbor_nexthop_self_all_hidden_cmd
);
18906 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18907 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18909 /* "neighbor as-override" commands. */
18910 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18911 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18912 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18913 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18914 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18915 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18916 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18917 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18918 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18919 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18920 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18921 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18922 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18923 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18924 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18925 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18926 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18927 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18929 /* "neighbor remove-private-AS" commands. */
18930 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18931 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18932 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18933 install_element(BGP_NODE
,
18934 &no_neighbor_remove_private_as_all_hidden_cmd
);
18935 install_element(BGP_NODE
,
18936 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18937 install_element(BGP_NODE
,
18938 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18939 install_element(BGP_NODE
,
18940 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18943 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18944 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18945 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18946 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18947 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18948 install_element(BGP_IPV4_NODE
,
18949 &neighbor_remove_private_as_replace_as_cmd
);
18950 install_element(BGP_IPV4_NODE
,
18951 &no_neighbor_remove_private_as_replace_as_cmd
);
18952 install_element(BGP_IPV4_NODE
,
18953 &neighbor_remove_private_as_all_replace_as_cmd
);
18954 install_element(BGP_IPV4_NODE
,
18955 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18956 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18957 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18958 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18959 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18960 install_element(BGP_IPV4M_NODE
,
18961 &neighbor_remove_private_as_replace_as_cmd
);
18962 install_element(BGP_IPV4M_NODE
,
18963 &no_neighbor_remove_private_as_replace_as_cmd
);
18964 install_element(BGP_IPV4M_NODE
,
18965 &neighbor_remove_private_as_all_replace_as_cmd
);
18966 install_element(BGP_IPV4M_NODE
,
18967 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18968 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18969 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18970 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18971 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18972 install_element(BGP_IPV4L_NODE
,
18973 &neighbor_remove_private_as_replace_as_cmd
);
18974 install_element(BGP_IPV4L_NODE
,
18975 &no_neighbor_remove_private_as_replace_as_cmd
);
18976 install_element(BGP_IPV4L_NODE
,
18977 &neighbor_remove_private_as_all_replace_as_cmd
);
18978 install_element(BGP_IPV4L_NODE
,
18979 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18980 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18981 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18982 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18983 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18984 install_element(BGP_IPV6_NODE
,
18985 &neighbor_remove_private_as_replace_as_cmd
);
18986 install_element(BGP_IPV6_NODE
,
18987 &no_neighbor_remove_private_as_replace_as_cmd
);
18988 install_element(BGP_IPV6_NODE
,
18989 &neighbor_remove_private_as_all_replace_as_cmd
);
18990 install_element(BGP_IPV6_NODE
,
18991 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18992 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18993 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18994 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18995 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18996 install_element(BGP_IPV6M_NODE
,
18997 &neighbor_remove_private_as_replace_as_cmd
);
18998 install_element(BGP_IPV6M_NODE
,
18999 &no_neighbor_remove_private_as_replace_as_cmd
);
19000 install_element(BGP_IPV6M_NODE
,
19001 &neighbor_remove_private_as_all_replace_as_cmd
);
19002 install_element(BGP_IPV6M_NODE
,
19003 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19004 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19005 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19006 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19007 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19008 install_element(BGP_IPV6L_NODE
,
19009 &neighbor_remove_private_as_replace_as_cmd
);
19010 install_element(BGP_IPV6L_NODE
,
19011 &no_neighbor_remove_private_as_replace_as_cmd
);
19012 install_element(BGP_IPV6L_NODE
,
19013 &neighbor_remove_private_as_all_replace_as_cmd
);
19014 install_element(BGP_IPV6L_NODE
,
19015 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19016 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19017 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19018 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19019 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19020 install_element(BGP_VPNV4_NODE
,
19021 &neighbor_remove_private_as_replace_as_cmd
);
19022 install_element(BGP_VPNV4_NODE
,
19023 &no_neighbor_remove_private_as_replace_as_cmd
);
19024 install_element(BGP_VPNV4_NODE
,
19025 &neighbor_remove_private_as_all_replace_as_cmd
);
19026 install_element(BGP_VPNV4_NODE
,
19027 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19028 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19029 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19030 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19031 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19032 install_element(BGP_VPNV6_NODE
,
19033 &neighbor_remove_private_as_replace_as_cmd
);
19034 install_element(BGP_VPNV6_NODE
,
19035 &no_neighbor_remove_private_as_replace_as_cmd
);
19036 install_element(BGP_VPNV6_NODE
,
19037 &neighbor_remove_private_as_all_replace_as_cmd
);
19038 install_element(BGP_VPNV6_NODE
,
19039 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19041 /* "neighbor send-community" commands.*/
19042 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19043 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19044 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19045 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19046 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19047 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19048 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19049 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19050 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19051 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19052 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19053 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19054 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19055 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19056 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19057 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19058 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19059 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19060 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19061 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19062 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19063 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19064 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19065 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19066 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19067 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19068 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19069 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19070 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19071 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19072 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19073 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19075 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19076 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19077 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19079 /* "neighbor route-reflector" commands.*/
19080 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19081 install_element(BGP_NODE
,
19082 &no_neighbor_route_reflector_client_hidden_cmd
);
19083 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19084 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19085 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19086 install_element(BGP_IPV4M_NODE
,
19087 &no_neighbor_route_reflector_client_cmd
);
19088 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19089 install_element(BGP_IPV4L_NODE
,
19090 &no_neighbor_route_reflector_client_cmd
);
19091 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19092 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19093 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19094 install_element(BGP_IPV6M_NODE
,
19095 &no_neighbor_route_reflector_client_cmd
);
19096 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19097 install_element(BGP_IPV6L_NODE
,
19098 &no_neighbor_route_reflector_client_cmd
);
19099 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19100 install_element(BGP_VPNV4_NODE
,
19101 &no_neighbor_route_reflector_client_cmd
);
19102 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19103 install_element(BGP_VPNV6_NODE
,
19104 &no_neighbor_route_reflector_client_cmd
);
19105 install_element(BGP_FLOWSPECV4_NODE
,
19106 &neighbor_route_reflector_client_cmd
);
19107 install_element(BGP_FLOWSPECV4_NODE
,
19108 &no_neighbor_route_reflector_client_cmd
);
19109 install_element(BGP_FLOWSPECV6_NODE
,
19110 &neighbor_route_reflector_client_cmd
);
19111 install_element(BGP_FLOWSPECV6_NODE
,
19112 &no_neighbor_route_reflector_client_cmd
);
19113 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19114 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19116 /* "neighbor route-server" commands.*/
19117 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19118 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19119 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19120 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19121 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19122 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19123 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19124 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19125 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19126 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19127 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19128 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19129 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19130 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19131 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19132 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19133 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19134 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19135 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19136 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19137 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19138 install_element(BGP_FLOWSPECV4_NODE
,
19139 &no_neighbor_route_server_client_cmd
);
19140 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19141 install_element(BGP_FLOWSPECV6_NODE
,
19142 &no_neighbor_route_server_client_cmd
);
19144 /* "neighbor addpath-tx-all-paths" commands.*/
19145 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19146 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19147 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19148 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19149 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19150 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19151 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19152 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19153 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19154 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19155 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19156 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19157 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19158 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19159 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19160 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19161 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19162 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19164 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19165 install_element(BGP_NODE
,
19166 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19167 install_element(BGP_NODE
,
19168 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19169 install_element(BGP_IPV4_NODE
,
19170 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19171 install_element(BGP_IPV4_NODE
,
19172 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19173 install_element(BGP_IPV4M_NODE
,
19174 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19175 install_element(BGP_IPV4M_NODE
,
19176 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19177 install_element(BGP_IPV4L_NODE
,
19178 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19179 install_element(BGP_IPV4L_NODE
,
19180 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19181 install_element(BGP_IPV6_NODE
,
19182 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19183 install_element(BGP_IPV6_NODE
,
19184 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19185 install_element(BGP_IPV6M_NODE
,
19186 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19187 install_element(BGP_IPV6M_NODE
,
19188 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19189 install_element(BGP_IPV6L_NODE
,
19190 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19191 install_element(BGP_IPV6L_NODE
,
19192 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19193 install_element(BGP_VPNV4_NODE
,
19194 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19195 install_element(BGP_VPNV4_NODE
,
19196 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19197 install_element(BGP_VPNV6_NODE
,
19198 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19199 install_element(BGP_VPNV6_NODE
,
19200 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19202 /* "neighbor sender-as-path-loop-detection" commands. */
19203 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19204 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19206 /* "neighbor passive" commands. */
19207 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19208 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19211 /* "neighbor shutdown" commands. */
19212 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19213 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19214 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19215 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19216 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19217 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19219 /* "neighbor capability extended-nexthop" commands.*/
19220 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19221 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19223 /* "neighbor capability orf prefix-list" commands.*/
19224 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19225 install_element(BGP_NODE
,
19226 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19227 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19228 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19229 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19230 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19231 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19232 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19233 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19234 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19235 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19236 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19237 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19238 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19240 /* "neighbor capability dynamic" commands.*/
19241 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19242 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19244 /* "neighbor dont-capability-negotiate" commands. */
19245 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19246 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19248 /* "neighbor ebgp-multihop" commands. */
19249 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19250 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19251 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19253 /* "neighbor disable-connected-check" commands. */
19254 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19255 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19257 /* "neighbor enforce-first-as" commands. */
19258 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19259 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19261 /* "neighbor description" commands. */
19262 install_element(BGP_NODE
, &neighbor_description_cmd
);
19263 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19264 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19266 /* "neighbor update-source" commands. "*/
19267 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19268 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19270 /* "neighbor default-originate" commands. */
19271 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19272 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19273 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19274 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19275 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19276 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19277 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19278 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19279 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19280 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19281 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19282 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19283 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19284 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19285 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19286 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19287 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19288 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19289 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19290 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19291 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19293 /* "neighbor port" commands. */
19294 install_element(BGP_NODE
, &neighbor_port_cmd
);
19295 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19297 /* "neighbor weight" commands. */
19298 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19299 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19301 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19302 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19303 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19304 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19305 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19306 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19307 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19308 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19309 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19310 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19311 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19312 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19313 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19314 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19315 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19316 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19318 /* "neighbor override-capability" commands. */
19319 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19320 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19322 /* "neighbor strict-capability-match" commands. */
19323 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19324 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19326 /* "neighbor timers" commands. */
19327 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19328 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19330 /* "neighbor timers connect" commands. */
19331 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19332 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19334 /* "neighbor timers delayopen" commands. */
19335 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19336 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19338 /* "neighbor advertisement-interval" commands. */
19339 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19340 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19342 /* "neighbor interface" commands. */
19343 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19344 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19346 /* "neighbor distribute" commands. */
19347 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19348 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19349 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19350 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19351 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19352 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19353 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19354 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19355 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19356 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19357 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19358 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19359 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19360 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19361 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19362 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19363 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19364 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19366 /* "neighbor prefix-list" commands. */
19367 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19368 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19369 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19370 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19371 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19372 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19373 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19374 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19375 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19376 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19377 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19379 /* "neighbor filter-list" commands. */
19380 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19381 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19382 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19383 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19384 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19385 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19386 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19387 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19388 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19389 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19390 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19391 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19392 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19393 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19394 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19395 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19396 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19397 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19398 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19399 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19400 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19401 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19403 /* "neighbor route-map" commands. */
19404 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19405 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19406 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19407 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19408 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19409 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19410 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19411 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19412 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19413 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19414 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19416 /* "neighbor unsuppress-map" commands. */
19417 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19418 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19419 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19420 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19421 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19422 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19423 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19424 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19425 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19426 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19427 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19428 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19429 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19430 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19431 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19432 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19433 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19434 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19436 /* "neighbor advertise-map" commands. */
19437 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19438 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19439 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19440 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19441 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19442 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19443 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19444 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19445 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19447 /* neighbor maximum-prefix-out commands. */
19448 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19449 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19450 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19451 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19452 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19453 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19454 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19455 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19456 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19457 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19458 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19459 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19460 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19461 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19462 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19463 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19464 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19465 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19467 /* "neighbor maximum-prefix" commands. */
19468 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19469 install_element(BGP_NODE
,
19470 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19471 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19472 install_element(BGP_NODE
,
19473 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19474 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19475 install_element(BGP_NODE
,
19476 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19477 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19478 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19479 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19480 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19481 install_element(BGP_IPV4_NODE
,
19482 &neighbor_maximum_prefix_threshold_warning_cmd
);
19483 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19484 install_element(BGP_IPV4_NODE
,
19485 &neighbor_maximum_prefix_threshold_restart_cmd
);
19486 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19487 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19488 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19489 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19490 install_element(BGP_IPV4M_NODE
,
19491 &neighbor_maximum_prefix_threshold_warning_cmd
);
19492 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19493 install_element(BGP_IPV4M_NODE
,
19494 &neighbor_maximum_prefix_threshold_restart_cmd
);
19495 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19496 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19497 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19498 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19499 install_element(BGP_IPV4L_NODE
,
19500 &neighbor_maximum_prefix_threshold_warning_cmd
);
19501 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19502 install_element(BGP_IPV4L_NODE
,
19503 &neighbor_maximum_prefix_threshold_restart_cmd
);
19504 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19505 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19506 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19507 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19508 install_element(BGP_IPV6_NODE
,
19509 &neighbor_maximum_prefix_threshold_warning_cmd
);
19510 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19511 install_element(BGP_IPV6_NODE
,
19512 &neighbor_maximum_prefix_threshold_restart_cmd
);
19513 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19514 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19515 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19516 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19517 install_element(BGP_IPV6M_NODE
,
19518 &neighbor_maximum_prefix_threshold_warning_cmd
);
19519 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19520 install_element(BGP_IPV6M_NODE
,
19521 &neighbor_maximum_prefix_threshold_restart_cmd
);
19522 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19523 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19524 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19525 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19526 install_element(BGP_IPV6L_NODE
,
19527 &neighbor_maximum_prefix_threshold_warning_cmd
);
19528 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19529 install_element(BGP_IPV6L_NODE
,
19530 &neighbor_maximum_prefix_threshold_restart_cmd
);
19531 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19532 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19533 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19534 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19535 install_element(BGP_VPNV4_NODE
,
19536 &neighbor_maximum_prefix_threshold_warning_cmd
);
19537 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19538 install_element(BGP_VPNV4_NODE
,
19539 &neighbor_maximum_prefix_threshold_restart_cmd
);
19540 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19541 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19542 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19543 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19544 install_element(BGP_VPNV6_NODE
,
19545 &neighbor_maximum_prefix_threshold_warning_cmd
);
19546 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19547 install_element(BGP_VPNV6_NODE
,
19548 &neighbor_maximum_prefix_threshold_restart_cmd
);
19549 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19551 /* "neighbor allowas-in" */
19552 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19553 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19554 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19555 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19556 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19557 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19558 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19559 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19560 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19561 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19562 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19563 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19564 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19565 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19566 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19567 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19568 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19569 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19570 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19571 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19573 /* "neighbor dampening" commands. */
19574 install_element(BGP_NODE
, &neighbor_damp_cmd
);
19575 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
19576 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
19577 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
19578 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
19579 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
19580 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
19581 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
19582 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
19583 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
19584 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
19585 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
19586 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
19587 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
19588 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
19590 /* address-family commands. */
19591 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19592 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19593 #ifdef KEEP_OLD_VPN_COMMANDS
19594 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19595 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19596 #endif /* KEEP_OLD_VPN_COMMANDS */
19598 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19600 /* "exit-address-family" command. */
19601 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19602 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19603 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19604 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19605 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19606 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19607 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19608 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19609 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19610 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19611 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19613 /* "clear ip bgp commands" */
19614 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19616 /* clear ip bgp prefix */
19617 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19618 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19619 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19621 /* "show [ip] bgp summary" commands. */
19622 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19623 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19624 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19625 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19626 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19627 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19628 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19630 /* "show [ip] bgp neighbors" commands. */
19631 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19633 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19635 /* "show [ip] bgp peer-group" commands. */
19636 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19638 /* "show [ip] bgp paths" commands. */
19639 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19641 /* "show [ip] bgp community" commands. */
19642 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19644 /* "show ip bgp large-community" commands. */
19645 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19646 /* "show [ip] bgp attribute-info" commands. */
19647 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19648 /* "show [ip] bgp route-leak" command */
19649 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19651 /* "redistribute" commands. */
19652 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19653 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19654 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19655 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19656 install_element(BGP_NODE
,
19657 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19658 install_element(BGP_NODE
,
19659 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19660 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19661 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19662 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19663 install_element(BGP_NODE
,
19664 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19665 install_element(BGP_NODE
,
19666 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19667 install_element(BGP_NODE
,
19668 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19669 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19670 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19671 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19672 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19673 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19674 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19675 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19676 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19677 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19678 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19679 install_element(BGP_IPV4_NODE
,
19680 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19681 install_element(BGP_IPV4_NODE
,
19682 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19683 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19684 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19685 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19686 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19687 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19688 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19690 /* import|export vpn [route-map WORD] */
19691 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19692 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19694 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19695 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19697 /* ttl_security commands */
19698 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19699 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19701 /* "show [ip] bgp memory" commands. */
19702 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19704 /* "show bgp martian next-hop" */
19705 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19707 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19709 /* "show [ip] bgp views" commands. */
19710 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19712 /* "show [ip] bgp vrfs" commands. */
19713 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19715 /* Community-list. */
19716 community_list_vty();
19718 community_alias_vty();
19720 /* vpn-policy commands */
19721 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19722 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19723 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19724 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19725 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19726 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19727 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19728 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19729 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19730 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19731 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19732 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19734 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19735 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19737 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19738 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19739 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19740 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19741 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19742 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19743 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19744 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19745 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19746 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19748 /* tcp-mss command */
19749 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19750 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19752 /* srv6 commands */
19753 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19754 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19755 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19756 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19757 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19760 #include "memory.h"
19761 #include "bgp_regex.h"
19762 #include "bgp_clist.h"
19763 #include "bgp_ecommunity.h"
19765 /* VTY functions. */
19767 /* Direction value to string conversion. */
19768 static const char *community_direct_str(int direct
)
19771 case COMMUNITY_DENY
:
19773 case COMMUNITY_PERMIT
:
19780 /* Display error string. */
19781 static void community_list_perror(struct vty
*vty
, int ret
)
19784 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19785 vty_out(vty
, "%% Can't find community-list\n");
19787 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19788 vty_out(vty
, "%% Malformed community-list value\n");
19790 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19792 "%% Community name conflict, previously defined as standard community\n");
19794 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19796 "%% Community name conflict, previously defined as expanded community\n");
19801 /* "community-list" keyword help string. */
19802 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19804 /*community-list standard */
19805 DEFUN (community_list_standard
,
19806 bgp_community_list_standard_cmd
,
19807 "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19810 "Community list number (standard)\n"
19811 "Add an standard community-list entry\n"
19812 "Community list name\n"
19813 "Sequence number of an entry\n"
19814 "Sequence number\n"
19815 "Specify community to reject\n"
19816 "Specify community to accept\n"
19819 char *cl_name_or_number
= NULL
;
19822 int style
= COMMUNITY_LIST_STANDARD
;
19825 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19827 seq
= argv
[idx
]->arg
;
19830 argv_find(argv
, argc
, "(1-99)", &idx
);
19831 argv_find(argv
, argc
, "WORD", &idx
);
19832 cl_name_or_number
= argv
[idx
]->arg
;
19833 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19835 argv_find(argv
, argc
, "AA:NN", &idx
);
19836 char *str
= argv_concat(argv
, argc
, idx
);
19838 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19841 XFREE(MTYPE_TMP
, str
);
19844 /* Display error string. */
19845 community_list_perror(vty
, ret
);
19846 return CMD_WARNING_CONFIG_FAILED
;
19849 return CMD_SUCCESS
;
19852 DEFUN (no_community_list_standard_all
,
19853 no_bgp_community_list_standard_all_cmd
,
19854 "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19858 "Community list number (standard)\n"
19859 "Add an standard community-list entry\n"
19860 "Community list name\n"
19861 "Sequence number of an entry\n"
19862 "Sequence number\n"
19863 "Specify community to reject\n"
19864 "Specify community to accept\n"
19867 char *cl_name_or_number
= NULL
;
19870 int style
= COMMUNITY_LIST_STANDARD
;
19874 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19876 seq
= argv
[idx
]->arg
;
19879 argv_find(argv
, argc
, "permit", &idx
);
19880 argv_find(argv
, argc
, "deny", &idx
);
19883 direct
= argv_find(argv
, argc
, "permit", &idx
)
19888 argv_find(argv
, argc
, "AA:NN", &idx
);
19889 str
= argv_concat(argv
, argc
, idx
);
19893 argv_find(argv
, argc
, "(1-99)", &idx
);
19894 argv_find(argv
, argc
, "WORD", &idx
);
19895 cl_name_or_number
= argv
[idx
]->arg
;
19897 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19900 XFREE(MTYPE_TMP
, str
);
19903 community_list_perror(vty
, ret
);
19904 return CMD_WARNING_CONFIG_FAILED
;
19907 return CMD_SUCCESS
;
19910 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19911 "no bgp community-list <(1-99)|standard WORD>",
19912 NO_STR BGP_STR COMMUNITY_LIST_STR
19913 "Community list number (standard)\n"
19914 "Add an standard community-list entry\n"
19915 "Community list name\n")
19917 /*community-list expanded */
19918 DEFUN (community_list_expanded_all
,
19919 bgp_community_list_expanded_all_cmd
,
19920 "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19923 "Community list number (expanded)\n"
19924 "Add an expanded community-list entry\n"
19925 "Community list name\n"
19926 "Sequence number of an entry\n"
19927 "Sequence number\n"
19928 "Specify community to reject\n"
19929 "Specify community to accept\n"
19932 char *cl_name_or_number
= NULL
;
19935 int style
= COMMUNITY_LIST_EXPANDED
;
19938 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19940 seq
= argv
[idx
]->arg
;
19944 argv_find(argv
, argc
, "(100-500)", &idx
);
19945 argv_find(argv
, argc
, "WORD", &idx
);
19946 cl_name_or_number
= argv
[idx
]->arg
;
19947 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19949 argv_find(argv
, argc
, "AA:NN", &idx
);
19950 char *str
= argv_concat(argv
, argc
, idx
);
19952 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19955 XFREE(MTYPE_TMP
, str
);
19958 /* Display error string. */
19959 community_list_perror(vty
, ret
);
19960 return CMD_WARNING_CONFIG_FAILED
;
19963 return CMD_SUCCESS
;
19966 DEFUN (no_community_list_expanded_all
,
19967 no_bgp_community_list_expanded_all_cmd
,
19968 "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19972 "Community list number (expanded)\n"
19973 "Add an expanded community-list entry\n"
19974 "Community list name\n"
19975 "Sequence number of an entry\n"
19976 "Sequence number\n"
19977 "Specify community to reject\n"
19978 "Specify community to accept\n"
19981 char *cl_name_or_number
= NULL
;
19985 int style
= COMMUNITY_LIST_EXPANDED
;
19988 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19990 seq
= argv
[idx
]->arg
;
19993 argv_find(argv
, argc
, "permit", &idx
);
19994 argv_find(argv
, argc
, "deny", &idx
);
19997 direct
= argv_find(argv
, argc
, "permit", &idx
)
20002 argv_find(argv
, argc
, "AA:NN", &idx
);
20003 str
= argv_concat(argv
, argc
, idx
);
20007 argv_find(argv
, argc
, "(100-500)", &idx
);
20008 argv_find(argv
, argc
, "WORD", &idx
);
20009 cl_name_or_number
= argv
[idx
]->arg
;
20011 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20014 XFREE(MTYPE_TMP
, str
);
20017 community_list_perror(vty
, ret
);
20018 return CMD_WARNING_CONFIG_FAILED
;
20021 return CMD_SUCCESS
;
20024 ALIAS(no_community_list_expanded_all
,
20025 no_bgp_community_list_expanded_all_list_cmd
,
20026 "no bgp community-list <(100-500)|expanded WORD>",
20027 NO_STR BGP_STR COMMUNITY_LIST_STR
20028 "Community list number (expanded)\n"
20029 "Add an expanded community-list entry\n"
20030 "Community list name\n")
20032 /* Return configuration string of community-list entry. */
20033 static const char *community_list_config_str(struct community_entry
*entry
)
20040 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20041 str
= community_str(entry
->u
.com
, false);
20042 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20043 str
= lcommunity_str(entry
->u
.lcom
, false);
20045 str
= entry
->config
;
20050 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20052 struct community_entry
*entry
;
20054 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20055 if (entry
== list
->head
) {
20056 if (all_digit(list
->name
))
20057 vty_out(vty
, "Community %s list %s\n",
20058 entry
->style
== COMMUNITY_LIST_STANDARD
20060 : "(expanded) access",
20063 vty_out(vty
, "Named Community %s list %s\n",
20064 entry
->style
== COMMUNITY_LIST_STANDARD
20070 vty_out(vty
, " %s\n",
20071 community_direct_str(entry
->direct
));
20073 vty_out(vty
, " %s %s\n",
20074 community_direct_str(entry
->direct
),
20075 community_list_config_str(entry
));
20079 DEFUN (show_community_list
,
20080 show_bgp_community_list_cmd
,
20081 "show bgp community-list",
20084 "List community-list\n")
20086 struct community_list
*list
;
20087 struct community_list_master
*cm
;
20089 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20091 return CMD_SUCCESS
;
20093 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20094 community_list_show(vty
, list
);
20096 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20097 community_list_show(vty
, list
);
20099 return CMD_SUCCESS
;
20102 DEFUN (show_community_list_arg
,
20103 show_bgp_community_list_arg_cmd
,
20104 "show bgp community-list <(1-500)|WORD> detail",
20107 "List community-list\n"
20108 "Community-list number\n"
20109 "Community-list name\n"
20110 "Detailed information on community-list\n")
20112 int idx_comm_list
= 3;
20113 struct community_list
*list
;
20115 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20116 COMMUNITY_LIST_MASTER
);
20118 vty_out(vty
, "%% Can't find community-list\n");
20119 return CMD_WARNING
;
20122 community_list_show(vty
, list
);
20124 return CMD_SUCCESS
;
20128 * Large Community code.
20130 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20131 struct cmd_token
**argv
, int style
,
20132 int reject_all_digit_name
)
20141 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20142 seq
= argv
[idx
]->arg
;
20145 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20148 /* All digit name check. */
20150 argv_find(argv
, argc
, "WORD", &idx
);
20151 argv_find(argv
, argc
, "(1-99)", &idx
);
20152 argv_find(argv
, argc
, "(100-500)", &idx
);
20153 cl_name
= argv
[idx
]->arg
;
20154 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20155 vty_out(vty
, "%% Community name cannot have all digits\n");
20156 return CMD_WARNING_CONFIG_FAILED
;
20160 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20161 argv_find(argv
, argc
, "LINE", &idx
);
20162 /* Concat community string argument. */
20164 str
= argv_concat(argv
, argc
, idx
);
20168 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20170 /* Free temporary community list string allocated by
20172 XFREE(MTYPE_TMP
, str
);
20175 community_list_perror(vty
, ret
);
20176 return CMD_WARNING_CONFIG_FAILED
;
20178 return CMD_SUCCESS
;
20181 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20182 struct cmd_token
**argv
, int style
)
20190 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20191 seq
= argv
[idx
]->arg
;
20194 argv_find(argv
, argc
, "permit", &idx
);
20195 argv_find(argv
, argc
, "deny", &idx
);
20198 /* Check the list direct. */
20199 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20200 direct
= COMMUNITY_PERMIT
;
20202 direct
= COMMUNITY_DENY
;
20205 argv_find(argv
, argc
, "LINE", &idx
);
20206 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20207 /* Concat community string argument. */
20208 str
= argv_concat(argv
, argc
, idx
);
20212 argv_find(argv
, argc
, "(1-99)", &idx
);
20213 argv_find(argv
, argc
, "(100-500)", &idx
);
20214 argv_find(argv
, argc
, "WORD", &idx
);
20216 /* Unset community list. */
20217 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20220 /* Free temporary community list string allocated by
20222 XFREE(MTYPE_TMP
, str
);
20225 community_list_perror(vty
, ret
);
20226 return CMD_WARNING_CONFIG_FAILED
;
20229 return CMD_SUCCESS
;
20232 /* "large-community-list" keyword help string. */
20233 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20234 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20236 DEFUN (lcommunity_list_standard
,
20237 bgp_lcommunity_list_standard_cmd
,
20238 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20240 LCOMMUNITY_LIST_STR
20241 "Large Community list number (standard)\n"
20242 "Sequence number of an entry\n"
20243 "Sequence number\n"
20244 "Specify large community to reject\n"
20245 "Specify large community to accept\n"
20246 LCOMMUNITY_VAL_STR
)
20248 return lcommunity_list_set_vty(vty
, argc
, argv
,
20249 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20252 DEFUN (lcommunity_list_expanded
,
20253 bgp_lcommunity_list_expanded_cmd
,
20254 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20256 LCOMMUNITY_LIST_STR
20257 "Large Community list number (expanded)\n"
20258 "Sequence number of an entry\n"
20259 "Sequence number\n"
20260 "Specify large community to reject\n"
20261 "Specify large community to accept\n"
20262 "An ordered list as a regular-expression\n")
20264 return lcommunity_list_set_vty(vty
, argc
, argv
,
20265 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20268 DEFUN (lcommunity_list_name_standard
,
20269 bgp_lcommunity_list_name_standard_cmd
,
20270 "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20272 LCOMMUNITY_LIST_STR
20273 "Specify standard large-community-list\n"
20274 "Large Community list name\n"
20275 "Sequence number of an entry\n"
20276 "Sequence number\n"
20277 "Specify large community to reject\n"
20278 "Specify large community to accept\n"
20279 LCOMMUNITY_VAL_STR
)
20281 return lcommunity_list_set_vty(vty
, argc
, argv
,
20282 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20285 DEFUN (lcommunity_list_name_expanded
,
20286 bgp_lcommunity_list_name_expanded_cmd
,
20287 "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
20289 LCOMMUNITY_LIST_STR
20290 "Specify expanded large-community-list\n"
20291 "Large Community list name\n"
20292 "Sequence number of an entry\n"
20293 "Sequence number\n"
20294 "Specify large community to reject\n"
20295 "Specify large community to accept\n"
20296 "An ordered list as a regular-expression\n")
20298 return lcommunity_list_set_vty(vty
, argc
, argv
,
20299 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20302 DEFUN (no_lcommunity_list_all
,
20303 no_bgp_lcommunity_list_all_cmd
,
20304 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
20307 LCOMMUNITY_LIST_STR
20308 "Large Community list number (standard)\n"
20309 "Large Community list number (expanded)\n"
20310 "Large Community list name\n")
20312 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20313 LARGE_COMMUNITY_LIST_STANDARD
);
20316 DEFUN (no_lcommunity_list_name_standard_all
,
20317 no_bgp_lcommunity_list_name_standard_all_cmd
,
20318 "no bgp large-community-list standard WORD",
20321 LCOMMUNITY_LIST_STR
20322 "Specify standard large-community-list\n"
20323 "Large Community list name\n")
20325 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20326 LARGE_COMMUNITY_LIST_STANDARD
);
20329 DEFUN (no_lcommunity_list_name_expanded_all
,
20330 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20331 "no bgp large-community-list expanded WORD",
20334 LCOMMUNITY_LIST_STR
20335 "Specify expanded large-community-list\n"
20336 "Large Community list name\n")
20338 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20339 LARGE_COMMUNITY_LIST_EXPANDED
);
20342 DEFUN (no_lcommunity_list_standard
,
20343 no_bgp_lcommunity_list_standard_cmd
,
20344 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20347 LCOMMUNITY_LIST_STR
20348 "Large Community list number (standard)\n"
20349 "Sequence number of an entry\n"
20350 "Sequence number\n"
20351 "Specify large community to reject\n"
20352 "Specify large community to accept\n"
20353 LCOMMUNITY_VAL_STR
)
20355 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20356 LARGE_COMMUNITY_LIST_STANDARD
);
20359 DEFUN (no_lcommunity_list_expanded
,
20360 no_bgp_lcommunity_list_expanded_cmd
,
20361 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20364 LCOMMUNITY_LIST_STR
20365 "Large Community list number (expanded)\n"
20366 "Sequence number of an entry\n"
20367 "Sequence number\n"
20368 "Specify large community to reject\n"
20369 "Specify large community to accept\n"
20370 "An ordered list as a regular-expression\n")
20372 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20373 LARGE_COMMUNITY_LIST_EXPANDED
);
20376 DEFUN (no_lcommunity_list_name_standard
,
20377 no_bgp_lcommunity_list_name_standard_cmd
,
20378 "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20381 LCOMMUNITY_LIST_STR
20382 "Specify standard large-community-list\n"
20383 "Large Community list name\n"
20384 "Sequence number of an entry\n"
20385 "Sequence number\n"
20386 "Specify large community to reject\n"
20387 "Specify large community to accept\n"
20388 LCOMMUNITY_VAL_STR
)
20390 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20391 LARGE_COMMUNITY_LIST_STANDARD
);
20394 DEFUN (no_lcommunity_list_name_expanded
,
20395 no_bgp_lcommunity_list_name_expanded_cmd
,
20396 "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
20399 LCOMMUNITY_LIST_STR
20400 "Specify expanded large-community-list\n"
20401 "Large community list name\n"
20402 "Sequence number of an entry\n"
20403 "Sequence number\n"
20404 "Specify large community to reject\n"
20405 "Specify large community to accept\n"
20406 "An ordered list as a regular-expression\n")
20408 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20409 LARGE_COMMUNITY_LIST_EXPANDED
);
20412 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20414 struct community_entry
*entry
;
20416 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20417 if (entry
== list
->head
) {
20418 if (all_digit(list
->name
))
20419 vty_out(vty
, "Large community %s list %s\n",
20421 LARGE_COMMUNITY_LIST_STANDARD
20423 : "(expanded) access",
20427 "Named large community %s list %s\n",
20429 LARGE_COMMUNITY_LIST_STANDARD
20435 vty_out(vty
, " %s\n",
20436 community_direct_str(entry
->direct
));
20438 vty_out(vty
, " %s %s\n",
20439 community_direct_str(entry
->direct
),
20440 community_list_config_str(entry
));
20444 DEFUN (show_lcommunity_list
,
20445 show_bgp_lcommunity_list_cmd
,
20446 "show bgp large-community-list",
20449 "List large-community list\n")
20451 struct community_list
*list
;
20452 struct community_list_master
*cm
;
20454 cm
= community_list_master_lookup(bgp_clist
,
20455 LARGE_COMMUNITY_LIST_MASTER
);
20457 return CMD_SUCCESS
;
20459 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20460 lcommunity_list_show(vty
, list
);
20462 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20463 lcommunity_list_show(vty
, list
);
20465 return CMD_SUCCESS
;
20468 DEFUN (show_lcommunity_list_arg
,
20469 show_bgp_lcommunity_list_arg_cmd
,
20470 "show bgp large-community-list <(1-500)|WORD> detail",
20473 "List large-community list\n"
20474 "Large-community-list number\n"
20475 "Large-community-list name\n"
20476 "Detailed information on large-community-list\n")
20478 struct community_list
*list
;
20480 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20481 LARGE_COMMUNITY_LIST_MASTER
);
20483 vty_out(vty
, "%% Can't find large-community-list\n");
20484 return CMD_WARNING
;
20487 lcommunity_list_show(vty
, list
);
20489 return CMD_SUCCESS
;
20492 /* "extcommunity-list" keyword help string. */
20493 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20494 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20496 DEFUN (extcommunity_list_standard
,
20497 bgp_extcommunity_list_standard_cmd
,
20498 "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20500 EXTCOMMUNITY_LIST_STR
20501 "Extended Community list number (standard)\n"
20502 "Specify standard extcommunity-list\n"
20503 "Community list name\n"
20504 "Sequence number of an entry\n"
20505 "Sequence number\n"
20506 "Specify community to reject\n"
20507 "Specify community to accept\n"
20508 EXTCOMMUNITY_VAL_STR
)
20510 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20512 char *cl_number_or_name
= NULL
;
20517 argv_find(argv
, argc
, "(1-99)", &idx
);
20518 argv_find(argv
, argc
, "WORD", &idx
);
20519 cl_number_or_name
= argv
[idx
]->arg
;
20521 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20522 seq
= argv
[idx
]->arg
;
20524 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20526 argv_find(argv
, argc
, "AA:NN", &idx
);
20527 char *str
= argv_concat(argv
, argc
, idx
);
20529 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20532 XFREE(MTYPE_TMP
, str
);
20535 community_list_perror(vty
, ret
);
20536 return CMD_WARNING_CONFIG_FAILED
;
20539 return CMD_SUCCESS
;
20542 DEFUN (extcommunity_list_name_expanded
,
20543 bgp_extcommunity_list_name_expanded_cmd
,
20544 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20546 EXTCOMMUNITY_LIST_STR
20547 "Extended Community list number (expanded)\n"
20548 "Specify expanded extcommunity-list\n"
20549 "Extended Community list name\n"
20550 "Sequence number of an entry\n"
20551 "Sequence number\n"
20552 "Specify community to reject\n"
20553 "Specify community to accept\n"
20554 "An ordered list as a regular-expression\n")
20556 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20558 char *cl_number_or_name
= NULL
;
20562 argv_find(argv
, argc
, "(100-500)", &idx
);
20563 argv_find(argv
, argc
, "WORD", &idx
);
20564 cl_number_or_name
= argv
[idx
]->arg
;
20566 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20567 seq
= argv
[idx
]->arg
;
20569 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20571 argv_find(argv
, argc
, "LINE", &idx
);
20572 char *str
= argv_concat(argv
, argc
, idx
);
20574 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20577 XFREE(MTYPE_TMP
, str
);
20580 community_list_perror(vty
, ret
);
20581 return CMD_WARNING_CONFIG_FAILED
;
20584 return CMD_SUCCESS
;
20587 DEFUN (no_extcommunity_list_standard_all
,
20588 no_bgp_extcommunity_list_standard_all_cmd
,
20589 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20592 EXTCOMMUNITY_LIST_STR
20593 "Extended Community list number (standard)\n"
20594 "Specify standard extcommunity-list\n"
20595 "Community list name\n"
20596 "Sequence number of an entry\n"
20597 "Sequence number\n"
20598 "Specify community to reject\n"
20599 "Specify community to accept\n"
20600 EXTCOMMUNITY_VAL_STR
)
20602 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20604 char *cl_number_or_name
= NULL
;
20609 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20610 seq
= argv
[idx
]->arg
;
20613 argv_find(argv
, argc
, "permit", &idx
);
20614 argv_find(argv
, argc
, "deny", &idx
);
20616 direct
= argv_find(argv
, argc
, "permit", &idx
)
20621 argv_find(argv
, argc
, "AA:NN", &idx
);
20622 str
= argv_concat(argv
, argc
, idx
);
20626 argv_find(argv
, argc
, "(1-99)", &idx
);
20627 argv_find(argv
, argc
, "WORD", &idx
);
20628 cl_number_or_name
= argv
[idx
]->arg
;
20630 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20631 seq
, direct
, style
);
20633 XFREE(MTYPE_TMP
, str
);
20636 community_list_perror(vty
, ret
);
20637 return CMD_WARNING_CONFIG_FAILED
;
20640 return CMD_SUCCESS
;
20643 ALIAS(no_extcommunity_list_standard_all
,
20644 no_bgp_extcommunity_list_standard_all_list_cmd
,
20645 "no bgp extcommunity-list <(1-99)|standard WORD>",
20646 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20647 "Extended Community list number (standard)\n"
20648 "Specify standard extcommunity-list\n"
20649 "Community list name\n")
20651 DEFUN (no_extcommunity_list_expanded_all
,
20652 no_bgp_extcommunity_list_expanded_all_cmd
,
20653 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20656 EXTCOMMUNITY_LIST_STR
20657 "Extended Community list number (expanded)\n"
20658 "Specify expanded extcommunity-list\n"
20659 "Extended Community list name\n"
20660 "Sequence number of an entry\n"
20661 "Sequence number\n"
20662 "Specify community to reject\n"
20663 "Specify community to accept\n"
20664 "An ordered list as a regular-expression\n")
20666 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20668 char *cl_number_or_name
= NULL
;
20673 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20674 seq
= argv
[idx
]->arg
;
20677 argv_find(argv
, argc
, "permit", &idx
);
20678 argv_find(argv
, argc
, "deny", &idx
);
20681 direct
= argv_find(argv
, argc
, "permit", &idx
)
20686 argv_find(argv
, argc
, "LINE", &idx
);
20687 str
= argv_concat(argv
, argc
, idx
);
20691 argv_find(argv
, argc
, "(100-500)", &idx
);
20692 argv_find(argv
, argc
, "WORD", &idx
);
20693 cl_number_or_name
= argv
[idx
]->arg
;
20695 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20696 seq
, direct
, style
);
20698 XFREE(MTYPE_TMP
, str
);
20701 community_list_perror(vty
, ret
);
20702 return CMD_WARNING_CONFIG_FAILED
;
20705 return CMD_SUCCESS
;
20708 ALIAS(no_extcommunity_list_expanded_all
,
20709 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20710 "no bgp extcommunity-list <(100-500)|expanded WORD>",
20711 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20712 "Extended Community list number (expanded)\n"
20713 "Specify expanded extcommunity-list\n"
20714 "Extended Community list name\n")
20716 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20718 struct community_entry
*entry
;
20720 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20721 if (entry
== list
->head
) {
20722 if (all_digit(list
->name
))
20723 vty_out(vty
, "Extended community %s list %s\n",
20724 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20726 : "(expanded) access",
20730 "Named extended community %s list %s\n",
20731 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20737 vty_out(vty
, " %s\n",
20738 community_direct_str(entry
->direct
));
20740 vty_out(vty
, " %s %s\n",
20741 community_direct_str(entry
->direct
),
20742 community_list_config_str(entry
));
20746 DEFUN (show_extcommunity_list
,
20747 show_bgp_extcommunity_list_cmd
,
20748 "show bgp extcommunity-list",
20751 "List extended-community list\n")
20753 struct community_list
*list
;
20754 struct community_list_master
*cm
;
20756 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20758 return CMD_SUCCESS
;
20760 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20761 extcommunity_list_show(vty
, list
);
20763 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20764 extcommunity_list_show(vty
, list
);
20766 return CMD_SUCCESS
;
20769 DEFUN (show_extcommunity_list_arg
,
20770 show_bgp_extcommunity_list_arg_cmd
,
20771 "show bgp extcommunity-list <(1-500)|WORD> detail",
20774 "List extended-community list\n"
20775 "Extcommunity-list number\n"
20776 "Extcommunity-list name\n"
20777 "Detailed information on extcommunity-list\n")
20779 int idx_comm_list
= 3;
20780 struct community_list
*list
;
20782 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20783 EXTCOMMUNITY_LIST_MASTER
);
20785 vty_out(vty
, "%% Can't find extcommunity-list\n");
20786 return CMD_WARNING
;
20789 extcommunity_list_show(vty
, list
);
20791 return CMD_SUCCESS
;
20794 /* Display community-list and extcommunity-list configuration. */
20795 static int community_list_config_write(struct vty
*vty
)
20797 struct community_list
*list
;
20798 struct community_entry
*entry
;
20799 struct community_list_master
*cm
;
20802 /* Community-list. */
20803 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20805 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20806 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20808 "bgp community-list %s seq %" PRId64
" %s %s\n",
20809 list
->name
, entry
->seq
,
20810 community_direct_str(entry
->direct
),
20811 community_list_config_str(entry
));
20814 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20815 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20817 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20818 entry
->style
== COMMUNITY_LIST_STANDARD
20821 list
->name
, entry
->seq
,
20822 community_direct_str(entry
->direct
),
20823 community_list_config_str(entry
));
20827 /* Extcommunity-list. */
20828 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20830 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20831 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20833 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20834 list
->name
, entry
->seq
,
20835 community_direct_str(entry
->direct
),
20836 community_list_config_str(entry
));
20839 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20840 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20842 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20843 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20846 list
->name
, entry
->seq
,
20847 community_direct_str(entry
->direct
),
20848 community_list_config_str(entry
));
20853 /* lcommunity-list. */
20854 cm
= community_list_master_lookup(bgp_clist
,
20855 LARGE_COMMUNITY_LIST_MASTER
);
20857 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20858 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20860 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20861 list
->name
, entry
->seq
,
20862 community_direct_str(entry
->direct
),
20863 community_list_config_str(entry
));
20866 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20867 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20869 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20871 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20874 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20875 community_list_config_str(entry
));
20882 static int community_list_config_write(struct vty
*vty
);
20883 static struct cmd_node community_list_node
= {
20884 .name
= "community list",
20885 .node
= COMMUNITY_LIST_NODE
,
20887 .config_write
= community_list_config_write
,
20890 static void community_list_vty(void)
20892 install_node(&community_list_node
);
20894 /* Community-list. */
20895 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20896 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20897 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20898 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20899 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20900 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20901 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20902 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20904 /* Extcommunity-list. */
20905 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20906 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20907 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20908 install_element(CONFIG_NODE
,
20909 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20910 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20911 install_element(CONFIG_NODE
,
20912 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20913 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20914 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20916 /* Large Community List */
20917 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20918 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20919 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20920 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20921 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20922 install_element(CONFIG_NODE
,
20923 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20924 install_element(CONFIG_NODE
,
20925 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20926 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20927 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20928 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20929 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20930 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20931 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20934 static struct cmd_node community_alias_node
= {
20935 .name
= "community alias",
20936 .node
= COMMUNITY_ALIAS_NODE
,
20938 .config_write
= bgp_community_alias_write
,
20941 void community_alias_vty(void)
20943 install_node(&community_alias_node
);
20945 /* Community-list. */
20946 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);